34 #include "TDecompSVD.h"
35 #include "TDecompQRH.h"
67 TString
option = GetOption();
72 edm::LogError(
"HcalCalib") <<
"\nERROR: Failed to read the phi symmetry corrections.\n"
73 <<
"Check if the filename is correct. If the corrections are not needed, set the "
74 "corresponding flag to \"false\"\n"
75 <<
"\nThe program will be terminated\n";
86 h1_trkP =
new TH1F(
"h1_trkP",
"Track momenta; p_{trk} (GeV); Number of tracks", 100, 0, 200);
87 h1_allTrkP =
new TH1F(
"h1_allTrkP",
"Track momenta - all tracks; p_{trk} (GeV); Number of tracks", 100, 0, 200);
90 "h1_selTrkP_iEta10",
"Track momenta - tracks with |iEta|<10; p_{trk} (GeV); Number of tracks", 100, 0, 200);
93 h1_rawSumE =
new TH1F(
"h1_rawSumE",
"Cluster Energy; E_{cl} (GeV); Number of tracks", 100, 0, 200);
95 h1_rawSumE =
new TH1F(
"h1_rawSumE",
"Cluster Energy; E_{cl} (GeV); Number of tracks", 1000, 0, 2000);
97 h1_rawResp =
new TH1F(
"h1_rawResp",
"Uncorrected response: |iEta|<24; E_{had}/p; Number of tracks", 300, 0, 3);
98 h1_corResp =
new TH1F(
"h1_corResp",
"Corrected response: |iEta|<24; E_{had}/p; Number of tracks", 300, 0, 3);
101 new TH1F(
"h1_rawRespBarrel",
"Uncorrected response: |iEta|<15; E_{had}/p; Number of tracks", 300, 0, 3);
103 new TH1F(
"h1_corRespBarrel",
"Corrected response: |iEta|<15; E_{had}/p; Number of tracks", 300, 0, 3);
106 new TH1F(
"h1_rawRespEndcap",
"Uncorrected response: 17<|iEta|<24; E_{had}/p; Number of tracks", 300, 0, 3);
108 new TH1F(
"h1_corRespEndcap",
"Corrected response: 17<|iEta|<24; E_{had}/p; Number of tracks", 300, 0, 3);
113 "{#Delta}i{#phi} vs {#Delta}i{#eta} of hit and most energetic "
114 "tower(|i{#eta}|<16);{#Delta}i{#eta}; {#Delta}i{#phi}",
122 "{#Delta}i{#phi} vs {#Delta}i{#eta} of hit and most energetic tower (16<|i{#eta}|<25) "
123 ";{#Delta}i{#eta}; {#Delta}i{#phi}",
133 for (Int_t
i = 0;
i < 48; ++
i) {
153 std::set<UInt_t> uniqueIds;
155 Bool_t acceptEvent = kTRUE;
169 std::vector<TCell> selectCells;
171 if (
cells->GetSize() == 0)
177 for (Int_t
i = 0;
i <
cells->GetSize(); ++
i) {
193 selectCells.push_back(*thisCell);
196 if (selectCells.empty()) {
197 edm::LogWarning(
"HcalCalib") <<
"NO CELLS ABOVE THRESHOLD FOUND FOR TARGET!!!";
206 std::pair<Int_t, UInt_t> refPos;
208 Int_t dEtaHitRef = 999;
209 Int_t dPhiHitRef = 999;
217 dEtaHitRef = iEtaMaxE -
iEtaHit;
218 dPhiHitRef = iPhiMaxE -
iPhiHit;
220 if (dPhiHitRef < -36)
257 refPos.first = iEtaMaxE;
258 refPos.second = iPhiMaxE;
263 acceptEvent = kFALSE;
267 acceptEvent = kFALSE;
270 acceptEvent = kFALSE;
272 acceptEvent = kFALSE;
274 acceptEvent = kFALSE;
276 acceptEvent = kFALSE;
291 refPos.first = iEtaMaxE;
292 refPos.second = iPhiMaxE;
294 if (
abs(iEtaMaxE) > 40)
295 acceptEvent = kFALSE;
303 std::vector<Float_t> energies;
304 std::vector<UInt_t> ids;
306 for (std::vector<TCell>::iterator i_it = selectCells.begin(); i_it != selectCells.end(); ++i_it) {
309 if (uniqueIds.insert(i_it->id()).
second) {
310 energies.push_back(i_it->e());
311 ids.push_back(i_it->id());
317 acceptEvent = kFALSE;
319 acceptEvent = kFALSE;
322 acceptEvent = kFALSE;
324 if (
abs(dEtaHitRef) > 1 ||
abs(dPhiHitRef) > 1)
325 acceptEvent = kFALSE;
331 h1_rawSumE->Fill(accumulate(energies.begin(), energies.end(), 0.0));
340 if (
abs(refPos.first) <= 10)
356 <<
"Number of input objects: " <<
cellIds.size()
357 <<
"\nPerforming minimization: depending on selected method can take some time...\n\n";
361 Float_t
weight = (
abs(it_rp->first) < 21) ? 1.0 / 72.0 : 1.0 / 36.0;
370 int numIterations = 10;
379 std::vector<UInt_t> idForSummedCells;
381 for (std::map<UInt_t, Float_t>::iterator m_it =
solution.begin(); m_it !=
solution.end(); ++m_it) {
387 idForSummedCells.push_back(
HcalDetId(m_it->first));
390 for (std::vector<UInt_t>::iterator v_it = idForSummedCells.begin(); v_it != idForSummedCells.end(); ++v_it) {
402 for (std::map<UInt_t, Float_t>::iterator it_s =
solution.begin(); it_s !=
solution.end(); ++it_s) {
451 (ind < 0) ? (ind += 24) : (ind += 23);
452 if (ind >= 0 && ind < 48) {
464 }
else if (maxIEta < 25 && minIEta > 16) {
496 for (Int_t
i = 0;
i < 48; ++
i) {
511 std::map<Int_t, Float_t> aveTargetE;
512 std::map<Int_t, Int_t> nEntries;
515 std::map<Int_t, std::map<Int_t, Float_t> > aveHitE;
537 for (std::map<Int_t, Float_t>::iterator m_it = aveTargetE.begin(); m_it != aveTargetE.end(); ++m_it) {
538 Int_t
iEta = m_it->first;
539 norm = (nEntries[
iEta] > 0) ? 1.0 / (nEntries[
iEta]) : 1.0;
540 aveTargetE[
iEta] *= norm;
542 std::map<Int_t, Float_t>::iterator n_it = (aveHitE[
iEta]).begin();
545 for (; n_it != (aveHitE[
iEta]).
end(); ++n_it) {
546 (n_it->second) *= norm;
547 sumRawE += (n_it->second);
556 std::vector<Int_t> iEtaList;
561 iEtaList.push_back(
i);
564 TMatrixD
A(2 * ONE_SIDE_IETA_RANGE, 2 * ONE_SIDE_IETA_RANGE);
565 TMatrixD
b(2 * ONE_SIDE_IETA_RANGE, 1);
566 TMatrixD
x(2 * ONE_SIDE_IETA_RANGE, 1);
568 for (Int_t
i = 0;
i < 2 * ONE_SIDE_IETA_RANGE; ++
i) {
569 for (Int_t
j = 0;
j < 2 * ONE_SIDE_IETA_RANGE; ++
j) {
574 for (UInt_t
i = 0;
i < iEtaList.size(); ++
i) {
575 b(
i, 0) = aveTargetE[iEtaList[
i]];
577 std::map<Int_t, Float_t>::iterator n_it = aveHitE[iEtaList[
i]].begin();
578 for (; n_it != aveHitE[iEtaList[
i]].end(); ++n_it) {
581 Int_t
j = Int_t(
find(iEtaList.begin(), iEtaList.end(), n_it->first) - iEtaList.begin());
582 A(
i,
j) = n_it->second;
588 Bool_t hasSolution = qrh.MultiSolve(coef);
591 for (UInt_t
i = 0;
i < iEtaList.size(); ++
i) {
601 edm::LogWarning(
"HcalCalib") <<
"\nERROR: Can not find file with phi symmetry constants \""
619 while (getline(phiSymFile,
line)) {
623 std::istringstream linestream(
line);
624 linestream >>
iEta >> iPhi >>
depth >> sdName >>
value >> std::hex >> detId;
628 else if (sdName ==
"HE")
630 else if (sdName ==
"HO")
632 else if (sdName ==
"HF")
635 edm::LogWarning(
"HcalCalib") <<
"\nInvalid detector name in phi symmetry constants file: " << sdName.Data()
636 <<
"\nCheck file and rerun!\n";
644 <<
"\nInconsistent info in phi symmetry file: subdet, iEta, iPhi, depth do not match rawId!\n";
650 <<
" subdet=" << sdName.Data() <<
" detId=" << detId <<
"\n";
663 TString sdName[8] = {
"EMPTY",
"HB",
"HE",
"HO",
"HF",
"TRITWR",
"UNDEF",
"OTHER"};
668 fprintf(constFile,
"%1s%16s%16s%16s%16s%9s%11s\n",
"#",
"eta",
"phi",
"depth",
"det",
"value",
"DetId");
672 for (Int_t
sd = 1;
sd <= 4;
sd++) {
673 for (Int_t
e = 1;
e <= 50;
e++) {
676 for (Int_t side = 0; side < 2; side++) {
677 eta = (side == 0) ? -
e :
e;
680 for (Int_t
d = 1;
d < 5;
d++) {
684 Float_t corrFactor = 1.0;
691 Int_t subdetInd =
sd;
725 fprintf(constFile,
"%17i%16i%16i%16s%9.5f%11X\n",
eta,
phi,
d, sdName[
sd].Data(), corrFactor,
id.rawId());