Phase2Fitter Class Reference

#include <Phase2Fitter.h>

List of all members.

Public Member Functions

 Phase2Fitter ()
 ~Phase2Fitter ()
void LoadCC (const char *file)
void LoadRAF (const char *file)
void Fit1D ()
void Fit2D ()
void Fit2DGPS ()
void Fit2DRAF ()
void FitMinimum (TH1D *h)
void PrintLikelihoods ()
void PrintLikelihoodsRAF ()
void SaveFitResults (const char *saveFile)
void SetMI60dir (const char *dir)
void SetGridFlag (bool)
void LoadRAFdelayFile (const TString s)

Public Attributes

double offsetMin
double offsetMax
double offsetStep
double smearingMin
double smearingMax
double smearingStep

Private Member Functions

double EventLikelihood (Phase2Event *event, double offset, double smearing)
double EventLikelihoodRAF (Phase2Event *event, double offset, double smearing)
double EventLikelihoodGPS (Phase2Event *event, double offset, double smearing)

Private Attributes

bool gridFlag
const char * MI60fileLocation
TH1D * hPDF
Phase2Eventevent
TTree * data
MI60pdf pdf
int nEvts
double startOfMI60data
double endOfMI60data
double earliestEvent
double earliestEventFD
double latestEvent
double latestEventFD
std::vector< TH1D * > hList
TH1D * likelihood1D
TH2D * likelihood2D
double lastSpillTime
double lastSmearing

Detailed Description

Definition at line 13 of file Phase2Fitter.h.


Constructor & Destructor Documentation

Phase2Fitter::Phase2Fitter (  ) 

Definition at line 29 of file Phase2Fitter.cxx.

References gridFlag, hPDF, lastSmearing, lastSpillTime, likelihood1D, likelihood2D, MI60fileLocation, offsetMax, offsetMin, offsetStep, smearingMax, smearingMin, and smearingStep.

00030 {
00031   MI60fileLocation = "";
00032   hPDF = 0;
00033   offsetMin=0;
00034   offsetMax=0;
00035   offsetStep=0;
00036   smearingMin=0;
00037   smearingMax=0;
00038   smearingStep=0;
00039   
00040   likelihood1D=0;
00041   likelihood2D=0;
00042   
00043   event = new Phase2Event;
00044 
00045   lastSpillTime = 0;
00046   lastSmearing = 0;
00047 
00048   gridFlag = false;
00049 }

Phase2Fitter::~Phase2Fitter (  ) 

Definition at line 52 of file Phase2Fitter.cxx.

References hList, it, likelihood1D, and likelihood2D.

00053 {
00054   if (likelihood1D) {delete likelihood1D; likelihood1D=0; std::cout<<"deleted likelihood1D"<<std::endl;}
00055   if (likelihood2D) {delete likelihood2D; likelihood2D=0; std::cout<<"deleted likelihood2D"<<std::endl;}
00056   for(std::vector<TH1D*>::iterator it = hList.begin(); it != hList.end(); it++){
00057     delete (*it);
00058     (*it) = 0;
00059   }
00060 
00061   if (event) {delete event; event=0; std::cout<<"deleted event"<<std::endl;}
00062 }


Member Function Documentation

double Phase2Fitter::EventLikelihood ( Phase2Event event,
double  offset,
double  smearing 
) [private]

Definition at line 377 of file Phase2Fitter.cxx.

References MI60pdf::CreatePDF(), MuELoss::e, endOfMI60data, MI60pdf::fileFound, MI60pdf::GetPDFhisto(), hPDF, MI60pdf::lastD74, lastSmearing, lastSpillTime, MI60pdf::MakeSmearedPDF(), pdf, Phase2Event::rwcmFilename, and startOfMI60data.

Referenced by Fit1D(), Fit2D(), and PrintLikelihoods().

