CMS 3D CMS Logo

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
const SimWatcheroperator= (const SimWatcher &)=delete
 
 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 BeginOfEvent *evt) override
 This routine will be called when the appropriate signal arrives. More...
 
void update (const BeginOfRun *run) 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)
 

Detailed Description

Definition at line 36 of file MaterialBudgetVolume.cc.

Constructor & Destructor Documentation

◆ MaterialBudgetVolume() [1/2]

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

Definition at line 77 of file MaterialBudgetVolume.cc.

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 }

References edm::ParameterSet::getParameter(), iaddLevel_, dqmdumpme::k, lvLevel_, lvNames_, and AlCaHLTBitMon_ParallelJobs::p.

◆ MaterialBudgetVolume() [2/2]

MaterialBudgetVolume::MaterialBudgetVolume ( const MaterialBudgetVolume )
delete

◆ ~MaterialBudgetVolume()

MaterialBudgetVolume::~MaterialBudgetVolume ( )
inlineoverride

Definition at line 46 of file MaterialBudgetVolume.cc.

46 {}

Member Function Documentation

◆ endOfEvent()

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

Definition at line 170 of file MaterialBudgetVolume.cc.

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 }

References info(), and store_.

Referenced by produce().

◆ findLV()

int MaterialBudgetVolume::findLV ( const G4VTouchable *  touch)
private

Definition at line 222 of file MaterialBudgetVolume.cc.

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 }

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

Referenced by update().

◆ loadLV()

bool MaterialBudgetVolume::loadLV ( )
private

Definition at line 190 of file MaterialBudgetVolume.cc.

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 }

References first, RemoveAddSevLevel::flag, mps_fire::i, iaddLevel_, dqmdumpme::k, lvLevel_, lvNames_, mapLV_, Skims_PA_cff::name, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by update().

◆ operator=()

const MaterialBudgetVolume& MaterialBudgetVolume::operator= ( const MaterialBudgetVolume )
delete

◆ produce()

void MaterialBudgetVolume::produce ( edm::Event e,
const edm::EventSetup  
)
overridevirtual

Implements SimProducer.

Definition at line 97 of file MaterialBudgetVolume.cc.

97  {
98  std::unique_ptr<edm::MaterialInformationContainer> matbg(new edm::MaterialInformationContainer);
99  endOfEvent(*matbg);
100  e.put(std::move(matbg), "MaterialInformation");
101 }

References MillePedeFileConverter_cfg::e, endOfEvent(), and eostools::move().

◆ update() [1/5]

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.

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 }

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

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

◆ update() [2/5]

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.

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 }

References init_, loadLV(), and mapLV_.

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

◆ update() [3/5]

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.

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 }

References GeV, lengths_, and mapLV_.

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

◆ update() [4/5]

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.

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 }

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

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

◆ update() [5/5]

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.

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 }

References findLV(), and lengths_.

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

Member Data Documentation

◆ iaddLevel_

int MaterialBudgetVolume::iaddLevel_
private

Definition at line 70 of file MaterialBudgetVolume.cc.

Referenced by loadLV(), and MaterialBudgetVolume().

◆ init_

bool MaterialBudgetVolume::init_
private

Definition at line 71 of file MaterialBudgetVolume.cc.

Referenced by update().

◆ lengths_

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

Definition at line 73 of file MaterialBudgetVolume.cc.

Referenced by update().

◆ lvLevel_

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

Definition at line 69 of file MaterialBudgetVolume.cc.

Referenced by loadLV(), and MaterialBudgetVolume().

◆ lvNames_

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

Definition at line 68 of file MaterialBudgetVolume.cc.

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

◆ mapLV_

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

Definition at line 72 of file MaterialBudgetVolume.cc.

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

◆ store_

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

Definition at line 74 of file MaterialBudgetVolume.cc.

Referenced by endOfEvent(), and update().

personalPlayback.level
level
Definition: personalPlayback.py:22
mps_fire.i
i
Definition: mps_fire.py:428
iev
const HitContainer *__restrict__ const TkSoA *__restrict__ const Quality *__restrict__ const CAHitNtupletGeneratorKernelsGPU::HitToTuple *__restrict__ int32_t int iev
Definition: CAHitNtupletGeneratorKernelsImpl.h:862
step
step
Definition: StallMonitor.cc:94
edm::MaterialInformationContainer
std::vector< MaterialInformation > MaterialInformationContainer
Definition: MaterialInformation.h:48
MaterialBudgetVolume::lvNames_
std::vector< std::string > lvNames_
Definition: MaterialBudgetVolume.cc:68
edm::second
U second(std::pair< T, U > const &p)
Definition: ParameterSet.cc:222
info
static const TGPicture * info(bool iBackgroundIsBlack)
Definition: FWCollectionSummaryWidget.cc:153
MaterialBudgetVolume::init_
bool init_
Definition: MaterialBudgetVolume.cc:71
MaterialInformation
Definition: MaterialInformation.h:9
PVValHelper::eta
Definition: PVValidationHelpers.h:70
MaterialBudgetVolume::endOfEvent
void endOfEvent(edm::MaterialInformationContainer &matbg)
Definition: MaterialBudgetVolume.cc:170
dqmdumpme.k
k
Definition: dqmdumpme.py:60
first
auto first
Definition: CAHitNtupletGeneratorKernelsImpl.h:125
MaterialBudgetVolume::lvLevel_
std::vector< int > lvLevel_
Definition: MaterialBudgetVolume.cc:69
edm::ParameterSet
Definition: ParameterSet.h:47
AlCaHLTBitMon_ParallelJobs.p
def p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
GeV
const double GeV
Definition: MathUtil.h:16
MaterialBudgetVolume::lengths_
std::vector< MatInfo > lengths_
Definition: MaterialBudgetVolume.cc:73
MaterialBudgetVolume::store_
std::vector< MaterialInformation > store_
Definition: MaterialBudgetVolume.cc:74
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
DDAxes::phi
eostools.move
def move(src, dest)
Definition: eostools.py:511
MaterialBudgetVolume::mapLV_
std::map< int, std::pair< G4LogicalVolume *, int > > mapLV_
Definition: MaterialBudgetVolume.cc:72
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
MaterialBudgetVolume::loadLV
bool loadLV()
Definition: MaterialBudgetVolume.cc:190
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
MaterialBudgetVolume::findLV
int findLV(const G4VTouchable *)
Definition: MaterialBudgetVolume.cc:222
MaterialBudgetVolume::iaddLevel_
int iaddLevel_
Definition: MaterialBudgetVolume.cc:70
edm::Log
Definition: MessageLogger.h:70
cuy.ii
ii
Definition: cuy.py:589
jets_cff.levels
levels
Definition: jets_cff.py:21
RemoveAddSevLevel.flag
flag
Definition: RemoveAddSevLevel.py:117
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37