test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EcalPreshowerRecHitsValidation.cc
Go to the documentation of this file.
1 /*
2  * \file EcalPreshowerRecHitsValidation.cc
3  *
4  * \author C. Rovelli
5  *
6  */
7 
12 
13 using namespace cms;
14 using namespace edm;
15 using namespace std;
16 
17 
19 
20 
21  // ----------------------
22  EEuncalibrechitCollection_token_ = consumes<EEUncalibratedRecHitCollection>(ps.getParameter<edm::InputTag>("EEuncalibrechitCollection"));
23  EErechitCollection_token_ = consumes<EERecHitCollection>(ps.getParameter<edm::InputTag>("EErechitCollection"));
24  ESrechitCollection_token_ = consumes<ESRecHitCollection>(ps.getParameter<edm::InputTag>("ESrechitCollection"));
25 
26 
27  // ----------------------
28  // verbosity switch
29  verbose_ = ps.getUntrackedParameter<bool>("verbose", false);
30 
31  // ----------------------
32  meESRecHitsEnergy_ = 0; // total energy
33  meESRecHitsEnergy_zp1st_ = 0;
34  meESRecHitsEnergy_zp2nd_ = 0;
35  meESRecHitsEnergy_zm1st_ = 0;
36  meESRecHitsEnergy_zm2nd_ = 0;
37  meESRecHitsMultip_ = 0; // total multiplicity
38  meESRecHitsMultip_zp1st_ = 0;
39  meESRecHitsMultip_zp2nd_ = 0;
40  meESRecHitsMultip_zm1st_ = 0;
41  meESRecHitsMultip_zm2nd_ = 0;
42  meESEERecHitsEnergy_zp_ = 0; // versus EE energy
43  meESEERecHitsEnergy_zm_ = 0;
44 
45  for (int kk=0; kk<32; kk++)
46  {
47  meESRecHitsStripOccupancy_zp1st_[kk] = 0;
48  meESRecHitsStripOccupancy_zm1st_[kk] = 0;
49  meESRecHitsStripOccupancy_zp2nd_[kk] = 0;
50  meESRecHitsStripOccupancy_zm2nd_[kk] = 0;
51  }
52 }
53 
55 
56 }
57 
59 
60  Char_t histo[200];
61 
62  ibooker.setCurrentFolder("EcalRecHitsV/EcalPreshowerRecHitsTask");
63 
64  sprintf (histo, "ES Energy" );
65  meESRecHitsEnergy_ = ibooker.book1D(histo, histo, 210, -0.0005, 0.01);
66 
67  sprintf (histo, "ES Energy Plane1 Side+" );
68  meESRecHitsEnergy_zp1st_ = ibooker.book1D(histo, histo, 210, -0.0005, 0.01);
69 
70  sprintf (histo, "ES Energy Plane2 Side+");
71  meESRecHitsEnergy_zp2nd_ = ibooker.book1D(histo, histo, 210, -0.0005, 0.01);
72 
73  sprintf (histo, "ES Energy Plane1 Side-");
74  meESRecHitsEnergy_zm1st_ = ibooker.book1D(histo, histo, 210, -0.0005, 0.01);
75 
76  sprintf (histo, "ES Energy Plane2 Side-");
77  meESRecHitsEnergy_zm2nd_ = ibooker.book1D(histo, histo, 210, -0.0005, 0.01);
78 
79  sprintf (histo, "ES Multiplicity" );
80  meESRecHitsMultip_ = ibooker.book1D(histo, histo, 100, 0., 700.);
81 
82  sprintf (histo, "ES Multiplicity Plane1 Side+");
83  meESRecHitsMultip_zp1st_ = ibooker.book1D(histo, histo, 100, 0., 700.);
84 
85  sprintf (histo, "ES Multiplicity Plane2 Side+");
86  meESRecHitsMultip_zp2nd_ = ibooker.book1D(histo, histo, 100, 0., 700.);
87 
88  sprintf (histo, "ES Multiplicity Plane1 Side-");
89  meESRecHitsMultip_zm1st_ = ibooker.book1D(histo, histo, 100, 0., 700.);
90 
91  sprintf (histo, "ES Multiplicity Plane2 Side-");
92  meESRecHitsMultip_zm2nd_ = ibooker.book1D(histo, histo, 100, 0., 700.);
93 
94  sprintf (histo, "Preshower EE vs ES energy Side+");
95  meESEERecHitsEnergy_zp_ = ibooker.book2D(histo, histo, 100, 0., 0.2, 100, 0., 150.);
96 
97  sprintf (histo, "Preshower EE vs ES energy Side-");
98  meESEERecHitsEnergy_zm_ = ibooker.book2D(histo, histo, 100, 0., 0.2, 100, 0., 150.);
99 
100  for (int kk=0; kk<32; kk++)
101  {
102  sprintf(histo, "ES Occupancy Plane1 Side+ Strip%02d", kk+1);
103  meESRecHitsStripOccupancy_zp1st_[kk] = ibooker.book2D(histo, histo, 40, 0., 40., 40, 0., 40.);
104 
105  sprintf(histo, "ES Occupancy Plane2 Side+ Strip%02d", kk+1);
106  meESRecHitsStripOccupancy_zp2nd_[kk] = ibooker.book2D(histo, histo, 40, 0., 40., 40, 0., 40.);
107 
108  sprintf(histo, "ES Occupancy Plane1 Side- Strip%02d", kk+1);
109  meESRecHitsStripOccupancy_zm1st_[kk] = ibooker.book2D(histo, histo, 40, 0., 40., 40, 0., 40.);
110 
111  sprintf(histo, "ES Occupancy Plane2 Side- Strip%02d", kk+1);
112  meESRecHitsStripOccupancy_zm2nd_[kk] = ibooker.book2D(histo, histo, 40, 0., 40., 40, 0., 40.);
113  }
114 }
115 
117 
118  const ESRecHitCollection *ESRecHit = 0;
119  Handle<ESRecHitCollection> EcalRecHitES;
120  e.getByToken( ESrechitCollection_token_, EcalRecHitES);
121  if (EcalRecHitES.isValid()) {
122  ESRecHit = EcalRecHitES.product ();
123  } else {
124  return;
125  }
126 
127  bool skipEE = false;
128  const EERecHitCollection *EERecHit = 0;
129  Handle<EERecHitCollection> EcalRecHitEE;
130  e.getByToken( EErechitCollection_token_, EcalRecHitEE);
131  if (EcalRecHitEE.isValid()){
132  EERecHit = EcalRecHitEE.product ();
133  } else {
134  skipEE = true;
135  }
136 
137  const EEUncalibratedRecHitCollection *EEUncalibRecHit = 0;
138  Handle< EEUncalibratedRecHitCollection > EcalUncalibRecHitEE;
139  e.getByToken( EEuncalibrechitCollection_token_, EcalUncalibRecHitEE);
140  if (EcalUncalibRecHitEE.isValid()) {
141  EEUncalibRecHit = EcalUncalibRecHitEE.product() ;
142  } else {
143  skipEE = true;
144  }
145 
146 
147 
148  // ----------------------
149  // loop over RecHits
150  // multiplicities
151  int mult_tot = 0;
152  int mult_zp1st = 0;
153  int mult_zp2nd = 0;
154  int mult_zm1st = 0;
155  int mult_zm2nd = 0;
156 
157  // energies
158  float ene_zp1st = 0.;
159  float ene_zp2nd = 0.;
160  float ene_zm1st = 0.;
161  float ene_zm2nd = 0.;
162 
163 
164  // ES
165  for (ESRecHitCollection::const_iterator recHit = ESRecHit->begin(); recHit != ESRecHit->end() ; ++recHit)
166  {
167  ESDetId ESid = ESDetId(recHit->id());
168 
169  int zside = ESid.zside();
170  int plane = ESid.plane();
171  int six = ESid.six();
172  int siy = ESid.siy();
173  int strip = ESid.strip();
174 
175  // global
176  mult_tot++;
177  if (meESRecHitsEnergy_) meESRecHitsEnergy_ ->Fill(recHit->energy());
178 
179  // side +, plane 1
180  if ( (zside == +1) && (plane == 1) )
181  {
182  mult_zp1st++;
183  ene_zp1st += recHit->energy();
184  if ( meESRecHitsEnergy_zp1st_ ) { meESRecHitsEnergy_zp1st_ -> Fill(recHit->energy()); }
185  if ( meESRecHitsStripOccupancy_zp1st_[strip-1] ){ meESRecHitsStripOccupancy_zp1st_[strip-1]-> Fill( six, siy ); }
186  }
187 
188 
189  // side +, plane 2
190  if ( (zside == +1) && (plane == 2) )
191  {
192  mult_zp2nd++;
193  ene_zp2nd += recHit->energy();
194  if ( meESRecHitsEnergy_zp2nd_ ) { meESRecHitsEnergy_zp2nd_ -> Fill(recHit->energy()); }
195  if ( meESRecHitsStripOccupancy_zp2nd_[strip-1] ){ meESRecHitsStripOccupancy_zp2nd_[strip-1]-> Fill( six, siy ); }
196  }
197 
198 
199  // side -, plane 1
200  if ( (zside == -1) && (plane == 1) )
201  {
202  mult_zm1st++;
203  ene_zm1st += recHit->energy();
204  if ( meESRecHitsEnergy_zm1st_ ) { meESRecHitsEnergy_zm1st_ -> Fill(recHit->energy()); }
205  if ( meESRecHitsStripOccupancy_zm1st_[strip-1] ){ meESRecHitsStripOccupancy_zm1st_[strip-1]-> Fill( six, siy ); }
206  }
207 
208 
209  // side +, plane 2
210  if ( (zside == -1) && (plane == 2) )
211  {
212  mult_zm2nd ++;
213  ene_zm2nd += recHit->energy();
214  if ( meESRecHitsEnergy_zm2nd_ ) { meESRecHitsEnergy_zm2nd_ -> Fill(recHit->energy()); }
215  if ( meESRecHitsStripOccupancy_zm2nd_[strip-1] ){ meESRecHitsStripOccupancy_zm2nd_[strip-1]-> Fill( six, siy ); }
216  }
217 
218  } // loop over the ES RecHitCollection
219 
220 
221 
222  // EE
223  double zpEE = 0.;
224  double zmEE = 0.;
225  if ( ! skipEE ) {
226 
227  for (EcalUncalibratedRecHitCollection::const_iterator uncalibRecHit = EEUncalibRecHit->begin(); uncalibRecHit != EEUncalibRecHit->end() ; ++uncalibRecHit)
228  {
229  EEDetId EEid = EEDetId(uncalibRecHit->id());
230  int mySide = EEid.zside();
231 
232  // Find corresponding recHit
233  EcalRecHitCollection::const_iterator myRecHit = EERecHit->find(EEid);
234 
235  if (myRecHit != EERecHit->end() )
236  {
237  if (mySide > 0) { zpEE = zpEE + myRecHit->energy(); }
238  if (mySide < 0) { zmEE = zmEE + myRecHit->energy(); }
239  }
240  }
241  }
242 
243 
244  // filling histos
245  if (meESRecHitsMultip_) { meESRecHitsMultip_ -> Fill(mult_tot); }
246  if (meESRecHitsMultip_zp1st_ ) { meESRecHitsMultip_zp1st_ -> Fill(mult_zp1st); }
247  if (meESRecHitsMultip_zp2nd_ ) { meESRecHitsMultip_zp2nd_ -> Fill(mult_zp2nd); }
248  if (meESRecHitsMultip_zm1st_ ) { meESRecHitsMultip_zm1st_ -> Fill(mult_zm1st); }
249  if (meESRecHitsMultip_zm2nd_ ) { meESRecHitsMultip_zm2nd_ -> Fill(mult_zm2nd); }
250  if (meESEERecHitsEnergy_zp_) { meESEERecHitsEnergy_zp_ -> Fill( (ene_zp1st + 0.7*ene_zp2nd)/0.09, zpEE ); }
251  if (meESEERecHitsEnergy_zm_) { meESEERecHitsEnergy_zm_ -> Fill( (ene_zm1st + 0.7*ene_zm2nd)/0.09, zmEE ); }
252 }
EcalPreshowerRecHitsValidation(const edm::ParameterSet &ps)
Constructor.
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
int strip() const
Definition: ESDetId.h:52
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:464
std::vector< EcalRecHit >::const_iterator const_iterator
int six() const
Definition: ESDetId.h:48
int zside(DetId const &)
void analyze(const edm::Event &e, const edm::EventSetup &c)
Analyze.
int siy() const
Definition: ESDetId.h:50
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
int zside() const
Definition: EEDetId.h:70
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:115
int zside() const
Definition: ESDetId.h:44
bool isValid() const
Definition: HandleBase.h:75
const_iterator end() const
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:274
T const * product() const
Definition: Handle.h:81
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:133
iterator find(key_type k)
int plane() const
Definition: ESDetId.h:46
void bookHistograms(DQMStore::IBooker &i, edm::Run const &, edm::EventSetup const &) override
const_iterator begin() const
Definition: Run.h:43