Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:14:24

0001 #include "Calibration/Tools/interface/CalibrationCluster.h"
0002 #include <iostream>
0003 #include <string>
0004 
0005 using namespace std;
0006 
0007 CalibrationCluster::CalibrationCluster() {}
0008 
0009 CalibrationCluster::~CalibrationCluster() {}
0010 
0011 ///////////////////////////////////////////////////////////////////////
0012 
0013 std::vector<EBDetId> CalibrationCluster::get5x5Id(EBDetId const& maxHitId) {
0014   Xtals5x5.clear();
0015 
0016   //   std::cout << "get5x5Id: max Containment crystal " << maxHitId.ic() << " eta " << maxHitId.ieta() << " phi " << maxHitId.iphi() << std::endl;
0017 
0018   for (unsigned int icry = 0; icry < 25; icry++) {
0019     unsigned int row = icry / 5;
0020     unsigned int column = icry % 5;
0021     //       std::cout << "CalibrationCluster::icry = " << icry << std::endl;
0022 
0023     int curr_eta = maxHitId.ieta() + column - (5 / 2);
0024     int curr_phi = maxHitId.iphi() + row - (5 / 2);
0025 
0026     if (curr_eta * maxHitId.ieta() <= 0) {
0027       if (maxHitId.ieta() > 0)
0028         curr_eta--;
0029       else
0030         curr_eta++;
0031     }  // JUMP over 0
0032     if (curr_phi < 1)
0033       curr_phi += 360;
0034     if (curr_phi > 360)
0035       curr_phi -= 360;
0036 
0037     try {
0038       //         Xtals5x5.push_back(EBDetId(maxHitId.ieta()+column-2,maxHitId.iphi()+row-2,EBDetId::ETAPHIMODE));
0039       Xtals5x5.push_back(EBDetId(curr_eta, curr_phi, EBDetId::ETAPHIMODE));
0040     } catch (...) {
0041       std::cout << "Cannot construct 5x5 matrix around EBDetId " << maxHitId << std::endl;
0042     }
0043   }
0044 
0045   return Xtals5x5;
0046 }
0047 
0048 ///////////////////////////////////////////////////////////////////////
0049 
0050 std::vector<EBDetId> CalibrationCluster::get3x3Id(EBDetId const& maxHitId) {
0051   Xtals3x3.clear();
0052 
0053   for (unsigned int icry = 0; icry < 9; icry++) {
0054     unsigned int row = icry / 3;
0055     unsigned int column = icry % 3;
0056 
0057     try {
0058       Xtals3x3.push_back(EBDetId(maxHitId.ieta() + column - 1, maxHitId.iphi() + row - 1, EBDetId::ETAPHIMODE));
0059     } catch (...) {
0060       std::cout << "Cannot construct 3x3 matrix around EBDetId " << maxHitId << std::endl;
0061     }
0062   }
0063 
0064   return Xtals3x3;
0065 }
0066 
0067 ///////////////////////////////////////////////////////////////////////
0068 
0069 CalibrationCluster::CalibMap CalibrationCluster::getMap(int minEta, int maxEta, int minPhi, int maxPhi) {
0070   calibRegion.clear();
0071   int rowSize = maxEta - minEta + 1;
0072   int columnSize = maxPhi - minPhi + 1;
0073   int reducedSize = rowSize * columnSize;
0074 
0075   for (int icry = 0; icry < reducedSize; icry++) {
0076     unsigned int eta = minEta + icry / columnSize;
0077     unsigned int phi = minPhi + icry % columnSize;
0078 
0079     try {
0080       calibRegion.insert(pippo(EBDetId(eta, phi, EBDetId::ETAPHIMODE), icry));
0081     } catch (...) {
0082       std::cout << "Cannot construct full matrix !!! " << std::endl;
0083     }
0084   }
0085 
0086   return calibRegion;
0087 }
0088 
0089 ///////////////////////////////////////////////////////////////////////
0090 
0091 std::vector<float> CalibrationCluster::getEnergyVector(const EBRecHitCollection* hits,
0092                                                        CalibMap& ReducedMap,
0093                                                        std::vector<EBDetId>& XstalsNxN,
0094                                                        float& outBoundEnergy,
0095                                                        int& nXtalsOut) {
0096   energyVector.clear();
0097   std::vector<EBDetId>::iterator it;
0098 
0099   // std::cout << "Reduced Map Size =" << ReducedMap.size() << std::endl;
0100   // std::cout << "XstalsNxN Size =" << XstalsNxN.size() << std::endl;
0101   energyVector.resize(ReducedMap.size(), 0.);
0102 
0103   outBoundEnergy = 0.;
0104   nXtalsOut = 0;
0105   for (it = XstalsNxN.begin(); it != XstalsNxN.end(); ++it) {
0106     if (ReducedMap.find(*it) != ReducedMap.end()) {
0107       CalibMap::iterator it2 = ReducedMap.find(*it);
0108 
0109       int icry = it2->second;
0110 
0111       energyVector[icry] = (hits->find(*it))->energy();
0112 
0113     } else {
0114       //       std::cout << " Cell out of Reduced map: did you subtracted the cell energy from P ???" << std::endl;
0115       outBoundEnergy += (hits->find(*it))->energy();
0116       nXtalsOut++;
0117     }
0118   }
0119 
0120   return energyVector;
0121 }