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