Run algo on data.
117{
118 B2INFO("Start calibration");
119
120 gROOT->SetBatch(1);
121 gErrorIgnoreLevel = 3001;
122
125
126 TF1* g1 = new TF1("g1", "gaus", -100, 100);
127 vector<double> b, db, Sb, dSb;
128 vector<double> c[56];
129 vector<double> dc[56];
130 vector<double> s[56];
131 vector<double> ds[56];
132
133 B2INFO("Gaus fitting for whole channel");
134 double par[3];
137 m_hTotal->Fit(
"g1",
"Q",
"", mean - 15, mean + 15);
138 g1->GetParameters(par);
139
140 B2INFO("Gaus fitting for each board");
141 for (int ib = 1; ib < 300; ++ib) {
142 if (
m_hT0b[ib]->GetEntries() < 10)
continue;
143 mean =
m_hT0b[ib]->GetMean();
144 m_hT0b[ib]->SetDirectory(0);
145 m_hT0b[ib]->Fit(
"g1",
"Q",
"", mean - 15, mean + 15);
146 g1->GetParameters(par);
147 b.push_back(ib);
148 db.push_back(0.0);
149 Sb.push_back(par[1]);
150 dSb.push_back(g1->GetParError(1));
152 err_dtb[ib] = g1->GetParError(1);
153 }
154 B2INFO("Gaus fitting for each cell");
155 for (int ilay = 0; ilay < 56; ++ilay) {
156 for (
unsigned int iwire = 0; iwire < cdcgeo.
nWiresInLayer(ilay); ++iwire) {
157 const int n =
m_h1[ilay][iwire]->GetEntries();
158 B2DEBUG(99, "layer " << ilay << " wire " << iwire << " entries " << n);
159 if (n < 10) continue;
160 mean =
m_h1[ilay][iwire]->GetMean();
161 m_h1[ilay][iwire]->SetDirectory(0);
162 m_h1[ilay][iwire]->Fit(
"g1",
"Q",
"", mean - 15, mean + 15);
163 g1->GetParameters(par);
164 c[ilay].push_back(iwire);
165 dc[ilay].push_back(0.0);
166 s[ilay].push_back(par[1]);
167 ds[ilay].push_back(g1->GetParError(1));
168
169 dt[ilay][iwire] = par[1];
170 err_dt[ilay][iwire] = g1->GetParError(1);
171 }
172 }
173
174
176 B2INFO("Store histo");
177 TFile* fout = new TFile("Correct_T0.root", "RECREATE");
178 fout->cd();
179 TGraphErrors* gr[56];
180 TDirectory* top = gDirectory;
182 TDirectory* subDir[56];
183 for (int ilay = 0; ilay < 56; ++ilay) {
184 subDir[ilay] = top ->mkdir(Form("lay_%d", ilay));
185 subDir[ilay]->cd();
186 for (
unsigned int iwire = 0; iwire < cdcgeo.
nWiresInLayer(ilay); ++iwire) {
187 m_h1[ilay][iwire]->Write();
188 }
189 }
190 top->cd();
191 TDirectory* corrT0 = top->mkdir("DeltaT0");
192 corrT0->cd();
193
194 if (b.size() > 2) {
195 TGraphErrors* grb = new TGraphErrors(b.size(), &b.at(0), &Sb.at(0), &db.at(0), &dSb.at(0));
196 grb->SetMarkerColor(2);
197 grb->SetMarkerSize(1.0);
198 grb->SetTitle("#DeltaT0;BoardID;#DeltaT0[ns]");
199 grb->SetMaximum(10);
200 grb->SetMinimum(-10);
201 grb->SetName("Board");
202 grb->Write();
203 }
204 for (int sl = 0; sl < 56; ++sl) {
205 if (c[sl].size() < 2) continue;
206 gr[sl] = new TGraphErrors(c[sl].size(), &c[sl].at(0), &s[sl].at(0), &dc[sl].at(0), &ds[sl].at(0));
207 gr[sl]->SetMarkerColor(2);
208 gr[sl]->SetMarkerSize(1.0);
209 gr[sl]->SetTitle(Form("Layer_%d;IWire;#LT t_{mea}-t_{fit} #GT [ns]", sl));
210 gr[sl]->SetMaximum(10);
211 gr[sl]->SetMinimum(-10);
212 gr[sl]->SetName(Form("lay%d", sl));
213 gr[sl]->Write();
214 }
215 fout->Close();
216 }
217 B2INFO("Write constants");
219 return true;
220}
The Class for CDC Geometry Parameters.
unsigned nWiresInLayer(int layerId) const
Returns wire numbers in a layer.
static CDCGeometryPar & Instance(const CDCGeometry *=nullptr)
Static method to get a reference to the CDCGeometryPar instance.
double dtb[300]
dt of each board
TH1F * m_hTotal
1D histogram of delta T whole channel
double dt[56][385]
dt of each channel
bool m_storeHisto
store histo or not
virtual void Write()
write outut or store db
virtual void CreateHisto()
create histo for each channel
TH1F * m_h1[56][385]
1D histogram for each channel
double err_dt[56][385]
error of dt of each channel
TH1F * m_hT0b[300]
1D histogram for each board
double err_dtb[300]
error of dt of board