Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-06-18 23:26:40

0001 #include "CondCore/Utilities/interface/PayloadInspector.h"
0002 #include "DataFormats/EcalDetId/interface/EBDetId.h"
0003 #include "DataFormats/EcalDetId/interface/EEDetId.h"
0004 #include "CondFormats/EcalObjects/interface/EcalCondObjectContainer.h"
0005 
0006 #include "TH2F.h"
0007 #include <string>
0008 
0009 enum { kEBChannels = 61200, kEEChannels = 14648 };
0010 enum {
0011   MIN_IETA = 1,
0012   MIN_IPHI = 1,
0013   MAX_IETA = 85,
0014   MAX_IPHI = 360,
0015   EBhistEtaMax = 171
0016 };  // barrel lower and upper bounds on eta and phi
0017 enum {
0018   IX_MIN = 1,
0019   IY_MIN = 1,
0020   IX_MAX = 100,
0021   IY_MAX = 100,
0022   EEhistXMax = 220
0023 };  // endcaps lower and upper bounds on x and y
0024 
0025 template <class floatCondObj>
0026 void fillEBMap_SingleIOV(std::shared_ptr<floatCondObj> payload, TH2F*& barrel) {
0027   for (int cellid = EBDetId::MIN_HASH; cellid < EBDetId::kSizeForDenseIndexing; ++cellid) {
0028     uint32_t rawid = EBDetId::unhashIndex(cellid);
0029     EcalCondObjectContainer<float>::const_iterator value_ptr = payload->find(rawid);
0030     if (value_ptr == payload->end())
0031       continue;  // cell absent from payload
0032 
0033     float weight = (float)(*value_ptr);
0034     Double_t phi = (Double_t)(EBDetId(rawid)).iphi() - 0.5;
0035     Double_t eta = (Double_t)(EBDetId(rawid)).ieta();
0036 
0037     if (eta > 0.)
0038       eta = eta - 0.5;  //   0.5 to 84.5
0039     else
0040       eta = eta + 0.5;  //  -84.5 to -0.5
0041 
0042     barrel->Fill(phi, eta, weight);
0043   }  // loop over cellid
0044 }
0045 
0046 template <class floatCondObj>
0047 void fillEEMap_SingleIOV(std::shared_ptr<floatCondObj> payload, TH2F*& endc_m, TH2F*& endc_p) {
0048   // looping over the EE channels
0049   for (int iz = -1; iz < 2; iz = iz + 2)  // -1 or +1
0050     for (int iy = IY_MIN; iy < IY_MAX + IY_MIN; iy++)
0051       for (int ix = IX_MIN; ix < IX_MAX + IX_MIN; ix++)
0052         if (EEDetId::validDetId(ix, iy, iz)) {
0053           EEDetId myEEId = EEDetId(ix, iy, iz, EEDetId::XYMODE);
0054           uint32_t rawid = myEEId.rawId();
0055           EcalCondObjectContainer<float>::const_iterator value_ptr = payload->find(rawid);
0056           if (value_ptr == payload->end())
0057             continue;  // cell absent from payload
0058 
0059           float weight = (float)(*value_ptr);
0060           if (iz == 1)
0061             endc_p->Fill(ix, iy, weight);
0062           else
0063             endc_m->Fill(ix, iy, weight);
0064 
0065         }  // validDetId
0066 }
0067 
0068 template <class floatCondObj>
0069 void fillEBMap_TwoIOVs(std::shared_ptr<floatCondObj> payload,
0070                        TH2F*& barrel,
0071                        int irun,
0072                        float pEB[],
0073                        float& pEBmin,
0074                        float& pEBmax,
0075                        int method) {
0076   for (int cellid = EBDetId::MIN_HASH; cellid < EBDetId::kSizeForDenseIndexing; ++cellid) {
0077     uint32_t rawid = EBDetId::unhashIndex(cellid);
0078     EcalCondObjectContainer<float>::const_iterator value_ptr = payload->find(rawid);
0079     if (value_ptr == payload->end())
0080       continue;  // cell absent from payload
0081 
0082     float weight = (float)(*value_ptr);
0083     if (irun == 0)
0084       pEB[cellid] = weight;
0085     else {
0086       Double_t phi = (Double_t)(EBDetId(rawid)).iphi() - 0.5;
0087       Double_t eta = (Double_t)(EBDetId(rawid)).ieta();
0088 
0089       if (eta > 0.)
0090         eta = eta - 0.5;  //   0.5 to 84.5
0091       else
0092         eta = eta + 0.5;  //  -84.5 to -0.5
0093       double dr;
0094       if (method == 0) {
0095         dr = weight - pEB[cellid];
0096       }  // diff
0097       else {
0098         if (pEB[cellid] != 0.)
0099           dr = weight / pEB[cellid];
0100         else {
0101           if (weight == 0.)
0102             dr = 1.;
0103           else
0104             dr = 9999.;  // use a large value
0105         }
0106       }  // ratio
0107       if (dr < pEBmin)
0108         pEBmin = dr;
0109       if (dr > pEBmax)
0110         pEBmax = dr;
0111       barrel->Fill(phi, eta, dr);
0112     }
0113   }  // loop over cellid
0114 }
0115 
0116 template <class floatCondObj>
0117 void fillEEMap_TwoIOVs(std::shared_ptr<floatCondObj> payload,
0118                        TH2F*& endc_m,
0119                        TH2F*& endc_p,
0120                        int irun,
0121                        float pEE[],
0122                        float& pEEmin,
0123                        float& pEEmax,
0124                        int method) {
0125   // looping over the EE channels
0126   for (int iz = -1; iz < 2; iz = iz + 2)  // -1 or +1
0127     for (int iy = IY_MIN; iy < IY_MAX + IY_MIN; iy++)
0128       for (int ix = IX_MIN; ix < IX_MAX + IX_MIN; ix++)
0129         if (EEDetId::validDetId(ix, iy, iz)) {
0130           EEDetId myEEId = EEDetId(ix, iy, iz, EEDetId::XYMODE);
0131           uint32_t cellid = myEEId.hashedIndex();
0132           uint32_t rawid = myEEId.rawId();
0133           EcalCondObjectContainer<float>::const_iterator value_ptr = payload->find(rawid);
0134 
0135           if (value_ptr == payload->end())
0136             continue;  // cell absent from payload
0137           float weight = (float)(*value_ptr);
0138 
0139           if (irun == 0)
0140             pEE[cellid] = weight;
0141           else {
0142             double dr;
0143             if (method == 0) {
0144               dr = weight - pEE[cellid];
0145             }  // diff
0146             else {
0147               if (pEE[cellid] != 0.)
0148                 dr = weight / pEE[cellid];
0149               else {
0150                 if (weight == 0.)
0151                   dr = 1.;
0152                 else
0153                   dr = 9999.;  // use a large value
0154               }
0155             }  // ratio
0156             if (dr < pEEmin)
0157               pEEmin = dr;
0158             if (dr > pEEmax)
0159               pEEmax = dr;
0160             if (iz == 1)
0161               endc_p->Fill(ix, iy, dr);
0162             else
0163               endc_m->Fill(ix, iy, dr);
0164           }
0165 
0166         }  // validDetId
0167 }
0168 
0169 inline void fillTableWithSummary(TH2F*& align,
0170                                  std::string title,
0171                                  const float& mean_x_EB,
0172                                  const float& rms_EB,
0173                                  const int& num_x_EB,
0174                                  const float& mean_x_EE,
0175                                  const float& rms_EE,
0176                                  const int& num_x_EE) {
0177   int NbRows = 2;
0178   align = new TH2F(title.c_str(), "EB/EE      mean_x      rms        num_x", 4, 0, 4, NbRows, 0, NbRows);
0179 
0180   double row = NbRows - 0.5;
0181 
0182   align->Fill(0.5, row, 1);
0183   align->Fill(1.5, row, mean_x_EB);
0184   align->Fill(2.5, row, rms_EB);
0185   align->Fill(3.5, row, num_x_EB);
0186 
0187   row--;
0188 
0189   align->Fill(0.5, row, 2);
0190   align->Fill(1.5, row, mean_x_EE);
0191   align->Fill(2.5, row, rms_EE);
0192   align->Fill(3.5, row, num_x_EE);
0193 
0194   align->GetXaxis()->SetTickLength(0.);
0195   align->GetXaxis()->SetLabelSize(0.);
0196   align->GetYaxis()->SetTickLength(0.);
0197   align->GetYaxis()->SetLabelSize(0.);
0198 }