CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_8_patch3/src/Calibration/EcalCalibAlgos/src/MatrixFillMap.cc

Go to the documentation of this file.
00001 #include "Calibration/EcalCalibAlgos/interface/MatrixFillMap.h"
00002 #include "DataFormats/EcalDetId/interface/EEDetId.h"
00003 #include "DataFormats/EcalDetId/interface/EBDetId.h"
00004 
00005 MatrixFillMap::MatrixFillMap (int WindowX,
00006         int WindowY,
00007         std::map<int,int> xtalReg,
00008         double minE,
00009         double maxE, 
00010         std::map<int,int> IndexReg,
00011         EcalIntercalibConstantMap * barrelMap,
00012         EcalIntercalibConstantMap * endcapMap): 
00013 
00014          VFillMap (WindowX,WindowY,xtalReg,minE,
00015                 maxE, IndexReg,
00016                 barrelMap,endcapMap)
00017         {
00018         }
00019 
00020 MatrixFillMap::~MatrixFillMap ()
00021         {
00022         }
00023 
00024 
00025 void
00026 MatrixFillMap::fillMap (const std::vector<std::pair<DetId,float> >  & v1,
00027         const DetId Max,
00028          const EcalRecHitCollection * barrelHitsCollection,
00029          const EcalRecHitCollection * endcapHitsCollection,
00030          std::map<int, double> & xtlMap,
00031          double & pSubtract)
00032 {
00033         if (Max.subdetId() == EcalBarrel ){
00034                 EBDetId EBMax = Max;
00035                 fillEBMap (EBMax, barrelHitsCollection, xtlMap,
00036                      m_xtalRegionId[Max.rawId()], pSubtract ) ;
00037          }
00038         else if (Max.subdetId()== EcalEndcap){
00039                EEDetId EEMax = Max;
00040                fillEEMap (EEMax, endcapHitsCollection, xtlMap,
00041                      m_xtalRegionId[Max.rawId()],pSubtract ) ;
00042         }
00043 }
00044 
00045 
00046 
00047 void 
00048 MatrixFillMap::fillEBMap (EBDetId EBmax,
00049          const EcalRecHitCollection * barrelHitsCollection,
00050          std::map<int, double> & EBRegionMap,
00051          int EBNumberOfRegion, double & pSubtract)
00052 {
00053   int curr_eta;
00054   int curr_phi;
00055   //reads the hits in a recoWindowSide^2 wide region around the MOX
00056   for (int ii = 0 ; ii< m_recoWindowSidex ; ++ii)
00057    for (int ij =0 ; ij< m_recoWindowSidey ; ++ij) 
00058    {
00059     curr_eta=EBmax.ieta() + ii - (m_recoWindowSidex/2);
00060     curr_phi=EBmax.iphi() + ij - (m_recoWindowSidey/2);
00061     //skips if the xtals matrix falls over the border
00062     if (abs(curr_eta)>85) continue;
00063     //Couples with the zero gap in the barrel eta index
00064     if (curr_eta * EBmax.ieta() <= 0) {
00065             if (EBmax.ieta() > 0) curr_eta--; 
00066               else curr_eta++;
00067         } // JUMP over 0
00068     //The following 2 couples with the ciclicity of the phiIndex
00069     if (curr_phi < 1) curr_phi += 360;
00070     if (curr_phi >= 360) curr_phi -= 360;
00071     //checks if the detId is valid
00072     if(EBDetId::validDetId(curr_eta,curr_phi))
00073      {
00074       EBDetId det = EBDetId(curr_eta,curr_phi,EBDetId::ETAPHIMODE);
00075       int ID= det.rawId();
00076       //finds the hit corresponding to the cell
00077       EcalRecHitCollection::const_iterator curr_recHit = barrelHitsCollection->find(det) ;
00078       double dummy = 0;
00079       dummy = curr_recHit->energy () ;
00080       //checks if the reading of the xtal is in a sensible range
00081       if (std::isnan(dummy)){
00082           dummy=0;
00083        }        
00084       if ( dummy < m_minEnergyPerCrystal) continue; 
00085       if (dummy > m_maxEnergyPerCrystal)  continue;
00086      //corrects the energy with the calibration coeff of the ring
00087       dummy *= (*m_barrelMap)[det];
00088       //sums the energy of the xtal to the appropiate ring
00089       if (m_xtalRegionId[ID]==EBNumberOfRegion)
00090         EBRegionMap[m_IndexInRegion[ID]]+= dummy;
00091       //adds the reading to pSubtract when part of the matrix is outside the region
00092       else pSubtract +=dummy; 
00093      }
00094    }
00095 }
00096 
00097 void MatrixFillMap::fillEEMap (EEDetId EEmax,
00098                 const EcalRecHitCollection * endcapHitsCollection,
00099                 std::map<int,double> & EExtlMap,
00100                 int EENumberOfRegion, double & pSubtract )
00101 {
00102  int curr_x;
00103  int curr_y;
00104  for (int ii = 0 ; ii< m_recoWindowSidex ; ++ii)
00105   for (int ij =0 ; ij< m_recoWindowSidey ; ++ij) 
00106  {
00107   //Works as fillEBMap
00108   curr_x = EEmax.ix() - m_recoWindowSidex/2 +ii;
00109   curr_y = EEmax.iy() - m_recoWindowSidey /2 +ij;
00110   if(EEDetId::validDetId(curr_x,curr_y,EEmax.zside()))
00111   {
00112    EEDetId det = EEDetId(curr_x,curr_y,EEmax.zside(),EEDetId::XYMODE);
00113    int ID=det.rawId();
00114    EcalRecHitCollection::const_iterator curr_recHit = endcapHitsCollection->find(det) ;
00115    double dummy = curr_recHit->energy () ;
00116    if (std::isnan(dummy)) {
00117      dummy=0;
00118    }
00119    if ( dummy < m_minEnergyPerCrystal ) continue; 
00120    if ( dummy > m_maxEnergyPerCrystal ) {
00121         dummy=0;
00122         continue;
00123    }
00124    dummy *= (*m_endcapMap)[det];
00125    if (m_xtalRegionId[ID]==EENumberOfRegion)
00126       EExtlMap[m_IndexInRegion[ID]] += dummy;
00127    else pSubtract +=dummy; 
00128   }
00129  }
00130 }