CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Attributes
XtalDedxAnalysis Class Reference
Inheritance diagram for XtalDedxAnalysis:
edm::one::EDAnalyzer< edm::one::SharedResources > edm::one::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

 XtalDedxAnalysis (const edm::ParameterSet &)
 
 ~XtalDedxAnalysis () override
 
- Public Member Functions inherited from edm::one::EDAnalyzer< edm::one::SharedResources >
 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)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- 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

void analyze (const edm::Event &, const edm::EventSetup &) override
 
void analyzeHits (std::vector< PCaloHit > &, const edm::Handle< edm::SimTrackContainer > &, const edm::Handle< edm::SimVertexContainer > &)
 
void beginJob () override
 
void endJob () override
 
- 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)
 

Private Attributes

const edm::InputTag caloHitSource_
 
const double energyMax_
 
TH1F * meE1T0_ [4]
 
TH1F * meE1T1_ [4]
 
TH1F * meE9T0_ [4]
 
TH1F * meE9T1_ [4]
 
TH1F * meNHit_ [4]
 
TH1I * mType_
 
const std::string simTkLabel_
 
const edm::EDGetTokenT< edm::PCaloHitContainertok_calo_
 
const edm::EDGetTokenT< edm::SimTrackContainertok_tk_
 
const edm::EDGetTokenT< edm::SimVertexContainertok_vtx_
 

Additional Inherited Members

- Public Types inherited from edm::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 

Detailed Description

Definition at line 36 of file XtalDedxAnalysis.cc.

Constructor & Destructor Documentation

◆ XtalDedxAnalysis()

XtalDedxAnalysis::XtalDedxAnalysis ( const edm::ParameterSet ps)
explicit

Definition at line 64 of file XtalDedxAnalysis.cc.

References caloHitSource_, energyMax_, mps_fire::i, TFileService::kSharedResource, meE1T0_, meE1T1_, meE9T0_, meE9T1_, meNHit_, mType_, Skims_PA_cff::name, simTkLabel_, AlCaHLTBitMon_QueryRunRegistry::string, compare::tfile, and runGCPTkAlMap::title.

65  : caloHitSource_(ps.getParameter<edm::InputTag>("caloHitSource")),
66  simTkLabel_(ps.getParameter<std::string>("moduleLabelTk")),
67  energyMax_(ps.getParameter<double>("energyMax")),
68  tok_calo_(consumes<edm::PCaloHitContainer>(caloHitSource_)),
69  tok_tk_(consumes<edm::SimTrackContainer>(edm::InputTag(simTkLabel_))),
70  tok_vtx_(consumes<edm::SimVertexContainer>(edm::InputTag(simTkLabel_))) {
71  usesResource(TFileService::kSharedResource);
72  edm::LogVerbatim("CherenkovAnalysis") << "XtalDedxAnalysis::Source " << caloHitSource_ << " Track Label "
73  << simTkLabel_ << " Energy Max " << energyMax_;
74 
75  // Book histograms
77 
78  if (!tfile.isAvailable())
79  throw cms::Exception("BadConfig") << "TFileService unavailable: "
80  << "please add it to config file";
81  // Histograms for Hits
82  std::string types[4] = {"total", "by dE/dx", "by delta-ray", "by bremms"};
83  char name[20], title[80];
84  for (int i = 0; i < 4; i++) {
85  sprintf(name, "Hits%d", i);
86  sprintf(title, "Number of hits (%s)", types[i].c_str());
87  meNHit_[i] = tfile->make<TH1F>(name, title, 5000, 0., 5000.);
88  meNHit_[i]->GetXaxis()->SetTitle(title);
89  meNHit_[i]->GetYaxis()->SetTitle("Events");
90  sprintf(name, "E1T0%d", i);
91  sprintf(title, "E1 (Loss %s) in GeV", types[i].c_str());
92  meE1T0_[i] = tfile->make<TH1F>(name, title, 5000, 0, energyMax_);
93  meE1T0_[i]->GetXaxis()->SetTitle(title);
94  meE1T0_[i]->GetYaxis()->SetTitle("Events");
95  sprintf(name, "E9T0%d", i);
96  sprintf(title, "E9 (Loss %s) in GeV", types[i].c_str());
97  meE9T0_[i] = tfile->make<TH1F>(name, title, 5000, 0, energyMax_);
98  meE9T0_[i]->GetXaxis()->SetTitle(title);
99  meE9T0_[i]->GetYaxis()->SetTitle("Events");
100  sprintf(name, "E1T1%d", i);
101  sprintf(title, "E1 (Loss %s with t < 400 ns) in GeV", types[i].c_str());
102  meE1T1_[i] = tfile->make<TH1F>(name, title, 5000, 0, energyMax_);
103  meE1T1_[i]->GetXaxis()->SetTitle(title);
104  meE1T1_[i]->GetYaxis()->SetTitle("Events");
105  sprintf(name, "E9T1%d", i);
106  sprintf(title, "E9 (Loss %s with t < 400 ns) in GeV", types[i].c_str());
107  meE9T1_[i] = tfile->make<TH1F>(name, title, 5000, 0, energyMax_);
108  meE9T1_[i]->GetXaxis()->SetTitle(title);
109  meE9T1_[i]->GetYaxis()->SetTitle("Events");
110  }
111  sprintf(name, "PDGType");
112  sprintf(title, "PDG ID of first level secondary");
113  mType_ = tfile->make<TH1I>(name, title, 5000, -2500, 2500);
114  mType_->GetXaxis()->SetTitle(title);
115  mType_->GetYaxis()->SetTitle("Tracks");
116 }
static const std::string kSharedResource
Definition: TFileService.h:76
Log< level::Info, true > LogVerbatim
const edm::EDGetTokenT< edm::SimVertexContainer > tok_vtx_
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
const edm::InputTag caloHitSource_
const edm::EDGetTokenT< edm::SimTrackContainer > tok_tk_
const double energyMax_
Definition: tfile.py:1
const edm::EDGetTokenT< edm::PCaloHitContainer > tok_calo_
const std::string simTkLabel_

