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

Class for shower library generation algorithm. More...

#include <LArG4GenShowerLib.h>

Inheritance diagram for LArG4GenShowerLib:
Collaboration diagram for LArG4GenShowerLib:

Public Member Functions

virtual StatusCode initialize () override
virtual StatusCode finalize () override
virtual StatusCode execute () override
 AthAlgorithm (const std::string &name, ISvcLocator *pSvcLocator)
 Constructor with parameters:
virtual StatusCode sysInitialize () override
 Override sysInitialize.
virtual const DataObjIDColl & extraOutputDeps () const override
 Return the list of extra output dependencies.
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
virtual StatusCode sysStart () override
 Handle START transition.
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles.
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles.
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T, V, H > &t)
void updateVHKA (Gaudi::Details::PropertyBase &)
MsgStream & msg () const
bool msgLvl (const MSG::Level lvl) const

Protected Member Functions

void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed.

Private Types

typedef std::map< std::string, ShowerLib::IShowerLib * > libMap
typedef ServiceHandle< StoreGateSvcStoreGateSvc_t

Private Member Functions

void clusterize (ShowerLib::StepInfoList *stepinfo)
const ShowerLib::StepInfoCollectiongetStepInfo ()
ShowerLib::StepInfoListcopyStepInfo (const ShowerLib::StepInfoCollection *stepinfo)
ShowerLib::StepInfoListcopyStepInfoZeroCleanup (const ShowerLib::StepInfoCollection *stepinfo)
void truncate (ShowerLib::StepInfoList *stepinfo)
HepMC::ConstGenParticlePtr getParticleFromMC ()
 return first MC truth particle for event
void calculateMoments (const ShowerLib::StepInfoCollection &eventSteps, double &weights, double &xavfra, double &yavfra, double &ravfra)
 calculate moments from StepInfoCollection
void addingTagsToLibrary ()
 adding tag information (release, detector description, ...) to library comment
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

DoubleProperty m_maxDistance
 property, see LArG4GenShowerLib::LArG4GenShowerLib
DoubleProperty m_maxRadius
 property, see LArG4GenShowerLib::LArG4GenShowerLib
DoubleProperty m_minEnergy
 property, see LArG4GenShowerLib::LArG4GenShowerLib
DoubleProperty m_containmentEnergy
 property, see LArG4GenShowerLib::LArG4GenShowerLib
DoubleProperty m_energyFraction
 property, see LArG4GenShowerLib::LArG4GenShowerLib
StringProperty m_physicslist_name
StringArrayProperty m_lib_struct_files
libMap m_libraries
 pointer to shower library
libMap m_libraries_by_filename
int m_stat_numshowers {0}
int m_stat_valid {0}
int m_stat_invalid {0}
int m_stat_nolib {0}
std::map< ShowerLib::IShowerLib *, int > m_stat_lib_saved
std::map< ShowerLib::IShowerLib *, int > m_stat_lib_notsaved
DataObjIDColl m_extendedExtraObjects
StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default)
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default)
std::vector< SG::VarHandleKeyArray * > m_vhka
bool m_varHandleArraysDeclared

Detailed Description

Class for shower library generation algorithm.

Create shower library using geant hits

Author
Wolfgang Ehrenfeld, University of Hamburg, Germany
Sasha Glazov, DESY Hamburg, Germany
Version
Id
LArG4GenShowerLib.h 711210 2015-11-27 15:56:00Z jchapman

Definition at line 40 of file LArG4GenShowerLib.h.

Member Typedef Documentation

◆ libMap

typedef std::map<std::string, ShowerLib::IShowerLib*> LArG4GenShowerLib::libMap
private

Definition at line 85 of file LArG4GenShowerLib.h.

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< Algorithm > >::StoreGateSvc_t
privateinherited

Definition at line 388 of file AthCommonDataStore.h.

Member Function Documentation

◆ addingTagsToLibrary()

void LArG4GenShowerLib::addingTagsToLibrary ( )
private

adding tag information (release, detector description, ...) to library comment

Definition at line 408 of file LArG4GenShowerLib.cxx.