00378 {
00379   double spillTime = event->spillTime;
00380   if (spillTime != lastSpillTime){
00381     std::cout<<"opening new RWCM file "<<event->rwcmFilename<<std::endl;
00382     pdf.CreatePDF(event->rwcmFilename, smearing);
00383     std::cout<<pdf.lastD74<<std::endl;
00384   }
00385 
00386   if (smearing != lastSmearing){
00387     //    std::cout<<"Changing smearing to "<<smearing<<std::endl;
00388     pdf.MakeSmearedPDF(smearing);
00389   }
00390 
00391   lastSpillTime = spillTime;
00392   lastSmearing = smearing;
00393 
00394   if (!pdf.fileFound) {
00395     //std::cout<<"No MI60 data for this spill. Skipping. "<<event->rwcmFilename<<std::endl;
00396     return 1e-10;
00397   }
00398 
00399   hPDF = pdf.GetPDFhisto();
00400   startOfMI60data = hPDF->GetXaxis()->GetBinCenter(1);
00401   endOfMI60data = hPDF->GetXaxis()->GetBinCenter(hPDF->GetNbinsX()-1);
00402 
00403   double eventTime = event->eventTime - offset + pdf.lastD74;
00404   double likelihood = 0;
00405 
00406   if (eventTime>startOfMI60data && eventTime<endOfMI60data){
00407     likelihood = hPDF->Interpolate(eventTime);
00408   }
00409 
00410   if (likelihood>0) return likelihood;
00411   else return 1e-10;
00412 }

double Phase2Fitter::EventLikelihoodGPS ( Phase2Event event,
double  offset,
double  smearing 
) [private]

Definition at line 455 of file Phase2Fitter.cxx.

References MI60pdf::CreatePDF(), MuELoss::e, endOfMI60data, MI60pdf::fileFound, MI60pdf::GetPDFhisto(), hPDF, MI60pdf::lastD74, lastSmearing, lastSpillTime, MI60pdf::MakeSmearedPDF(), pdf, Phase2Event::rwcmFilename, and startOfMI60data.

Referenced by Fit2DGPS().

00456 {
00457   double spillTime = event->spillTime;
00458   if (spillTime != lastSpillTime){
00459     //std::cout<<"opening new RWCM file "<<event->rwcmFilename<<std::endl;
00460     pdf.CreatePDF(event->rwcmFilename, smearing);
00461   }
00462 
00463   if (smearing != lastSmearing){
00464     //    std::cout<<"Changing smearing to "<<smearing<<std::endl;
00465     pdf.MakeSmearedPDF(smearing);
00466   }
00467 
00468   lastSpillTime = spillTime;
00469   lastSmearing = smearing;
00470 
00471   if (!pdf.fileFound) {
00472     //    std::cout<<"No MI60 data for this spill. Skipping. "<<event->rwcmFilename<<std::endl;
00473     return 1e-10;
00474   }
00475 
00476 
00477   hPDF = pdf.GetPDFhisto();
00478   startOfMI60data = hPDF->GetXaxis()->GetBinCenter(1);
00479   endOfMI60data = hPDF->GetXaxis()->GetBinCenter(hPDF->GetNbinsX()-1);
00480 
00481 
00482   double eventTime = event->gpsEventTime - offset + pdf.lastD74;
00483   double likelihood = 0;
00484 
00485   if (eventTime>startOfMI60data && eventTime<endOfMI60data){
00486     likelihood = hPDF->Interpolate(eventTime);
00487   }
00488 
00489   if (likelihood>0) return likelihood;
00490   else return 1e-10;
00491 }

double Phase2Fitter::EventLikelihoodRAF ( Phase2Event event,
double  offset,
double  smearing 
) [private]

Definition at line 415 of file Phase2Fitter.cxx.

References MI60pdf::CreatePDF(), MuELoss::e, endOfMI60data, MI60pdf::fileFound, MI60pdf::GetPDFhisto(), hPDF, MI60pdf::lastD74, lastSmearing, lastSpillTime, MI60pdf::makeRAFPDF(), MI60pdf::MakeSmearedPDF(), pdf, Phase2Event::rwcmFilename, and startOfMI60data.

