174{
175 MsgStream log(
msgSvc(), name());
176 log<<MSG::INFO<<"DedxCalibEAng::WriteHists()"<<endreq;
177
182
183 double Norm=0;
186 {
187 Ip_eangle[ip] = ip;
189
190 entryNo[ip]= m_eangle[ip]->Integral();
191 mean[ip] = m_eangle[ip]->GetMean();
192 sigma[ip] = m_eangle[ip]->GetRMS();
193 pos_entryNo[ip]= m_pos_eangle[ip]->Integral();
194 pos_mean[ip] = m_pos_eangle[ip]->GetMean();
195 pos_sigma[ip] = m_pos_eangle[ip]->GetRMS();
196 neg_entryNo[ip]= m_neg_eangle[ip]->Integral();
197 neg_mean[ip] = m_neg_eangle[ip]->GetMean();
198 neg_sigma[ip] = m_neg_eangle[ip]->GetRMS();
199 if(entryNo[ip]<10 || pos_entryNo[ip]<10 || neg_entryNo[ip]<10) continue;
200
202 {
203 fitmean[ip] = m_eangle[ip]->GetFunction("mylan")->GetParameter(1);
204 fitmeanerr[ip] = m_eangle[ip]->GetFunction("mylan")->GetParError(1);
205 fitsigma[ip] = m_eangle[ip]->GetFunction("mylan")->GetParameter(2);
206 chisq[ip] = (m_eangle[ip]->GetFunction("mylan")-> GetChisquare())/(m_eangle[ip]->GetFunction("mylan")-> GetNDF());
207
208 pos_fitmean[ip] = m_pos_eangle[ip]->GetFunction("mylan")->GetParameter(1);
209 pos_fitmeanerr[ip] = m_pos_eangle[ip]->GetFunction("mylan")->GetParError(1);
210 pos_fitsigma[ip] = m_pos_eangle[ip]->GetFunction("mylan")->GetParameter(2);
211 pos_chisq[ip] = (m_pos_eangle[ip]->GetFunction("mylan")-> GetChisquare())/(m_pos_eangle[ip]->GetFunction("mylan")-> GetNDF());
212
213 neg_fitmean[ip] = m_neg_eangle[ip]->GetFunction("mylan")->GetParameter(1);
214 neg_fitmeanerr[ip] = m_neg_eangle[ip]->GetFunction("mylan")->GetParError(1);
215 neg_fitsigma[ip] = m_neg_eangle[ip]->GetFunction("mylan")->GetParameter(2);
216 neg_chisq[ip] = (m_neg_eangle[ip]->GetFunction("mylan")-> GetChisquare())/(m_neg_eangle[ip]->GetFunction("mylan")-> GetNDF());
217 }
219 {
220 fitmean[ip] = m_eangle[ip]->GetFunction("landaun")->GetParameter(1);
221 fitmeanerr[ip] = m_eangle[ip]->GetFunction("landaun")->GetParError(1);
222 fitsigma[ip] = m_eangle[ip]->GetFunction("landaun")->GetParameter(2);
223 chisq[ip] = (m_eangle[ip]->GetFunction("landaun")-> GetChisquare())/(m_eangle[ip]->GetFunction("mylan")-> GetNDF());
224
225 pos_fitmean[ip] = m_pos_eangle[ip]->GetFunction("landaun")->GetParameter(1);
226 pos_fitmeanerr[ip] = m_pos_eangle[ip]->GetFunction("landaun")->GetParError(1);
227 pos_fitsigma[ip] = m_pos_eangle[ip]->GetFunction("landaun")->GetParameter(2);
228 pos_chisq[ip] = (m_pos_eangle[ip]->GetFunction("landaun")-> GetChisquare())/(m_pos_eangle[ip]->GetFunction("landaun")-> GetNDF());
229
230 neg_fitmean[ip] = m_neg_eangle[ip]->GetFunction("landaun")->GetParameter(1);
231 neg_fitmeanerr[ip] = m_neg_eangle[ip]->GetFunction("landaun")->GetParError(1);
232 neg_fitsigma[ip] = m_neg_eangle[ip]->GetFunction("landaun")->GetParameter(2);
233 neg_chisq[ip] = (m_neg_eangle[ip]->GetFunction("landaun")-> GetChisquare())/(m_neg_eangle[ip]->GetFunction("landaun")-> GetNDF());
234 }
236 {
237 fitmean[ip] = m_eangle[ip]->GetFunction("Landau")->GetParameter(1);
238 fitmeanerr[ip] = m_eangle[ip]->GetFunction("Landau")->GetParError(1);
239 fitsigma[ip] = m_eangle[ip]->GetFunction("Landau")->GetParameter(2);
240 chisq[ip] = (m_eangle[ip]->GetFunction("Landau")-> GetChisquare())/(m_eangle[ip]->GetFunction("Landau")-> GetNDF());
241
242 pos_fitmean[ip] = m_pos_eangle[ip]->GetFunction("Landau")->GetParameter(1);
243 pos_fitmeanerr[ip] = m_pos_eangle[ip]->GetFunction("Landau")->GetParError(1);
244 pos_fitsigma[ip] = m_pos_eangle[ip]->GetFunction("Landau")->GetParameter(2);
245 pos_chisq[ip] = (m_pos_eangle[ip]->GetFunction("Landau")-> GetChisquare())/(m_pos_eangle[ip]->GetFunction("Landau")-> GetNDF());
246
247 neg_fitmean[ip] = m_neg_eangle[ip]->GetFunction("Landau")->GetParameter(1);
248 neg_fitmeanerr[ip] = m_neg_eangle[ip]->GetFunction("Landau")->GetParError(1);
249 neg_fitsigma[ip] = m_neg_eangle[ip]->GetFunction("Landau")->GetParameter(2);
250 neg_chisq[ip] = (m_neg_eangle[ip]->GetFunction("Landau")-> GetChisquare())/(m_neg_eangle[ip]->GetFunction("Landau")-> GetNDF());
251 }
253 {
254 fitmean[ip] = m_eangle[ip]->GetFunction("Vavilov")->GetParameter(1);
255 fitmeanerr[ip] = m_eangle[ip]->GetFunction("Vavilov")->GetParError(1);
256 fitsigma[ip] = m_eangle[ip]->GetFunction("Vavilov")->GetParameter(2);
257 chisq[ip] = (m_eangle[ip]->GetFunction("Vavilov")-> GetChisquare())/(m_eangle[ip]->GetFunction("Vavilov")-> GetNDF());
258
259 pos_fitmean[ip] = m_pos_eangle[ip]->GetFunction("Vavilov")->GetParameter(1);
260 pos_fitmeanerr[ip] = m_pos_eangle[ip]->GetFunction("Vavilov")->GetParError(1);
261 pos_fitsigma[ip] = m_pos_eangle[ip]->GetFunction("Vavilov")->GetParameter(2);
262 pos_chisq[ip] = (m_pos_eangle[ip]->GetFunction("Vavilov")-> GetChisquare())/(m_pos_eangle[ip]->GetFunction("Vavilov")-> GetNDF());
263
264 neg_fitmean[ip] = m_neg_eangle[ip]->GetFunction("Vavilov")->GetParameter(1);
265 neg_fitmeanerr[ip] = m_neg_eangle[ip]->GetFunction("Vavilov")->GetParError(1);
266 neg_fitsigma[ip] = m_neg_eangle[ip]->GetFunction("Vavilov")->GetParameter(2);
267 neg_chisq[ip] = (m_neg_eangle[ip]->GetFunction("Vavilov")-> GetChisquare())/(m_neg_eangle[ip]->GetFunction("Vavilov")-> GetNDF());
268 }
270 {
271 fitmean[ip] = m_eangle[ip]->GetFunction("AsymGauss")->GetParameter(1);
272 fitmeanerr[ip] = m_eangle[ip]->GetFunction("AsymGauss")->GetParError(1);
273 fitsigma[ip] = m_eangle[ip]->GetFunction("AsymGauss")->GetParameter(2);
274 chisq[ip] = (m_eangle[ip]->GetFunction("AsymGauss")-> GetChisquare())/(m_eangle[ip]->GetFunction("AsymGauss")-> GetNDF());
275
276 pos_fitmean[ip] = m_pos_eangle[ip]->GetFunction("AsymGauss")->GetParameter(1);
277 pos_fitmeanerr[ip] = m_pos_eangle[ip]->GetFunction("AsymGauss")->GetParError(1);
278 pos_fitsigma[ip] = m_pos_eangle[ip]->GetFunction("AsymGauss")->GetParameter(2);
279 pos_chisq[ip] = (m_pos_eangle[ip]->GetFunction("AsymGauss")-> GetChisquare())/(m_pos_eangle[ip]->GetFunction("AsymGauss")-> GetNDF());
280
281 neg_fitmean[ip] = m_neg_eangle[ip]->GetFunction("AsymGauss")->GetParameter(1);
282 neg_fitmeanerr[ip] = m_neg_eangle[ip]->GetFunction("AsymGauss")->GetParError(1);
283 neg_fitsigma[ip] = m_neg_eangle[ip]->GetFunction("AsymGauss")->GetParameter(2);
284 neg_chisq[ip] = (m_neg_eangle[ip]->GetFunction("AsymGauss")-> GetChisquare())/(m_neg_eangle[ip]->GetFunction("AsymGauss")-> GetNDF());
285 }
286 if(entryNo[ip]>1500 && fitmean[ip]>0 && fitmeanerr[ip]>0 && fitmeanerr[ip]<10 && fitsigma[ip]>0 && fitsigma[ip]<200)
287 {
288 Norm+=fitmean[ip];
290 }
291 }
293
294 cout<<
"count= "<<
count<<
" average value of eangle bins: "<<Norm<<endl;
296 {
297 if(entryNo[i]>10 && fitmean[i]>0 && fitsigma[i]>0) gain[i]=fitmean[i]/Norm;
298 else{
299 gain[i] = 1;
300 fitmeanerr[i]=10000;
301 }
302 if(pos_entryNo[i]>10 && pos_fitmean[i]>0 && pos_fitsigma[i]>0) pos_gain[i]=pos_fitmean[i]/Norm;
303 else pos_gain[i] = 0;
304 if(neg_entryNo[i]>10 && neg_fitmean[i]>0 && neg_fitsigma[i]>0) neg_gain[i]=neg_fitmean[i]/Norm;
305 else neg_gain[i] = 0;
306 if(gain[i] != 0){
307 m_EAngAverdE -> SetBinContent(i+1, gain[i]);
308 m_EAngAverdE->SetBinError(i+1, fitmeanerr[i]/Norm);
309 }
310 if(pos_gain[i] != 0){
311 m_pos_EAngAverdE -> SetBinContent(i+1, pos_gain[i]);
312 m_pos_EAngAverdE->SetBinError(i+1, pos_fitmeanerr[i]/Norm);
313 }
314 if(neg_gain[i] != 0){
315 m_neg_EAngAverdE -> SetBinContent(i+1, neg_gain[i]);
316 m_neg_EAngAverdE->SetBinError(i+1, neg_fitmeanerr[i]/Norm);
317 }
318 }
319
320 log<<MSG::INFO<<"begin getting calibration constant!!! "<<endreq;
322 int denangle_entry[1] = {100};
323 m_EAngAverdE->Fit("pol1","r","",-0.25,0.25);
324 double par0 = m_EAngAverdE->GetFunction("pol1")->GetParameter(0);
325 double par1 = m_EAngAverdE->GetFunction("pol1")->GetParameter(1);
326
327
328
329 for(
int i=0;i<
NumSlices;i++) denangle[i] = gain[i];
330
331 log<<MSG::INFO<<"begin generating root file!!! "<<endreq;
332 TFile*
f =
new TFile(
m_rootfile.c_str(),
"recreate");
334 {
335 m_eangle[ip]->Write();
336 m_pos_eangle[ip]->Write();
337 m_neg_eangle[ip]->Write();
338 }
339 m_EAngAverdE->Write();
340 m_pos_EAngAverdE->Write();
341 m_neg_EAngAverdE->Write();
342
343 TTree* entracalib = new TTree("entracalib","entracalib");
344 entracalib->Branch("1denangle", denangle, "denangle[100]/D");
345 entracalib->Branch("1denangle_entry", denangle_entry, "denangle_entry[1]/I");
346 entracalib->Fill();
347 entracalib-> Write();
348
349 TTree* ddgcalib = new TTree("ddgcalib", "ddgcalib");
350 ddgcalib -> Branch("hits", entryNo, "entryNo[100]/D");
351 ddgcalib -> Branch("mean", mean, "mean[100]/D");
352 ddgcalib -> Branch("sigma", sigma, "sigma[100]/D");
353 ddgcalib -> Branch("fitmean", fitmean, "fitmean[100]/D");
354 ddgcalib -> Branch("fitmeanerr", fitmeanerr, "fitmeanerr[100]/D");
355 ddgcalib -> Branch("chi", fitsigma, "fitsigma[100]/D");
356 ddgcalib -> Branch("gain", gain, "gain[100]/D");
357 ddgcalib -> Branch("chisq", chisq, "chisq[100]/D");
358 ddgcalib -> Branch("pos_hits", pos_entryNo, "pos_entryNo[100]/D");
359 ddgcalib -> Branch("pos_mean", pos_mean, "pos_mean[100]/D");
360 ddgcalib -> Branch("pos_sigma", pos_sigma, "pos_sigma[100]/D");
361 ddgcalib -> Branch("pos_fitmean", pos_fitmean, "pos_fitmean[100]/D");
362 ddgcalib -> Branch("pos_fitmeanerr", pos_fitmeanerr, "pos_fitmeanerr[100]/D");
363 ddgcalib -> Branch("pos_chi", pos_fitsigma, "pos_fitsigma[100]/D");
364 ddgcalib -> Branch("pos_gain", pos_gain, "pos_gain[100]/D");
365 ddgcalib -> Branch("pos_chisq", pos_chisq, "pos_chisq[100]/D");
366 ddgcalib -> Branch("neg_hits", neg_entryNo, "neg_entryNo[100]/D");
367 ddgcalib -> Branch("neg_mean", neg_mean, "neg_mean[100]/D");
368 ddgcalib -> Branch("neg_sigma", neg_sigma, "neg_sigma[100]/D");
369 ddgcalib -> Branch("neg_fitmean", neg_fitmean, "neg_fitmean[100]/D");
370 ddgcalib -> Branch("neg_fitmeanerr", neg_fitmeanerr, "neg_fitmeanerr[100]/D");
371 ddgcalib -> Branch("neg_chi", neg_fitsigma, "neg_fitsigma[100]/D");
372 ddgcalib -> Branch("neg_gain", neg_gain, "neg_gain[100]/D");
373 ddgcalib -> Branch("neg_chisq", neg_chisq, "neg_chisq[100]/D");
374 ddgcalib -> Branch("Ip_eangle", Ip_eangle, "Ip_eangle[100]/D");
375 ddgcalib -> Branch("eangle", eangle, "eangle[100]/D");
376 ddgcalib -> Fill();
377 ddgcalib -> Write();
379
380 TCanvas c1("c1", "canvas", 500, 400);
382 m_EAngAverdE->Draw();
384 m_pos_EAngAverdE->Draw();
386 m_neg_EAngAverdE->Draw();
389 {
390 m_eangle[ip]->Draw();
392 }
394 {
395 m_pos_eangle[ip]->Draw();
397 }
399 {
400 m_neg_eangle[ip]->Draw();
402 }
404
406 {
407 delete m_eangle[ip];
408 delete m_pos_eangle[ip];
409 delete m_neg_eangle[ip];
410 }
411 delete m_EAngAverdE;
412 delete m_pos_EAngAverdE;
413 delete m_neg_EAngAverdE;
414
415}
DOUBLE_PRECISION count[3]