126 {
127 auto file = new TFile(outfile.c_str(), "RECREATE");
128 auto otree = new TTree("fits", "fitted times");
129
130 unsigned channel = 0;
131 double maxpos = 0;
132
133 otree->Branch("maxpos", &maxpos, "maxpos/D");
134
136 double parms[3];
137 double parmErrs[3];
138 otree->Branch("channel", &channel, "channel/I");
139 otree->Branch("norm", &(parms[0]), "norm/D");
140 otree->Branch("time", &(parms[1]), "time/D");
141 otree->Branch("reso", &(parms[2]), "reso/D");
142 otree->Branch("normErr", &(parmErrs[0]), "normErr/D");
143 otree->Branch("timeErr", &(parmErrs[1]), "timeErr/D");
144 otree->Branch("resoErr", &(parmErrs[2]), "resoErr/D");
145
148 if (f) {
149 f->GetParameters(parms);
150 for (int iPar = 0; iPar < 3; iPar++)
151 parmErrs[iPar] = f->GetParError(iPar);
152 otree->Fill();
153 channel++;
154 }
155 }
157 double parms[8];
158 double parmErrs[8];
159
160 double time2 = 0;
161 otree->Branch("channel", &channel, "channel/I");
162 otree->Branch("norm1", &(parms[0]), "norm1/D");
163 otree->Branch("time1", &(parms[1]), "time1/D");
164 otree->Branch("reso1", &(parms[2]), "reso1/D");
165 otree->Branch("alpha_CB", &(parms[3]), "alpha_CB/D");
166 otree->Branch("n_CB", &(parms[4]), "n_CB/D");
167 otree->Branch("norm2", &(parms[5]), "norm2/D");
168 otree->Branch("dt12", &(parms[6]), "dt12/D");
169 otree->Branch("reso2", &(parms[7]), "reso2/D");
170 otree->Branch("time2", &time2, "time2/D");
171
172 otree->Branch("norm1Err", &(parmErrs[0]), "norm1Err/D");
173 otree->Branch("time1Err", &(parmErrs[1]), "time1Err/D");
174 otree->Branch("reso1Err", &(parmErrs[2]), "reso1Err/D");
175 otree->Branch("alpha_CBErr", &(parmErrs[3]), "alpha_CBErr/D");
176 otree->Branch("n_CBErr", &(parmErrs[4]), "n_CBErr/D");
177 otree->Branch("norm2Err", &(parmErrs[5]), "norm2Err/D");
178 otree->Branch("dt12Err", &(parmErrs[6]), "dt12Err/D");
179 otree->Branch("reso2Err", &(parmErrs[7]), "reso2Err/D");
180
181
184 if (f) {
185 f->GetParameters(parms);
186 for (int iPar = 0; iPar < 8; iPar++)
187 parmErrs[iPar] = f->GetParError(iPar);
188 otree->Fill();
189 channel++;
190 }
191 }
193 double parms[5];
194 double parmErrs[5];
195
196 otree->Branch("channel", &channel, "channel/I");
197 otree->Branch("norm", &(parms[0]), "norm/D");
198 otree->Branch("time", &(parms[1]), "time/D");
199 otree->Branch("reso", &(parms[2]), "reso/D");
200 otree->Branch("alpha_CB", &(parms[3]), "alpha_CB/D");
201 otree->Branch("n_CB", &(parms[4]), "n_CB/D");
202
203 otree->Branch("normErr", &(parmErrs[0]), "normErr/D");
204 otree->Branch("timeErr", &(parmErrs[1]), "timeErr/D");
205 otree->Branch("resoErr", &(parmErrs[2]), "resoErr/D");
206 otree->Branch("alpha_CBErr", &(parmErrs[3]), "alpha_CBErr/D");
207 otree->Branch("n_CBErr", &(parmErrs[4]), "n_CBErr/D");
208
211 if (f) {
212 f->GetParameters(parms);
213 for (int iPar = 0; iPar < 5; iPar++)
214 parmErrs[iPar] = f->GetParError(iPar);
215 otree->Fill();
216 channel++;
217 }
218 }
219 } else {
220 B2WARNING("Nothing be written to files!");
221 return;
222 }
224 if (h && h->GetEntries() >= 10) {
225 h->Write();
226 }
227 }
228 otree->Write();
229 delete otree;
230 file->Close();
231 delete file;
232 }