195{
196 MsgStream log(
msgSvc(), name());
197 log<<MSG::INFO<<"DedxCalibLayerGain::WriteHists()"<<endreq;
198
199
201 double fitmean_gaus[
layNo]={0},fitmeanerr_gaus[
layNo]={0},fitsigma_gaus[
layNo]={0},layerg_gaus[
layNo]={0};
202 for(
int i=0; i<
layNo; i++)
203 {
204 fitmean_gaus[i] = m_laygain_gaus[i]->GetFunction("gaus")->GetParameter(1);
205 fitmeanerr_gaus[i] = m_laygain_gaus[i]->GetFunction("gaus")->GetParError(1);
206 fitsigma_gaus[i] = m_laygain_gaus[i]->GetFunction("gaus")->GetParameter(2);
207
208 entryNo[i] = m_laygain[i]->GetEntries();
209 mean[i] = m_laygain[i]->GetMean();
210 sigma[i] = m_laygain[i]->GetRMS();
211 proper[i] = m_laygain[i]->GetBinCenter(m_laygain[i]->GetMaximumBin());
212 if(entryNo[i]<10) continue;
213
215 {
216 fitmean[i] = m_laygain[i]->GetFunction("mylan")->GetParameter(1);
217 fitmeanerr[i] = m_laygain[i]->GetFunction("mylan")->GetParError(1);
218 fitsigma[i] = m_laygain[i]->GetFunction("mylan")->GetParameter(2);
219 chisq[i] = (m_laygain[i]->GetFunction("mylan")-> GetChisquare())/(m_laygain[i]->GetFunction("mylan")-> GetNDF());
220 }
222 {
223 fitmean[i] = m_laygain[i]->GetFunction("landaun")->GetParameter(1);
224 fitmeanerr[i] = m_laygain[i]->GetFunction("landaun")->GetParError(1);
225 fitsigma[i] = m_laygain[i]->GetFunction("landaun")->GetParameter(2);
226 chisq[i] = (m_laygain[i]->GetFunction("landaun")-> GetChisquare())/(m_laygain[i]->GetFunction("landaun")-> GetNDF());
227 }
229 {
230 fitmean[i] = m_laygain[i]->GetFunction("Landau")->GetParameter(1);
231 fitmeanerr[i] = m_laygain[i]->GetFunction("Landau")->GetParError(1);
232 fitsigma[i] = m_laygain[i]->GetFunction("Landau")->GetParameter(2);
233 chisq[i] = (m_laygain[i]->GetFunction("Landau")-> GetChisquare())/(m_laygain[i]->GetFunction("Landau")-> GetNDF());
234 }
236 {
237 fitmean[i] = m_laygain[i]->GetFunction("Vavilov")->GetParameter(1);
238 fitmeanerr[i] = m_laygain[i]->GetFunction("Vavilov")->GetParError(1);
239 fitsigma[i] = m_laygain[i]->GetFunction("Vavilov")->GetParameter(2);
240 chisq[i] = (m_laygain[i]->GetFunction("Vavilov")-> GetChisquare())/(m_laygain[i]->GetFunction("Vavilov")-> GetNDF());
241 }
243 {
244 fitmean[i] = m_laygain[i]->GetFunction("AsymGauss")->GetParameter(1);
245 fitmeanerr[i] = m_laygain[i]->GetFunction("AsymGauss")->GetParError(1);
246 fitsigma[i] = m_laygain[i]->GetFunction("AsymGauss")->GetParameter(2);
247 chisq[i] = (m_laygain[i]->GetFunction("AsymGauss")-> GetChisquare())/(m_laygain[i]->GetFunction("AsymGauss")-> GetNDF());
248 }
249
250 }
251
252 double sum=0, sum_gaus=0, n=0;
253 for(
int i=4; i<
layNo; i++)
254 {
255 if(fitmean[i]>0 && fitmeanerr[i]>0 && fitmeanerr[i]<10 && fitsigma[i]>0 && fitsigma[i]<200 && entryNo[i]>1500)
256 {
257 sum += fitmean[i];
258 sum_gaus+= fitmean_gaus[i];
259 n++;
260 }
261 }
262 sum/=n;
263 sum_gaus/=n;
264 cout<<"average value of good layer: "<<sum<<endl;
265
266 for(
int i=0;i<
layNo;i++)
267 {
268 layerg[i] = fitmean[i]/sum;
269 layerg_gaus[i] = fitmean_gaus[i]/sum_gaus;
270 layer[i] = i;
271 }
272
273
274 log<<MSG::INFO<<"begin generating root file!!! "<<endreq;
275 TFile*
f =
new TFile(
m_rootfile.c_str(),
"recreate");
276 for(
int i=0;i<
layNo;i++)
277 {
278 m_laygain[i]->Write();
279 m_laygain_gaus[i]->Write();
280 }
281
282 TTree* layergcalib = new TTree("layergcalib", "layergcalib");
283 layergcalib->Branch("layerg_gaus", layerg_gaus, "layerg_gaus[43]/D");
284 layergcalib->Branch("layerg", layerg, "layerg[43]/D");
285 layergcalib->Branch("layer", layer, "layer[43]/D");
286 layergcalib->Branch("entryNo", entryNo, "entryNo[43]/D");
287 layergcalib->Branch("mean", mean, "mean[43]/D");
288 layergcalib->Branch(
"sigma",
sigma,
"sigma[43]/D");
289 layergcalib->Branch("fitmean", fitmean, "fitmean[43]/D");
290 layergcalib->Branch("fitmeanerr", fitmeanerr, "fitmeanerr[43]/D");
291 layergcalib->Branch("fitsigma", fitsigma, "fitsigma[43]/D");
292 layergcalib->Branch("chisq", chisq, "chisq[43]/D");
293 layergcalib->Branch("fitmean_gaus", fitmean_gaus, "fitmean_gaus[43]/D");
294 layergcalib->Branch("fitmeanerr_gaus", fitmeanerr_gaus, "fitmeanerr_gaus[43]/D");
295 layergcalib->Branch("fitsigma_gaus", fitsigma_gaus, "fitsigma_gaus[43]/D");
296 layergcalib->Fill();
297 layergcalib->Write();
298
300
301 TCanvas c1("c1", "canvas", 500, 400);
303 for(
int i=0;i<
layNo;i++)
304 {
305 m_laygain[i]->Draw();
307 }
309
310 for(
int i=0;i<
layNo;i++)
311 {
312 delete m_laygain[i];
313 delete m_laygain_gaus[i];
314 }
315}