Referenced by Fit2DRAF(), and PrintLikelihoodsRAF().

00416 {
00417   double spillTime = event->spillTime;
00418   if (spillTime != lastSpillTime){
00419     std::cout<<"opening new RWCM file "<<event->rwcmFilename<<std::endl;
00420     pdf.CreatePDF(event->rwcmFilename, smearing);
00421     pdf.makeRAFPDF();
00422     std::cout<<pdf.lastD74<<std::endl;
00423   }
00424 
00425   if (smearing != lastSmearing){
00426     //    std::cout<<"Changing smearing to "<<smearing<<std::endl;
00427     pdf.MakeSmearedPDF(smearing);
00428     pdf.makeRAFPDF();
00429   }
00430 
00431   lastSpillTime = spillTime;
00432   lastSmearing = smearing;
00433 
00434   if (!pdf.fileFound) {
00435     //std::cout<<"No MI60 data for this spill. Skipping. "<<event->rwcmFilename<<std::endl;
00436     return 1e-10;
00437   }
00438 
00439   hPDF = pdf.GetPDFhisto();
00440   startOfMI60data = hPDF->GetXaxis()->GetBinCenter(1);
00441   endOfMI60data = hPDF->GetXaxis()->GetBinCenter(hPDF->GetNbinsX()-1);
00442 
00443   double eventTime = event->eventTime - offset + pdf.lastD74;
00444   double likelihood = 0;
00445 
00446   if (eventTime>startOfMI60data && eventTime<endOfMI60data){
00447     likelihood = hPDF->Interpolate(eventTime);
00448   }
00449 
00450   if (likelihood>0) return likelihood;
00451   else return 1e-10;
00452 }

void Phase2Fitter::Fit1D (  ) 

Definition at line 122 of file Phase2Fitter.cxx.

References data, EventLikelihood(), likelihood1D, nEvts, offsetMax, offsetMin, offsetStep, and smearingMin.

00122                         {
00123 
00124   std::cout<<"Executing 1D fit between  and MI60."<<std::endl;
00125   std::cout<<"Offset start value: "<< offsetMin <<std::endl
00126            <<"Offset end value: "  << offsetMax <<std::endl
00127            <<"Offset step size: "  << offsetStep<<std::endl;
00128   
00129   double smearing = smearingMin;
00130   
00131   //stores the distribution of likelihood across the fitted range of offset
00132   //want bin centers on the step values. Need nSteps+1 bins
00133   int nBins = ((offsetMax-offsetMin)/offsetStep)+1.45; //rounds to appropriate int
00134   likelihood1D = new TH1D("likelihood1D","1D  Likelihood", nBins,
00135                             offsetMin - 0.5*offsetStep, offsetMax + 0.5*offsetStep);
00136   
00137   nEvts = data->GetEntries();
00138 
00139   for (int i=0; i<nEvts; i++){
00140     data->GetEntry(i);
00141     std::cout<<event->spillTime<<std::endl;
00142     for (double offset = offsetMin; offset<=offsetMax+(offsetStep*0.1); offset+=offsetStep){
00143       double L = (EventLikelihood(event, offset, smearing));
00144       likelihood1D->Fill(offset, -2*log(L));
00145     }
00146     delete event; event = 0;
00147   } 
00148 }

void Phase2Fitter::Fit2D (  ) 

Definition at line 151 of file Phase2Fitter.cxx.

References data, EventLikelihood(), Plot::Format(), hList, likelihood2D, nEvts, offsetMax, offsetMin, offsetStep, smearingMax, smearingMin, and smearingStep.

