CMS 3D CMS Logo

EcalPreshowerSimHitsValidation.cc
Go to the documentation of this file.
1 /*
2  * \file EcalPreshowerSimHitsValidation.cc
3  *
4  * \author C.Rovelli
5  *
6  */
7 
13 
14 using namespace cms;
15 using namespace edm;
16 using namespace std;
17 
19  :
20 
21  HepMCLabel(ps.getParameter<std::string>("moduleLabelMC")),
22  g4InfoLabel(ps.getParameter<std::string>("moduleLabelG4")),
23  EEHitsCollection(ps.getParameter<std::string>("EEHitsCollection")),
24  ESHitsCollection(ps.getParameter<std::string>("ESHitsCollection")) {
25  HepMCToken = consumes<edm::HepMCProduct>(HepMCLabel);
26  EEHitsToken =
27  consumes<edm::PCaloHitContainer>(edm::InputTag(std::string(g4InfoLabel), std::string(EEHitsCollection)));
28  ESHitsToken =
29  consumes<edm::PCaloHitContainer>(edm::InputTag(std::string(g4InfoLabel), std::string(ESHitsCollection)));
30  // verbosity switch
31  verbose_ = ps.getUntrackedParameter<bool>("verbose", false);
32 }
33 
35  ib.setCurrentFolder("EcalHitsV/EcalSimHitsValidation");
36  ib.setScope(MonitorElementData::Scope::RUN);
37 
38  std::string histo = "ES hits layer 1 multiplicity z+";
39  menESHits1zp_ = ib.book1D(histo, histo, 50, 0., 50.);
40 
41  histo = "ES hits layer 2 multiplicity z+";
42  menESHits2zp_ = ib.book1D(histo, histo, 50, 0., 50.);
43 
44  histo = "ES hits layer 1 multiplicity z-";
45  menESHits1zm_ = ib.book1D(histo, histo, 50, 0., 50.);
46 
47  histo = "ES hits layer 2 multiplicity z-";
48  menESHits2zm_ = ib.book1D(histo, histo, 50, 0., 50.);
49 
50  histo = "ES hits energy layer 1 z+";
51  meESEnergyHits1zp_ = ib.book1D(histo, histo, 100, 0., 0.05);
52 
53  histo = "ES hits energy layer 2 z+";
54  meESEnergyHits2zp_ = ib.book1D(histo, histo, 100, 0., 0.05);
55 
56  histo = "ES hits energy layer 1 z-";
57  meESEnergyHits1zm_ = ib.book1D(histo, histo, 100, 0., 0.05);
58 
59  histo = "ES hits energy layer 2 z-";
60  meESEnergyHits2zm_ = ib.book1D(histo, histo, 100, 0., 0.05);
61 
62  histo = "ES hits log10energy spectrum";
63  meEShitLog10Energy_ = ib.book1D(histo, histo, 140, -10., 4.);
64 
65  histo = "ES hits log10energy spectrum vs normalized energy";
66  meEShitLog10EnergyNorm_ = ib.bookProfile(histo, histo, 140, -10., 4., 100, 0., 1.);
67 
68  histo = "ES E1+07E2 z+";
69  meE1alphaE2zp_ = ib.book1D(histo, histo, 100, 0., 0.05);
70 
71  histo = "ES E1+07E2 z-";
72  meE1alphaE2zm_ = ib.book1D(histo, histo, 100, 0., 0.05);
73 
74  histo = "EE vs ES z+";
75  meEEoverESzp_ = ib.bookProfile(histo, histo, 250, 0., 500., 200, 0., 200.);
76 
77  histo = "EE vs ES z-";
78  meEEoverESzm_ = ib.bookProfile(histo, histo, 250, 0., 500., 200, 0., 200.);
79 
80  histo = "ES ene2oEne1 z+";
81  me2eszpOver1eszp_ = ib.book1D(histo, histo, 50, 0., 10.);
82 
83  histo = "ES ene2oEne1 z-";
84  me2eszmOver1eszm_ = ib.book1D(histo, histo, 50, 0., 10.);
85 }
86 
88  edm::LogInfo("EventInfo") << " Run = " << e.id().run() << " Event = " << e.id().event();
89 
91  e.getByToken(HepMCToken, MCEvt);
92 
94  e.getByToken(EEHitsToken, EcalHitsEE);
95 
97  e.getByToken(ESHitsToken, EcalHitsES);
98 
99  std::vector<PCaloHit> theEECaloHits;
100  if (EcalHitsEE.isValid()) {
101  theEECaloHits.insert(theEECaloHits.end(), EcalHitsEE->begin(), EcalHitsEE->end());
102  }
103 
104  std::vector<PCaloHit> theESCaloHits;
105  if (EcalHitsES.isValid()) {
106  theESCaloHits.insert(theESCaloHits.end(), EcalHitsES->begin(), EcalHitsES->end());
107  }
108 
109  double ESEnergy_ = 0.;
110  // std::map<unsigned int, std::vector<PCaloHit>,std::less<unsigned int> >
111  // CaloHitMap;
112 
113  // endcap
114  double EEetzp_ = 0.;
115  double EEetzm_ = 0.;
116  for (std::vector<PCaloHit>::iterator isim = theEECaloHits.begin(); isim != theEECaloHits.end(); ++isim) {
117  EEDetId eeid(isim->id());
118  if (eeid.zside() > 0)
119  EEetzp_ += isim->energy();
120  if (eeid.zside() < 0)
121  EEetzm_ += isim->energy();
122  }
123 
124  uint32_t nESHits1zp = 0;
125  uint32_t nESHits1zm = 0;
126  uint32_t nESHits2zp = 0;
127  uint32_t nESHits2zm = 0;
128  double ESet1zp_ = 0.;
129  double ESet2zp_ = 0.;
130  double ESet1zm_ = 0.;
131  double ESet2zm_ = 0.;
132  std::vector<double> econtr(140, 0.);
133 
134  for (std::vector<PCaloHit>::iterator isim = theESCaloHits.begin(); isim != theESCaloHits.end(); ++isim) {
135  // CaloHitMap[(*isim).id()].push_back((*isim));
136 
137  ESDetId esid(isim->id());
138 
139  LogDebug("HitInfo") << " CaloHit " << isim->getName() << "\n"
140  << " DetID = " << isim->id() << " ESDetId: z side " << esid.zside() << " plane "
141  << esid.plane() << esid.six() << ',' << esid.siy() << ':' << esid.strip() << "\n"
142  << " Time = " << isim->time() << "\n"
143  << " Track Id = " << isim->geantTrackId() << "\n"
144  << " Energy = " << isim->energy();
145 
146  ESEnergy_ += isim->energy();
147  if (isim->energy() > 0) {
148  meEShitLog10Energy_->Fill(log10(isim->energy()));
149  int log10i = int((log10(isim->energy()) + 10.) * 10.);
150  if (log10i >= 0 && log10i < 140)
151  econtr[log10i] += isim->energy();
152  }
153 
154  if (esid.plane() == 1) {
155  if (esid.zside() > 0) {
156  nESHits1zp++;
157  ESet1zp_ += isim->energy();
158  meESEnergyHits1zp_->Fill(isim->energy());
159  } else if (esid.zside() < 0) {
160  nESHits1zm++;
161  ESet1zm_ += isim->energy();
162  meESEnergyHits1zm_->Fill(isim->energy());
163  }
164  } else if (esid.plane() == 2) {
165  if (esid.zside() > 0) {
166  nESHits2zp++;
167  ESet2zp_ += isim->energy();
168  meESEnergyHits2zp_->Fill(isim->energy());
169  } else if (esid.zside() < 0) {
170  nESHits2zm++;
171  ESet2zm_ += isim->energy();
172  meESEnergyHits2zm_->Fill(isim->energy());
173  }
174  }
175  }
176 
177  menESHits1zp_->Fill(nESHits1zp);
178  menESHits1zm_->Fill(nESHits1zm);
179 
180  menESHits2zp_->Fill(nESHits2zp);
181  menESHits2zm_->Fill(nESHits2zm);
182 
183  if (ESEnergy_ != 0) {
184  for (int i = 0; i < 140; i++) {
185  meEShitLog10EnergyNorm_->Fill(-10. + (float(i) + 0.5) / 10., econtr[i] / ESEnergy_);
186  }
187  }
188 
189  for (HepMC::GenEvent::particle_const_iterator p = MCEvt->GetEvent()->particles_begin();
190  p != MCEvt->GetEvent()->particles_end();
191  ++p) {
192  double htheta = (*p)->momentum().theta();
193  double heta = -99999.;
194  if (tan(htheta * 0.5) > 0) {
195  heta = -log(tan(htheta * 0.5));
196  }
197 
198  if (heta > 1.653 && heta < 2.6) {
199  meE1alphaE2zp_->Fill(ESet1zp_ + 0.7 * ESet2zp_);
200  meEEoverESzp_->Fill((ESet1zp_ + 0.7 * ESet2zp_) / 0.00009, EEetzp_);
201  if (ESet1zp_ != 0.)
202  me2eszpOver1eszp_->Fill(ESet2zp_ / ESet1zp_);
203  }
204  if (heta < -1.653 && heta > -2.6) {
205  meE1alphaE2zm_->Fill(ESet1zm_ + 0.7 * ESet2zm_);
206  meEEoverESzm_->Fill((ESet1zm_ + 0.7 * ESet2zm_) / 0.00009, EEetzm_);
207  if (ESet1zm_ != 0.)
208  me2eszmOver1eszm_->Fill(ESet2zm_ / ESet1zm_);
209  }
210  }
211 }
212 
213 // LocalWords: EcalSimHitsValidation
mps_fire.i
i
Definition: mps_fire.py:428
EcalPreshowerSimHitsValidation::ESHitsToken
edm::EDGetTokenT< edm::PCaloHitContainer > ESHitsToken
Definition: EcalPreshowerSimHitsValidation.h:55
EcalPreshowerSimHitsValidation::meEShitLog10Energy_
MonitorElement * meEShitLog10Energy_
Definition: EcalPreshowerSimHitsValidation.h:65
EcalPreshowerSimHitsValidation::meESEnergyHits2zm_
MonitorElement * meESEnergyHits2zm_
Definition: EcalPreshowerSimHitsValidation.h:72
edm::Run
Definition: Run.h:45
EcalPreshowerSimHitsValidation::verbose_
bool verbose_
Definition: EcalPreshowerSimHitsValidation.h:57
edm
HLT enums.
Definition: AlignableModifier.h:19
EcalPreshowerSimHitsValidation::meEEoverESzm_
MonitorElement * meEEoverESzm_
Definition: EcalPreshowerSimHitsValidation.h:78
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
EcalPreshowerSimHitsValidation::meEEoverESzp_
MonitorElement * meEEoverESzp_
Definition: EcalPreshowerSimHitsValidation.h:77
EEDetId.h
EcalPreshowerSimHitsValidation::analyze
void analyze(const edm::Event &e, const edm::EventSetup &c) override
Analyze.
Definition: EcalPreshowerSimHitsValidation.cc:87
timingPdfMaker.histo
histo
Definition: timingPdfMaker.py:279
DQMStore.h
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
ESDetId
Definition: ESDetId.h:15
ESDetId.h
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
EcalPreshowerSimHitsValidation::EcalPreshowerSimHitsValidation
EcalPreshowerSimHitsValidation(const edm::ParameterSet &ps)
Constructor.
Definition: EcalPreshowerSimHitsValidation.cc:18
edm::Handle< edm::HepMCProduct >
EcalPreshowerSimHitsValidation::EEHitsCollection
std::string EEHitsCollection
Definition: EcalPreshowerSimHitsValidation.h:50
EcalPreshowerSimHitsValidation::HepMCToken
edm::EDGetTokenT< edm::HepMCProduct > HepMCToken
Definition: EcalPreshowerSimHitsValidation.h:53
EcalPreshowerSimHitsValidation::meESEnergyHits1zp_
MonitorElement * meESEnergyHits1zp_
Definition: EcalPreshowerSimHitsValidation.h:68
ecalPreshowerSimHitsValidation_cfi.ESHitsCollection
ESHitsCollection
Definition: ecalPreshowerSimHitsValidation_cfi.py:6
EcalPreshowerSimHitsValidation::meE1alphaE2zm_
MonitorElement * meE1alphaE2zm_
Definition: EcalPreshowerSimHitsValidation.h:75
dqm::impl::MonitorElement::Fill
void Fill(long long x)
Definition: MonitorElement.h:290
EcalPreshowerSimHitsValidation::EEHitsToken
edm::EDGetTokenT< edm::PCaloHitContainer > EEHitsToken
Definition: EcalPreshowerSimHitsValidation.h:54
EcalPreshowerSimHitsValidation.h
EcalPreshowerSimHitsValidation::meESEnergyHits2zp_
MonitorElement * meESEnergyHits2zp_
Definition: EcalPreshowerSimHitsValidation.h:69
EcalPreshowerSimHitsValidation::meE1alphaE2zp_
MonitorElement * meE1alphaE2zp_
Definition: EcalPreshowerSimHitsValidation.h:74
EEDetId
Definition: EEDetId.h:14
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
edm::ParameterSet
Definition: ParameterSet.h:47
funct::tan
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
EcalPreshowerSimHitsValidation::me2eszpOver1eszp_
MonitorElement * me2eszpOver1eszp_
Definition: EcalPreshowerSimHitsValidation.h:80
createfilelist.int
int
Definition: createfilelist.py:10
EcalPreshowerSimHitsValidation::g4InfoLabel
std::string g4InfoLabel
Definition: EcalPreshowerSimHitsValidation.h:49
cuy.ib
ib
Definition: cuy.py:662
edm::EventSetup
Definition: EventSetup.h:58
edm::HepMCProduct::GetEvent
const HepMC::GenEvent * GetEvent() const
Definition: HepMCProduct.h:37
ecalEndcapSimHitsValidation_cfi.EEHitsCollection
EEHitsCollection
Definition: ecalEndcapSimHitsValidation_cfi.py:5
EcalPreshowerSimHitsValidation::menESHits2zm_
MonitorElement * menESHits2zm_
Definition: EcalPreshowerSimHitsValidation.h:63
EcalPreshowerSimHitsValidation::menESHits2zp_
MonitorElement * menESHits2zp_
Definition: EcalPreshowerSimHitsValidation.h:60
EcalPreshowerSimHitsValidation::HepMCLabel
std::string HepMCLabel
Definition: EcalPreshowerSimHitsValidation.h:48
std
Definition: JetResolutionObject.h:76
EcalPreshowerSimHitsValidation::menESHits1zm_
MonitorElement * menESHits1zm_
Definition: EcalPreshowerSimHitsValidation.h:62
EcalPreshowerSimHitsValidation::menESHits1zp_
MonitorElement * menESHits1zp_
Definition: EcalPreshowerSimHitsValidation.h:59
EcalPreshowerSimHitsValidation::meESEnergyHits1zm_
MonitorElement * meESEnergyHits1zm_
Definition: EcalPreshowerSimHitsValidation.h:71
Exception.h
dqm-mbProfile.log
log
Definition: dqm-mbProfile.py:17
dqm::implementation::IBooker
Definition: DQMStore.h:43
EcalPreshowerSimHitsValidation::bookHistograms
void bookHistograms(DQMStore::IBooker &ib, edm::Run const &, edm::EventSetup const &c) override
Definition: EcalPreshowerSimHitsValidation.cc:34
c
auto & c
Definition: CAHitNtupletGeneratorKernelsImpl.h:46
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
edm::Event
Definition: Event.h:73
EcalPreshowerSimHitsValidation::me2eszmOver1eszm_
MonitorElement * me2eszmOver1eszm_
Definition: EcalPreshowerSimHitsValidation.h:81
edm::InputTag
Definition: InputTag.h:15
EcalPreshowerSimHitsValidation::meEShitLog10EnergyNorm_
MonitorElement * meEShitLog10EnergyNorm_
Definition: EcalPreshowerSimHitsValidation.h:66
EcalPreshowerSimHitsValidation::ESHitsCollection
std::string ESHitsCollection
Definition: EcalPreshowerSimHitsValidation.h:51
cms
Namespace of DDCMS conversion namespace.
Definition: ProducerAnalyzer.cc:21
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37