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 (const EventContext &ctx) override
 Execute method.
 AthAlgorithm (const std::string &name, ISvcLocator *pSvcLocator)
 Constructor.
virtual StatusCode sysInitialize () override
 Override sysInitialize.
virtual bool isClonable () const override
 Specify if the algorithm is clonable.
virtual StatusCode sysExecute (const EventContext &ctx) override
 Execute an algorithm.
virtual const DataObjIDColl & extraOutputDeps () const override
 Return the list of extra output dependencies.
virtual bool filterPassed (const EventContext &ctx) const
 Get filter decision:
virtual void setFilterPassed (bool state, const EventContext &ctx) const
 Set filter decision:
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

virtual bool isReEntrant () const override final
 Legacy algorithms are not thread-safe.
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
 Extra output dependency collection, extended by AthAlgorithmDHUpdate to add symlinks.
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< Gaudi::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 403 of file LArG4GenShowerLib.cxx.

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

◆ AthAlgorithm()

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

Constructor.

Definition at line 31 of file AthAlgorithm.cxx.

11 :
12 AthCommonAlgorithm<Gaudi::Algorithm>( name, pSvcLocator )
13{
14 // default cardinality for non-reentrant algorithms
15 setProperty( "Cardinality", 1 ).orThrow("Unable to set property 'Cardinality'", name);
16}
void setProperty(columnar::PythonToolHandle &self, const std::string &key, nb::object value)
AthCommonAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)

◆ calculateMoments()

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

calculate moments from StepInfoCollection

Definition at line 481 of file LArG4GenShowerLib.cxx.

483{
484 double escal(0.);
485 double xav(0.), yav(0.), xav2(0.), yav2(0.);
486
487 for (ShowerLib::StepInfoCollection::const_iterator i=eventSteps.begin();i<eventSteps.end(); ++i) {
488 escal += (*i)->dep();
489 xav += (*i)->x()*(*i)->dep();
490 yav += (*i)->y()*(*i)->dep();
491 xav2 += (*i)->x()*(*i)->x()*(*i)->dep();
492 yav2 += (*i)->y()*(*i)->y()*(*i)->dep();
493 }
494
495 // Center of gravity:
496 const double inv_escal = escal == 0 ? 1 : 1. / escal;
497 xavfra = xav*inv_escal;
498 yavfra = yav*inv_escal;
499 // Second momentum:
500 ravfra = std::sqrt(std::abs((xav2*inv_escal-xavfra*xavfra) +
501 (yav2*inv_escal-yavfra*yavfra)));
502 // energy is used as weights
503 weights = escal;
504
505 return;
506}
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 318 of file LArG4GenShowerLib.cxx.

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

◆ copyStepInfo()

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

Definition at line 276 of file LArG4GenShowerLib.cxx.

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

◆ copyStepInfoZeroCleanup()

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

Definition at line 289 of file LArG4GenShowerLib.cxx.

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

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< Gaudi::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< Gaudi::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< Gaudi::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< Gaudi::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 ( const EventContext & ctx)
overridevirtual

Execute method.

Implements AthAlgorithm.

Definition at line 124 of file LArG4GenShowerLib.cxx.

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

Return the list of extra output dependencies.

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

Definition at line 89 of file AthCommonAlgorithm.cxx.

54{
55 // If we didn't find any symlinks to add, just return the collection
56 // from the base class. Otherwise, return the extended collection.
57 if (!m_extendedExtraObjects.empty()) {
59 }
61}
Common base class for algorithms.

◆ filterPassed()

virtual bool AthCommonAlgorithm< Gaudi::Algorithm >::filterPassed ( const EventContext & ctx) const
inlinevirtualinherited

Get filter decision:

Definition at line 93 of file AthCommonAlgorithm.h.

93 {
94 return execState( ctx ).filterPassed();
95 }
virtual bool filterPassed(const EventContext &ctx) const
Get filter decision:

◆ finalize()

StatusCode LArG4GenShowerLib::finalize ( )
overridevirtual

Definition at line 442 of file LArG4GenShowerLib.cxx.

