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