Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 11:57:32

0001 #ifndef CalibCalorimetry_CaloMiscalibTools_CaloMiscalibMapEcal_h
0002 #define CalibCalorimetry_CaloMiscalibTools_CaloMiscalibMapEcal_h
0003 #include "CondFormats/EcalObjects/interface/EcalIntercalibConstants.h"
0004 #include "CalibCalorimetry/CaloMiscalibTools/interface/CaloMiscalibMap.h"
0005 #include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h"
0006 #include "Geometry/Records/interface/IdealGeometryRecord.h"
0007 #include "Geometry/CaloGeometry/interface/CaloGeometry.h"
0008 #include "DataFormats/EcalDetId/interface/EBDetId.h"
0009 #include "DataFormats/EcalDetId/interface/EEDetId.h"
0010 #include <iostream>
0011 #include <iomanip>
0012 #include <map>
0013 #include <vector>
0014 
0015 class CaloMiscalibMapEcal : public CaloMiscalibMap {
0016 public:
0017   CaloMiscalibMapEcal() {}
0018 
0019   void prefillMap() {
0020     for (int iEta = -EBDetId::MAX_IETA; iEta <= EBDetId::MAX_IETA; ++iEta) {
0021       if (iEta == 0)
0022         continue;
0023       for (int iPhi = EBDetId::MIN_IPHI; iPhi <= EBDetId::MAX_IPHI; ++iPhi) {
0024         EBDetId ebdetid(iEta, iPhi);
0025         map_.setValue(ebdetid.rawId(), 1.0);
0026       }
0027     }
0028 
0029     for (int iX = EEDetId::IX_MIN; iX <= EEDetId::IX_MAX; ++iX) {
0030       for (int iY = EEDetId::IY_MIN; iY <= EEDetId::IY_MAX; ++iY) {
0031         EEDetId eedetidpos(iX, iY, 1);
0032         map_.setValue(eedetidpos.rawId(), 1.0);
0033         EEDetId eedetidneg(iX, iY, -1);
0034         map_.setValue(eedetidneg.rawId(), 1.0);
0035       }
0036     }
0037   }
0038 
0039   void addCell(const DetId &cell, float scaling_factor) override { map_.setValue(cell.rawId(), scaling_factor); }
0040 
0041   void print() {
0042     int icount = 0;
0043     for (int iEta = -EBDetId::MAX_IETA; iEta <= EBDetId::MAX_IETA; ++iEta) {
0044       if (iEta == 0)
0045         continue;
0046       for (int iPhi = EBDetId::MIN_IPHI; iPhi <= EBDetId::MAX_IPHI; ++iPhi) {
0047         if (EBDetId::validDetId(iEta, iPhi)) {
0048           EBDetId ebdetid(iEta, iPhi);
0049           EcalIntercalibConstantMap::const_iterator icalit = map_.find(ebdetid.rawId());
0050           EcalIntercalibConstant icalconst;
0051           icalconst = (*icalit);
0052 
0053           icount++;
0054           if (icount % 230 == 0) {
0055             std::cout << "here is value for chan eta/phi " << iEta << "/" << iPhi << "=" << icalconst << std::endl;
0056           }
0057         }
0058       }
0059     }
0060     for (int iX = EEDetId::IX_MIN; iX <= EEDetId::IX_MAX; ++iX) {
0061       for (int iY = EEDetId::IY_MIN; iY <= EEDetId::IY_MAX; ++iY) {
0062         if (EEDetId::validDetId(iX, iY, 1)) {
0063           EEDetId eedetidpos(iX, iY, 1);
0064           EcalIntercalibConstantMap::const_iterator icalit = map_.find(eedetidpos.rawId());
0065           EcalIntercalibConstant icalconst;
0066           icalconst = (*icalit);
0067 
0068           EEDetId eedetidneg(iX, iY, -1);
0069           EcalIntercalibConstantMap::const_iterator icalit2 = map_.find(eedetidneg.rawId());
0070           EcalIntercalibConstant icalconst2;
0071           icalconst2 = (*icalit2);
0072 
0073           icount++;
0074           if (icount % 230 == 0) {
0075             std::cout << "here is value for chan x/y " << iX << "/" << iY << " pos side is =" << icalconst
0076                       << " and neg side is= " << icalconst2 << std::endl;
0077           }
0078         }
0079       }
0080     }
0081   }
0082 
0083   const EcalIntercalibConstants &get() { return map_; }
0084 
0085 private:
0086   EcalIntercalibConstants map_;
0087   const CaloSubdetectorGeometry *geometry;
0088 };
0089 
0090 #endif