443{
444
445 // add condition tags
447
448 libMap::iterator itr;
449 for (itr = m_libraries_by_filename.begin();itr != m_libraries_by_filename.end();++itr){
450 ATH_MSG_DEBUG ( "Writing shower library to file " << (*itr).first );
451
452 TFile libr((*itr).first.c_str(),"RECREATE");
453
454 if (!(*itr).second->writeToROOT(&libr)) {
455 ATH_MSG_ERROR ( "Wasn't able to write " << (*itr).first << ". Probably empty lib." );
456 }
457
458 libr.Close();
459 }
460 if (m_stat_numshowers> 0) {
461 ATH_MSG_DEBUG ( "********Statistics for GenShowerLib********" );
462 ATH_MSG_DEBUG ( "Total number of showers: " << m_stat_numshowers
463 << ", valid: "<< m_stat_valid << " (" << (m_stat_valid*100)/m_stat_numshowers << "%)"
464 << ", invalid: " << m_stat_invalid << " (" << (m_stat_invalid*100)/m_stat_numshowers << "%)" );
465 for (itr = m_libraries.begin();itr != m_libraries.end();++itr){
466 ATH_MSG_DEBUG ( "*******************************************" );
467 std::stringstream ss((*itr).second->statistics());
468 for(std::string line; std::getline(ss,line);)
469 ATH_MSG_DEBUG ( line );
470 ATH_MSG_DEBUG ( "Saved: " << m_stat_lib_saved[(*itr).second] << " Rejected: " << m_stat_lib_notsaved[(*itr).second] );
471 }
472 ATH_MSG_DEBUG ( "*******************************************" );
473 ATH_MSG_DEBUG ( "Showers with no corresponding library: " << m_stat_nolib << " (" << (m_stat_nolib*100)/m_stat_numshowers << "%)" );
474 }
475 ATH_MSG_DEBUG ( "Finalized." );
476
477 return StatusCode::SUCCESS;
478}
#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 255 of file LArG4GenShowerLib.cxx.

256{
257 const McEventCollection* mcEvent;
258 if (evtStore()->retrieve(mcEvent,"GEN_EVENT").isFailure()) return nullptr;
259
260 // Return the last particle of the event.
261 if (mcEvent)
262 return !mcEvent->at(0)->particles().empty() ? mcEvent->at(0)->particles().back() : nullptr;
263
264 return nullptr;
265}
ServiceHandle< StoreGateSvc > & evtStore()
const T * at(size_type n) const
Access an element, as an rvalue.

◆ getStepInfo()

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

Definition at line 267 of file LArG4GenShowerLib.cxx.

268{
269 const ShowerLib::StepInfoCollection* eventStepsES;
270 if (evtStore()->retrieve(eventStepsES, "EventSteps").isFailure()) return nullptr;
271
272 return eventStepsES;
273
274}

◆ initialize()

StatusCode LArG4GenShowerLib::initialize ( )
overridevirtual

Definition at line 83 of file LArG4GenShowerLib.cxx.

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

◆ isClonable()

virtual bool AthCommonAlgorithm< Gaudi::Algorithm >::isClonable ( ) const
inlineoverridevirtualinherited

Specify if the algorithm is clonable.

Only relevant for non-reentrant algorithms. Actual number of clones needs to be set via the "Cardinality" property.

Reimplemented in AFP_DigiTop, AlgB, AlgT, BCM_Digitization, CscDigitBuilder, CscDigitToCscRDO, G4AtlasAlg, G4RunAlg, HGTD_Digitization, HiveAlgBase, InDet::GNNSeedingTrackMaker, InDet::SCT_Clusterization, InDet::SiSPGNNTrackMaker, InDet::SiSPSeededTrackFinder, InDet::SiTrackerSpacePointFinder, ISF::SimKernelMT, ITk::StripDigitization, ITkPixelCablingAlg, ITkStripCablingAlg, LArHitEMapMaker, LArTTL1Maker, LUCID_DigiTop, LVL1::L1TopoSimulation, MergeCalibHits, MergeGenericMuonSimHitColl, MergeHijingPars, MergeMcEventCollection, MergeTrackRecordCollection, MergeTruthJets, MergeTruthParticles, MuonDigitizer, PileUpMTAlg, PixelDigitization, RoIBResultToxAOD, SCT_ByteStreamErrorsTestAlg, SCT_CablingCondAlgFromCoraCool, SCT_CablingCondAlgFromText, SCT_ConditionsParameterTestAlg, SCT_ConditionsSummaryTestAlg, SCT_ConfigurationConditionsTestAlg, SCT_Digitization, SCT_FlaggedConditionTestAlg, SCT_LinkMaskingTestAlg, SCT_MajorityConditionsTestAlg, SCT_ModuleVetoTestAlg, SCT_MonitorConditionsTestAlg, SCT_PrepDataToxAOD, SCT_RawDataToxAOD, SCT_ReadCalibChipDataTestAlg, SCT_ReadCalibDataTestAlg, SCT_RODVetoTestAlg, SCT_SensorsTestAlg, SCT_SiliconConditionsTestAlg, SCT_StripVetoTestAlg, SCT_TdaqEnabledTestAlg, SCT_TestCablingAlg, SCTEventFlagWriter, SCTRawDataProvider, SCTSiLorentzAngleTestAlg, SCTSiPropertiesTestAlg, SGInputLoader, Simulation::BeamEffectsAlg, TileHitVecToCnt, TileMuonFitter, TilePulseForTileMuonReceiver, TileRawChannelMaker, TRTDigitization, and ZDC_DigiTop.

