Belle II Software  release-05-02-19
SVDMissingAPVsClusterCreatorModule.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2010 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Giulia Casarosa *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #include <svd/modules/svdReconstruction/SVDMissingAPVsClusterCreatorModule.h>
12 
13 #include <framework/datastore/DataStore.h>
14 #include <framework/logging/Logger.h>
15 
16 #include <vxd/geometry/GeoCache.h>
17 #include <svd/geometry/SensorInfo.h>
18 
19 using namespace std;
20 using namespace Belle2;
21 using namespace Belle2::SVD;
22 
23 
24 //-----------------------------------------------------------------
25 // Register the Module
26 //-----------------------------------------------------------------
27 REG_MODULE(SVDMissingAPVsClusterCreator)
28 
29 //-----------------------------------------------------------------
30 // Implementation
31 //-----------------------------------------------------------------
32 
33 std::string Belle2::SVD::SVDMissingAPVsClusterCreatorModule::m_xmlFileName = std::string("SVDChannelMapping.xml");
34 
35 SVDMissingAPVsClusterCreatorModule::SVDMissingAPVsClusterCreatorModule()
36  : Module()
37  , m_mapping(m_xmlFileName)
38 {
39  //Set module properties
40  setDescription("This module produces clusters in the middle of a region read by a disabled APV. It can be run only after the SVDSimpleClusterizer because it does not register the SVDClusters StoreArray in the DataStore, but only add clusters.");
42 
43  addParam("Clusters", m_storeClustersName,
44  "SVDCluster collection name", string(""));
45 
46  addParam("time", m_time, "cluster time", float(0));
47  addParam("timeError", m_timeError, "cluster time error", float(10));
48  addParam("seedCharge", m_seedCharge, "cluster seed charge (in e-)", float(10000));
49  addParam("charge", m_charge, "cluster charge (in e-)", float(20000));
50  addParam("SNR", m_SNR, "cluster SNR", float(15));
51  addParam("size", m_size, "cluster size", int(128));
52  addParam("firstFrame", m_firstFrame, "first frame, needed to build the cluster", int(0));
53  addParam("nFakeClusters", m_nFakeClusters, "number of fake clusters equally distributed in the dead area", int(4));
54 }
55 
57 {
58 
59  if (m_mapping.hasChanged()) { m_map = std::make_unique<SVDOnlineToOfflineMap>(m_mapping->getFileName()); }
60 
61  m_map->prepareListOfMissingAPVs();
62  B2DEBUG(29, " found a total of " << m_map->getNumberOfMissingAPVs() << " missing APVs in the channel mapping");
63 
64 }
65 
67 {
68  //Register clusters only if the SVDClusters are not already registered
69  // this makes some test fail. Commented out until we find a bug-fix.
70  // if(!m_storeClusters.isValid())
71  // m_storeClusters.registerInDataStore(m_storeClustersName);
72 
73  //Store names to speed up creation later
75 
76  // Report:
77  B2DEBUG(1, "SVDMissingAPVsClusterCreator Parameters (in default system unit, *=cannot be set directly):");
78 
79  B2DEBUG(1, " 1. COLLECTIONS:");
80  B2DEBUG(1, " --> SVDClusters: " << DataStore::arrayName<SVDCluster>(m_storeClustersName));
81 }
82 
83 
84 
86 {
87 
89 
90  for (int nAPV = 0; nAPV < m_map->getNumberOfMissingAPVs(); nAPV++) {
91 
92  SVDOnlineToOfflineMap::missingAPV tmp_missingAPV = (m_map->m_missingAPVs).at(nAPV);
93 
94  VxdID sensorID = tmp_missingAPV.m_sensorID;
95  bool isU = tmp_missingAPV.m_isUSide;
96 
97  //position
98  const VXD::SensorInfoBase& info = geo.getSensorInfo(sensorID);
99  float floatingStrip = tmp_missingAPV.m_halfStrip;
100  double pitch = isU ? info.getUPitch(0) : info.getVPitch(0);
101 
102  float halfChip_position = isU ? info.getUCellPosition(floatingStrip) : info.getVCellPosition(floatingStrip);
103  const int Nstrips = 128; //number of strips in each APV
104  float positionError = Nstrips * pitch / sqrt(12);
105 
106  //time
107  float time = m_time;
108  float timeError = m_timeError;
109 
110  //charge
111  float seedCharge = m_seedCharge;
112  float charge = m_charge;
113  float size = m_size;
114  float SNR = m_SNR;
115 
116  // Built m_nFakeClusters equally distributed
117  float fakeCluster_width = pitch * Nstrips / m_nFakeClusters;
118  float chip_halfWidth = pitch * Nstrips / 2;
119  float firstStrip_position = halfChip_position - chip_halfWidth;
120 
121  //position of the first fake cluster:
122  float fakeCluster_position = firstStrip_position + fakeCluster_width / 2;
123  //store first fake cluster:
125  sensorID, isU, fakeCluster_position, positionError, time, timeError, charge, seedCharge, size, SNR, m_firstFrame
126  ));
127  // Store all other Fake Clusters into DataStore
128  for (int i = 1; i < m_nFakeClusters; i++) {
129  fakeCluster_position = fakeCluster_position + fakeCluster_width;
131  sensorID, isU, fakeCluster_position, positionError, time, timeError, charge, seedCharge, size, SNR, m_firstFrame
132  ));
133  }
134  }
135  B2DEBUG(1, "Number of clusters: " << m_storeClusters.getEntries());
136 }
137 
Belle2::StoreArray::appendNew
T * appendNew()
Construct a new T object at the end of the array.
Definition: StoreArray.h:256
Belle2::DBAccessorBase::hasChanged
bool hasChanged()
Check whether the object has changed since the last call to hasChanged of the accessor).
Definition: DBAccessorBase.h:92
Belle2::SVD::SVDMissingAPVsClusterCreatorModule::m_xmlFileName
static std::string m_xmlFileName
< channel mapping xml filename
Definition: SVDMissingAPVsClusterCreatorModule.h:79
Belle2::VxdID
Class to uniquely identify a any structure of the PXD and SVD.
Definition: VxdID.h:43
Belle2::SVD::SVDMissingAPVsClusterCreatorModule::m_size
int m_size
size of the cluster
Definition: SVDMissingAPVsClusterCreatorModule.h:71
Belle2::Module::setDescription
void setDescription(const std::string &description)
Sets the description of the module.
Definition: Module.cc:216
Belle2::SVD::SVDMissingAPVsClusterCreatorModule::m_timeError
float m_timeError
time error of the cluster, in ns
Definition: SVDMissingAPVsClusterCreatorModule.h:67
REG_MODULE
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:652
Belle2::Module::c_ParallelProcessingCertified
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
Definition: Module.h:82
Belle2::SVD::SVDMissingAPVsClusterCreatorModule::m_storeClustersName
std::string m_storeClustersName
name of the collection to use for the SVDClusters
Definition: SVDMissingAPVsClusterCreatorModule.h:65
Belle2::SVD::SVDMissingAPVsClusterCreatorModule::m_SNR
float m_SNR
SNR of the cluster.
Definition: SVDMissingAPVsClusterCreatorModule.h:70
Belle2::VXD::SensorInfoBase
Base class to provide Sensor Information for PXD and SVD.
Definition: SensorInfoBase.h:40
Belle2::SVDOnlineToOfflineMap::missingAPV::m_sensorID
VxdID m_sensorID
Sensor ID.
Definition: SVDOnlineToOfflineMap.h:219
Belle2::SVDOnlineToOfflineMap::missingAPV::m_isUSide
bool m_isUSide
True if u-side of the sensor.
Definition: SVDOnlineToOfflineMap.h:220
Belle2::SVD::SVDMissingAPVsClusterCreatorModule::m_mapping
DBObjPtr< PayloadFile > m_mapping
channel mapping payload
Definition: SVDMissingAPVsClusterCreatorModule.h:80
Belle2::SVD::SVDMissingAPVsClusterCreatorModule::m_seedCharge
float m_seedCharge
seed charge of the cluster, in e-
Definition: SVDMissingAPVsClusterCreatorModule.h:68
Belle2::SVD::SVDMissingAPVsClusterCreatorModule::m_map
std::unique_ptr< SVDOnlineToOfflineMap > m_map
channel mapping map
Definition: SVDMissingAPVsClusterCreatorModule.h:81
Belle2::SVDOnlineToOfflineMap::missingAPV::m_halfStrip
float m_halfStrip
floating strip in the middle of the APV
Definition: SVDOnlineToOfflineMap.h:221
Belle2::Module
Base class for Modules.
Definition: Module.h:74
Belle2::Module::setPropertyFlags
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
Definition: Module.cc:210
Belle2::SVDOnlineToOfflineMap::missingAPV
struct to hold missing APVs informations
Definition: SVDOnlineToOfflineMap.h:218
Belle2::VXD::GeoCache::getInstance
static GeoCache & getInstance()
Return a reference to the singleton instance.
Definition: GeoCache.cc:215
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::SVD::SVDMissingAPVsClusterCreatorModule::m_firstFrame
int m_firstFrame
first frame
Definition: SVDMissingAPVsClusterCreatorModule.h:72
Belle2::SVD
Namespace to encapsulate code needed for simulation and reconstrucion of the SVD.
Definition: GeoSVDCreator.h:35
Belle2::SVD::SVDMissingAPVsClusterCreatorModule::event
virtual void event() override
do the clustering
Definition: SVDMissingAPVsClusterCreatorModule.cc:85
Belle2::SVD::SVDMissingAPVsClusterCreatorModule::m_charge
float m_charge
total charge of the cluster, in e-
Definition: SVDMissingAPVsClusterCreatorModule.h:69
Belle2::SVD::SVDMissingAPVsClusterCreatorModule::m_time
float m_time
time of the cluster, in ns
Definition: SVDMissingAPVsClusterCreatorModule.h:66
Belle2::SVD::SVDMissingAPVsClusterCreatorModule::m_storeClusters
StoreArray< SVDCluster > m_storeClusters
Collection of SVDClusters.
Definition: SVDMissingAPVsClusterCreatorModule.h:76
Belle2::SVDCluster
The SVD Cluster class This class stores all information about reconstructed SVD clusters.
Definition: SVDCluster.h:38
Belle2::Module::addParam
void addParam(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
Definition: Module.h:562
Belle2::VXD::GeoCache
Class to faciliate easy access to sensor information of the VXD like coordinate transformations or pi...
Definition: GeoCache.h:41
Belle2::VXD::GeoCache::getSensorInfo
const SensorInfoBase & getSensorInfo(Belle2::VxdID id) const
Return a referecne to the SensorInfo of a given SensorID.
Definition: GeoCache.cc:68
Belle2::SVD::SVDMissingAPVsClusterCreatorModule::initialize
virtual void initialize() override
Initialize the module.
Definition: SVDMissingAPVsClusterCreatorModule.cc:66
Belle2::SVD::SVDMissingAPVsClusterCreatorModule::beginRun
virtual void beginRun() override
check if channel mapping is changed
Definition: SVDMissingAPVsClusterCreatorModule.cc:56
Belle2::StoreArray::getEntries
int getEntries() const
Get the number of objects in the array.
Definition: StoreArray.h:226
Belle2::SVD::SVDMissingAPVsClusterCreatorModule::m_nFakeClusters
int m_nFakeClusters
number of fake clusters
Definition: SVDMissingAPVsClusterCreatorModule.h:73