9 #include <ecl/modules/eclClusterProperties/ECLClusterPropertiesModule.h>
10 #include <ecl/geometry/ECLGeometryPar.h>
27 setDescription(
"This module calculates some properties of ECL clusters.");
28 setPropertyFlags(c_ParallelProcessingCertified);
30 addParam(
"trackClusterRelationName", m_trackClusterRelationName,
"Name of relation array between tracks and ECL clusters",
31 std::string(
"AngularDistance"));
40 m_tracks.isRequired();
41 m_eclShowers.isRequired();
42 m_eclClusters.isRequired();
43 m_eclCalDigits.isRequired();
44 m_extHits.isRequired();
49 for (
auto& shower : m_eclShowers) {
51 unsigned short trackID = std::numeric_limits<unsigned short>::max();
52 double dist = computeTrkMinDistance(shower, m_tracks, trackID);
53 shower.setMinTrkDistance(dist);
55 if (cluster !=
nullptr) {
56 cluster->setMinTrkDistance(
float(dist));
57 cluster->setMinTrkDistanceID(trackID);
62 if (cluster->isTrack()) {
64 computeDepth(shower, lTrk, lShower);
65 B2DEBUG(29,
"shower depth: ltrk = " << lTrk <<
" lShower = " << lShower);
66 shower.setTrkDepth(lTrk);
67 shower.setShowerDepth(lShower);
68 cluster->setdeltaL(lTrk);
75 unsigned short& trackID)
const
77 double minDist(10000);
82 for (
const auto& track : tracks) {
83 TVector3 trkpos(0, 0, 0);
84 for (
const auto& extHit : track.getRelationsTo<
ExtHit>()) {
85 if (abs(extHit.getPdgCode()) != pdgCode)
continue;
86 if ((extHit.getDetectorID() != Const::EDetector::ECL))
continue;
87 if (extHit.getCopyID() == -1)
continue;
88 trkpos = extHit.getPosition();
89 double distance = (cryCenter - trkpos).Mag();
90 if (distance < minDist) {
91 trackID = track.getArrayIndex();
96 if (minDist > 9999) minDist = -1;
105 TVector3 avgDir(0, 0, 0), showerCenter, trkpos, trkdir;
109 for (
unsigned int iRel = 0; iRel < relatedDigitsPairs.size(); iRel++) {
110 const auto aECLCalDigit = relatedDigitsPairs.object(iRel);
111 const auto weight = relatedDigitsPairs.weight(iRel);
112 double energy = weight * aECLCalDigit->getEnergy();
113 int cellid = aECLCalDigit->getCellId();
114 TVector3 cvec = geometry->GetCrystalVec(cellid - 1);
115 avgDir += energy * cvec;
118 if (cluster ==
nullptr)
return;
119 const Track* selectedTrk =
nullptr;
121 for (
const auto& track : cluster->getRelationsFrom<
Track>(
"", m_trackClusterRelationName)) {
124 if (fit != 0) cp = fit->getMomentum().Mag();
126 selectedTrk = &track;
130 if (selectedTrk ==
nullptr)
return;
133 if ((extHit.getDetectorID() != Const::EDetector::ECL))
continue;
134 if (extHit.getStatus() != EXT_ENTER)
continue;
135 if (extHit.getCopyID() == -1)
continue;
136 trkpos = extHit.getPosition();
137 trkdir = extHit.getMomentum().Unit();
142 TVector3 w0 = showerCenter - trkpos;
143 double costh = avgDir.Unit() * trkdir;
144 double sin2th = 1 - costh * costh;
145 lShower = costh * (w0 * trkdir) - w0 * avgDir.Unit();
148 lTrk = w0 * trkdir - costh * (w0 * avgDir.Unit());
Provides a type-safe way to pass members of the chargedStableSet set.
int getPDGCode() const
PDG code.
static const ChargedStable pion
charged pion particle
Class to store calibrated ECLDigits: ECLCalDigits.
This module calculates some properties of ECL clusters.
virtual void initialize() override
Initialize the required input arrays.
virtual void event() override
Event loop.
void computeDepth(const ECLShower &shower, double &lTrk, double &lShower) const
Computation of depths / distances.
virtual ~ECLClusterPropertiesModule()
Destructor.
double computeTrkMinDistance(const ECLShower &, StoreArray< Track > &, unsigned short &trackID) const
Minimal distance between track and shower.
Class to store ECL Showers.
double getPhi() const
Get Phi.
double getR() const
Get R.
double getTheta() const
Get Theta.
The Class for ECL Geometry Parameters.
static ECLGeometryPar * Instance()
Static method to get a reference to the ECLGeometryPar instance.
Store one Ext hit as a ROOT object.
RelationVector< TO > getRelationsTo(const std::string &name="", const std::string &namedRelation="") const
Get the relations that point from this object to another store array.
FROM * getRelatedFrom(const std::string &name="", const std::string &namedRelation="") const
Get the object from which this object has a relation.
Accessor to arrays stored in the data store.
Values of the result of a track fit with a given particle hypothesis.
Class that bundles various TrackFitResults.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.