Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
#include "Calibration/Tools/interface/CalibrationCluster.h"
#include <iostream>
#include <string>

using namespace std;

CalibrationCluster::CalibrationCluster() {}

CalibrationCluster::~CalibrationCluster() {}

///////////////////////////////////////////////////////////////////////

std::vector<EBDetId> CalibrationCluster::get5x5Id(EBDetId const& maxHitId) {
  Xtals5x5.clear();

  //   std::cout << "get5x5Id: max Containment crystal " << maxHitId.ic() << " eta " << maxHitId.ieta() << " phi " << maxHitId.iphi() << std::endl;

  for (unsigned int icry = 0; icry < 25; icry++) {
    unsigned int row = icry / 5;
    unsigned int column = icry % 5;
    //       std::cout << "CalibrationCluster::icry = " << icry << std::endl;

    int curr_eta = maxHitId.ieta() + column - (5 / 2);
    int curr_phi = maxHitId.iphi() + row - (5 / 2);

    if (curr_eta * maxHitId.ieta() <= 0) {
      if (maxHitId.ieta() > 0)
        curr_eta--;
      else
        curr_eta++;
    }  // JUMP over 0
    if (curr_phi < 1)
      curr_phi += 360;
    if (curr_phi > 360)
      curr_phi -= 360;

    try {
      //         Xtals5x5.push_back(EBDetId(maxHitId.ieta()+column-2,maxHitId.iphi()+row-2,EBDetId::ETAPHIMODE));
      Xtals5x5.push_back(EBDetId(curr_eta, curr_phi, EBDetId::ETAPHIMODE));
    } catch (...) {
      std::cout << "Cannot construct 5x5 matrix around EBDetId " << maxHitId << std::endl;
    }
  }

  return Xtals5x5;
}

///////////////////////////////////////////////////////////////////////

std::vector<EBDetId> CalibrationCluster::get3x3Id(EBDetId const& maxHitId) {
  Xtals3x3.clear();

  for (unsigned int icry = 0; icry < 9; icry++) {
    unsigned int row = icry / 3;
    unsigned int column = icry % 3;

    try {
      Xtals3x3.push_back(EBDetId(maxHitId.ieta() + column - 1, maxHitId.iphi() + row - 1, EBDetId::ETAPHIMODE));
    } catch (...) {
      std::cout << "Cannot construct 3x3 matrix around EBDetId " << maxHitId << std::endl;
    }
  }

  return Xtals3x3;
}

///////////////////////////////////////////////////////////////////////

CalibrationCluster::CalibMap CalibrationCluster::getMap(int minEta, int maxEta, int minPhi, int maxPhi) {
  calibRegion.clear();
  int rowSize = maxEta - minEta + 1;
  int columnSize = maxPhi - minPhi + 1;
  int reducedSize = rowSize * columnSize;

  for (int icry = 0; icry < reducedSize; icry++) {
    unsigned int eta = minEta + icry / columnSize;
    unsigned int phi = minPhi + icry % columnSize;

    try {
      calibRegion.insert(pippo(EBDetId(eta, phi, EBDetId::ETAPHIMODE), icry));
    } catch (...) {
      std::cout << "Cannot construct full matrix !!! " << std::endl;
    }
  }

  return calibRegion;
}

///////////////////////////////////////////////////////////////////////

std::vector<float> CalibrationCluster::getEnergyVector(const EBRecHitCollection* hits,
                                                       CalibMap& ReducedMap,
                                                       std::vector<EBDetId>& XstalsNxN,
                                                       float& outBoundEnergy,
                                                       int& nXtalsOut) {
  energyVector.clear();
  std::vector<EBDetId>::iterator it;

  // std::cout << "Reduced Map Size =" << ReducedMap.size() << std::endl;
  // std::cout << "XstalsNxN Size =" << XstalsNxN.size() << std::endl;
  energyVector.resize(ReducedMap.size(), 0.);

  outBoundEnergy = 0.;
  nXtalsOut = 0;
  for (it = XstalsNxN.begin(); it != XstalsNxN.end(); ++it) {
    if (ReducedMap.find(*it) != ReducedMap.end()) {
      CalibMap::iterator it2 = ReducedMap.find(*it);

      int icry = it2->second;

      energyVector[icry] = (hits->find(*it))->energy();

    } else {
      //       std::cout << " Cell out of Reduced map: did you subtracted the cell energy from P ???" << std::endl;
      outBoundEnergy += (hits->find(*it))->energy();
      nXtalsOut++;
    }
  }

  return energyVector;
}