00151                         {
00152 
00153   std::cout<<"Executing 2D fit between  and MI60."<<std::endl;
00154   std::cout<<"Offset start value: "<< offsetMin <<std::endl
00155            <<"Offset end value: "  << offsetMax <<std::endl
00156            <<"Offset step size: "  << offsetStep<<std::endl;
00157 
00158   std::cout<<"Smearing start value: "<< smearingMin <<std::endl
00159            <<"Smearing end value: "  << smearingMax <<std::endl
00160            <<"Smearing step size: "  << smearingStep<<std::endl;
00161   
00162   //stores the distribution of likelihood across the fitted range of offset
00163   //want bin centers on the step values. Need nSteps+1 bins
00164   int nBinsOffset = ((offsetMax-offsetMin)/offsetStep)+1.45; //rounds to appropriate int
00165   int nBinsSmearing = ((smearingMax-smearingMin)/smearingStep)+1.45;
00166 
00167   likelihood2D = new TH2D("likelihood2D","2D  Likelihood", nBinsOffset,
00168                             offsetMin - 0.5*offsetStep, offsetMax + 0.5*offsetStep,
00169                             nBinsSmearing, smearingMin - 0.5*smearingStep, smearingMax + 0.5*smearingStep);
00170   
00171 
00172   nEvts = data->GetEntries();
00173 
00174   for (double smearing = smearingMin; smearing<=smearingMax+(smearingStep*0.1); smearing+=smearingStep){
00175     //want not only a 2d histogram but a 1d for each smearing point
00176     TString histoName = TString::Format("h1Ds%.0f",smearing*1e10);
00177     std::cout<<"creating histo "<< histoName<<std::endl;
00178     TH1D* h1D = new TH1D(histoName.Data(),histoName.Data(),
00179                          nBinsOffset,
00180                          offsetMin - 0.5*offsetStep,
00181                          offsetMax + 0.5*offsetStep);
00182     hList.push_back(h1D);
00183   }
00184   
00185   for (int i=0; i<nEvts; i++){
00186     if (i%100 == 0) std::cout<<i<<" / "<<nEvts<<std::endl;
00187     data->GetEntry(i);
00188     int smearBin = 0;
00189     for (double smearing = smearingMin; smearing<=smearingMax+(smearingStep*0.1); smearing+=smearingStep){
00190       for (double offset = offsetMin; offset<=offsetMax+(offsetStep*0.1); offset+=offsetStep){
00191       double L = (EventLikelihood(event, offset, smearing));
00192       likelihood2D->Fill(offset, smearing, -2*log(L));
00193       hList[smearBin]->Fill(offset, -2*log(L));
00194       //      std::cout<<-2*log(L)<<std::endl;
00195       }
00196       smearBin++;
00197     }
00198     delete event; event = 0;
00199   } 
00200 }

void Phase2Fitter::Fit2DGPS (  ) 

Definition at line 254 of file Phase2Fitter.cxx.

References data, EventLikelihoodGPS(), Plot::Format(), hList, likelihood2D, nEvts, offsetMax, offsetMin, offsetStep, smearingMax, smearingMin, and smearingStep.

