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