409{
410 char* atlasProject = getenv("AtlasProject");
411 char* atlasVersion = getenv("AtlasVersion");
412 std::string atlasReleaseTag = (atlasProject? std::string(atlasProject)+std::string("-") : std::string("Unknown-"));
413 if(atlasVersion) {
414 atlasReleaseTag += std::string(atlasVersion);
415 }
416 else {
417 atlasReleaseTag += std::string("Unknown");
418 }
419
420 libMap::iterator itr;
421 for (itr = m_libraries.begin();itr != m_libraries.end();++itr){
422 // release
423 (*itr).second->release(atlasReleaseTag);
424
425 // get geometry version
426 ServiceHandle<IGeoModelSvc> geoModelSvc("GeoModelSvc", this->name());
427 (*itr).second->geometry(geoModelSvc->atlasVersion());
428
429 // get Physics list
430 (*itr).second->physicsList(m_physicslist_name);
431
432 // get geant4 version and strip off CVS Name tag
433 std::string g4Version = G4Version;
434 size_t pos = g4Version.find("$Name: ");
435 if (pos != std::string::npos) {
436 g4Version.erase(pos, 7);
437 }
438 pos = g4Version.find(" $");
439 if (pos != std::string::npos) {
440 g4Version.erase(pos, 2);
441 }
442 (*itr).second->geantVersion(g4Version);
443 }
444}
if(febId1==febId2)
libMap m_libraries
pointer to shower library
std::string getenv(const std::string &variableName)
get an environment variable

◆ AthAlgorithm()

AthAlgorithm::AthAlgorithm ( const std::string & name,
ISvcLocator * pSvcLocator )

Constructor with parameters:

Definition at line 51 of file AthAlgorithm.cxx.

25 :
27{
28 // Set up to run AthAlgorithmDHUpdate in sysInitialize before
29 // merging dependency lists. This extends the output dependency
30 // list with any symlinks implied by inheritance relations.
31 m_updateDataHandles =
32 std::make_unique<AthenaBaseComps::AthAlgorithmDHUpdate>
34 std::move (m_updateDataHandles));
35}
DataObjIDColl m_extendedExtraObjects
AthCommonDataStore(const std::string &name, T... args)

◆ calculateMoments()

void LArG4GenShowerLib::calculateMoments ( const ShowerLib::StepInfoCollection & eventSteps,
double & weights,
double & xavfra,
double & yavfra,
double & ravfra )
private

calculate moments from StepInfoCollection

Definition at line 486 of file LArG4GenShowerLib.cxx.

488{
489 double escal(0.);
490 double xav(0.), yav(0.), xav2(0.), yav2(0.);
491
492 for (ShowerLib::StepInfoCollection::const_iterator i=eventSteps.begin();i<eventSteps.end(); ++i) {
493 escal += (*i)->dep();
494 xav += (*i)->x()*(*i)->dep();
495 yav += (*i)->y()*(*i)->dep();
496 xav2 += (*i)->x()*(*i)->x()*(*i)->dep();
497 yav2 += (*i)->y()*(*i)->y()*(*i)->dep();
498 }
499
500 // Center of gravity:
501 const double inv_escal = escal == 0 ? 1 : 1. / escal;
502 xavfra = xav*inv_escal;
503 yavfra = yav*inv_escal;
504 // Second momentum:
505 ravfra = std::sqrt(std::abs((xav2*inv_escal-xavfra*xavfra) +
506 (yav2*inv_escal-yavfra*yavfra)));
507 // energy is used as weights
508 weights = escal;
509
510 return;
511}
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.

◆ clusterize()

void LArG4GenShowerLib::clusterize ( ShowerLib::StepInfoList * stepinfo)
private

Definition at line 323 of file LArG4GenShowerLib.cxx.

