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