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"))
55 assert (!((
m_etaEnd - m_etaStart-1 )%m_etaWidth));
57 assert (m_etaStart >=-85 && m_etaStart <= 86);
67 edm::LogInfo (
"IML") <<
"[InvRingCalib][ctor] Calib Block" ;
74 if (algorithm ==
"IMA")
78 else if (algorithm ==
"L3")
85 <<
" is not a valid calibration algorithm" ;
93 for (
int i = 0;
i < EEBlocks ; ++
i)
96 if (algorithm ==
"IMA")
100 else if (algorithm ==
"L3")
107 <<
" is not a valid calibration algorithm" ;
111 edm::LogInfo (
"IML") <<
" [InvRingCalib][ctor] end of creator";
144 edm::LogInfo (
"IML") <<
"[InvMatrixCalibLooper][Start] entering loop " << ciclo;
145 for (std::vector<VEcalCalibBlock *>::iterator calibBlock =
m_IMACalibBlocks.begin () ;
150 (*calibBlock)->reset () ;
176 edm::LogInfo (
"IML") <<
"[InvRingCalib] Event Setup read";
181 edm::LogInfo (
"IML") <<
"[InvRingCalib] Defining Barrel Regions";
184 edm::LogInfo (
"IML") <<
"[InvRingCalib] Defining endcap Rings";
187 edm::LogInfo (
"IML") <<
"[InvRingCalib] Defining endcap Regions";
201 edm::LogInfo (
"IML") <<
"[InvRingCalib] Initializing the coeffs";
204 TH2F EBRegion (
"EBRegion",
"EBRegion",171,-85,86,360,1,361);
205 TH2F EBRing (
"EBRing",
"EBRing",171,-85,86,360,1,361);
206 for (std::vector<DetId>::const_iterator it=
m_barrelCells.begin();
215 TH2F EEPRegion (
"EEPRegion",
"EEPRegion",100,1,101,100,1,101);
216 TH2F EEPRing (
"EEPRing",
"EEPRing",100,1,101,100,1,101);
217 TH2F EEPRingReg (
"EEPRingReg",
"EEPRingReg",100,1,101,100,1,101);
218 TH2F EEMRegion (
"EEMRegion",
"EEMRegion",100,1,101,100,1,101);
219 TH2F EEMRing (
"EEMRing",
"EEMRing",100,1,101,100,1,101);
220 TH2F EEMRingReg (
"EEMRingReg",
"EEMRingReg",100,1,101,100,1,101);
222 for (std::vector<DetId>::const_iterator it =
m_endcapCells.begin();
244 TFile
out (
"EBZone.root",
"recreate");
255 edm::LogInfo (
"IML") <<
"[InvRingCalib] Start to acquire the coeffs";
278 double pSubtract = 0.;
283 barrelHitsCollection = barrelRecHitsHandle.
product() ;
285 if (!barrelRecHitsHandle.
isValid ()) {
286 edm::LogError (
"IML") <<
"[EcalEleCalibLooper] barrel rec hits not found" ;
293 endcapHitsCollection = endcapRecHitsHandle.
product() ;
295 if (!endcapRecHitsHandle.
isValid ()) {
296 edm::LogError (
"IML") <<
"[EcalEleCalibLooper] endcap rec hits not found" ;
305 edm::LogError (
"IML")<<
"[EcalEleCalibLooper] electrons not found" ;
310 for (reco::GsfElectronCollection::const_iterator eleIt = pElectrons->begin();
311 eleIt != pElectrons->end();
315 pTk=eleIt->trackMomentumAtVtx().R();
316 std::map<int , double> xtlMap;
319 Max = EcalClusterTools::getMaximum(eleIt->superCluster()->hitsAndFractions(),barrelHitsCollection).
first;
321 Max = EcalClusterTools::getMaximum(eleIt->superCluster()->hitsAndFractions(),endcapHitsCollection).
first;
322 if (Max.det()==0)
continue;
324 barrelHitsCollection,endcapHitsCollection, xtlMap,pSubtract);
326 pSubtract += eleIt->superCluster()->preshowerEnergy() ;
330 xtlMap.begin(), xtlMap.end(),pTk,pSubtract
343 unsigned int iCounter)
345 std::map<int,double> InterRings;
346 edm::LogInfo (
"IML") <<
"[InvMatrixCalibLooper][endOfLoop] Start to invert the matrixes" ;
348 for (std::vector<VEcalCalibBlock *>::iterator calibBlock=
m_IMACalibBlocks.begin();
353 edm::LogInfo(
"IML") <<
"[InvRingLooper][endOfLoop] Starting to write the coeffs";
354 TH1F *coeffDistr =
new TH1F(
"coeffdistr",
"coeffdistr",100 ,0.7,1.4);
355 TH1F *
coeffMap =
new TH1F(
"coeffRingMap",
"coeffRingMap",250,-85,165);
356 TH1F *ringDistr =
new TH1F(
"ringDistr",
"ringDistr",250,-85,165);
357 TH1F *RingFill =
new TH1F(
"RingFill",
"RingFill",250,-85,165);
358 for(std::map<int,int>::const_iterator it=
m_xtalRing.begin();
361 ringDistr->Fill(it->second+0.1);
364 std::map<int,int>
flag;
365 for(std::map<int,int>::const_iterator it=
m_xtalRing.begin();
370 for (std::vector<DetId>::const_iterator it=
m_barrelCells.begin();
380 coeffMap->Fill (m_xtalRing[ID]+0.1,InterRings[m_xtalRing[ID]]);
381 coeffDistr->Fill(InterRings[m_xtalRing[ID]]);
384 for (std::vector<DetId>::const_iterator it=
m_endcapCells.begin();
394 coeffMap->Fill (m_xtalRing[ID],InterRings[m_xtalRing[ID]]);
395 coeffDistr->Fill(InterRings[m_xtalRing[ID]]);
400 sprintf(filename,
"coeff%d.root",iCounter);
401 TFile
out(filename,
"recreate");
407 for (std::vector<DetId>::const_iterator it=
m_barrelCells.begin();
412 for (std::vector<DetId>::const_iterator it=
m_endcapCells.begin();
429 edm::LogInfo (
"IML") <<
"[InvMatrixCalibLooper][endOfJob] saving calib coeffs" ;
432 for (std::vector<DetId>::const_iterator barrelIt =
m_barrelCells.begin();
438 for (std::vector<DetId>::const_iterator endcapIt =
m_endcapCells.begin();
475 for (std::vector<DetId>::const_iterator endcapIt =
m_endcapCells.begin();
478 auto cellGeometry = endcapGeometry->
getGeometry(*endcapIt);
479 m_cellPos[endcapIt->rawId()] = cellGeometry->getPosition();
480 m_cellPhi[endcapIt->rawId()] = cellGeometry->getPosition().phi();
490 double etaBonduary[40];
498 for (std::vector<DetId>::const_iterator endcapIt=
m_endcapCells.begin();
500 if (fabs(
m_cellPos[endcapIt->rawId()].eta())>etaBonduary[
ring] &&
501 fabs(
m_cellPos[endcapIt->rawId()].eta())<etaBonduary[
ring+1])
505 else CRing =
ring + 125;
527 if (ee.
zside()<0)
return -1;
536 if (ee.
zside()>0)
return -1;
558 for (std::vector<DetId>::const_iterator endcapIt=
m_endcapCells.begin();
561 reg =
EERegId(endcapIt->rawId());
611 if (ieta<m_etaStart || ieta>=
m_etaEnd)
return -1;
612 else return (
m_Reg[ieta]);
623 for (std::vector<DetId>::const_iterator it=
m_barrelCells.begin();
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.
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
std::map< int, int > m_cellPhi
constexpr uint32_t rawId() const
get the raw id
bool parseXMLMiscalibFile(std::string configFile)
std::map< int, GlobalPoint > m_cellPos
position of the cell, borders, coords etc...
EcalIntercalibConstantMap m_endcapMap
void EERegionDef()
Defines the regions in the endcap.
std::map< int, int > m_Reg
EB regions vs. eta index.
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, int > m_RingNumOfHits
number of events already read per Ring
std::map< int, int > m_xtalRegionId
association map between raw detIds and Region
edm::InputTag m_endcapAlCa
EcalEndcap Input Collection name.
VFillMap * m_MapFiller
The class that fills the map!
const EcalIntercalibConstants & get()
std::vector< DetId > m_barrelCells
geometry things used all over the file
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
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
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::map< int, CalibCoeff > coeffMap
std::vector< DetId > getValidDetIds() const
Get the list of all valid detector ids.
double m_minCoeff
minimum coefficient accepted (RAW)
void writeLine(EBDetId const &, float)
std::string m_EBcoeffFile
coeffs filenames
int m_recoWindowSidex
reconstruction window size
std::vector< DetId > m_endcapCells
std::map< int, int > m_RinginRegion
association map between raw detIds and the number of the ring inside the region
std::map< int, int > m_xtalRing
association map between Raw detIds and Rings
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.