36 : theMaxLoops(iConfig.getUntrackedParameter<unsigned
int>(
"maxLoops", 0)),
37 ecalHitsProducer_(iConfig.getParameter<
std::
string>(
"ecalRecHitsProducer")),
38 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);
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++) {
207 std::cout <<
"[Pi0FixedMassWindowCalibration] Starting loop number " << iLoop << std::endl;
214 std::cout <<
"[Pi0FixedMassWindowCalibration] Ending loop " << iLoop << std::endl;
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++) {
242 std::cout <<
"Calib constant for barrel crystal "
296 std::cout <<
"Taken EcalIntercalibConstants" << std::endl;
300 std::cerr <<
"Error! can't get EcalIntercalibConstants " << std::endl;
311 std::vector<DetId>::const_iterator barrelIt;
317 if (itcalib == imap.
end()) {
324 std::cout <<
"Read old constant for crystal "
325 <<
" (" << eb.
ieta() <<
"," << eb.
iphi() <<
") : " <<
calib << std::endl;
335 std::cout <<
"[Pi0FixedMassWindowCalibration] Events processed: " <<
nevent << std::endl;
351 EBDetId ebrhdetid = aRecHitEB->detid();
356 int sign = ebrhdetid.
zside() > 0 ? 1 : 0;
377 std::pair<DetId, EcalRecHit> map_entry(aRecHitEB->id(), *aRecHitEB);
427 std::vector<reco::ClusterShape> ClusVec_recalib;
428 for (
int erg = 0; erg <
int(clusters_recalib.size()); ++erg) {
431 ClusVec_recalib.push_back(TestShape_recalib);
436 clustersshapes_p_recalib->assign(ClusVec_recalib.begin(), ClusVec_recalib.end());
438 cout <<
"[Pi0FixedMassWindowCalibration][recalibration] Basic Cluster collection size: " << clusters_recalib.size()
440 cout <<
"[Pi0FixedMassWindowCalibration][recalibration] Basic Cluster Shape Collection size: "
441 << clustersshapes_p_recalib->size() << endl;
447 static const int MAXBCEB = 200;
448 static const int MAXBCEBRH = 200;
450 float eIslandBCEB[MAXBCEB];
451 float etIslandBCEB[MAXBCEB];
452 float etaIslandBCEB[MAXBCEB];
453 float phiIslandBCEB[MAXBCEB];
454 float e2x2IslandBCEB[MAXBCEB];
455 float e3x3IslandBCEB[MAXBCEB];
456 float e5x5IslandBCEB[MAXBCEB];
459 int nIslandBCEBRecHits[MAXBCEB];
461 int ietaIslandBCEBRecHits[MAXBCEB][MAXBCEBRH];
462 int iphiIslandBCEBRecHits[MAXBCEB][MAXBCEBRH];
463 int zsideIslandBCEBRecHits[MAXBCEB][MAXBCEBRH];
464 float eIslandBCEBRecHits[MAXBCEB][MAXBCEBRH];
467 for (
int i = 0;
i < MAXBCEB;
i++) {
470 etaIslandBCEB[
i] = 0;
471 phiIslandBCEB[
i] = 0;
472 e2x2IslandBCEB[
i] = 0;
473 e3x3IslandBCEB[
i] = 0;
474 e5x5IslandBCEB[
i] = 0;
475 nIslandBCEBRecHits[
i] = 0;
476 for (
int j = 0;
j < MAXBCEBRH;
j++) {
478 ietaIslandBCEBRecHits[
i][
j] = 0;
479 iphiIslandBCEBRecHits[
i][
j] = 0;
480 zsideIslandBCEBRecHits[
i][
j] = 0;
481 eIslandBCEBRecHits[
i][
j] = 0;
485 int iClus_recalib = 0;
486 for (reco::BasicClusterCollection::const_iterator aClus = clusters_recalib.begin(); aClus != clusters_recalib.end();
488 cout <<
" CLUSTER [recalibration] : #,NHits,e,et,eta,phi,e2x2,e3x3,e5x5: " << iClus_recalib <<
" " << aClus->size()
489 <<
" " << aClus->energy() <<
" " << aClus->energy() *
sin(aClus->position().theta()) <<
" "
490 << aClus->position().eta() <<
" " << aClus->position().phi() <<
" "
491 << (*clustersshapes_p_recalib)[iClus_recalib].e2x2() <<
" "
492 << (*clustersshapes_p_recalib)[iClus_recalib].e3x3() <<
" "
493 << (*clustersshapes_p_recalib)[iClus_recalib].e5x5() << endl;
495 eIslandBCEB[nIslandBCEB] = aClus->energy();
496 etIslandBCEB[nIslandBCEB] = aClus->energy() *
sin(aClus->position().theta());
497 etaIslandBCEB[nIslandBCEB] = aClus->position().eta();
498 phiIslandBCEB[nIslandBCEB] = aClus->position().phi();
500 e2x2IslandBCEB[nIslandBCEB] = (*clustersshapes_p_recalib)[nIslandBCEB].e2x2();
501 e3x3IslandBCEB[nIslandBCEB] = (*clustersshapes_p_recalib)[nIslandBCEB].e3x3();
502 e5x5IslandBCEB[nIslandBCEB] = (*clustersshapes_p_recalib)[nIslandBCEB].e5x5();
504 nIslandBCEBRecHits[nIslandBCEB] = aClus->size();
506 std::vector<std::pair<DetId, float>>
hits = aClus->hitsAndFractions();
507 std::vector<std::pair<DetId, float>>::iterator
hit;
508 std::map<DetId, EcalRecHit>::iterator aHit;
516 EBDetId sel_rh = aHit->second.detid();
521 ietaIslandBCEBRecHits[nIslandBCEB][irhcount] = sel_rh.
ieta();
522 iphiIslandBCEBRecHits[nIslandBCEB][irhcount] = sel_rh.
iphi();
523 zsideIslandBCEBRecHits[nIslandBCEB][irhcount] = sel_rh.
zside();
524 eIslandBCEBRecHits[nIslandBCEB][irhcount] = aHit->second.energy();
534 if (nIslandBCEB > 1) {
535 for (
int i = 0;
i < nIslandBCEB;
i++) {
536 for (
int j =
i + 1;
j < nIslandBCEB;
j++) {
538 float theta_0 = 2. * atan(
exp(-etaIslandBCEB[
i]));
539 float theta_1 = 2. * atan(
exp(-etaIslandBCEB[
j]));
541 float p0x = eIslandBCEB[
i] *
sin(theta_0) *
cos(phiIslandBCEB[
i]);
542 float p1x = eIslandBCEB[
j] *
sin(theta_1) *
cos(phiIslandBCEB[
j]);
544 float p0y = eIslandBCEB[
i] *
sin(theta_0) *
sin(phiIslandBCEB[
i]);
545 float p1y = eIslandBCEB[
j] *
sin(theta_1) *
sin(phiIslandBCEB[
j]);
547 float p0z = eIslandBCEB[
i] *
cos(theta_0);
548 float p1z = eIslandBCEB[
j] *
cos(theta_1);
550 float pi0_px = p0x + p1x;
551 float pi0_py = p0y + p1y;
552 float pi0_pz = p0z + p1z;
554 float pi0_ptot =
sqrt(pi0_px * pi0_px + pi0_py * pi0_py + pi0_pz * pi0_pz);
556 float pi0_theta = acos(pi0_pz / pi0_ptot);
557 float pi0_eta = -
log(
tan(pi0_theta / 2));
558 float pi0_phi = atan(pi0_py / pi0_px);
564 for (Int_t
k = 0;
k < nIslandBCEB;
k++) {
565 if ((
k !=
i) && (
k !=
j)) {
566 float dr_pi0_k =
sqrt((etaIslandBCEB[
k] - pi0_eta) * (etaIslandBCEB[
k] - pi0_eta) +
567 (phiIslandBCEB[
k] - pi0_phi) * (phiIslandBCEB[
k] - pi0_phi));
568 float deta_pi0_k = fabs(etaIslandBCEB[
k] - pi0_eta);
570 et_belt = et_belt + etIslandBCEB[
k];
574 float pt_pi0 =
sqrt((p0x + p1x) * (p0x + p1x) + (p0y + p1y) * (p0y + p1y));
579 float m_inv =
sqrt((eIslandBCEB[
i] + eIslandBCEB[
j]) * (eIslandBCEB[
i] + eIslandBCEB[
j]) -
580 (p0x + p1x) * (p0x + p1x) - (p0y + p1y) * (p0y + p1y) - (p0z + p1z) * (p0z + p1z));
581 cout <<
" pi0 (pt>2.5 GeV) m_inv = " << m_inv << endl;
583 float s4s9_1 = e2x2IslandBCEB[
i] / e3x3IslandBCEB[
i];
584 float s4s9_2 = e2x2IslandBCEB[
j] / e3x3IslandBCEB[
j];
586 float s9s25_1 = e3x3IslandBCEB[
i] / e5x5IslandBCEB[
i];
587 float s9s25_2 = e3x3IslandBCEB[
j] / e5x5IslandBCEB[
j];
599 cout <<
" Pi0 Good candidate : minv = " << m_inv << endl;
600 for (
int kk = 0;
kk < nIslandBCEBRecHits[
i];
kk++) {
601 int ieta_xtal = ietaIslandBCEBRecHits[
i][
kk];
602 int iphi_xtal = iphiIslandBCEBRecHits[
i][
kk];
603 int sign = zsideIslandBCEBRecHits[
i][
kk] > 0 ? 1 : 0;
605 wxtals[
abs(ieta_xtal) - 1][iphi_xtal - 1][
sign] + eIslandBCEBRecHits[
i][
kk] / e3x3IslandBCEB[
i];
609 (eIslandBCEBRecHits[
i][
kk] / e3x3IslandBCEB[
i]);
610 cout <<
"[Pi0FixedMassWindowCalibration] eta, phi, sign, e, e3x3, wxtals and mwxtals: " << ieta_xtal
611 <<
" " << iphi_xtal <<
" " <<
sign <<
" " << eIslandBCEBRecHits[
i][
kk] <<
" "
612 << e3x3IslandBCEB[
i] <<
" " <<
wxtals[
abs(ieta_xtal) - 1][iphi_xtal - 1][
sign] <<
" "
616 for (
int kk = 0;
kk < nIslandBCEBRecHits[
j];
kk++) {
617 int ieta_xtal = ietaIslandBCEBRecHits[
j][
kk];
618 int iphi_xtal = iphiIslandBCEBRecHits[
j][
kk];
619 int sign = zsideIslandBCEBRecHits[
j][
kk] > 0 ? 1 : 0;
621 wxtals[
abs(ieta_xtal) - 1][iphi_xtal - 1][
sign] + eIslandBCEBRecHits[
j][
kk] / e3x3IslandBCEB[
j];
625 (eIslandBCEBRecHits[
j][
kk] / e3x3IslandBCEB[
j]);
626 cout <<
"[Pi0FixedMassWindowCalibration] eta, phi, sign, e, e3x3, wxtals and mwxtals: " << ieta_xtal
627 <<
" " << iphi_xtal <<
" " <<
sign <<
" " << eIslandBCEBRecHits[
j][
kk] <<
" "
628 << e3x3IslandBCEB[
j] <<
" " <<
wxtals[
abs(ieta_xtal) - 1][iphi_xtal - 1][
sign] <<
" "
640 cout <<
" Not enough ECAL Barrel Basic Clusters: " << nIslandBCEB << endl;