Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-07-30 02:33:37

0001 /*
0002  * \file EcalEndcapRecHitsValidation.cc
0003  *
0004  * \author C. Rovelli
0005  *
0006  */
0007 
0008 #include "DQMServices/Core/interface/DQMStore.h"
0009 #include <DataFormats/EcalDetId/interface/EEDetId.h>
0010 #include <Validation/EcalRecHits/interface/EcalEndcapRecHitsValidation.h>
0011 
0012 using namespace cms;
0013 using namespace edm;
0014 using namespace std;
0015 
0016 EcalEndcapRecHitsValidation::EcalEndcapRecHitsValidation(const ParameterSet &ps) : ecalPeds(esConsumes()) {
0017   // ----------------------
0018   EEdigiCollection_token_ = consumes<EEDigiCollection>(ps.getParameter<edm::InputTag>("EEdigiCollection"));
0019   EEuncalibrechitCollection_token_ =
0020       consumes<EEUncalibratedRecHitCollection>(ps.getParameter<edm::InputTag>("EEuncalibrechitCollection"));
0021 
0022   // ----------------------
0023   // verbosity switch
0024   verbose_ = ps.getUntrackedParameter<bool>("verbose", false);
0025 
0026   // ----------------------
0027   meEEUncalibRecHitsOccupancyPlus_ = nullptr;
0028   meEEUncalibRecHitsOccupancyMinus_ = nullptr;
0029   meEEUncalibRecHitsAmplitude_ = nullptr;
0030   meEEUncalibRecHitsPedestal_ = nullptr;
0031   meEEUncalibRecHitsJitter_ = nullptr;
0032   meEEUncalibRecHitsChi2_ = nullptr;
0033   meEEUncalibRecHitMaxSampleRatio_ = nullptr;
0034   meEEUncalibRecHitsOccupancyPlusGt60adc_ = nullptr;
0035   meEEUncalibRecHitsOccupancyMinusGt60adc_ = nullptr;
0036   meEEUncalibRecHitsAmplitudeGt60adc_ = nullptr;
0037   meEEUncalibRecHitsPedestalGt60adc_ = nullptr;
0038   meEEUncalibRecHitsJitterGt60adc_ = nullptr;
0039   meEEUncalibRecHitsChi2Gt60adc_ = nullptr;
0040   meEEUncalibRecHitMaxSampleRatioGt60adc_ = nullptr;
0041   meEEUncalibRecHitsAmpFullMap_ = nullptr;
0042   meEEUncalibRecHitsPedFullMap_ = nullptr;
0043 }
0044 
0045 EcalEndcapRecHitsValidation::~EcalEndcapRecHitsValidation() {}
0046 
0047 void EcalEndcapRecHitsValidation::bookHistograms(DQMStore::IBooker &ibooker,
0048                                                  edm::Run const &,
0049                                                  edm::EventSetup const &) {
0050   Char_t histo[200];
0051 
0052   ibooker.setCurrentFolder("EcalRecHitsV/EcalEndcapRecHitsTask");
0053 
0054   sprintf(histo, "EE+ Occupancy");
0055   meEEUncalibRecHitsOccupancyPlus_ = ibooker.book2D(histo, histo, 100, 0., 100., 100, 0., 100.);
0056 
0057   sprintf(histo, "EE- Occupancy");
0058   meEEUncalibRecHitsOccupancyMinus_ = ibooker.book2D(histo, histo, 100, 0., 100., 100, 0., 100.);
0059 
0060   sprintf(histo, "EE Amplitude");
0061   meEEUncalibRecHitsAmplitude_ = ibooker.book1D(histo, histo, 201, -20., 4000.);
0062 
0063   sprintf(histo, "EE Pedestal");
0064   meEEUncalibRecHitsPedestal_ = ibooker.book1D(histo, histo, 50, 190., 210.);
0065 
0066   sprintf(histo, "EE Jitter");
0067   meEEUncalibRecHitsJitter_ = ibooker.book1D(histo, histo, 100, 0., 100.);
0068 
0069   sprintf(histo, "EE Chi2");
0070   meEEUncalibRecHitsChi2_ = ibooker.book1D(histo, histo, 100, 18000., 22000.);
0071 
0072   sprintf(histo, "EE RecHit Max Sample Ratio");
0073   meEEUncalibRecHitMaxSampleRatio_ = ibooker.book1D(histo, histo, 120, 0.90, 1.05);
0074 
0075   sprintf(histo, "EE+ Occupancy gt 60 adc counts");
0076   meEEUncalibRecHitsOccupancyPlusGt60adc_ = ibooker.book2D(histo, histo, 100, 0., 100., 100, 0., 100.);
0077 
0078   sprintf(histo, "EE- Occupancy gt 60 adc counts");
0079   meEEUncalibRecHitsOccupancyMinusGt60adc_ = ibooker.book2D(histo, histo, 100, 0., 100., 100, 0., 100.);
0080 
0081   sprintf(histo, "EE Amplitude gt 60 adc counts");
0082   meEEUncalibRecHitsAmplitudeGt60adc_ = ibooker.book1D(histo, histo, 200, 0., 4000.);
0083 
0084   sprintf(histo, "EE Pedestal gt 60 adc counts");
0085   meEEUncalibRecHitsPedestalGt60adc_ = ibooker.book1D(histo, histo, 50, 190., 210.);
0086 
0087   sprintf(histo, "EE Jitter gt 60 adc counts");
0088   meEEUncalibRecHitsJitterGt60adc_ = ibooker.book1D(histo, histo, 100, 0., 100.);
0089 
0090   sprintf(histo, "EE Chi2 gt 60 adc counts");
0091   meEEUncalibRecHitsChi2Gt60adc_ = ibooker.book1D(histo, histo, 100, 18000., 22000.);
0092 
0093   sprintf(histo, "EE RecHit Max Sample Ratio gt 60 adc counts");
0094   meEEUncalibRecHitMaxSampleRatioGt60adc_ = ibooker.book1D(histo, histo, 120, 0.90, 1.05);
0095 
0096   sprintf(histo, "EE Amplitude Full Map");
0097   meEEUncalibRecHitsAmpFullMap_ = ibooker.bookProfile2D(histo, histo, 100, 0., 100., 100, 0., 100., 200, 0., 4000.);
0098 
0099   sprintf(histo, "EE Pedestal Full Map");
0100   meEEUncalibRecHitsPedFullMap_ = ibooker.bookProfile2D(histo, histo, 100, 0., 100., 100, 0., 100., 50, 194., 201.);
0101 }
0102 
0103 void EcalEndcapRecHitsValidation::analyze(const Event &e, const EventSetup &c) {
0104   const EEUncalibratedRecHitCollection *EEUncalibRecHit = nullptr;
0105   Handle<EEUncalibratedRecHitCollection> EcalUncalibRecHitEE;
0106   e.getByToken(EEuncalibrechitCollection_token_, EcalUncalibRecHitEE);
0107   if (EcalUncalibRecHitEE.isValid()) {
0108     EEUncalibRecHit = EcalUncalibRecHitEE.product();
0109   } else {
0110     return;
0111   }
0112 
0113   bool skipDigis = false;
0114   const EEDigiCollection *EEDigi = nullptr;
0115   Handle<EEDigiCollection> EcalDigiEE;
0116   e.getByToken(EEdigiCollection_token_, EcalDigiEE);
0117   if (EcalDigiEE.isValid()) {
0118     EEDigi = EcalDigiEE.product();
0119   } else {
0120     skipDigis = true;
0121   }
0122 
0123   // ----------------------
0124   // loop over UncalibRecHits
0125   for (EcalUncalibratedRecHitCollection::const_iterator uncalibRecHit = EEUncalibRecHit->begin();
0126        uncalibRecHit != EEUncalibRecHit->end();
0127        ++uncalibRecHit) {
0128     EEDetId EEid = EEDetId(uncalibRecHit->id());
0129 
0130     int mySide = EEid.zside();
0131 
0132     // general checks
0133     if (mySide > 0) {
0134       if (meEEUncalibRecHitsOccupancyPlus_)
0135         meEEUncalibRecHitsOccupancyPlus_->Fill(EEid.ix(), EEid.iy());
0136     }
0137     if (mySide < 0) {
0138       if (meEEUncalibRecHitsOccupancyMinus_)
0139         meEEUncalibRecHitsOccupancyMinus_->Fill(EEid.ix(), EEid.iy());
0140     }
0141     if (meEEUncalibRecHitsAmplitude_)
0142       meEEUncalibRecHitsAmplitude_->Fill(uncalibRecHit->amplitude());
0143     if (meEEUncalibRecHitsPedestal_)
0144       meEEUncalibRecHitsPedestal_->Fill(uncalibRecHit->pedestal());
0145     if (meEEUncalibRecHitsJitter_)
0146       meEEUncalibRecHitsJitter_->Fill(uncalibRecHit->jitter());
0147     if (meEEUncalibRecHitsChi2_)
0148       meEEUncalibRecHitsChi2_->Fill(uncalibRecHit->chi2());
0149     if (meEEUncalibRecHitsAmpFullMap_)
0150       meEEUncalibRecHitsAmpFullMap_->Fill(EEid.ix(), EEid.iy(), uncalibRecHit->amplitude());
0151     if (meEEUncalibRecHitsPedFullMap_)
0152       meEEUncalibRecHitsPedFullMap_->Fill(EEid.ix(), EEid.iy(), uncalibRecHit->pedestal());
0153 
0154     // general checks, with threshold at 60 ADC counts
0155     if (uncalibRecHit->amplitude() > 60) {
0156       if (mySide > 0) {
0157         if (meEEUncalibRecHitsOccupancyPlusGt60adc_)
0158           meEEUncalibRecHitsOccupancyPlusGt60adc_->Fill(EEid.ix(), EEid.iy());
0159       }
0160       if (mySide < 0) {
0161         if (meEEUncalibRecHitsOccupancyMinusGt60adc_)
0162           meEEUncalibRecHitsOccupancyMinusGt60adc_->Fill(EEid.ix(), EEid.iy());
0163       }
0164       if (meEEUncalibRecHitsAmplitudeGt60adc_)
0165         meEEUncalibRecHitsAmplitudeGt60adc_->Fill(uncalibRecHit->amplitude());
0166       if (meEEUncalibRecHitsPedestalGt60adc_)
0167         meEEUncalibRecHitsPedestalGt60adc_->Fill(uncalibRecHit->pedestal());
0168       if (meEEUncalibRecHitsJitterGt60adc_)
0169         meEEUncalibRecHitsJitterGt60adc_->Fill(uncalibRecHit->jitter());
0170       if (meEEUncalibRecHitsChi2Gt60adc_)
0171         meEEUncalibRecHitsChi2Gt60adc_->Fill(uncalibRecHit->chi2());
0172     }
0173 
0174     if (!skipDigis) {
0175       // Find the rechit corresponding digi
0176       EEDigiCollection::const_iterator myDigi = EEDigi->find(EEid);
0177       // int sMax    = -1; // UNUSED
0178       double eMax = 0.;
0179       if (myDigi != EEDigi->end()) {
0180         for (unsigned int sample = 0; sample < myDigi->size(); ++sample) {
0181           EcalMGPASample thisSample = (*myDigi)[sample];
0182           double analogSample = thisSample.adc();
0183           if (eMax < analogSample) {
0184             eMax = analogSample;
0185             // sMax = sample; // UNUSED
0186           }
0187         }
0188       } else
0189         continue;
0190 
0191       // ratio uncalibratedRecHit amplitude + ped / max energy digi
0192       const EcalPedestals *myped = &c.getData(ecalPeds);
0193       EcalPedestalsMap::const_iterator it = myped->getMap().find(EEid);
0194       if (it != myped->getMap().end()) {
0195         if (eMax > (*it).mean_x1 + 5 * (*it).rms_x1 && eMax != 0) {  // only real signal RecHit
0196 
0197           if (meEEUncalibRecHitMaxSampleRatio_) {
0198             meEEUncalibRecHitMaxSampleRatio_->Fill((uncalibRecHit->amplitude() + uncalibRecHit->pedestal()) / eMax);
0199           }
0200 
0201           if (meEEUncalibRecHitMaxSampleRatioGt60adc_ && (uncalibRecHit->amplitude() > 60)) {
0202             meEEUncalibRecHitMaxSampleRatioGt60adc_->Fill((uncalibRecHit->amplitude() + uncalibRecHit->pedestal()) /
0203                                                           eMax);
0204           }
0205 
0206           LogDebug("EcalRecHitsTaskInfo")
0207               << "endcap, eMax = " << eMax << " Amplitude = " << uncalibRecHit->amplitude() + uncalibRecHit->pedestal();
0208         } else
0209           continue;
0210       } else
0211         continue;
0212     }
0213   }  // loop over the UncalibratedRecHitCollection
0214 }