ATLAS Offline Software
Loading...
Searching...
No Matches
CscDigitizationTool Class Reference

#include <CscDigitizationTool.h>

Inheritance diagram for CscDigitizationTool:

Public Member Functions

 CscDigitizationTool (const std::string &type, const std::string &name, const IInterface *pIID)
 ~CscDigitizationTool ()=default
virtual StatusCode initialize () override final
virtual StatusCode mergeEvent (const EventContext &ctx) override final
 called at the end of the subevts loop. Not (necessarily) able to access subEvents
virtual StatusCode processBunchXing (int bunchXing, SubEventIterator bSubEvents, SubEventIterator eSubEvents) override final
 called for each active bunch-crossing to process current subEvents. bunchXing is in ns
virtual StatusCode prepareEvent (const EventContext &ctx, unsigned int) override final
 return false if not interested in certain xing times (in ns) implemented by default in PileUpToolBase as FirstXing<=bunchXing<=LastXing
virtual StatusCode processAllSubEvents (const EventContext &ctx) override final
 alternative interface which uses the PileUpMergeSvc to obtain all the required SubEvents.

Private Types

typedef std::vector< CscSimData::Depositdeposits
typedef std::map< IdentifierHash, std::pair< double, double > > csc_map
typedef std::map< IdentifierHash, std::vector< float > > csc_newmap
using Collections_t = std::vector<std::unique_ptr<CscDigitCollection> >

Private Member Functions

StatusCode FillCollectionWithNewDigitEDM (csc_newmap &data_SampleMap, std::map< IdentifierHash, deposits > &myDeposits, bool phaseToSet, Collections_t &collections, CscSimDataCollection *cscSimData)
StatusCode FillCollectionWithOldDigitEDM (csc_map &data_map, std::map< IdentifierHash, deposits > &myDeposits, Collections_t &collections, CscSimDataCollection *cscSimData)
StatusCode CoreDigitization (Collections_t &collections, CscSimDataCollection *cscSimData, CLHEP::HepRandomEngine *rndmEngine, const EventContext &ctx)
StatusCode getNextEvent (const EventContext &ctx)

Private Attributes

ToolHandle< ICscCalibToolm_pcalib {this, "cscCalibTool", "CscCalibTool", "CSC calibration tool"}
BooleanProperty m_onlyUseContainerName {this, "OnlyUseContainerName", true, "Don't use the ReadHandleKey directly. Just extract the container name from it."}
SG::ReadHandleKey< CSCSimHitCollectionm_hitsContainerKey {this, "InputObjectName", "CSC_Hits", "name of the input objects"}
std::string m_inputObjectName {""}
SG::WriteHandleKey< CscSimDataCollectionm_cscSimDataCollectionWriteHandleKey {this,"CSCSimDataCollectionOutputName","CSC_SDO","WriteHandleKey for Output CscSimDataCollection"}
SG::WriteHandleKey< CscDigitContainerm_cscDigitContainerKey {this,"OutputObjectName","CSC_DIGITS","CSC digit container object"}
std::unique_ptr< CSC_Digitizerm_cscDigitizer {nullptr}
ServiceHandle< Muon::IMuonIdHelperSvcm_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}
Gaudi::Property< double > m_pedestal {this, "pedestal",0.0, ""}
Gaudi::Property< bool > m_maskBadChannel {this, "maskBadChannels", true, ""}
Gaudi::Property< double > m_amplification {this, "amplification", 0.58e5, ""}
TimedHitCollection< CSCSimHit > * m_thpcCSC {nullptr}
std::list< CSCSimHitCollection * > m_cscHitCollList
Gaudi::Property< bool > m_includePileUpTruth {this, "IncludePileUpTruth", true, "Include pile-up truth info"}
Gaudi::Property< double > m_timeWindowLowerOffset {this, "WindowLowerOffset", -25., ""}
Gaudi::Property< double > m_timeWindowUpperOffset {this, "WindowUpperOffset", +25., ""}
Gaudi::Property< bool > m_isPileUp {this, "isPileUp", false, ""}
Gaudi::Property< bool > m_newDigitEDM {this, "NewDigitEDM", true, ""}
Gaudi::Property< double > m_driftVelocity {this, "DriftVelocity", 60, ""}
Gaudi::Property< double > m_electronEnergy {this, "ElectronEnergy", 66, ""}
Gaudi::Property< bool > m_NInterFixed {this, "NInterFixed", false, ""}
ServiceHandle< PileUpMergeSvcm_mergeSvc {this, "PileUpMergeSvc", "PileUpMergeSvc", ""}
ServiceHandle< IAthRNGSvcm_rndmSvc {this, "RndmSvc", "AthRNGSvc", ""}

structors and AlgTool implementation

virtual bool toProcess (int bunchXing) const override
 the method this base class helps implementing
virtual bool filterPassed () const override
 dummy implementation of passing filter
virtual void resetFilter () override
 dummy implementation of filter reset
Gaudi::Property< int > m_firstXing
Gaudi::Property< int > m_lastXing
Gaudi::Property< int > m_vetoPileUpTruthLinks
bool m_filterPassed {true}

Detailed Description

Definition at line 39 of file CscDigitizationTool.h.

Member Typedef Documentation

◆ Collections_t

using CscDigitizationTool::Collections_t = std::vector<std::unique_ptr<CscDigitCollection> >
private

Definition at line 75 of file CscDigitizationTool.h.

◆ csc_map

typedef std::map<IdentifierHash,std::pair<double,double> > CscDigitizationTool::csc_map
private

Definition at line 42 of file CscDigitizationTool.h.

◆ csc_newmap

typedef std::map<IdentifierHash,std::vector<float> > CscDigitizationTool::csc_newmap
private

Definition at line 43 of file CscDigitizationTool.h.

◆ deposits