324{
325 typedef std::multimap<double,Dist> distMap;
326
327 distMap distances;
328
329 //fill the map
330 for (ShowerLib::StepInfoList::iterator i_h1(stepinfo->begin()); i_h1 != stepinfo->end(); ++i_h1) {
331 //iterate only the upper triangle of N*N matrix, since we do not want to create every distance twice
332 for (ShowerLib::StepInfoList::reverse_iterator i_h2(stepinfo->rbegin()); (*i_h2) != (*i_h1); ++i_h2) {
333 distances.insert(distMap::value_type((*i_h1)->diff2(**i_h2),Dist(*i_h1, *i_h2)));
334 }
335 }
336
337 const double rmin = m_maxRadius;
338
339 int cursize = stepinfo->size();
340
341
342 while (cursize > 1) {
343 distMap::iterator iter = distances.begin();
344 while ( !( (*iter).second.h1->valid() && (*iter).second.h2->valid() ) ) {
345 distances.erase(iter++); //find the first (i.e. closest) valid pair of hits, removing invalid
346 }
347
348 if ((*iter).first > rmin ) break; //if the closest already far enough - stop
349
350 ShowerLib::StepInfo* mergedHit = (*iter).second.merge(); //merge two closest hits
351
352 for (ShowerLib::StepInfoList::iterator i_h1(stepinfo->begin()); i_h1 != stepinfo->end(); ++i_h1) {
353 if ((*i_h1)->valid()){ //only for valid hits
354 distances.insert(distMap::value_type((*i_h1)->diff2(*mergedHit),Dist(*i_h1, mergedHit))); //calculate and store distances
355 }
356 }
357
358 stepinfo->push_back(mergedHit); //store the merged hit
359 cursize--; //merging == -1 valid hit
360 }
361
362 // remove invalid
363 for (ShowerLib::StepInfoList::iterator i = stepinfo->begin(); i != stepinfo->end();) {
364 if ((*i)->valid()) {
365 ++i;
366 } else {
367 delete (*i);
368 i = stepinfo->erase(i);
369 }
370 }
371
372}
DoubleProperty m_maxRadius
property, see LArG4GenShowerLib::LArG4GenShowerLib

◆ copyStepInfo()

ShowerLib::StepInfoList * LArG4GenShowerLib::copyStepInfo ( const ShowerLib::StepInfoCollection * stepinfo)
private

Definition at line 281 of file LArG4GenShowerLib.cxx.

282{
284 ShowerLib::StepInfo *copy = nullptr;
285
286 for (ShowerLib::StepInfoCollection::const_iterator iter = stepinfo->begin(); iter!=stepinfo->end(); ++iter) {
287 copy = new ShowerLib::StepInfo(*(*iter));
288 rez->push_back(copy);
289 }
290
291 return rez;
292}
std::list< StepInfo * > StepInfoList
bool copy
Definition calibdata.py:26

◆ copyStepInfoZeroCleanup()

ShowerLib::StepInfoList * LArG4GenShowerLib::copyStepInfoZeroCleanup ( const ShowerLib::StepInfoCollection * stepinfo)
private

Definition at line 294 of file LArG4GenShowerLib.cxx.

295{
297
298 const double dsame = 1.; // 1mm^2
299 ShowerLib::StepInfo *i1 = nullptr;
300 ShowerLib::StepInfo *i2 = nullptr;
301
302 for (ShowerLib::StepInfoCollection::const_iterator i = stepinfo->begin(); i!=stepinfo->end(); ++i) {
303 if(i1 == nullptr) {
304 i1 = new ShowerLib::StepInfo(*(*i));
305 rez->push_back(i1);
306 }
307 else {
308 i2 = new ShowerLib::StepInfo(*(*i));
309 // if distance below cut off, combined and erase
310 if ( (i1)->diff2(*i2) < dsame) {
311 *i1 += *i2;
312 delete i2;
313 } else {
314 rez->push_back(i2);
315 i1 = i2;
316 }
317 }
318 }
319
320 return rez;
321}

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< Algorithm > >::declareGaudiProperty ( Gaudi::Property< T, V, H > & hndl,
const SG::VarHandleKeyType &  )
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158 {
160 hndl.value(),
161 hndl.documentation());
162
163 }
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)

