CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Classes | Public Member Functions | Private Member Functions | Private Attributes
MaterialBudgetVolume Class Reference
Inheritance diagram for MaterialBudgetVolume:
SimProducer Observer< const BeginOfRun * > Observer< const BeginOfEvent * > Observer< const BeginOfTrack * > Observer< const G4Step * > Observer< const EndOfTrack * > SimWatcher

Classes

struct  MatInfo
 

Public Member Functions

 MaterialBudgetVolume (const edm::ParameterSet &p)
 
 MaterialBudgetVolume (const MaterialBudgetVolume &)=delete
 
const MaterialBudgetVolumeoperator= (const MaterialBudgetVolume &)=delete
 
void produce (edm::Event &, const edm::EventSetup &) override
 
 ~MaterialBudgetVolume () override
 
- Public Member Functions inherited from SimProducer
const SimProduceroperator= (const SimProducer &)=delete
 
void registerProducts (edm::ProducesCollector producesCollector)
 
 SimProducer ()
 
 SimProducer (const SimProducer &)=delete
 
- Public Member Functions inherited from SimWatcher
virtual void beginRun (edm::EventSetup const &)
 
bool isMT () const
 
const SimWatcheroperator= (const SimWatcher &)=delete
 
virtual void registerConsumes (edm::ConsumesCollector)
 
 SimWatcher ()
 
 SimWatcher (const SimWatcher &)=delete
 
virtual ~SimWatcher ()
 
- Public Member Functions inherited from Observer< const BeginOfRun * >
 Observer ()
 
void slotForUpdate (const BeginOfRun *iT)
 
virtual ~Observer ()
 
- Public Member Functions inherited from Observer< const BeginOfEvent * >
 Observer ()
 
void slotForUpdate (const BeginOfEvent *iT)
 
virtual ~Observer ()
 
- Public Member Functions inherited from Observer< const BeginOfTrack * >
 Observer ()
 
void slotForUpdate (const BeginOfTrack *iT)
 
virtual ~Observer ()
 
- Public Member Functions inherited from Observer< const G4Step * >
 Observer ()
 
void slotForUpdate (const G4Step *iT)
 
virtual ~Observer ()
 
- Public Member Functions inherited from Observer< const EndOfTrack * >
 Observer ()
 
void slotForUpdate (const EndOfTrack *iT)
 
virtual ~Observer ()
 

Private Member Functions

void endOfEvent (edm::MaterialInformationContainer &matbg)
 
int findLV (const G4VTouchable *)
 
bool loadLV ()
 
void update (const BeginOfRun *run) override
 This routine will be called when the appropriate signal arrives. More...
 
void update (const BeginOfEvent *evt) override
 This routine will be called when the appropriate signal arrives. More...
 
void update (const BeginOfTrack *) override
 This routine will be called when the appropriate signal arrives. More...
 
void update (const EndOfTrack *) override
 This routine will be called when the appropriate signal arrives. More...
 
void update (const G4Step *step) override
 This routine will be called when the appropriate signal arrives. More...
 

Private Attributes

int iaddLevel_
 
bool init_
 
std::vector< MatInfolengths_
 
std::vector< int > lvLevel_
 
std::vector< std::string > lvNames_
 
std::map< int, std::pair
< G4LogicalVolume *, int > > 
mapLV_
 
std::vector< MaterialInformationstore_
 

Additional Inherited Members

- Protected Member Functions inherited from SimProducer
template<class T >
void produces ()
 
template<class T >
void produces (const std::string &instanceName)
 
- Protected Member Functions inherited from SimWatcher
void setMT (bool val)
 

Detailed Description

Definition at line 36 of file MaterialBudgetVolume.cc.

Constructor & Destructor Documentation

MaterialBudgetVolume::MaterialBudgetVolume ( const edm::ParameterSet p)

Definition at line 77 of file MaterialBudgetVolume.cc.

References edm::ParameterSet::getParameter(), iaddLevel_, isotrackApplyRegressor::k, lvLevel_, and lvNames_.