Definition at line 68 of file AthCommonAlgorithm.h.

68 {
69 return true;
70 }

◆ isReEntrant()

virtual bool AthAlgorithm::isReEntrant ( ) const
inlinefinaloverrideprotectedvirtualinherited

Legacy algorithms are not thread-safe.

Definition at line 47 of file AthAlgorithm.h.

47{ return false; }

◆ msg()

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

Definition at line 24 of file AthCommonMsg.h.

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

◆ msgLvl()

bool AthCommonMsg< Gaudi::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< Gaudi::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< Gaudi::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< Gaudi::Algorithm > >::renounceArray ( SG::VarHandleKeyArray & handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364 {
366 }

◆ setFilterPassed()

virtual void AthCommonAlgorithm< Gaudi::Algorithm >::setFilterPassed ( bool state,
const EventContext & ctx ) const
inlinevirtualinherited

Set filter decision:

Reimplemented in AthFilterAlgorithm.

Definition at line 99 of file AthCommonAlgorithm.h.

99 {
101 }
virtual void setFilterPassed(bool state, const EventContext &ctx) const
Set filter decision:

◆ sysExecute()

StatusCode AthCommonAlgorithm< Gaudi::Algorithm >::sysExecute ( const EventContext & ctx)
overridevirtualinherited

Execute an algorithm.

We override this in order to work around an issue with the Algorithm base class storing the event context in a member variable that can cause crashes in MT jobs.

Reimplemented in AthAnalysisAlgorithm.

Definition at line 80 of file AthCommonAlgorithm.cxx.

41{
42 return BaseAlg::sysExecute (ctx);
43}

◆ sysInitialize()

StatusCode AthCommonAlgorithm< Gaudi::Algorithm >::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< Gaudi::Algorithm > >.

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

Definition at line 60 of file AthCommonAlgorithm.cxx.

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

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< Gaudi::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 369 of file LArG4GenShowerLib.cxx.

370{
371 double etot = 0;
372 stepinfo->sort(stepInfoDistCompare(stepInfoDistCompare::RHO));
373
374 for (ShowerLib::StepInfoList::const_iterator i(stepinfo->begin()); i != stepinfo->end(); ++i) {
375 etot += (*i)->dep();
376 }
377
378 double minEnergy = m_minEnergy * etot;
379 double rsum = 0.;
380 ShowerLib::StepInfoList::iterator iterCut;
381 //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) )
382 for (iterCut = stepinfo->begin(); (iterCut != stepinfo->end()) && (((*iterCut)->position().mag2() < m_maxDistance) || (rsum < minEnergy));++iterCut) {
383 rsum += (*iterCut)->dep();
384 }
385
386 if (iterCut == stepinfo->end()) {
387 return;
388 }
389
390 stepinfo->erase(iterCut,stepinfo->end());
391
392 if (rsum == 0) { //WTF?
393 return;
394 }
395
396 const double inv_rsum = 1. / rsum;
397 for (iterCut = stepinfo->begin(); iterCut != stepinfo->end(); ++iterCut){
398 (*iterCut)->setE((*iterCut)->dep() * etot*inv_rsum);
399 }
400
401}
DoubleProperty m_maxDistance
property, see LArG4GenShowerLib::LArG4GenShowerLib
DoubleProperty m_minEnergy
property, see LArG4GenShowerLib::LArG4GenShowerLib

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< Gaudi::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 }

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< Gaudi::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< Gaudi::Algorithm > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default).

Definition at line 390 of file AthCommonDataStore.h.

◆ m_extendedExtraObjects

DataObjIDColl AthCommonAlgorithm< Gaudi::Algorithm >::m_extendedExtraObjects
privateinherited

Extra output dependency collection, extended by AthAlgorithmDHUpdate to add symlinks.

Empty if no symlinks were found.

Definition at line 108 of file AthCommonAlgorithm.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< Gaudi::Algorithm > >::m_varHandleArraysDeclared
privateinherited

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

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

Definition at line 398 of file AthCommonDataStore.h.


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