Belle II Software  release-05-02-19
ARICHRelateModule.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2010 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Dino Tahirovic, Luka Santelj *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 // Own include
12 #include <arich/modules/arichRelate/ARICHRelateModule.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 using namespace std;
22 
23 namespace Belle2 {
29  //-----------------------------------------------------------------
30  // Register module
31  //-----------------------------------------------------------------
32 
33  REG_MODULE(ARICHRelate)
34 
35  //-----------------------------------------------------------------
36  // Implementation
37  //-----------------------------------------------------------------
38 
40  {
41  // set module description (e.g. insert text)
42  setDescription("Creates relations between ARICHAeroHits and ExtHits. Allows to store simulation output without MCParticles");
43  // Set property flags
44  setPropertyFlags(c_ParallelProcessingCertified);
45 
46  }
47 
48  ARICHRelateModule::~ARICHRelateModule()
49  {
50  }
51 
52  void ARICHRelateModule::initialize()
53 
54  {
55  // Dependecies check
56  m_mcParticles.isRequired();
57  m_mdstTracks.isRequired();
58  m_aeroHits.isRequired();
59  m_extHits.isRequired();
60  m_extHits.registerRelationTo(m_aeroHits);
61  }
62 
63  void ARICHRelateModule::beginRun()
64  {
65  }
66 
67  void ARICHRelateModule::event()
68  {
69  int nHits = m_aeroHits.getEntries();
70  B2DEBUG(50, "No. of hits " << nHits);
71 
72  for (int iHit = 0; iHit < nHits; ++iHit) {
73  const ARICHAeroHit* aeroHit = m_aeroHits[iHit];
74  const MCParticle* particle = DataStore::getRelated<MCParticle>(aeroHit);
75  if (!particle) {
76  B2DEBUG(50, "No MCParticle for AeroHit!");
77  continue;
78  }
79 
80  int pdg = 211;
81 
82  // Find the track produced by MCParticle
83  const Track* track = DataStore::getRelated<Track>(particle);
84  if (!track) continue;
85 
86  const TrackFitResult* fitResult = track->getTrackFitResultWithClosestMass(Const::pion);
87  if (!fitResult) continue;
88 
89  RelationVector<ExtHit> extHits = DataStore::getRelationsWithObj<ExtHit>(track);
90  Const::EDetector myDetID = Const::EDetector::ARICH;
91  for (unsigned i = 0; i < extHits.size(); i++) {
92  const ExtHit* extHit = extHits[i];
93  if (abs(extHit->getPdgCode()) != pdg) continue;
94  if (extHit->getDetectorID() != myDetID) continue;
95  if (extHit->getCopyID() != 6789) continue; // aerogel Al support plate
96  if (extHit->getStatus() != EXT_EXIT) continue; // particles registered at the EXIT of the Al plate
97  extHit->addRelationTo(aeroHit);
98  break;
99  }
100  }
101  }
102 
103 
104  void ARICHRelateModule::endRun()
105  {
106  }
107 
108  void ARICHRelateModule::terminate()
109  {
110  }
111 
112  void ARICHRelateModule::printModuleParams() const
113  {
114  }
115 
116 
118 } // end Belle2 namespace
119 
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::ExtHit::getDetectorID
Const::EDetector getDetectorID() const
Get detector ID of this extrapolation hit.
Definition: ExtHit.h:130
Belle2::ARICHAeroHit
Datastore class that holds information on track parameters at the entrance in aerogel.
Definition: ARICHAeroHit.h:37
Belle2::RelationsInterface::addRelationTo
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).
Definition: RelationsObject.h:144
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::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
Belle2::ARICHRelateModule
Definition: ARICHRelateModule.h:43