77  : init_(false) {
78  edm::ParameterSet m_p = p.getParameter<edm::ParameterSet>("MaterialBudgetVolume");
79 
80  lvNames_ = m_p.getParameter<std::vector<std::string> >("lvNames");
81  lvLevel_ = m_p.getParameter<std::vector<int> >("lvLevels");
82  iaddLevel_ = (m_p.getParameter<bool>("useDD4hep")) ? 1 : 0;
83 
84  edm::LogVerbatim("MaterialBudget") << "MaterialBudgetVolume: Studies Material budget for " << lvNames_.size()
85  << " volumes with addLevel " << iaddLevel_;
86  std::ostringstream st1;
87  for (unsigned int k = 0; k < lvNames_.size(); ++k)
88  st1 << " [" << k << "] " << lvNames_[k] << " at " << lvLevel_[k];
89  edm::LogVerbatim("MaterialBudget") << "MaterialBudgetVolume: Volumes" << st1.str();
90 
91  produces<edm::MaterialInformationContainer>("MaterialInformation");
92 #ifdef EDM_ML_DEBUG
93  edm::LogVerbatim("MaterialBudget") << "MaterialBudgetVolume: will produce MaterialInformationContainer";
94 #endif
95 }
Log< level::Info, true > LogVerbatim
std::vector< std::string > lvNames_
std::vector< int > lvLevel_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
MaterialBudgetVolume::MaterialBudgetVolume ( const MaterialBudgetVolume )
delete
MaterialBudgetVolume::~MaterialBudgetVolume ( )
inlineoverride

Definition at line 46 of file MaterialBudgetVolume.cc.

46 {}

Member Function Documentation

void MaterialBudgetVolume::endOfEvent ( edm::MaterialInformationContainer matbg)
private

Definition at line 170 of file MaterialBudgetVolume.cc.

References info(), and store_.

Referenced by produce().

170  {
171 #ifdef EDM_ML_DEBUG
172  unsigned int kount(0);
173 #endif
174  for (const auto& element : store_) {
175  MaterialInformation info(element.vname(),
176  element.id(),
177  element.trackEta(),
178  element.trackPhi(),
179  element.stepLength(),
180  element.radiationLength(),
181  element.interactionLength());
182  matbg.push_back(info);
183 #ifdef EDM_ML_DEBUG
184  edm::LogVerbatim("MaterialBudget") << "MaterialBudgetVolume:: Info[" << kount << "] " << info;
185  ++kount;
186 #endif
187  }
188 }
Log< level::Info, true > LogVerbatim
static const TGPicture * info(bool iBackgroundIsBlack)
std::vector< MaterialInformation > store_
int MaterialBudgetVolume::findLV ( const G4VTouchable *  touch)
private

Definition at line 222 of file MaterialBudgetVolume.cc.

References mps_fire::i, cuy::ii, testEve_cfg::level, jetCorrFactors_cfi::levels, mapLV_, and edm::second().

Referenced by update().

222  {
223  int level(-1);
224  int levels = ((touch->GetHistoryDepth()) + 1);
225  for (const auto& lvs : mapLV_) {
226  if ((lvs.second).second <= levels) {
227  int ii = levels - (lvs.second).second;
228  if ((touch->GetVolume(ii)->GetLogicalVolume()) == (lvs.second).first) {
229  level = lvs.first;
230  break;
231  }
232  }
233  }
234 #ifdef EDM_ML_DEBUG
235  if (level < 0) {
236  edm::LogVerbatim("MaterialBudget") << "findLV: Gets " << level << " from " << levels << " levels in touchables";
237  for (int i = 0; i < levels; ++i)
238  edm::LogVerbatim("MaterialBudget") << "[" << (levels - i) << "] " << touch->GetVolume(i)->GetLogicalVolume()
239  << " : " << touch->GetVolume(i)->GetLogicalVolume()->GetName();
240  }
241 #endif
242  return level;
243 }
Log< level::Info, true > LogVerbatim
std::map< int, std::pair< G4LogicalVolume *, int > > mapLV_
int ii
Definition: cuy.py:589
U second(std::pair< T, U > const &p)
tuple level
Definition: testEve_cfg.py:47
bool MaterialBudgetVolume::loadLV ( )
private

Definition at line 190 of file MaterialBudgetVolume.cc.

References first, mps_fire::i, iaddLevel_, isotrackApplyRegressor::k, lvLevel_, lvNames_, mapLV_, mergeVDriftHistosByStation::name, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by update().

