|
ATLAS Offline Software
|
Class for shower library generation algorithm.
More...
#include <LArG4GenShowerLib.h>
|
| LArG4GenShowerLib (const std::string &name, ISvcLocator *pSvcLocator) |
|
StatusCode | initialize () |
|
StatusCode | finalize () |
|
StatusCode | execute () |
|
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 > &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 > &hndl, const SG::VarHandleKeyType &) |
| specialization for handling Gaudi::Property<SG::VarHandleKey> More...
|
|
Gaudi::Details::PropertyBase & | declareGaudiProperty (Gaudi::Property< T > &hndl, const SG::VarHandleKeyArrayType &) |
| specialization for handling Gaudi::Property<SG::VarHandleKeyArray> More...
|
|
Gaudi::Details::PropertyBase & | declareGaudiProperty (Gaudi::Property< T > &hndl, const SG::VarHandleType &) |
| specialization for handling Gaudi::Property<SG::VarHandleBase> More...
|
|
Gaudi::Details::PropertyBase & | declareGaudiProperty (Gaudi::Property< T > &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
◆ LArG4GenShowerLib()
LArG4GenShowerLib::LArG4GenShowerLib |
( |
const std::string & |
name, |
|
|
ISvcLocator * |
pSvcLocator |
|
) |
| |
Definition at line 84 of file LArG4GenShowerLib.cxx.
88 "max distance squared after which the hits will be truncated");
90 "energy border, that truncation won't cross");
92 "maximal radius squared until two hits will be combined");
94 "energy fraction that will be inside containment borders");
96 "List of files to read library structures from");
98 "the allowed amount of energy that can be deposited outside calorimeter region ");
◆ addingTagsToLibrary()
void LArG4GenShowerLib::addingTagsToLibrary |
( |
| ) |
|
|
private |
adding tag information (release, detector description, ...) to library comment
Definition at line 427 of file LArG4GenShowerLib.cxx.
429 char* atlasProject =
getenv(
"AtlasProject");
430 char* atlasVersion =
getenv(
"AtlasVersion");
431 std::string atlasReleaseTag = (atlasProject? std::string(atlasProject)+std::string(
"-") : std::string(
"Unknown-"));
433 atlasReleaseTag += std::string(atlasVersion);
436 atlasReleaseTag += std::string(
"Unknown");
442 (*itr).second->release(atlasReleaseTag);
446 (*itr).second->geometry(geoModelSvc->atlasVersion());
452 std::string g4Version = G4Version;
453 size_t pos = g4Version.find(
"$Name: ");
454 if (
pos != std::string::npos) {
455 g4Version.erase(
pos, 7);
457 pos = g4Version.find(
" $");
458 if (
pos != std::string::npos) {
459 g4Version.erase(
pos, 2);
461 (*itr).second->geantVersion(g4Version);
◆ calculateMoments()
calculate moments from StepInfoCollection
Definition at line 505 of file LArG4GenShowerLib.cxx.
509 double xav(0.), yav(0.), xav2(0.), yav2(0.);
512 escal += (*i)->dep();
513 xav += (*i)->x()*(*i)->dep();
514 yav += (*i)->y()*(*i)->dep();
515 xav2 += (*i)->x()*(*i)->x()*(*i)->dep();
516 yav2 += (*i)->y()*(*i)->y()*(*i)->dep();
522 const double inv_escal = 1. / escal;
523 xavfra = xav*inv_escal;
524 yavfra = yav*inv_escal;
526 ravfra = std::sqrt(std::abs((xav2*inv_escal-xavfra*xavfra) +
527 (yav2*inv_escal-yavfra*yavfra)));
◆ clusterize()
Definition at line 342 of file LArG4GenShowerLib.cxx.
344 typedef std::multimap<double,Dist> distMap;
351 for (ShowerLib::StepInfoList::reverse_iterator i_h2(stepinfo->rbegin()); (*i_h2) != (*i_h1); ++i_h2) {
352 distances.insert(distMap::value_type((*i_h1)->diff2(**i_h2),
Dist(*i_h1, *i_h2)));
358 int cursize = stepinfo->size();
361 while (cursize > 1) {
363 while ( !( (*iter).second.h1->valid() && (*iter).second.h2->valid() ) ) {
364 distances.erase(iter++);
367 if ((*iter).first > rmin )
break;
372 if ((*i_h1)->valid()){
373 distances.insert(distMap::value_type((*i_h1)->diff2(*mergedHit),
Dist(*i_h1, mergedHit)));
377 stepinfo->push_back(mergedHit);
387 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 |
( |
| ) |
|
Definition at line 144 of file LArG4GenShowerLib.cxx.
151 return StatusCode::FAILURE;
156 double fraction = eventStepsES->
invalid_energy/theParticle->momentum().e();
158 ATH_MSG_WARNING (
"Shower deposited too much energy outside the calorimeter region (" << (
int)(fraction*100) <<
"%), ignoring" );
160 return StatusCode::SUCCESS;
167 if (eventStepsES->
size()>500) {
174 for (ShowerLib::StepInfoList::const_iterator iter = eventSteps->begin();iter != eventSteps->end();++iter) {
175 etot += (*iter)->dep();
178 std::stringstream location;
180 location << eventStepsES->
detector <<
"/" << theParticle->pdg_id();
190 return StatusCode::SUCCESS;
193 Hep3Vector origin(theParticle->production_vertex()->position().x(),
194 theParticle->production_vertex()->position().y(),
195 theParticle->production_vertex()->position().z());
199 Hep3Vector DirectionShower(theParticle->momentum().px(),
200 theParticle->momentum().py(),
201 theParticle->momentum().pz());
202 DirectionShower /= DirectionShower.mag();
203 Hep3Vector OrthoShower = DirectionShower.orthogonal();
204 OrthoShower /= OrthoShower.mag();
205 Hep3Vector CrossShower = DirectionShower.cross(OrthoShower);
206 CrossShower /= CrossShower.mag();
210 Hep3Vector HitDir = (*i)->position() - origin;
212 (*i)->setX(HitDir*OrthoShower);
213 (*i)->setY(HitDir*CrossShower);
214 (*i)->setZ(HitDir*DirectionShower);
221 ATH_MSG_VERBOSE (
"Size after clusterization: " << eventSteps->size() );
223 if (eventSteps->size() > 10) {
228 double maxZ = 0, maxR = 0;
235 ShowerLib::StepInfoList::const_iterator iter = eventSteps->begin();
236 for (;(iter != eventSteps->end()) && (edep < containmentEnergy);++iter) {
237 edep += (*iter)->dep();
238 maxR = (*iter)->position().r();
244 iter = eventSteps->begin();
245 for (;(iter != eventSteps->end()) && (edep < containmentEnergy);++iter) {
246 edep += (*iter)->dep();
247 maxZ = (*iter)->position().z();
263 if ((*
m_libraries.find(location.str())).second->storeShower(theParticle, shower)) {
266 ATH_MSG_WARNING (
"Wasn't able to store shower (" << location.str() <<
")" );
272 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 |
( |
| ) |
|
Definition at line 466 of file LArG4GenShowerLib.cxx.
474 ATH_MSG_DEBUG (
"Writing shower library to file " << (*itr).first );
476 TFile libr((*itr).first.c_str(),
"RECREATE");
478 if (!(*itr).second->writeToROOT(&libr)) {
479 ATH_MSG_ERROR (
"Wasn't able to write " << (*itr).first <<
". Probably empty lib." );
485 ATH_MSG_DEBUG (
"********Statistics for GenShowerLib********" );
490 ATH_MSG_DEBUG (
"*******************************************" );
491 std::stringstream
ss((*itr).second->statistics());
496 ATH_MSG_DEBUG (
"*******************************************" );
501 return StatusCode::SUCCESS;
◆ getParticleFromMC()
return first MC truth particle for event
Definition at line 275 of file LArG4GenShowerLib.cxx.
283 return !mcEvent->
at(0)->particles().empty() ? mcEvent->
at(0)->particles().back() :
nullptr;
285 return ( * (* mcEvent->
begin())->particles_end());
◆ getStepInfo()
◆ initialize()
StatusCode LArG4GenShowerLib::initialize |
( |
| ) |
|
Definition at line 103 of file LArG4GenShowerLib.cxx.
109 std::vector< std::string >::const_iterator nameiter;
118 if (library ==
nullptr) {
119 ATH_MSG_WARNING (
"Library structure file " << (*nameiter) <<
" doesn't describe a valid library" );
123 std::stringstream location;
130 ATH_MSG_VERBOSE (
"Library named " << (*nameiter)+
".root" <<
"is stored at the location " << location.str() );
135 ATH_MSG_ERROR (
"No valid library structure files found. Further execution is pointless." );
136 return StatusCode::FAILURE;
141 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 393 of file LArG4GenShowerLib.cxx.
398 for (ShowerLib::StepInfoList::const_iterator
i(stepinfo->begin());
i != stepinfo->end(); ++
i) {
406 for (iterCut = stepinfo->begin(); (iterCut != stepinfo->end()) && (((*iterCut)->position().mag2() <
m_maxDistance) || (rsum < minEnergy));++iterCut) {
407 rsum += (*iterCut)->dep();
410 if (iterCut == stepinfo->end()) {
414 stepinfo->erase(iterCut,stepinfo->end());
420 const double inv_rsum = 1. / rsum;
421 for (iterCut = stepinfo->begin(); iterCut != stepinfo->end(); ++iterCut){
422 (*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 |
◆ 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
std::string LArG4GenShowerLib::m_physicslist_name |
|
private |
◆ m_stat_invalid
int LArG4GenShowerLib::m_stat_invalid |
|
private |
◆ m_stat_lib_notsaved
◆ m_stat_lib_saved
◆ m_stat_nolib
int LArG4GenShowerLib::m_stat_nolib |
|
private |
◆ m_stat_numshowers
int LArG4GenShowerLib::m_stat_numshowers |
|
private |
◆ m_stat_valid
int LArG4GenShowerLib::m_stat_valid |
|
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
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
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
std::string m_physicslist_name
virtual void setOwner(IDataHandleHolder *o)=0
IShowerLib * iterateStruct(const std::string &fname)
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.
void addingTagsToLibrary()
adding tag information (release, detector description, ...) to library comment
::StatusCode StatusCode
StatusCode definition for legacy code.
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.
AthAlgorithm()
Default constructor:
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.
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>
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.