24 statusThreshold_(iConfig.getUntrackedParameter<int>(
"statusThreshold", 0)),
25 reiteration_(iConfig.getUntrackedParameter<bool>(
"reiteration",
false)),
26 oldcalibfile_(iConfig.getUntrackedParameter<std::
string>(
"oldcalibfile",
"EcalIntercalibConstants.xml")),
27 have_initial_miscalib_(iConfig.getUntrackedParameter<bool>(
"haveInitialMiscalib",
false)),
28 initialmiscalibfile_(iConfig.getUntrackedParameter<std::
string>(
"initialmiscalibfile",
"InitialMiscalib.xml")) {}
50 namespace fs = std::filesystem;
73 namespace fs = std::filesystem;
95 for (
int ieta = 0; ieta <
kBarlRings; ieta++) {
121 edm::LogError(
"PhiSym") <<
"Must process at least one event-Exiting" << endl;
148 std::ofstream etsumMean_barl_out(
"etsumMean_barl.dat",
ios::out);
149 for (
int ieta = 0; ieta <
kBarlRings; ieta++) {
152 etsumMean_barl_out.close();
154 std::ofstream etsumMean_endc_out(
"etsumMean_endc.dat",
ios::out);
158 etsumMean_endc_out.close();
161 for (
int ieta = 0; ieta <
kBarlRings; ieta++) {
197 std::string newcalibfile(
"EcalIntercalibConstants_new.xml");
199 TFile ehistof(
"ehistos.root",
"recreate");
201 TH1D ebhisto(
"eb",
"eb", 100, 0., 2.);
203 std::vector<DetId>::const_iterator barrelIt =
barrelCells.begin();
204 for (; barrelIt !=
barrelCells.end(); barrelIt++) {
207 int iphi = eb.
iphi() - 1;
224 TH1D eehisto(
"ee",
"ee", 100, 0., 2.);
225 std::vector<DetId>::const_iterator endcapIt =
endcapCells.begin();
227 for (; endcapIt !=
endcapCells.end(); endcapIt++) {
229 int ix = ee.
ix() - 1;
230 int iy = ee.
iy() - 1;
245 header.
method_ =
"phi symmetry";
249 header.
tag_ =
"unknown";
250 header.
date_ =
"Mar 24 1973";
263 std::fstream ebf(
"etsummary_barl.dat",
ios::out);
264 std::fstream eef(
"etsummary_endc.dat",
ios::out);
266 for (
int ieta = 0; ieta <
kBarlRings; ieta++) {
284 TFile
f(
"CalibHistos.root",
"recreate");
286 TH2F barreletamap(
"barreletamap",
"barreletamap", 171, -85, 86, 100, 0., 2.);
287 TH2F barreletamapraw(
"barreletamapraw",
"barreletamapraw", 171, -85, 86, 100, 0., 2.);
289 TH2F barrelmapold(
"barrelmapold",
"barrelmapold", 360, 1., 361., 171, -85., 86.);
290 TH2F barrelmapnew(
"barrelmapnew",
"barrelmapnew", 360, 1., 361., 171, -85., 86.);
291 TH2F barrelmapratio(
"barrelmapratio",
"barrelmapratio", 360, 1., 361., 171, -85., 86.);
293 TH1F rawconst_endc_h(
"rawconst_endc",
"rawconst_endc", 100, 0., 2.);
294 TH1F const_endc_h(
"const_endc",
"const_endc", 100, 0., 2.);
296 TH1F oldconst_endc_h(
"oldconst_endc",
"oldconst_endc;oldCalib;", 200, 0, 2);
297 TH2F newvsraw_endc_h(
"newvsraw_endc",
"newvsraw_endc;rawConst;newCalib", 200, 0, 2, 200, 0, 2);
299 TH2F endcapmapold_plus(
"endcapmapold_plus",
"endcapmapold_plus", 100, 1., 101., 100, 1., 101.);
300 TH2F endcapmapnew_plus(
"endcapmapnew_plus",
"endcapmapnew_plus", 100, 1., 101., 100, 1., 101.);
301 TH2F endcapmapratio_plus(
"endcapmapratio_plus",
"endcapmapratio_plus", 100, 1., 101., 100, 1., 101.);
303 TH2F endcapmapold_minus(
"endcapmapold_minus",
"endcapmapold_minus", 100, 1., 101., 100, 1., 101.);
304 TH2F endcapmapnew_minus(
"endcapmapnew_minus",
"endcapmapnew_minus", 100, 1., 101., 100, 1., 101.);
305 TH2F endcapmapratio_minus(
"endcapmapratio_minus",
"endcapmapratio_minus", 100, 1., 101., 100, 1., 101.);
308 int thesign =
sign == 1 ? 1 : -1;
310 for (
int ieta = 0; ieta <
kBarlRings; ieta++) {
313 EBDetId eb(thesign * (ieta + 1), iphi + 1);
316 barreletamap.Fill(ieta * thesign + thesign,
newCalibs_[eb]);
317 barreletamapraw.Fill(ieta * thesign + thesign,
rawconst_barl[ieta][iphi][sign]);
319 barrelmapold.Fill(iphi + 1, ieta * thesign + thesign,
oldCalibs_[eb]);
320 barrelmapnew.Fill(iphi + 1, ieta * thesign + thesign,
newCalibs_[eb]);
331 EEDetId ee(ix + 1, iy + 1, thesign);
339 endcapmapold_plus.Fill(ix + 1, iy + 1,
oldCalibs_[ee]);
340 endcapmapnew_plus.Fill(ix + 1, iy + 1,
newCalibs_[ee]);
343 endcapmapold_minus.Fill(ix + 1, iy + 1,
oldCalibs_[ee]);
344 endcapmapnew_minus.Fill(ix + 1, iy + 1,
newCalibs_[ee]);
354 barreletamap.Write();
355 barreletamapraw.Write();
356 rawconst_endc_h.Write();
357 const_endc_h.Write();
358 oldconst_endc_h.Write();
359 newvsraw_endc_h.Write();
360 barrelmapold.Write();
361 barrelmapnew.Write();
362 barrelmapratio.Write();
363 endcapmapold_plus.Write();
364 endcapmapnew_plus.Write();
365 endcapmapratio_plus.Write();
366 endcapmapold_minus.Write();
367 endcapmapnew_minus.Write();
368 endcapmapratio_minus.Write();
376 TFile
f(
"PhiSymmetryCalibration.root",
"recreate");
378 std::vector<TH1F*> etsum_barl_histos(
kBarlRings);
379 std::vector<TH1F*> esum_barl_histos(
kBarlRings);
382 for (
int ieta = 0; ieta <
kBarlRings; ieta++) {
385 float low_e = 999999.;
391 if (etsum < low && etsum != 0.)
397 if (esum < low_e && esum != 0.)
405 t <<
"etsum_barl_" << ieta + 1;
406 etsum_barl_histos[ieta] =
new TH1F(t.str().c_str(),
"", 50, low - .2 * low, high + .1 * high);
409 t <<
"esum_barl_" << ieta + 1;
410 esum_barl_histos[ieta] =
new TH1F(t.str().c_str(),
"", 50, low_e - .2 * low_e, high_e + .1 * high_e);
421 etsum_barl_histos[ieta]->Fill(etsum);
422 esum_barl_histos[ieta]->Fill(esum);
429 etsum_barl_histos[ieta]->Write();
430 esum_barl_histos[ieta]->Write();
433 delete etsum_barl_histos[ieta];
434 delete esum_barl_histos[ieta];
447 float low_uncorr = FLT_MAX;
449 float high_uncorr = 0;
450 float low_e = FLT_MAX;
459 if (etsum < low && etsum != 0.)
465 if (etsum_uncorr < low_uncorr && etsum_uncorr != 0.)
466 low_uncorr = etsum_uncorr;
467 if (etsum_uncorr > high_uncorr)
468 high_uncorr = etsum_uncorr;
471 if (esum < low_e && esum != 0.)
487 t <<
"etsum_endc_" <<
ring + 1;
488 etsum_endc_histos[
ring] =
new TH1F(t.str().c_str(),
"", 50, low - .2 * low, high + .1 * high);
491 t <<
"etsum_endc_uncorr_" << ring + 1;
492 etsum_endc_uncorr_histos[
ring] =
493 new TH1F(t.str().c_str(),
"", 50, low_uncorr - .2 * low_uncorr, high_uncorr + .1 * high_uncorr);
496 t <<
"esum_endc_" << ring + 1;
497 esum_endc_histos[
ring] =
new TH1F(t.str().c_str(),
"", 50, low_e - .2 * low_e, high_e + .1 * high_e);
500 t <<
"etsumvsarea_endc_" << ring + 1;
501 etsumvsarea_endc_histos[
ring] =
502 new TH2F(t.str().c_str(),
";A_{#eta#phi};#Sigma E_{T}", 50, low_a, high_a, 50, low, high);
505 t <<
"esumvsarea_endc_" << ring + 1;
506 esumvsarea_endc_histos[
ring] =
507 new TH2F(t.str().c_str(),
";A_{#eta#phi};#Sigma E", 50, low_a, high_a, 50, low_e, high_e);
521 etsum_endc_histos[
ring]->Fill(etsum);
522 etsum_endc_uncorr_histos[
ring]->Fill(etsum_uncorr);
523 esum_endc_histos[
ring]->Fill(esum);
526 etsumvsarea_endc_histos[
ring]->Fill(area, etsum);
527 esumvsarea_endc_histos[
ring]->Fill(area, esum);
537 etsum_endc_histos[
ring]->Write();
538 etsum_endc_uncorr_histos[
ring]->Write();
539 esum_endc_histos[
ring]->Write();
542 etsumvsarea_endc_histos[
ring]->Write();
543 esumvsarea_endc_histos[
ring]->Write();
545 delete etsum_endc_histos[
ring];
546 delete etsum_endc_uncorr_histos[
ring];
547 delete esum_endc_histos[
ring];
548 delete etsumvsarea_endc_histos[
ring];
549 delete esumvsarea_endc_histos[
ring];
553 TH2F barreletamap(
"barreletamap",
"barreletamap", 171, -85, 86, 100, 0, 2);
554 TH2F barrelmap(
"barrelmap",
"barrelmap - #frac{#Sigma E_{T}}{<#Sigma E_{T}>_{0}}", 360, 1, 360, 171, -85, 86);
555 TH2F barrelmap_e(
"barrelmape",
"barrelmape - #frac{#Sigma E}{<#Sigma E>_{0}}", 360, 1, 360, 171, -85, 86);
556 TH2F barrelmap_divided(
"barrelmapdiv",
"barrelmapdivided - #frac{#Sigma E_{T}}{hits}", 360, 1, 360, 171, -85, 86);
557 TH2F barrelmap_e_divided(
"barrelmapediv",
"barrelmapedivided - #frac{#Sigma E}{hits}", 360, 1, 360, 171, -85, 86);
558 TH2F endcmap_plus_corr(
559 "endcapmapplus_corrected",
"endcapmapplus - #frac{#Sigma E_{T}}{<#Sigma E_{T}>_{38}}", 100, 1, 101, 100, 1, 101);
560 TH2F endcmap_minus_corr(
561 "endcapmapminus_corrected",
"endcapmapminus - #frac{#Sigma E_{T}}{<#Sigma E_{T}>_{38}}", 100, 1, 101, 100, 1, 101);
562 TH2F endcmap_plus_uncorr(
"endcapmapplus_uncorrected",
563 "endcapmapplus_uncor - #frac{#Sigma E_{T}}{<#Sigma E_{T}>_{38}}",
570 TH2F endcmap_minus_uncorr(
"endcapmapminus_uncorrected",
571 "endcapmapminus_uncor - #frac{#Sigma E_{T}}{<#Sigma E_{T}>_{38}}",
578 TH2F endcmap_e_plus(
"endcapmapeplus",
"endcapmapeplus - #frac{#Sigma E}{<#Sigma E>_{38}}", 100, 1, 101, 100, 1, 101);
579 TH2F endcmap_e_minus(
580 "endcapmapeminus",
"endcapmapeminus - #frac{#Sigma E}{<#Sigma E>_{38}}", 100, 1, 101, 100, 1, 101);
583 int thesign =
sign == 1 ? 1 : -1;
585 for (
int ieta = 0; ieta <
kBarlRings; ieta++) {
592 barrelmap_divided.Fill(
594 barrelmap_e_divided.Fill(
619 barreletamap.Write();
620 barrelmap_divided.Write();
622 barrelmap_e_divided.Write();
624 endcmap_plus_corr.Write();
625 endcmap_minus_corr.Write();
626 endcmap_plus_uncorr.Write();
627 endcmap_minus_uncorr.Write();
628 endcmap_e_plus.Write();
629 endcmap_e_minus.Write();
631 vector<TH1F*> etavsphi_endc(kEndcEtaRings);
632 vector<TH1F*> areavsphi_endc(kEndcEtaRings);
633 vector<TH1F*> etsumvsphi_endcp_corr(kEndcEtaRings);
634 vector<TH1F*> etsumvsphi_endcm_corr(kEndcEtaRings);
635 vector<TH1F*> etsumvsphi_endcp_uncorr(kEndcEtaRings);
636 vector<TH1F*> etsumvsphi_endcm_uncorr(kEndcEtaRings);
637 vector<TH1F*> esumvsphi_endcp(kEndcEtaRings);
638 vector<TH1F*> esumvsphi_endcm(kEndcEtaRings);
640 std::vector<TH1F*> deltaeta_histos(kEndcEtaRings);
641 std::vector<TH1F*> deltaphi_histos(kEndcEtaRings);
645 t <<
"etavsphi_endc_" <<
ring;
649 t <<
"areavsphi_endc_" <<
ring;
653 t <<
"etsumvsphi_endcp_corr_" <<
ring;
657 t <<
"etsumvsphi_endcm_corr_" <<
ring;
661 t <<
"etsumvsphi_endcp_uncorr_" <<
ring;
665 t <<
"etsumvsphi_endcm_uncorr_" <<
ring;
669 t <<
"esumvsphi_endcp_" <<
ring;
673 t <<
"esumvsphi_endcm_" <<
ring;
677 t <<
"deltaeta_" <<
ring;
678 deltaeta_histos[
ring] =
new TH1F(t.str().c_str(),
"", 50, -.1, .1);
680 t <<
"deltaphi_" <<
ring;
681 deltaphi_histos[
ring] =
new TH1F(t.str().c_str(),
"", 50, -.1, .1);
695 if (iphi_endc != -1) {
699 etsumvsphi_endcp_corr[
ring]->Fill(iphi_endc,
etsum_endc_[ix][iy][sign]);
703 etsumvsphi_endcm_corr[
ring]->Fill(iphi_endc,
etsum_endc_[ix][iy][sign]);
718 etavsphi_endc[
ring]->Write();
719 areavsphi_endc[
ring]->Write();
720 etsumvsphi_endcp_corr[
ring]->Write();
721 etsumvsphi_endcm_corr[
ring]->Write();
722 etsumvsphi_endcp_uncorr[
ring]->Write();
723 etsumvsphi_endcm_uncorr[
ring]->Write();
724 esumvsphi_endcp[
ring]->Write();
725 esumvsphi_endcm[
ring]->Write();
726 deltaeta_histos[
ring]->Write();
727 deltaphi_histos[
ring]->Write();
729 delete etsumvsphi_endcp_corr[
ring];
730 delete etsumvsphi_endcm_corr[
ring];
731 delete etsumvsphi_endcp_uncorr[
ring];
732 delete etsumvsphi_endcm_uncorr[
ring];
733 delete etavsphi_endc[
ring];
734 delete areavsphi_endc[
ring];
735 delete esumvsphi_endcp[
ring];
736 delete esumvsphi_endcm[
ring];
737 delete deltaeta_histos[
ring];
738 delete deltaphi_histos[
ring];
747 int ieta, iphi,
sign, ix, iy, dummy;
750 std::ifstream etsum_barl_in(
"etsum_barl.dat",
ios::in);
751 while (etsum_barl_in >> dummy >> ieta >> iphi >> sign >> etsum >> nhits) {
756 std::ifstream etsum_endc_in(
"etsum_endc.dat",
ios::in);
757 while (etsum_endc_in >> dummy >> ix >> iy >> sign >> etsum >> nhits >> dummy) {
762 std::ifstream k_barl_in(
"k_barl.dat",
ios::in);
763 for (
int ieta = 0; ieta <
kBarlRings; ieta++) {
764 k_barl_in >> dummy >>
k_barl_[ieta];
767 std::ifstream k_endc_in(
"k_endc.dat",
ios::in);
777 for (
int ieta = 0; ieta <
kBarlRings; ieta++) {
779 t1 <<
"mr_barl_" << ieta + 1;
782 t2 <<
"co_barl_" << ieta + 1;
791 t1 <<
"mr_endc_" <<
ring + 1;
794 t2 <<
"co_endc_" << ring + 1;
801 TFile
f(
"PhiSymmetryCalibration_miscal_resid.root",
"recreate");
802 for (
int ieta = 0; ieta < 85; ieta++) {
double esumMean_endc_[kEndcEtaRings]
void fillConstantsHistos()
const edm::ESGetToken< EcalChannelStatus, EcalChannelStatusRcd > channelStatusToken_
double etsumMean_barl_[kBarlRings]
double etsum_endc_[kEndcWedgesX][kEndcWedgesX][kSides]
tuple ret
prodAgent to be discontinued
static int writeXML(const std::string &filename, const EcalCondHeader &header, const EcalFloatCondObjectContainer &record)
double esumMean_barl_[kBarlRings]
void setup(const CaloGeometry *geometry, const EcalChannelStatus *chstatus, int statusThreshold)
int nRing_[kEndcEtaRings]
unsigned int nhits_barl_[kBarlRings][kBarlWedges][kSides]
int nBads_endc[kEndcEtaRings]
static const int kBarlRings
bool goodCell_barl[kBarlRings][kBarlWedges][kSides]
GlobalPoint cellPos_[kEndcWedgesX][kEndcWedgesY]
Log< level::Error, false > LogError
~PhiSymmetryCalibration_step2() override
float epsilon_M_endc[kEndcWedgesX][kEndcWedgesY][kSides]
double phi_endc_[kMaxEndciPhi][kEndcEtaRings]
static int readXML(const std::string &filename, EcalCondHeader &header, EcalFloatCondObjectContainer &record)
float epsilon_M_barl[kBarlRings][kBarlWedges][kSides]
int iphi() const
get the crystal iphi
double k_barl_[kBarlRings]
static const int kBarlWedges
bool getData(T &iHolder) const
double etsum_barl_[kBarlRings][kBarlWedges][kSides]
PhiSymmetryCalibration_step2(const edm::ParameterSet &iConfig)
static const int kEndcWedgesX
std::vector< DetId > barrelCells
float rawconst_barl[kBarlRings][kBarlWedges][kSides]
double etsum_endc_uncorr[kEndcWedgesX][kEndcWedgesX][kSides]
int endcapRing_[kEndcWedgesX][kEndcWedgesY]
static const int kEndcEtaRings
std::vector< DetId > endcapCells
Abs< T >::type abs(const T &t)
double k_endc_[kEndcEtaRings]
const std::string initialmiscalibfile_
EcalIntercalibConstants oldCalibs_
the old calibration constants (when reiterating, the last ones derived)
int ieta() const
get the crystal ieta
std::vector< TH1F * > miscal_resid_endc_histos
double etsumMean_endc_[kEndcEtaRings]
std::vector< TH2F * > correl_endc_histos
void setUp(const edm::EventSetup &setup)
const edm::ESGetToken< CaloGeometry, CaloGeometryRecord > geometryToken_
const bool have_initial_miscalib_
std::vector< TH1F * > miscal_resid_barl_histos
res miscalib histos
unsigned int nhits_endc_[kEndcWedgesX][kEndcWedgesX][kSides]
void analyze(const edm::Event &, const edm::EventSetup &) override
static bool validDetId(int crystal_ix, int crystal_iy, int iz)
const std::string oldcalibfile_
EcalIntercalibConstants miscalib_
initial miscalibration applied if any)
const int statusThreshold_
double esum_barl_[kBarlRings][kBarlWedges][kSides]
double cellPhi_[kEndcWedgesX][kEndcWedgesY]
std::vector< TH2F * > correl_barl_histos
EcalIntercalibConstants newCalibs_
calib constants that we are going to calculate
double meanCellArea_[kEndcEtaRings]
double cellArea_[kEndcWedgesX][kEndcWedgesY]
float rawconst_endc[kEndcWedgesX][kEndcWedgesX][kSides]
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
int nBads_barl[kBarlRings]
int zside() const
get the z-side of the crystal (1/-1)
bool goodCell_endc[kEndcWedgesX][kEndcWedgesX][kSides]
double esum_endc_[kEndcWedgesX][kEndcWedgesX][kSides]
static const int kEndcWedgesY