typedef std::vector<CscSimData::Deposit> CscDigitizationTool::deposits
private

Definition at line 41 of file CscDigitizationTool.h.

Constructor & Destructor Documentation

◆ CscDigitizationTool()

CscDigitizationTool::CscDigitizationTool ( const std::string & type,
const std::string & name,
const IInterface * pIID )

Definition at line 16 of file CscDigitizationTool.cxx.

16 :
17 PileUpToolBase(type, name, pIID) {
18}
PileUpToolBase(const std::string &type, const std::string &name, const IInterface *parent)

◆ ~CscDigitizationTool()

CscDigitizationTool::~CscDigitizationTool ( )
default

Member Function Documentation

◆ CoreDigitization()

StatusCode CscDigitizationTool::CoreDigitization ( Collections_t & collections,
CscSimDataCollection * cscSimData,
CLHEP::HepRandomEngine * rndmEngine,
const EventContext & ctx )
private

Definition at line 138 of file CscDigitizationTool.cxx.

138 {
139
140 std::map <IdentifierHash,deposits> myDeposits;
141 csc_map data_map;
142 csc_newmap data_SampleMap, data_SampleMapOddPhase;
143
145
146 // Perform null check on m_thpcCSC
147 if(!m_thpcCSC) {
148 ATH_MSG_ERROR ( "m_thpcCSC is null" );
149 return StatusCode::FAILURE;
150 }
151
152 // get the iterator pairs for this DetEl
153 while( m_thpcCSC->nextDetectorElement(i, e) ) {
154
155 // Loop over the hits:
156 while (i != e) {
157
158 TimedHitPtr<CSCSimHit> phit(*i++);
159 const CSCSimHit& hit(*phit);
160
161
162 ATH_MSG_DEBUG(hit.print());
163
164
165
166 double globalHitTime(hitTime(phit));
167 double bunchTime(globalHitTime - hit.globalTime());
168
169 // Hit time is the G4 hit time plus the drift time.
170 // Gloabl time add the bnch crossing time to the hit time.
171 ATH_MSG_DEBUG ( "bunch time (ns) " << bunchTime << "globalHitTime (ns) " << globalHitTime << " hit Time (ns) " << hitTime(phit) );
172 m_cscDigitizer->set(bunchTime);
173
174 std::vector<IdentifierHash> hashVec;
176 ? m_cscDigitizer->digitize_hit(&hit, hashVec, data_SampleMap, data_SampleMapOddPhase, rndmEngine)
177 : m_cscDigitizer->digitize_hit(&hit, hashVec, data_map, rndmEngine);
178
179 if (status.isFailure()) {
180 ATH_MSG_ERROR ( "CSC Digitizer Failed to digitize a hit!" );
181 return status;
182 }
183
184 std::vector<IdentifierHash>::const_iterator vecBeg = hashVec.begin();
185 std::vector<IdentifierHash>::const_iterator vecEnd = hashVec.end();
186 // Fetch the energy deposit.
187 const double energy = hit.energyDeposit();
188 // Determine where hit crosses the wire plane (x=0).
189 float ypos = -99999.9;
190 float zpos = ypos;
191 double xi = hit.getHitStart().x();
192 double yi = hit.getHitStart().y();
193 double zi = hit.getHitStart().z();
194 double xf = hit.getHitEnd().x();
195 double yf = hit.getHitEnd().y();
196 double zf = hit.getHitEnd().z();
197 double dx = xf - xi;
198 double dy = yf - yi;
199 double dz = zf - zi;
200 if ( dx>0.0 && xi<=0.0 && xf>=0.0 ) {
201 double f = -xi/dx;
202 ypos = yi + f*dy;
203 zpos = zi + f*dz;
204 }
205
207 hashVec.clear();
208 continue;
209 }
210 const HepMcParticleLink trackLink = HepMcParticleLink::getRedirectedLink(phit->particleLink(), phit.eventId(), ctx); // This link should now correctly resolve to the TruthEvent McEventCollection in the main StoreGateSvc.
211 const auto cscd = CscMcData(energy, ypos, zpos);
212 for (; vecBeg != vecEnd; ++vecBeg) {
213 myDeposits[(*vecBeg)].emplace_back(trackLink,cscd);
214 }
215 hashVec.clear();
216 }
217 }
218
219 // reset the pointer.
220 delete m_thpcCSC;
221 m_thpcCSC=nullptr;
222
223 // now loop over the digit map
224 // build the digits
225 // build the digit collections and record them
226
227 if (m_newDigitEDM) {
228 double flat = CLHEP::RandFlat::shoot(rndmEngine, 0.0,1.0); // for other particles
229 bool phaseToSet = flat<0.5;
230 if (phaseToSet)
231 return FillCollectionWithNewDigitEDM(data_SampleMapOddPhase, myDeposits, phaseToSet, collections, cscSimData);
232 else
233 return FillCollectionWithNewDigitEDM(data_SampleMap, myDeposits, phaseToSet, collections, cscSimData);
234 } else
235 return FillCollectionWithOldDigitEDM(data_map, myDeposits, collections, cscSimData);
236
237}
float hitTime(const AFP_SIDSimHit &hit)
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
bool hit(const std::valarray< int > &ids, int pdgId)
std::map< IdentifierHash, std::vector< float > > csc_newmap
TimedHitCollection< CSCSimHit > * m_thpcCSC
StatusCode FillCollectionWithNewDigitEDM(csc_newmap &data_SampleMap, std::map< IdentifierHash, deposits > &myDeposits, bool phaseToSet, Collections_t &collections, CscSimDataCollection *cscSimData)
StatusCode FillCollectionWithOldDigitEDM(csc_map &data_map, std::map< IdentifierHash, deposits > &myDeposits, Collections_t &collections, CscSimDataCollection *cscSimData)
std::map< IdentifierHash, std::pair< double, double > > csc_map
Gaudi::Property< bool > m_includePileUpTruth
Gaudi::Property< bool > m_newDigitEDM
std::unique_ptr< CSC_Digitizer > m_cscDigitizer
Gaudi::Property< int > m_vetoPileUpTruthLinks
TimedVector::const_iterator const_iterator
::StatusCode StatusCode
StatusCode definition for legacy code.
bool ignoreTruthLink(const T &p, bool vetoPileUp)
Helper function for SDO creation in PileUpTools.
status
Definition merge.py:16