◆ ~XtalDedxAnalysis()

XtalDedxAnalysis::~XtalDedxAnalysis ( )
inlineoverride

Definition at line 39 of file XtalDedxAnalysis.cc.

39 {}

Member Function Documentation

◆ analyze()

void XtalDedxAnalysis::analyze ( const edm::Event e,
const edm::EventSetup  
)
overrideprotectedvirtual

Implements edm::one::EDAnalyzerBase.

Definition at line 126 of file XtalDedxAnalysis.cc.

References analyzeHits(), MillePedeFileConverter_cfg::e, edm::HandleBase::isValid(), tok_calo_, tok_tk_, and tok_vtx_.

126  {
127 #ifdef EDM_ML_DEBUG
128  edm::LogVerbatim("CherenkovAnalysis") << "XtalDedxAnalysis::Run = " << e.id().run() << " Event = " << e.id().event();
129 #endif
130  std::vector<PCaloHit> caloHits;
131  const edm::Handle<edm::PCaloHitContainer> &pCaloHits = e.getHandle(tok_calo_);
132 
133  const edm::Handle<edm::SimTrackContainer> &simTk = e.getHandle(tok_tk_);
134  const edm::Handle<edm::SimVertexContainer> &simVtx = e.getHandle(tok_vtx_);
135 
136  if (pCaloHits.isValid()) {
137  caloHits.insert(caloHits.end(), pCaloHits->begin(), pCaloHits->end());
138 #ifdef EDM_ML_DEBUG
139  edm::LogVerbatim("CherenkovAnalysis") << "XtalDedxAnalysis: Hit buffer " << caloHits.size();
140 #endif
141  analyzeHits(caloHits, simTk, simVtx);
142  }
143 }
Log< level::Info, true > LogVerbatim
const edm::EDGetTokenT< edm::SimVertexContainer > tok_vtx_
const edm::EDGetTokenT< edm::SimTrackContainer > tok_tk_
void analyzeHits(std::vector< PCaloHit > &, const edm::Handle< edm::SimTrackContainer > &, const edm::Handle< edm::SimVertexContainer > &)
bool isValid() const
Definition: HandleBase.h:70
const edm::EDGetTokenT< edm::PCaloHitContainer > tok_calo_

◆ analyzeHits()

void XtalDedxAnalysis::analyzeHits ( std::vector< PCaloHit > &  hits,
const edm::Handle< edm::SimTrackContainer > &  SimTk,
const edm::Handle< edm::SimVertexContainer > &  SimVtx 
)
protected

Definition at line 145 of file XtalDedxAnalysis.cc.

References hcalRecHitTable_cff::energy, hfClusterShapes_cfi::hits, mps_fire::i, gpuVertexFinder::iv, meE1T0_, meE1T1_, meE9T0_, meE9T1_, meNHit_, mType_, class-composition::parent, and hcalRecHitTable_cff::time.

