CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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  : g4InfoLabel(ps.getParameter<std::string>("moduleLabelG4")),
20  EEHitsCollection(ps.getParameter<std::string>("EEHitsCollection")),
21  ESHitsCollection(ps.getParameter<std::string>("ESHitsCollection")),
22  HepMCToken(consumes<edm::HepMCProduct>(ps.getParameter<edm::InputTag>("moduleLabelMC"))) {
23  EEHitsToken =
24  consumes<edm::PCaloHitContainer>(edm::InputTag(std::string(g4InfoLabel), std::string(EEHitsCollection)));
25  ESHitsToken =
26  consumes<edm::PCaloHitContainer>(edm::InputTag(std::string(g4InfoLabel), std::string(ESHitsCollection)));
27  // verbosity switch
28  verbose_ = ps.getUntrackedParameter<bool>("verbose", false);
29 }
30 
32  ib.setCurrentFolder("EcalHitsV/EcalSimHitsValidation");
33  ib.setScope(MonitorElementData::Scope::RUN);
34 
35  std::string histo = "ES hits layer 1 multiplicity z+";
36  menESHits1zp_ = ib.book1D(histo, histo, 50, 0., 50.);
37 
38  histo = "ES hits layer 2 multiplicity z+";
39  menESHits2zp_ = ib.book1D(histo, histo, 50, 0., 50.);
40 
41  histo = "ES hits layer 1 multiplicity z-";
42  menESHits1zm_ = ib.book1D(histo, histo, 50, 0., 50.);
43 
44  histo = "ES hits layer 2 multiplicity z-";
45  menESHits2zm_ = ib.book1D(histo, histo, 50, 0., 50.);
46 
47  histo = "ES hits energy layer 1 z+";
48  meESEnergyHits1zp_ = ib.book1D(histo, histo, 100, 0., 0.05);
49 
50  histo = "ES hits energy layer 2 z+";
51  meESEnergyHits2zp_ = ib.book1D(histo, histo, 100, 0., 0.05);
52 
53  histo = "ES hits energy layer 1 z-";
54  meESEnergyHits1zm_ = ib.book1D(histo, histo, 100, 0., 0.05);
55 
56  histo = "ES hits energy layer 2 z-";
57  meESEnergyHits2zm_ = ib.book1D(histo, histo, 100, 0., 0.05);
58 
59  histo = "ES hits log10energy spectrum";
60  meEShitLog10Energy_ = ib.book1D(histo, histo, 140, -10., 4.);
61 
62  histo = "ES hits log10energy spectrum vs normalized energy";
63  meEShitLog10EnergyNorm_ = ib.bookProfile(histo, histo, 140, -10., 4., 100, 0., 1.);
64 
65  histo = "ES E1+07E2 z+";
66  meE1alphaE2zp_ = ib.book1D(histo, histo, 100, 0., 0.05);
67 
68  histo = "ES E1+07E2 z-";
69  meE1alphaE2zm_ = ib.book1D(histo, histo, 100, 0., 0.05);
70 
71  histo = "EE vs ES z+";
72  meEEoverESzp_ = ib.bookProfile(histo, histo, 250, 0., 500., 200, 0., 200.);
73 
74  histo = "EE vs ES z-";
75  meEEoverESzm_ = ib.bookProfile(histo, histo, 250, 0., 500., 200, 0., 200.);
76 
77  histo = "ES ene2oEne1 z+";
78  me2eszpOver1eszp_ = ib.book1D(histo, histo, 50, 0., 10.);
79 
80  histo = "ES ene2oEne1 z-";
81  me2eszmOver1eszm_ = ib.book1D(histo, histo, 50, 0., 10.);
82 }
83 
85  edm::LogInfo("EventInfo") << " Run = " << e.id().run() << " Event = " << e.id().event();
86 
88  e.getByToken(HepMCToken, MCEvt);
89 
91  e.getByToken(EEHitsToken, EcalHitsEE);
92 
94  e.getByToken(ESHitsToken, EcalHitsES);
95 
96  std::vector<PCaloHit> theEECaloHits;
97  if (EcalHitsEE.isValid()) {
98  theEECaloHits.insert(theEECaloHits.end(), EcalHitsEE->begin(), EcalHitsEE->end());
99  }
100 
101  std::vector<PCaloHit> theESCaloHits;
102  if (EcalHitsES.isValid()) {
103  theESCaloHits.insert(theESCaloHits.end(), EcalHitsES->begin(), EcalHitsES->end());
104  }
105 
106  double ESEnergy_ = 0.;
107  // std::map<unsigned int, std::vector<PCaloHit>,std::less<unsigned int> >
108  // CaloHitMap;
109 
110  // endcap
111  double EEetzp_ = 0.;
112  double EEetzm_ = 0.;
113  for (std::vector<PCaloHit>::iterator isim = theEECaloHits.begin(); isim != theEECaloHits.end(); ++isim) {
114  EEDetId eeid(isim->id());
115  if (eeid.zside() > 0)
116  EEetzp_ += isim->energy();
117  if (eeid.zside() < 0)
118  EEetzm_ += isim->energy();
119  }
120 
121  uint32_t nESHits1zp = 0;
122  uint32_t nESHits1zm = 0;
123  uint32_t nESHits2zp = 0;
124  uint32_t nESHits2zm = 0;
125  double ESet1zp_ = 0.;
126  double ESet2zp_ = 0.;
127  double ESet1zm_ = 0.;
128  double ESet2zm_ = 0.;
129  std::vector<double> econtr(140, 0.);
130 
131  for (std::vector<PCaloHit>::iterator isim = theESCaloHits.begin(); isim != theESCaloHits.end(); ++isim) {
132  // CaloHitMap[(*isim).id()].push_back((*isim));
133 
134  ESDetId esid(isim->id());
135 
136  LogDebug("HitInfo") << " CaloHit " << isim->getName() << "\n"
137  << " DetID = " << isim->id() << " ESDetId: z side " << esid.zside() << " plane "
138  << esid.plane() << esid.six() << ',' << esid.siy() << ':' << esid.strip() << "\n"
139  << " Time = " << isim->time() << "\n"
140  << " Track Id = " << isim->geantTrackId() << "\n"
141  << " Energy = " << isim->energy();
142 
143  ESEnergy_ += isim->energy();
144  if (isim->energy() > 0) {
145  meEShitLog10Energy_->Fill(log10(isim->energy()));
146  int log10i = int((log10(isim->energy()) + 10.) * 10.);
147  if (log10i >= 0 && log10i < 140)
148  econtr[log10i] += isim->energy();
149  }
150 
151  if (esid.plane() == 1) {
152  if (esid.zside() > 0) {
153  nESHits1zp++;
154  ESet1zp_ += isim->energy();
155  meESEnergyHits1zp_->Fill(isim->energy());
156  } else if (esid.zside() < 0) {
157  nESHits1zm++;
158  ESet1zm_ += isim->energy();
159  meESEnergyHits1zm_->Fill(isim->energy());
160  }
161  } else if (esid.plane() == 2) {
162  if (esid.zside() > 0) {
163  nESHits2zp++;
164  ESet2zp_ += isim->energy();
165  meESEnergyHits2zp_->Fill(isim->energy());
166  } else if (esid.zside() < 0) {
167  nESHits2zm++;
168  ESet2zm_ += isim->energy();
169  meESEnergyHits2zm_->Fill(isim->energy());
170  }
171  }
172  }
173 
174  menESHits1zp_->Fill(nESHits1zp);
175  menESHits1zm_->Fill(nESHits1zm);
176 
177  menESHits2zp_->Fill(nESHits2zp);
178  menESHits2zm_->Fill(nESHits2zm);
179 
180  if (ESEnergy_ != 0) {
181  for (int i = 0; i < 140; i++) {
182  meEShitLog10EnergyNorm_->Fill(-10. + (float(i) + 0.5) / 10., econtr[i] / ESEnergy_);
183  }
184  }
185 
186  for (HepMC::GenEvent::particle_const_iterator p = MCEvt->GetEvent()->particles_begin();
187  p != MCEvt->GetEvent()->particles_end();
188  ++p) {
189  double htheta = (*p)->momentum().theta();
190  double heta = -99999.;
191  if (tan(htheta * 0.5) > 0) {
192  heta = -log(tan(htheta * 0.5));
193  }
194 
195  if (heta > 1.653 && heta < 2.6) {
196  meE1alphaE2zp_->Fill(ESet1zp_ + 0.7 * ESet2zp_);
197  meEEoverESzp_->Fill((ESet1zp_ + 0.7 * ESet2zp_) / 0.00009, EEetzp_);
198  if (ESet1zp_ != 0.)
199  me2eszpOver1eszp_->Fill(ESet2zp_ / ESet1zp_);
200  }
201  if (heta < -1.653 && heta > -2.6) {
202  meE1alphaE2zm_->Fill(ESet1zm_ + 0.7 * ESet2zm_);
203  meEEoverESzm_->Fill((ESet1zm_ + 0.7 * ESet2zm_) / 0.00009, EEetzm_);
204  if (ESet1zm_ != 0.)
205  me2eszmOver1eszm_->Fill(ESet2zm_ / ESet1zm_);
206  }
207  }
208 }
209 
210 // LocalWords: EcalSimHitsValidation
RunNumber_t run() const
Definition: EventID.h:38
EventNumber_t event() const
Definition: EventID.h:40
T getUntrackedParameter(std::string const &, T const &) const
static std::vector< std::string > checklist log
const edm::EventSetup & c
int ib
Definition: cuy.py:661
EcalPreshowerSimHitsValidation(const edm::ParameterSet &ps)
Constructor.
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
virtual MonitorElementData::Scope setScope(MonitorElementData::Scope newscope)
Definition: DQMStore.cc:46
void analyze(const edm::Event &e, const edm::EventSetup &c) override
Analyze.
void Fill(long long x)
edm::EDGetTokenT< edm::HepMCProduct > HepMCToken
MonitorElement * bookProfile(TString const &name, TString const &title, int nchX, double lowX, double highX, int, double lowY, double highY, char const *option="s", FUNC onbooking=NOOP())
Definition: DQMStore.h:322
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
bool isValid() const
Definition: HandleBase.h:70
void bookHistograms(DQMStore::IBooker &ib, edm::Run const &, edm::EventSetup const &c) override
Log< level::Info, false > LogInfo
edm::EventID id() const
Definition: EventBase.h:59
edm::EDGetTokenT< edm::PCaloHitContainer > EEHitsToken
edm::EDGetTokenT< edm::PCaloHitContainer > ESHitsToken
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
Definition: Run.h:45
#define LogDebug(id)