◆ FillCollectionWithNewDigitEDM()

StatusCode CscDigitizationTool::FillCollectionWithNewDigitEDM ( csc_newmap & data_SampleMap,
std::map< IdentifierHash, deposits > & myDeposits,
bool phaseToSet,
Collections_t & collections,
CscSimDataCollection * cscSimData )
private

mask this readout channel if it is a dead channel or a hot channel

Definition at line 240 of file CscDigitizationTool.cxx.

244 {
245
246 CscDigitCollection * collection = nullptr;
247
248 IdContext context = m_idHelperSvc->cscIdHelper().channel_context();
249 IdContext cscContext = m_idHelperSvc->cscIdHelper().module_context();
250
251 Identifier prevId;
252
253 csc_newmap::const_iterator cscMap = data_SampleMap.begin();
254 csc_newmap::const_iterator cscMapEnd = data_SampleMap.end();
255
256 for (; cscMap != cscMapEnd; ++cscMap) {
257 Identifier digitId;
258 IdentifierHash hashId = (*cscMap).first;
259 if (m_idHelperSvc->cscIdHelper().get_id( hashId, digitId, &context ) ) {
260 ATH_MSG_ERROR ( "cannot get CSC channel identifier from hash " << hashId );
261 return StatusCode::FAILURE;
262 }
263
264 Identifier elementId = m_idHelperSvc->cscIdHelper().parentID(digitId);
265 IdentifierHash coll_hash;
266 if (m_idHelperSvc->cscIdHelper().get_hash(elementId, coll_hash, &cscContext)) {
267 ATH_MSG_ERROR ( "Unable to get CSC hash id from CSC Digit collection "
268 << "context begin_index = " << cscContext.begin_index()
269 << " context end_index = " << cscContext.end_index()
270 << " the identifier is \n" << elementId);
271 }
272
273
274 // get the charge
275 double stripCharge = 0.0;
276 double driftTime = 0.0;
277 const std::vector<float> samples = (*cscMap).second;
278
279 unsigned int samplingPhase =0;
280 double samplingTime = m_pcalib->getSamplingTime();
281 m_pcalib->findCharge(samplingTime, samplingPhase, samples, stripCharge, driftTime);
282 driftTime += m_pcalib->getLatency();
283
285 if ( !m_pcalib->isGood( hashId ) && m_maskBadChannel ) {
286 stripCharge = 0.0;
288 }
289
290 int zsec = m_idHelperSvc->cscIdHelper().stationEta(digitId);
291 int phisec = m_idHelperSvc->cscIdHelper().stationPhi(digitId);
292 int istation = m_idHelperSvc->cscIdHelper().stationName(digitId) - 49;
293
294 int wlay = m_idHelperSvc->cscIdHelper().wireLayer(digitId);
295 int measphi = m_idHelperSvc->cscIdHelper().measuresPhi(digitId);
296 int istrip = m_idHelperSvc->cscIdHelper().strip(digitId);
297
298 int sector = zsec*(2*phisec-istation+1);
299
300 auto depositsForHash = myDeposits.find(hashId);
301 if (depositsForHash != myDeposits.end() && !depositsForHash->second.empty()) {
302 depositsForHash->second[0].second.setCharge(stripCharge);
303 cscSimData->insert ( std::make_pair(digitId, CscSimData(depositsForHash->second,0)) );
304 }
305
306 // fill the digit collections in StoreGate
307 // Now, we pass driftTime as well as stripCharge.
308 // SimHIT time should be added to distinguish prompt muons from secondary.... 11/19/2009 WP
309 ATH_MSG_DEBUG ( "NEWDigit sec:measphi:wlay:istr:chg:t(w/latency) "
310 << m_idHelperSvc->cscIdHelper().show_to_string(digitId,&context)
311 << " hash:eleId = " << hashId << " " << elementId << " " << prevId << " "
312 << sector << " " << measphi << " " << wlay << " " << istrip << " "
313 << int(stripCharge+1) << " " << float(driftTime)
314 << " phase=" << phaseToSet
315 << " samps: " << samples[0] << " " << samples[1] << " "
316 << samples[2] << " " << samples[3]
317 );
318
319 if (prevId != elementId) {
320 if (coll_hash >= collections.size()) {
321 collections.resize (coll_hash+1);
322 }
323 collection = collections[coll_hash].get();
324 if (nullptr == collection) {
325 collections[coll_hash] = std::make_unique<CscDigitCollection>(elementId,coll_hash);
326 collection = collections[coll_hash].get();
327 }
328 if (phaseToSet) collection->set_samplingPhase();
329 collection->push_back (std::make_unique<CscDigit>(digitId, samples));
330
331 prevId = elementId;
332 } else {
333 // According to coverity, collection could still be null here.
334 if (!collection) {
335 ATH_MSG_ERROR("Trying to use NULL CscDigitCollection");
336 return StatusCode::FAILURE;
337 }
338
339 if (phaseToSet) collection->set_samplingPhase();
340 collection->push_back (std::make_unique<CscDigit>(digitId, samples));
341 }
342 }
343 return StatusCode::SUCCESS;
344}
Gaudi::Property< double > m_timeWindowUpperOffset
ToolHandle< ICscCalibTool > m_pcalib
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
Gaudi::Property< bool > m_maskBadChannel
const T * get(size_type n) const
Access an element, as an rvalue.
value_type push_back(value_type pElem)
Add an element to the end of the collection.
size_type begin_index() const
Definition IdContext.h:45
size_type end_index() const
Definition IdContext.h:46
@ driftTime
Definition HitInfo.h:43