00254                            {
00255 
00256   std::cout<<"Executing 2D fit between  and MI60."<<std::endl;
00257   std::cout<<"Offset start value: "<< offsetMin <<std::endl
00258            <<"Offset end value: "  << offsetMax <<std::endl
00259            <<"Offset step size: "  << offsetStep<<std::endl;
00260 
00261   std::cout<<"Smearing start value: "<< smearingMin <<std::endl
00262            <<"Smearing end value: "  << smearingMax <<std::endl
00263            <<"Smearing step size: "  << smearingStep<<std::endl;
00264   
00265   //stores the distribution of likelihood across the fitted range of offset
00266   //want bin centers on the step values. Need nSteps+1 bins
00267   int nBinsOffset = ((offsetMax-offsetMin)/offsetStep)+1.45; //rounds to appropriate int
00268   int nBinsSmearing = ((smearingMax-smearingMin)/smearingStep)+1.45;
00269 
00270   likelihood2D = new TH2D("likelihood2D","2D  Likelihood", nBinsOffset,
00271                             offsetMin - 0.5*offsetStep, offsetMax + 0.5*offsetStep,
00272                             nBinsSmearing, smearingMin - 0.5*smearingStep, smearingMax + 0.5*smearingStep);
00273   
00274 
00275   nEvts = data->GetEntries();
00276 
00277   for (double smearing = smearingMin; smearing<=smearingMax+(smearingStep*0.1); smearing+=smearingStep){
00278     //want not only a 2d histogram but a 1d for each smearing point
00279     TString histoName = TString::Format("h1Ds%.0f",smearing*1e10);
00280     std::cout<<"creating histo "<< histoName<<std::endl;
00281     TH1D* h1D = new TH1D(histoName.Data(),histoName.Data(),
00282                          nBinsOffset,
00283                          offsetMin - 0.5*offsetStep,
00284                          offsetMax + 0.5*offsetStep);
00285     hList.push_back(h1D);
00286   }
00287   
00288   for (int i=0; i<nEvts; i++){
00289     if (i%100 == 0) std::cout<<i<<" / "<<nEvts<<std::endl;
00290     data->GetEntry(i);
00291     int smearBin = 0;
00292     for (double smearing = smearingMin; smearing<=smearingMax+(smearingStep*0.1); smearing+=smearingStep){
00293       for (double offset = offsetMin; offset<=offsetMax+(offsetStep*0.1); offset+=offsetStep){
00294       double L = (EventLikelihoodGPS(event, offset, smearing));
00295       likelihood2D->Fill(offset, smearing, -2*log(L));
00296       hList[smearBin]->Fill(offset, -2*log(L));
00297       }
00298       smearBin++;
00299     }
00300     delete event; event = 0;
00301   } 
00302 }

void Phase2Fitter::Fit2DRAF (  ) 

Definition at line 203 of file Phase2Fitter.cxx.

References data, EventLikelihoodRAF(), Plot::Format(), hList, likelihood2D, nEvts, offsetMax, offsetMin, offsetStep, smearingMax, smearingMin, and smearingStep.

00203                            {
00204 
00205   std::cout<<"Offset start value: "<< offsetMin <<std::endl
00206            <<"Offset end value: "  << offsetMax <<std::endl
00207            <<"Offset step size: "  << offsetStep<<std::endl;
00208 
00209   std::cout<<"Smearing start value: "<< smearingMin <<std::endl
00210            <<"Smearing end value: "  << smearingMax <<std::endl
00211            <<"Smearing step size: "  << smearingStep<<std::endl;
00212   
00213   //stores the distribution of likelihood across the fitted range of offset
00214   //want bin centers on the step values. Need nSteps+1 bins
00215   int nBinsOffset = ((offsetMax-offsetMin)/offsetStep)+1.45; //rounds to appropriate int
00216   int nBinsSmearing = ((smearingMax-smearingMin)/smearingStep)+1.45;
00217 
00218   likelihood2D = new TH2D("likelihood2D","2D  Likelihood", nBinsOffset,
00219                             offsetMin - 0.5*offsetStep, offsetMax + 0.5*offsetStep,
00220                             nBinsSmearing, smearingMin - 0.5*smearingStep, smearingMax + 0.5*smearingStep);
00221   
00222 
00223   nEvts = data->GetEntries();
00224 
00225   for (double smearing = smearingMin; smearing<=smearingMax+(smearingStep*0.1); smearing+=smearingStep){
00226     //want not only a 2d histogram but a 1d for each smearing point
00227     TString histoName = TString::Format("h1Ds%.0f",smearing*1e10);
00228     std::cout<<"creating histo "<< histoName<<std::endl;
00229     TH1D* h1D = new TH1D(histoName.Data(),histoName.Data(),
00230                          nBinsOffset,
00231                          offsetMin - 0.5*offsetStep,
00232                          offsetMax + 0.5*offsetStep);
00233     hList.push_back(h1D);
00234   }
00235   
00236   for (int i=0; i<nEvts; i++){
00237     if (i%100 == 0) std::cout<<i<<" / "<<nEvts<<std::endl;
00238     data->GetEntry(i);
00239     int smearBin = 0;
00240     for (double smearing = smearingMin; smearing<=smearingMax+(smearingStep*0.1); smearing+=smearingStep){
00241       for (double offset = offsetMin; offset<=offsetMax+(offsetStep*0.1); offset+=offsetStep){
00242       double L = (EventLikelihoodRAF(event, offset, smearing));
00243       likelihood2D->Fill(offset, smearing, -2*log(L));
00244       hList[smearBin]->Fill(offset, -2*log(L));
00245       //      std::cout<<-2*log(L)<<std::endl;
00246       }
00247       smearBin++;
00248     }
00249     delete event; event = 0;
00250   } 
00251 }

