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")) {}
48 for (
int ieta = 0; ieta <
kBarlRings; ieta++) {
50 int iphi_r = int(iphi /
nscx);
62 namespace fs = std::filesystem;
84 namespace fs = std::filesystem;
106 for (
int ieta = 0; ieta <
kBarlRings; ieta++) {
109 int iphi_r = int(iphi /
nscx);
138 edm::LogError(
"PhiSym") <<
"Must process at least one event-Exiting" << endl;
168 std::ofstream etsumMean_barl_out(
"etsumMean_barl.dat",
ios::out);
169 for (
int ieta = 0; ieta <
kBarlRings; ieta++) {
172 etsumMean_barl_out.close();
174 std::ofstream etsumMean_endc_out(
"etsumMean_endc.dat",
ios::out);
178 etsumMean_endc_out.close();
181 for (
int ieta = 0; ieta <
kBarlRings; ieta++) {
185 int iphi_r = int(iphi /
nscx);
231 for (
int ieta = 0; ieta <
kBarlRings; ++ieta) {
240 std::string newcalibfile(
"EcalIntercalibConstants_new.xml");
242 TFile ehistof(
"ehistos.root",
"recreate");
244 TH1D ebhisto(
"eb",
"eb", 100, 0., 2.);
246 std::vector<DetId>::const_iterator barrelIt =
barrelCells.begin();
247 for (; barrelIt !=
barrelCells.end(); barrelIt++) {
250 int iphi = eb.
iphi() - 1;
267 TH1D eehisto(
"ee",
"ee", 100, 0., 2.);
268 std::vector<DetId>::const_iterator endcapIt =
endcapCells.begin();
270 for (; endcapIt !=
endcapCells.end(); endcapIt++) {
272 int ix = ee.
ix() - 1;
273 int iy = ee.
iy() - 1;
288 header.
method_ =
"phi symmetry";
292 header.
tag_ =
"unknown";
293 header.
date_ =
"Mar 24 1973";
307 TFile
f(
"CalibHistos.root",
"recreate");
309 TH2F barreletamap(
"barreletamap",
"barreletamap", 171, -85, 86, 100, 0., 2.);
310 TH2F barreletamapraw(
"barreletamapraw",
"barreletamapraw", 171, -85, 86, 100, 0., 2.);
312 TH2F barrelmapold(
"barrelmapold",
"barrelmapold", 360, 1., 361., 171, -85., 86.);
313 TH2F barrelmapnew(
"barrelmapnew",
"barrelmapnew", 360, 1., 361., 171, -85., 86.);
314 TH2F barrelmapratio(
"barrelmapratio",
"barrelmapratio", 360, 1., 361., 171, -85., 86.);
316 TH1F rawconst_endc_h(
"rawconst_endc",
"rawconst_endc", 100, 0., 2.);
317 TH1F const_endc_h(
"const_endc",
"const_endc", 100, 0., 2.);
319 TH1F oldconst_endc_h(
"oldconst_endc",
"oldconst_endc;oldCalib;", 200, 0, 2);
320 TH2F newvsraw_endc_h(
"newvsraw_endc",
"newvsraw_endc;rawConst;newCalib", 200, 0, 2, 200, 0, 2);
322 TH2F endcapmapold_plus(
"endcapmapold_plus",
"endcapmapold_plus", 100, 1., 101., 100, 1., 101.);
323 TH2F endcapmapnew_plus(
"endcapmapnew_plus",
"endcapmapnew_plus", 100, 1., 101., 100, 1., 101.);
324 TH2F endcapmapratio_plus(
"endcapmapratio_plus",
"endcapmapratio_plus", 100, 1., 101., 100, 1., 101.);
326 TH2F endcapmapold_minus(
"endcapmapold_minus",
"endcapmapold_minus", 100, 1., 101., 100, 1., 101.);
327 TH2F endcapmapnew_minus(
"endcapmapnew_minus",
"endcapmapnew_minus", 100, 1., 101., 100, 1., 101.);
328 TH2F endcapmapratio_minus(
"endcapmapratio_minus",
"endcapmapratio_minus", 100, 1., 101., 100, 1., 101.);
331 int thesign =
sign == 1 ? 1 : -1;
333 for (
int ieta = 0; ieta <
kBarlRings; ieta++) {
336 EBDetId eb(thesign * (ieta + 1), iphi + 1);
339 barreletamap.Fill(ieta * thesign + thesign,
newCalibs_[eb]);
340 barreletamapraw.Fill(ieta * thesign + thesign,
rawconst_barl[ieta][iphi][sign]);
342 barrelmapold.Fill(iphi + 1, ieta * thesign + thesign,
oldCalibs_[eb]);
343 barrelmapnew.Fill(iphi + 1, ieta * thesign + thesign,
newCalibs_[eb]);
354 EEDetId ee(ix + 1, iy + 1, thesign);
362 endcapmapold_plus.Fill(ix + 1, iy + 1,
oldCalibs_[ee]);
363 endcapmapnew_plus.Fill(ix + 1, iy + 1,
newCalibs_[ee]);
366 endcapmapold_minus.Fill(ix + 1, iy + 1,
oldCalibs_[ee]);
367 endcapmapnew_minus.Fill(ix + 1, iy + 1,
newCalibs_[ee]);
377 barreletamap.Write();
378 barreletamapraw.Write();
379 rawconst_endc_h.Write();
380 const_endc_h.Write();
381 oldconst_endc_h.Write();
382 newvsraw_endc_h.Write();
383 barrelmapold.Write();
384 barrelmapnew.Write();
385 barrelmapratio.Write();
386 endcapmapold_plus.Write();
387 endcapmapnew_plus.Write();
388 endcapmapratio_plus.Write();
389 endcapmapold_minus.Write();
390 endcapmapnew_minus.Write();
391 endcapmapratio_minus.Write();
399 TFile
f(
"PhiSymmetryCalibration.root",
"recreate");
401 std::vector<TH1F*> etsum_barl_histos(
kBarlRings);
402 std::vector<TH1F*> esum_barl_histos(
kBarlRings);
405 for (
int ieta = 0; ieta <
kBarlRings; ieta++) {
408 float low_e = 999999.;
414 if (etsum < low && etsum != 0.)
420 if (esum < low_e && esum != 0.)
428 t <<
"etsum_barl_" << ieta + 1;
429 etsum_barl_histos[ieta] =
new TH1F(t.str().c_str(),
"", 50, low - .2 * low, high + .1 * high);
432 t <<
"esum_barl_" << ieta + 1;
433 esum_barl_histos[ieta] =
new TH1F(t.str().c_str(),
"", 50, low_e - .2 * low_e, high_e + .1 * high_e);
443 int iphi_r = int(iphi /
nscx);
445 if (!(iphi %
nscx)) {
456 etsum_barl_histos[ieta]->Fill(etsum);
457 esum_barl_histos[ieta]->Fill(esum);
465 etsum_barl_histos[ieta]->Write();
466 esum_barl_histos[ieta]->Write();
470 delete etsum_barl_histos[ieta];
471 delete esum_barl_histos[ieta];
484 float low_uncorr = FLT_MAX;
486 float high_uncorr = 0;
487 float low_e = FLT_MAX;
496 if (etsum < low && etsum != 0.)
502 if (etsum_uncorr < low_uncorr && etsum_uncorr != 0.)
503 low_uncorr = etsum_uncorr;
504 if (etsum_uncorr > high_uncorr)
505 high_uncorr = etsum_uncorr;
508 if (esum < low_e && esum != 0.)
524 t <<
"etsum_endc_" <<
ring + 1;
525 etsum_endc_histos[
ring] =
new TH1F(t.str().c_str(),
"", 50, low - .2 * low, high + .1 * high);
528 t <<
"etsum_endc_uncorr_" << ring + 1;
529 etsum_endc_uncorr_histos[
ring] =
530 new TH1F(t.str().c_str(),
"", 50, low_uncorr - .2 * low_uncorr, high_uncorr + .1 * high_uncorr);
533 t <<
"esum_endc_" << ring + 1;
534 esum_endc_histos[
ring] =
new TH1F(t.str().c_str(),
"", 50, low_e - .2 * low_e, high_e + .1 * high_e);
537 t <<
"etsumvsarea_endc_" << ring + 1;
538 etsumvsarea_endc_histos[
ring] =
539 new TH2F(t.str().c_str(),
";A_{#eta#phi};#Sigma E_{T}", 50, low_a, high_a, 50, low, high);
542 t <<
"esumvsarea_endc_" << ring + 1;
543 esumvsarea_endc_histos[
ring] =
544 new TH2F(t.str().c_str(),
";A_{#eta#phi};#Sigma E", 50, low_a, high_a, 50, low_e, high_e);
558 etsum_endc_histos[
ring]->Fill(etsum);
559 etsum_endc_uncorr_histos[
ring]->Fill(etsum_uncorr);
560 esum_endc_histos[
ring]->Fill(esum);
563 etsumvsarea_endc_histos[
ring]->Fill(area, etsum);
564 esumvsarea_endc_histos[
ring]->Fill(area, esum);
574 etsum_endc_histos[
ring]->Write();
575 etsum_endc_uncorr_histos[
ring]->Write();
576 esum_endc_histos[
ring]->Write();
579 etsumvsarea_endc_histos[
ring]->Write();
580 esumvsarea_endc_histos[
ring]->Write();
582 delete etsum_endc_histos[
ring];
583 delete etsum_endc_uncorr_histos[
ring];
584 delete esum_endc_histos[
ring];
585 delete etsumvsarea_endc_histos[
ring];
586 delete esumvsarea_endc_histos[
ring];
590 TH2F barreletamap(
"barreletamap",
"barreletamap", 171, -85, 86, 100, 0, 2);
591 TH2F barrelmap(
"barrelmap",
"barrelmap - #frac{#Sigma E_{T}}{<#Sigma E_{T}>_{0}}", 360, 1, 360, 171, -85, 86);
592 TH2F barrelmap_e(
"barrelmape",
"barrelmape - #frac{#Sigma E}{<#Sigma E>_{0}}", 360, 1, 360, 171, -85, 86);
593 TH2F barrelmap_divided(
"barrelmapdiv",
"barrelmapdivided - #frac{#Sigma E_{T}}{hits}", 360, 1, 360, 171, -85, 86);
594 TH2F barrelmap_e_divided(
"barrelmapediv",
"barrelmapedivided - #frac{#Sigma E}{hits}", 360, 1, 360, 171, -85, 86);
595 TH2F endcmap_plus_corr(
596 "endcapmapplus_corrected",
"endcapmapplus - #frac{#Sigma E_{T}}{<#Sigma E_{T}>_{38}}", 100, 1, 101, 100, 1, 101);
597 TH2F endcmap_minus_corr(
598 "endcapmapminus_corrected",
"endcapmapminus - #frac{#Sigma E_{T}}{<#Sigma E_{T}>_{38}}", 100, 1, 101, 100, 1, 101);
599 TH2F endcmap_plus_uncorr(
"endcapmapplus_uncorrected",
600 "endcapmapplus_uncor - #frac{#Sigma E_{T}}{<#Sigma E_{T}>_{38}}",
607 TH2F endcmap_minus_uncorr(
"endcapmapminus_uncorrected",
608 "endcapmapminus_uncor - #frac{#Sigma E_{T}}{<#Sigma E_{T}>_{38}}",
615 TH2F endcmap_e_plus(
"endcapmapeplus",
"endcapmapeplus - #frac{#Sigma E}{<#Sigma E>_{38}}", 100, 1, 101, 100, 1, 101);
616 TH2F endcmap_e_minus(
617 "endcapmapeminus",
"endcapmapeminus - #frac{#Sigma E}{<#Sigma E>_{38}}", 100, 1, 101, 100, 1, 101);
620 int thesign =
sign == 1 ? 1 : -1;
622 for (
int ieta = 0; ieta <
kBarlRings; ieta++) {
629 barrelmap_divided.Fill(
631 barrelmap_e_divided.Fill(
656 barreletamap.Write();
657 barrelmap_divided.Write();
659 barrelmap_e_divided.Write();
661 endcmap_plus_corr.Write();
662 endcmap_minus_corr.Write();
663 endcmap_plus_uncorr.Write();
664 endcmap_minus_uncorr.Write();
665 endcmap_e_plus.Write();
666 endcmap_e_minus.Write();
668 vector<TH1F*> etavsphi_endc(kEndcEtaRings);
669 vector<TH1F*> areavsphi_endc(kEndcEtaRings);
670 vector<TH1F*> etsumvsphi_endcp_corr(kEndcEtaRings);
671 vector<TH1F*> etsumvsphi_endcm_corr(kEndcEtaRings);
672 vector<TH1F*> etsumvsphi_endcp_uncorr(kEndcEtaRings);
673 vector<TH1F*> etsumvsphi_endcm_uncorr(kEndcEtaRings);
674 vector<TH1F*> esumvsphi_endcp(kEndcEtaRings);
675 vector<TH1F*> esumvsphi_endcm(kEndcEtaRings);
677 std::vector<TH1F*> deltaeta_histos(kEndcEtaRings);
678 std::vector<TH1F*> deltaphi_histos(kEndcEtaRings);
682 t <<
"etavsphi_endc_" <<
ring;
686 t <<
"areavsphi_endc_" <<
ring;
690 t <<
"etsumvsphi_endcp_corr_" <<
ring;
694 t <<
"etsumvsphi_endcm_corr_" <<
ring;
698 t <<
"etsumvsphi_endcp_uncorr_" <<
ring;
702 t <<
"etsumvsphi_endcm_uncorr_" <<
ring;
706 t <<
"esumvsphi_endcp_" <<
ring;
710 t <<
"esumvsphi_endcm_" <<
ring;
714 t <<
"deltaeta_" <<
ring;
715 deltaeta_histos[
ring] =
new TH1F(t.str().c_str(),
"", 50, -.1, .1);
717 t <<
"deltaphi_" <<
ring;
718 deltaphi_histos[
ring] =
new TH1F(t.str().c_str(),
"", 50, -.1, .1);
732 if (iphi_endc != -1) {
736 etsumvsphi_endcp_corr[
ring]->Fill(iphi_endc,
etsum_endc_[ix][iy][sign]);
740 etsumvsphi_endcm_corr[
ring]->Fill(iphi_endc,
etsum_endc_[ix][iy][sign]);
755 etavsphi_endc[
ring]->Write();
756 areavsphi_endc[
ring]->Write();
757 etsumvsphi_endcp_corr[
ring]->Write();
758 etsumvsphi_endcm_corr[
ring]->Write();
759 etsumvsphi_endcp_uncorr[
ring]->Write();
760 etsumvsphi_endcm_uncorr[
ring]->Write();
761 esumvsphi_endcp[
ring]->Write();
762 esumvsphi_endcm[
ring]->Write();
763 deltaeta_histos[
ring]->Write();
764 deltaphi_histos[
ring]->Write();
766 delete etsumvsphi_endcp_corr[
ring];
767 delete etsumvsphi_endcm_corr[
ring];
768 delete etsumvsphi_endcp_uncorr[
ring];
769 delete etsumvsphi_endcm_uncorr[
ring];
770 delete etavsphi_endc[
ring];
771 delete areavsphi_endc[
ring];
772 delete esumvsphi_endcp[
ring];
773 delete esumvsphi_endcm[
ring];
774 delete deltaeta_histos[
ring];
775 delete deltaphi_histos[
ring];
784 int ieta, iphi,
sign, ix, iy, dummy;
787 std::ifstream etsum_barl_in(
"etsum_barl.dat",
ios::in);
788 while (etsum_barl_in >> dummy >> ieta >> iphi >> sign >> etsum >> nhits) {
793 int iphi_r = int(iphi /
nscx);
801 std::ifstream etsum_endc_in(
"etsum_endc.dat",
ios::in);
802 while (etsum_endc_in >> dummy >> ix >> iy >> sign >> etsum >> nhits >> dummy) {
807 std::ifstream k_barl_in(
"k_barl.dat",
ios::in);
808 for (
int ieta = 0; ieta <
kBarlRings; ieta++) {
809 k_barl_in >> dummy >>
k_barl_[ieta];
812 std::ifstream k_endc_in(
"k_endc.dat",
ios::in);
822 for (
int ieta = 0; ieta <
kBarlRings; ieta++) {
824 t1 <<
"mr_barl_" << ieta + 1;
827 t2 <<
"co_barl_" << ieta + 1;
836 t1 <<
"mr_endc_" <<
ring + 1;
839 t2 <<
"co_endc_" << ring + 1;
846 TFile
f(
"PhiSymmetryCalibration_miscal_resid.root",
"recreate");
847 for (
int ieta = 0; ieta < 85; ieta++) {
tuple ret
prodAgent to be discontinued
static int writeXML(const std::string &filename, const EcalCondHeader &header, const EcalFloatCondObjectContainer &record)
void setup(const CaloGeometry *geometry, const EcalChannelStatus *chstatus, int statusThreshold)
double etsumMean_endc_[kEndcEtaRings]
EcalIntercalibConstants miscalib_
initial miscalibration applied if any)
double etsum_barl_[kBarlRings][kBarlWedges][kSides]
int nRing_[kEndcEtaRings]
double k_barl_[kBarlRings]
PhiSymmetryCalibration_step2_SM(const edm::ParameterSet &iConfig)
int nBads_endc[kEndcEtaRings]
static const int kBarlRings
bool goodCell_barl[kBarlRings][kBarlWedges][kSides]
unsigned int nhits_endc_[kEndcWedgesX][kEndcWedgesX][kSides]
std::vector< DetId > endcapCells
double etsumMean_barl_[kBarlRings]
GlobalPoint cellPos_[kEndcWedgesX][kEndcWedgesY]
double etsum_barl_SM_[kBarlRings][int(kBarlWedges/nscx)][kSides]
double esumMean_endc_[kEndcEtaRings]
const std::string initialmiscalibfile_
std::vector< TH1F * > miscal_resid_endc_histos
Log< level::Error, false > LogError
float epsilon_M_barl[kBarlRings][kBarlWedges][kSides]
double etsumMean_barl_SM_[kBarlRings]
int nBads_barl_SM_[kBarlRings][int(kBarlWedges/nscx)][kSides]
double phi_endc_[kMaxEndciPhi][kEndcEtaRings]
static int readXML(const std::string &filename, EcalCondHeader &header, EcalFloatCondObjectContainer &record)
double esumMean_barl_[kBarlRings]
int iphi() const
get the crystal iphi
static const int kBarlWedges
bool getData(T &iHolder) const
const int statusThreshold_
static const int kEndcWedgesX
int endcapRing_[kEndcWedgesX][kEndcWedgesY]
static const int kEndcEtaRings
Abs< T >::type abs(const T &t)
void fillConstantsHistos()
int ieta() const
get the crystal ieta
double k_endc_[kEndcEtaRings]
double esum_endc_[kEndcWedgesX][kEndcWedgesX][kSides]
double etsum_endc_[kEndcWedgesX][kEndcWedgesX][kSides]
const edm::ESGetToken< CaloGeometry, CaloGeometryRecord > geometryToken_
double epsilon_M_barl_SM_[kBarlRings][int(kBarlWedges/nscx)][kSides]
const edm::ESGetToken< EcalChannelStatus, EcalChannelStatusRcd > channelStatusToken_
~PhiSymmetryCalibration_step2_SM() override
void analyze(const edm::Event &, const edm::EventSetup &) override
float epsilon_M_endc[kEndcWedgesX][kEndcWedgesY][kSides]
std::vector< TH2F * > correl_barl_histos
const bool have_initial_miscalib_
float rawconst_barl[kBarlRings][kBarlWedges][kSides]
static bool validDetId(int crystal_ix, int crystal_iy, int iz)
const std::string oldcalibfile_
std::vector< TH2F * > correl_endc_histos
void setUp(const edm::EventSetup &setup)
EcalIntercalibConstants newCalibs_
calib constants that we are going to calculate
double cellPhi_[kEndcWedgesX][kEndcWedgesY]
EcalIntercalibConstants oldCalibs_
the old calibration constants (when reiterating, the last ones derived)
float rawconst_endc[kEndcWedgesX][kEndcWedgesX][kSides]
double cellArea_[kEndcWedgesX][kEndcWedgesY]
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
std::vector< DetId > barrelCells
std::vector< TH1F * > miscal_resid_barl_histos
res miscalib histos
double etsum_endc_uncorr[kEndcWedgesX][kEndcWedgesX][kSides]
double esum_barl_[kBarlRings][kBarlWedges][kSides]
unsigned int nhits_barl_[kBarlRings][kBarlWedges][kSides]
int nBads_barl[kBarlRings]
int zside() const
get the z-side of the crystal (1/-1)
bool goodCell_endc[kEndcWedgesX][kEndcWedgesX][kSides]
static const int kEndcWedgesY