Referenced by analyze().

147  {
148  edm::SimTrackContainer::const_iterator simTrkItr;
149  int nHit = hits.size();
150  double e10[4], e90[4], e11[4], e91[4], hit[4];
151  for (int i = 0; i < 4; i++)
152  e10[i] = e90[i] = e11[i] = e91[i] = hit[i] = 0;
153  for (int i = 0; i < nHit; i++) {
154  double energy = hits[i].energy();
155  double time = hits[i].time();
156  unsigned int id_ = hits[i].id();
157  int trackID = hits[i].geantTrackId();
158  int type = 1;
159  for (simTrkItr = SimTk->begin(); simTrkItr != SimTk->end(); simTrkItr++) {
160  if (trackID == (int)(simTrkItr->trackId())) {
161  int thePID = simTrkItr->type();
162  if (thePID == 11)
163  type = 2;
164  else if (thePID != -13 && thePID != 13)
165  type = 3;
166  break;
167  }
168  }
169  hit[0]++;
170  hit[type]++;
171  e90[0] += energy;
172  e90[type] += energy;
173  if (time < 400) {
174  e91[0] += energy;
175  e91[type] += energy;
176  }
177  if (id_ == 22) {
178  e10[0] += energy;
179  e10[type] += energy;
180  if (time < 400) {
181  e11[0] += energy;
182  e11[type] += energy;
183  }
184  }
185 #ifdef EDM_ML_DEBUG
186  edm::LogVerbatim("CherenkovAnalysis") << "XtalDedxAnalysis:Hit[" << i << "] ID " << id_ << " E " << energy
187  << " time " << time << " track " << trackID << " type " << type;
188 #endif
189  }
190  for (int i = 0; i < 4; i++) {
191 #ifdef EDM_ML_DEBUG
192  edm::LogVerbatim("CherenkovAnalysis") << "XtalDedxAnalysis:Type(" << i << ") Hit " << hit[i] << " E10 " << e10[i]
193  << " E11 " << e11[i] << " E90 " << e90[i] << " E91 " << e91[i];
194 #endif
195  meNHit_[i]->Fill(hit[i]);
196  meE1T0_[i]->Fill(e10[i]);
197  meE9T0_[i]->Fill(e90[i]);
198  meE1T1_[i]->Fill(e11[i]);
199  meE9T1_[i]->Fill(e91[i]);
200  }
201 
202  // Type of the secondary (coming directly from a generator level track)
203  int nvtx = 0, k1 = 0;
204  edm::SimVertexContainer::const_iterator simVtxItr;
205  for (simVtxItr = SimVtx->begin(); simVtxItr != SimVtx->end(); simVtxItr++)
206  nvtx++;
207 #ifdef EDM_ML_DEBUG
208  int ntrk = 0;
209  for (simTrkItr = SimTk->begin(); simTrkItr != SimTk->end(); simTrkItr++)
210  ntrk++;
211  edm::LogVerbatim("CherenkovAnalysis") << "XtalDedxAnalysis: " << ntrk << " tracks and " << nvtx << " vertices";
212 #endif
213  for (simTrkItr = SimTk->begin(); simTrkItr != SimTk->end(); simTrkItr++, ++k1) {
214 #ifdef EDM_ML_DEBUG
215  edm::LogVerbatim("CherenkovAnalysis") << "Track " << k1 << " PDGId " << simTrkItr->type() << " Vertex ID "
216  << simTrkItr->vertIndex() << " Generator " << simTrkItr->noGenpart();
217 #endif
218  if (simTrkItr->noGenpart()) { // This is a secondary
219  int vertIndex = simTrkItr->vertIndex(); // Vertex index of origin
220  if (vertIndex >= 0 && vertIndex < nvtx) {
221  simVtxItr = SimVtx->begin();
222  for (int iv = 0; iv < vertIndex; iv++)
223  simVtxItr++;
224  int parent = simVtxItr->parentIndex(), k2 = 0;
225  for (edm::SimTrackContainer::const_iterator trkItr = SimTk->begin(); trkItr != SimTk->end(); trkItr++, ++k2) {
226 #ifdef EDM_ML_DEBUG
227  edm::LogVerbatim("CherenkovAnalysis") << "XtalDedxAnalysis::Track " << k2 << " ID " << trkItr->trackId()
228  << " (" << parent << ") Generator " << trkItr->noGenpart();
229 #endif
230  if ((int)trkItr->trackId() == parent) { // Parent track
231  if (!trkItr->noGenpart()) { // Generator level
232 #ifdef EDM_ML_DEBUG
233  edm::LogVerbatim("CherenkovAnalysis") << "XtalDedxAnalysis::Track found with ID " << simTrkItr->type();
234 #endif
235  mType_->Fill(simTrkItr->type());
236  }
237  break;
238  }
239  }
240  }
241  }
242  }
243 }
Log< level::Info, true > LogVerbatim
int32_t *__restrict__ iv

