9#include <svd/modules/svdSpacePointCreator/SpacePointHelperFunctions.h>
10#include <svd/modules/svdSpacePointCreator/SVDSpacePointQICalibrationModule.h>
25 setDescription(
"Generate PDFs used in assigning quality to SpacePoints.");
30 "SVDCluster collection name",
string(
""));
33 "RecoTracks collection name",
string(
""));
37 "allows the user to set an identifier for this module. Usefull if one wants to use several instances of that module",
string(
""));
45 "Use legacy pdf naming",
bool(
true));
48 "Name of output file containing pdfs", std::string(
"spacePointQICalibration.root"));
64 for (
auto& sensors : geo.
getSensors(ladders)) {
68 std::string sensorName =
"";
69 std::string errorStringName =
"";
74 std::string signalHistName = sensorName +
"signal";
75 std::string backgroundHistName = sensorName +
"background";
78 TH2F* sigHist =
new TH2F(signalHistName.c_str(),
"",
m_binSize, 0, 200000,
m_binSize, 0, 200000);
79 TH2F* bkgHist =
new TH2F(backgroundHistName.c_str(),
"",
m_binSize, 0, 200000,
m_binSize, 0, 200000);
89 TH2F* timeSignal =
new TH2F(
"timeSignal",
"", 40, -100, 100, 40, -100, 100);
90 TH2F* timeBackground =
new TH2F(
"timeBackground",
"", 40, -100, 100, 40, -100, 100);
91 TH2F* sizeSignal =
new TH2F(
"sizeSignal",
"", 20, 0, 20, 20, 0, 20);
92 TH2F* sizeBackground =
new TH2F(
"sizeBackground",
"", 20, 0, 20, 20, 0, 20);
106 if (track.wasFitSuccessful() == 1) {
107 if (track.hasSVDHits() == 1) {
108 for (
auto& svdHit : track.getSVDHitList()) {
109 if (svdHit->isUCluster()) {
110 for (
auto& svdHit2 : track.getSVDHitList()) {
111 if (svdHit2->isUCluster() == 0) {
112 if (svdHit->getSensorID() == svdHit2->getSensorID()) {
114 std::string errorStringName;
118 sigHist->Fill(svdHit->getCharge(), svdHit2->getCharge());
120 timeSigHist->Fill(svdHit->getClsTime(), svdHit2->getClsTime());
122 sizeSigHist->Fill(svdHit->getSize(), svdHit2->getSize());
134 if (uCluster.isUCluster() == 1) {
136 if (vCluster.isUCluster() == 0) {
137 if (uCluster.getSensorID() == vCluster.getSensorID()) {
139 std::string errorStringName;
143 bkgHist->Fill(uCluster.getCharge(), vCluster.getCharge());
145 timeBkgHist->Fill(uCluster.getClsTime(), vCluster.getClsTime());
147 sizeBkgHist->Fill(uCluster.getSize(), vCluster.getSize());
162 std::vector<std::string> usedSensors;
165 for (
auto& ladders : geo.
getLadders(layers)) {
166 for (
auto& sensors : geo.
getSensors(ladders)) {
169 std::string sensorName;
170 std::string errorName;
175 if (std::find(usedSensors.begin(), usedSensors.end(), sensorName.c_str()) == usedSensors.end()) {
176 usedSensors.push_back(sensorName);
177 TH2F* probHist =
new TH2F(sensorName.c_str(),
"",
m_binSize, 0, 200000,
m_binSize, 0, 200000);
178 TH2F* errorHist =
new TH2F(errorName.c_str(),
"",
m_binSize, 0, 200000,
m_binSize, 0, 200000);
190 TH2F* timeProb =
new TH2F(
"timeProb",
"", 40, -100, 100, 40, -100, 100);
191 TH2F* timeError =
new TH2F(
"timeError",
"", 40, -100, 100, 40, -100, 100);
192 TH2F* sizeProb =
new TH2F(
"sizeProb",
"", 20, 0, 20, 20, 0, 20);
193 TH2F* sizeError =
new TH2F(
"sizeError",
"", 20, 0, 20, 20, 0, 20);
209 signal->Divide(background);
210 probability->Add(signal);
215 int imax = signal->GetXaxis()->GetNbins();
216 int jmax = signal->GetYaxis()->GetNbins();
217 for (
int i = 1; i <= imax; i++) {
218 for (
int j = 1; j <= jmax; j++) {
219 int bkg = background->GetBinContent(i, j);
220 int sig = signal->GetBinContent(i, j);
221 double var = ((sig + 1) * (sig + 2)) / ((bkg + 2) * (bkg + 3)) -
222 ((sig + 1) * (sig + 1)) / ((bkg + 2) * (bkg + 2));
223 double err =
sqrt(var);
224 error->SetBinContent(i, j, err);
void setDescription(const std::string &description)
Sets the description of the module.
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
std::string m_svdClustersName
SVDCluster collection name.
std::string m_nameOfInstance
allows the user to set an identifier for this module.
virtual void initialize() override
Init the module.
StoreArray< SVDCluster > m_svdClusters
the storeArray for svdClusters as member, is faster than recreating link for each event
virtual void event() override
event
virtual void terminate() override
final output
void calculateError(TH2F *signal, TH2F *background, TH2F *error)
compute error
std::map< std::string, TH2F * > backgroundHistMap
map for background histograms
bool m_useLegacyNaming
use legacy pdf naming
std::string m_recoTracksName
RecoTracks collection name.
std::map< std::string, TH2F * > signalHistMap
map of signal histograms
int m_maxClusterSize
max numnber of strips the PDF are separated into
StoreArray< RecoTrack > m_recoTracks
RecoTrack store array.
void calculateProb(TH2F *signal, TH2F *background, TH2F *probability)
compute probability
SVDSpacePointQICalibrationModule()
Constructor.
int m_binSize
number of bins in charge distribution
std::string m_outputFileName
output file name
bool isRequired(const std::string &name="")
Ensure this array/object has been registered previously.
Class to faciliate easy access to sensor information of the VXD like coordinate transformations or pi...
const std::set< Belle2::VxdID > getLayers(SensorInfoBase::SensorType sensortype=SensorInfoBase::VXD)
Return a set of all known Layers.
const std::set< Belle2::VxdID > & getSensors(Belle2::VxdID ladder) const
Return a set of all sensor IDs belonging to a given ladder.
static GeoCache & getInstance()
Return a reference to the singleton instance.
const std::set< Belle2::VxdID > & getLadders(Belle2::VxdID layer) const
Return a set of all ladder IDs belonging to a given layer.
void addParam(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
double sqrt(double a)
sqrt for double
void spPDFName(const VxdID &sensor, int uSize, int vSize, int maxClusterSize, std::string &PDFName, std::string &errorPDFName, bool useLegacyNaming)
Function to set name of PDF for spacePoint quality estimation.
Abstract base class for different kinds of events.