4 #include <TLorentzVector.h>
13 #include <calobase/RawCluster.h>
14 #include <calobase/RawClusterContainer.h>
15 #include <calobase/RawClusterUtility.h>
16 #include <calobase/RawTower.h>
17 #include <calobase/RawTowerContainer.h>
18 #include <calobase/RawTowerGeom.h>
19 #include <calobase/RawTowerGeomContainer.h>
20 #include <calobase/TowerInfo.h>
21 #include <calobase/TowerInfoContainer.h>
22 #include <calobase/TowerInfoDefs.h>
25 #include <calobase/RawCluster.h>
26 #include <calobase/RawClusterContainer.h>
45 #include <TProfile2D.h>
48 #include <Event/Event.h>
49 #include <Event/packet.h>
65 R__LOAD_LIBRARY(libLiteCaloEvalTowSlope.so)
94 for (
int i = 0;
i < 96;
i++)
h_mass_eta_lt[
i] =
new TH1F(Form(
"h_mass_eta_lt%d",
i),
"", 50, 0, 0.5);
96 h_cemc_etaphi =
new TH2F(
"h_cemc_etaphi",
"", 96, 0, 96, 256, 0, 256);
99 h_InvMass =
new TH1F(
"h_InvMass",
"Invariant Mass", 120, 0, 1.2);
100 h_InvMassMix =
new TH1F(
"h_InvMassMix",
"Invariant Mass", 120, 0, 1.2);
103 h_etaphi_clus =
new TH2F(
"h_etaphi_clus",
"", 140, -1.2, 1.2, 64, -1 * TMath::Pi(), TMath::Pi());
104 h_clusE =
new TH1F(
"h_clusE",
"", 100, 0, 10);
108 h_pt1 =
new TH1F(
"h_pt1",
"", 100, 0, 5);
109 h_pt2 =
new TH1F(
"h_pt2",
"", 100, 0, 5);
111 h_nclusters =
new TH1F(
"h_nclusters",
"", 1000, 0, 1000);
132 float emcal_hit_threshold = 0.5;
136 float maxAlpha = 0.6;
137 float clus_chisq_cut = 4;
138 float nClus_ptCut = 0.5;
139 int max_nClusCount = 300;
143 GlobalVertexMap* vertexmap = findNode::getClass<GlobalVertexMap>(topNode,
"GlobalVertexMap");
147 std::cout <<
"CaloAna GlobalVertexMap node is missing" << std::endl;
151 if (vertexmap && !vertexmap->
empty())
156 vtx_z = vtx->
get_z();
160 vector<float> ht_eta;
161 vector<float> ht_phi;
165 TowerInfoContainer* towers = findNode::getClass<TowerInfoContainer>(topNode,
"TOWERINFO_CALIB_CEMC");
177 if (!isGood && offlineenergy > 0.2)
179 ht_eta.push_back(ieta);
180 ht_phi.push_back(iphi);
183 if (offlineenergy > emcal_hit_threshold)
190 RawClusterContainer* clusterContainer = findNode::getClass<RawClusterContainer>(topNode,
"CLUSTERINFO_CEMC2");
191 if (!clusterContainer)
193 std::cout <<
PHWHERE <<
"funkyCaloStuff::process_event - Fatal Error - CLUSTER_CEMC node is missing. " << std::endl;
200 RawTowerGeomContainer* m_geometry = findNode::getClass<RawTowerGeomContainer>(topNode, towergeomnodename);
203 std::cout <<
Name() <<
"::"
205 <<
": Could not find node " << towergeomnodename << std::endl;
206 throw std::runtime_error(
"failed to find TOWERGEOM node in RawClusterDeadHotMask::CreateNodeTree");
213 for (clusterIter = clusterEnd.first; clusterIter != clusterEnd.second; clusterIter++)
215 RawCluster* recoCluster = clusterIter->second;
217 CLHEP::Hep3Vector
vertex(0, 0, vtx_z);
220 float clus_pt = E_vec_cluster.perp();
221 float clus_chisq = recoCluster->
get_chi2();
223 if (clus_pt < nClus_ptCut)
continue;
224 if (clus_chisq > clus_chisq_cut)
continue;
233 float pt1ClusCut = 2;
234 float pt2ClusCut = 1.3;
238 pt1ClusCut += 1.4 * (nClusCount - 29) / 200.0;
239 pt2ClusCut += 1.4 * (nClusCount - 29) / 200.0;
242 float pi0ptcut = 1.22 * (pt1ClusCut + pt2ClusCut);
244 vector<float> save_pt;
245 vector<float> save_eta;
246 vector<float> save_phi;
247 vector<float> save_e;
249 for (clusterIter = clusterEnd.first; clusterIter != clusterEnd.second; clusterIter++)
251 RawCluster* recoCluster = clusterIter->second;
253 CLHEP::Hep3Vector
vertex(0, 0, vtx_z);
256 float clusE = E_vec_cluster.mag();
257 float clus_eta = E_vec_cluster.pseudoRapidity();
258 float clus_phi = E_vec_cluster.phi();
259 float clus_pt = E_vec_cluster.perp();
260 float clus_chisq = recoCluster->
get_chi2();
263 if (clus_chisq > clus_chisq_cut)
continue;
268 bool hotClus =
false;
270 unsigned int lt_eta = -1;
271 for (toweriter = towerCR.first; toweriter != towerCR.second; ++toweriter)
284 for (
size_t i = 0;
i < ht_eta.size();
i++)
285 if (towerphi == ht_phi[
i] && towereta == ht_eta[
i])
293 TLorentzVector photon1;
294 photon1.SetPtEtaPhiE(clus_pt, clus_eta, clus_phi, clusE);
298 if (clus_pt < pt1ClusCut)
continue;
300 for (clusterIter2 = clusterEnd.first; clusterIter2 != clusterEnd.second; clusterIter2++)
302 if (clusterIter == clusterIter2)
306 RawCluster* recoCluster2 = clusterIter2->second;
310 float clus2E = E_vec_cluster2.mag();
311 float clus2_eta = E_vec_cluster2.pseudoRapidity();
312 float clus2_phi = E_vec_cluster2.phi();
313 float clus2_pt = E_vec_cluster2.perp();
314 float clus2_chisq = recoCluster2->
get_chi2();
316 if (clus2_pt < pt2ClusCut)
continue;
317 if (clus2_chisq > clus_chisq_cut)
continue;
322 bool hotClus2 =
false;
323 for (toweriter2 = towerCR2.first; toweriter2 != towerCR2.second; ++toweriter2)
328 for (
size_t i = 0;
i < ht_eta.size();
i++)
330 if (towerphi == ht_phi[
i] && towereta == ht_phi[
i]) hotClus2 =
true;
335 TLorentzVector photon2;
336 photon2.SetPtEtaPhiE(clus2_pt, clus2_eta, clus2_phi, clus2E);
338 if (fabs(clusE - clus2E) / (clusE + clus2E) > maxAlpha)
continue;
340 if (photon1.DeltaR(photon2) > maxDr)
continue;
342 TLorentzVector pi0 = photon1 + photon2;
343 if (pi0.Pt() < pi0ptcut)
continue;
345 h_pt1->Fill(photon1.Pt());
346 h_pt2->Fill(photon2.Pt());
348 if (lt_eta > 95)
continue;
374 TF1*
fitFunc =
new TF1(
"fitFunc",
"[0]*exp(-0.5*((x-[1])/[2])^2) + [3] + [4]*x + [5]*x^2 + [6]*x^3", h->GetXaxis()->GetXmin(), h->GetXaxis()->GetXmax());
376 fitFunc->SetParameter(0, h->GetMaximum());
378 fitFunc->SetParameter(2, 0.01);
379 fitFunc->SetParameter(3, 0.0);
380 fitFunc->SetParameter(4, 0.0);
381 fitFunc->SetParameter(5, 0.0);
382 fitFunc->SetParameter(6, 0.0);
384 fitFunc->SetParLimits(1, 0.1, 0.2);
387 h->Fit(
"fitFunc",
"QN");
390 double mean = fitFunc->GetParameter(1);
391 double errorOnMean = fitFunc->GetParError(1);
394 std::pair<double, double> result(mean, errorOnMean);
401 TFile* fin =
new TFile(infile.c_str());
402 cout <<
"getting hists" << endl;
403 TH1F* h_peak_eta =
new TH1F(
"h_peak_eta",
"", 96, 0, 96);
404 if (!fin) cout <<
"CaloAna::fitEtaSlices null fin" << endl;
406 for (
int i = 0;
i < 96;
i++) h_M_eta[
i] = (TH1F*) fin->Get(Form(
"h_mass_eta_lt%d",
i));
408 for (
int i = 0;
i < 96;
i++)
410 if (!h_M_eta[
i]) cout <<
"CaloAna::fitEtaSlices null hist" << endl;
411 std::pair<double, double> result =
fitHistogram(h_M_eta[i]);
412 h_peak_eta->SetBinContent(i + 1, result.first);
413 h_peak_eta->SetBinError(i + 1, result.second);
420 string m_fieldname =
"Femc_datadriven_qm1_correction";
422 for (
int i = 0;
i < 96;
i++)
424 for (
int j = 0;
j < 256;
j++)
429 cdbttree2->SetFloatValue(key, m_fieldname, val1 * correction);
434 cdbttree2->WriteCDBTTree();
438 TFile* fit_out =
new TFile(fitOutFile.c_str(),
"recreate");
441 for (
int i = 0;
i < 96;
i++)
449 cout <<
"finish fitting suc" << endl;