9#include <svd/modules/svdCalibration/SVDPositionErrorScaleFactorImporterModule.h>
10#include <svd/calibration/SVDCoGOnlyErrorScaleFactors.h>
11#include <svd/calibration/SVDOldDefaultErrorScaleFactors.h>
12#include <vxd/geometry/GeoCache.h>
13#include <framework/datastore/StoreObjPtr.h>
14#include <framework/datastore/StoreArray.h>
15#include <framework/datastore/RelationVector.h>
16#include <framework/datastore/RelationArray.h>
17#include <framework/dataobjects/EventMetaData.h>
24REG_MODULE(SVDPositionErrorScaleFactorImporter);
33 setDescription(
"Module to produce a list of histograms showing the uploaded calibration constants");
36 addParam(
"outputFileName",
m_rootFileName,
"Name of output root file.", std::string(
"SVDPositionErrorScaleFactors.root"));
42 addParam(
"noOutliers",
m_noOutliers,
"If True, removes outliers from cluster position error scale factor computation.",
59 m_tree =
new TTree(
"scf",
"RECREATE");
75 TH1F hClsPullSize1(
"clusterPulls1_L@layerL@ladderS@sensor@view",
76 Form(
"Cluster %s Pulls for Size 1 in @layer.@ladder.@sensor @view/@side",
m_posAlgorithm.c_str()),
78 hClsPullSize1.GetXaxis()->SetTitle(
"cluster pull");
81 TH1F hClsPullSize2(
"clusterPulls2_L@layerL@ladderS@sensor@view",
82 Form(
"Cluster %s Pulls for Size 2 in @layer.@ladder.@sensor @view/@side",
m_posAlgorithm.c_str()),
84 hClsPullSize2.GetXaxis()->SetTitle(
"cluster pull");
87 TH1F hClsPullSize3(
"clusterPulls3_L@layerL@ladderS@sensor@view",
88 Form(
"Cluster %s Pulls for Size 3 in @layer.@ladder.@sensor @view/@side",
m_posAlgorithm.c_str()),
90 hClsPullSize3.GetXaxis()->SetTitle(
"cluster pull");
93 TH1F hClsPullSize4(
"clusterPulls4_L@layerL@ladderS@sensor@view",
94 Form(
"Cluster %s Pulls for Size 4 in @layer.@ladder.@sensor @view/@side",
m_posAlgorithm.c_str()),
96 hClsPullSize4.GetXaxis()->SetTitle(
"cluster pull");
99 TH1F hClsPullSize5(
"clusterPulls5_L@layerL@ladderS@sensor@view",
100 Form(
"Cluster %s Pulls for Size > 4 in @layer.@ladder.@sensor @view/@side",
m_posAlgorithm.c_str()),
102 hClsPullSize5.GetXaxis()->SetTitle(
"cluster pull");
105 for (
int i = 0; i < 2; i++)
106 for (
int s = 0; s <
maxSize; s++) {
108 if (i == 0) sside =
"v";
109 m_hL3Pulls[s][i] =
new TH1F(Form(
"l3_%s_size%d", sside.Data(), s + 1), Form(
"Size %d Cluster %s Pulls for L3 %s sensors",
111 m_hL3Pulls[s][i]->GetXaxis()->SetTitle(
"cluster pull");
112 m_hBWPulls[s][i] =
new TH1F(Form(
"bw_%s_size%d", sside.Data(), s + 1), Form(
"Size %d Cluster %s Pulls for BW %s sensors",
114 m_hBWPulls[s][i]->GetXaxis()->SetTitle(
"cluster pull");
115 m_hFWPulls[s][i] =
new TH1F(Form(
"fw_%s_size%d", sside.Data(), s + 1), Form(
"Size %d Cluster %s Pulls for FW %s sensors",
117 m_hFWPulls[s][i]->GetXaxis()->SetTitle(
"cluster pull");
118 m_hORPulls[s][i] =
new TH1F(Form(
"or_%s_size%d", sside.Data(), s + 1), Form(
"Size %d Cluster %s Pulls for ORIGAMI %s sensors",
120 m_hORPulls[s][i]->GetXaxis()->SetTitle(
"cluster pull");
129 m_run = meta->getRun();
130 m_exp = meta->getExperiment();
136 if (trueHit.
size() == 0)
continue;
138 m_size = cluster.getSize();
139 m_side = cluster.isUCluster();
142 m_clsPos =
m_side ? cluster.getPosition(trueHit[0]->getV()) : cluster.getPosition();
143 m_clsErr = cluster.getPositionSigma();
147 m_layer = cluster.getSensorID().getLayerNumber();
148 m_ladder = cluster.getSensorID().getLadderNumber();
149 m_sensor = cluster.getSensorID().getSensorNumber();
171 std::set<Belle2::VxdID>::iterator itSvdLayers = svdLayers.begin();
173 while ((itSvdLayers != svdLayers.end()) && (itSvdLayers->getLayerNumber() != 7)) {
175 std::set<Belle2::VxdID> svdLadders = aGeometry.
getLadders(*itSvdLayers);
176 std::set<Belle2::VxdID>::iterator itSvdLadders = svdLadders.begin();
178 while (itSvdLadders != svdLadders.end()) {
180 std::set<Belle2::VxdID> svdSensors = aGeometry.
getSensors(*itSvdLadders);
181 std::set<Belle2::VxdID>::iterator itSvdSensors = svdSensors.begin();
182 B2DEBUG(1,
" svd sensor info " << * (svdSensors.begin()));
184 while (itSvdSensors != svdSensors.end()) {
185 B2DEBUG(1,
" svd sensor info " << *itSvdSensors);
187 m_layer = (int)itSvdSensors->getLayerNumber();
188 m_ladder = (int)itSvdSensors->getLadderNumber();
189 m_sensor = (int)itSvdSensors->getSensorNumber();
195 h->SetTitle(Form(
"%s, scf = %1.2f", h->GetTitle(),
oneSigma(h)));
197 h->SetTitle(Form(
"%s, scf = %1.2f", h->GetTitle(),
oneSigma(h)));
199 h->SetTitle(Form(
"%s, scf = %1.2f", h->GetTitle(),
oneSigma(h)));
201 h->SetTitle(Form(
"%s, scf = %1.2f", h->GetTitle(),
oneSigma(h)));
203 h->SetTitle(Form(
"%s, scf = %1.2f", h->GetTitle(),
oneSigma(h)));
261 for (
auto ladder : geoCache.getLadders(layer))
267 if (theVxdID.getLayerNumber() == 3) {
275 else if (theVxdID.getSensorNumber() == 1) {
283 else if (theVxdID.getSensorNumber() == theVxdID.getLayerNumber() - 1) {
300 payload_cogOnly->set(theVxdID.getLayerNumber(), theVxdID.getLadderNumber(), theVxdID.getSensorNumber(),
m_side, 1, *scfs);
302 payload_oldDefault->set(theVxdID.getLayerNumber(), theVxdID.getLadderNumber(), theVxdID.getSensorNumber(),
m_side, 1, *scfs);
308 B2RESULT(
"SVDCoGOnlyErrorScaleFactors imported to database.");
313 B2RESULT(
"SVDOldDefaultErrorScaleFactors imported to database.");
329 for (
auto ladder : geoCache.getLadders(layer))
344 for (
int s = 0; s <
maxSize; s++) {
356 B2RESULT(
"The rootfile containing the list of histograms has been filled and closed.");
363 TH1F* h1_res = (TH1F*)h1->Clone(
"h1_res");
365 double probs[2] = {0.16, 1 - 0.16};
366 double quant[2] = {0, 0};
368 int nbinsHisto = h1_res->GetNbinsX();
371 h1_res->SetBinContent(1, h1_res->GetBinContent(0) + h1_res->GetBinContent(1));
372 h1_res->SetBinContent(nbinsHisto, h1_res->GetBinContent(nbinsHisto) + h1_res->GetBinContent(nbinsHisto + 1));
373 h1_res->SetBinContent(0, 0);
374 h1_res->SetBinContent(nbinsHisto + 1, 0);
377 h1_res->GetQuantiles(2, quant, probs);
379 return (-quant[0] + quant[1]) / 2;
A class that describes the interval of experiments/runs for which an object in the database is valid.
void setDescription(const std::string &description)
Sets the description of the module.
Class for type safe access to objects that are referred to in relations.
size_t size() const
Get number of relations.
The SVD Cluster class This class stores all information about reconstructed SVD clusters.
static std::string name
name of SVDPosErrScaleFactors payload
SVDCalibrationsBase< SVDCalibrationsScalar< SVDPosErrScaleFactors > > t_payload
typedef for the of SVDPosErrScaleFactors payload of all SVD sensors
template class for SVd histograms
void fill(const VxdID &vxdID, int view, Types ... args)
fill the histogram for
H * getHistogram(const VxdID &vxdID, int view)
get a reference to the histogram for
static std::string name
name of SVDPosErrScaleFactors payload
SVDCalibrationsBase< SVDCalibrationsScalar< SVDPosErrScaleFactors > > t_payload
typedef for the of SVDPosErrScaleFactors payload of all SVD sensors
std::string m_rootFileName
root file name
SVDHistograms< TH1F > * m_hClsPullSize1
cluster size 1, position error scale factor histo
TTree * m_tree
pointer at tree containing the mean and RMS of calibration constants
TH1F * m_hFWPulls[5][2]
cumulative FW pulls histograms [size][side]
StoreArray< SVDTrueHit > m_truehits
SVDTrueHits StoreArray.
int m_ladder
ladder number
float m_clsErr
cluster position error
TH1F * m_hORPulls[5][2]
cumulative ORIGAMI pulls histograms [size][side]
virtual void initialize() override
check presence of data objects
virtual void event() override
fill trees and histograms
float m_clsTime
cluster time
bool m_noOutliers
if True removes outliers from scale factor computation
SVDHistograms< TH1F > * m_hClsPullSize5
cluster size 5, position error scale factor histo
virtual void endRun() override
create cumulative histograms, compute scale factors, create payloads and import it to a localdb,...
int m_sensor
sensor number
float m_clsCharge
cluster charge
SVDPositionErrorScaleFactorImporterModule()
Constructor: Sets the description, the properties and the parameters of the module.
float m_max
max of the pulls histograms
SVDHistograms< TH1F > * m_hClsPullSize3
cluster size 3, position error scale factor histo
StoreArray< SVDCluster > m_clusters
SVDClusters StoreArray.
float m_clsPull
cluster position pull
std::string m_posAlgorithm
position algorithm
virtual void beginRun() override
initialize the TTrees and create histograms
TH1F * m_hL3Pulls[5][2]
cumulative L3 pulls histograms [size][side]
float m_min
min of the pulls histograms
SVDHistograms< TH1F > * m_hClsPullSize2
cluster size 2, position error scale factor histo
std::string m_uniqueID
payload uniqueID
float m_nBins
number of bins of the pulls histograms
SVDHistograms< TH1F > * m_hClsPullSize4
cluster size 4, position error scale factor histo
float m_clsResid
cluster positionresidual
TH1F * m_hBWPulls[5][2]
cumulative BW pulls histograms [size][side]
double oneSigma(TH1F *)
computes the scale factor by requiring that 68% of the pull distribution is between ±1
TFile * m_rootFilePtr
pointer at root file used for storing histograms
float m_clsPos
cluster position error
const int maxSize
maximum cluster size
Class SVDTrueHit - Records of tracks that either enter or leave the sensitive volume.
bool isRequired(const std::string &name="")
Ensure this array/object has been registered previously.
Type-safe access to single objects in the data store.
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.
Class to uniquely identify a any structure of the PXD and SVD.
baseType getSensorNumber() const
Get the sensor id.
baseType getLayerNumber() const
Get the layer id.
void addParam(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
static Database & Instance()
Instance of a singleton Database.
bool storeData(const std::string &name, TObject *object, const IntervalOfValidity &iov)
Store an object in the database.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.
contains the scaling factors for the cluster position error