1 #include <ecl/calibration/eclEdgeAlgorithm.h>
2 #include <ecl/dbobjects/ECLCrystalCalib.h>
7 #include "TDirectory.h"
13 using namespace Calibration;
20 "Generate payloads ECLCrystalThetaEdge and ECLCrystalPhiEdge found by eclEdgeCollector"
31 auto eclCrystalX = getObjectPtr<TH1F>(
"eclCrystalX");
32 auto eclCrystalY = getObjectPtr<TH1F>(
"eclCrystalY");
33 auto eclCrystalZ = getObjectPtr<TH1F>(
"eclCrystalZ");
34 auto eclCrystalR = getObjectPtr<TH1F>(
"eclCrystalR");
35 auto eclCrystalTheta = getObjectPtr<TH1F>(
"eclCrystalTheta");
36 auto eclCrystalPhi = getObjectPtr<TH1F>(
"eclCrystalPhi");
37 auto eclCrystalDirTheta = getObjectPtr<TH1F>(
"eclCrystalDirTheta");
38 auto eclCrystalDirPhi = getObjectPtr<TH1F>(
"eclCrystalDirPhi");
39 auto eclCrystalEdgeTheta = getObjectPtr<TH1F>(
"eclCrystalEdgeTheta");
40 auto eclCrystalEdgePhi = getObjectPtr<TH1F>(
"eclCrystalEdgePhi");
41 auto eclEdgeCounter = getObjectPtr<TH1F>(
"eclEdgeCounter");
44 TFile* histfile =
new TFile(
"eclEdgeAlgorithm.root",
"recreate");
49 eclCrystalTheta->Write();
50 eclCrystalPhi->Write();
51 eclCrystalDirTheta->Write();
52 eclCrystalDirPhi->Write();
53 eclCrystalEdgeTheta->Write();
54 eclCrystalEdgePhi->Write();
55 eclEdgeCounter->Write();
61 const int nCalls = (int)(eclEdgeCounter->GetBinContent(1) + 0.0001);
64 int firstCrysID[69] = {};
65 for (
int thetaID = 1; thetaID < 69; thetaID++) {
70 TH1F* eclCrystalWidthTheta =
new TH1F(
"eclCrystalWidthTheta",
"Width of each crystal in theta;cellID;crystal width (rad)", 8736, 1,
72 TH1F* eclCrystalWidthPhi =
new TH1F(
"eclCrystalWidthPhi",
"Width of each crystal in phi;cellID;crystal width (rad)", 8736, 1, 8737);
76 std::vector<float> tempThetaEdge;
77 std::vector<float> tempUnc(8736, 0.);
78 for (
int cellID = 1; cellID <= 8736; cellID++) {
79 tempThetaEdge.push_back(eclCrystalEdgeTheta->GetBinContent(cellID) / nCalls);
84 B2RESULT(
"eclEdgeAlgorithm: successfully stored payload ECLCrystalThetaEdge");
88 std::vector<float> tempPhiEdge;
89 for (
int cellID = 1; cellID <= 8736; cellID++) {
90 tempPhiEdge.push_back(eclCrystalEdgePhi->GetBinContent(cellID) / nCalls);
95 B2RESULT(
"eclEdgeAlgorithm: successfully stored payload ECLCrystalPhiEdge");
100 std::vector<float> tempPhiWidth;
102 for (
int thetaID = 0; thetaID < 69; thetaID++) {
105 int nextID = crysID + 1;
107 double width = tempPhiEdge[nextID] - tempPhiEdge[crysID];
108 if (width < 0) {width += 2.*TMath::Pi();}
109 tempPhiWidth.push_back(width);
115 B2RESULT(
"eclEdgeAlgorithm: successfully stored payload ECLCrystalPhiWidth");
118 for (
int cellID = 1; cellID <= 8736; cellID++) {
119 eclCrystalWidthPhi->SetBinContent(cellID, tempPhiWidth[cellID - 1]);
120 eclCrystalWidthPhi->SetBinError(cellID, 0.);
123 eclCrystalWidthPhi->Write();
128 std::vector<float> tempThetaWidth;
129 for (
int thetaID = 0; thetaID < 68; thetaID++) {
130 for (
int ic = firstCrysID[thetaID]; ic < firstCrysID[thetaID] +
m_crystalsPerRing[thetaID]; ic++) {
131 double minThetaWidth = 999.;
132 double maxThetaWidth = -999.;
133 for (
int icnext = firstCrysID[thetaID + 1]; icnext < firstCrysID[thetaID + 1] +
m_crystalsPerRing[thetaID + 1]; icnext++) {
136 double offset = tempPhiEdge[ic] - tempPhiEdge[icnext];
137 if (offset < -TMath::Pi()) {offset += 2.*TMath::Pi();}
138 if (offset > TMath::Pi()) {offset -= 2.*TMath::Pi();}
139 if (offset >= 0. and offset < tempPhiWidth[icnext]) {
140 double width = tempThetaEdge[icnext] - tempThetaEdge[ic];
141 if (width < minThetaWidth) {minThetaWidth = width;}
142 if (width > maxThetaWidth) {maxThetaWidth = width;}
146 offset = tempPhiEdge[icnext] - tempPhiEdge[ic];
147 if (offset < -TMath::Pi()) {offset += 2.*TMath::Pi();}
148 if (offset > TMath::Pi()) {offset -= 2.*TMath::Pi();}
149 if (offset >= 0. and offset < tempPhiWidth[ic]) {
150 double width = tempThetaEdge[icnext] - tempThetaEdge[ic];
151 if (width < minThetaWidth) {minThetaWidth = width;}
152 if (width > maxThetaWidth) {maxThetaWidth = width;}
156 tempThetaWidth.push_back(0.5 * (maxThetaWidth + minThetaWidth));
161 const double upperThetaEdge = 2.7416;
162 const int thetaID68 = 68;
163 for (
int ic = firstCrysID[thetaID68]; ic < firstCrysID[thetaID68] +
m_crystalsPerRing[thetaID68]; ic++) {
164 tempThetaWidth.push_back(upperThetaEdge - tempThetaEdge[ic]);
171 B2RESULT(
"eclEdgeAlgorithm: successfully stored payload ECLCrystalThetaWidth");
174 for (
int cellID = 1; cellID <= 8736; cellID++) {
175 eclCrystalWidthTheta->SetBinContent(cellID, tempThetaWidth[cellID - 1]);
176 eclCrystalWidthTheta->SetBinError(cellID, 0.);
179 eclCrystalWidthTheta->Write();