47 #include <G4String.hh>
62 vetoCounterEDLeft( 0 ), vetoCounterEDRight( 0 ),
63 calorimeterEDLeft( 0 ), calorimeterEDRight( 0 ),
64 calorimeterEDLeftMaxX( 0 ), calorimeterEDLeftMaxY( 0 ),
65 calorimeterEDRightMaxX( 0 ), calorimeterEDRightMaxY( 0 ),
66 monitorHasTriggered( false ), hasTriggered( false ),
67 monitorEDThreshold( 0 ),
68 vetoCounterEDLeftThreshold( 0 ), vetoCounterEDRightThreshold( 0 ),
69 calorimeterEDLeftThreshold( 0 ), calorimeterEDRightThreshold( 0 ),
72 outerCrystalsVetoFraction( 0 ), monitorEDThresholdRef( 0 ),
73 vetoCounterEDLeftThresholdRef( 0 ), vetoCounterEDRightThresholdRef( 0 ),
74 calorimeterEDLeftThresholdRef( 0 ), calorimeterEDRightThresholdRef( 0 ),
77 outerCrystalsVetoFractionRef( 0 ), nCrystalsInColumn( 1 ),
78 nCrystalsInRow( 1 ), applyFiniteCrystalResolution( false ),
82 const CexmcSetup * setup( static_cast< const CexmcSetup * >(
87 nCrystalsInColumn = calorimeterGeometry.nCrystalsInColumn;
88 nCrystalsInRow = calorimeterGeometry.nCrystalsInRow;
90 if ( nCrystalsInColumn > 0 )
92 calorimeterEDLeftCollection.resize( nCrystalsInColumn );
93 calorimeterEDRightCollection.resize( nCrystalsInColumn );
96 if ( nCrystalsInRow > 0 )
98 for ( CexmcEnergyDepositCalorimeterCollection::iterator
99 k( calorimeterEDLeftCollection.begin() );
100 k != calorimeterEDLeftCollection.end(); ++k )
102 k->resize( nCrystalsInRow );
104 for ( CexmcEnergyDepositCalorimeterCollection::iterator
105 k( calorimeterEDRightCollection.begin() );
106 k != calorimeterEDRightCollection.end(); ++k )
108 k->resize( nCrystalsInRow );
122 void CexmcEnergyDepositDigitizer::InitializeData(
void )
125 vetoCounterEDLeft = 0;
126 vetoCounterEDRight = 0;
127 calorimeterEDLeft = 0;
128 calorimeterEDRight = 0;
129 calorimeterEDLeftMaxX = 0;
130 calorimeterEDLeftMaxY = 0;
131 calorimeterEDRightMaxX = 0;
132 calorimeterEDRightMaxY = 0;
133 monitorHasTriggered =
false;
134 hasTriggered =
false;
136 for ( CexmcEnergyDepositCalorimeterCollection::iterator
137 k( calorimeterEDLeftCollection.begin() );
138 k != calorimeterEDLeftCollection.end(); ++k )
140 for ( CexmcEnergyDepositCrystalRowCollection::iterator
141 l( k->begin() ); l != k->end(); ++l )
146 for ( CexmcEnergyDepositCalorimeterCollection::iterator
147 k( calorimeterEDRightCollection.begin() );
148 k != calorimeterEDRightCollection.end(); ++k )
150 for ( CexmcEnergyDepositCrystalRowCollection::iterator
151 l( k->begin() ); l != k->end(); ++l )
168 hitsCollection( static_cast< const CexmcEnergyDepositCollection * >(
171 if ( hitsCollection )
174 if ( ( *hitsCollection )[ 0 ] )
175 monitorED = *( *hitsCollection )[ 0 ];
183 if ( hitsCollection )
185 for ( CexmcEnergyDepositCollectionData::iterator
186 k( hitsCollection->GetMap()->begin() );
187 k != hitsCollection->GetMap()->end(); ++k )
195 vetoCounterEDLeft = *k->second;
198 vetoCounterEDRight = *k->second;
221 if ( hitsCollection )
223 for ( CexmcEnergyDepositCollectionData::iterator
224 k( hitsCollection->GetMap()->begin() );
225 k != hitsCollection->GetMap()->end(); ++k )
234 if ( applyFiniteCrystalResolution && value > 0. &&
237 for ( CexmcEnergyRangeWithDoubleValueList::const_iterator
238 l( crystalResolutionData.begin() );
239 l != crystalResolutionData.end(); ++l )
253 if ( value > maxEDCrystalLeft )
255 calorimeterEDLeftMaxX = column;
256 calorimeterEDLeftMaxY = row;
257 maxEDCrystalLeft =
value;
261 outerCrystalsEDLeft +=
value;
265 innerCrystalsEDLeft +=
value;
267 calorimeterEDLeft +=
value;
268 calorimeterEDLeftCollection[ row ][ column ] =
value;
271 if ( value > maxEDCrystalRight )
273 calorimeterEDRightMaxX = column;
274 calorimeterEDRightMaxY = row;
275 maxEDCrystalRight =
value;
279 outerCrystalsEDRight +=
value;
283 innerCrystalsEDRight +=
value;
285 calorimeterEDRight +=
value;
286 calorimeterEDRightCollection[ row ][ column ] =
value;
294 G4double calorimeterEDLeftEffective( calorimeterEDLeft );
295 G4double calorimeterEDRightEffective( calorimeterEDRight );
297 if ( calorimeterTriggerAlgorithm ==
300 calorimeterEDLeftEffective = innerCrystalsEDLeft;
301 calorimeterEDRightEffective = innerCrystalsEDRight;
304 monitorHasTriggered = monitorED >= monitorEDThreshold;
306 hasTriggered = monitorHasTriggered &&
307 vetoCounterEDLeft < vetoCounterEDLeftThreshold &&
308 vetoCounterEDRight < vetoCounterEDRightThreshold &&
309 calorimeterEDLeftEffective >= calorimeterEDLeftThreshold &&
310 calorimeterEDRightEffective >= calorimeterEDRightThreshold;
315 switch ( outerCrystalsVetoAlgorithm )
322 calorimeterEDLeftMaxY ) &&
324 calorimeterEDRightMaxY );
328 ( ( outerCrystalsEDLeft / calorimeterEDLeft ) <
329 outerCrystalsVetoFraction ) &&
330 ( ( outerCrystalsEDRight / calorimeterEDRight ) <
331 outerCrystalsVetoFraction );
343 std::streamsize prec( out.precision() );
348 for ( CexmcEnergyDepositCalorimeterCollection::const_reverse_iterator
349 k( edCollection.rbegin() ); k != edCollection.rend(); ++k )
351 for ( CexmcEnergyDepositCrystalRowCollection::const_reverse_iterator
352 l( k->rbegin() ); l != k->rend(); ++l )
353 out << std::setw( 10 ) << *l;
357 out.precision( prec );
ThreeVector shoot(const G4int Ap, const G4int Af)
const G4VUserDetectorConstruction * GetUserDetectorConstruction() const
static G4int GetColumn(G4int index)
CexmcEnergyDepositDigitizer(const G4String &name)
const G4String CexmcDetectorTypeName[CexmcNumberOfDetectorTypes]
static G4DigiManager * GetDMpointer()
const G4VHitsCollection * GetHitsCollection(G4int HCID, G4int eventID=0)
G4bool ProjectIsRead(void) const
G4bool IsOuterCrystal(G4int column, G4int row) const
std::vector< CexmcEnergyDepositCrystalRowCollection > CexmcEnergyDepositCalorimeterCollection
G4int GetHitsCollectionID(G4String HCname)
const G4String CexmcDetectorRoleName[CexmcNumberOfDetectorRoles]
static G4int GetRow(G4int index)
static G4RunManager * GetRunManager()
~CexmcEnergyDepositDigitizer()
std::ostream & operator<<(std::ostream &, const BasicVector3D< float > &)
const CalorimeterGeometryData & GetCalorimeterGeometry(void) const
const G4double CexmcFwhmToStddev(0.42466)
static CexmcSide GetSide(G4int index)
const XML_Char int const XML_Char * value