CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10_patch1/src/Calibration/Tools/src/CalibrationCluster.cc

Go to the documentation of this file.
00001 #include "Calibration/Tools/interface/CalibrationCluster.h"
00002 #include <iostream>
00003 #include <string>
00004 
00005 using namespace std;
00006 
00007 CalibrationCluster::CalibrationCluster(){
00008 
00009 }
00010 
00011 CalibrationCluster::~CalibrationCluster(){
00012 }
00013 
00015 
00016 std::vector<EBDetId> CalibrationCluster::get5x5Id(EBDetId const & maxHitId){
00017 
00018 
00019    Xtals5x5.clear();
00020    
00021    
00022 //   std::cout << "get5x5Id: max Containment crystal " << maxHitId.ic() << " eta " << maxHitId.ieta() << " phi " << maxHitId.iphi() << std::endl;
00023 
00024    for (unsigned int icry=0;icry<25;icry++)
00025      {
00026        unsigned int row = icry / 5;
00027        unsigned int column= icry %5;
00028 //       std::cout << "CalibrationCluster::icry = " << icry << std::endl;
00029        
00030        int curr_eta=maxHitId.ieta() + column - (5/2);
00031        int curr_phi=maxHitId.iphi() + row - (5/2);
00032               
00033        if (curr_eta * maxHitId.ieta() <= 0) {if (maxHitId.ieta() > 0) curr_eta--; else curr_eta++; }  // JUMP over 0
00034        if (curr_phi < 1) curr_phi += 360;
00035        if (curr_phi > 360) curr_phi -= 360;
00036       
00037        try
00038          {
00039 //         Xtals5x5.push_back(EBDetId(maxHitId.ieta()+column-2,maxHitId.iphi()+row-2,EBDetId::ETAPHIMODE));
00040          Xtals5x5.push_back(EBDetId(curr_eta,curr_phi,EBDetId::ETAPHIMODE));
00041          }
00042        catch ( ... )
00043          {
00044            std::cout << "Cannot construct 5x5 matrix around EBDetId " << maxHitId << std::endl;
00045          }
00046      }
00047 
00048    return Xtals5x5;
00049 }
00050 
00052 
00053 std::vector<EBDetId> CalibrationCluster::get3x3Id(EBDetId const & maxHitId){
00054 
00055     Xtals3x3.clear();
00056 
00057     for (unsigned int icry=0;icry<9;icry++)
00058      {
00059        unsigned int row = icry / 3;
00060        unsigned int column= icry %3;
00061        
00062        
00063        try
00064          {
00065          Xtals3x3.push_back(EBDetId(maxHitId.ieta()+column-1,maxHitId.iphi()+row-1,EBDetId::ETAPHIMODE));
00066          }
00067        catch ( ... )
00068          {
00069            std::cout << "Cannot construct 3x3 matrix around EBDetId " << maxHitId << std::endl;
00070          }
00071      }
00072 
00073    return Xtals3x3;
00074 }
00075 
00077 
00078 
00079 CalibrationCluster::CalibMap CalibrationCluster::getMap(int minEta, int maxEta, int minPhi, int maxPhi){
00080    
00081    calibRegion.clear();
00082    int rowSize=maxEta-minEta+1;
00083    int columnSize=maxPhi-minPhi+1;
00084    int reducedSize=rowSize*columnSize;
00085    
00086 
00087    for (int icry=0;icry<reducedSize;icry++)
00088      {
00089        unsigned int eta = minEta + icry/columnSize;
00090        unsigned int phi = minPhi + icry%columnSize;
00091 
00092        
00093        try
00094          {
00095          calibRegion.insert(pippo(EBDetId(eta,phi,EBDetId::ETAPHIMODE),icry));
00096          }
00097        catch ( ... )
00098          {
00099            std::cout << "Cannot construct full matrix !!! " << std::endl;
00100          }
00101      }
00102 
00103    return calibRegion;
00104 
00105 }
00106 
00108 
00109 
00110 std::vector<float> CalibrationCluster::getEnergyVector(const EBRecHitCollection*
00111 hits, CalibMap & ReducedMap, std::vector<EBDetId> & XstalsNxN, float & outBoundEnergy, int & nXtalsOut){
00112 
00113  energyVector.clear();
00114  std::vector<EBDetId>::iterator it;
00115 
00116 // std::cout << "Reduced Map Size =" << ReducedMap.size() << std::endl;
00117 // std::cout << "XstalsNxN Size =" << XstalsNxN.size() << std::endl;
00118  energyVector.resize(ReducedMap.size(),0.);
00119 
00120    outBoundEnergy=0.;   
00121    nXtalsOut=0;
00122    for(it=XstalsNxN.begin();it!=XstalsNxN.end();++it)
00123    {
00124        if(ReducedMap.find(*it) != ReducedMap.end()){
00125        CalibMap::iterator  it2 = ReducedMap.find(*it);
00126    
00127        int icry = it2->second;
00128    
00129        energyVector[icry]=(hits->find(*it))->energy();
00130        
00131        } else {
00132        
00133 //       std::cout << " Cell out of Reduced map: did you subtracted the cell energy from P ???" << std::endl;
00134        outBoundEnergy+=(hits->find(*it))->energy();
00135        nXtalsOut++;
00136        }
00137     }
00138 
00139 
00140 
00141 return energyVector;
00142 
00143 }
00144