◆ FillCollectionWithOldDigitEDM()

StatusCode CscDigitizationTool::FillCollectionWithOldDigitEDM ( csc_map & data_map,
std::map< IdentifierHash, deposits > & myDeposits,
Collections_t & collections,
CscSimDataCollection * cscSimData )
private

mask this readout channel if it is a dead channel or a hot channel

Definition at line 347 of file CscDigitizationTool.cxx.

348 {
349
350 CscDigitCollection * collection = nullptr;
351 IdContext context = m_idHelperSvc->cscIdHelper().channel_context();
352 IdContext cscContext = m_idHelperSvc->cscIdHelper().module_context();
353
354 Identifier prevId;
355 csc_map::const_iterator cscMap = data_map.begin();
356 csc_map::const_iterator cscMapEnd = data_map.end();
357 for (; cscMap != cscMapEnd; ++cscMap) {
358 Identifier digitId;
359 IdentifierHash hashId = (*cscMap).first;
360 if (m_idHelperSvc->cscIdHelper().get_id( hashId, digitId, &context ) ) {
361 ATH_MSG_ERROR ( "cannot get CSC channel identifier from hash " << hashId );
362 return StatusCode::FAILURE;
363 }
364
365 // get the charge
366 double stripCharge = 0.0;
367 stripCharge = ((*cscMap).second).second + m_pedestal; // + m_noiseLevel*gaus;
368 double driftTime =((*cscMap).second).first; // SimHIT time is added yet 12/03/2009
369
371 if ( !m_pcalib->isGood( hashId ) && m_maskBadChannel ) {
372 stripCharge = 0.0;
374 }
375
376 ATH_MSG_VERBOSE ( "CSC Digit Id = " << m_idHelperSvc->cscIdHelper().show_to_string(digitId,&context)
377 << " hash = " << hashId
378 << " charge = " << int (stripCharge+1) );
379
380 int zsec = m_idHelperSvc->cscIdHelper().stationEta(digitId);
381 int phisec = m_idHelperSvc->cscIdHelper().stationPhi(digitId);
382 int istation = m_idHelperSvc->cscIdHelper().stationName(digitId) - 49;
383
384 int wlay = m_idHelperSvc->cscIdHelper().wireLayer(digitId);
385 int measphi = m_idHelperSvc->cscIdHelper().measuresPhi(digitId);
386 int istrip = m_idHelperSvc->cscIdHelper().strip(digitId);
387
388 int sector = zsec*(2*phisec-istation+1);
389
390 auto depositsForHash = myDeposits.find(hashId);
391 if (depositsForHash != myDeposits.end() && !depositsForHash->second.empty()) {
392 depositsForHash->second[0].second.setCharge(stripCharge);
393 cscSimData->insert ( std::make_pair(digitId, CscSimData(depositsForHash->second,0)) );
394 }
395
396 // fill the digit collections in StoreGate
397 // Now, we pass driftTime as well as stripCharge.
398 // SimHIT time should be added to distinguish prompt muons from secondary.... 11/19/2009 WP
399 auto newDigit = std::make_unique<CscDigit>(digitId, int(stripCharge+1), float(driftTime) );
400 Identifier elementId = m_idHelperSvc->cscIdHelper().parentID(digitId);
401
402 ATH_MSG_DEBUG ( "CSC Digit sector:measphi:wlay:istrip:charge "
403 << sector << " "
404 << measphi << " " << wlay << " " << istrip
405 << " " << int(stripCharge+1) << " " << float(driftTime) << " " << (newDigit->sampleCharges()).size());
406
407
408 IdentifierHash coll_hash;
409 if (m_idHelperSvc->cscIdHelper().get_hash(elementId, coll_hash, &cscContext)) {
410 ATH_MSG_ERROR ( "Unable to get CSC hash id from CSC Digit collection "
411 << "context begin_index = " << cscContext.begin_index()
412 << " context end_index = " << cscContext.end_index()
413 << " the identifier is \n"<< elementId );
414 }
415
416 if (prevId != elementId) {
417 if (coll_hash >= collections.size()) {
418 collections.resize (coll_hash+1);
419 }
420 collection = collections[coll_hash].get();
421 if (nullptr == collection) {
422 collections[coll_hash] = std::make_unique<CscDigitCollection>(elementId,coll_hash);
423 collection = collections[coll_hash].get();
424 }
425 collection->push_back(std::move(newDigit));
426 prevId = elementId;
427 } else {
428 // According to coverity, collection could still be null here.
429 if (collection) {
430 collection->push_back(std::move(newDigit));
431 } else {
432 ATH_MSG_ERROR("Trying to push back NULL CscDigitCollection");
433 return StatusCode::FAILURE;
434 }
435 }
436 }
437 return StatusCode::SUCCESS;
438}
#define ATH_MSG_VERBOSE(x)
Gaudi::Property< double > m_pedestal

◆ filterPassed()

virtual bool PileUpToolBase::filterPassed ( ) const
inlineoverridevirtualinherited

dummy implementation of passing filter

Definition at line 49 of file PileUpToolBase.h.

49{ return m_filterPassed; }

◆ getNextEvent()

StatusCode CscDigitizationTool::getNextEvent ( const EventContext & ctx)
private

Definition at line 442 of file CscDigitizationTool.cxx.

