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