10 #include <ecl/calibration/eclEdgeAlgorithm.h>
13 #include <ecl/dataobjects/ECLElementNumbers.h>
14 #include <ecl/dbobjects/ECLCrystalCalib.h>
17 #include <TDirectory.h>
29 using namespace Calibration;
36 "Generate payloads ECLCrystalThetaEdge and ECLCrystalPhiEdge found by eclEdgeCollector"
47 auto eclCrystalX = getObjectPtr<TH1F>(
"eclCrystalX");
48 auto eclCrystalY = getObjectPtr<TH1F>(
"eclCrystalY");
49 auto eclCrystalZ = getObjectPtr<TH1F>(
"eclCrystalZ");
50 auto eclCrystalR = getObjectPtr<TH1F>(
"eclCrystalR");
51 auto eclCrystalTheta = getObjectPtr<TH1F>(
"eclCrystalTheta");
52 auto eclCrystalPhi = getObjectPtr<TH1F>(
"eclCrystalPhi");
53 auto eclCrystalDirTheta = getObjectPtr<TH1F>(
"eclCrystalDirTheta");
54 auto eclCrystalDirPhi = getObjectPtr<TH1F>(
"eclCrystalDirPhi");
55 auto eclCrystalEdgeTheta = getObjectPtr<TH1F>(
"eclCrystalEdgeTheta");
56 auto eclCrystalEdgePhi = getObjectPtr<TH1F>(
"eclCrystalEdgePhi");
57 auto eclEdgeCounter = getObjectPtr<TH1F>(
"eclEdgeCounter");
60 TFile* histfile =
new TFile(
"eclEdgeAlgorithm.root",
"recreate");
65 eclCrystalTheta->Write();
66 eclCrystalPhi->Write();
67 eclCrystalDirTheta->Write();
68 eclCrystalDirPhi->Write();
69 eclCrystalEdgeTheta->Write();
70 eclCrystalEdgePhi->Write();
71 eclEdgeCounter->Write();
77 const int nCalls = (int)(eclEdgeCounter->GetBinContent(1) + 0.0001);
80 int firstCrysID[69] = {};
81 for (
int thetaID = 1; thetaID < 69; thetaID++) {
86 TH1F* eclCrystalWidthTheta =
new TH1F(
"eclCrystalWidthTheta",
"Width of each crystal in theta;cellID;crystal width (rad)",
89 TH1F* eclCrystalWidthPhi =
new TH1F(
"eclCrystalWidthPhi",
"Width of each crystal in phi;cellID;crystal width (rad)",
94 std::vector<float> tempThetaEdge;
97 tempThetaEdge.push_back(eclCrystalEdgeTheta->GetBinContent(cellID) / nCalls);
102 B2RESULT(
"eclEdgeAlgorithm: successfully stored payload ECLCrystalThetaEdge");
106 std::vector<float> tempPhiEdge;
108 tempPhiEdge.push_back(eclCrystalEdgePhi->GetBinContent(cellID) / nCalls);
113 B2RESULT(
"eclEdgeAlgorithm: successfully stored payload ECLCrystalPhiEdge");
118 std::vector<float> tempPhiWidth;
120 for (
int thetaID = 0; thetaID < 69; thetaID++) {
123 int nextID = crysID + 1;
125 double width = tempPhiEdge[nextID] - tempPhiEdge[crysID];
126 if (width < 0) {width += 2.*TMath::Pi();}
127 tempPhiWidth.push_back(width);
133 B2RESULT(
"eclEdgeAlgorithm: successfully stored payload ECLCrystalPhiWidth");
137 eclCrystalWidthPhi->SetBinContent(cellID, tempPhiWidth[cellID - 1]);
138 eclCrystalWidthPhi->SetBinError(cellID, 0.);
141 eclCrystalWidthPhi->Write();
146 std::vector<float> tempThetaWidth;
147 for (
int thetaID = 0; thetaID < 68; thetaID++) {
148 for (
int ic = firstCrysID[thetaID]; ic < firstCrysID[thetaID] +
m_crystalsPerRing[thetaID]; ic++) {
149 double minThetaWidth = 999.;
150 double maxThetaWidth = -999.;
151 for (
int icnext = firstCrysID[thetaID + 1]; icnext < firstCrysID[thetaID + 1] +
m_crystalsPerRing[thetaID + 1]; icnext++) {
154 double offset = tempPhiEdge[ic] - tempPhiEdge[icnext];
155 if (offset < -TMath::Pi()) {offset += 2.*TMath::Pi();}
156 if (offset > TMath::Pi()) {offset -= 2.*TMath::Pi();}
157 if (offset >= 0. and offset < tempPhiWidth[icnext]) {
158 double width = tempThetaEdge[icnext] - tempThetaEdge[ic];
159 if (width < minThetaWidth) {minThetaWidth = width;}
160 if (width > maxThetaWidth) {maxThetaWidth = width;}
164 offset = tempPhiEdge[icnext] - tempPhiEdge[ic];
165 if (offset < -TMath::Pi()) {offset += 2.*TMath::Pi();}
166 if (offset > TMath::Pi()) {offset -= 2.*TMath::Pi();}
167 if (offset >= 0. and offset < tempPhiWidth[ic]) {
168 double width = tempThetaEdge[icnext] - tempThetaEdge[ic];
169 if (width < minThetaWidth) {minThetaWidth = width;}
170 if (width > maxThetaWidth) {maxThetaWidth = width;}
174 tempThetaWidth.push_back(0.5 * (maxThetaWidth + minThetaWidth));
179 const double upperThetaEdge = 2.7416;
180 const int thetaID68 = 68;
181 for (
int ic = firstCrysID[thetaID68]; ic < firstCrysID[thetaID68] +
m_crystalsPerRing[thetaID68]; ic++) {
182 tempThetaWidth.push_back(upperThetaEdge - tempThetaEdge[ic]);
189 B2RESULT(
"eclEdgeAlgorithm: successfully stored payload ECLCrystalThetaWidth");
193 eclCrystalWidthTheta->SetBinContent(cellID, tempThetaWidth[cellID - 1]);
194 eclCrystalWidthTheta->SetBinError(cellID, 0.);
197 eclCrystalWidthTheta->Write();
Base class for calibration algorithms.
void saveCalibration(TClonesArray *data, const std::string &name)
Store DBArray payload with given name with default IOV.
void setDescription(const std::string &description)
Set algorithm description (in constructor)
EResult
The result of calibration.
@ c_OK
Finished successfuly =0 in Python.
General DB object to store one calibration number per ECL crystal.
void setCalibVector(const std::vector< float > &CalibConst, const std::vector< float > &CalibConstUnc)
Set vector of constants with uncertainties.
const short m_crystalsPerRing[69]
crystals per thetaID
virtual EResult calibrate() override
..Run algorithm
const int c_NCrystals
Number of crystals.
Abstract base class for different kinds of events.