void Phase2Fitter::FitMinimum ( TH1D *  h  ) 

Definition at line 494 of file Phase2Fitter.cxx.

References MuELoss::a, Munits::g, and root().

Referenced by SaveFitResults().

00495 {
00496   std::cout<<"Finding minimum for "<<h->GetName()<<std::endl;
00497   //We will have several likelihood minima
00498   //TODO: should fit each one and compare them
00499   double xMin = h->GetBinCenter(h->GetMinimumBin());
00500 
00501   h->SetTitle("");
00502   h->GetXaxis()->SetTitle("Time of flight [s]");
00503   h->GetYaxis()->SetTitle("-2ln(L)");
00504 
00505   //have to play around with the data to get it to fit properly,
00506   //centering it on zero mainly
00507   TGraph* g = new TGraph();
00508   for (int i = 0; i<11; i++){
00509     g->SetPoint(i, 1e9*h->GetBinCenter(h->GetMinimumBin()-5 +i) - (1e9*xMin), h->GetBinContent(h->GetMinimumBin()-5 +i));
00510   }
00511 
00512   TString fitname = h->GetName() + TString("Fit");
00513   TString graphname = TString("g") + h->GetName();
00514 
00515   TF1* fit = new TF1(fitname,"[0]+([1]*x)+([2]*x*x)",-100,100);
00516   fit->SetParameters(622251,-29030.2,359.282);
00517   g->Fit(fit->GetName());
00518   g->SetName(graphname);
00519 
00520   g->Write();
00521   fit->Write();
00522 
00523   //work out best fit and uncertainty
00525   double a = fit->GetParameter(2);
00526   double b = fit->GetParameter(1);
00527   double c = fit->GetParameter(0);
00528 
00529   double bestTOF = -0.5*(b/a);
00530   double lMin = fit->Eval(bestTOF);
00531 
00532   //want value at a*x*x + b*x + c = min + 1
00533   //i.e. a*x*x+ b*x + (c - (min +1));
00534   double cNew = c - (lMin+1);
00535 
00536   double root = (-b + sqrt( (b*b)-(4*a*cNew) )) / (2*a);
00537   double sig = root - bestTOF;
00538 
00539   //dont forget we took off (xMin*1e9) earlier to make the fit work!
00540   printf("best fit tof = %.3f\n", bestTOF + (xMin*1e9));
00541   std::cout<<"1 sigma uncertainty = "<< sig <<std::endl;
00542 }

void Phase2Fitter::LoadCC ( const char *  file  ) 

Definition at line 84 of file Phase2Fitter.cxx.

References data, earliestEvent, latestEvent, and nEvts.

00084                                          {
00085   std::cout<<"Loading  data from "<<file<<std::endl;
00086   
00087   TFile* f = new TFile(file);
00088   std::cout<<"Opened file. Getting tree..."<<std::endl;
00089   data=(TTree*)f->Get("eventTreeCC");
00090   data->SetBranchAddress("eventData",&event);
00091   
00092   nEvts = data->GetEntries();
00093 
00094   data->GetEntry(0); earliestEvent = event->spillTime;
00095   data->GetEntry(nEvts-1); latestEvent = event->spillTime;
00096   
00097   std::cout<<"Read "<<nEvts<<"  events."<<std::endl
00098            <<"First event: " <<earliestEvent<<std::endl
00099            <<"Last event: "  <<latestEvent  <<std::endl;
00100 }

