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  // get hold of back-end interface
33  dbe_ = 0;
34  dbe_ = Service<DQMStore>().operator->();
35  if ( dbe_ ) {
36  if ( verbose_ ) {
37  dbe_->setVerbose(1);
38  } else {
39  dbe_->setVerbose(0);
40  }
41  }
42  if ( dbe_ ) {
43  if ( verbose_ ) dbe_->showDirStructure();
44  }
45 
46 
47  // ----------------------
48  meESRecHitsEnergy_ = 0; // total energy
49  meESRecHitsEnergy_zp1st_ = 0;
50  meESRecHitsEnergy_zp2nd_ = 0;
51  meESRecHitsEnergy_zm1st_ = 0;
52  meESRecHitsEnergy_zm2nd_ = 0;
53  meESRecHitsMultip_ = 0; // total multiplicity
54  meESRecHitsMultip_zp1st_ = 0;
55  meESRecHitsMultip_zp2nd_ = 0;
56  meESRecHitsMultip_zm1st_ = 0;
57  meESRecHitsMultip_zm2nd_ = 0;
58  meESEERecHitsEnergy_zp_ = 0; // versus EE energy
59  meESEERecHitsEnergy_zm_ = 0;
60 
61  for (int kk=0; kk<32; kk++)
62  {
63  meESRecHitsStripOccupancy_zp1st_[kk] = 0;
64  meESRecHitsStripOccupancy_zm1st_[kk] = 0;
65  meESRecHitsStripOccupancy_zp2nd_[kk] = 0;
66  meESRecHitsStripOccupancy_zm2nd_[kk] = 0;
67  }
68 
69 
70  // ----------------------
71  Char_t histo[200];
72  if ( dbe_ )
73  {
74  dbe_->setCurrentFolder("EcalRecHitsV/EcalPreshowerRecHitsTask");
75 
76  sprintf (histo, "ES Energy" );
77  meESRecHitsEnergy_ = dbe_->book1D(histo, histo, 210, -0.0005, 0.01);
78 
79  sprintf (histo, "ES Energy Plane1 Side+" );
80  meESRecHitsEnergy_zp1st_ = dbe_->book1D(histo, histo, 210, -0.0005, 0.01);
81 
82  sprintf (histo, "ES Energy Plane2 Side+");
83  meESRecHitsEnergy_zp2nd_ = dbe_->book1D(histo, histo, 210, -0.0005, 0.01);
84 
85  sprintf (histo, "ES Energy Plane1 Side-");
86  meESRecHitsEnergy_zm1st_ = dbe_->book1D(histo, histo, 210, -0.0005, 0.01);
87 
88  sprintf (histo, "ES Energy Plane2 Side-");
89  meESRecHitsEnergy_zm2nd_ = dbe_->book1D(histo, histo, 210, -0.0005, 0.01);
90 
91  sprintf (histo, "ES Multiplicity" );
92  meESRecHitsMultip_ = dbe_->book1D(histo, histo, 100, 0., 700.);
93 
94  sprintf (histo, "ES Multiplicity Plane1 Side+");
95  meESRecHitsMultip_zp1st_ = dbe_->book1D(histo, histo, 100, 0., 700.);
96 
97  sprintf (histo, "ES Multiplicity Plane2 Side+");
98  meESRecHitsMultip_zp2nd_ = dbe_->book1D(histo, histo, 100, 0., 700.);
99 
100  sprintf (histo, "ES Multiplicity Plane1 Side-");
101  meESRecHitsMultip_zm1st_ = dbe_->book1D(histo, histo, 100, 0., 700.);
102 
103  sprintf (histo, "ES Multiplicity Plane2 Side-");
104  meESRecHitsMultip_zm2nd_ = dbe_->book1D(histo, histo, 100, 0., 700.);
105 
106  sprintf (histo, "Preshower EE vs ES energy Side+");
107  meESEERecHitsEnergy_zp_ = dbe_->book2D(histo, histo, 100, 0., 0.2, 100, 0., 150.);
108 
109  sprintf (histo, "Preshower EE vs ES energy Side-");
110  meESEERecHitsEnergy_zm_ = dbe_->book2D(histo, histo, 100, 0., 0.2, 100, 0., 150.);
111 
112  for (int kk=0; kk<32; kk++)
113  {
114  sprintf(histo, "ES Occupancy Plane1 Side+ Strip%02d", kk+1);
115  meESRecHitsStripOccupancy_zp1st_[kk] = dbe_->book2D(histo, histo, 40, 0., 40., 40, 0., 40.);
116 
117  sprintf(histo, "ES Occupancy Plane2 Side+ Strip%02d", kk+1);
118  meESRecHitsStripOccupancy_zp2nd_[kk] = dbe_->book2D(histo, histo, 40, 0., 40., 40, 0., 40.);
119 
120  sprintf(histo, "ES Occupancy Plane1 Side- Strip%02d", kk+1);
121  meESRecHitsStripOccupancy_zm1st_[kk] = dbe_->book2D(histo, histo, 40, 0., 40., 40, 0., 40.);
122 
123  sprintf(histo, "ES Occupancy Plane2 Side- Strip%02d", kk+1);
124  meESRecHitsStripOccupancy_zm2nd_[kk] = dbe_->book2D(histo, histo, 40, 0., 40., 40, 0., 40.);
125  }
126  }
127 }
128 
130 
131 }
132 
134 
135 }
136 
138 
139 }
140 
142 
143  const ESRecHitCollection *ESRecHit = 0;
144  Handle<ESRecHitCollection> EcalRecHitES;
145  e.getByToken( ESrechitCollection_token_, EcalRecHitES);
146  if (EcalRecHitES.isValid()) {
147  ESRecHit = EcalRecHitES.product ();
148  } else {
149  return;
150  }
151 
152  bool skipEE = false;
153  const EERecHitCollection *EERecHit = 0;
154  Handle<EERecHitCollection> EcalRecHitEE;
155  e.getByToken( EErechitCollection_token_, EcalRecHitEE);
156  if (EcalRecHitEE.isValid()){
157  EERecHit = EcalRecHitEE.product ();
158  } else {
159  skipEE = true;
160  }
161 
162  const EEUncalibratedRecHitCollection *EEUncalibRecHit = 0;
163  Handle< EEUncalibratedRecHitCollection > EcalUncalibRecHitEE;
164  e.getByToken( EEuncalibrechitCollection_token_, EcalUncalibRecHitEE);
165  if (EcalUncalibRecHitEE.isValid()) {
166  EEUncalibRecHit = EcalUncalibRecHitEE.product() ;
167  } else {
168  skipEE = true;
169  }
170 
171 
172 
173  // ----------------------
174  // loop over RecHits
175  // multiplicities
176  int mult_tot = 0;
177  int mult_zp1st = 0;
178  int mult_zp2nd = 0;
179  int mult_zm1st = 0;
180  int mult_zm2nd = 0;
181 
182  // energies
183  float ene_zp1st = 0.;
184  float ene_zp2nd = 0.;
185  float ene_zm1st = 0.;
186  float ene_zm2nd = 0.;
187 
188 
189  // ES
190  for (ESRecHitCollection::const_iterator recHit = ESRecHit->begin(); recHit != ESRecHit->end() ; ++recHit)
191  {
192  ESDetId ESid = ESDetId(recHit->id());
193 
194  int zside = ESid.zside();
195  int plane = ESid.plane();
196  int six = ESid.six();
197  int siy = ESid.siy();
198  int strip = ESid.strip();
199 
200  // global
201  mult_tot++;
202  if (meESRecHitsEnergy_) meESRecHitsEnergy_ ->Fill(recHit->energy());
203 
204  // side +, plane 1
205  if ( (zside == +1) && (plane == 1) )
206  {
207  mult_zp1st++;
208  ene_zp1st += recHit->energy();
209  if ( meESRecHitsEnergy_zp1st_ ) { meESRecHitsEnergy_zp1st_ -> Fill(recHit->energy()); }
210  if ( meESRecHitsStripOccupancy_zp1st_[strip-1] ){ meESRecHitsStripOccupancy_zp1st_[strip-1]-> Fill( six, siy ); }
211  }
212 
213 
214  // side +, plane 2
215  if ( (zside == +1) && (plane == 2) )
216  {
217  mult_zp2nd++;
218  ene_zp2nd += recHit->energy();
219  if ( meESRecHitsEnergy_zp2nd_ ) { meESRecHitsEnergy_zp2nd_ -> Fill(recHit->energy()); }
220  if ( meESRecHitsStripOccupancy_zp2nd_[strip-1] ){ meESRecHitsStripOccupancy_zp2nd_[strip-1]-> Fill( six, siy ); }
221  }
222 
223 
224  // side -, plane 1
225  if ( (zside == -1) && (plane == 1) )
226  {
227  mult_zm1st++;
228  ene_zm1st += recHit->energy();
229  if ( meESRecHitsEnergy_zm1st_ ) { meESRecHitsEnergy_zm1st_ -> Fill(recHit->energy()); }
230  if ( meESRecHitsStripOccupancy_zm1st_[strip-1] ){ meESRecHitsStripOccupancy_zm1st_[strip-1]-> Fill( six, siy ); }
231  }
232 
233 
234  // side +, plane 2
235  if ( (zside == -1) && (plane == 2) )
236  {
237  mult_zm2nd ++;
238  ene_zm2nd += recHit->energy();
239  if ( meESRecHitsEnergy_zm2nd_ ) { meESRecHitsEnergy_zm2nd_ -> Fill(recHit->energy()); }
240  if ( meESRecHitsStripOccupancy_zm2nd_[strip-1] ){ meESRecHitsStripOccupancy_zm2nd_[strip-1]-> Fill( six, siy ); }
241  }
242 
243  } // loop over the ES RecHitCollection
244 
245 
246 
247  // EE
248  double zpEE = 0.;
249  double zmEE = 0.;
250  if ( ! skipEE ) {
251 
252  for (EcalUncalibratedRecHitCollection::const_iterator uncalibRecHit = EEUncalibRecHit->begin(); uncalibRecHit != EEUncalibRecHit->end() ; ++uncalibRecHit)
253  {
254  EEDetId EEid = EEDetId(uncalibRecHit->id());
255  int mySide = EEid.zside();
256 
257  // Find corresponding recHit
258  EcalRecHitCollection::const_iterator myRecHit = EERecHit->find(EEid);
259 
260  if (myRecHit != EERecHit->end() )
261  {
262  if (mySide > 0) { zpEE = zpEE + myRecHit->energy(); }
263  if (mySide < 0) { zmEE = zmEE + myRecHit->energy(); }
264  }
265  }
266  }
267 
268 
269  // filling histos
270  if (meESRecHitsMultip_) { meESRecHitsMultip_ -> Fill(mult_tot); }
271  if (meESRecHitsMultip_zp1st_ ) { meESRecHitsMultip_zp1st_ -> Fill(mult_zp1st); }
272  if (meESRecHitsMultip_zp2nd_ ) { meESRecHitsMultip_zp2nd_ -> Fill(mult_zp2nd); }
273  if (meESRecHitsMultip_zm1st_ ) { meESRecHitsMultip_zm1st_ -> Fill(mult_zm1st); }
274  if (meESRecHitsMultip_zm2nd_ ) { meESRecHitsMultip_zm2nd_ -> Fill(mult_zm2nd); }
275  if (meESEERecHitsEnergy_zp_) { meESEERecHitsEnergy_zp_ -> Fill( (ene_zp1st + 0.7*ene_zp2nd)/0.09, zpEE ); }
276  if (meESEERecHitsEnergy_zm_) { meESEERecHitsEnergy_zm_ -> Fill( (ene_zm1st + 0.7*ene_zm2nd)/0.09, zmEE ); }
277 }
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:434
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
int zside() const
Definition: ESDetId.h:44
bool isValid() const
Definition: HandleBase.h:76
DQMStore * dbe_
const_iterator end() const
T const * product() const
Definition: Handle.h:81
iterator find(key_type k)
int plane() const
Definition: ESDetId.h:46
const_iterator begin() const