 |
Belle II Software
release-05-01-25
|
1 #include "cdc/modules/cdcInitialT0Determination/CDCInitialT0Determination.h"
2 #include <cdc/dataobjects/CDCHit.h>
3 #include <cdc/geometry/CDCGeometryPar.h>
4 #include <framework/datastore/StoreArray.h>
5 #include <framework/gearbox/Const.h>
7 #include "TDirectory.h"
9 #include "TGraphErrors.h"
18 CDCInitialT0DeterminationModule::CDCInitialT0DeterminationModule() :
Module()
26 addParam(
"Cosmic",
m_cosmic,
"true; tof negative for upper part of cdc",
true);
42 for (
int il = 0; il < 56; ++il) {
43 for (
unsigned short w = 0; w < cdcgeo.
nWiresInLayer(il); ++w) {
47 for (
int ib = 0; ib < 300; ++ib) {
50 m_hT0All =
new TH1D(
"hT0All",
"", 8500, 0, 8500);
57 for (
const auto& hit : cdcHits) {
58 WireID wireid(hit.getID());
59 unsigned short lay = wireid.getICLayer();
60 unsigned short w = wireid.getIWire();
62 m_hTDC[lay][w]->Fill(hit.getTDCCount());
70 std::vector<double> sb;
71 std::vector<double> dsb;
72 std::vector<double> t0b;
73 std::vector<double> dt0b;
74 std::vector<double> b;
75 std::vector<double> db;
76 TH1D* hs =
new TH1D(
"hs",
"sigma", 100, 0, 20);
79 TF1* f1 =
new TF1(
"f1",
"[0]+[1]*(exp([2]*(x-[3]))/(1+exp(-([4]-x)/[5])))",
m_tdcMin,
m_tdcMax);
80 f1->SetParLimits(0, 0., 1000.);
81 f1->SetLineColor(kRed);
84 for (
int ib = 1; ib < 300; ++ib) {
86 B2DEBUG(199,
"Warning: this board low statistic: " <<
m_hTDCBoard[ib]->GetEntries());
95 if ((fabs(f1->GetParameter(4) -
m_initT0) > 100)
96 || (fabs(f1->GetParameter(5)) < 0.01)
97 || (fabs(f1->GetParameter(5)) > 16)) {
105 m_t0b[ib] = f1->GetParameter(4) * tdcBinWidth;
107 sb.push_back(f1->GetParameter(5));
108 dsb.push_back(f1->GetParError(5));
109 t0b.push_back(f1->GetParameter(4));
110 dt0b.push_back(f1->GetParError(4));
115 for (
int il = 0; il < 56; ++il) {
116 for (
unsigned short w = 0; w < cdcgeo.
nWiresInLayer(il); ++w) {
117 B2DEBUG(99,
"fitting for channel: " << il <<
" - " << w);
118 B2DEBUG(99,
"number of entries" <<
m_hTDC[il][w]->GetEntries());
122 B2DEBUG(99,
"Warning: low statistic channel: " <<
m_hTDC[il][w]->GetEntries());
123 if (bflag[bid] != 0) {
126 }
else {
m_flag[il][w] =
false;}
128 double p3 =
m_hTDC[il][w]->GetXaxis()->GetBinCenter(
m_hTDC[il][w]->GetMaximumBin());
129 f1->SetParameters(0,
m_hTDC[il][w]->GetMaximum(), -0.001, p3,
m_initT0, 2.5);
131 B2DEBUG(99,
"prob of fit : " << f1->GetProb());
132 if ((f1->GetProb() < 1E-150) || (fabs(f1->GetParameter(4) -
m_initT0) > 100) || (f1->GetParameter(5) < 0.1)
133 || (f1->GetParameter(5) > 20)) {
134 if (bflag[bid] != 0) {
137 }
else {
m_flag[il][w] =
false;}
139 m_t0[il][w] = f1->GetParameter(4) * tdcBinWidth;
140 hs->Fill(f1->GetParameter(5));
144 B2DEBUG(99,
"P4 = " <<
m_t0[il][w]);
151 m_t0[il][w] += 6.122;
159 for (
int il = 0; il < 56; ++il) {
160 for (
unsigned short w = 0; w < cdcgeo.
nWiresInLayer(il); ++w) {
161 if (
m_flag[il][w] !=
true) {
164 ofs << il <<
"\t" << w <<
"\t" <<
m_t0[il][w] << endl;
171 TDirectory* top = gDirectory;
172 TDirectory* Direct[56];
173 for (
int il = 0; il < 56; ++il) {
175 Direct[il] = gDirectory->mkdir(Form(
"lay_%d", il));
177 for (
unsigned short w = 0; w < cdcgeo.
nWiresInLayer(il); ++w) {
178 if (
m_flag[il][w] ==
true) {
184 TDirectory* board = gDirectory->mkdir(
"board");
186 for (
int ib = 0; ib < 300; ++ib) {
195 TGraphErrors* gr =
new TGraphErrors(b.size(), &b.at(0), &sb.at(0), &db.at(0), &dsb.at(0));
198 TGraphErrors* grT0b =
new TGraphErrors(b.size(), &b.at(0), &t0b.at(0), &db.at(0), &dt0b.at(0));
199 grT0b->SetName(
"T0Board");
void initialize() override
Initializes the Module.
TH1D * m_hTDCBoard[300]
T0 distribution of each board.
bool m_cosmic
for cosmic case, tof of upper sector will be negative
Class to identify a wire inside the CDC.
virtual ~CDCInitialT0DeterminationModule()
Destructor.
void setDescription(const std::string &description)
Sets the description of the module.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
unsigned short m_tdcMax
Upper boundary TDC histogram.
unsigned short m_tdcMin
Lower boundary TDC histogram.
unsigned short m_minEntries
min entries per histo.
TH1D * m_hTDC[56][400]
TDC distribution histo.
double getTdcBinWidth() const
Return TDC bin width (nsec).
bool m_storeFittedHisto
Store fitted histogram or not.
void terminate() override
Termination action, fit t0 and store histograms.
bool m_flag[56][400]
flag =1 for good, =0 for low statistic or bad fit
TH1D * m_hT0All
T0 distribution of all channel.
double m_initT0
initial t0, use int fitting
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
static const double speedOfLight
[cm/ns]
The Class for CDC Geometry Parameters.
void event() override
Event action (main routine).
double senseWireR(int layerId) const
Returns radius of sense wire in each layer.
const TVector3 wireBackwardPosition(int layerId, int cellId, EWirePosition set=c_Base) const
Returns the backward position of the input sense wire.
static CDCGeometryPar & Instance(const CDCGeometry *=nullptr)
Static method to get a reference to the CDCGeometryPar instance.
std::string m_outputFileName
output file name of t0 file.
Abstract base class for different kinds of events.
std::string m_histoFileName
output file to store TDC histo after fit
unsigned short getBoardID(const WireID &wID) const
Returns frontend board id. corresponding to the wire id.
void addParam(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
unsigned nWiresInLayer(int layerId) const
Returns wire numbers in a layer.
unsigned short m_adcMin
ADC cut to reject noise.
Accessor to arrays stored in the data store.
double m_t0b[300]
T0 for each board.
double m_zOffset
z offset for calculate prop time, it is position of trigger counter,
double m_t0[56][400]
T0 of each channel.