Changeset 14946 for fact/tools/rootmacros/PulseTemplates/pulse.C
- Timestamp:
- 02/21/13 14:56:09 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fact/tools/rootmacros/PulseTemplates/pulse.C
r14814 r14946 75 75 // PUBLIC OPERATIONS 76 76 // =========================================================================== 77 78 void 79 Pulse::Fit() 80 { 81 Fit(mName, mOptions, mType); 82 } 83 84 void 85 Pulse::Fit( 86 TString fitOptions, 87 int type 88 ) 89 { 90 Fit(mName, fitOptions, type); 91 } 77 92 78 93 void … … 140 155 mHisto = NULL; 141 156 mModel = NULL; 142 mOptions = " S";157 mOptions = "ERS"; 143 158 mBsl.first = 0; 144 159 mHeight.first = 0; … … 168 183 mChi2 = 0; 169 184 mTimeResolution = 0.5; 185 mVerbosityLvl = 6; 170 186 } 171 187 … … 181 197 ) 182 198 { 199 int numPara = 7; 183 200 mFitMin = fitMin; 184 201 mFitMax = fitMax; 185 mModel = new TF1(fitName, shapeFunc, fitMin, fitMax, 7);186 202 mModel = new TF1(fitName, shapeFunc, fitMin, fitMax, numPara ); 203 mModel->SetNpx( mHisto->GetNbinsX()); 187 204 // ====================================================================== 188 205 // Calculate startvaues for fit … … 214 231 double para[] = {bsl, amplitude, start, stop, tau, tau, phe}; 215 232 233 234 // cout startvalues 235 if (mVerbosityLvl > 3) 236 { 237 for (unsigned int i = 0; i < numPara; i++) 238 { 239 cout << "para[ " << i << "]: " << para[i] << endl; 240 } 241 } 216 242 217 243 … … 246 272 ) 247 273 { 274 int numPara = 6; 248 275 mFitMin = fitMin; 249 276 mFitMax = fitMax; 250 mModel = new TF1(fitName, shapeFunc2, fitMin, fitMax, 6);251 277 mModel = new TF1(fitName, shapeFunc2, fitMin, fitMax, numPara ); 278 mModel->SetNpx( mHisto->GetNbinsX()); 252 279 // ====================================================================== 253 280 // Calculate startvaues for fit 254 double tau 281 double tau = 30.0; 255 282 double bsl = 0; //MW der ersten zehn slices 283 // double bsl2 = 0; //MW der ersten zehn slices 256 284 double gain = 10; //startvalue for gain 257 int first_bin = mHisto->GetXaxis()->GetFirst(); 258 259 for (int i = 0; i < 30; i++){ 260 bsl += mHisto->GetBinContent(first_bin+0); 261 } 262 bsl = bsl/30; 285 int counter = 0; 263 286 264 287 double stop = mHisto->GetMaximumBin(); //pos of max 265 double amplitude= mHisto->GetBinContent(stop); 266 double start = stop-10; //pos 10 slices before maximum 288 double amplitude=0; 289 290 for (int i = (stop - 3) ; i < (stop + 3) && i <= fitMax && i >= fitMin ; i++) 291 { 292 counter++; 293 amplitude= mHisto->GetBinContent(i); 294 } 295 amplitude=amplitude/counter; 296 297 counter = 0; 298 for (int i = (stop - 15) ; i > fitMin+2 && i <= fitMax ; i--) 299 { 300 if (mHisto->GetBinContent(i) > 0) 301 { 302 break; 303 } 304 counter++; 305 bsl += mHisto->GetBinContent(i); 306 } 307 if (counter <= 0) 308 { 309 counter = 1; 310 } 311 bsl = bsl/counter; 312 313 // counter = 0; 314 // for (int i = stop + 100; i < stop + 200 && i <= fitMax && i >= fitMin ; i++) 315 // { 316 // if (mHisto->GetBinContent(i) > 0.5*amplitude ) 317 // { 318 // break; 319 // } 320 // counter++; 321 // bsl2 += mHisto->GetBinContent(i); 322 // } 323 // if (counter <= 0) 324 // { 325 // counter = 1; 326 // } 327 // bsl2 = bsl2/counter; 328 329 double start = mHisto->GetBinCenter(stop-10); //pos 10 slices before maximum 267 330 int phe = 0; 268 331 if (mOrder < 0) … … 277 340 278 341 279 double para[] = {bsl, amplitude, start, tau, tau, phe};342 double para[] = {bsl, 2*amplitude+gain, start, tau*0.1, tau, phe}; 280 343 mModel->SetParameters(para); 281 344 mModel->SetParNames("BSL", "A0", "t0", "Tau1", "Tau2", "PhE"); 282 345 mModel->SetLineColor(kBlue); 283 346 347 // cout startvalues 348 if (mVerbosityLvl > 3) 349 { 350 cout << endl; 351 for (unsigned int i = 0; i < numPara; i++) 352 { 353 cout << "para[ " << i << "]: " << para[i] << endl; 354 } 355 } 284 356 mFitResultPtr = mHisto->Fit(mModel, fitOptions); 285 357 mBsl.first = mModel->GetParameter(0); … … 401 473 double Pulse::GetTimeResolution(){return mTimeResolution;} 402 474 void Pulse::SetTimeResolution(double timeResolution){mTimeResolution = timeResolution;} 475 void Pulse::SetVerbosity(int verbLvl){mVerbosityLvl = verbLvl;} 403 476 404 477 … … 498 571 double tau2 = par[4]; 499 572 int phe = par[5]; 573 // double bsl2 = par[6]; 500 574 501 575 // helper variables
Note:
See TracChangeset
for help on using the changeset viewer.