10#include <arich/modules/arichNtuple/ARICHNtupleModule.h>
13#include <framework/dataobjects/EventMetaData.h>
14#include <arich/dataobjects/ARICHLikelihood.h>
15#include <arich/dataobjects/ARICHAeroHit.h>
16#include <arich/dataobjects/ARICHTrack.h>
17#include <arich/dataobjects/ARICHPhoton.h>
18#include <arich/dataobjects/ARICHHit.h>
19#include <arich/dataobjects/ARICHInfo.h>
22#include <framework/datastore/StoreObjPtr.h>
24#include <mdst/dataobjects/HitPatternCDC.h>
26#ifdef ALIGNMENT_USING_BHABHA
27#include <mdst/dataobjects/ECLCluster.h>
31#include <framework/gearbox/Const.h>
32#include <framework/logging/Logger.h>
35#include <Math/Vector3D.h>
59 setDescription(
"The module saves variables needed for performance analysis, such as postion and momentum of the hit, likelihoods for hypotheses and number of photons.");
75 B2FATAL(
"Couldn't open file '" <<
m_outputFile <<
"' for writing!");
79 m_tree =
new TTree(
"arich",
"ARICH validation ntuple");
90#ifdef ALIGNMENT_USING_BHABHA
134 arichHits.isRequired();
146#ifdef ALIGNMENT_USING_BHABHA
155 for (
const auto& cluster : eclClusters) {
156 if (!cluster.isNeutral())
continue;
157 if (cluster.getHypothesisId() != 5 && cluster.getHypothesisId() != 1)
159 if (cluster.getEnergy() > 0.1) E_tot += cluster.getEnergy();
167 const Track* mdstTrack = NULL;
185 if (arichTrack.hitsWindow()) {
207#ifdef ALIGNMENT_USING_BHABHA
224 ROOT::Math::XYZVector trkPos = fitResult->
getPosition();
229#ifdef ALIGNMENT_USING_BHABHA
230 ROOT::Math::XYZVector trkMom = fitResult->
getMomentum();
239 int fromARICHMCP = 0;
240 particle = mdstTrack->getRelated<
MCParticle>();
241 if (!particle) { particle = mdstTrack->getRelated<
MCParticle>(
"arichMCParticles"); fromARICHMCP = 1;}
245 m_arich.
seen = particle->hasSeenInDetector(Const::ARICH);
246 ROOT::Math::XYZVector prodVertex = particle->getProductionVertex();
250 ROOT::Math::XYZVector decVertex = particle->getDecayVertex();
258 std::vector<Belle2::MCParticle*> daughs = particle->getDaughters();
259 for (
const auto daugh : daughs) {
260 if (daugh == NULL)
continue;
269 const std::vector<ARICHPhoton>& photons = arichTrack.getPhotons();
271 for (
auto it = photons.begin(); it != photons.end(); ++it) {
273 if (iph.
getHitID() < arichHits.getEntries()) {
274 auto ihit = *arichHits[iph.
getHitID()];
275 int module = ihit.getModule();
276 int channel = ihit.getChannel();
277 int chid = 1 << 16 | module << 8 | channel;
283 ROOT::Math::XYZVector recPos = arichTrack.getPosition();
288 ROOT::Math::XYZVector recMom = arichTrack.getDirection() * arichTrack.getMomentum();
294 ROOT::Math::XYZVector truePos = aeroHit->getPosition();
299 ROOT::Math::XYZVector trueMom = aeroHit->getMomentum();
314 m_arich.
seen = particle->hasSeenInDetector(Const::ARICH);
315 ROOT::Math::XYZVector prodVertex = particle->getProductionVertex();
319 ROOT::Math::XYZVector decVertex = particle->getDecayVertex();
324 std::vector<Belle2::MCParticle*> daughs = particle->getDaughters();
325 for (
const auto daugh : daughs) {
Datastore class that holds information on track parameters at the entrance in aerogel.
This is a class to store ARICH likelihoods in the datastore.
TTree * m_tree
pointer to output tree
StoreArray< ARICHAeroHit > m_arichAeroHits
Optional input array of ARICHAeroHits.
std::string m_outputFile
output root file
StoreArray< ARICHTrack > m_arichTracks
Required array of input ARICHTracks.
ARICH::ARICHTree m_arich
ntuple structure
StoreArray< MCParticle > m_arichMCPs
Optional input array of MCParticles.
StoreArray< Track > m_tracks
Optional input array of Tracks.
StoreArray< ARICHLikelihood > m_arichLikelihoods
Required array of input ARICHLikelihoods.
TFile * m_file
pointer to output root file
StoreArray< ARICHInfo > m_arichInfo
Optional input array of ARICHInfo.
Struct for ARICH reconstructed photon (hit related to track) information.
void setHitID(int id)
Set ID of corresponding ARICHHit.
int getHitID()
Get ID of corresponding ARICHHit.
static const ChargedStable muon
muon particle
static const ChargedStable pion
charged pion particle
static const ChargedStable proton
proton particle
static const ChargedStable kaon
charged kaon particle
static const ChargedStable electron
electron particle
static const ChargedStable deuteron
deuteron particle
double getE9oE21() const
Return E9/E21 (shower shape variable).
double getEnergy(EHypothesisBit hypothesis) const
Return Energy (GeV).
Store one Ext hit as a ROOT object.
unsigned short getNHits() const
Get the total Number of CDC hits in the fit.
A Class to store the Monte Carlo particle information.
@ c_PrimaryParticle
bit 0: Particle is primary particle.
int getPDG() const
Return PDG code of particle.
void setDescription(const std::string &description)
Sets the description of the module.
T * getRelated(const std::string &name="", const std::string &namedRelation="") const
Get the object to or from which this object has a relation.
bool isOptional(const std::string &name="")
Tell the DataStore about an optional input.
Accessor to arrays stored in the data store.
Type-safe access to single objects in the data store.
Values of the result of a track fit with a given particle hypothesis.
short getChargeSign() const
Return track charge (1 or -1).
double getPValue() const
Getter for Chi2 Probability of the track fit.
ROOT::Math::XYZVector getMomentum() const
Getter for vector of momentum at closest approach of track in r/phi projection.
ROOT::Math::XYZVector getPosition() const
Getter for vector of position at closest approach of track in r/phi projection.
HitPatternCDC getHitPatternCDC() const
Getter for the hit pattern in the CDC;.
Class that bundles various TrackFitResults.
virtual void initialize() override
Initialize the Module.
virtual void event() override
Event processor.
virtual void terminate() override
Termination action.
virtual ~ARICHNtupleModule()
Destructor.
ARICHNtupleModule()
Constructor.
void addParam(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.
Float_t zDec
Decay vertex (cylindrical coordinate z) of MCParticle.
Int_t detPhot
Number of detected photons.
Int_t nCDC
Number of track CDC hits.
Float_t winHit[2]
Track hit on hapd window (x,y coordinates).
Float_t rhoDec
Decay vertex (cylindrical coordinate r) of MCParticle.
ParticlesArray logL
Log likelihoods.
Int_t scatter
1 if particle scattered (i.e.
Int_t nRec
Number of reconstructed photons.
Short_t primary
Is a primary particle (from related MCParticle).
Short_t seen
Is seen in ARICH (from related MCParticle).
TrackHit recHit
Extrapolated Track hit.
Int_t motherPDG
PDG code of related mother MCParticle.
Int_t exp
Experiment number.
ParticlesArray numBkg
Number of expected background photons.
ParticlesArray expPhot
Number of expected photons (signal + bkg).
std::vector< Belle2::ARICHPhoton > photons
Vector of reconstructed photons.
Float_t phiProd
Production vertex (cylindrical coordinate phi) of MCParticle.
Int_t trgtype
Event trigger type.
Float_t rhoProd
Production vertex (cylindrical coordinate r) of MCParticle.
void clear()
Clear the structure: set elements to zero.
Float_t phiDec
Decay vertex (cylindrical coordinate phi) of MCParticle.
Bool_t inAcc
Track in detector acceptance, i.e.
TrackHit mcHit
Related MC particle hit.
Int_t PDG
PDG code of related MCParticle.
Int_t status
Track status (add proper description).
Float_t pValue
p-value of Track fit.
Float_t zProd
Production vertex (cylindrical coordinate z) of MCParticle.
Float_t p
momentum magnitude
Float_t z
impact point, z component
Float_t theta
momentum polar angle
Float_t phi
momentum azimuthal angle
Float_t x
impact point, x component
Float_t y
impact point, y component