443{
444
445 // get the container(s)
447
448 // In case of single hits container just load the collection using read handles
450 SG::ReadHandle<CSCSimHitCollection> hitCollection(m_hitsContainerKey, ctx);
451 if (!hitCollection.isValid()) {
452 ATH_MSG_ERROR("Could not get CSCSimHitCollection container " << hitCollection.name() << " from store " << hitCollection.store());
453 return StatusCode::FAILURE;
454 }
455
456 // create a new hits collection
457 m_thpcCSC = new TimedHitCollection<CSCSimHit>{1};
458 m_thpcCSC->insert(0, hitCollection.cptr());
459 ATH_MSG_DEBUG("CSCSimHitCollection found with " << hitCollection->size() << " hits");
460
461 return StatusCode::SUCCESS;
462 }
463
464 //this is a list<pair<time_t, DataLink<CSCSimHitCollection> > >
465 TimedHitCollList hitCollList;
466
467 if (!(m_mergeSvc->retrieveSubEvtsData(m_inputObjectName, hitCollList).isSuccess()) ) {
468 ATH_MSG_ERROR ( "Could not fill TimedHitCollList" );
469 return StatusCode::FAILURE;
470 }
471 if (hitCollList.empty()) {
472 ATH_MSG_ERROR ( "TimedHitCollList has size 0" );
473 return StatusCode::FAILURE;
474 } else {
475 ATH_MSG_DEBUG ( hitCollList.size()
476 << " CSCSimHitCollections with key " << m_inputObjectName
477 << " found" );
478 }
479
480 // create a new hits collection
481 m_thpcCSC = new TimedHitCollection<CSCSimHit>();
482
483 //now merge all collections into one
484 TimedHitCollList::iterator iColl(hitCollList.begin());
485 TimedHitCollList::iterator endColl(hitCollList.end());
486 while (iColl != endColl) {
487 const CSCSimHitCollection* p_collection(iColl->second);
488 m_thpcCSC->insert(iColl->first, p_collection);
489 ATH_MSG_DEBUG ( "CSCSimHitCollection found with "
490 << p_collection->size() << " hits" ); // loop on the hit collections
491 ++iColl;
492 }
493 return StatusCode::SUCCESS;
494}
AtlasHitsVector< CSCSimHit > CSCSimHitCollection
ServiceHandle< PileUpMergeSvc > m_mergeSvc
SG::ReadHandleKey< CSCSimHitCollection > m_hitsContainerKey
BooleanProperty m_onlyUseContainerName
std::list< value_t > type
type of the collection of timed data object

◆ initialize()

StatusCode CscDigitizationTool::initialize ( )
finaloverridevirtual

CSC calibratin tool for the Condtiions Data base access

Reimplemented from PileUpToolBase.

Definition at line 20 of file CscDigitizationTool.cxx.

20 {
21
22 ATH_MSG_DEBUG ( "Initialized Properties :" );
23 ATH_MSG_DEBUG ( " InputObjectName " << m_inputObjectName );
24 ATH_MSG_DEBUG ( " WindowLowerOffset " << m_timeWindowLowerOffset );
25 ATH_MSG_DEBUG ( " WindowUpperOffset " << m_timeWindowUpperOffset );
26 ATH_MSG_DEBUG ( " PileUp On? " << m_isPileUp );
27 ATH_MSG_DEBUG ( " maskBadChannels? " << m_maskBadChannel );
28 ATH_MSG_DEBUG ( " amplification(gain) " << m_amplification );
29 ATH_MSG_DEBUG ( " Use NewDigitEDM? " << m_newDigitEDM );
30 ATH_MSG_DEBUG ( " Drift Velocity Set? " << m_driftVelocity );
31 ATH_MSG_DEBUG ( " NInteraction per layer from poisson not from energyLoss? " << m_NInterFixed );
32 ATH_MSG_DEBUG ( " IncludePileUpTruth " << m_includePileUpTruth );
33 ATH_MSG_DEBUG ( " VetoPileUpTruthLinks " << m_vetoPileUpTruthLinks );
34
35 ATH_MSG_DEBUG ( " RndmSvc " << m_rndmSvc.typeAndName() );
36 ATH_MSG_DEBUG ( " cscCalibTool " << m_pcalib.typeAndName() );
37 ATH_MSG_DEBUG ( " CscSimDataCollection key " << m_cscSimDataCollectionWriteHandleKey.key());
38 ATH_MSG_DEBUG ( " CscDigitContainer key " << m_cscDigitContainerKey.key());
39
40 // initialize transient detector store and MuonDetDescrManager
41 const MuonGM::MuonDetectorManager* muDetMgr=nullptr;
42 ATH_CHECK(detStore()->retrieve(muDetMgr));
43 ATH_MSG_DEBUG ( "MuonDetectorManager retrieved from StoreGate.");
44
46 ATH_CHECK(m_mergeSvc.retrieve());
47 }
48
49 //random number initialization
50 ATH_CHECK(m_rndmSvc.retrieve());
51
53 ATH_CHECK(m_pcalib.retrieve());
54
55 //initialize the CSC digitizer
56 m_cscDigitizer = std::make_unique<CSC_Digitizer>(CscHitIdHelper::GetHelper(), muDetMgr, &*(m_pcalib));
57 m_cscDigitizer->setAmplification(m_amplification);
58 m_cscDigitizer->setDebug ( msgLvl(MSG::DEBUG) );
59 m_cscDigitizer->setDriftVelocity(m_driftVelocity);
60 m_cscDigitizer->setElectronEnergy (m_electronEnergy);
61 if (m_NInterFixed) {
62 m_cscDigitizer->setNInterFixed();
63 }
65 ATH_CHECK(m_cscDigitizer->initialize());
66
67 ATH_CHECK(m_idHelperSvc.retrieve());
68
69 // check the input object name
70 if (m_hitsContainerKey.key().empty()) {
71 ATH_MSG_FATAL("Property InputObjectName not set !");
72 return StatusCode::FAILURE;
73 }
75 ATH_MSG_DEBUG("Input objects in container : '" << m_inputObjectName << "'");
76
77 // Initialize ReadHandleKey
78 ATH_CHECK(m_hitsContainerKey.initialize(true));
79
80 // +++ Initialize WriteHandleKey
83
84 return StatusCode::SUCCESS;
85
86}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_FATAL(x)
SG::WriteHandleKey< CscDigitContainer > m_cscDigitContainerKey
Gaudi::Property< bool > m_isPileUp
ServiceHandle< IAthRNGSvc > m_rndmSvc
Gaudi::Property< double > m_driftVelocity
Gaudi::Property< bool > m_NInterFixed
SG::WriteHandleKey< CscSimDataCollection > m_cscSimDataCollectionWriteHandleKey
Gaudi::Property< double > m_timeWindowLowerOffset
Gaudi::Property< double > m_electronEnergy
Gaudi::Property< double > m_amplification
static const CscHitIdHelper * GetHelper()

