Belle II Software  release-06-00-14
ARICHMCParticlesModule.cc
1 /**************************************************************************
2  * basf2 (Belle II Analysis Software Framework) *
3  * Author: The Belle II Collaboration *
4  * *
5  * See git log for contributors and copyright holders. *
6  * This file is licensed under LGPL-3.0, see LICENSE.md. *
7  **************************************************************************/
8 
9 // Own include
10 #include <arich/modules/arichMCParticles/ARICHMCParticlesModule.h>
11 
12 // framework - DataStore
13 #include <framework/datastore/DataStore.h>
14 
15 // framework aux
16 #include <framework/gearbox/Const.h>
17 #include <framework/logging/Logger.h>
18 
19 
20 using namespace std;
21 
22 namespace Belle2 {
28  //-----------------------------------------------------------------
29  // Register module
30  //-----------------------------------------------------------------
31 
32  REG_MODULE(ARICHMCParticles)
33 
34  //-----------------------------------------------------------------
35  // Implementation
36  //-----------------------------------------------------------------
37 
39  {
40  // set module description (e.g. insert text)
41  setDescription("Creates collection of MCParticles related to tracks that hit ARICH.");
42  // Set property flags
43  setPropertyFlags(c_ParallelProcessingCertified);
44 
45  }
46 
47  ARICHMCParticlesModule::~ARICHMCParticlesModule()
48  {
49  }
50 
51  void ARICHMCParticlesModule::initialize()
52 
53  {
54  // Dependecies check
55  m_tracks.isRequired();
56  m_extHits.isRequired();
57 
58  m_arichMCPs.registerInDataStore();
59  m_tracks.registerRelationTo(m_arichMCPs);
60 
61  }
62 
63  void ARICHMCParticlesModule::beginRun()
64  {
65  }
66 
67  void ARICHMCParticlesModule::event()
68  {
69  Const::EDetector myDetID = Const::EDetector::ARICH; // arich
70  Const::ChargedStable hypothesis = Const::pion;
71  int pdgCode = abs(hypothesis.getPDGCode());
72 
73  for (int itrk = 0; itrk < m_tracks.getEntries(); ++itrk) {
74 
75  const Track* track = m_tracks[itrk];
76  const TrackFitResult* fitResult = track->getTrackFitResultWithClosestMass(hypothesis);
77  if (!fitResult) {
78  B2ERROR("No TrackFitResult for " << hypothesis.getPDGCode());
79  continue;
80  }
81 
82  const MCParticle* particle = track->getRelated<MCParticle>();
83  if (!particle) continue;
84 
85  RelationVector<ExtHit> extHits = DataStore::getRelationsWithObj<ExtHit>(track);
86 
87  for (unsigned i = 0; i < extHits.size(); i++) {
88  const ExtHit* extHit = extHits[i];
89  if (abs(extHit->getPdgCode()) != pdgCode) continue;
90  if (extHit->getDetectorID() != myDetID) continue;
91  if (extHit->getStatus() != EXT_EXIT) continue; // particles registered at the EXIT of the Al plate
92  if (extHit->getMomentum().Z() < 0.0) continue; // track passes in backward
93  if (extHit->getCopyID() == 6789) {
94  //MCParticle arichMCP = *particle;
95  MCParticle* arichP = m_arichMCPs.appendNew(*particle);
96  track->addRelationTo(arichP);
97 
98  }
99 
100  }
101  }
102 
103  }
104 
105 
106  void ARICHMCParticlesModule::endRun()
107  {
108  }
109 
110  void ARICHMCParticlesModule::terminate()
111  {
112  }
113 
114  void ARICHMCParticlesModule::printModuleParams() const
115  {
116  }
117 
118 
120 } // end Belle2 namespace
121 
Provides a type-safe way to pass members of the chargedStableSet set.
Definition: Const.h:470
int getPDGCode() const
PDG code.
Definition: Const.h:354
EDetector
Enum for identifying the detector components (detector and subdetector).
Definition: Const.h:42
Store one Ext hit as a ROOT object.
Definition: ExtHit.h:30
int getPdgCode() const
Get PDG code of this extrapolation's hypothesis.
Definition: ExtHit.h:116
ExtHitStatus getStatus() const
Get state of extrapolation at this hit.
Definition: ExtHit.h:128
TVector3 getMomentum() const
Get momentum at this extrapolation hit.
Definition: ExtHit.h:147
int getCopyID() const
Get detector-element ID of sensitive element within detector.
Definition: ExtHit.h:124
Const::EDetector getDetectorID() const
Get detector ID of this extrapolation hit.
Definition: ExtHit.h:120
A Class to store the Monte Carlo particle information.
Definition: MCParticle.h:32
Class for type safe access to objects that are referred to in relations.
size_t size() const
Get number of relations.
Values of the result of a track fit with a given particle hypothesis.
Class that bundles various TrackFitResults.
Definition: Track.h:25
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:650
Abstract base class for different kinds of events.