 |
ATLAS Offline Software
|
Class for shower library generation algorithm.
More...
#include <LArG4GenShowerLib.h>
|
virtual StatusCode | initialize () override |
|
virtual StatusCode | finalize () override |
|
virtual StatusCode | execute () override |
|
| AthAlgorithm (const std::string &name, ISvcLocator *pSvcLocator) |
| Constructor with parameters: More...
|
|
virtual StatusCode | sysInitialize () override |
| Override sysInitialize. More...
|
|
virtual const DataObjIDColl & | extraOutputDeps () const override |
| Return the list of extra output dependencies. More...
|
|
ServiceHandle< StoreGateSvc > & | evtStore () |
| The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc . More...
|
|
const ServiceHandle< StoreGateSvc > & | evtStore () const |
| The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc . More...
|
|
const ServiceHandle< StoreGateSvc > & | detStore () const |
| The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc . More...
|
|
virtual StatusCode | sysStart () override |
| Handle START transition. More...
|
|
virtual std::vector< Gaudi::DataHandle * > | inputHandles () const override |
| Return this algorithm's input handles. More...
|
|
virtual std::vector< Gaudi::DataHandle * > | outputHandles () const override |
| Return this algorithm's output handles. More...
|
|
Gaudi::Details::PropertyBase & | declareProperty (Gaudi::Property< T, V, H > &t) |
|
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, SG::VarHandleKey &hndl, const std::string &doc, const SG::VarHandleKeyType &) |
| Declare a new Gaudi property. More...
|
|
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, SG::VarHandleBase &hndl, const std::string &doc, const SG::VarHandleType &) |
| Declare a new Gaudi property. More...
|
|
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, SG::VarHandleKeyArray &hndArr, const std::string &doc, const SG::VarHandleKeyArrayType &) |
|
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, T &property, const std::string &doc, const SG::NotHandleType &) |
| Declare a new Gaudi property. More...
|
|
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, T &property, const std::string &doc="none") |
| Declare a new Gaudi property. More...
|
|
void | updateVHKA (Gaudi::Details::PropertyBase &) |
|
MsgStream & | msg () const |
|
MsgStream & | msg (const MSG::Level lvl) const |
|
bool | msgLvl (const MSG::Level lvl) const |
|
|
void | clusterize (ShowerLib::StepInfoList *stepinfo) |
|
const ShowerLib::StepInfoCollection * | getStepInfo () |
|
ShowerLib::StepInfoList * | copyStepInfo (const ShowerLib::StepInfoCollection *stepinfo) |
|
ShowerLib::StepInfoList * | copyStepInfoZeroCleanup (const ShowerLib::StepInfoCollection *stepinfo) |
|
void | truncate (ShowerLib::StepInfoList *stepinfo) |
|
HepMC::ConstGenParticlePtr | getParticleFromMC () |
| return first MC truth particle for event More...
|
|
void | calculateMoments (const ShowerLib::StepInfoCollection &eventSteps, double &weights, double &xavfra, double &yavfra, double &ravfra) |
| calculate moments from StepInfoCollection More...
|
|
void | addingTagsToLibrary () |
| adding tag information (release, detector description, ...) to library comment More...
|
|
Gaudi::Details::PropertyBase & | declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &) |
| specialization for handling Gaudi::Property<SG::VarHandleKey> More...
|
|
Gaudi::Details::PropertyBase & | declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyArrayType &) |
| specialization for handling Gaudi::Property<SG::VarHandleKeyArray> More...
|
|
Gaudi::Details::PropertyBase & | declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleType &) |
| specialization for handling Gaudi::Property<SG::VarHandleBase> More...
|
|
Gaudi::Details::PropertyBase & | declareGaudiProperty (Gaudi::Property< T, V, H > &t, const SG::NotHandleType &) |
| specialization for handling everything that's not a Gaudi::Property<SG::VarHandleKey> or a <SG::VarHandleKeyArray> More...
|
|
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.
◆ libMap
◆ StoreGateSvc_t
◆ addingTagsToLibrary()
void LArG4GenShowerLib::addingTagsToLibrary |
( |
| ) |
|
|
private |
adding tag information (release, detector description, ...) to library comment
Definition at line 408 of file LArG4GenShowerLib.cxx.
410 char* atlasProject =
getenv(
"AtlasProject");
411 char* atlasVersion =
getenv(
"AtlasVersion");
412 std::string atlasReleaseTag = (atlasProject? std::string(atlasProject)+std::string(
"-") : std::string(
"Unknown-"));
414 atlasReleaseTag += std::string(atlasVersion);
417 atlasReleaseTag += std::string(
"Unknown");
423 (*itr).second->release(atlasReleaseTag);
427 (*itr).second->geometry(geoModelSvc->atlasVersion());
433 std::string g4Version = G4Version;
434 size_t pos = g4Version.find(
"$Name: ");
435 if (
pos != std::string::npos) {
436 g4Version.erase(
pos, 7);
438 pos = g4Version.find(
" $");
439 if (
pos != std::string::npos) {
440 g4Version.erase(
pos, 2);
442 (*itr).second->geantVersion(g4Version);
◆ AthAlgorithm()
AthAlgorithm::AthAlgorithm |
Constructor with parameters:
Definition at line 51 of file AthAlgorithm.cxx.
32 std::make_unique<AthenaBaseComps::AthAlgorithmDHUpdate>
34 std::move (m_updateDataHandles));
◆ calculateMoments()
calculate moments from StepInfoCollection
Definition at line 486 of file LArG4GenShowerLib.cxx.
490 double xav(0.), yav(0.), xav2(0.), yav2(0.);
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();
501 const double inv_escal = 1. / escal;
502 xavfra = xav*inv_escal;
503 yavfra = yav*inv_escal;
505 ravfra = std::sqrt(std::abs((xav2*inv_escal-xavfra*xavfra) +
506 (yav2*inv_escal-yavfra*yavfra)));
◆ clusterize()
Definition at line 323 of file LArG4GenShowerLib.cxx.
325 typedef std::multimap<double,Dist> distMap;
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)));
339 int cursize = stepinfo->size();
342 while (cursize > 1) {
344 while ( !( (*iter).second.h1->valid() && (*iter).second.h2->valid() ) ) {
345 distances.erase(
iter++);
348 if ((*iter).first > rmin )
break;
353 if ((*i_h1)->valid()){
354 distances.insert(distMap::value_type((*i_h1)->diff2(*mergedHit),
Dist(*i_h1, mergedHit)));
358 stepinfo->push_back(mergedHit);
368 i = stepinfo->erase(
i);
◆ copyStepInfo()
◆ copyStepInfoZeroCleanup()
◆ declareGaudiProperty() [1/4]
specialization for handling Gaudi::Property<SG::VarHandleKeyArray>
Definition at line 170 of file AthCommonDataStore.h.
175 hndl.documentation());
◆ declareGaudiProperty() [2/4]
specialization for handling Gaudi::Property<SG::VarHandleKey>
Definition at line 156 of file AthCommonDataStore.h.
161 hndl.documentation());
◆ declareGaudiProperty() [3/4]
specialization for handling Gaudi::Property<SG::VarHandleBase>
Definition at line 184 of file AthCommonDataStore.h.
189 hndl.documentation());
◆ declareGaudiProperty() [4/4]
◆ declareProperty() [1/6]
Declare a new Gaudi property.
- Parameters
-
name | Name of the property. |
hndl | Object holding the property value. |
doc | Documentation string for the property. |
This is the version for types that derive from SG::VarHandleBase
. The property value object is put on the input and output lists as appropriate; then we forward to the base class.
Definition at line 245 of file AthCommonDataStore.h.
250 this->declare(hndl.
vhKey());
251 hndl.
vhKey().setOwner(
this);
253 return PBASE::declareProperty(
name,hndl,
doc);
◆ declareProperty() [2/6]
Declare a new Gaudi property.
- Parameters
-
name | Name of the property. |
hndl | Object holding the property value. |
doc | Documentation string for the property. |
This is the version for types that derive from SG::VarHandleKey
. The property value object is put on the input and output lists as appropriate; then we forward to the base class.
Definition at line 221 of file AthCommonDataStore.h.
229 return PBASE::declareProperty(
name,hndl,
doc);
◆ declareProperty() [3/6]
◆ declareProperty() [4/6]
Declare a new Gaudi property.
- Parameters
-
name | Name of the property. |
property | Object holding the property value. |
doc | Documentation string for the property. |
This is the generic version, for types that do not derive from SG::VarHandleKey
. It just forwards to the base class version of declareProperty
.
Definition at line 333 of file AthCommonDataStore.h.
338 return PBASE::declareProperty(
name, property,
doc);
◆ declareProperty() [5/6]
Declare a new Gaudi property.
- Parameters
-
name | Name of the property. |
property | Object holding the property value. |
doc | Documentation string for the property. |
This dispatches to either the generic declareProperty
or the one for VarHandle/Key/KeyArray.
Definition at line 352 of file AthCommonDataStore.h.
◆ declareProperty() [6/6]
◆ detStore()
◆ evtStore() [1/2]
◆ evtStore() [2/2]
◆ execute()
StatusCode LArG4GenShowerLib::execute |
( |
| ) |
|
|
overridevirtual |
Definition at line 125 of file LArG4GenShowerLib.cxx.
132 return StatusCode::FAILURE;
137 double fraction = eventStepsES->
invalid_energy/theParticle->momentum().e();
139 ATH_MSG_WARNING (
"Shower deposited too much energy outside the calorimeter region (" << (
int)(fraction*100) <<
"%), ignoring" );
141 return StatusCode::SUCCESS;
148 if (eventStepsES->
size()>500) {
155 for (ShowerLib::StepInfoList::const_iterator
iter = eventSteps->begin();
iter != eventSteps->end();++
iter) {
156 etot += (*iter)->dep();
159 std::stringstream location;
161 location << eventStepsES->
detector <<
"/" << theParticle->pdg_id();
171 return StatusCode::SUCCESS;
174 Hep3Vector origin(theParticle->production_vertex()->position().x(),
175 theParticle->production_vertex()->position().y(),
176 theParticle->production_vertex()->position().z());
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();
191 Hep3Vector HitDir = (*i)->position() - origin;
193 (*i)->setX(HitDir*OrthoShower);
194 (*i)->setY(HitDir*CrossShower);
195 (*i)->setZ(HitDir*DirectionShower);
202 ATH_MSG_VERBOSE (
"Size after clusterization: " << eventSteps->size() );
204 if (eventSteps->size() > 10) {
209 double maxZ = 0, maxR = 0;
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();
225 iter = eventSteps->begin();
226 for (;(
iter != eventSteps->end()) && (edep < containmentEnergy);++
iter) {
227 edep += (*iter)->dep();
228 maxZ = (*iter)->position().z();
244 if ((*
m_libraries.find(location.str())).second->storeShower(theParticle, shower)) {
247 ATH_MSG_WARNING (
"Wasn't able to store shower (" << location.str() <<
")" );
253 return StatusCode::SUCCESS;
◆ extraDeps_update_handler()
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.
57 return Algorithm::extraOutputDeps();
◆ finalize()
StatusCode LArG4GenShowerLib::finalize |
( |
| ) |
|
|
overridevirtual |
Definition at line 447 of file LArG4GenShowerLib.cxx.
455 ATH_MSG_DEBUG (
"Writing shower library to file " << (*itr).first );
457 TFile libr((*itr).first.c_str(),
"RECREATE");
459 if (!(*itr).second->writeToROOT(&libr)) {
460 ATH_MSG_ERROR (
"Wasn't able to write " << (*itr).first <<
". Probably empty lib." );
466 ATH_MSG_DEBUG (
"********Statistics for GenShowerLib********" );
471 ATH_MSG_DEBUG (
"*******************************************" );
472 std::stringstream
ss((*itr).second->statistics());
477 ATH_MSG_DEBUG (
"*******************************************" );
482 return StatusCode::SUCCESS;
◆ getParticleFromMC()
return first MC truth particle for event
Definition at line 256 of file LArG4GenShowerLib.cxx.
264 return !mcEvent->
at(0)->particles().empty() ? mcEvent->
at(0)->particles().back() :
nullptr;
266 return ( * (* mcEvent->
begin())->particles_end());
◆ getStepInfo()
◆ initialize()
StatusCode LArG4GenShowerLib::initialize |
( |
| ) |
|
|
overridevirtual |
Definition at line 84 of file LArG4GenShowerLib.cxx.
90 std::vector< std::string >::const_iterator nameiter;
99 if (library ==
nullptr) {
100 ATH_MSG_WARNING (
"Library structure file " << (*nameiter) <<
" doesn't describe a valid library" );
104 std::stringstream location;
111 ATH_MSG_VERBOSE (
"Library named " << (*nameiter)+
".root" <<
"is stored at the location " << location.str() );
116 ATH_MSG_ERROR (
"No valid library structure files found. Further execution is pointless." );
117 return StatusCode::FAILURE;
122 return StatusCode::SUCCESS;
◆ inputHandles()
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() [1/2]
◆ msg() [2/2]
◆ msgLvl()
◆ outputHandles()
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()
◆ renounceArray()
◆ sysInitialize()
StatusCode AthAlgorithm::sysInitialize |
( |
| ) |
|
|
overridevirtualinherited |
◆ sysStart()
Handle START transition.
We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.
◆ truncate()
Definition at line 374 of file LArG4GenShowerLib.cxx.
379 for (ShowerLib::StepInfoList::const_iterator
i(stepinfo->begin());
i != stepinfo->end(); ++
i) {
387 for (iterCut = stepinfo->begin(); (iterCut != stepinfo->end()) && (((*iterCut)->position().mag2() <
m_maxDistance) || (rsum < minEnergy));++iterCut) {
388 rsum += (*iterCut)->dep();
391 if (iterCut == stepinfo->end()) {
395 stepinfo->erase(iterCut,stepinfo->end());
401 const double inv_rsum = 1. / rsum;
402 for (iterCut = stepinfo->begin(); iterCut != stepinfo->end(); ++iterCut){
403 (*iterCut)->setE((*iterCut)->dep() * etot*inv_rsum);
◆ updateVHKA()
◆ m_containmentEnergy
DoubleProperty LArG4GenShowerLib::m_containmentEnergy |
|
private |
◆ m_detStore
◆ m_energyFraction
DoubleProperty LArG4GenShowerLib::m_energyFraction |
|
private |
◆ m_evtStore
◆ m_extendedExtraObjects
DataObjIDColl AthAlgorithm::m_extendedExtraObjects |
|
privateinherited |
◆ 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.
◆ m_libraries
libMap LArG4GenShowerLib::m_libraries |
|
private |
◆ m_libraries_by_filename
libMap LArG4GenShowerLib::m_libraries_by_filename |
|
private |
◆ m_maxDistance
DoubleProperty LArG4GenShowerLib::m_maxDistance |
|
private |
◆ m_maxRadius
DoubleProperty LArG4GenShowerLib::m_maxRadius |
|
private |
◆ m_minEnergy
DoubleProperty LArG4GenShowerLib::m_minEnergy |
|
private |
◆ 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.
◆ m_stat_invalid
int LArG4GenShowerLib::m_stat_invalid {0} |
|
private |
◆ m_stat_lib_notsaved
◆ m_stat_lib_saved
◆ m_stat_nolib
int LArG4GenShowerLib::m_stat_nolib {0} |
|
private |
◆ m_stat_numshowers
int LArG4GenShowerLib::m_stat_numshowers {0} |
|
private |
◆ m_stat_valid
int LArG4GenShowerLib::m_stat_valid {0} |
|
private |
◆ m_varHandleArraysDeclared
◆ m_vhka
The documentation for this class was generated from the following files:
def retrieve(aClass, aKey=None)
JetConstituentVector::iterator iterator
void setZSize(const float zsize)
void truncate(ShowerLib::StepInfoList *stepinfo)
Const iterator class for DataVector/DataList.
DoubleProperty m_energyFraction
property, see LArG4GenShowerLib::LArG4GenShowerLib
Class for shower library shower.
std::map< ShowerLib::IShowerLib *, int > m_stat_lib_notsaved
virtual const std::string detector() const
get detector tag
std::list< StepInfo * > StepInfoList
const ShowerLib::StepInfoCollection * getStepInfo()
libMap m_libraries
pointer to shower library
StoreGateSvc_t m_evtStore
Pointer to StoreGate (event store by default)
std::vector< SG::VarHandleKeyArray * > m_vhka
DoubleProperty m_maxRadius
property, see LArG4GenShowerLib::LArG4GenShowerLib
Class for collection of StepInfo class (G4 hits)
ShowerLib::StepInfoList * copyStepInfo(const ShowerLib::StepInfoCollection *stepinfo)
#define ATH_MSG_VERBOSE(x)
ShowerLib::StepInfoList * copyStepInfoZeroCleanup(const ShowerLib::StepInfoCollection *stepinfo)
DoubleProperty m_maxDistance
property, see LArG4GenShowerLib::LArG4GenShowerLib
virtual int particle_id() const
get particle tag
StringArrayProperty m_lib_struct_files
virtual void setOwner(IDataHandleHolder *o)=0
IShowerLib * iterateStruct(const std::string &fname)
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
virtual StatusCode sysInitialize() override
Override sysInitialize.
virtual std::vector< Gaudi::DataHandle * > outputHandles() const override
Return this algorithm's output handles.
StringProperty m_physicslist_name
void addingTagsToLibrary()
adding tag information (release, detector description, ...) to library comment
::StatusCode StatusCode
StatusCode definition for legacy code.
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
Class for shower library shower lib interface.
void clusterize(ShowerLib::StepInfoList *stepinfo)
StoreGateSvc_t m_detStore
Pointer to StoreGate (detector store by default)
This defines the McEventCollection, which is really just an ObjectVector of McEvent objects.
DoubleProperty m_minEnergy
property, see LArG4GenShowerLib::LArG4GenShowerLib
virtual void renounce()=0
std::conditional< std::is_base_of< SG::VarHandleKeyArray, T >::value, VarHandleKeyArrayType, type2 >::type type
libMap m_libraries_by_filename
HepMC::ConstGenParticlePtr getParticleFromMC()
return first MC truth particle for event
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
DoubleProperty m_containmentEnergy
property, see LArG4GenShowerLib::LArG4GenShowerLib
DataObjIDColl m_extendedExtraObjects
std::string getenv(const std::string &variableName)
get an environment variable
#define ATH_MSG_WARNING(x)
void setRSize(const float rsize)
SG::VarHandleKey & vhKey()
Return a non-const reference to the HandleKey.
const T * at(size_type n) const
Access an element, as an rvalue.
size_type size() const noexcept
Returns the number of elements in the collection.
std::map< ShowerLib::IShowerLib *, int > m_stat_lib_saved
Class to collect information about G4 steps.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.