◆ mergeEvent()

StatusCode CscDigitizationTool::mergeEvent ( const EventContext & ctx)
finaloverridevirtual

called at the end of the subevts loop. Not (necessarily) able to access subEvents

Definition at line 542 of file CscDigitizationTool.cxx.

542 {
543
544 ATH_MSG_DEBUG ( "in mergeEvent()" );
545
546 //create and record CscDigitContainer in SG
547 SG::WriteHandle<CscDigitContainer> cscDigits(m_cscDigitContainerKey, ctx);
548 ATH_CHECK(cscDigits.record(std::make_unique<CscDigitContainer>(m_idHelperSvc->cscIdHelper().module_hash_max())));
549 ATH_MSG_DEBUG("recorded CscDigitContainer with name "<<cscDigits.key());
550
551 // create and record the SDO container in StoreGate
552 SG::WriteHandle<CscSimDataCollection> cscSimData(m_cscSimDataCollectionWriteHandleKey, ctx);
553 ATH_CHECK(cscSimData.record(std::make_unique<CscSimDataCollection>()));
554
555 ATHRNG::RNGWrapper* rngWrapper = m_rndmSvc->getEngine(this);
556 rngWrapper->setSeed( name(), ctx );
557
558 Collections_t collections;
559 ATH_CHECK(CoreDigitization(collections,cscSimData.ptr(), rngWrapper->getEngine(ctx), ctx));
560 for (size_t coll_hash = 0; coll_hash < collections.size(); ++coll_hash) {
561 if (collections[coll_hash]) {
562 ATH_CHECK( cscDigits->addCollection (collections[coll_hash].release(), coll_hash) );
563 }
564 }
565
566 // remove cloned one in processBunchXing......
567 std::list<CSCSimHitCollection*>::iterator cscHitColl = m_cscHitCollList.begin();
568 std::list<CSCSimHitCollection*>::iterator cscHitCollEnd = m_cscHitCollList.end();
569 while(cscHitColl!=cscHitCollEnd)
570 {
571 delete (*cscHitColl);
572 ++cscHitColl;
573 }
574 m_cscHitCollList.clear();
575
576 return StatusCode::SUCCESS;
577}
void setSeed(const std::string &algName, const EventContext &ctx)
Set the random seed using a string (e.g.
Definition RNGWrapper.h:169
CLHEP::HepRandomEngine * getEngine(const EventContext &ctx) const
Retrieve the random engine corresponding to the provided EventContext.
Definition RNGWrapper.h:134
std::vector< std::unique_ptr< CscDigitCollection > > Collections_t
std::list< CSCSimHitCollection * > m_cscHitCollList
StatusCode CoreDigitization(Collections_t &collections, CscSimDataCollection *cscSimData, CLHEP::HepRandomEngine *rndmEngine, const EventContext &ctx)

◆ prepareEvent()

StatusCode CscDigitizationTool::prepareEvent ( const EventContext & ctx,
unsigned int  )
finaloverridevirtual

return false if not interested in certain xing times (in ns) implemented by default in PileUpToolBase as FirstXing<=bunchXing<=LastXing

Definition at line 89 of file CscDigitizationTool.cxx.

89 {
90
91 if (nullptr == m_thpcCSC)
92 m_thpcCSC = new TimedHitCollection<CSCSimHit>();
93
94 m_cscHitCollList.clear();
95
96 return StatusCode::SUCCESS;
97}

◆ processAllSubEvents()

StatusCode CscDigitizationTool::processAllSubEvents ( const EventContext & ctx)
finaloverridevirtual

alternative interface which uses the PileUpMergeSvc to obtain all the required SubEvents.

Reimplemented from PileUpToolBase.

Definition at line 100 of file CscDigitizationTool.cxx.

100 {
101
102 ATH_MSG_DEBUG ( "in processAllSubEvents()" );
103
104 //create and record CscDigitContainer in SG
105 SG::WriteHandle<CscDigitContainer> cscDigits(m_cscDigitContainerKey, ctx);
106 ATH_CHECK(cscDigits.record(std::make_unique<CscDigitContainer>(m_idHelperSvc->cscIdHelper().module_hash_max())));
107 ATH_MSG_DEBUG("recorded CscDigitContainer with name "<<cscDigits.key());
108
109 if (m_isPileUp) return StatusCode::SUCCESS;
110
111 // create and record the SDO container in StoreGate
112 SG::WriteHandle<CscSimDataCollection> cscSimData(m_cscSimDataCollectionWriteHandleKey, ctx);
113 ATH_CHECK(cscSimData.record(std::make_unique<CscSimDataCollection>()));
114
115 //merging of the hit collection in getNextEvent method
116 if (nullptr == m_thpcCSC ) {
118 if (StatusCode::FAILURE == sc) {
119 ATH_MSG_INFO ( "There are no CSC hits in this event" );
120 return sc; // there are no hits in this event
121 }
122 }
123
124 ATHRNG::RNGWrapper* rngWrapper = m_rndmSvc->getEngine(this);
125 rngWrapper->setSeed( name(), ctx );
126
127 Collections_t collections;
128 ATH_CHECK( CoreDigitization(collections,cscSimData.ptr(), rngWrapper->getEngine(ctx), ctx) );
129 for (size_t coll_hash = 0; coll_hash < collections.size(); ++coll_hash) {
130 if (collections[coll_hash]) {
131 ATH_CHECK( cscDigits->addCollection (collections[coll_hash].release(), coll_hash) );
132 }
133 }
134
135 return StatusCode::SUCCESS;
136}
#define ATH_MSG_INFO(x)
static Double_t sc
StatusCode getNextEvent(const EventContext &ctx)

◆ processBunchXing()

StatusCode CscDigitizationTool::processBunchXing ( int bunchXing,
SubEventIterator bSubEvents,
SubEventIterator eSubEvents )
finaloverridevirtual

called for each active bunch-crossing to process current subEvents. bunchXing is in ns

Reimplemented from PileUpToolBase.

Definition at line 499 of file CscDigitizationTool.cxx.

502{
503 ATH_MSG_DEBUG("CscDigitizationTool::processBunchXing() " << bunchXing);
504
506 TimedHitCollList hitCollList;
507
508 if (!(m_mergeSvc->retrieveSubSetEvtData(m_inputObjectName, hitCollList, bunchXing,
509 bSubEvents, eSubEvents).isSuccess()) &&
510 hitCollList.empty()) {
511 ATH_MSG_ERROR("Could not fill TimedHitCollList");
512 return StatusCode::FAILURE;
513 } else {
514 ATH_MSG_VERBOSE(hitCollList.size() << " CSCSimHitCollection with key " <<
515 m_inputObjectName << " found");
516 }
517
518 TimedHitCollList::iterator iColl(hitCollList.begin());
519 TimedHitCollList::iterator endColl(hitCollList.end());
520
521 // Iterating over the list of collections
522 for( ; iColl != endColl; ++iColl){
523
524 CSCSimHitCollection *hitCollPtr = new CSCSimHitCollection(*iColl->second);
525 PileUpTimeEventIndex timeIndex(iColl->first);
526
527 ATH_MSG_DEBUG("CSCSimHitCollection found with " << hitCollPtr->size() <<
528 " hits");
529 ATH_MSG_VERBOSE("time index info. time: " << timeIndex.time()
530 << " index: " << timeIndex.index()
531 << " type: " << timeIndex.type());
532
533 m_thpcCSC->insert(timeIndex, hitCollPtr);
534 m_cscHitCollList.push_back(hitCollPtr);
535
536 }
537
538 return StatusCode::SUCCESS;
539}
size_type size() const

◆ resetFilter()

virtual void PileUpToolBase::resetFilter ( )
inlineoverridevirtualinherited

dummy implementation of filter reset

Reimplemented in MergeTruthJetsTool.

Definition at line 51 of file PileUpToolBase.h.

51{ m_filterPassed=true; }

◆ toProcess()

virtual bool PileUpToolBase::toProcess ( int bunchXing) const
inlineoverridevirtualinherited

the method this base class helps implementing

Reimplemented in MergeHijingParsTool, and MergeTrackRecordCollTool.

Definition at line 32 of file PileUpToolBase.h.

32 {
33 //closed interval [m_firstXing,m_lastXing]
34 return !((m_firstXing > bunchXing) || (bunchXing > m_lastXing));
35 }
Gaudi::Property< int > m_firstXing
Gaudi::Property< int > m_lastXing

Member Data Documentation

◆ m_amplification

Gaudi::Property<double> CscDigitizationTool::m_amplification {this, "amplification", 0.58e5, ""}
private

Definition at line 103 of file CscDigitizationTool.h.

103{this, "amplification", 0.58e5, ""};

◆ m_cscDigitContainerKey

SG::WriteHandleKey<CscDigitContainer> CscDigitizationTool::m_cscDigitContainerKey {this,"OutputObjectName","CSC_DIGITS","CSC digit container object"}
private

Definition at line 95 of file CscDigitizationTool.h.

95{this,"OutputObjectName","CSC_DIGITS","CSC digit container object"};

◆ m_cscDigitizer

std::unique_ptr<CSC_Digitizer> CscDigitizationTool::m_cscDigitizer {nullptr}
private

Definition at line 97 of file CscDigitizationTool.h.

97{nullptr};

◆ m_cscHitCollList

std::list<CSCSimHitCollection*> CscDigitizationTool::m_cscHitCollList
private

Definition at line 107 of file CscDigitizationTool.h.

◆ m_cscSimDataCollectionWriteHandleKey

SG::WriteHandleKey<CscSimDataCollection> CscDigitizationTool::m_cscSimDataCollectionWriteHandleKey {this,"CSCSimDataCollectionOutputName","CSC_SDO","WriteHandleKey for Output CscSimDataCollection"}
private

Definition at line 94 of file CscDigitizationTool.h.

94{this,"CSCSimDataCollectionOutputName","CSC_SDO","WriteHandleKey for Output CscSimDataCollection"};

◆ m_driftVelocity

Gaudi::Property<double> CscDigitizationTool::m_driftVelocity {this, "DriftVelocity", 60, ""}
private

Definition at line 115 of file CscDigitizationTool.h.

115{this, "DriftVelocity", 60, ""}; // 60 / (1e-6 * 1e9); // 6 cm/microsecond -> mm/ns // 0.06

◆ m_electronEnergy

Gaudi::Property<double> CscDigitizationTool::m_electronEnergy {this, "ElectronEnergy", 66, ""}
private

Definition at line 116 of file CscDigitizationTool.h.

116{this, "ElectronEnergy", 66, ""}; // eV

◆ m_filterPassed

bool PileUpToolBase::m_filterPassed {true}
protectedinherited

Definition at line 60 of file PileUpToolBase.h.

60{true};

◆ m_firstXing

Gaudi::Property<int> PileUpToolBase::m_firstXing
protectedinherited
Initial value:
{this, "FirstXing", -999,
"First bunch-crossing in which det is live"}

Definition at line 54 of file PileUpToolBase.h.

54 {this, "FirstXing", -999,
55 "First bunch-crossing in which det is live"};

◆ m_hitsContainerKey

SG::ReadHandleKey<CSCSimHitCollection> CscDigitizationTool::m_hitsContainerKey {this, "InputObjectName", "CSC_Hits", "name of the input objects"}
private

Definition at line 92 of file CscDigitizationTool.h.

92{this, "InputObjectName", "CSC_Hits", "name of the input objects"}; // name of the input objects

◆ m_idHelperSvc

ServiceHandle<Muon::IMuonIdHelperSvc> CscDigitizationTool::m_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}
private