◆ declareProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty ( Gaudi::Property< T, V, H > & t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145 {
146 typedef typename SG::HandleClassifier<T>::type htype;
148 }
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>

◆ detStore()

const ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< Algorithm > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

◆ evtStore()

ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< Algorithm > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

◆ execute()

StatusCode LArG4GenShowerLib::execute ( )
overridevirtual

Definition at line 125 of file LArG4GenShowerLib.cxx.

126{
127 const ShowerLib::StepInfoCollection* eventStepsES = getStepInfo();
128
129 auto theParticle = getParticleFromMC();
130 if (!theParticle) {
131 ATH_MSG_ERROR ( "Couldn't get truth particle" );
132 return StatusCode::FAILURE;
133 }
134
136
137 double fraction = eventStepsES->invalid_energy/theParticle->momentum().e();
138 if (fraction > m_energyFraction) {
139 ATH_MSG_WARNING ( "Shower deposited too much energy outside the calorimeter region (" << (int)(fraction*100) << "%), ignoring" );
140 m_stat_invalid += 1;
141 return StatusCode::SUCCESS;
142 }
143 //otherwise shower is valid. even if it ultimately wont go to any library
144 m_stat_valid += 1;
145
146 ShowerLib::StepInfoList* eventSteps;
147
148 if (eventStepsES->size()>500) {
149 eventSteps = copyStepInfoZeroCleanup(eventStepsES);
150 } else {
151 eventSteps = copyStepInfo(eventStepsES);
152 }
153
154 double etot = 0.;
155 for (ShowerLib::StepInfoList::const_iterator iter = eventSteps->begin();iter != eventSteps->end();++iter) {
156 etot += (*iter)->dep();
157 }
158
159 std::stringstream location;
160
161 location << eventStepsES->detector << "/" << theParticle->pdg_id();
162
163 if (m_libraries.find(location.str()) == m_libraries.end()) {
164 ATH_MSG_WARNING ( "No library structure for " << location.str() );
165
166 for (ShowerLib::StepInfoList::iterator i(eventSteps->begin());i != eventSteps->end(); ++i) {
167 delete (*i);
168 }
169 delete eventSteps;
170 m_stat_nolib += 1;
171 return StatusCode::SUCCESS; //not really an error, just lost time
172 }
173
174 Hep3Vector origin(theParticle->production_vertex()->position().x(),
175 theParticle->production_vertex()->position().y(),
176 theParticle->production_vertex()->position().z());
177
178 // Also save direction vector. By default shower lib is created in
179 // the direction of the input particle.
180 Hep3Vector DirectionShower(theParticle->momentum().px(),
181 theParticle->momentum().py(),
182 theParticle->momentum().pz());
183 DirectionShower /= DirectionShower.mag();
184 Hep3Vector OrthoShower = DirectionShower.orthogonal();
185 OrthoShower /= OrthoShower.mag();
186 Hep3Vector CrossShower = DirectionShower.cross(OrthoShower);
187 CrossShower /= CrossShower.mag();
188
189 // Rotate the hit such that Z direction is along the shower direction
190 for (ShowerLib::StepInfoList::iterator i(eventSteps->begin()); i != eventSteps->end(); ++i) {
191 Hep3Vector HitDir = (*i)->position() - origin;
192
193 (*i)->setX(HitDir*OrthoShower);
194 (*i)->setY(HitDir*CrossShower);
195 (*i)->setZ(HitDir*DirectionShower);
196 }
197
198 ATH_MSG_VERBOSE ( "Size of input shower: " << eventSteps->size() );
199
200 clusterize(eventSteps);
201
202 ATH_MSG_VERBOSE ( "Size after clusterization: " << eventSteps->size() );
203
204 if (eventSteps->size() > 10) {
205 truncate(eventSteps);
206 ATH_MSG_VERBOSE ( "Size after truncation: " << eventSteps->size() );
207 }
208
209 double maxZ = 0, maxR = 0;
210 double edep = 0.;
211
212 double containmentEnergy = m_containmentEnergy * etot;
213
214 // sort the hits by R, make the border where 95% is deposited
215 eventSteps->sort(stepInfoDistCompare(stepInfoDistCompare::R));
216 ShowerLib::StepInfoList::const_iterator iter = eventSteps->begin();
217 for (;(iter != eventSteps->end()) && (edep < containmentEnergy);++iter) {
218 edep += (*iter)->dep();
219 maxR = (*iter)->position().r();
220 }
221
222 edep = 0.;
223 // sort the hits by Z, make the border where 95% is deposited
224 eventSteps->sort(stepInfoDistCompare(stepInfoDistCompare::Z));
225 iter = eventSteps->begin();
226 for (;(iter != eventSteps->end()) && (edep < containmentEnergy);++iter) {
227 edep += (*iter)->dep();
228 maxZ = (*iter)->position().z();
229 }
230
231 ShowerLib::Shower* shower = new ShowerLib::Shower();
232 shower->setZSize(maxZ);
233 shower->setRSize(maxR);
234
235 for (ShowerLib::StepInfoList::iterator i(eventSteps->begin());i != eventSteps->end(); ++i) {
236
237 shower->push_back(new ShowerLib::ShowerEnergySpot(G4ThreeVector((*i)->x(), (*i)->y(), (*i)->z()),(*i)->dep(),(*i)->time()));
238
239 delete (*i);
240 }
241
242 delete eventSteps;
243
244 if ((*m_libraries.find(location.str())).second->storeShower(std::move(theParticle), shower)) {
245 m_stat_lib_saved[(*m_libraries.find(location.str())).second] += 1;
246 } else {
247 ATH_MSG_WARNING ( "Wasn't able to store shower (" << location.str() << ")" );
248 m_stat_lib_notsaved[(*m_libraries.find(location.str())).second] += 1;
249 }
250
251 ATH_MSG_VERBOSE ( "Successfully finished" );
252
253 return StatusCode::SUCCESS;
254}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
size_type size() const noexcept
Returns the number of elements in the collection.
DoubleProperty m_containmentEnergy
property, see LArG4GenShowerLib::LArG4GenShowerLib
DoubleProperty m_energyFraction
property, see LArG4GenShowerLib::LArG4GenShowerLib
std::map< ShowerLib::IShowerLib *, int > m_stat_lib_notsaved
void truncate(ShowerLib::StepInfoList *stepinfo)
std::map< ShowerLib::IShowerLib *, int > m_stat_lib_saved
void clusterize(ShowerLib::StepInfoList *stepinfo)
ShowerLib::StepInfoList * copyStepInfo(const ShowerLib::StepInfoCollection *stepinfo)
HepMC::ConstGenParticlePtr getParticleFromMC()
return first MC truth particle for event
const ShowerLib::StepInfoCollection * getStepInfo()
ShowerLib::StepInfoList * copyStepInfoZeroCleanup(const ShowerLib::StepInfoCollection *stepinfo)
void setZSize(const float zsize)
Definition Shower.h:64
void setRSize(const float rsize)
Definition Shower.h:65

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< Algorithm > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase & ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ extraOutputDeps()

const DataObjIDColl & AthAlgorithm::extraOutputDeps ( ) const
overridevirtualinherited

Return the list of extra output dependencies.

This list is extended to include symlinks implied by inheritance relations.

Definition at line 50 of file AthAlgorithm.cxx.

51{
52 // If we didn't find any symlinks to add, just return the collection
53 // from the base class. Otherwise, return the extended collection.
54 if (!m_extendedExtraObjects.empty()) {
56 }
57 return Algorithm::extraOutputDeps();
58}

◆ finalize()

StatusCode LArG4GenShowerLib::finalize ( )
overridevirtual

Definition at line 447 of file LArG4GenShowerLib.cxx.

448{
449
450 // add condition tags
452
453 libMap::iterator itr;
454 for (itr = m_libraries_by_filename.begin();itr != m_libraries_by_filename.end();++itr){
455 ATH_MSG_DEBUG ( "Writing shower library to file " << (*itr).first );
456
457 TFile libr((*itr).first.c_str(),"RECREATE");
458
459 if (!(*itr).second->writeToROOT(&libr)) {
460 ATH_MSG_ERROR ( "Wasn't able to write " << (*itr).first << ". Probably empty lib." );
461 }
462
463 libr.Close();
464 }
465 if (m_stat_numshowers> 0) {
466 ATH_MSG_DEBUG ( "********Statistics for GenShowerLib********" );
467 ATH_MSG_DEBUG ( "Total number of showers: " << m_stat_numshowers
468 << ", valid: "<< m_stat_valid << " (" << (m_stat_valid*100)/m_stat_numshowers << "%)"
469 << ", invalid: " << m_stat_invalid << " (" << (m_stat_invalid*100)/m_stat_numshowers << "%)" );
470 for (itr = m_libraries.begin();itr != m_libraries.end();++itr){
471 ATH_MSG_DEBUG ( "*******************************************" );
472 std::stringstream ss((*itr).second->statistics());
473 for(std::string line; std::getline(ss,line);)
474 ATH_MSG_DEBUG ( line );
475 ATH_MSG_DEBUG ( "Saved: " << m_stat_lib_saved[(*itr).second] << " Rejected: " << m_stat_lib_notsaved[(*itr).second] );
476 }
477 ATH_MSG_DEBUG ( "*******************************************" );
478 ATH_MSG_DEBUG ( "Showers with no corresponding library: " << m_stat_nolib << " (" << (m_stat_nolib*100)/m_stat_numshowers << "%)" );
479 }
480 ATH_MSG_DEBUG ( "Finalized." );
481
482 return StatusCode::SUCCESS;
483}
#define ATH_MSG_DEBUG(x)
static Double_t ss
void addingTagsToLibrary()
adding tag information (release, detector description, ...) to library comment

◆ getParticleFromMC()

HepMC::ConstGenParticlePtr LArG4GenShowerLib::getParticleFromMC ( )
private

return first MC truth particle for event

Definition at line 256 of file LArG4GenShowerLib.cxx.

257{
258 const McEventCollection* mcEvent;
259 if (evtStore()->retrieve(mcEvent,"GEN_EVENT").isFailure()) return nullptr;
260
261 // Return the last particle of the event.
262 if (mcEvent)
263#ifdef HEPMC3
264 return !mcEvent->at(0)->particles().empty() ? mcEvent->at(0)->particles().back() : nullptr;
265#else
266 return ( * (* mcEvent->begin())->particles_end());
267#endif
268
269 return nullptr;
270}
const T * at(size_type n) const
Access an element, as an rvalue.
retrieve(aClass, aKey=None)
Definition PyKernel.py:110

◆ getStepInfo()

const ShowerLib::StepInfoCollection * LArG4GenShowerLib::getStepInfo ( )
private

Definition at line 272 of file LArG4GenShowerLib.cxx.

273{
274 const ShowerLib::StepInfoCollection* eventStepsES;
275 if (evtStore()->retrieve(eventStepsES, "EventSteps").isFailure()) return nullptr;
276
277 return eventStepsES;
278
279}

◆ initialize()

StatusCode LArG4GenShowerLib::initialize ( )
overridevirtual

Definition at line 84 of file LArG4GenShowerLib.cxx.

85{
86 ATH_MSG_DEBUG ( "Initializing" );
87
88 ShowerLib::IShowerLib* library = nullptr;
89
90 std::vector< std::string >::const_iterator nameiter;
91
92 ATH_MSG_DEBUG ( "Starting struct files iteration" );
93 for (nameiter = m_lib_struct_files.value().begin(); nameiter != m_lib_struct_files.value().end(); ++nameiter ) {
94
95 ATH_MSG_DEBUG ( "Struct file: " << (*nameiter) );
96
97 library = ShowerLib::iterateStruct(*nameiter);
98
99 if (library == nullptr) {
100 ATH_MSG_WARNING ( "Library structure file " << (*nameiter) << " doesn't describe a valid library" );
101 continue;
102 }
103
104 std::stringstream location;
105 location << library->detector() << "/" << library->particle_id();
106 m_libraries[location.str()] = library;
107 m_libraries_by_filename[(*nameiter)+".root"] = library;
108 m_stat_lib_saved[library]=0;
109 m_stat_lib_notsaved[library]=0;
110
111 ATH_MSG_VERBOSE ( "Library named " << (*nameiter)+".root" << "is stored at the location " << location.str() );
112
113 }
114
115 if (m_libraries.empty()) {
116 ATH_MSG_ERROR ( "No valid library structure files found. Further execution is pointless." );
117 return StatusCode::FAILURE;
118 }
119
120 ATH_MSG_DEBUG ( "LArG4GenShowerLib " << this->name() << " initialized" );
121
122 return StatusCode::SUCCESS;
123}
StringArrayProperty m_lib_struct_files
virtual int particle_id() const
get particle tag
Definition IShowerLib.h:124
virtual const std::string detector() const
get detector tag
Definition IShowerLib.h:121
IShowerLib * iterateStruct(const std::string &fname)

◆ inputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< Algorithm > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ msg()

MsgStream & AthCommonMsg< Algorithm >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24 {
25 return this->msgStream();
26 }

◆ msgLvl()

bool AthCommonMsg< Algorithm >::msgLvl ( const MSG::Level lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30 {
31 return this->msgLevel(lvl);
32 }

◆ outputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< Algorithm > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ renounce()

std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > AthCommonDataStore< AthCommonMsg< Algorithm > >::renounce ( T & h)
inlineprotectedinherited

Definition at line 380 of file AthCommonDataStore.h.

381 {
382 h.renounce();
384 }
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce(T &h)

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< Algorithm > >::renounceArray ( SG::VarHandleKeyArray & handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364 {
366 }

◆ sysInitialize()

StatusCode AthAlgorithm::sysInitialize ( )
overridevirtualinherited

Override sysInitialize.

Override sysInitialize from the base class.

Loop through all output handles, and if they're WriteCondHandles, automatically register them and this Algorithm with the CondSvc

Scan through all outputHandles, and if they're WriteCondHandles, register them with the CondSvc

Reimplemented from AthCommonDataStore< AthCommonMsg< Algorithm > >.

Reimplemented in AthAnalysisAlgorithm, AthFilterAlgorithm, AthHistogramAlgorithm, and PyAthena::Alg.

Definition at line 66 of file AthAlgorithm.cxx.

66 {
68
69 if (sc.isFailure()) {
70 return sc;
71 }
72 ServiceHandle<ICondSvc> cs("CondSvc",name());
73 for (auto h : outputHandles()) {
74 if (h->isCondition() && h->mode() == Gaudi::DataHandle::Writer) {
75 // do this inside the loop so we don't create the CondSvc until needed
76 if ( cs.retrieve().isFailure() ) {
77 ATH_MSG_WARNING("no CondSvc found: won't autoreg WriteCondHandles");
78 return StatusCode::SUCCESS;
79 }
80 if (cs->regHandle(this,*h).isFailure()) {
81 sc = StatusCode::FAILURE;
82 ATH_MSG_ERROR("unable to register WriteCondHandle " << h->fullKey()
83 << " with CondSvc");
84 }
85 }
86 }
87 return sc;
88}
static Double_t sc
virtual StatusCode sysInitialize() override
Override sysInitialize.
virtual std::vector< Gaudi::DataHandle * > outputHandles() const override
::StatusCode StatusCode
StatusCode definition for legacy code.

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< Algorithm > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ truncate()

void LArG4GenShowerLib::truncate ( ShowerLib::StepInfoList * stepinfo)
private

Definition at line 374 of file LArG4GenShowerLib.cxx.

375{
376 double etot = 0;
377 stepinfo->sort(stepInfoDistCompare(stepInfoDistCompare::RHO));
378
379 for (ShowerLib::StepInfoList::const_iterator i(stepinfo->begin()); i != stepinfo->end(); ++i) {
380 etot += (*i)->dep();
381 }
382
383 double minEnergy = m_minEnergy * etot;
384 double rsum = 0.;
385 ShowerLib::StepInfoList::iterator iterCut;
386 //we're continuing our cycle if (we're not at the end yet) && ( (the current hit is still inside maxDistance radius) || (the total energy still less then the threshold) )
387 for (iterCut = stepinfo->begin(); (iterCut != stepinfo->end()) && (((*iterCut)->position().mag2() < m_maxDistance) || (rsum < minEnergy));++iterCut) {
388 rsum += (*iterCut)->dep();
389 }
390
391 if (iterCut == stepinfo->end()) {
392 return;
393 }
394
395 stepinfo->erase(iterCut,stepinfo->end());
396
397 if (rsum == 0) { //WTF?
398 return;
399 }
400
401 const double inv_rsum = 1. / rsum;
402 for (iterCut = stepinfo->begin(); iterCut != stepinfo->end(); ++iterCut){
403 (*iterCut)->setE((*iterCut)->dep() * etot*inv_rsum);
404 }
405
406}
DoubleProperty m_maxDistance
property, see LArG4GenShowerLib::LArG4GenShowerLib
DoubleProperty m_minEnergy
property, see LArG4GenShowerLib::LArG4GenShowerLib

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< Algorithm > >::updateVHKA ( Gaudi::Details::PropertyBase & )
inlineinherited

Definition at line 308 of file AthCommonDataStore.h.

308 {
309 // debug() << "updateVHKA for property " << p.name() << " " << p.toString()
310 // << " size: " << m_vhka.size() << endmsg;
311 for (auto &a : m_vhka) {
313 for (auto k : keys) {
314 k->setOwner(this);
315 }
316 }
317 }
std::vector< SG::VarHandleKeyArray * > m_vhka

Member Data Documentation

◆ m_containmentEnergy

DoubleProperty LArG4GenShowerLib::m_containmentEnergy
private
Initial value:
{this, "ContainmentEnergy", 0.95
, "energy fraction that will be inside containment borders"}

property, see LArG4GenShowerLib::LArG4GenShowerLib

Definition at line 76 of file LArG4GenShowerLib.h.

76 {this, "ContainmentEnergy", 0.95
77 , "energy fraction that will be inside containment borders"};

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< Algorithm > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default)

Definition at line 393 of file AthCommonDataStore.h.

◆ m_energyFraction

DoubleProperty LArG4GenShowerLib::m_energyFraction
private
Initial value:
{this, "EnergyFraction", .02
, "the allowed amount of energy that can be deposited outside calorimeter region"}

property, see LArG4GenShowerLib::LArG4GenShowerLib

Definition at line 78 of file LArG4GenShowerLib.h.

78 {this, "EnergyFraction", .02
79 , "the allowed amount of energy that can be deposited outside calorimeter region"};

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< Algorithm > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default)

Definition at line 390 of file AthCommonDataStore.h.

◆ m_extendedExtraObjects

DataObjIDColl AthAlgorithm::m_extendedExtraObjects
privateinherited

Definition at line 79 of file AthAlgorithm.h.

◆ m_lib_struct_files

StringArrayProperty LArG4GenShowerLib::m_lib_struct_files
private
Initial value:
{this, "LibStructFiles", {}
, "List of files to read library structures from"}

Definition at line 82 of file LArG4GenShowerLib.h.

82 {this, "LibStructFiles", {}
83 , "List of files to read library structures from"};

◆ m_libraries

libMap LArG4GenShowerLib::m_libraries
private

pointer to shower library

Definition at line 86 of file LArG4GenShowerLib.h.

◆ m_libraries_by_filename

libMap LArG4GenShowerLib::m_libraries_by_filename
private

Definition at line 87 of file LArG4GenShowerLib.h.

◆ m_maxDistance

DoubleProperty LArG4GenShowerLib::m_maxDistance
private
Initial value:
{this, "MaxDistance", 50000.
, "max distance squared after which the hits will be truncated"}

property, see LArG4GenShowerLib::LArG4GenShowerLib

Definition at line 70 of file LArG4GenShowerLib.h.

70 {this, "MaxDistance", 50000.
71 , "max distance squared after which the hits will be truncated"};

◆ m_maxRadius

DoubleProperty LArG4GenShowerLib::m_maxRadius
private
Initial value:
{this, "MaxRadius", 25.
, "maximal radius squared until two hits will be combined"}

property, see LArG4GenShowerLib::LArG4GenShowerLib

Definition at line 72 of file LArG4GenShowerLib.h.

72 {this, "MaxRadius", 25.
73 , "maximal radius squared until two hits will be combined"};

◆ m_minEnergy

DoubleProperty LArG4GenShowerLib::m_minEnergy
private
Initial value:
{this, "MinEnergy", .99
, "energy border, that truncation won't cross"}

property, see LArG4GenShowerLib::LArG4GenShowerLib

Definition at line 74 of file LArG4GenShowerLib.h.

74 {this, "MinEnergy", .99
75 , "energy border, that truncation won't cross"};

◆ m_physicslist_name

StringProperty LArG4GenShowerLib::m_physicslist_name
private
Initial value:
{this, "PhysicsList", "FTFP_BERT"
, "Geant4 PhysicsList used in the simulation"}

Definition at line 80 of file LArG4GenShowerLib.h.

80 {this, "PhysicsList", "FTFP_BERT"
81 , "Geant4 PhysicsList used in the simulation"};

◆ m_stat_invalid

int LArG4GenShowerLib::m_stat_invalid {0}
private

Definition at line 91 of file LArG4GenShowerLib.h.

91{0};

◆ m_stat_lib_notsaved

std::map<ShowerLib::IShowerLib*, int> LArG4GenShowerLib::m_stat_lib_notsaved
private

Definition at line 95 of file LArG4GenShowerLib.h.

◆ m_stat_lib_saved

std::map<ShowerLib::IShowerLib*, int> LArG4GenShowerLib::m_stat_lib_saved
private

Definition at line 94 of file LArG4GenShowerLib.h.

◆ m_stat_nolib

int LArG4GenShowerLib::m_stat_nolib {0}
private

Definition at line 92 of file LArG4GenShowerLib.h.

92{0};

◆ m_stat_numshowers

int LArG4GenShowerLib::m_stat_numshowers {0}
private

Definition at line 89 of file LArG4GenShowerLib.h.

89{0};

◆ m_stat_valid

int LArG4GenShowerLib::m_stat_valid {0}
private

Definition at line 90 of file LArG4GenShowerLib.h.

90{0};

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< Algorithm > >::m_varHandleArraysDeclared
privateinherited

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< Algorithm > >::m_vhka
privateinherited

Definition at line 398 of file AthCommonDataStore.h.


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