10#include <ecl/modules/eclEdgeCollector/eclEdgeCollectorModule.h>
13#include <ecl/dataobjects/ECLElementNumbers.h>
14#include <ecl/dbobjects/ECLCrystalCalib.h>
15#include <ecl/geometry/ECLGeometryPar.h>
18#include <Math/Vector3D.h>
35 m_ECLCrystalOffsetPhi(
"ECLCrystalOffsetPhi")
38 setDescription(
"Obtain location of crystal edges from geometry and ECLCrystalOffsetTheta and ECLCrystalOffsetPhi payloads.");
45 registerObject<TH1F>(
"eclCrystalX", eclCrystalX);
48 registerObject<TH1F>(
"eclCrystalY", eclCrystalY);
51 registerObject<TH1F>(
"eclCrystalZ", eclCrystalZ);
54 registerObject<TH1F>(
"eclCrystalR", eclCrystalR);
56 auto eclCrystalTheta =
new TH1F(
"eclCrystalTheta",
"theta of each crystal location;cellID;theta (rad)",
58 registerObject<TH1F>(
"eclCrystalTheta", eclCrystalTheta);
62 registerObject<TH1F>(
"eclCrystalPhi", eclCrystalPhi);
64 auto eclCrystalDirTheta =
new TH1F(
"eclCrystalDirTheta",
"theta of each crystal direction;cellID;theta (rad)",
66 registerObject<TH1F>(
"eclCrystalDirTheta", eclCrystalDirTheta);
68 auto eclCrystalDirPhi =
new TH1F(
"eclCrystalDirPhi",
"phi of each crystal direction;cellID;phi (rad)",
70 registerObject<TH1F>(
"eclCrystalDirPhi", eclCrystalDirPhi);
72 auto eclCrystalEdgeTheta =
new TH1F(
"eclCrystalEdgeTheta",
"lower edge of each crystal in theta;cellID;theta (rad)",
74 registerObject<TH1F>(
"eclCrystalEdgeTheta", eclCrystalEdgeTheta);
76 auto eclCrystalEdgePhi =
new TH1F(
"eclCrystalEdgePhi",
"lower edge of each crystal in phi;cellID;phi (rad)",
78 registerObject<TH1F>(
"eclCrystalEdgePhi", eclCrystalEdgePhi);
80 auto eclEdgeCounter =
new TH1F(
"eclEdgeCounter",
"dummy histogram to count collector calls;cellID;calls",
82 registerObject<TH1F>(
"eclEdgeCounter", eclEdgeCounter);
93 std::vector<float> offsetTheta;
95 std::vector<float> offsetPhi;
101 ROOT::Math::XYZVector crystalPos = eclGeometry->
GetCrystalPos(cellID - 1);
102 ROOT::Math::XYZVector crystalDirection = eclGeometry->
GetCrystalVec(cellID - 1);
103 getObjectPtr<TH1F>(
"eclCrystalX")->SetBinContent(cellID, crystalPos.X());
104 getObjectPtr<TH1F>(
"eclCrystalY")->SetBinContent(cellID, crystalPos.Y());
105 getObjectPtr<TH1F>(
"eclCrystalZ")->SetBinContent(cellID, crystalPos.Z());
106 getObjectPtr<TH1F>(
"eclCrystalR")->SetBinContent(cellID, crystalPos.R());
107 getObjectPtr<TH1F>(
"eclCrystalTheta")->SetBinContent(cellID, crystalPos.Theta());
108 getObjectPtr<TH1F>(
"eclCrystalPhi")->SetBinContent(cellID, crystalPos.Phi());
109 getObjectPtr<TH1F>(
"eclCrystalDirTheta")->SetBinContent(cellID, crystalDirection.Theta());
110 getObjectPtr<TH1F>(
"eclCrystalDirPhi")->SetBinContent(cellID, crystalDirection.Phi());
111 getObjectPtr<TH1F>(
"eclEdgeCounter")->SetBinContent(cellID, 1);
114 float thetaEdge = crystalPos.Theta() - offsetTheta[cellID - 1];
115 getObjectPtr<TH1F>(
"eclCrystalEdgeTheta")->SetBinContent(cellID, thetaEdge);
117 float phiEdge = crystalPos.Phi();
118 if (!offsetPhi.empty()) phiEdge -= offsetPhi[cellID - 1];
119 if (phiEdge < -TMath::Pi()) {phiEdge += 2 * TMath::Pi();}
120 getObjectPtr<TH1F>(
"eclCrystalEdgePhi")->SetBinContent(cellID, phiEdge);
123 if (cellID % 1000 == 0) {
124 B2INFO(
"cellID " << cellID <<
": theta " << crystalPos.Theta() <<
" phi " <<
125 crystalPos.Phi() <<
" R " << crystalPos.R() <<
" thetaEdge " << thetaEdge <<
" phiEdge " << phiEdge);
Calibration collector module base class.
The Class for ECL Geometry Parameters.
static ECLGeometryPar * Instance()
Static method to get a reference to the ECLGeometryPar instance.
ROOT::Math::XYZVector GetCrystalPos(int cid)
The Position of crystal.
ROOT::Math::XYZVector GetCrystalVec(int cid)
The direction of crystal.
void setDescription(const std::string &description)
Sets the description of the module.
bool storeGeo
force geometry to be saved first event
DBObjPtr< ECLCrystalCalib > m_ECLCrystalOffsetPhi
offset in phi
virtual void collect() override
Accumulate histograms.
DBObjPtr< ECLCrystalCalib > m_ECLCrystalOffsetTheta
Offset between crystal center and lower edge, from database.
virtual void prepare() override
Define histograms and read payloads from DB.
eclEdgeCollectorModule()
Constructor: Sets the description, the properties and the parameters of the module.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
const int c_NCrystals
Number of crystals.
Abstract base class for different kinds of events.