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 | 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
 
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)
 

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 > &, edm::Handle< edm::SimTrackContainer > &, 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< B > consumes (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 () noexcept
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
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

edm::InputTag caloHitSource_
 
TH1F * meE1T0_ [4]
 
TH1F * meE1T1_ [4]
 
TH1F * meE9T0_ [4]
 
TH1F * meE9T1_ [4]
 
TH1F * meNHit_ [4]
 
TH1I * mType_
 
std::string simTkLabel_
 
edm::EDGetTokenT
< edm::PCaloHitContainer
tok_calo_
 
edm::EDGetTokenT
< edm::SimTrackContainer
tok_tk_
 
edm::EDGetTokenT
< edm::SimVertexContainer
tok_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 ( const edm::ParameterSet ps)
explicit

Definition at line 64 of file XtalDedxAnalysis.cc.

References caloHitSource_, edm::ParameterSet::getParameter(), mps_fire::i, HLT_FULL_cff::InputTag, TFileService::kSharedResource, meE1T0_, meE1T1_, meE9T0_, meE9T1_, meNHit_, mType_, mergeVDriftHistosByStation::name, simTkLabel_, AlCaHLTBitMon_QueryRunRegistry::string, compare::tfile, runGCPTkAlMap::title, tok_calo_, tok_tk_, and tok_vtx_.

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

Definition at line 39 of file XtalDedxAnalysis.cc.

39 {}

Member Function Documentation

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

Implements edm::one::EDAnalyzerBase.

Definition at line 127 of file XtalDedxAnalysis.cc.

References analyzeHits(), edm::EventID::event(), edm::Event::getByToken(), edm::EventBase::id(), edm::HandleBase::isValid(), edm::EventID::run(), tok_calo_, tok_tk_, and tok_vtx_.

127  {
128 #ifdef EDM_ML_DEBUG
129  edm::LogVerbatim("CherenkovAnalysis") << "XtalDedxAnalysis::Run = " << e.id().run() << " Event = " << e.id().event();
130 #endif
131  std::vector<PCaloHit> caloHits;
133  e.getByToken(tok_calo_, pCaloHits);
134 
135  std::vector<SimTrack> theSimTracks;
137  e.getByToken(tok_tk_, simTk);
138 
139  std::vector<SimVertex> theSimVertex;
141  e.getByToken(tok_vtx_, simVtx);
142 
143  if (pCaloHits.isValid()) {
144  caloHits.insert(caloHits.end(), pCaloHits->begin(), pCaloHits->end());
145 #ifdef EDM_ML_DEBUG
146  edm::LogVerbatim("CherenkovAnalysis") << "XtalDedxAnalysis: Hit buffer " << caloHits.size();
147 #endif
148  analyzeHits(caloHits, simTk, simVtx);
149  }
150 }
RunNumber_t run() const
Definition: EventID.h:38
Log< level::Info, true > LogVerbatim
EventNumber_t event() const
Definition: EventID.h:40
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
edm::EDGetTokenT< edm::SimVertexContainer > tok_vtx_
edm::EDGetTokenT< edm::SimTrackContainer > tok_tk_
edm::EDGetTokenT< edm::PCaloHitContainer > tok_calo_
bool isValid() const
Definition: HandleBase.h:70
edm::EventID id() const
Definition: EventBase.h:59
void analyzeHits(std::vector< PCaloHit > &, edm::Handle< edm::SimTrackContainer > &, edm::Handle< edm::SimVertexContainer > &)
void XtalDedxAnalysis::analyzeHits ( std::vector< PCaloHit > &  hits,
edm::Handle< edm::SimTrackContainer > &  SimTk,
edm::Handle< edm::SimVertexContainer > &  SimVtx 
)
protected

Definition at line 152 of file XtalDedxAnalysis.cc.

References relval_parameters_module::energy, mps_fire::i, gpuVertexFinder::iv, relval_steps::k2, meE1T0_, meE1T1_, meE9T0_, meE9T1_, meNHit_, mType_, and SpecificationBuilder_cfi::parent().

Referenced by analyze().

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

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 44 of file XtalDedxAnalysis.cc.

44 {}
void XtalDedxAnalysis::endJob ( void  )
inlineoverrideprotectedvirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 46 of file XtalDedxAnalysis.cc.

46 {}
void XtalDedxAnalysis::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 119 of file XtalDedxAnalysis.cc.

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

119  {
121  desc.add<edm::InputTag>("caloHitSource", edm::InputTag("g4SimHits", "EcalHitsEB"));
122  desc.add<std::string>("moduleLabelTk", "g4SimHits");
123  desc.add<double>("energyMax", 2.0);
124  descriptions.add("xtalDedxAnalysis", desc);
125 }
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)

Member Data Documentation

edm::InputTag XtalDedxAnalysis::caloHitSource_
private

Definition at line 53 of file XtalDedxAnalysis.cc.

Referenced by XtalDedxAnalysis().

TH1F * XtalDedxAnalysis::meE1T0_[4]
private

Definition at line 60 of file XtalDedxAnalysis.cc.

Referenced by analyzeHits(), and XtalDedxAnalysis().

TH1F * XtalDedxAnalysis::meE1T1_[4]
private

Definition at line 60 of file XtalDedxAnalysis.cc.

Referenced by analyzeHits(), and XtalDedxAnalysis().

TH1F * XtalDedxAnalysis::meE9T0_[4]
private

Definition at line 60 of file XtalDedxAnalysis.cc.

Referenced by analyzeHits(), and XtalDedxAnalysis().

TH1F * XtalDedxAnalysis::meE9T1_[4]
private

Definition at line 60 of file XtalDedxAnalysis.cc.

Referenced by analyzeHits(), and XtalDedxAnalysis().

TH1F* XtalDedxAnalysis::meNHit_[4]
private

Definition at line 60 of file XtalDedxAnalysis.cc.

Referenced by analyzeHits(), and XtalDedxAnalysis().

TH1I* XtalDedxAnalysis::mType_
private

Definition at line 61 of file XtalDedxAnalysis.cc.

Referenced by analyzeHits(), and XtalDedxAnalysis().

std::string XtalDedxAnalysis::simTkLabel_
private

Definition at line 54 of file XtalDedxAnalysis.cc.

Referenced by XtalDedxAnalysis().

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

Definition at line 56 of file XtalDedxAnalysis.cc.

Referenced by analyze(), and XtalDedxAnalysis().

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

Definition at line 57 of file XtalDedxAnalysis.cc.

Referenced by analyze(), and XtalDedxAnalysis().

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

Definition at line 58 of file XtalDedxAnalysis.cc.

Referenced by analyze(), and XtalDedxAnalysis().