23 hDebugFile =
new TFile(
"DTMeanTimerFitter.root",
"RECREATE");
31 vector<float> vDriftAndReso;
34 if (
histos->hTmax123 !=
nullptr) {
37 hTMax.push_back(
histos->hTmax123);
38 hTMax.push_back(
histos->hTmax124s72);
39 hTMax.push_back(
histos->hTmax124s78);
40 hTMax.push_back(
histos->hTmax134s72);
41 hTMax.push_back(
histos->hTmax134s78);
42 hTMax.push_back(
histos->hTmax234);
44 hT0.push_back(
histos->hTmax_3t0);
45 hT0.push_back(
histos->hTmax_2t0);
46 hT0.push_back(
histos->hTmax_t0);
47 hT0.push_back(
histos->hTmax_0);
59 vector<Double_t>
mean;
60 vector<Double_t> sigma;
61 vector<Double_t>
count;
63 for (vector<TH1F *>::const_iterator ith = hTMax.begin(); ith != hTMax.end(); ++ith) {
66 edm::LogError(
"DTMeanTimerFitter") <<
"Error when fitting TMax..histogram name" << (*ith)->GetName();
68 vector<float> defvec(6, -1);
76 sigma.push_back(
funct->GetParameter(2));
77 count.push_back((*ith)->GetEntries());
80 Double_t tMaxMean = 0.;
81 Double_t wTMaxSum = 0.;
83 Double_t wSigmaSum = 0.;
86 for (
int i = 0;
i <= 5;
i++) {
90 wTMaxSum +=
count[
i] / (sigma[
i] * sigma[
i]);
97 if ((!wTMaxSum) || (!wSigmaSum)) {
98 edm::LogError(
"DTMeanTimerFitter") <<
"Error zero sum of weights..returning default";
99 vector<float> defvec(6, -1);
103 tMaxMean /= wTMaxSum;
107 Double_t vDrift = 2.1 / tMaxMean;
108 Double_t reso = vDrift * sigmaT;
109 vDriftAndReso.push_back(vDrift);
110 vDriftAndReso.push_back(reso);
113 <<
" final TMaxMean=" << tMaxMean <<
" sigma= " << sigmaT <<
" v_d and reso: " << vDrift <<
" " << reso << endl;
116 map<Double_t, TH1F *> hEntries;
117 for (vector<TH1F *>::const_iterator ith = hT0.begin(); ith != hT0.end(); ++ith) {
118 hEntries[(*ith)->GetEntries()] = (*ith);
123 for (map<Double_t, TH1F *>::reverse_iterator iter = hEntries.rbegin(); iter != hEntries.rend(); ++iter) {
126 hT0.push_back(iter->second);
128 hT0.push_back(iter->second);
134 vector<Double_t> meanT0;
135 vector<Double_t> sigmaT0;
136 vector<Double_t> countT0;
138 for (vector<TH1F *>::const_iterator ith = hT0.begin(); ith != hT0.end(); ++ith) {
142 edm::LogError(
"DTMeanTimerFitter") <<
"Exception when fitting T0..histogram " << (*ith)->GetName();
144 vector<float> defvec(6, -1);
147 TF1 *
f1 = (*ith)->GetFunction(
"gaus");
149 meanT0.push_back(
f1->GetParameter(1));
150 sigmaT0.push_back(
f1->GetParameter(2));
151 countT0.push_back((*ith)->GetEntries());
154 if (hT0.size() != 6) {
156 for (
int i = 1;
i <= 4;
i++) {
157 vDriftAndReso.push_back(-1);
159 return vDriftAndReso;
162 for (
int it0 = 0; it0 <= 2; it0++) {
163 if ((countT0[it0] > 200) && (countT0[it0 + 1] > 200)) {
164 Double_t deltaT0 = meanT0[it0] - meanT0[it0 + 1];
165 vDriftAndReso.push_back(deltaT0);
167 vDriftAndReso.push_back(999.);
170 if ((countT0[4] > 200) && (countT0[5] > 200)) {
171 Double_t t0Diff =
histos->GetT0Factor(hT0[4]) -
histos->GetT0Factor(hT0[5]);
172 Double_t deltaT0MaxEntries = (meanT0[4] - meanT0[5]) / t0Diff;
173 vDriftAndReso.push_back(deltaT0MaxEntries);
175 vDriftAndReso.push_back(999.);
177 for (
int i = 1;
i <= 6;
i++) {
180 vDriftAndReso.push_back(-1);
183 return vDriftAndReso;
188 Double_t peak = (((((
histo->GetXaxis())->GetXmax()) - ((
histo->GetXaxis())->GetXmin())) /
histo->GetNbinsX()) *
189 (
histo->GetMaximumBin())) +
190 ((
histo->GetXaxis())->GetXmin());
192 LogDebug(
"DTMeanTimerFitter") <<
"Peak " << peak <<
" : "
193 <<
"xmax " << ((
histo->GetXaxis())->GetXmax()) <<
" xmin "
194 << ((
histo->GetXaxis())->GetXmin()) <<
" nbin " <<
histo->GetNbinsX()
195 <<
" bin with max " << (
histo->GetMaximumBin());
200 rGaus->SetMarkerSize();
202 histo->Fit(
"rGaus",
"R");
204 edm::LogError(
"DTMeanTimerFitter") <<
"Exception when fitting TMax..histogram " <<
histo->GetName()
205 <<
" setting return function pointer to zero";