CMS 3D CMS Logo

List of all members | Public Member Functions | Private Types | Private Member Functions | Private Attributes
DD4hep_TrackingMaterialAnalyser Class Reference

#include <DD4hep_TrackingMaterialAnalyser.h>

Inheritance diagram for DD4hep_TrackingMaterialAnalyser:
edm::one::EDAnalyzer<> edm::one::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

 DD4hep_TrackingMaterialAnalyser (const edm::ParameterSet &)
 
 ~DD4hep_TrackingMaterialAnalyser () override
 
- Public Member Functions inherited from edm::one::EDAnalyzer<>
 EDAnalyzer ()=default
 
 EDAnalyzer (const EDAnalyzer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
const EDAnalyzeroperator= (const EDAnalyzer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
- Public Member Functions inherited from edm::one::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () const
 
 ~EDAnalyzerBase () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const *> const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Types

enum  SplitMode { NEAREST_LAYER, INNER_LAYER, OUTER_LAYER, UNDEFINED }
 

Private Member Functions

void analyze (const edm::Event &, const edm::EventSetup &) override
 
void beginJob () override
 
void endJob () override
 
int findLayer (const MaterialAccountingDetector &detector)
 
void saveLayerPlots ()
 
void saveParameters (const char *name)
 
void saveXml (const char *name)
 
void split (MaterialAccountingTrack &track)
 

Private Attributes

edm::ESGetToken< cms::DDCompactView, IdealGeometryRecordm_dddToken
 
std::vector< std::string > m_groupNames
 
std::vector< DD4hep_MaterialAccountingGroup * > m_groups
 
bool m_isHFNose
 
bool m_isHGCal
 
edm::EDGetTokenT< std::vector< MaterialAccountingTrack > > m_materialToken
 
std::unique_ptr< DD4hep_TrackingMaterialPlotterm_plotter
 
bool m_saveDetailedPlots
 
bool m_saveParameters
 
bool m_saveSummaryPlot
 
bool m_saveXml
 
bool m_skipAfterLastDetector
 
bool m_skipBeforeFirstDetector
 
SplitMode m_splitMode
 

Additional Inherited Members

- Public Types inherited from edm::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::one::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

Definition at line 16 of file DD4hep_TrackingMaterialAnalyser.h.

Member Enumeration Documentation

◆ SplitMode

Constructor & Destructor Documentation

◆ DD4hep_TrackingMaterialAnalyser()

DD4hep_TrackingMaterialAnalyser::DD4hep_TrackingMaterialAnalyser ( const edm::ParameterSet iPSet)
explicit

Definition at line 27 of file DD4hep_TrackingMaterialAnalyser.cc.

References edm::EDConsumerBase::esConsumes(), Exception, edm::ParameterSet::getParameter(), INNER_LAYER, edm::errors::LogicError, m_dddToken, m_groupNames, m_isHFNose, m_isHGCal, m_materialToken, m_plotter, m_saveDetailedPlots, m_saveParameters, m_saveSummaryPlot, m_saveXml, m_skipAfterLastDetector, m_skipBeforeFirstDetector, m_splitMode, NEAREST_LAYER, OUTER_LAYER, AlCaHLTBitMon_QueryRunRegistry::string, and UNDEFINED.

27  {
29  consumes<std::vector<MaterialAccountingTrack> >(iPSet.getParameter<edm::InputTag>("MaterialAccounting"));
30  m_groupNames = iPSet.getParameter<std::vector<std::string> >("Groups");
31  const std::string& splitmode = iPSet.getParameter<std::string>("SplitMode");
32  if (strcasecmp(splitmode.c_str(), "NearestLayer") == 0) {
34  } else if (strcasecmp(splitmode.c_str(), "InnerLayer") == 0) {
36  } else if (strcasecmp(splitmode.c_str(), "OuterLayer") == 0) {
38  } else {
41  << "Invalid SplitMode \"" << splitmode
42  << "\". Acceptable values are \"NearestLayer\", \"InnerLayer\", \"OuterLayer\".";
43  }
44  m_dddToken = esConsumes(iPSet.getParameter<edm::ESInputTag>("DDDetector"));
45  m_skipAfterLastDetector = iPSet.getParameter<bool>("SkipAfterLastDetector");
46  m_skipBeforeFirstDetector = iPSet.getParameter<bool>("SkipBeforeFirstDetector");
47  m_saveSummaryPlot = iPSet.getParameter<bool>("SaveSummaryPlot");
48  m_saveDetailedPlots = iPSet.getParameter<bool>("SaveDetailedPlots");
49  m_saveParameters = iPSet.getParameter<bool>("SaveParameters");
50  m_saveXml = iPSet.getParameter<bool>("SaveXML");
51  m_isHGCal = iPSet.getParameter<bool>("isHGCal");
52  m_isHFNose = iPSet.getParameter<bool>("isHFNose");
53  if (m_saveSummaryPlot) {
54  if (m_isHGCal) {
55  m_plotter = std::make_unique<DD4hep_TrackingMaterialPlotter>(550., 300., 10);
56  } else if (m_isHFNose) {
57  m_plotter = std::make_unique<DD4hep_TrackingMaterialPlotter>(1200., 350., 10);
58  } else {
59  m_plotter = std::make_unique<DD4hep_TrackingMaterialPlotter>(300., 120., 10);
60  } // 10x10 points per cm2
61  } else {
62  m_plotter = nullptr;
63  }
64 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
std::unique_ptr< DD4hep_TrackingMaterialPlotter > m_plotter
edm::ESGetToken< cms::DDCompactView, IdealGeometryRecord > m_dddToken
edm::EDGetTokenT< std::vector< MaterialAccountingTrack > > m_materialToken

◆ ~DD4hep_TrackingMaterialAnalyser()

DD4hep_TrackingMaterialAnalyser::~DD4hep_TrackingMaterialAnalyser ( void  )
override

Definition at line 67 of file DD4hep_TrackingMaterialAnalyser.cc.

67 {}

Member Function Documentation

◆ analyze()

void DD4hep_TrackingMaterialAnalyser::analyze ( const edm::Event event,
const edm::EventSetup setup 
)
overrideprivatevirtual

Implements edm::one::EDAnalyzerBase.

Definition at line 154 of file DD4hep_TrackingMaterialAnalyser.cc.

References mps_fire::end, mps_fire::i, m_dddToken, m_groupNames, m_groups, m_materialToken, singleTopDQM_cfi::setup, split(), submitPVValidationJobs::t, and HLT_2023v12_cff::track.

154  {
155  using namespace edm;
156  auto hDDD = setup.getTransientHandle(m_dddToken);
157 
158  m_groups.reserve(m_groupNames.size());
159  // Initialize m_groups iff it has size equal to zero, so that we are
160  // sure it will never be repopulated with the same entries over and
161  // over again in the eventloop, at each call of the analyze method.
162  if (m_groups.empty()) {
163  for (unsigned int i = 0; i < m_groupNames.size(); ++i)
164  m_groups.emplace_back(new DD4hep_MaterialAccountingGroup(m_groupNames[i], *hDDD));
165 
166  edm::LogVerbatim("TrackerMaterialAnalysis")
167  << "TrackingMaterialAnalyser: List of the tracker groups: " << std::endl;
168  for (unsigned int i = 0; i < m_groups.size(); ++i)
169  edm::LogVerbatim("TrackerMaterialAnalysis")
170  << i << " TrackingMaterialAnalyser:\t" << m_groups[i]->info() << std::endl;
171  }
173  event.getByToken(m_materialToken, h_tracks);
174 
175  for (std::vector<MaterialAccountingTrack>::const_iterator t = h_tracks->begin(), end = h_tracks->end(); t != end;
176  ++t) {
178  split(track);
179  }
180 }
Log< level::Info, true > LogVerbatim
void split(MaterialAccountingTrack &track)
edm::ESGetToken< cms::DDCompactView, IdealGeometryRecord > m_dddToken
std::vector< DD4hep_MaterialAccountingGroup * > m_groups
edm::EDGetTokenT< std::vector< MaterialAccountingTrack > > m_materialToken
HLT enums.

◆ beginJob()

void DD4hep_TrackingMaterialAnalyser::beginJob ( void  )
inlineoverrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 25 of file DD4hep_TrackingMaterialAnalyser.h.

25 {}

◆ endJob()

void DD4hep_TrackingMaterialAnalyser::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 135 of file DD4hep_TrackingMaterialAnalyser.cc.

References m_plotter, m_saveDetailedPlots, m_saveParameters, m_saveSummaryPlot, m_saveXml, saveLayerPlots(), saveParameters(), and saveXml().

◆ findLayer()

int DD4hep_TrackingMaterialAnalyser::findLayer ( const MaterialAccountingDetector detector)
private

Definition at line 351 of file DD4hep_TrackingMaterialAnalyser.cc.

References hgcalTestNeighbor_cfi::detector, alignBH_cfg::fixed, mps_fire::i, and m_groups.

Referenced by split().

351  {
352  int index = 0;
353  size_t inside = 0;
354  for (size_t i = 0; i < m_groups.size(); ++i)
355  if (m_groups[i]->isInside(detector)) {
356  ++inside;
357  index = i + 1;
358  }
359  if (inside == 0) {
360  index = 0;
361  edm::LogError("TrackerMaterialAnalysis")
362  << "TrackingMaterialAnalyser::findLayer(...): ERROR: detector does not belong to any DetLayer" << std::endl;
363  edm::LogError("TrackerMaterialAnalysis")
364  << "TrackingMaterialAnalyser::findLayer(...): detector position: " << std::fixed
365  << " (r: " << std::setprecision(1) << std::setw(5) << detector.position().perp()
366  << ", z: " << std::setprecision(1) << std::setw(6) << detector.position().z()
367  << ", phi: " << std::setprecision(3) << std::setw(6) << detector.position().phi() << ")" << std::endl;
368  }
369  if (inside > 1) {
370  index = 0;
371  edm::LogError("TrackerMaterialAnalysis") << "TrackingMaterialAnalyser::findLayer(...): ERROR: detector belongs to "
372  << inside << " DetLayers" << std::endl;
373  edm::LogError("TrackerMaterialAnalysis")
374  << "TrackingMaterialAnalyser::findLayer(...): detector position: " << std::fixed
375  << " (r: " << std::setprecision(1) << std::setw(5) << detector.position().perp()
376  << ", z: " << std::setprecision(1) << std::setw(6) << detector.position().z()
377  << ", phi: " << std::setprecision(3) << std::setw(6) << detector.position().phi() << ")" << std::endl;
378  }
379 
380  return index;
381 }
std::vector< DD4hep_MaterialAccountingGroup * > m_groups
Log< level::Error, false > LogError

◆ saveLayerPlots()

void DD4hep_TrackingMaterialAnalyser::saveLayerPlots ( )
private

Definition at line 127 of file DD4hep_TrackingMaterialAnalyser.cc.

References mps_fire::i, nano_mu_digi_cff::layer, and m_groups.

Referenced by endJob().

127  {
128  for (unsigned int i = 0; i < m_groups.size(); ++i) {
130  layer.savePlots();
131  }
132 }
std::vector< DD4hep_MaterialAccountingGroup * > m_groups

◆ saveParameters()

void DD4hep_TrackingMaterialAnalyser::saveParameters ( const char *  name)
private

Definition at line 70 of file DD4hep_TrackingMaterialAnalyser.cc.

References mps_fire::i, nano_mu_digi_cff::layer, m_groups, and Skims_PA_cff::name.

Referenced by endJob().

70  {
71  std::ofstream parameters(name);
72  edm::LogVerbatim("TrackerMaterialAnalysis") << "TrackingMaterialAnalyser" << std::endl;
73  for (unsigned int i = 0; i < m_groups.size(); ++i) {
75  edm::LogVerbatim("TrackerMaterialAnalysis") << "TrackingMaterialAnalyser" << layer.name() << std::endl;
76  edm::LogVerbatim("TrackerMaterialAnalysis")
77  << "TrackingMaterialAnalyser" << fmt::sprintf("\tnumber of hits: %9d", layer.tracks())
78  << std::endl;
79  edm::LogVerbatim("TrackerMaterialAnalysis")
80  << "TrackingMaterialAnalyser"
81  << fmt::sprintf("\tnormalized segment length: %9.1f ± %9.1f cm", layer.averageLength(), layer.sigmaLength())
82  << std::endl;
83  edm::LogVerbatim("TrackerMaterialAnalysis") << "TrackingMaterialAnalyser"
84  << fmt::sprintf("\tnormalized radiation lengths: %9.3f ± %9.3f",
85  layer.averageRadiationLengths(),
86  layer.sigmaRadiationLengths())
87  << std::endl;
88  edm::LogVerbatim("TrackerMaterialAnalysis")
89  << "TrackingMaterialAnalyser"
90  << fmt::sprintf("\tnormalized energy loss: %6.5fe-03 ± %6.5fe-03 GeV",
91  layer.averageEnergyLoss(),
92  layer.sigmaEnergyLoss())
93  << std::endl;
94  parameters << fmt::sprintf("%-20s\t%7d\t%5.1f ± %5.1f cm\t%6.4f ± %6.4f \t%6.4fe-03 ± %6.4fe-03 GeV",
95  layer.name(),
96  layer.tracks(),
97  layer.averageLength(),
98  layer.sigmaLength(),
99  layer.averageRadiationLengths(),
100  layer.sigmaRadiationLengths(),
101  layer.averageEnergyLoss(),
102  layer.sigmaEnergyLoss())
103  << std::endl;
104  }
105  edm::LogVerbatim("TrackerMaterialAnalysis") << "TrackingMaterialAnalyser" << std::endl;
106 
107  parameters.close();
108 }
Log< level::Info, true > LogVerbatim
std::vector< DD4hep_MaterialAccountingGroup * > m_groups

◆ saveXml()

void DD4hep_TrackingMaterialAnalyser::saveXml ( const char *  name)
private

Definition at line 111 of file DD4hep_TrackingMaterialAnalyser.cc.

References mps_fire::i, nano_mu_digi_cff::layer, m_groups, and Skims_PA_cff::name.

Referenced by endJob().

111  {
112  std::ofstream xml(name);
113  xml << "<?xml version=\"1.0\" encoding=\"utf-8\"?>" << std::endl;
114  xml << "<Groups>" << std::endl;
115  for (unsigned int i = 0; i < m_groups.size(); ++i) {
117  xml << " <Group name=\"" << layer.name() << "\">\n"
118  << " <Parameter name=\"TrackerRadLength\" value=\"" << layer.averageRadiationLengths() << "\"/>\n"
119  << " <Parameter name=\"TrackerXi\" value=\"" << layer.averageEnergyLoss() << "\"/>\n"
120  << " </Group>\n"
121  << std::endl;
122  }
123  xml << "</Groups>" << std::endl;
124 }
std::vector< DD4hep_MaterialAccountingGroup * > m_groups

◆ split()

void DD4hep_TrackingMaterialAnalyser::split ( MaterialAccountingTrack track)
private

Definition at line 191 of file DD4hep_TrackingMaterialAnalyser.cc.

References cms::cuda::assert(), MuonGeometrySanityCheck_cfi::detectors(), mps_fire::end, Exception, findLayer(), HLT_2023v12_cff::fraction, watchdog::group, mps_fire::i, INNER_LAYER, TH2PolyOfflineMaps::limits, edm::errors::LogicError, m_groups, m_plotter, m_skipAfterLastDetector, m_skipBeforeFirstDetector, m_splitMode, NEAREST_LAYER, or, OUTER_LAYER, HLT_2023v12_cff::track, and UNDEFINED.

Referenced by analyze().

191  {
192  using namespace edm;
193  // group sensitive detectors by their DetLayer
194  std::vector<int> group(track.detectors().size());
195  for (unsigned int i = 0; i < track.detectors().size(); ++i)
196  group[i] = findLayer(track.detectors()[i]);
197 
198  for (unsigned int i = 0; i < group.size(); ++i)
199  if (group[i] > 0)
200  edm::LogVerbatim("TrackerMaterialAnalysis") << "TrackingMaterialAnalyser:\n"
201  << "For detector i: " << i << " index: " << group[i]
202  << " R-ranges: " << m_groups[group[i] - 1]->getBoundingR().first
203  << ", " << m_groups[group[i] - 1]->getBoundingR().second << group[i]
204  << " Z-ranges: " << m_groups[group[i] - 1]->getBoundingZ().first
205  << ", " << m_groups[group[i] - 1]->getBoundingZ().second << std::endl;
206 
207  unsigned int detectors = track.detectors().size();
208  if (detectors == 0) {
209  // the track doesn't cross any active detector:
210  // keep al material as unassigned
211  if (m_plotter)
212  for (unsigned int i = 1; i < track.steps().size(); ++i)
213  m_plotter->plotSegmentUnassigned(track.steps()[i]);
214  } else {
215  const double TOLERANCE = 0.0001; // 1 um tolerance
216  std::vector<double> limits(detectors + 2);
217 
218  // define the trivial limits
220  limits[0] = track.detectors()[0].m_curvilinearIn - TOLERANCE;
221  else
222  limits[0] = -TOLERANCE;
224  limits[detectors] = track.detectors()[detectors - 1].m_curvilinearOut + TOLERANCE;
225  else
226  limits[detectors] = track.summary().length() + TOLERANCE;
227  limits[detectors + 1] = INFINITY; // this is probably no more needed, but doesn't harm...
228 
229  // pick the algorithm to define the non-trivial limits
230  switch (m_splitMode) {
231  // assign each segment to the the nearest layer
232  // e.g. the material between pixel barrel 3 and TIB 1 will be split among the two
233  case NEAREST_LAYER:
234  for (unsigned int i = 1; i < detectors; ++i) {
235  limits[i] = (track.detectors()[i - 1].m_curvilinearOut + track.detectors()[i].m_curvilinearIn) / 2.;
236  }
237  break;
238 
239  // assign each segment to the the inner layer
240  // e.g. all material between pixel barrel 3 and TIB 1 will go into the pixel barrel
241  case INNER_LAYER:
242  for (unsigned int i = 1; i < detectors; ++i)
243  limits[i] = track.detectors()[i].m_curvilinearIn - TOLERANCE;
244  break;
245 
246  // assign each segment to the the outer layer
247  // e.g. all material between pixel barrel 3 and TIB 1 will go into the TIB
248  case OUTER_LAYER:
249  for (unsigned int i = 1; i < detectors; ++i)
250  limits[i] = track.detectors()[i - 1].m_curvilinearOut + TOLERANCE;
251  break;
252 
253  case UNDEFINED:
254  [[fallthrough]];
255 
256  default:
257  // throw something
258  throw edm::Exception(edm::errors::LogicError) << "Invalid SplitMode";
259  }
260 
261  double begin = 0.; // beginning of step, along the track
262  double end = 0.; // end of step, along the track
263  unsigned int i = 1; // step conter
264 
265  // skip the material before the first layer
266  while (end < limits[0]) {
267  const MaterialAccountingStep& step = track.steps()[i++];
268  end = begin + step.length();
269 
270  // do not account material before the first layer
271  if (m_plotter)
272  m_plotter->plotSegmentUnassigned(step);
273 
274  begin = end;
275  }
276 
277  unsigned int index = 0; // which detector
278  while (i < track.steps().size()) {
279  const MaterialAccountingStep& step = track.steps()[i++];
280 
281  end = begin + step.length();
282 
283  if (begin > limits[detectors]) {
284  // segment after last layer and skipping requested in configuation
285  if (m_plotter)
286  m_plotter->plotSegmentUnassigned(step);
287  begin = end;
288  continue;
289  }
290 
291  // from here onwards we should be in the accountable region, either completely in a single layer:
292  // limits[index] <= begin < end <= limits[index+1]
293  // or possibly split between 2 layers
294  // limits[index] < begin < limits[index+1] < end < limits[index+2]
295  if (begin < limits[index] or end > limits[index + 2]) {
296  // sanity check
297  edm::LogError("TrackerMaterialAnalysis")
298  << "TrackingMaterialAnalyser::split(): ERROR: internal logic error, expected " << limits[index] << " < "
299  << begin << " < " << limits[index + 1] << std::endl;
300  break;
301  }
302 
303  if (limits[index] <= begin and end <= limits[index + 1]) {
304  // step completely inside current detector range
305  track.detectors()[index].account(step, begin, end);
306  if (m_plotter)
307  m_plotter->plotSegmentInLayer(step, group[index]);
308  } else {
309  // step shared beteewn two detectors, transition at limits[index+1]
310  double fraction = (limits[index + 1] - begin) / (end - begin);
311  assert(fraction < 1.);
312  std::pair<MaterialAccountingStep, MaterialAccountingStep> parts = step.split(fraction);
313 
314  if (m_plotter) {
315  if (index > 0)
316  m_plotter->plotSegmentInLayer(parts.first, group[index]);
317  else
318  // track outside acceptance, keep as unassocated
319  m_plotter->plotSegmentUnassigned(parts.first);
320 
321  if (index + 1 < detectors)
322  m_plotter->plotSegmentInLayer(parts.second, group[index + 1]);
323  else
324  // track outside acceptance, keep as unassocated
325  m_plotter->plotSegmentUnassigned(parts.second);
326  }
327 
328  track.detectors()[index].account(parts.first, begin, limits[index + 1]);
329  ++index; // next layer
330  if (index < detectors)
331  track.detectors()[index].account(parts.second, limits[index + 1], end);
332  }
333  begin = end;
334  }
335  }
336 
337  // add the material from each detector to its layer (if there is one and only one)
338  for (unsigned int i = 0; i < track.detectors().size(); ++i)
339  if (group[i] != 0)
340  m_groups[group[i] - 1]->addDetector(track.detectors()[i]);
341 
342  // end of track: commit internal buffers and reset the m_groups internal state for a new track
343  for (unsigned int i = 0; i < m_groups.size(); ++i)
344  m_groups[i]->endOfTrack();
345 }
Log< level::Info, true > LogVerbatim
std::unique_ptr< DD4hep_TrackingMaterialPlotter > m_plotter
std::vector< DD4hep_MaterialAccountingGroup * > m_groups
Log< level::Error, false > LogError
assert(be >=bs)
int findLayer(const MaterialAccountingDetector &detector)
def detectors(dt=True, csc=True, me42=False, chambers=True, superlayers=False, layers=False)
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
HLT enums.
step
Definition: StallMonitor.cc:83

Member Data Documentation

◆ m_dddToken

edm::ESGetToken<cms::DDCompactView, IdealGeometryRecord> DD4hep_TrackingMaterialAnalyser::m_dddToken
private

Definition at line 36 of file DD4hep_TrackingMaterialAnalyser.h.

Referenced by analyze(), and DD4hep_TrackingMaterialAnalyser().

◆ m_groupNames

std::vector<std::string> DD4hep_TrackingMaterialAnalyser::m_groupNames
private

Definition at line 47 of file DD4hep_TrackingMaterialAnalyser.h.

Referenced by analyze(), and DD4hep_TrackingMaterialAnalyser().

◆ m_groups

std::vector<DD4hep_MaterialAccountingGroup *> DD4hep_TrackingMaterialAnalyser::m_groups
private

◆ m_isHFNose

bool DD4hep_TrackingMaterialAnalyser::m_isHFNose
private

Definition at line 45 of file DD4hep_TrackingMaterialAnalyser.h.

Referenced by DD4hep_TrackingMaterialAnalyser().

◆ m_isHGCal

bool DD4hep_TrackingMaterialAnalyser::m_isHGCal
private

Definition at line 44 of file DD4hep_TrackingMaterialAnalyser.h.

Referenced by DD4hep_TrackingMaterialAnalyser().

◆ m_materialToken

edm::EDGetTokenT<std::vector<MaterialAccountingTrack> > DD4hep_TrackingMaterialAnalyser::m_materialToken
private

Definition at line 35 of file DD4hep_TrackingMaterialAnalyser.h.

Referenced by analyze(), and DD4hep_TrackingMaterialAnalyser().

◆ m_plotter

std::unique_ptr<DD4hep_TrackingMaterialPlotter> DD4hep_TrackingMaterialAnalyser::m_plotter
private

◆ m_saveDetailedPlots

bool DD4hep_TrackingMaterialAnalyser::m_saveDetailedPlots
private

Definition at line 41 of file DD4hep_TrackingMaterialAnalyser.h.

Referenced by DD4hep_TrackingMaterialAnalyser(), and endJob().

◆ m_saveParameters

bool DD4hep_TrackingMaterialAnalyser::m_saveParameters
private

Definition at line 42 of file DD4hep_TrackingMaterialAnalyser.h.

Referenced by DD4hep_TrackingMaterialAnalyser(), and endJob().

◆ m_saveSummaryPlot

bool DD4hep_TrackingMaterialAnalyser::m_saveSummaryPlot
private

Definition at line 40 of file DD4hep_TrackingMaterialAnalyser.h.

Referenced by DD4hep_TrackingMaterialAnalyser(), and endJob().

◆ m_saveXml

bool DD4hep_TrackingMaterialAnalyser::m_saveXml
private

Definition at line 43 of file DD4hep_TrackingMaterialAnalyser.h.

Referenced by DD4hep_TrackingMaterialAnalyser(), and endJob().

◆ m_skipAfterLastDetector

bool DD4hep_TrackingMaterialAnalyser::m_skipAfterLastDetector
private

Definition at line 38 of file DD4hep_TrackingMaterialAnalyser.h.

Referenced by DD4hep_TrackingMaterialAnalyser(), and split().

◆ m_skipBeforeFirstDetector

bool DD4hep_TrackingMaterialAnalyser::m_skipBeforeFirstDetector
private

Definition at line 39 of file DD4hep_TrackingMaterialAnalyser.h.

Referenced by DD4hep_TrackingMaterialAnalyser(), and split().

◆ m_splitMode

SplitMode DD4hep_TrackingMaterialAnalyser::m_splitMode
private

Definition at line 37 of file DD4hep_TrackingMaterialAnalyser.h.

Referenced by DD4hep_TrackingMaterialAnalyser(), and split().