Definition at line 99 of file CscDigitizationTool.h.

99{this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"};

◆ m_includePileUpTruth

Gaudi::Property<bool> CscDigitizationTool::m_includePileUpTruth {this, "IncludePileUpTruth", true, "Include pile-up truth info"}
private

Definition at line 109 of file CscDigitizationTool.h.

109{this, "IncludePileUpTruth", true, "Include pile-up truth info"};

◆ m_inputObjectName

std::string CscDigitizationTool::m_inputObjectName {""}
private

Definition at line 93 of file CscDigitizationTool.h.

93{""};

◆ m_isPileUp

Gaudi::Property<bool> CscDigitizationTool::m_isPileUp {this, "isPileUp", false, ""}
private

Definition at line 113 of file CscDigitizationTool.h.

113{this, "isPileUp", false, ""};

◆ m_lastXing

Gaudi::Property<int> PileUpToolBase::m_lastXing
protectedinherited
Initial value:
{this, "LastXing", 999,
"Last bunch-crossing in which det is live"}

Definition at line 56 of file PileUpToolBase.h.

56 {this, "LastXing", 999,
57 "Last bunch-crossing in which det is live"};

◆ m_maskBadChannel

Gaudi::Property<bool> CscDigitizationTool::m_maskBadChannel {this, "maskBadChannels", true, ""}
private

Definition at line 102 of file CscDigitizationTool.h.

102{this, "maskBadChannels", true, ""};

◆ m_mergeSvc

ServiceHandle<PileUpMergeSvc> CscDigitizationTool::m_mergeSvc {this, "PileUpMergeSvc", "PileUpMergeSvc", ""}
private

Definition at line 119 of file CscDigitizationTool.h.

119{this, "PileUpMergeSvc", "PileUpMergeSvc", ""}; // Pile up service

◆ m_newDigitEDM

Gaudi::Property<bool> CscDigitizationTool::m_newDigitEDM {this, "NewDigitEDM", true, ""}
private

Definition at line 114 of file CscDigitizationTool.h.

114{this, "NewDigitEDM", true, ""};

◆ m_NInterFixed

Gaudi::Property<bool> CscDigitizationTool::m_NInterFixed {this, "NInterFixed", false, ""}
private

Definition at line 117 of file CscDigitizationTool.h.

117{this, "NInterFixed", false, ""};

◆ m_onlyUseContainerName

BooleanProperty CscDigitizationTool::m_onlyUseContainerName {this, "OnlyUseContainerName", true, "Don't use the ReadHandleKey directly. Just extract the container name from it."}
private

Definition at line 91 of file CscDigitizationTool.h.

91{this, "OnlyUseContainerName", true, "Don't use the ReadHandleKey directly. Just extract the container name from it."};

◆ m_pcalib

ToolHandle<ICscCalibTool> CscDigitizationTool::m_pcalib {this, "cscCalibTool", "CscCalibTool", "CSC calibration tool"}
private

Definition at line 89 of file CscDigitizationTool.h.

89{this, "cscCalibTool", "CscCalibTool", "CSC calibration tool"};

◆ m_pedestal

Gaudi::Property<double> CscDigitizationTool::m_pedestal {this, "pedestal",0.0, ""}
private

Definition at line 101 of file CscDigitizationTool.h.

101{this, "pedestal",0.0, ""};

◆ m_rndmSvc

ServiceHandle<IAthRNGSvc> CscDigitizationTool::m_rndmSvc {this, "RndmSvc", "AthRNGSvc", ""}
private

Definition at line 121 of file CscDigitizationTool.h.

121{this, "RndmSvc", "AthRNGSvc", ""}; // Random number service

◆ m_thpcCSC

TimedHitCollection<CSCSimHit>* CscDigitizationTool::m_thpcCSC {nullptr}
private

Definition at line 106 of file CscDigitizationTool.h.

106{nullptr}; // the hits

◆ m_timeWindowLowerOffset

Gaudi::Property<double> CscDigitizationTool::m_timeWindowLowerOffset {this, "WindowLowerOffset", -25., ""}
private

Definition at line 111 of file CscDigitizationTool.h.

111{this, "WindowLowerOffset", -25., ""};

◆ m_timeWindowUpperOffset

Gaudi::Property<double> CscDigitizationTool::m_timeWindowUpperOffset {this, "WindowUpperOffset", +25., ""}
private

Definition at line 112 of file CscDigitizationTool.h.

112{this, "WindowUpperOffset", +25., ""};

◆ m_vetoPileUpTruthLinks

Gaudi::Property<int> PileUpToolBase::m_vetoPileUpTruthLinks
protectedinherited
Initial value:
{this, "VetoPileUpTruthLinks", true,
"Ignore links to suppressed pile-up truth"}

Definition at line 58 of file PileUpToolBase.h.

58 {this, "VetoPileUpTruthLinks", true,
59 "Ignore links to suppressed pile-up truth"};

The documentation for this class was generated from the following files: