CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Private Types | Private Member Functions | Private Attributes
TrackingMaterialAnalyser Class Reference

#include <TrackingMaterialAnalyser.h>

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

Public Member Functions

 TrackingMaterialAnalyser (const edm::ParameterSet &)
 
 ~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
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > 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
 
bool registeredToConsumeMany (TypeID const &, 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::ESRecordsToProxyIndices 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< DDCompactView,
IdealGeometryRecord
m_dddToken
 
std::vector< std::string > m_groupNames
 
std::vector
< MaterialAccountingGroup * > 
m_groups
 
bool m_isHFNose
 
bool m_isHGCal
 
edm::EDGetTokenT< std::vector
< MaterialAccountingTrack > > 
m_materialToken
 
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 ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
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 TrackingMaterialAnalyser.h.

Member Enumeration Documentation

Constructor & Destructor Documentation

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

Definition at line 30 of file 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.

30  {
32  consumes<std::vector<MaterialAccountingTrack> >(iPSet.getParameter<edm::InputTag>("MaterialAccounting"));
34  m_groupNames = iPSet.getParameter<std::vector<std::string> >("Groups");
35  const std::string& splitmode = iPSet.getParameter<std::string>("SplitMode");
36  if (strcasecmp(splitmode.c_str(), "NearestLayer") == 0) {
38  } else if (strcasecmp(splitmode.c_str(), "InnerLayer") == 0) {
40  } else if (strcasecmp(splitmode.c_str(), "OuterLayer") == 0) {
42  } else {
45  << "Invalid SplitMode \"" << splitmode
46  << "\". Acceptable values are \"NearestLayer\", \"InnerLayer\", \"OuterLayer\".";
47  }
48  m_skipAfterLastDetector = iPSet.getParameter<bool>("SkipAfterLastDetector");
49  m_skipBeforeFirstDetector = iPSet.getParameter<bool>("SkipBeforeFirstDetector");
50  m_saveSummaryPlot = iPSet.getParameter<bool>("SaveSummaryPlot");
51  m_saveDetailedPlots = iPSet.getParameter<bool>("SaveDetailedPlots");
52  m_saveParameters = iPSet.getParameter<bool>("SaveParameters");
53  m_saveXml = iPSet.getParameter<bool>("SaveXML");
54  m_isHGCal = iPSet.getParameter<bool>("isHGCal");
55  m_isHFNose = iPSet.getParameter<bool>("isHFNose");
56  if (m_saveSummaryPlot) {
57  if (m_isHGCal) {
58  m_plotter = new TrackingMaterialPlotter(550., 300., 10);
59  } else if (m_isHFNose) {
60  m_plotter = new TrackingMaterialPlotter(1200., 350., 10);
61  } else {
62  m_plotter = new TrackingMaterialPlotter(300., 120., 10);
63  } // 10x10 points per cm2
64  } else {
65  m_plotter = nullptr;
66  }
67 }
edm::EDGetTokenT< std::vector< MaterialAccountingTrack > > m_materialToken
std::vector< std::string > m_groupNames
TrackingMaterialPlotter * m_plotter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::ESGetToken< DDCompactView, IdealGeometryRecord > m_dddToken
TrackingMaterialAnalyser::~TrackingMaterialAnalyser ( void  )
override

Definition at line 70 of file TrackingMaterialAnalyser.cc.

References m_plotter.

70  {
71  if (m_plotter)
72  delete m_plotter;
73 }
TrackingMaterialPlotter * m_plotter

Member Function Documentation

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

Implements edm::one::EDAnalyzerBase.

Definition at line 154 of file TrackingMaterialAnalyser.cc.

References dataset::end, edm::EventSetup::getHandle(), mps_fire::i, m_dddToken, m_groupNames, m_groups, m_materialToken, split(), submitPVValidationJobs::t, and HLT_FULL_cff::track.

154  {
155  using namespace edm;
156  auto hDDD = setup.getHandle(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.push_back(new MaterialAccountingGroup(m_groupNames[i], *hDDD));
165 
166  LogInfo("TrackingMaterialAnalyser") << "TrackingMaterialAnalyser: List of the tracker groups: " << std::endl;
167  for (unsigned int i = 0; i < m_groups.size(); ++i)
168  LogInfo("TrackingMaterialAnalyser") << i << " TrackingMaterialAnalyser:\t" << m_groups[i]->info() << std::endl;
169  }
171  event.getByToken(m_materialToken, h_tracks);
172 
173  for (std::vector<MaterialAccountingTrack>::const_iterator t = h_tracks->begin(), end = h_tracks->end(); t != end;
174  ++t) {
176  split(track);
177  }
178 }
void split(MaterialAccountingTrack &track)
edm::EDGetTokenT< std::vector< MaterialAccountingTrack > > m_materialToken
Log< level::Info, false > LogInfo
std::vector< std::string > m_groupNames
std::vector< MaterialAccountingGroup * > m_groups
string end
Definition: dataset.py:937
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:151
edm::ESGetToken< DDCompactView, IdealGeometryRecord > m_dddToken
void TrackingMaterialAnalyser::beginJob ( void  )
inlineoverrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 25 of file TrackingMaterialAnalyser.h.

25 {}
void TrackingMaterialAnalyser::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 135 of file TrackingMaterialAnalyser.cc.

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

135  {
136  if (m_saveParameters)
137  saveParameters("parameters");
138 
139  if (m_saveXml)
140  saveXml("parameters.xml");
141 
143  saveLayerPlots();
144 
145  if (m_saveSummaryPlot and m_plotter) {
146  m_plotter->normalize();
147  m_plotter->draw();
148  }
149 }
void saveParameters(const char *name)
TrackingMaterialPlotter * m_plotter
int TrackingMaterialAnalyser::findLayer ( const MaterialAccountingDetector detector)
private

Definition at line 347 of file TrackingMaterialAnalyser.cc.

References EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0::cerr, mps_fire::i, m_groups, PV3DBase< T, PVType, FrameType >::perp(), PV3DBase< T, PVType, FrameType >::phi(), MaterialAccountingDetector::position(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by split().

347  {
348  int index = 0;
349  size_t inside = 0;
350  for (size_t i = 0; i < m_groups.size(); ++i)
351  if (m_groups[i]->inside(detector)) {
352  ++inside;
353  index = i + 1;
354  }
355  if (inside == 0) {
356  index = 0;
357  std::cerr << "TrackingMaterialAnalyser::findLayer(...): ERROR: detector does not belong to any DetLayer"
358  << std::endl;
359  std::cerr << "TrackingMaterialAnalyser::findLayer(...): detector position: " << std::fixed
360  << " (r: " << std::setprecision(1) << std::setw(5) << detector.position().perp()
361  << ", z: " << std::setprecision(1) << std::setw(6) << detector.position().z()
362  << ", phi: " << std::setprecision(3) << std::setw(6) << detector.position().phi() << ")" << std::endl;
363  }
364  if (inside > 1) {
365  index = 0;
366  std::cerr << "TrackingMaterialAnalyser::findLayer(...): ERROR: detector belongs to " << inside << " DetLayers"
367  << std::endl;
368  std::cerr << "TrackingMaterialAnalyser::findLayer(...): detector position: " << std::fixed
369  << " (r: " << std::setprecision(1) << std::setw(5) << detector.position().perp()
370  << ", z: " << std::setprecision(1) << std::setw(6) << detector.position().z()
371  << ", phi: " << std::setprecision(3) << std::setw(6) << detector.position().phi() << ")" << std::endl;
372  }
373 
374  return index;
375 }
T perp() const
Definition: PV3DBase.h:69
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
T z() const
Definition: PV3DBase.h:61
std::vector< MaterialAccountingGroup * > m_groups
const GlobalPoint & position() const
void TrackingMaterialAnalyser::saveLayerPlots ( )
private

Definition at line 127 of file TrackingMaterialAnalyser.cc.

References mps_fire::i, phase1PixelTopology::layer, m_groups, and MaterialAccountingGroup::savePlots().

Referenced by endJob().

127  {
128  for (unsigned int i = 0; i < m_groups.size(); ++i) {
130  layer.savePlots();
131  }
132 }
constexpr std::array< uint8_t, layerIndexSize > layer
std::vector< MaterialAccountingGroup * > m_groups
void savePlots(void)
save the plots
void TrackingMaterialAnalyser::saveParameters ( const char *  name)
private

Definition at line 76 of file TrackingMaterialAnalyser.cc.

References MaterialAccountingGroup::averageEnergyLoss(), MaterialAccountingGroup::averageLength(), MaterialAccountingGroup::averageRadiationLengths(), gather_cfg::cout, mps_fire::i, phase1PixelTopology::layer, m_groups, MaterialAccountingGroup::name(), MaterialAccountingGroup::sigmaEnergyLoss(), MaterialAccountingGroup::sigmaLength(), MaterialAccountingGroup::sigmaRadiationLengths(), and MaterialAccountingGroup::tracks().

Referenced by endJob().

76  {
77  std::ofstream parameters(name);
78  std::cout << std::endl;
79  for (unsigned int i = 0; i < m_groups.size(); ++i) {
81  std::cout << layer.name() << std::endl;
82  std::cout << fmt::sprintf("\tnumber of hits: %9d", layer.tracks()) << std::endl;
83  std::cout << fmt::sprintf(
84  "\tnormalized segment length: %9.1f ± %9.1f cm", layer.averageLength(), layer.sigmaLength())
85  << std::endl;
86  std::cout << fmt::sprintf("\tnormalized radiation lengths: %9.3f ± %9.3f",
88  layer.sigmaRadiationLengths())
89  << std::endl;
90  std::cout << 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(),
100  layer.sigmaRadiationLengths(),
101  layer.averageEnergyLoss(),
102  layer.sigmaEnergyLoss())
103  << std::endl;
104  }
105  std::cout << std::endl;
106 
107  parameters.close();
108 }
double averageRadiationLengths(void) const
return the average normalized number of radiation lengths
double sigmaLength(void) const
return the sigma of the normalized layer thickness
double sigmaRadiationLengths(void) const
return the sigma of the normalized number of radiation lengths
double sigmaEnergyLoss(void) const
return the sigma of the normalized energy loss density factor for Bethe-Bloch
unsigned int tracks(void) const
return the number of tracks that hit this layer
double averageLength(void) const
return the average normalized layer thickness
constexpr std::array< uint8_t, layerIndexSize > layer
double averageEnergyLoss(void) const
return the average normalized energy loss density factor for Bethe-Bloch
const std::string & name(void) const
get the layer name
std::vector< MaterialAccountingGroup * > m_groups
tuple cout
Definition: gather_cfg.py:144
void TrackingMaterialAnalyser::saveXml ( const char *  name)
private

Definition at line 111 of file TrackingMaterialAnalyser.cc.

References MaterialAccountingGroup::averageEnergyLoss(), MaterialAccountingGroup::averageRadiationLengths(), mps_fire::i, phase1PixelTopology::layer, m_groups, and MaterialAccountingGroup::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 }
double averageRadiationLengths(void) const
return the average normalized number of radiation lengths
constexpr std::array< uint8_t, layerIndexSize > layer
double averageEnergyLoss(void) const
return the average normalized energy loss density factor for Bethe-Bloch
const std::string & name(void) const
get the layer name
std::vector< MaterialAccountingGroup * > m_groups
void TrackingMaterialAnalyser::split ( MaterialAccountingTrack track)
private

Definition at line 189 of file TrackingMaterialAnalyser.cc.

References cms::cuda::assert(), SplitLinear::begin, EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0::cerr, MuonGeometrySanityCheck_cfi::detectors(), MaterialAccountingTrack::detectors(), dataset::end, Exception, findLayer(), HLT_FULL_cff::fraction, watchdog::group, mps_fire::i, INNER_LAYER, MaterialAccountingStep::length(), TH2PolyOfflineMaps::limits, edm::errors::LogicError, m_groups, m_plotter, m_skipAfterLastDetector, m_skipBeforeFirstDetector, m_splitMode, NEAREST_LAYER, or, OUTER_LAYER, TrackingMaterialPlotter::plotSegmentInLayer(), TrackingMaterialPlotter::plotSegmentUnassigned(), MaterialAccountingStep::split(), MaterialAccountingTrack::steps(), MaterialAccountingTrack::summary(), and UNDEFINED.

Referenced by analyze().

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

Member Data Documentation

edm::ESGetToken<DDCompactView, IdealGeometryRecord> TrackingMaterialAnalyser::m_dddToken
private

Definition at line 36 of file TrackingMaterialAnalyser.h.

Referenced by analyze(), and TrackingMaterialAnalyser().

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

Definition at line 47 of file TrackingMaterialAnalyser.h.

Referenced by analyze(), and TrackingMaterialAnalyser().

std::vector<MaterialAccountingGroup *> TrackingMaterialAnalyser::m_groups
private
bool TrackingMaterialAnalyser::m_isHFNose
private

Definition at line 45 of file TrackingMaterialAnalyser.h.

Referenced by TrackingMaterialAnalyser().

bool TrackingMaterialAnalyser::m_isHGCal
private

Definition at line 44 of file TrackingMaterialAnalyser.h.

Referenced by TrackingMaterialAnalyser().

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

Definition at line 35 of file TrackingMaterialAnalyser.h.

Referenced by analyze(), and TrackingMaterialAnalyser().

TrackingMaterialPlotter* TrackingMaterialAnalyser::m_plotter
private
bool TrackingMaterialAnalyser::m_saveDetailedPlots
private

Definition at line 41 of file TrackingMaterialAnalyser.h.

Referenced by endJob(), and TrackingMaterialAnalyser().

bool TrackingMaterialAnalyser::m_saveParameters
private

Definition at line 42 of file TrackingMaterialAnalyser.h.

Referenced by endJob(), and TrackingMaterialAnalyser().

bool TrackingMaterialAnalyser::m_saveSummaryPlot
private

Definition at line 40 of file TrackingMaterialAnalyser.h.

Referenced by endJob(), and TrackingMaterialAnalyser().

bool TrackingMaterialAnalyser::m_saveXml
private

Definition at line 43 of file TrackingMaterialAnalyser.h.

Referenced by endJob(), and TrackingMaterialAnalyser().

bool TrackingMaterialAnalyser::m_skipAfterLastDetector
private

Definition at line 38 of file TrackingMaterialAnalyser.h.

Referenced by split(), and TrackingMaterialAnalyser().

bool TrackingMaterialAnalyser::m_skipBeforeFirstDetector
private

Definition at line 39 of file TrackingMaterialAnalyser.h.

Referenced by split(), and TrackingMaterialAnalyser().

SplitMode TrackingMaterialAnalyser::m_splitMode
private

Definition at line 37 of file TrackingMaterialAnalyser.h.

Referenced by split(), and TrackingMaterialAnalyser().