Belle II Software  release-05-02-19
PXDROIFinderModule.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2011 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Giulia Casarosa, Eugenio Paoloni *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #include <tracking/modules/pxdDataReduction/PXDROIFinderModule.h>
12 #include <framework/datastore/StoreArray.h>
13 #include <framework/datastore/RelationArray.h>
14 #include <genfit/MaterialEffects.h>
15 
16 using namespace std;
17 using namespace Belle2;
18 
19 //-----------------------------------------------------------------
20 // Register the Module
21 //-----------------------------------------------------------------
22 REG_MODULE(PXDROIFinder)
23 
24 //-----------------------------------------------------------------
25 // Implementation
26 //-----------------------------------------------------------------
27 
29 {
30  //Set module properties
31  setDescription("This module performs the reduction of the PXD data output");
32  setPropertyFlags(c_ParallelProcessingCertified);
33 
34 
35  addParam("recoTrackListName", m_recoTracksListName, " name of the list of the fitted tracks", std::string(""));
36 
37  addParam("tolerancePhi", m_tolerancePhi, "Tolerance by finding sensor in phi coordinate (radians).", double(0.15));
38 
39  addParam("toleranceZ", m_toleranceZ, "Tolerance by finding sensor in Z coordinate (cm).", double(0.5));
40 
41  addParam("sigmaSystU", m_sigmaSystU, " systematic sigma in the u local coordinate ", double(0.025));
42  addParam("sigmaSystV", m_sigmaSystV, " systematic sigma in the V local coordinate ", double(0.025));
43  addParam("numSigmaTotU", m_numSigmaTotU, " number of sigmas (total) in the U local coordinate ", double(10));
44  addParam("numSigmaTotV", m_numSigmaTotV, " number of sigmas (total) in the V local coordinate ", double(10));
45  addParam("maxWidthU", m_maxWidthU, " upper limit on width of the ROI in the U local coordinate (cm) ", double(0.5));
46  addParam("maxWidthV", m_maxWidthV, " upper limit on width of the ROI in the V local coordinate (cm) ", double(0.5));
47 
48  addParam("PXDInterceptListName", m_PXDInterceptListName, "name of the list of interceptions", std::string(""));
49  addParam("ROIListName", m_ROIListName, "name of the list of ROIs", std::string(""));
50 
51 }
52 
53 
54 void PXDROIFinderModule::initialize()
55 {
56  StoreArray<RecoTrack> trackList(m_recoTracksListName);
57 
58  StoreArray<ROIid> ROIList(m_ROIListName);
59  ROIList.registerInDataStore(DataStore::c_ErrorIfAlreadyRegistered);
60 
61  StoreArray<PXDIntercept> PXDInterceptList(m_PXDInterceptListName);
62  PXDInterceptList.registerInDataStore(DataStore::c_ErrorIfAlreadyRegistered);
63 
64  trackList.registerRelationTo(PXDInterceptList);
65  PXDInterceptList.registerRelationTo(ROIList);
66 
67 
68  if (!genfit::MaterialEffects::getInstance()->isInitialized()) {
69  B2FATAL("Material effects not set up. Please use SetupGenfitExtrapolationModule.");
70  }
71 
72 }
73 
74 void PXDROIFinderModule::beginRun()
75 {
76 
77  B2DEBUG(1, "||| PXDROIFinder Parameters:");
78  B2DEBUG(1, " tolerance: phi = " << m_tolerancePhi);
79  B2DEBUG(1, " z = " << m_toleranceZ);
80  B2DEBUG(1, " n sigma: u = " << m_numSigmaTotU);
81  B2DEBUG(1, " v = " << m_numSigmaTotV);
82  B2DEBUG(1, " systematic: u = " << m_sigmaSystU);
83  B2DEBUG(1, " v = " << m_sigmaSystV);
84  B2DEBUG(1, " max width: u = " << m_maxWidthU);
85  B2DEBUG(1, " v = " << m_maxWidthV);
86 
87  m_ROIinfo.sigmaSystU = m_sigmaSystU;
88  m_ROIinfo.sigmaSystV = m_sigmaSystV;
89  m_ROIinfo.numSigmaTotU = m_numSigmaTotU;
90  m_ROIinfo.numSigmaTotV = m_numSigmaTotV;
91  m_ROIinfo.maxWidthU = m_maxWidthU;
92  m_ROIinfo.maxWidthV = m_maxWidthV;
93  m_ROIinfo.PXDInterceptListName = m_PXDInterceptListName;
94  m_ROIinfo.ROIListName = m_ROIListName;
95  m_ROIinfo.recoTracksListName = m_recoTracksListName;
96 
97  m_thePXDInterceptor = new PXDInterceptor(&m_ROIinfo, m_toleranceZ, m_tolerancePhi);
98 
99  m_thePixelTranslator = new ROIPixelTranslator(&m_ROIinfo);
100 
101 }
102 
103 
104 void PXDROIFinderModule::event()
105 {
106 
107  StoreArray<PXDIntercept> PXDInterceptList(m_PXDInterceptListName);
108 
109  StoreArray<ROIid> ROIList(m_ROIListName);
110 
111  StoreArray<RecoTrack> trackList(m_recoTracksListName);
112  B2DEBUG(1, "%%%%%%%% Number of RecoTracks in the events = " << trackList.getEntries());
113 
114  RelationArray recoTrackToPXDIntercepts(trackList, PXDInterceptList);
115  recoTrackToPXDIntercepts.create();
116 
117  RelationArray PXDInterceptsToROIids(PXDInterceptList, ROIList);
118  PXDInterceptsToROIids.create();
119 
120  // timespec time1, time2, time3;
121 
122  // clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &time1);
123 
124  if (m_thePXDInterceptor) m_thePXDInterceptor->fillInterceptList(&PXDInterceptList, trackList, &recoTrackToPXDIntercepts);
125 
126  //clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &time2);
127 
128  if (m_thePixelTranslator) m_thePixelTranslator->fillRoiIDList(&PXDInterceptList, &ROIList);
129 
130  // clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &time3);
131 
132 }
133 
134 
135 void PXDROIFinderModule::endRun()
136 {
137  if (m_thePixelTranslator) delete m_thePixelTranslator;
138  if (m_thePXDInterceptor) delete m_thePXDInterceptor;
139 }
140 
Belle2::RelationArray
Low-level class to create/modify relations between StoreArrays.
Definition: RelationArray.h:72
Belle2::ROIPixelTranslator
Translator for ROI-geometry-information into a list of pixels.
Definition: ROIPixelTranslator.h:34
Belle2::StoreArray::registerRelationTo
bool registerRelationTo(const StoreArray< TO > &toArray, DataStore::EDurability durability=DataStore::c_Event, DataStore::EStoreFlags storeFlags=DataStore::c_WriteOut, const std::string &namedRelation="") const
Register a relation to the given StoreArray.
Definition: StoreArray.h:150
REG_MODULE
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:652
Belle2::RelationArray::create
bool create(bool replace=false)
Create an empty relation array in the data store.
Definition: RelationArray.h:163
Belle2::Module
Base class for Modules.
Definition: Module.h:74
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::PXDInterceptor
The PXDInterceptor class fills a StoreArray of PXDIntercepts that will be used to define the PXD ROIs...
Definition: PXDInterceptor.h:40
Belle2::PXDROIFinderModule
The PXD ROI Finder Module.
Definition: PXDROIFinderModule.h:43
Belle2::StoreArray
Accessor to arrays stored in the data store.
Definition: ECLMatchingPerformanceExpertModule.h:33
Belle2::StoreArray::getEntries
int getEntries() const
Get the number of objects in the array.
Definition: StoreArray.h:226