190  {
191  const G4LogicalVolumeStore* lvs = G4LogicalVolumeStore::GetInstance();
192  bool flag(false);
193  if (lvs != nullptr) {
194  std::vector<G4LogicalVolume*>::const_iterator lvcite;
195  for (unsigned int i = 0; i < lvNames_.size(); i++) {
196  G4LogicalVolume* lv = nullptr;
198  for (lvcite = lvs->begin(); lvcite != lvs->end(); lvcite++) {
199  std::string namx(dd4hep::dd::noNamespace((*lvcite)->GetName()));
200  if (namx == name) {
201  lv = (*lvcite);
202  break;
203  }
204  }
205  if (lv != nullptr)
206  mapLV_[i] = std::make_pair(lv, (lvLevel_[i] + iaddLevel_));
207  }
208  flag = true;
209 #ifdef EDM_ML_DEBUG
210  edm::LogVerbatim("MaterialBudget") << "MaterialBudgetVolume::Finds " << mapLV_.size() << " logical volumes";
211  unsigned int k(0);
212  for (const auto& lvs : mapLV_) {
213  edm::LogVerbatim("MaterialBudget") << "Entry[" << k << "] " << lvs.first << ": (" << (lvs.second).first << ", "
214  << (lvs.second).second << ") : " << lvNames_[lvs.first];
215  ++k;
216  }
217 #endif
218  }
219  return flag;
220 }
Log< level::Info, true > LogVerbatim
std::map< int, std::pair< G4LogicalVolume *, int > > mapLV_
std::vector< std::string > lvNames_
std::vector< int > lvLevel_
const MaterialBudgetVolume& MaterialBudgetVolume::operator= ( const MaterialBudgetVolume )
delete
void MaterialBudgetVolume::produce ( edm::Event e,
const edm::EventSetup  
)
overridevirtual

Implements SimProducer.

Definition at line 97 of file MaterialBudgetVolume.cc.

References endOfEvent(), eostools::move(), and edm::Event::put().

97  {
98  std::unique_ptr<edm::MaterialInformationContainer> matbg(new edm::MaterialInformationContainer);
99  endOfEvent(*matbg);
100  e.put(std::move(matbg), "MaterialInformation");
101 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
def move
Definition: eostools.py:511
std::vector< MaterialInformation > MaterialInformationContainer
void endOfEvent(edm::MaterialInformationContainer &matbg)
void MaterialBudgetVolume::update ( const BeginOfRun )
overrideprivatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfRun * >.

Definition at line 103 of file MaterialBudgetVolume.cc.

References init_, loadLV(), and mapLV_.

Referenced by MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), and MatrixUtil.Steps::overwrite().

103  {
104  init_ = loadLV();
105 
106 #ifdef EDM_ML_DEBUG
107  edm::LogVerbatim("MaterialBudget") << "MaterialBudgetVolume::Finds " << mapLV_.size()
108  << " logical volumes with return flag " << init_;
109 #endif
110 }
Log< level::Info, true > LogVerbatim
std::map< int, std::pair< G4LogicalVolume *, int > > mapLV_
void MaterialBudgetVolume::update ( const BeginOfEvent )
overrideprivatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfEvent * >.

Definition at line 112 of file MaterialBudgetVolume.cc.

References iev, init_, loadLV(), and store_.

Referenced by MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), and MatrixUtil.Steps::overwrite().

112  {
113 #ifdef EDM_ML_DEBUG
114  int iev = (*evt)()->GetEventID();
115  edm::LogVerbatim("MaterialBudget") << "MaterialBudgetVolume: =====> Begin event = " << iev << std::endl;
116 #endif
117  if (!init_)
118  init_ = loadLV();
119 
120  store_.clear();
121 }
Log< level::Info, true > LogVerbatim
std::vector< MaterialInformation > store_
HitContainer const *__restrict__ TkSoA const *__restrict__ Quality const *__restrict__ CAHitNtupletGeneratorKernelsGPU::HitToTuple const *__restrict__ int32_t int32_t int iev
void MaterialBudgetVolume::update ( const BeginOfTrack )
overrideprivatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfTrack * >.

Definition at line 123 of file MaterialBudgetVolume.cc.

References lengths_, and mapLV_.

Referenced by MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), and MatrixUtil.Steps::overwrite().

