103{
104 MsgStream log(
msgSvc(), name());
105 log<<MSG::INFO<<"DedxCalibRunByRun::WriteHists()"<<endreq;
106
107 TFile* f =
new TFile(
m_rootfile.c_str(),
"recreate");
108
109 Double_t gainpar=0, resolpar=0;
110 gainpar = m_hist -> GetFunction("gaus") -> GetParameter(1);
111 resolpar = m_hist -> GetFunction("gaus") -> GetParameter(2);
112
113 TTree* gain = new TTree("gaincalib", "gaincalib");
114 gain -> Branch("gain", &gainpar, "gain[1]/D");
115 gain->Fill();
116 TTree* resol = new TTree("resolcalib", "resolcalib");
117 resol -> Branch("resol", &resolpar, "resol[1]/D");
118 resol->Fill();
119
120 Int_t runno=0;
121 Double_t runmean=0, rungain=0, runresol=0;
122 TTree* runbyrun = new TTree("runcalib", "runcalib");
123 runbyrun -> Branch("runno", &runno, "runno/I");
124 runbyrun -> Branch("runmean", &runmean, "runmean/D");
125 runbyrun -> Branch("rungain", &rungain, "rungain/D");
126 runbyrun -> Branch("runresol", &runresol, "runresol/D");
127 for(
int i=0; i<
runNo; i++)
128 {
129 runno = m_runNOVector[i];
130 runmean = m_rungain[i] -> GetFunction("gaus") -> GetParameter(1);
131 runresol = m_rungain[i] -> GetFunction("gaus") -> GetParameter(2);
133 cout<<"i = "<<i<<" runno = "<<runno <<" @ runmean = "<<runmean<<" @ rungain = "<<rungain<<" @ runresol = "<<runresol<<endl;
134 runbyrun -> Fill();
135 }
136
137 m_hist->Write();
138 for(
int i=0; i<
runNo; i++) m_rungain[i]->Write();
139 gain->Write();
140 resol -> Write();
141 runbyrun -> Write();
142
143 delete m_hist;
144 for(
int i=0; i<
runNo; i++)
delete m_rungain[i];
145 delete gain;
146 delete resol;
147 delete runbyrun;
148 f->Close();
149}