33 : theMaxLoops(iConfig.getUntrackedParameter<unsigned int>(
"maxLoops", 0)),
34 ecalHitsProducer_(iConfig.getParameter<std::
string>(
"ecalRecHitsProducer")),
35 barrelHits_(iConfig.getParameter<std::
string>(
"barrelHitCollection")),
39 std::cout <<
"[Pi0FixedMassWindowCalibration] Constructor " << std::endl;
42 if (verbosityString ==
"DEBUG")
44 else if (verbosityString ==
"WARNING")
46 else if (verbosityString ==
"INFO")
55 double barrelSeedThreshold = iConfig.
getParameter<
double>(
"IslandBarrelSeedThr");
56 double endcapSeedThreshold = iConfig.
getParameter<
double>(
"IslandEndcapSeedThr");
86 const std::vector<std::string> seedflagnamesEB =
87 iConfig.
getParameter<std::vector<std::string>>(
"SeedRecHitFlagToBeExcludedEB");
88 const std::vector<int> seedflagsexclEB = StringToEnumValue<EcalRecHit::Flags>(seedflagnamesEB);
90 const std::vector<std::string> seedflagnamesEE =
91 iConfig.
getParameter<std::vector<std::string>>(
"SeedRecHitFlagToBeExcludedEE");
92 const std::vector<int> seedflagsexclEE = StringToEnumValue<EcalRecHit::Flags>(seedflagnamesEE);
94 const std::vector<std::string> flagnamesEB =
95 iConfig.
getParameter<std::vector<std::string>>(
"RecHitFlagToBeExcludedEB");
96 const std::vector<int> flagsexclEB = StringToEnumValue<EcalRecHit::Flags>(flagnamesEB);
98 const std::vector<std::string> flagnamesEE =
99 iConfig.
getParameter<std::vector<std::string>>(
"RecHitFlagToBeExcludedEE");
100 const std::vector<int> flagsexclEE = StringToEnumValue<EcalRecHit::Flags>(flagnamesEE);
122 desc.
add<
unsigned int>(
"maxLoops", 0);
129 desc.
add<
double>(
"IslandBarrelSeedThr", 0);
130 desc.
add<
double>(
"IslandEndcapSeedThr", 0);
132 desc.
add<
double>(
"selePi0PtGammaOneMin", 0);
133 desc.
add<
double>(
"selePi0PtGammaTwoMin", 0);
135 desc.
add<
double>(
"selePi0DRBelt", 0);
136 desc.
add<
double>(
"selePi0DetaBelt", 0);
138 desc.
add<
double>(
"selePi0PtPi0Min", 0);
140 desc.
add<
double>(
"selePi0S4S9GammaOneMin", 0);
141 desc.
add<
double>(
"selePi0S4S9GammaTwoMin", 0);
142 desc.
add<
double>(
"selePi0S9S25GammaOneMin", 0);
143 desc.
add<
double>(
"selePi0S9S25GammaTwoMin", 0);
145 desc.
add<
double>(
"selePi0EtBeltIsoRatioMax", 0);
147 desc.
add<
double>(
"selePi0MinvMeanFixed", 0);
148 desc.
add<
double>(
"selePi0MinvSigmaFixed", 0);
151 posCalcParameters.add<
bool>(
"LogWeighted",
true);
152 posCalcParameters.add<
double>(
"T0_barl", 7.4);
153 posCalcParameters.add<
double>(
"T0_endc", 3.1);
154 posCalcParameters.add<
double>(
"T0_endcPresh", 1.2);
155 posCalcParameters.add<
double>(
"W0", 4.2);
156 posCalcParameters.add<
double>(
"X0", 0.89);
159 desc.
add<
std::string>(
"clustershapecollectionEB",
"islandBarrelShape");
160 desc.
add<
std::string>(
"barrelShapeAssociation",
"islandBarrelShapeAssoc");
162 desc.
add<std::vector<std::string>>(
"SeedRecHitFlagToBeExcludedEB", {});
163 desc.
add<std::vector<std::string>>(
"SeedRecHitFlagToBeExcludedEE", {});
164 desc.
add<std::vector<std::string>>(
"RecHitFlagToBeExcludedEB", {});
165 desc.
add<std::vector<std::string>>(
"RecHitFlagToBeExcludedEE", {});
167 descriptions.
add(
"Pi0FixedMassWindowCalibration", desc);
180 std::cout <<
"[Pi0FixedMassWindowCalibration] endOfJob" << endl;
186 std::vector<DetId>::const_iterator barrelIt =
barrelCells.begin();
187 for (; barrelIt !=
barrelCells.end(); barrelIt++) {
189 int ieta = eb.
ieta();
190 int iphi = eb.
iphi();
200 for (
int ieta = 0; ieta < 85; ieta++) {
201 for (
int iphi = 0; iphi < 360; iphi++) {
207 std::cout <<
"[Pi0FixedMassWindowCalibration] Starting loop number " << iLoop << std::endl;
214 std::cout <<
"[Pi0FixedMassWindowCalibration] Ending loop " << iLoop << std::endl;
217 for (
int ieta = 0; ieta < 85; ieta++) {
218 for (
int iphi = 0; iphi < 360; iphi++) {
225 cout <<
" New calibration constant: ieta iphi sign - old,mwxtals,wxtals,new: " << ieta <<
" " << iphi <<
" "
234 std::vector<DetId>::const_iterator barrelIt =
barrelCells.begin();
235 for (; barrelIt !=
barrelCells.end(); barrelIt++) {
237 int ieta = eb.
ieta();
238 int iphi = eb.
iphi();
242 std::cout <<
"Calib constant for barrel crystal "
251 for (
int ieta = 0; ieta < 85; ieta++) {
252 for (
int iphi = 0; iphi < 360; iphi++) {
282 for (
int ieta = 0; ieta < 85; ieta++) {
283 for (
int iphi = 0; iphi < 360; iphi++) {
295 const auto& imap = pIcal.getMap();
296 std::cout <<
"imap.size() = " << imap.size() << std::endl;
300 std::vector<DetId>::const_iterator barrelIt;
306 if (itcalib == imap.end()) {
313 std::cout <<
"Read old constant for crystal "
314 <<
" (" << eb.
ieta() <<
"," << eb.
iphi() <<
") : " << calib << std::endl;
324 std::cout <<
"[Pi0FixedMassWindowCalibration] Events processed: " <<
nevent << std::endl;
332 event.getByToken(
recHitToken_, pEcalRecHitBarrelCollection);
340 EBDetId ebrhdetid = aRecHitEB->detid();
345 int sign = ebrhdetid.
zside() > 0 ? 1 : 0;
349 recalibEcalRecHitCollection->push_back(aHit);
357 aRecHitEB != recalibEcalRecHitCollection->end();
366 std::pair<DetId, EcalRecHit> map_entry(aRecHitEB->id(), *aRecHitEB);
412 std::vector<reco::ClusterShape> ClusVec_recalib;
413 for (
int erg = 0; erg < int(clusters_recalib.size()); ++erg) {
415 shapeAlgo_.
Calculate(clusters_recalib[erg], recalibEcalRecHitCollection, geometry_p, &topology);
416 ClusVec_recalib.push_back(TestShape_recalib);
421 clustersshapes_p_recalib->assign(ClusVec_recalib.begin(), ClusVec_recalib.end());
423 cout <<
"[Pi0FixedMassWindowCalibration][recalibration] Basic Cluster collection size: " << clusters_recalib.size()
425 cout <<
"[Pi0FixedMassWindowCalibration][recalibration] Basic Cluster Shape Collection size: "
426 << clustersshapes_p_recalib->size() << endl;
432 static const int MAXBCEB = 200;
433 static const int MAXBCEBRH = 200;
435 float eIslandBCEB[MAXBCEB];
436 float etIslandBCEB[MAXBCEB];
437 float etaIslandBCEB[MAXBCEB];
438 float phiIslandBCEB[MAXBCEB];
439 float e2x2IslandBCEB[MAXBCEB];
440 float e3x3IslandBCEB[MAXBCEB];
441 float e5x5IslandBCEB[MAXBCEB];
444 int nIslandBCEBRecHits[MAXBCEB];
446 int ietaIslandBCEBRecHits[MAXBCEB][MAXBCEBRH];
447 int iphiIslandBCEBRecHits[MAXBCEB][MAXBCEBRH];
448 int zsideIslandBCEBRecHits[MAXBCEB][MAXBCEBRH];
449 float eIslandBCEBRecHits[MAXBCEB][MAXBCEBRH];
452 for (
int i = 0;
i < MAXBCEB;
i++) {
455 etaIslandBCEB[
i] = 0;
456 phiIslandBCEB[
i] = 0;
457 e2x2IslandBCEB[
i] = 0;
458 e3x3IslandBCEB[
i] = 0;
459 e5x5IslandBCEB[
i] = 0;
460 nIslandBCEBRecHits[
i] = 0;
461 for (
int j = 0;
j < MAXBCEBRH;
j++) {
463 ietaIslandBCEBRecHits[
i][
j] = 0;
464 iphiIslandBCEBRecHits[
i][
j] = 0;
465 zsideIslandBCEBRecHits[
i][
j] = 0;
466 eIslandBCEBRecHits[
i][
j] = 0;
470 int iClus_recalib = 0;
471 for (reco::BasicClusterCollection::const_iterator aClus = clusters_recalib.begin(); aClus != clusters_recalib.end();
473 cout <<
" CLUSTER [recalibration] : #,NHits,e,et,eta,phi,e2x2,e3x3,e5x5: " << iClus_recalib <<
" " << aClus->size()
474 <<
" " << aClus->energy() <<
" " << aClus->energy() *
sin(aClus->position().theta()) <<
" "
475 << aClus->position().eta() <<
" " << aClus->position().phi() <<
" "
476 << (*clustersshapes_p_recalib)[iClus_recalib].e2x2() <<
" "
477 << (*clustersshapes_p_recalib)[iClus_recalib].e3x3() <<
" "
478 << (*clustersshapes_p_recalib)[iClus_recalib].e5x5() << endl;
480 eIslandBCEB[nIslandBCEB] = aClus->energy();
481 etIslandBCEB[nIslandBCEB] = aClus->energy() *
sin(aClus->position().theta());
482 etaIslandBCEB[nIslandBCEB] = aClus->position().eta();
483 phiIslandBCEB[nIslandBCEB] = aClus->position().phi();
485 e2x2IslandBCEB[nIslandBCEB] = (*clustersshapes_p_recalib)[nIslandBCEB].e2x2();
486 e3x3IslandBCEB[nIslandBCEB] = (*clustersshapes_p_recalib)[nIslandBCEB].e3x3();
487 e5x5IslandBCEB[nIslandBCEB] = (*clustersshapes_p_recalib)[nIslandBCEB].e5x5();
489 nIslandBCEBRecHits[nIslandBCEB] = aClus->size();
491 std::vector<std::pair<DetId, float>> hits = aClus->hitsAndFractions();
492 std::vector<std::pair<DetId, float>>::iterator
hit;
493 std::map<DetId, EcalRecHit>::iterator aHit;
496 for (hit = hits.begin(); hit != hits.end(); hit++) {
501 EBDetId sel_rh = aHit->second.detid();
506 ietaIslandBCEBRecHits[nIslandBCEB][irhcount] = sel_rh.
ieta();
507 iphiIslandBCEBRecHits[nIslandBCEB][irhcount] = sel_rh.
iphi();
508 zsideIslandBCEBRecHits[nIslandBCEB][irhcount] = sel_rh.
zside();
509 eIslandBCEBRecHits[nIslandBCEB][irhcount] = aHit->second.energy();
519 if (nIslandBCEB > 1) {
520 for (
int i = 0;
i < nIslandBCEB;
i++) {
521 for (
int j =
i + 1;
j < nIslandBCEB;
j++) {
523 float theta_0 = 2. * atan(
exp(-etaIslandBCEB[
i]));
524 float theta_1 = 2. * atan(
exp(-etaIslandBCEB[
j]));
526 float p0x = eIslandBCEB[
i] *
sin(theta_0) *
cos(phiIslandBCEB[i]);
527 float p1x = eIslandBCEB[
j] *
sin(theta_1) *
cos(phiIslandBCEB[j]);
529 float p0y = eIslandBCEB[
i] *
sin(theta_0) *
sin(phiIslandBCEB[i]);
530 float p1y = eIslandBCEB[
j] *
sin(theta_1) *
sin(phiIslandBCEB[j]);
532 float p0z = eIslandBCEB[
i] *
cos(theta_0);
533 float p1z = eIslandBCEB[
j] *
cos(theta_1);
535 float pi0_px = p0x + p1x;
536 float pi0_py = p0y + p1y;
537 float pi0_pz = p0z + p1z;
539 float pi0_ptot =
sqrt(pi0_px * pi0_px + pi0_py * pi0_py + pi0_pz * pi0_pz);
541 float pi0_theta = acos(pi0_pz / pi0_ptot);
542 float pi0_eta = -
log(
tan(pi0_theta / 2));
543 float pi0_phi = atan(pi0_py / pi0_px);
549 for (Int_t
k = 0;
k < nIslandBCEB;
k++) {
550 if ((
k != i) && (
k != j)) {
551 float dr_pi0_k =
sqrt((etaIslandBCEB[
k] - pi0_eta) * (etaIslandBCEB[
k] - pi0_eta) +
552 (phiIslandBCEB[
k] - pi0_phi) * (phiIslandBCEB[
k] - pi0_phi));
553 float deta_pi0_k = fabs(etaIslandBCEB[
k] - pi0_eta);
555 et_belt = et_belt + etIslandBCEB[
k];
559 float pt_pi0 =
sqrt((p0x + p1x) * (p0x + p1x) + (p0y + p1y) * (p0y + p1y));
564 float m_inv =
sqrt((eIslandBCEB[i] + eIslandBCEB[j]) * (eIslandBCEB[i] + eIslandBCEB[j]) -
565 (p0x + p1x) * (p0x + p1x) - (p0y + p1y) * (p0y + p1y) - (p0z + p1z) * (p0z + p1z));
566 cout <<
" pi0 (pt>2.5 GeV) m_inv = " << m_inv << endl;
568 float s4s9_1 = e2x2IslandBCEB[
i] / e3x3IslandBCEB[
i];
569 float s4s9_2 = e2x2IslandBCEB[
j] / e3x3IslandBCEB[
j];
571 float s9s25_1 = e3x3IslandBCEB[
i] / e5x5IslandBCEB[
i];
572 float s9s25_2 = e3x3IslandBCEB[
j] / e5x5IslandBCEB[
j];
584 cout <<
" Pi0 Good candidate : minv = " << m_inv << endl;
585 for (
int kk = 0;
kk < nIslandBCEBRecHits[
i];
kk++) {
586 int ieta_xtal = ietaIslandBCEBRecHits[
i][
kk];
587 int iphi_xtal = iphiIslandBCEBRecHits[
i][
kk];
588 int sign = zsideIslandBCEBRecHits[
i][
kk] > 0 ? 1 : 0;
590 wxtals[
abs(ieta_xtal) - 1][iphi_xtal - 1][
sign] + eIslandBCEBRecHits[
i][
kk] / e3x3IslandBCEB[
i];
594 (eIslandBCEBRecHits[
i][
kk] / e3x3IslandBCEB[
i]);
595 cout <<
"[Pi0FixedMassWindowCalibration] eta, phi, sign, e, e3x3, wxtals and mwxtals: " << ieta_xtal
596 <<
" " << iphi_xtal <<
" " << sign <<
" " << eIslandBCEBRecHits[
i][
kk] <<
" "
597 << e3x3IslandBCEB[
i] <<
" " <<
wxtals[
abs(ieta_xtal) - 1][iphi_xtal - 1][
sign] <<
" "
601 for (
int kk = 0;
kk < nIslandBCEBRecHits[
j];
kk++) {
602 int ieta_xtal = ietaIslandBCEBRecHits[
j][
kk];
603 int iphi_xtal = iphiIslandBCEBRecHits[
j][
kk];
604 int sign = zsideIslandBCEBRecHits[
j][
kk] > 0 ? 1 : 0;
606 wxtals[
abs(ieta_xtal) - 1][iphi_xtal - 1][
sign] + eIslandBCEBRecHits[
j][
kk] / e3x3IslandBCEB[
j];
610 (eIslandBCEBRecHits[
j][
kk] / e3x3IslandBCEB[
j]);
611 cout <<
"[Pi0FixedMassWindowCalibration] eta, phi, sign, e, e3x3, wxtals and mwxtals: " << ieta_xtal
612 <<
" " << iphi_xtal <<
" " << sign <<
" " << eIslandBCEBRecHits[
j][
kk] <<
" "
613 << e3x3IslandBCEB[
j] <<
" " <<
wxtals[
abs(ieta_xtal) - 1][iphi_xtal - 1][
sign] <<
" "
625 cout <<
" Not enough ECAL Barrel Basic Clusters: " << nIslandBCEB << endl;
double selePi0PtGammaTwoMin_
edm::ParameterSet theParameterSet
void startingNewLoop(unsigned int iLoop) override
Called at beginning of loop.
void beginOfJob() override
Called at beginning of job.
static std::vector< std::string > checklist log
const edm::ESGetToken< CaloGeometry, CaloGeometryRecord > geometryToken_
std::string clustershapecollectionEB_
const edm::ESGetToken< EcalIntercalibConstants, EcalIntercalibConstantsRcd > intercalibConstantsToken_
double selePi0S9S25GammaOneMin_
Status endOfLoop(const edm::EventSetup &, unsigned int iLoop) override
Called at end of loop.
void writeLine(EBDetId const &, float)
Sin< T >::type sin(const T &t)
std::vector< DetId > barrelCells
double selePi0S4S9GammaOneMin_
const unsigned int theMaxLoops
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
constexpr uint32_t rawId() const
get the raw id
std::vector< EcalRecHit >::const_iterator const_iterator
std::vector< ClusterShape > ClusterShapeCollection
collection of ClusterShape objects
Exp< T >::type exp(const T &t)
IslandClusterAlgo::VerbosityLevel verbosity
PositionCalc posCalculator_
int iphi() const
get the crystal iphi
bool getData(T &iHolder) const
double selePi0PtGammaOneMin_
reco::ClusterShape Calculate(const reco::BasicCluster &passedCluster, const EcalRecHitCollection *hits, const CaloSubdetectorGeometry *geometry, const CaloSubdetectorTopology *topology)
double selePi0MinvMeanFixed_
std::string barrelClusterCollection_
Cos< T >::type cos(const T &t)
Tan< T >::type tan(const T &t)
double selePi0MinvSigmaFixed_
Abs< T >::type abs(const T &t)
double selePi0S9S25GammaTwoMin_
int ieta() const
get the crystal ieta
ParameterDescriptionBase * add(U const &iLabel, T const &value)
const EcalRecHitCollection * ecalRecHitBarrelCollection
const_iterator end() const
const edm::EDGetTokenT< EcalRecHitCollection > recHitToken_
double newCalibs_barl[85][360][2]
std::vector< reco::BasicCluster > makeClusters(const EcalRecHitCollection *hits, const CaloSubdetectorGeometry *geometry, const CaloSubdetectorTopology *topology_p, const CaloSubdetectorGeometry *geometryES_p, EcalPart ecalPart, bool regional=false, const std::vector< RectangularEtaPhiRegion > ®ions=std::vector< RectangularEtaPhiRegion >())
double selePi0EtBeltIsoRatioMax_
std::vector< Item >::const_iterator const_iterator
Status duringLoop(const edm::Event &, const edm::EventSetup &) override
Called at each event.
T getParameter(std::string const &) const
double selePi0S4S9GammaTwoMin_
void add(std::string const &label, ParameterSetDescription const &psetDescription)
std::vector< BasicCluster > BasicClusterCollection
collection of BasicCluster objects
std::string barrelClusterShapeAssociation_
IslandClusterAlgo * island_p
double mwxtals[85][360][2]
double oldCalibs_barl[85][360][2]
std::map< DetId, EcalRecHit > * recHitsEB_map
Pi0FixedMassWindowCalibration(const edm::ParameterSet &iConfig)
Constructor.
~Pi0FixedMassWindowCalibration() override
Destructor.
const EcalRecHitCollection * recalibEcalRecHitCollection
void endOfJob() override
Called at end of job.
const_iterator begin() const
ClusterShapeAlgo shapeAlgo_
int zside() const
get the z-side of the crystal (1/-1)
float EcalIntercalibConstant
double wxtals[85][360][2]