void Phase2Fitter::LoadRAF ( const char *  file  ) 

Definition at line 103 of file Phase2Fitter.cxx.

References data, earliestEvent, latestEvent, and nEvts.

00103                                           {
00104   std::cout<<"Loading  data from "<<file<<std::endl;
00105   
00106   TFile* f = new TFile(file);
00107   std::cout<<"Opened file. Getting tree..."<<std::endl;
00108   data=(TTree*)f->Get("eventTreeRAF");
00109   data->SetBranchAddress("eventData",&event);
00110   
00111   nEvts = data->GetEntries();
00112 
00113   data->GetEntry(0); earliestEvent = event->spillTime;
00114   data->GetEntry(nEvts-1); latestEvent = event->spillTime;
00115   
00116   std::cout<<"Read "<<nEvts<<"  events."<<std::endl
00117            <<"First event: " <<earliestEvent<<std::endl
00118            <<"Last event: "  <<latestEvent  <<std::endl;
00119 }

void Phase2Fitter::LoadRAFdelayFile ( const TString  s  ) 

Definition at line 72 of file Phase2Fitter.cxx.

References MI60pdf::LoadRAFdelayFile(), and pdf.

00073 {
00074   pdf.LoadRAFdelayFile(s);
00075 }

void Phase2Fitter::PrintLikelihoods (  ) 

Definition at line 305 of file Phase2Fitter.cxx.

References data, EventLikelihood(), Plot::Format(), nEvts, offsetMax, offsetMin, offsetStep, and smearingMin.

00306 {
00307   TFile f("likelihoodsCC.root","recreate");
00308   f.cd();
00309   nEvts = data->GetEntries();
00310   double smearing = smearingMin;
00311   int nBinsOffset = ((offsetMax-offsetMin)/offsetStep)+1.45; //rounds to appropriate int
00312 
00313   for (int i=0; i<nEvts; i++){
00314     data->GetEntry(i);
00315 
00316     TH1D* h = new TH1D(TString::Format("h%d",i),"",
00317                        nBinsOffset,
00318                        offsetMin - 0.5*offsetStep,
00319                        offsetMax + 0.5*offsetStep);
00320 
00321     for (double offset = offsetMin; offset<=offsetMax+(offsetStep*0.1); offset+=offsetStep){
00322       double L = (EventLikelihood(event, offset, smearing));
00323       h->Fill(offset,-2*log(L));
00324     }
00325     h->Write();
00326     delete h; h=0;
00327   }
00328   f.Close();
00329 }

void Phase2Fitter::PrintLikelihoodsRAF (  ) 

Definition at line 333 of file Phase2Fitter.cxx.

References data, EventLikelihoodRAF(), Plot::Format(), nEvts, offsetMax, offsetMin, offsetStep, and smearingMin.

00334 {
00335   TFile f("likelihoodsRAF.root","recreate");
00336   f.cd();
00337   nEvts = data->GetEntries();
00338   double smearing = smearingMin;
00339   int nBinsOffset = ((offsetMax-offsetMin)/offsetStep)+1.45; //rounds to appropriate int
00340 
00341   for (int i=0; i<nEvts; i++){
00342     data->GetEntry(i);
00343 
00344     TH1D* h = new TH1D(TString::Format("h%d",i),"",
00345                        nBinsOffset,
00346                        offsetMin - 0.5*offsetStep,
00347                        offsetMax + 0.5*offsetStep);
00348 
00349     for (double offset = offsetMin; offset<=offsetMax+(offsetStep*0.1); offset+=offsetStep){
00350       double L = (EventLikelihoodRAF(event, offset, smearing));
00351       h->Fill(offset,-2*log(L));
00352     }
00353     h->SetLineColor(kRed);
00354     h->Write();
00355     delete h; h=0;
00356   }
00357   f.Close();
00358 }

