175{
176 MsgStream log(
msgSvc(), name());
177 log<<MSG::INFO<<"DedxCalibTzero::WriteHists()"<<endreq;
178
182
183
184 double avegain(550.);
185
187 t0[i] = tzero_bin_value[i];
188 fitentryNo[i] = m_tzero[i]->Integral();
189 if(m_debug) cout << "num of bin " << i << " with events " << fitentryNo[i] << endl;
190 if(fitentryNo[i]<=
numcut)
continue;
191 if(m_debug) cout << "get results at " << i << " bin with fit entries " << fitentryNo[i] << endl;
192 if(m_tzero[i]->GetFunction("gaus")){
193 fitmean[i] = m_tzero[i]->GetFunction("gaus")->GetParameter(1);
194 fitmeanerr[i] = m_tzero[i]->GetFunction("gaus")->GetParError(1);
195 fitsigma[i] = m_tzero[i]->GetFunction("gaus")->GetParameter(2);
196 gain[i] = fitmean[i]/avegain;
197 fakegain[i] = 1.0;
198 fitchisq[i] = (m_tzero[i]->GetFunction("gaus")->GetChisquare())/(m_tzero[i]->GetFunction("gaus")->GetNDF());
199 }
200 pos_fitentryNo[i] = m_pos_tzero[i]->Integral();
201 if(pos_fitentryNo[i]<=
numcut)
continue;
202 if(m_debug) cout << "get results at " << i << " bin with pos_fit entries " << pos_fitentryNo[i] << endl;
203 if(m_pos_tzero[i]->GetFunction("gaus")){
204 pos_fitmean[i] = m_pos_tzero[i]->GetFunction("gaus")->GetParameter(1);
205 pos_fitmeanerr[i] = m_pos_tzero[i]->GetFunction("gaus")->GetParError(1);
206 pos_fitsigma[i] = m_pos_tzero[i]->GetFunction("gaus")->GetParameter(2);
207 pos_gain[i] = pos_fitmean[i]/avegain;
208 pos_fitchisq[i] = (m_pos_tzero[i]->GetFunction("gaus")->GetChisquare())/(m_pos_tzero[i]->GetFunction("gaus")->GetNDF());
209 }
210 neg_fitentryNo[i] = m_neg_tzero[i]->Integral();
211 if(neg_fitentryNo[i]<=
numcut)
continue;
212 if(m_debug) cout << "get results at " << i << " bin with neg_fit entries " << neg_fitentryNo[i] << endl;
213 if(m_neg_tzero[i]->GetFunction("gaus")){
214 neg_fitmean[i] = m_neg_tzero[i]->GetFunction("gaus")->GetParameter(1);
215 neg_fitmeanerr[i] = m_neg_tzero[i]->GetFunction("gaus")->GetParError(1);
216 neg_fitsigma[i] = m_neg_tzero[i]->GetFunction("gaus")->GetParameter(2);
217 neg_gain[i] = neg_fitmean[i]/avegain;
218 neg_fitchisq[i] = (m_neg_tzero[i]->GetFunction("gaus")->GetChisquare())/(m_neg_tzero[i]->GetFunction("gaus")->GetNDF());
219 }
220 }
221
222 log<<MSG::INFO<<"begin generating root file!!! "<<endreq;
223 TFile*
f =
new TFile(
m_rootfile.c_str(),
"RECREATE");
225 m_chi[i]->Write();
226 m_pos_chi[i]->Write();
227 m_neg_chi[i]->Write();
228 m_tzero[i]->Write();
229 m_pos_tzero[i]->Write();
230 m_neg_tzero[i]->Write();
231 }
232 m_dEdxVsTzero->Write();
233 m_pos_dEdxVsTzero->Write();
234 m_neg_dEdxVsTzero->Write();
235
236 TTree *tzerocalib = new TTree("gaincalib","gaincalib");
237 tzerocalib->Branch("gain", &avegain, "gain/D");
238 tzerocalib->Branch("t0", t0, "t0[35]/D");
239 tzerocalib->Branch("dedx", gain, "dedx[35]/D");
240 tzerocalib->Branch("fakededx", fakegain, "fakededx[35]/D");
241 tzerocalib->Branch("fitmean", fitmean, "fitmean[35]/D");
242 tzerocalib->Branch("fitmeanerr", fitmeanerr, "fitmeanerr[35]/D");
243 tzerocalib->Branch("fitsigma", fitsigma, "fitsigma[35]/D");
244 tzerocalib->Branch("fitchisq", fitchisq, "fitchisq[35]/D");
245 tzerocalib->Fill();
246 tzerocalib->Write();
247
248 TCanvas c1("c1", "canvas", 500, 400);
250 tzerocalib->Draw("dedx:t0");
252
254 m_dEdxVsTzero->Draw();
256 m_pos_dEdxVsTzero->Draw();
258 m_neg_dEdxVsTzero->Draw();
261 m_tzero[i]->Draw();
263 }
265 m_pos_tzero[i]->Draw();
267 }
269 m_neg_tzero[i]->Draw();
271 }
273 if(m_debug) cout << "before delete" << endl;
275 delete m_chi[i];
276 delete m_pos_chi[i];
277 delete m_neg_chi[i];
278 delete m_tzero[i];
279 delete m_pos_tzero[i];
280 delete m_neg_tzero[i];
281 }
282 delete m_dEdxVsTzero;
283 delete m_pos_dEdxVsTzero;
284 delete m_neg_dEdxVsTzero;
285}