Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-06-30 04:13:40

0001 #include "DQMOffline/JetMET/interface/ECALRecHitAnalyzer.h"
0002 #include "DQMServices/Core/interface/DQMStore.h"
0003 #include "Geometry/Records/interface/CaloGeometryRecord.h"
0004 
0005 // author: Bobby Scurlock, University of Florida
0006 // first version 11/20/2006
0007 
0008 #define DEBUG(X)                   \
0009   {                                \
0010     if (debug_) {                  \
0011       std::cout << X << std::endl; \
0012     }                              \
0013   }
0014 
0015 ECALRecHitAnalyzer::ECALRecHitAnalyzer(const edm::ParameterSet& iConfig) {
0016   // Retrieve Information from the Configuration File
0017   EBRecHitsLabel_ = consumes<EBRecHitCollection>(iConfig.getParameter<edm::InputTag>("EBRecHitsLabel"));
0018   EERecHitsLabel_ = consumes<EERecHitCollection>(iConfig.getParameter<edm::InputTag>("EERecHitsLabel"));
0019   caloGeomToken_ = esConsumes<edm::Transition::BeginRun>();
0020   FolderName_ = iConfig.getUntrackedParameter<std::string>("FolderName");
0021   debug_ = iConfig.getParameter<bool>("Debug");
0022   //  EBRecHitsLabel_= consumes<EcalRecHitCollection>(edm::InputTag(EBRecHitsLabel_));
0023   //  EERecHitsLabel_= consumes<EcalRecHitCollection>(edm::InputTag(EERecHitsLabel_));
0024 }
0025 
0026 void ECALRecHitAnalyzer::dqmbeginRun(const edm::Run& iRun, const edm::EventSetup& iSetup) {
0027   CurrentEvent = -1;
0028   caloGeom_ = &iSetup.getData(caloGeomToken_);
0029   // Fill the geometry histograms
0030   FillGeometry(iSetup);
0031 }
0032 
0033 void ECALRecHitAnalyzer::bookHistograms(DQMStore::IBooker& ibooker, edm::Run const& iRun, edm::EventSetup const&) {
0034   // get ahold of back-end interface
0035   // Book Geometry Histograms
0036   ibooker.setCurrentFolder(FolderName_ + "/geometry");
0037 
0038   // ECAL barrel
0039   hEB_ieta_iphi_etaMap = ibooker.book2D("hEB_ieta_iphi_etaMap", "", 171, -85, 86, 360, 1, 361);
0040   hEB_ieta_iphi_phiMap = ibooker.book2D("hEB_ieta_iphi_phiMap", "", 171, -85, 86, 360, 1, 361);
0041   hEB_ieta_detaMap = ibooker.book1D("hEB_ieta_detaMap", "", 171, -85, 86);
0042   hEB_ieta_dphiMap = ibooker.book1D("hEB_ieta_dphiMap", "", 171, -85, 86);
0043   // ECAL +endcap
0044   hEEpZ_ix_iy_irMap = ibooker.book2D("hEEpZ_ix_iy_irMap", "", 100, 1, 101, 100, 1, 101);
0045   hEEpZ_ix_iy_xMap = ibooker.book2D("hEEpZ_ix_iy_xMap", "", 100, 1, 101, 100, 1, 101);
0046   hEEpZ_ix_iy_yMap = ibooker.book2D("hEEpZ_ix_iy_yMap", "", 100, 1, 101, 100, 1, 101);
0047   hEEpZ_ix_iy_zMap = ibooker.book2D("hEEpZ_ix_iy_zMap", "", 100, 1, 101, 100, 1, 101);
0048   hEEpZ_ix_iy_dxMap = ibooker.book2D("hEEpZ_ix_iy_dxMap", "", 100, 1, 101, 100, 1, 101);
0049   hEEpZ_ix_iy_dyMap = ibooker.book2D("hEEpZ_ix_iy_dyMap", "", 100, 1, 101, 100, 1, 101);
0050   // ECAL -endcap
0051   hEEmZ_ix_iy_irMap = ibooker.book2D("hEEmZ_ix_iy_irMap", "", 100, 1, 101, 100, 1, 101);
0052   hEEmZ_ix_iy_xMap = ibooker.book2D("hEEmZ_ix_iy_xMap", "", 100, 1, 101, 100, 1, 101);
0053   hEEmZ_ix_iy_yMap = ibooker.book2D("hEEmZ_ix_iy_yMap", "", 100, 1, 101, 100, 1, 101);
0054   hEEmZ_ix_iy_zMap = ibooker.book2D("hEEmZ_ix_iy_zMap", "", 100, 1, 101, 100, 1, 101);
0055   hEEmZ_ix_iy_dxMap = ibooker.book2D("hEEmZ_ix_iy_dxMap", "", 100, 1, 101, 100, 1, 101);
0056   hEEmZ_ix_iy_dyMap = ibooker.book2D("hEEmZ_ix_iy_dyMap", "", 100, 1, 101, 100, 1, 101);
0057 
0058   // Initialize bins for geometry to -999 because z = 0 is a valid entry
0059   for (int i = 1; i <= 100; i++)
0060     for (int j = 1; j <= 100; j++) {
0061       hEEpZ_ix_iy_irMap->setBinContent(i, j, -999);
0062       hEEpZ_ix_iy_xMap->setBinContent(i, j, -999);
0063       hEEpZ_ix_iy_yMap->setBinContent(i, j, -999);
0064       hEEpZ_ix_iy_zMap->setBinContent(i, j, -999);
0065       hEEpZ_ix_iy_dxMap->setBinContent(i, j, -999);
0066       hEEpZ_ix_iy_dyMap->setBinContent(i, j, -999);
0067 
0068       hEEmZ_ix_iy_irMap->setBinContent(i, j, -999);
0069       hEEmZ_ix_iy_xMap->setBinContent(i, j, -999);
0070       hEEmZ_ix_iy_yMap->setBinContent(i, j, -999);
0071       hEEmZ_ix_iy_zMap->setBinContent(i, j, -999);
0072       hEEmZ_ix_iy_dxMap->setBinContent(i, j, -999);
0073       hEEmZ_ix_iy_dyMap->setBinContent(i, j, -999);
0074     }
0075 
0076   for (int i = 1; i <= 171; i++) {
0077     hEB_ieta_detaMap->setBinContent(i, -999);
0078     hEB_ieta_dphiMap->setBinContent(i, -999);
0079     for (int j = 1; j <= 360; j++) {
0080       hEB_ieta_iphi_etaMap->setBinContent(i, j, -999);
0081       hEB_ieta_iphi_phiMap->setBinContent(i, j, -999);
0082     }
0083   }
0084 
0085   // Book Data Histograms
0086   ibooker.setCurrentFolder(FolderName_);
0087 
0088   hECAL_Nevents = ibooker.book1D("hECAL_Nevents", "", 1, 0, 1);
0089 
0090   // Energy Histograms by logical index
0091   hEEpZ_energy_ix_iy = ibooker.book2D("hEEpZ_energy_ix_iy", "", 100, 1, 101, 100, 1, 101);
0092   hEEmZ_energy_ix_iy = ibooker.book2D("hEEmZ_energy_ix_iy", "", 100, 1, 101, 100, 1, 101);
0093   hEB_energy_ieta_iphi = ibooker.book2D("hEB_energy_ieta_iphi", "", 171, -85, 86, 360, 1, 361);
0094 
0095   hEEpZ_Minenergy_ix_iy = ibooker.book2D("hEEpZ_Minenergy_ix_iy", "", 100, 1, 101, 100, 1, 101);
0096   hEEmZ_Minenergy_ix_iy = ibooker.book2D("hEEmZ_Minenergy_ix_iy", "", 100, 1, 101, 100, 1, 101);
0097   hEB_Minenergy_ieta_iphi = ibooker.book2D("hEB_Minenergy_ieta_iphi", "", 171, -85, 86, 360, 1, 361);
0098 
0099   hEEpZ_Maxenergy_ix_iy = ibooker.book2D("hEEpZ_Maxenergy_ix_iy", "", 100, 1, 101, 100, 1, 101);
0100   hEEmZ_Maxenergy_ix_iy = ibooker.book2D("hEEmZ_Maxenergy_ix_iy", "", 100, 1, 101, 100, 1, 101);
0101   hEB_Maxenergy_ieta_iphi = ibooker.book2D("hEB_Maxenergy_ieta_iphi", "", 171, -85, 86, 360, 1, 361);
0102 
0103   // need to initialize those
0104   for (int i = 1; i <= 171; i++)
0105     for (int j = 1; j <= 360; j++) {
0106       hEB_Maxenergy_ieta_iphi->setBinContent(i, j, -999);
0107       hEB_Minenergy_ieta_iphi->setBinContent(i, j, 14000);
0108     }
0109   for (int i = 1; i <= 100; i++)
0110     for (int j = 1; j <= 100; j++) {
0111       hEEpZ_Maxenergy_ix_iy->setBinContent(i, j, -999);
0112       hEEpZ_Minenergy_ix_iy->setBinContent(i, j, 14000);
0113       hEEmZ_Maxenergy_ix_iy->setBinContent(i, j, -999);
0114       hEEmZ_Minenergy_ix_iy->setBinContent(i, j, 14000);
0115     }
0116 
0117   // Occupancy Histograms by logical index
0118   hEEpZ_Occ_ix_iy = ibooker.book2D("hEEpZ_Occ_ix_iy", "", 100, 1, 101, 100, 1, 101);
0119   hEEmZ_Occ_ix_iy = ibooker.book2D("hEEmZ_Occ_ix_iy", "", 100, 1, 101, 100, 1, 101);
0120   hEB_Occ_ieta_iphi = ibooker.book2D("hEB_Occ_ieta_iphi", "", 171, -85, 86, 360, 1, 361);
0121 
0122   // Integrated Histograms
0123   if (finebinning_) {
0124     hEEpZ_energyvsir = ibooker.book2D("hEEpZ_energyvsir", "", 100, 1, 101, 20110, -10, 201);
0125     hEEmZ_energyvsir = ibooker.book2D("hEEmZ_energyvsir", "", 100, 1, 101, 20110, -10, 201);
0126     hEB_energyvsieta = ibooker.book2D("hEB_energyvsieta", "", 171, -85, 86, 20110, -10, 201);
0127 
0128     hEEpZ_Maxenergyvsir = ibooker.book2D("hEEpZ_Maxenergyvsir", "", 100, 1, 101, 20110, -10, 201);
0129     hEEmZ_Maxenergyvsir = ibooker.book2D("hEEmZ_Maxenergyvsir", "", 100, 1, 101, 20110, -10, 201);
0130     hEB_Maxenergyvsieta = ibooker.book2D("hEB_Maxenergyvsieta", "", 171, -85, 86, 20110, -10, 201);
0131 
0132     hEEpZ_Minenergyvsir = ibooker.book2D("hEEpZ_Minenergyvsir", "", 100, 1, 101, 20110, -10, 201);
0133     hEEmZ_Minenergyvsir = ibooker.book2D("hEEmZ_Minenergyvsir", "", 100, 1, 101, 20110, -10, 201);
0134     hEB_Minenergyvsieta = ibooker.book2D("hEB_Minenergyvsieta", "", 171, -85, 86, 20110, -10, 201);
0135 
0136     hEEpZ_SETvsir = ibooker.book2D("hEEpZ_SETvsir", "", 50, 1, 51, 20010, 0, 201);
0137     hEEmZ_SETvsir = ibooker.book2D("hEEmZ_SETvsir", "", 50, 1, 51, 20010, 0, 201);
0138     hEB_SETvsieta = ibooker.book2D("hEB_SETvsieta", "", 171, -85, 86, 20010, 0, 201);
0139 
0140     hEEpZ_METvsir = ibooker.book2D("hEEpZ_METvsir", "", 50, 1, 51, 20010, 0, 201);
0141     hEEmZ_METvsir = ibooker.book2D("hEEmZ_METvsir", "", 50, 1, 51, 20010, 0, 201);
0142     hEB_METvsieta = ibooker.book2D("hEB_METvsieta", "", 171, -85, 86, 20010, 0, 201);
0143 
0144     hEEpZ_METPhivsir = ibooker.book2D("hEEpZ_METPhivsir", "", 50, 1, 51, 80, -4, 4);
0145     hEEmZ_METPhivsir = ibooker.book2D("hEEmZ_METPhivsir", "", 50, 1, 51, 80, -4, 4);
0146     hEB_METPhivsieta = ibooker.book2D("hEB_METPhivsieta", "", 171, -85, 86, 80, -4, 4);
0147 
0148     hEEpZ_MExvsir = ibooker.book2D("hEEpZ_MExvsir", "", 50, 1, 51, 10010, -50, 51);
0149     hEEmZ_MExvsir = ibooker.book2D("hEEmZ_MExvsir", "", 50, 1, 51, 10010, -50, 51);
0150     hEB_MExvsieta = ibooker.book2D("hEB_MExvsieta", "", 171, -85, 86, 10010, -50, 51);
0151 
0152     hEEpZ_MEyvsir = ibooker.book2D("hEEpZ_MEyvsir", "", 50, 1, 51, 10010, -50, 51);
0153     hEEmZ_MEyvsir = ibooker.book2D("hEEmZ_MEyvsir", "", 50, 1, 51, 10010, -50, 51);
0154     hEB_MEyvsieta = ibooker.book2D("hEB_MEyvsieta", "", 171, -85, 86, 10010, -50, 51);
0155 
0156     hEEpZ_Occvsir = ibooker.book2D("hEEpZ_Occvsir", "", 50, 1, 51, 1000, 0, 1000);
0157     hEEmZ_Occvsir = ibooker.book2D("hEEmZ_Occvsir", "", 50, 1, 51, 1000, 0, 1000);
0158     hEB_Occvsieta = ibooker.book2D("hEB_Occvsieta", "", 171, -85, 86, 400, 0, 400);
0159   } else {
0160     hEEpZ_energyvsir = ibooker.book2D("hEEpZ_energyvsir", "", 100, 1, 101, 510, -10, 100);
0161     hEEmZ_energyvsir = ibooker.book2D("hEEmZ_energyvsir", "", 100, 1, 101, 510, -10, 100);
0162     hEB_energyvsieta = ibooker.book2D("hEB_energyvsieta", "", 171, -85, 86, 510, -10, 100);
0163 
0164     hEEpZ_Maxenergyvsir = ibooker.book2D("hEEpZ_Maxenergyvsir", "", 100, 1, 101, 510, -10, 100);
0165     hEEmZ_Maxenergyvsir = ibooker.book2D("hEEmZ_Maxenergyvsir", "", 100, 1, 101, 510, -10, 100);
0166     hEB_Maxenergyvsieta = ibooker.book2D("hEB_Maxenergyvsieta", "", 171, -85, 86, 510, -10, 100);
0167 
0168     hEEpZ_Minenergyvsir = ibooker.book2D("hEEpZ_Minenergyvsir", "", 100, 1, 101, 510, -10, 100);
0169     hEEmZ_Minenergyvsir = ibooker.book2D("hEEmZ_Minenergyvsir", "", 100, 1, 101, 510, -10, 100);
0170     hEB_Minenergyvsieta = ibooker.book2D("hEB_Minenergyvsieta", "", 171, -85, 86, 510, -10, 100);
0171 
0172     hEEpZ_SETvsir = ibooker.book2D("hEEpZ_SETvsir", "", 50, 1, 51, 510, 0, 100);
0173     hEEmZ_SETvsir = ibooker.book2D("hEEmZ_SETvsir", "", 50, 1, 51, 510, 0, 100);
0174     hEB_SETvsieta = ibooker.book2D("hEB_SETvsieta", "", 171, -85, 86, 510, 0, 100);
0175 
0176     hEEpZ_METvsir = ibooker.book2D("hEEpZ_METvsir", "", 50, 1, 51, 510, 0, 100);
0177     hEEmZ_METvsir = ibooker.book2D("hEEmZ_METvsir", "", 50, 1, 51, 510, 0, 100);
0178     hEB_METvsieta = ibooker.book2D("hEB_METvsieta", "", 171, -85, 86, 510, 0, 100);
0179 
0180     hEEpZ_METPhivsir = ibooker.book2D("hEEpZ_METPhivsir", "", 50, 1, 51, 80, -4, 4);
0181     hEEmZ_METPhivsir = ibooker.book2D("hEEmZ_METPhivsir", "", 50, 1, 51, 80, -4, 4);
0182     hEB_METPhivsieta = ibooker.book2D("hEB_METPhivsieta", "", 171, -85, 86, 80, -4, 4);
0183 
0184     hEEpZ_MExvsir = ibooker.book2D("hEEpZ_MExvsir", "", 50, 1, 51, 510, -50, 51);
0185     hEEmZ_MExvsir = ibooker.book2D("hEEmZ_MExvsir", "", 50, 1, 51, 510, -50, 51);
0186     hEB_MExvsieta = ibooker.book2D("hEB_MExvsieta", "", 171, -85, 86, 510, -50, 51);
0187 
0188     hEEpZ_MEyvsir = ibooker.book2D("hEEpZ_MEyvsir", "", 50, 1, 51, 510, -50, 51);
0189     hEEmZ_MEyvsir = ibooker.book2D("hEEmZ_MEyvsir", "", 50, 1, 51, 510, -50, 51);
0190     hEB_MEyvsieta = ibooker.book2D("hEB_MEyvsieta", "", 171, -85, 86, 510, -50, 51);
0191 
0192     hEEpZ_Occvsir = ibooker.book2D("hEEpZ_Occvsir", "", 50, 1, 51, 1000, 0, 1000);
0193     hEEmZ_Occvsir = ibooker.book2D("hEEmZ_Occvsir", "", 50, 1, 51, 1000, 0, 1000);
0194     hEB_Occvsieta = ibooker.book2D("hEB_Occvsieta", "", 171, -85, 86, 400, 0, 400);
0195   }
0196 }
0197 
0198 void ECALRecHitAnalyzer::FillGeometry(const edm::EventSetup& iSetup) {
0199   // Fill geometry histograms
0200   using namespace edm;
0201   //const auto& cG = iSetup.getData(caloGeomToken_);
0202   //----Fill Ecal Barrel----//
0203   const CaloSubdetectorGeometry* EBgeom = caloGeom_->getSubdetectorGeometry(DetId::Ecal, 1);
0204   int n = 0;
0205   std::vector<DetId> EBids = EBgeom->getValidDetIds(DetId::Ecal, 1);
0206   for (std::vector<DetId>::iterator i = EBids.begin(); i != EBids.end(); i++) {
0207     n++;
0208     auto cell = EBgeom->getGeometry(*i);
0209     //GlobalPoint p = cell->getPosition();
0210 
0211     EBDetId EcalID(i->rawId());
0212 
0213     int Crystal_ieta = EcalID.ieta();
0214     int Crystal_iphi = EcalID.iphi();
0215     double Crystal_eta = cell->getPosition().eta();
0216     double Crystal_phi = cell->getPosition().phi();
0217     hEB_ieta_iphi_etaMap->setBinContent(Crystal_ieta + 86, Crystal_iphi, Crystal_eta);
0218     hEB_ieta_iphi_phiMap->setBinContent(Crystal_ieta + 86, Crystal_iphi, (Crystal_phi * 180 / M_PI));
0219 
0220     DEBUG(" Crystal " << n);
0221     DEBUG("  ieta, iphi = " << Crystal_ieta << ", " << Crystal_iphi);
0222     DEBUG("   eta,  phi = " << cell->getPosition().eta() << ", " << cell->getPosition().phi());
0223     DEBUG(" ");
0224   }
0225   //----Fill Ecal Endcap----------//
0226   const CaloSubdetectorGeometry* EEgeom = caloGeom_->getSubdetectorGeometry(DetId::Ecal, 2);
0227   n = 0;
0228   std::vector<DetId> EEids = EEgeom->getValidDetIds(DetId::Ecal, 2);
0229   for (std::vector<DetId>::iterator i = EEids.begin(); i != EEids.end(); i++) {
0230     n++;
0231     auto cell = EEgeom->getGeometry(*i);
0232     //GlobalPoint p = cell->getPosition();
0233     EEDetId EcalID(i->rawId());
0234     int Crystal_zside = EcalID.zside();
0235     int Crystal_ix = EcalID.ix();
0236     int Crystal_iy = EcalID.iy();
0237     Float_t ix_ = Crystal_ix - 50.5;
0238     Float_t iy_ = Crystal_iy - 50.5;
0239     Int_t ir = (Int_t)sqrt(ix_ * ix_ + iy_ * iy_);
0240 
0241     //double Crystal_eta = cell->getPosition().eta();
0242     //double Crystal_phi = cell->getPosition().phi();
0243     double Crystal_x = cell->getPosition().x();
0244     double Crystal_y = cell->getPosition().y();
0245     double Crystal_z = cell->getPosition().z();
0246     // ECAL -endcap
0247     if (Crystal_zside == -1) {
0248       hEEmZ_ix_iy_irMap->setBinContent(Crystal_ix, Crystal_iy, ir);
0249       hEEmZ_ix_iy_xMap->setBinContent(Crystal_ix, Crystal_iy, Crystal_x);
0250       hEEmZ_ix_iy_yMap->setBinContent(Crystal_ix, Crystal_iy, Crystal_y);
0251       hEEmZ_ix_iy_zMap->setBinContent(Crystal_ix, Crystal_iy, Crystal_z);
0252     }
0253     // ECAL +endcap
0254     if (Crystal_zside == 1) {
0255       hEEpZ_ix_iy_irMap->setBinContent(Crystal_ix, Crystal_iy, ir);
0256       hEEpZ_ix_iy_xMap->setBinContent(Crystal_ix, Crystal_iy, Crystal_x);
0257       hEEpZ_ix_iy_yMap->setBinContent(Crystal_ix, Crystal_iy, Crystal_y);
0258       hEEpZ_ix_iy_zMap->setBinContent(Crystal_ix, Crystal_iy, Crystal_z);
0259     }
0260 
0261     DEBUG(" Crystal " << n);
0262     DEBUG("  side = " << Crystal_zside);
0263     DEBUG("   ix, iy = " << Crystal_ix << ", " << Crystal_iy);
0264     DEBUG("    x,  y = " << Crystal_x << ", " << Crystal_y);
0265     ;
0266     DEBUG(" ");
0267   }
0268 
0269   //-------Set the cell size for each (ieta, iphi) bin-------//
0270   double currentLowEdge_eta = 0;
0271   //double currentHighEdge_eta = 0;
0272   for (int ieta = 1; ieta <= 85; ieta++) {
0273     int ieta_ = 86 + ieta;
0274 
0275     double eta = hEB_ieta_iphi_etaMap->getBinContent(ieta_, 1);
0276     double etam1 = -999;
0277 
0278     if (ieta == 1)
0279       etam1 = hEB_ieta_iphi_etaMap->getBinContent(85, 1);
0280     else
0281       etam1 = hEB_ieta_iphi_etaMap->getBinContent(ieta_ - 1, 1);
0282 
0283     //double phi = hEB_ieta_iphi_phiMap->getBinContent(ieta_, 1);
0284     double deta = fabs(eta - etam1);
0285     double dphi = fabs(hEB_ieta_iphi_phiMap->getBinContent(ieta_, 1) - hEB_ieta_iphi_phiMap->getBinContent(ieta_, 2));
0286 
0287     currentLowEdge_eta += deta;
0288     hEB_ieta_detaMap->setBinContent(ieta_, deta);      // positive rings
0289     hEB_ieta_dphiMap->setBinContent(ieta_, dphi);      // positive rings
0290     hEB_ieta_detaMap->setBinContent(86 - ieta, deta);  // negative rings
0291     hEB_ieta_dphiMap->setBinContent(86 - ieta, dphi);  // negative rings
0292   }
0293 }
0294 
0295 void ECALRecHitAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
0296   CurrentEvent++;
0297   DEBUG("Event: " << CurrentEvent);
0298   WriteECALRecHits(iEvent, iSetup);
0299   hECAL_Nevents->Fill(0.5);
0300 }
0301 
0302 void ECALRecHitAnalyzer::WriteECALRecHits(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
0303   edm::Handle<EBRecHitCollection> EBRecHits;
0304   edm::Handle<EERecHitCollection> EERecHits;
0305   iEvent.getByToken(EBRecHitsLabel_, EBRecHits);
0306   iEvent.getByToken(EERecHitsLabel_, EERecHits);
0307   DEBUG("Got ECALRecHits");
0308 
0309   //const CaloSubdetectorGeometry* EBgeom=cG.getSubdetectorGeometry(DetId::Ecal,1);
0310   //const CaloSubdetectorGeometry* EEgeom=cG.getSubdetectorGeometry(DetId::Ecal,2);
0311   DEBUG("Got Geometry");
0312 
0313   TLorentzVector vEBMET_EtaRing[171];
0314   int EBActiveRing[171];
0315   int EBNActiveCells[171];
0316   double EBSET_EtaRing[171];
0317   double EBMaxEnergy_EtaRing[171];
0318   double EBMinEnergy_EtaRing[171];
0319   double EBenergy_EtaRing[171];
0320 
0321   for (int i = 0; i < 171; i++) {
0322     EBActiveRing[i] = 0;
0323     EBNActiveCells[i] = 0;
0324     EBSET_EtaRing[i] = 0.0;
0325     EBMaxEnergy_EtaRing[i] = -999;
0326     EBMinEnergy_EtaRing[i] = 14E3;
0327     EBenergy_EtaRing[i] = 0.0;
0328   }
0329 
0330   edm::LogInfo("OutputInfo") << "Looping over EB" << std::endl;
0331 
0332   EBRecHitCollection::const_iterator ebrechit;
0333   //int nEBrechit = 0;
0334 
0335   for (ebrechit = EBRecHits->begin(); ebrechit != EBRecHits->end(); ebrechit++) {
0336     EBDetId det = ebrechit->id();
0337     double Energy = ebrechit->energy();
0338     Int_t ieta = det.ieta();
0339     Int_t iphi = det.iphi();
0340     int EtaRing = 85 + ieta;  // this counts from 0
0341     double eta = hEB_ieta_iphi_etaMap->getBinContent(EtaRing + 1, iphi);
0342     double phi = hEB_ieta_iphi_phiMap->getBinContent(EtaRing + 1, iphi);
0343     double theta = 2 * TMath::ATan(exp(-1 * eta));
0344     double ET = Energy * TMath::Sin(theta);
0345     TLorentzVector v_;
0346 
0347     if (Energy > EBMaxEnergy_EtaRing[EtaRing])
0348       EBMaxEnergy_EtaRing[EtaRing] = Energy;
0349     if (Energy < EBMinEnergy_EtaRing[EtaRing])
0350       EBMinEnergy_EtaRing[EtaRing] = Energy;
0351 
0352     if (Energy > 0) {
0353       EBActiveRing[EtaRing] = 1;
0354       EBNActiveCells[EtaRing]++;
0355       EBSET_EtaRing[EtaRing] += ET;
0356       v_.SetPtEtaPhiE(ET, 0, phi, ET);
0357       vEBMET_EtaRing[EtaRing] -= v_;
0358       EBenergy_EtaRing[EtaRing] += Energy;
0359       hEB_Occ_ieta_iphi->Fill(ieta, iphi);
0360     }
0361 
0362     hEB_energy_ieta_iphi->Fill(ieta, iphi, Energy);
0363     if (Energy > hEB_Maxenergy_ieta_iphi->getBinContent(EtaRing + 1, iphi))
0364       hEB_Maxenergy_ieta_iphi->setBinContent(EtaRing + 1, iphi, Energy);
0365     if (Energy < hEB_Minenergy_ieta_iphi->getBinContent(EtaRing + 1, iphi))
0366       hEB_Minenergy_ieta_iphi->setBinContent(EtaRing + 1, iphi, Energy);
0367 
0368   }  // loop over EB
0369 
0370   for (int iEtaRing = 0; iEtaRing < 171; iEtaRing++) {
0371     hEB_Minenergyvsieta->Fill(iEtaRing - 85, EBMinEnergy_EtaRing[iEtaRing]);
0372     hEB_Maxenergyvsieta->Fill(iEtaRing - 85, EBMaxEnergy_EtaRing[iEtaRing]);
0373 
0374     if (EBActiveRing[iEtaRing]) {
0375       hEB_METvsieta->Fill(iEtaRing - 85, vEBMET_EtaRing[iEtaRing].Pt());
0376       hEB_METPhivsieta->Fill(iEtaRing - 85, vEBMET_EtaRing[iEtaRing].Phi());
0377       hEB_MExvsieta->Fill(iEtaRing - 85, vEBMET_EtaRing[iEtaRing].Px());
0378       hEB_MEyvsieta->Fill(iEtaRing - 85, vEBMET_EtaRing[iEtaRing].Py());
0379       hEB_SETvsieta->Fill(iEtaRing - 85, EBSET_EtaRing[iEtaRing]);
0380       hEB_Occvsieta->Fill(iEtaRing - 85, EBNActiveCells[iEtaRing]);
0381       hEB_energyvsieta->Fill(iEtaRing - 85, EBenergy_EtaRing[iEtaRing]);
0382     }
0383   }
0384 
0385   TLorentzVector vEEpZMET_EtaRing[101];
0386   int EEpZActiveRing[101];
0387   int EEpZNActiveCells[101];
0388   double EEpZSET_EtaRing[101];
0389   double EEpZMaxEnergy_EtaRing[101];
0390   double EEpZMinEnergy_EtaRing[101];
0391 
0392   TLorentzVector vEEmZMET_EtaRing[101];
0393   int EEmZActiveRing[101];
0394   int EEmZNActiveCells[101];
0395   double EEmZSET_EtaRing[101];
0396   double EEmZMaxEnergy_EtaRing[101];
0397   double EEmZMinEnergy_EtaRing[101];
0398 
0399   for (int i = 0; i < 101; i++) {
0400     EEpZActiveRing[i] = 0;
0401     EEpZNActiveCells[i] = 0;
0402     EEpZSET_EtaRing[i] = 0.0;
0403     EEpZMaxEnergy_EtaRing[i] = -999;
0404     EEpZMinEnergy_EtaRing[i] = 14E3;
0405 
0406     EEmZActiveRing[i] = 0;
0407     EEmZNActiveCells[i] = 0;
0408     EEmZSET_EtaRing[i] = 0.0;
0409     EEmZMaxEnergy_EtaRing[i] = -999;
0410     EEmZMinEnergy_EtaRing[i] = 14E3;
0411   }
0412 
0413   edm::LogInfo("OutputInfo") << "Looping over EE" << std::endl;
0414   EERecHitCollection::const_iterator eerechit;
0415   //int nEErechit = 0;
0416   for (eerechit = EERecHits->begin(); eerechit != EERecHits->end(); eerechit++) {
0417     EEDetId det = eerechit->id();
0418     double Energy = eerechit->energy();
0419     Int_t ix = det.ix();
0420     Int_t iy = det.iy();
0421     //Float_t ix_ = (Float_t)-999;
0422     //Float_t iy_ = (Float_t)-999;
0423     Int_t ir = -999;
0424     //    edm::LogInfo("OutputInfo") << ix << " " << iy << " " << ix_ << " " << iy_ << " " << ir << std::endl;
0425 
0426     double x = -999;
0427     double y = -999;
0428     double z = -999;
0429     double theta = -999;
0430     double phi = -999;
0431 
0432     int Crystal_zside = det.zside();
0433 
0434     if (Crystal_zside == -1) {
0435       ir = (Int_t)hEEmZ_ix_iy_irMap->getBinContent(ix, iy);
0436       x = hEEmZ_ix_iy_xMap->getBinContent(ix, iy);
0437       y = hEEmZ_ix_iy_yMap->getBinContent(ix, iy);
0438       z = hEEmZ_ix_iy_zMap->getBinContent(ix, iy);
0439     }
0440     if (Crystal_zside == 1) {
0441       ir = (Int_t)hEEpZ_ix_iy_irMap->getBinContent(ix, iy);
0442       x = hEEpZ_ix_iy_xMap->getBinContent(ix, iy);
0443       y = hEEpZ_ix_iy_yMap->getBinContent(ix, iy);
0444       z = hEEpZ_ix_iy_zMap->getBinContent(ix, iy);
0445     }
0446     TVector3 pos_vector(x, y, z);
0447     phi = pos_vector.Phi();
0448     theta = pos_vector.Theta();
0449     double ET = Energy * TMath::Sin(theta);
0450     TLorentzVector v_;
0451 
0452     if (Crystal_zside == -1) {
0453       if (Energy > 0) {
0454         EEmZActiveRing[ir] = 1;
0455         EEmZNActiveCells[ir]++;
0456         EEmZSET_EtaRing[ir] += ET;
0457         v_.SetPtEtaPhiE(ET, 0, phi, ET);
0458         vEEmZMET_EtaRing[ir] -= v_;
0459         hEEmZ_Occ_ix_iy->Fill(ix, iy);
0460       }
0461       hEEmZ_energyvsir->Fill(ir, Energy);
0462       hEEmZ_energy_ix_iy->Fill(ix, iy, Energy);
0463 
0464       if (Energy > EEmZMaxEnergy_EtaRing[ir])
0465         EEmZMaxEnergy_EtaRing[ir] = Energy;
0466       if (Energy < EEmZMinEnergy_EtaRing[ir])
0467         EEmZMinEnergy_EtaRing[ir] = Energy;
0468 
0469       if (Energy > hEEmZ_Maxenergy_ix_iy->getBinContent(ix, iy))
0470         hEEmZ_Maxenergy_ix_iy->setBinContent(ix, iy, Energy);
0471       if (Energy < hEEmZ_Minenergy_ix_iy->getBinContent(ix, iy))
0472         hEEmZ_Minenergy_ix_iy->setBinContent(ix, iy, Energy);
0473     }
0474     if (Crystal_zside == 1) {
0475       if (Energy > 0) {
0476         EEpZActiveRing[ir] = 1;
0477         EEpZNActiveCells[ir]++;
0478         EEpZSET_EtaRing[ir] += ET;
0479         v_.SetPtEtaPhiE(ET, 0, phi, ET);
0480         vEEpZMET_EtaRing[ir] -= v_;
0481         hEEpZ_Occ_ix_iy->Fill(ix, iy);
0482       }
0483       hEEpZ_energyvsir->Fill(ir, Energy);
0484       hEEpZ_energy_ix_iy->Fill(ix, iy, Energy);
0485 
0486       if (Energy > EEpZMaxEnergy_EtaRing[ir])
0487         EEpZMaxEnergy_EtaRing[ir] = Energy;
0488       if (Energy < EEpZMinEnergy_EtaRing[ir])
0489         EEpZMinEnergy_EtaRing[ir] = Energy;
0490       if (Energy > hEEpZ_Maxenergy_ix_iy->getBinContent(ix, iy))
0491         hEEpZ_Maxenergy_ix_iy->setBinContent(ix, iy, Energy);
0492       if (Energy < hEEpZ_Minenergy_ix_iy->getBinContent(ix, iy))
0493         hEEpZ_Minenergy_ix_iy->setBinContent(ix, iy, Energy);
0494     }
0495   }  // loop over EE
0496   edm::LogInfo("OutputInfo") << "Done Looping over EE" << std::endl;
0497   for (int iEtaRing = 0; iEtaRing < 101; iEtaRing++) {
0498     hEEpZ_Maxenergyvsir->Fill(iEtaRing, EEpZMaxEnergy_EtaRing[iEtaRing]);
0499     hEEpZ_Minenergyvsir->Fill(iEtaRing, EEpZMinEnergy_EtaRing[iEtaRing]);
0500     hEEmZ_Maxenergyvsir->Fill(iEtaRing, EEmZMaxEnergy_EtaRing[iEtaRing]);
0501     hEEmZ_Minenergyvsir->Fill(iEtaRing, EEmZMinEnergy_EtaRing[iEtaRing]);
0502 
0503     if (EEpZActiveRing[iEtaRing]) {
0504       hEEpZ_METvsir->Fill(iEtaRing, vEEpZMET_EtaRing[iEtaRing].Pt());
0505       hEEpZ_METPhivsir->Fill(iEtaRing, vEEpZMET_EtaRing[iEtaRing].Phi());
0506       hEEpZ_MExvsir->Fill(iEtaRing, vEEpZMET_EtaRing[iEtaRing].Px());
0507       hEEpZ_MEyvsir->Fill(iEtaRing, vEEpZMET_EtaRing[iEtaRing].Py());
0508       hEEpZ_SETvsir->Fill(iEtaRing, EEpZSET_EtaRing[iEtaRing]);
0509       hEEpZ_Occvsir->Fill(iEtaRing, EEpZNActiveCells[iEtaRing]);
0510     }
0511 
0512     if (EEmZActiveRing[iEtaRing]) {
0513       hEEmZ_METvsir->Fill(iEtaRing, vEEmZMET_EtaRing[iEtaRing].Pt());
0514       hEEmZ_METPhivsir->Fill(iEtaRing, vEEmZMET_EtaRing[iEtaRing].Phi());
0515       hEEmZ_MExvsir->Fill(iEtaRing, vEEmZMET_EtaRing[iEtaRing].Px());
0516       hEEmZ_MEyvsir->Fill(iEtaRing, vEEmZMET_EtaRing[iEtaRing].Py());
0517       hEEmZ_SETvsir->Fill(iEtaRing, EEmZSET_EtaRing[iEtaRing]);
0518       hEEmZ_Occvsir->Fill(iEtaRing, EEmZNActiveCells[iEtaRing]);
0519     }
0520   }
0521   edm::LogInfo("OutputInfo") << "Done ..." << std::endl;
0522 }  // loop over RecHits