void Phase2Fitter::SaveFitResults ( const char *  saveFile  ) 

Definition at line 361 of file Phase2Fitter.cxx.

References FitMinimum(), hList, it, likelihood1D, and likelihood2D.

00362 {
00363   std::cout<<"saving fit results"<<std::endl;
00364   TFile f(outfile,"RECREATE");
00365   f.cd();
00366   if (likelihood1D) likelihood1D->Write();
00367   if (likelihood2D) likelihood2D->Write();
00368   for(std::vector<TH1D*>::iterator it = hList.begin(); it != hList.end(); it++){
00369     FitMinimum(*it);
00370     (*it)->Write();
00371   }
00372   f.Close();
00373 }

void Phase2Fitter::SetGridFlag ( bool  trueOrFalse  ) 

Definition at line 78 of file Phase2Fitter.cxx.

References gridFlag.

00079 {
00080   gridFlag = trueOrFalse;
00081 }

void Phase2Fitter::SetMI60dir ( const char *  dir  ) 

Definition at line 65 of file Phase2Fitter.cxx.

References MI60fileLocation, pdf, and MI60pdf::SetMI60dir().

00066 {
00067   MI60fileLocation = dir;
00068   pdf.SetMI60dir(dir);
00069 }


Member Data Documentation

TTree* Phase2Fitter::data [private]
double Phase2Fitter::earliestEvent [private]

Definition at line 60 of file Phase2Fitter.h.

Referenced by LoadCC(), and LoadRAF().

Definition at line 61 of file Phase2Fitter.h.

double Phase2Fitter::endOfMI60data [private]

Definition at line 59 of file Phase2Fitter.h.

Referenced by EventLikelihood(), EventLikelihoodGPS(), and EventLikelihoodRAF().

Definition at line 51 of file Phase2Fitter.h.

bool Phase2Fitter::gridFlag [private]

Definition at line 47 of file Phase2Fitter.h.

Referenced by Phase2Fitter(), and SetGridFlag().

std::vector<TH1D*> Phase2Fitter::hList [private]

Definition at line 65 of file Phase2Fitter.h.

Referenced by Fit2D(), Fit2DGPS(), Fit2DRAF(), SaveFitResults(), and ~Phase2Fitter().

TH1D* Phase2Fitter::hPDF [private]
double Phase2Fitter::lastSmearing [private]
double Phase2Fitter::lastSpillTime [private]
double Phase2Fitter::latestEvent [private]

Definition at line 62 of file Phase2Fitter.h.

Referenced by LoadCC(), and LoadRAF().

double Phase2Fitter::latestEventFD [private]

Definition at line 63 of file Phase2Fitter.h.

TH1D* Phase2Fitter::likelihood1D [private]

Definition at line 67 of file Phase2Fitter.h.

Referenced by Fit1D(), Phase2Fitter(), SaveFitResults(), and ~Phase2Fitter().

TH2D* Phase2Fitter::likelihood2D [private]

Definition at line 68 of file Phase2Fitter.h.

Referenced by Fit2D(), Fit2DGPS(), Fit2DRAF(), Phase2Fitter(), SaveFitResults(), and ~Phase2Fitter().

const char* Phase2Fitter::MI60fileLocation [private]

Definition at line 48 of file Phase2Fitter.h.

Referenced by Phase2Fitter(), and SetMI60dir().

int Phase2Fitter::nEvts [private]

Definition at line 36 of file Phase2Fitter.h.

Referenced by Fit2D(), Fit2DGPS(), Fit2DRAF(), and Phase2Fitter().

Definition at line 37 of file Phase2Fitter.h.

Referenced by Fit2D(), Fit2DGPS(), Fit2DRAF(), and Phase2Fitter().

Definition at line 58 of file Phase2Fitter.h.

Referenced by EventLikelihood(), EventLikelihoodGPS(), and EventLikelihoodRAF().


The documentation for this class was generated from the following files:

Generated on 2 Nov 2017 for loon by  doxygen 1.6.1