Belle II Software  release-06-02-00
ARICHRelateModule.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/arichRelate/ARICHRelateModule.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 using namespace std;
20 
21 namespace Belle2 {
27  //-----------------------------------------------------------------
28  // Register module
29  //-----------------------------------------------------------------
30 
31  REG_MODULE(ARICHRelate)
32 
33  //-----------------------------------------------------------------
34  // Implementation
35  //-----------------------------------------------------------------
36 
38  {
39  // set module description (e.g. insert text)
40  setDescription("Creates relations between ARICHAeroHits and ExtHits. Allows to store simulation output without MCParticles");
41  // Set property flags
42  setPropertyFlags(c_ParallelProcessingCertified);
43 
44  }
45 
46  ARICHRelateModule::~ARICHRelateModule()
47  {
48  }
49 
50  void ARICHRelateModule::initialize()
51 
52  {
53  // Dependecies check
54  m_mcParticles.isRequired();
55  m_mdstTracks.isRequired();
56  m_aeroHits.isRequired();
57  m_extHits.isRequired();
58  m_extHits.registerRelationTo(m_aeroHits);
59  }
60 
61  void ARICHRelateModule::beginRun()
62  {
63  }
64 
65  void ARICHRelateModule::event()
66  {
67  int nHits = m_aeroHits.getEntries();
68  B2DEBUG(50, "No. of hits " << nHits);
69 
70  for (int iHit = 0; iHit < nHits; ++iHit) {
71  const ARICHAeroHit* aeroHit = m_aeroHits[iHit];
72  const MCParticle* particle = DataStore::getRelated<MCParticle>(aeroHit);
73  if (!particle) {
74  B2DEBUG(50, "No MCParticle for AeroHit!");
75  continue;
76  }
77 
78  // Find the track produced by MCParticle
79  const Track* track = DataStore::getRelated<Track>(particle);
80  if (!track) continue;
81 
82  const TrackFitResult* fitResult = track->getTrackFitResultWithClosestMass(Const::pion);
83  if (!fitResult) continue;
84 
85  RelationVector<ExtHit> extHits = DataStore::getRelationsWithObj<ExtHit>(track);
86  Const::EDetector myDetID = Const::EDetector::ARICH;
87  for (unsigned i = 0; i < extHits.size(); i++) {
88  const ExtHit* extHit = extHits[i];
89  if (abs(extHit->getPdgCode()) != Const::pion.getPDGCode()) continue;
90  if (extHit->getDetectorID() != myDetID) continue;
91  if (extHit->getCopyID() != 6789) continue; // aerogel Al support plate
92  if (extHit->getStatus() != EXT_EXIT) continue; // particles registered at the EXIT of the Al plate
93  extHit->addRelationTo(aeroHit);
94  break;
95  }
96  }
97  }
98 
99 
100  void ARICHRelateModule::endRun()
101  {
102  }
103 
104  void ARICHRelateModule::terminate()
105  {
106  }
107 
108  void ARICHRelateModule::printModuleParams() const
109  {
110  }
111 
112 
114 } // end Belle2 namespace
115 
Datastore class that holds information on track parameters at the entrance in aerogel.
Definition: ARICHAeroHit.h:27
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
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.
void addRelationTo(const RelationsInterface< BASE > *object, float weight=1.0, const std::string &namedRelation="") const
Add a relation from this object to another object (with caching).
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.