◆ beginJob()

void XtalDedxAnalysis::beginJob ( void  )
inlineoverrideprotectedvirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 44 of file XtalDedxAnalysis.cc.

44 {}

◆ endJob()

void XtalDedxAnalysis::endJob ( void  )
inlineoverrideprotectedvirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 46 of file XtalDedxAnalysis.cc.

46 {}

◆ fillDescriptions()

void XtalDedxAnalysis::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 118 of file XtalDedxAnalysis.cc.

References edm::ConfigurationDescriptions::add(), submitPVResolutionJobs::desc, ProducerED_cfi::InputTag, and AlCaHLTBitMon_QueryRunRegistry::string.

118  {
120  desc.add<edm::InputTag>("caloHitSource", edm::InputTag("g4SimHits", "EcalHitsEB"));
121  desc.add<std::string>("moduleLabelTk", "g4SimHits");
122  desc.add<double>("energyMax", 2.0);
123  descriptions.add("xtalDedxAnalysis", desc);
124 }
void add(std::string const &label, ParameterSetDescription const &psetDescription)

Member Data Documentation

◆ caloHitSource_

const edm::InputTag XtalDedxAnalysis::caloHitSource_
private

Definition at line 53 of file XtalDedxAnalysis.cc.

Referenced by XtalDedxAnalysis().

◆ energyMax_

const double XtalDedxAnalysis::energyMax_
private

Definition at line 55 of file XtalDedxAnalysis.cc.

Referenced by XtalDedxAnalysis().

◆ meE1T0_

TH1F * XtalDedxAnalysis::meE1T0_[4]
private

Definition at line 60 of file XtalDedxAnalysis.cc.

Referenced by analyzeHits(), and XtalDedxAnalysis().

◆ meE1T1_

TH1F * XtalDedxAnalysis::meE1T1_[4]
private

Definition at line 60 of file XtalDedxAnalysis.cc.

Referenced by analyzeHits(), and XtalDedxAnalysis().

◆ meE9T0_

TH1F * XtalDedxAnalysis::meE9T0_[4]
private

Definition at line 60 of file XtalDedxAnalysis.cc.

Referenced by analyzeHits(), and XtalDedxAnalysis().

◆ meE9T1_

TH1F * XtalDedxAnalysis::meE9T1_[4]
private

Definition at line 60 of file XtalDedxAnalysis.cc.

Referenced by analyzeHits(), and XtalDedxAnalysis().

◆ meNHit_

TH1F* XtalDedxAnalysis::meNHit_[4]
private

Definition at line 60 of file XtalDedxAnalysis.cc.

Referenced by analyzeHits(), and XtalDedxAnalysis().

◆ mType_

TH1I* XtalDedxAnalysis::mType_
private

Definition at line 61 of file XtalDedxAnalysis.cc.

Referenced by analyzeHits(), and XtalDedxAnalysis().

◆ simTkLabel_

const std::string XtalDedxAnalysis::simTkLabel_
private

Definition at line 54 of file XtalDedxAnalysis.cc.

Referenced by XtalDedxAnalysis().

◆ tok_calo_

const edm::EDGetTokenT<edm::PCaloHitContainer> XtalDedxAnalysis::tok_calo_
private

Definition at line 56 of file XtalDedxAnalysis.cc.

Referenced by analyze().

◆ tok_tk_

const edm::EDGetTokenT<edm::SimTrackContainer> XtalDedxAnalysis::tok_tk_
private

Definition at line 57 of file XtalDedxAnalysis.cc.

Referenced by analyze().

◆ tok_vtx_

const edm::EDGetTokenT<edm::SimVertexContainer> XtalDedxAnalysis::tok_vtx_
private

Definition at line 58 of file XtalDedxAnalysis.cc.

Referenced by analyze().