CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EcalBarrelRecHitsValidation.cc
Go to the documentation of this file.
1 /*
2  * \file EcalBarrelRecHitsValidation.cc
3  *
4  * $Date: 2009/07/28 09:32:01 $
5  * \author C. Rovelli
6  *
7  */
8 
12 
13 using namespace cms;
14 using namespace edm;
15 using namespace std;
16 
18 
19  // ----------------------
20  EBdigiCollection_ = ps.getParameter<edm::InputTag>("EBdigiCollection");
21  EBuncalibrechitCollection_ = ps.getParameter<edm::InputTag>("EBuncalibrechitCollection");
22 
23  // ----------------------
24  // verbosity switch
25  verbose_ = ps.getUntrackedParameter<bool>("verbose", false);
26 
27  // ----------------------
28  // get hold of back-end interface
29  dbe_ = 0;
30  dbe_ = Service<DQMStore>().operator->();
31  if ( dbe_ ) {
32  if ( verbose_ ) {
33  dbe_->setVerbose(1);
34  } else {
35  dbe_->setVerbose(0);
36  }
37  }
38  if ( dbe_ ) {
39  if ( verbose_ ) dbe_->showDirStructure();
40  }
41 
42 
43  // ----------------------
44  meEBUncalibRecHitsOccupancy_ = 0;
45  meEBUncalibRecHitsAmplitude_ = 0;
46  meEBUncalibRecHitsPedestal_ = 0;
47  meEBUncalibRecHitsJitter_ = 0;
48  meEBUncalibRecHitsChi2_ = 0;
49  meEBUncalibRecHitMaxSampleRatio_ = 0;
50  meEBUncalibRecHitsOccupancyGt100adc_ = 0;
51  meEBUncalibRecHitsAmplitudeGt100adc_ = 0;
52  meEBUncalibRecHitsPedestalGt100adc_ = 0;
53  meEBUncalibRecHitsJitterGt100adc_ = 0;
54  meEBUncalibRecHitsChi2Gt100adc_ = 0;
55  meEBUncalibRecHitMaxSampleRatioGt100adc_ = 0;
56  meEBUncalibRecHitsAmpFullMap_ = 0;
57  meEBUncalibRecHitsPedFullMap_ = 0;
58  for (int i=0; i<36 ; i++)
59  {
60  meEBUncalibRecHitAmplMap_[i] = 0;
61  meEBUncalibRecHitPedMap_[i] = 0;
62  }
63 
64  // ----------------------
65  Char_t histo[200];
66 
67  if ( dbe_ )
68  {
69  dbe_->setCurrentFolder("EcalRecHitsV/EcalBarrelRecHitsTask");
70 
71  sprintf (histo, "EB Occupancy" );
72  meEBUncalibRecHitsOccupancy_ = dbe_->book2D(histo, histo, 170, -85., 85., 360, 0., 360.);
73 
74  sprintf (histo, "EB Amplitude" );
75  meEBUncalibRecHitsAmplitude_ = dbe_->book1D(histo, histo, 201, -20., 4000.);
76 
77  sprintf (histo, "EB Pedestal" );
78  meEBUncalibRecHitsPedestal_ = dbe_->book1D(histo, histo, 50, 190., 210.);
79 
80  sprintf (histo, "EB Jitter" );
81  meEBUncalibRecHitsJitter_ = dbe_->book1D(histo, histo, 100, 0., 100.);
82 
83  sprintf (histo, "EB Chi2" );
84  meEBUncalibRecHitsChi2_ = dbe_->book1D(histo, histo, 100, 18000., 22000.);
85 
86  sprintf (histo, "EB RecHit Max Sample Ratio");
87  meEBUncalibRecHitMaxSampleRatio_ = dbe_->book1D(histo, histo, 120, 0.90, 1.05);
88 
89  sprintf (histo, "EB Occupancy gt 100 adc counts" );
90  meEBUncalibRecHitsOccupancyGt100adc_ = dbe_->book2D(histo, histo, 170, -85., 85., 360, 0., 360.);
91 
92  sprintf (histo, "EB Amplitude gt 100 adc counts" );
93  meEBUncalibRecHitsAmplitudeGt100adc_ = dbe_->book1D(histo, histo, 200, 0., 4000.);
94 
95  sprintf (histo, "EB Pedestal gt 100 adc counts" );
96  meEBUncalibRecHitsPedestalGt100adc_ = dbe_->book1D(histo, histo, 50, 190., 210.);
97 
98  sprintf (histo, "EB Jitter gt 100 adc counts" );
99  meEBUncalibRecHitsJitterGt100adc_ = dbe_->book1D(histo, histo, 100, 0., 100.);
100 
101  sprintf (histo, "EB Chi2 gt 100 adc counts" );
102  meEBUncalibRecHitsChi2Gt100adc_ = dbe_->book1D(histo, histo, 100, 18000., 22000.);
103 
104  sprintf (histo, "EB RecHit Max Sample Ratio gt 100 adc counts");
105  meEBUncalibRecHitMaxSampleRatioGt100adc_ = dbe_->book1D(histo, histo, 120, 0.90, 1.05);
106 
107  sprintf (histo, "EB Amplitude Full Map");
108  meEBUncalibRecHitsAmpFullMap_ = dbe_->bookProfile2D(histo, histo, 170, -85., 85., 360, 0., 360., 200, 0., 4000.);
109 
110  sprintf (histo, "EB Pedestal Full Map");
111  meEBUncalibRecHitsPedFullMap_ = dbe_->bookProfile2D(histo, histo, 170, -85., 85., 360, 0., 360., 50, 194., 201.);
112 
113  for (int i=0; i<36 ; i++)
114  {
115  sprintf(histo, "EB Amp SM%02d", i+1);
116  meEBUncalibRecHitAmplMap_[i] = dbe_->bookProfile2D(histo, histo, 85, 0., 85., 20, 0., 20., 200, 0., 4000.);
117 
118  sprintf(histo, "EB Ped SM%02d", i+1);
119  meEBUncalibRecHitPedMap_[i] = dbe_->bookProfile2D(histo, histo, 85, 0., 85., 20, 0., 20., 50, 194., 201.);
120  }
121  }
122 }
123 
125 
126 }
127 
129 
130 }
131 
133 
134 }
135 
137 
138 
139  const EBUncalibratedRecHitCollection *EBUncalibRecHit = 0;
140  Handle< EBUncalibratedRecHitCollection > EcalUncalibRecHitEB;
141  e.getByLabel( EBuncalibrechitCollection_, EcalUncalibRecHitEB);
142  if (EcalUncalibRecHitEB.isValid()) {
143  EBUncalibRecHit = EcalUncalibRecHitEB.product();
144  } else {
145  return;
146  }
147 
148  bool skipDigis = false;
149  const EBDigiCollection *EBDigi = 0;
150  Handle< EBDigiCollection > EcalDigiEB;
151  e.getByLabel( EBdigiCollection_, EcalDigiEB);
152  if (EcalDigiEB.isValid()) {
153  EBDigi = EcalDigiEB.product();
154  } else {
155  skipDigis = true;
156  }
157 
159  c.get<EcalPedestalsRcd>().get(ecalPeds);
160 
161  // ----------------------
162  // loop over UncalibRecHits
163  for (EcalUncalibratedRecHitCollection::const_iterator uncalibRecHit = EBUncalibRecHit->begin(); uncalibRecHit != EBUncalibRecHit->end() ; ++uncalibRecHit)
164  {
165  EBDetId EBid = EBDetId(uncalibRecHit->id());
166 
167  // general checks
168  if (meEBUncalibRecHitsOccupancy_) meEBUncalibRecHitsOccupancy_ -> Fill(EBid.ieta(), EBid.iphi());
169  if (meEBUncalibRecHitsAmplitude_) meEBUncalibRecHitsAmplitude_ -> Fill(uncalibRecHit->amplitude());
170  if (meEBUncalibRecHitsPedestal_) meEBUncalibRecHitsPedestal_ -> Fill(uncalibRecHit->pedestal());
171  if (meEBUncalibRecHitsJitter_) meEBUncalibRecHitsJitter_ -> Fill(uncalibRecHit->jitter());
172  if (meEBUncalibRecHitsChi2_) meEBUncalibRecHitsChi2_ -> Fill(uncalibRecHit->chi2());
173  if (meEBUncalibRecHitsAmpFullMap_) meEBUncalibRecHitsAmpFullMap_ -> Fill(EBid.ieta(), EBid.iphi(), uncalibRecHit->amplitude());
174  if (meEBUncalibRecHitsPedFullMap_) meEBUncalibRecHitsPedFullMap_ -> Fill(EBid.ieta(), EBid.iphi(), uncalibRecHit->pedestal());
175 
176  // general checks, with threshold at 3.5 GeV = 100 ADC counts
177  if ( uncalibRecHit->amplitude() > 100 )
178  {
179  if (meEBUncalibRecHitsOccupancyGt100adc_) meEBUncalibRecHitsOccupancyGt100adc_ -> Fill(EBid.ieta(), EBid.iphi());
180  if (meEBUncalibRecHitsAmplitudeGt100adc_) meEBUncalibRecHitsAmplitudeGt100adc_ -> Fill(uncalibRecHit->amplitude());
181  if (meEBUncalibRecHitsPedestalGt100adc_) meEBUncalibRecHitsPedestalGt100adc_ -> Fill(uncalibRecHit->pedestal());
182  if (meEBUncalibRecHitsJitterGt100adc_) meEBUncalibRecHitsJitterGt100adc_ -> Fill(uncalibRecHit->jitter());
183  if (meEBUncalibRecHitsChi2Gt100adc_) meEBUncalibRecHitsChi2Gt100adc_ -> Fill(uncalibRecHit->chi2());
184  }
185 
186  // supermodule maps
187  int ic = EBid.ic();
188  int ie = (ic-1)/20 + 1;
189  int ip = (ic-1)%20 + 1;
190  int ism = EBid.ism();
191  float xie = ie - 0.5;
192  float xip = ip - 0.5;
193  if( meEBUncalibRecHitPedMap_[ism-1] ) meEBUncalibRecHitPedMap_[ism-1]->Fill(xie, xip, uncalibRecHit->pedestal());
194  if( meEBUncalibRecHitAmplMap_[ism-1] ) meEBUncalibRecHitAmplMap_[ism-1]->Fill(xie, xip, uncalibRecHit->amplitude());
195 
196  if ( ! skipDigis ) {
197  // find the rechit corresponding digi and the max sample
198  EBDigiCollection::const_iterator myDigi = EBDigi->find(EBid);
199  int sMax = -1;
200  double eMax = 0.;
201  if (myDigi != EBDigi->end()){
202  for (unsigned int sample = 0 ; sample < myDigi->size(); ++sample){
203  EcalMGPASample thisSample = (*myDigi)[sample];
204  double analogSample = thisSample.adc();
205  if ( eMax < analogSample ){
206  eMax = analogSample;
207  sMax = sample;
208  }
209  }
210  }
211  else
212  continue;
213 
214  // ratio uncalibratedRecHit amplitude + ped / max energy digi
215  const EcalPedestals* myped = ecalPeds.product();
216  EcalPedestalsMap::const_iterator it=myped->getMap().find( EBid );
217  if( it != myped->getMap().end() ){
218 
219  if (eMax > (*it).mean_x1 + 5 * (*it).rms_x1 && eMax != 0 ) {//only real signal RecHit
220 
221  if ( meEBUncalibRecHitMaxSampleRatio_ ) meEBUncalibRecHitMaxSampleRatio_->Fill( (uncalibRecHit->amplitude()+uncalibRecHit->pedestal())/eMax);
222  if ( meEBUncalibRecHitMaxSampleRatioGt100adc_ && (uncalibRecHit->amplitude()>100) ) meEBUncalibRecHitMaxSampleRatioGt100adc_->Fill( (uncalibRecHit->amplitude()+uncalibRecHit->pedestal())/eMax);
223  LogDebug("EcalRecHitsTaskInfo") << "barrel, eMax = " << eMax << " Amplitude = " << uncalibRecHit->amplitude()+uncalibRecHit->pedestal();
224  }
225  else
226  continue;
227  }
228  else
229  continue;
230  }
231 
232  } // loop over the UncalibratedRecHitCollection
233 }
#define LogDebug(id)
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
boost::transform_iterator< IterHelp, boost::counting_iterator< int > > const_iterator
EcalBarrelRecHitsValidation(const edm::ParameterSet &ps)
Constructor.
const self & getMap() const
std::vector< T >::const_iterator const_iterator
tuple histo
Definition: trackerHits.py:12
int ism() const
get the ECAL/SM id
Definition: EBDetId.cc:79
int iphi() const
get the crystal iphi
Definition: EBDetId.h:46
void analyze(const edm::Event &e, const edm::EventSetup &c)
Analyze.
const_iterator find(id_type i) const
int ieta() const
get the crystal ieta
Definition: EBDetId.h:44
bool isValid() const
Definition: HandleBase.h:76
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:359
int ic() const
get ECAL/crystal number inside SM
Definition: EBDetId.cc:94
DQMStore * dbe_
const_iterator end() const
const T & get() const
Definition: EventSetup.h:55
std::vector< Item >::const_iterator const_iterator
T const * product() const
Definition: ESHandle.h:62
T const * product() const
Definition: Handle.h:74
const_iterator end() const
const_iterator find(uint32_t rawId) const
const_iterator end() const
int ism(int ieta, int iphi)
Definition: EcalPyUtils.cc:47
const_iterator begin() const
int adc() const
get the ADC sample (12 bits)