123  {
124  lengths_ = std::vector<MatInfo>(mapLV_.size());
125 
126 #ifdef EDM_ML_DEBUG
127  const G4Track* aTrack = (*trk)();
128  const G4ThreeVector& mom = aTrack->GetMomentum();
129  double theEnergy = aTrack->GetTotalEnergy();
130  int theID = static_cast<int>(aTrack->GetDefinition()->GetPDGEncoding());
131  edm::LogVerbatim("MaterialBudget") << "MaterialBudgetVolumme: Track " << aTrack->GetTrackID() << " Code " << theID
132  << " Energy " << theEnergy / CLHEP::GeV << " GeV; Momentum " << mom / CLHEP::GeV
133  << " GeV";
134 #endif
135 }
Log< level::Info, true > LogVerbatim
std::vector< MatInfo > lengths_
std::map< int, std::pair< G4LogicalVolume *, int > > mapLV_
void MaterialBudgetVolume::update ( const EndOfTrack )
overrideprivatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const EndOfTrack * >.

Definition at line 156 of file MaterialBudgetVolume.cc.

References PVValHelper::eta, info(), isotrackApplyRegressor::k, lengths_, lvNames_, phi, and store_.

Referenced by MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), and MatrixUtil.Steps::overwrite().

156  {
157  const G4Track* aTrack = (*trk)();
158  int id = aTrack->GetTrackID();
159  double eta = aTrack->GetMomentumDirection().eta();
160  double phi = aTrack->GetMomentumDirection().phi();
161  for (unsigned int k = 0; k < lengths_.size(); ++k) {
162  MaterialInformation info(lvNames_[k], id, eta, phi, lengths_[k].stepL, lengths_[k].radL, lengths_[k].intL);
163  store_.emplace_back(info);
164 #ifdef EDM_ML_DEBUG
165  edm::LogVerbatim("MaterialBudget") << "MaterialBudgetVolume::Volume[" << k << "]: " << info;
166 #endif
167  }
168 }
Log< level::Info, true > LogVerbatim
static const TGPicture * info(bool iBackgroundIsBlack)
std::vector< MatInfo > lengths_
std::vector< MaterialInformation > store_
std::vector< std::string > lvNames_
void MaterialBudgetVolume::update ( const G4Step *  )
overrideprivatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const G4Step * >.

Definition at line 137 of file MaterialBudgetVolume.cc.

References findLV(), and lengths_.

Referenced by MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), and MatrixUtil.Steps::overwrite().

137  {
138  G4Material* material = aStep->GetPreStepPoint()->GetMaterial();
139  double step = aStep->GetStepLength();
140  double radl = material->GetRadlen();
141  double intl = material->GetNuclearInterLength();
142  const G4VTouchable* touch = aStep->GetPreStepPoint()->GetTouchable();
143  int index = findLV(touch);
144  if (index >= 0) {
145  lengths_[index].stepL += step;
146  lengths_[index].radL += (step / radl);
147  lengths_[index].intL += (step / intl);
148  }
149 #ifdef EDM_ML_DEBUG
150  edm::LogVerbatim("MaterialBudget") << "MaterialBudgetVolume::Step in "
151  << touch->GetVolume(0)->GetLogicalVolume()->GetName() << " Index " << index
152  << " Step " << step << " RadL " << step / radl << " IntL " << step / intl;
153 #endif
154 }
Log< level::Info, true > LogVerbatim
std::vector< MatInfo > lengths_
int findLV(const G4VTouchable *)
step
Definition: StallMonitor.cc:98

Member Data Documentation

int MaterialBudgetVolume::iaddLevel_
private

Definition at line 70 of file MaterialBudgetVolume.cc.

Referenced by loadLV(), and MaterialBudgetVolume().

bool MaterialBudgetVolume::init_
private

Definition at line 71 of file MaterialBudgetVolume.cc.

Referenced by update().

std::vector<MatInfo> MaterialBudgetVolume::lengths_
private

Definition at line 73 of file MaterialBudgetVolume.cc.

Referenced by update().

std::vector<int> MaterialBudgetVolume::lvLevel_
private

Definition at line 69 of file MaterialBudgetVolume.cc.

Referenced by loadLV(), and MaterialBudgetVolume().

std::vector<std::string> MaterialBudgetVolume::lvNames_
private

Definition at line 68 of file MaterialBudgetVolume.cc.

Referenced by loadLV(), MaterialBudgetVolume(), and update().

std::map<int, std::pair<G4LogicalVolume*, int> > MaterialBudgetVolume::mapLV_
private

Definition at line 72 of file MaterialBudgetVolume.cc.

Referenced by findLV(), loadLV(), and update().

std::vector<MaterialInformation> MaterialBudgetVolume::store_
private

Definition at line 74 of file MaterialBudgetVolume.cc.

Referenced by endOfEvent(), and update().