31 : m_barrelAlCa(iConfig.getParameter<
edm::
InputTag>(
"barrelAlca")),
32 m_endcapAlCa(iConfig.getParameter<
edm::
InputTag>(
"endcapAlca")),
33 m_ElectronLabel(iConfig.getParameter<
edm::
InputTag>(
"ElectronLabel")),
34 m_recoWindowSidex(iConfig.getParameter<
int>(
"recoWindowSidex")),
35 m_recoWindowSidey(iConfig.getParameter<
int>(
"recoWindowSidey")),
36 m_minEnergyPerCrystal(iConfig.getParameter<double>(
"minEnergyPerCrystal")),
37 m_maxEnergyPerCrystal(iConfig.getParameter<double>(
"maxEnergyPerCrystal")),
38 m_etaStart(iConfig.getParameter<
int>(
"etaStart")),
39 m_etaEnd(iConfig.getParameter<
int>(
"etaEnd")),
40 m_etaWidth(iConfig.getParameter<
int>(
"etaWidth")),
41 m_maxSelectedNumPerRing(iConfig.getParameter<
int>(
"maxNumPerRing")),
42 m_minCoeff(iConfig.getParameter<double>(
"minCoeff")),
43 m_maxCoeff(iConfig.getParameter<double>(
"maxCoeff")),
44 m_usingBlockSolver(iConfig.getParameter<
int>(
"usingBlockSolver")),
45 m_startRing(iConfig.getParameter<
int>(
"startRing")),
46 m_endRing(iConfig.getParameter<
int>(
"endRing")),
47 m_EBcoeffFile(iConfig.getParameter<
std::
string>(
"EBcoeffs")),
48 m_EEcoeffFile(iConfig.getParameter<
std::
string>(
"EEcoeffs")),
49 m_EEZone(iConfig.getParameter<
int>(
"EEZone")) {
54 assert(!((
m_etaEnd - m_etaStart - 1) % m_etaWidth));
56 assert(m_etaStart >= -85 && m_etaStart <= 86);
66 edm::LogInfo(
"IML") <<
"[InvRingCalib][ctor] Calib Block";
72 if (algorithm ==
"IMA")
74 else if (algorithm ==
"L3")
77 edm::LogError(
"building") << algorithm <<
" is not a valid calibration algorithm";
87 for (
int i = 0;
i < EEBlocks; ++
i) {
88 if (algorithm ==
"IMA")
90 else if (algorithm ==
"L3")
93 edm::LogError(
"building") << algorithm <<
" is not a valid calibration algorithm";
97 edm::LogInfo(
"IML") <<
" [InvRingCalib][ctor] end of creator";
114 edm::LogInfo(
"IML") <<
"[InvMatrixCalibLooper][Start] entering loop " << ciclo;
115 for (std::vector<VEcalCalibBlock*>::iterator calibBlock =
m_IMACalibBlocks.begin();
119 (*calibBlock)->reset();
136 edm::LogInfo(
"IML") <<
"[InvRingCalib] Event Setup read";
141 edm::LogInfo(
"IML") <<
"[InvRingCalib] Defining Barrel Regions";
144 edm::LogInfo(
"IML") <<
"[InvRingCalib] Defining endcap Rings";
147 edm::LogInfo(
"IML") <<
"[InvRingCalib] Defining endcap Regions";
167 edm::LogInfo(
"IML") <<
"[InvRingCalib] Initializing the coeffs";
170 TH2F EBRegion(
"EBRegion",
"EBRegion", 171, -85, 86, 360, 1, 361);
171 TH2F EBRing(
"EBRing",
"EBRing", 171, -85, 86, 360, 1, 361);
178 TH2F EEPRegion(
"EEPRegion",
"EEPRegion", 100, 1, 101, 100, 1, 101);
179 TH2F EEPRing(
"EEPRing",
"EEPRing", 100, 1, 101, 100, 1, 101);
180 TH2F EEPRingReg(
"EEPRingReg",
"EEPRingReg", 100, 1, 101, 100, 1, 101);
181 TH2F EEMRegion(
"EEMRegion",
"EEMRegion", 100, 1, 101, 100, 1, 101);
182 TH2F EEMRing(
"EEMRing",
"EEMRing", 100, 1, 101, 100, 1, 101);
183 TH2F EEMRingReg(
"EEMRingReg",
"EEMRingReg", 100, 1, 101, 100, 1, 101);
187 if (ee.
zside() > 0) {
192 if (ee.
zside() < 0) {
202 TFile
out(
"EBZone.root",
"recreate");
213 edm::LogInfo(
"IML") <<
"[InvRingCalib] Start to acquire the coeffs";
233 double pSubtract = 0.;
238 barrelHitsCollection = barrelRecHitsHandle.
product();
240 if (!barrelRecHitsHandle.
isValid()) {
241 edm::LogError(
"IML") <<
"[EcalEleCalibLooper] barrel rec hits not found";
248 endcapHitsCollection = endcapRecHitsHandle.
product();
250 if (!endcapRecHitsHandle.
isValid()) {
251 edm::LogError(
"IML") <<
"[EcalEleCalibLooper] endcap rec hits not found";
260 edm::LogError(
"IML") <<
"[EcalEleCalibLooper] electrons not found";
265 for (reco::GsfElectronCollection::const_iterator eleIt = pElectrons->begin(); eleIt != pElectrons->end(); ++eleIt) {
267 pTk = eleIt->trackMomentumAtVtx().R();
268 std::map<int, double> xtlMap;
271 Max = EcalClusterTools::getMaximum(eleIt->superCluster()->hitsAndFractions(), barrelHitsCollection).
first;
273 Max = EcalClusterTools::getMaximum(eleIt->superCluster()->hitsAndFractions(), endcapHitsCollection).
first;
277 eleIt->superCluster()->hitsAndFractions(),
Max, barrelHitsCollection, endcapHitsCollection, xtlMap, pSubtract);
280 pSubtract += eleIt->superCluster()->preshowerEnergy();
292 std::map<int, double> InterRings;
293 edm::LogInfo(
"IML") <<
"[InvMatrixCalibLooper][endOfLoop] Start to invert the matrixes";
295 for (std::vector<VEcalCalibBlock*>::iterator calibBlock =
m_IMACalibBlocks.begin();
300 edm::LogInfo(
"IML") <<
"[InvRingLooper][endOfLoop] Starting to write the coeffs";
301 TH1F* coeffDistr =
new TH1F(
"coeffdistr",
"coeffdistr", 100, 0.7, 1.4);
302 TH1F*
coeffMap =
new TH1F(
"coeffRingMap",
"coeffRingMap", 250, -85, 165);
303 TH1F* ringDistr =
new TH1F(
"ringDistr",
"ringDistr", 250, -85, 165);
304 TH1F* RingFill =
new TH1F(
"RingFill",
"RingFill", 250, -85, 165);
306 ringDistr->Fill(it->second + 0.1);
309 std::map<int, int>
flag;
311 flag[it->second] = 0;
322 coeffMap->Fill(m_xtalRing[ID] + 0.1, InterRings[m_xtalRing[ID]]);
323 coeffDistr->Fill(InterRings[m_xtalRing[ID]]);
335 coeffMap->Fill(m_xtalRing[ID], InterRings[m_xtalRing[ID]]);
336 coeffDistr->Fill(InterRings[m_xtalRing[ID]]);
340 sprintf(filename,
"coeff%d.root", iCounter);
341 TFile
out(filename,
"recreate");
362 edm::LogInfo(
"IML") <<
"[InvMatrixCalibLooper][endOfJob] saving calib coeffs";
405 auto cellGeometry = endcapGeometry->
getGeometry(*endcapIt);
406 m_cellPos[endcapIt->rawId()] = cellGeometry->getPosition();
407 m_cellPhi[endcapIt->rawId()] = cellGeometry->getPosition().phi();
417 double etaBonduary[40];
418 etaBonduary[0] = 1.49;
419 etaBonduary[39] = 4.0;
421 etaBonduary[
ring] = (eta_ring[
ring] + eta_ring[
ring - 1]) / 2.;
427 if (fabs(
m_cellPos[endcapIt->rawId()].eta()) > etaBonduary[
ring] &&
428 fabs(
m_cellPos[endcapIt->rawId()].eta()) < etaBonduary[
ring + 1]) {
496 reg =
EERegId(endcapIt->rawId());
539 if (ieta < m_etaStart || ieta >=
m_etaEnd)
542 return (
m_Reg[ieta]);
T getParameter(std::string const &) const
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
T getUntrackedParameter(std::string const &, T const &) const
virtual void fillMap(const std::vector< std::pair< DetId, float > > &, const DetId, const EcalRecHitCollection *, const EcalRecHitCollection *, std::map< int, double > &xtlMap, double &)=0
The Map filler.
edm::InputTag m_ElectronLabel
To take the electrons.
void startingNewLoop(unsigned int) override
startingNewLoop
void EERingDef(const edm::EventSetup &)
Defines the rins in the endcap.
std::map< int, int > m_xtalRegionId
association map between raw detIds and Region
int EBRegionNum() const
Number of regions in EB.
void EBRegionDef()
Defines the regions in the barrel.
double m_maxCoeff
maximum coefficient accepted (RAW)
const self & getMap() const
std::string m_EEcoeffFile
InvRingCalib(const edm::ParameterSet &)
ctor
double m_minEnergyPerCrystal
minimum energy per crystal cut
int m_EEZone
endcap zone to be calibrated
constexpr uint32_t rawId() const
get the raw id
bool parseXMLMiscalibFile(std::string configFile)
EcalIntercalibConstantMap m_endcapMap
void EERegionDef()
Defines the regions in the endcap.
void beginOfJob() override
BeginOfJob.
double m_maxEnergyPerCrystal
maximum energy per crystal cut
std::vector< VEcalCalibBlock * > m_IMACalibBlocks
single blocks calibrators
Status duringLoop(const edm::Event &, const edm::EventSetup &) override
duringLoop
int EERegId(int)
gives back in which region of the endcap you are.
int m_etaStart
eta start of the zone of interest
Status endOfLoop(const edm::EventSetup &, unsigned int iCounter) override
int iphi() const
get the crystal iphi
EcalIntercalibConstantMap m_barrelMap
std::map< int, GlobalPoint > m_cellPos
position of the cell, borders, coords etc...
edm::InputTag m_endcapAlCa
EcalEndcap Input Collection name.
VFillMap * m_MapFiller
The class that fills the map!
const EcalIntercalibConstants & get()
std::map< int, int > m_Reg
EB regions vs. eta index.
std::vector< DetId > m_barrelCells
geometry things used all over the file
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
std::map< int, int > m_RinginRegion
association map between raw detIds and the number of the ring inside the region
int m_startRing
LP define the EE region to calibrate.
interface to the L3Univ class for testing
~InvRingCalib() override
dtor
Abs< T >::type abs(const T &t)
void RegPrepare()
Prepares the EB regions;.
int m_etaWidth
eta size of the regions
int ieta() const
get the crystal ieta
unsigned int m_loops
LP sets the number of loops to do.
int m_usingBlockSolver
to exclude the blocksolver
edm::InputTag m_barrelAlCa
EcalBarrel Input Collection name.
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
int m_etaEnd
eta end of the zone of interest
std::map< int, int > m_xtalRing
association map between Raw detIds and Rings
T const * product() const
virtual std::shared_ptr< const CaloCellGeometry > getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
static bool validDetId(int crystal_ix, int crystal_iy, int iz)
std::vector< DetId > getValidDetIds() const
Get the list of all valid detector ids.
double m_minCoeff
minimum coefficient accepted (RAW)
std::map< int, CalibCoeff > coeffMap
void writeLine(EBDetId const &, float)
std::string m_EBcoeffFile
coeffs filenames
std::map< int, int > m_cellPhi
int m_recoWindowSidex
reconstruction window size
std::vector< DetId > m_endcapCells
std::map< int, int > m_RingNumOfHits
number of events already read per Ring
T const * product() const
std::string m_mapFillerType
int EBRegId(const int)
Gives back in which region you are:
int EERegionNum() const
The number of regions in EE.