#define timewalk2bset10_cxx #include "timewalk2bset10.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using namespace RooFit; //-----------------------------------DECLARING LANDAU FIT---------------------------------------------- double fitlan(double *v,double *par) { double x; x=v[0]; double amp=par[0]; double mpv=par[1]+0.022278298; double sigma=par[2]; double result=amp*TMath::Landau(x,mpv,sigma); return result; } //-------------------------------------------THE LOOP FUNCTION----------------------------------------------- void timewalk2bset10::Loop(Int_t eventnum) { // In a ROOT session, you can do: // Root > .L timewalk2bset10.C // Root > timewalk2bset10 t // Root > t.GetEntry(12); // Fill t data members with entry number 12 // Root > t.Show(); // Show values of entry 12 // Root > t.Show(16); // Read and show values of entry 16 // Root > t.Loop(); // Loop on all entries // // This is the loop skeleton where: // jentry is the global entry number in the chain // ientry is the entry number in the current Tree // Note that the argument to GetEntry must be: // jentry for TChain::GetEntry // ientry for TTree::GetEntry and TBranch::GetEntry // // To read only selected branches, Insert statements like: // METHOD1: // fChain->SetBranchStatus("*",0); // disable all branches // fChain->SetBranchStatus("branchname",1); // activate branchname // METHOD2: replace line // fChain->GetEntry(jentry); //read all branches //by b_branchname->GetEntry(ientry); //read only this branch if (fChain == 0) return; fio2b_set10=new TFile("timewalkcorrections2bset10.root","recreate"); Long64_t nentries = fChain->GetEntriesFast(); Long64_t nbytes = 0, nb = 0; //-------------------------------------------DECLARING THE HISTOGRAM-------------------------------------------- h2b_set10_1=new TH1F("set10_1","hists_set10_1",101,-0.5,100.5); hist_offset_set10=new TF1("offset_set10","pol0",0.5,100.5); f_set10=new TF1("fit_set10",fitlan,0.5,100.5,3); //--------------------------------------------EVENT LOOP-------------------------------------------------------- for (Long64_t jentry=0; jentryGetEntry(jentry); nbytes += nb; if(eventn_iev==eventnum) h2b_set10_1->Fill(eventn_count,eventn_adc1_raw); // if (Cut(ientry) < 0) continue; } cout<<"histograms are filled"<Fit(hist_offset_set10,"","",0.5,100.5); h2b_set10_1->Add(hist_offset_set10,-1); double binamplitude=h2b_set10_1->GetMaximumBin(); double x1=h2b_set10_1->GetXaxis()->GetBinCenter(binamplitude); f_set10->SetParameter(0,binamplitude); f_set10->SetParameter(1,x1-5); f_set10->SetParameter(2,1.0); h2b_set10_1->Fit(f_set10,"","",40.5,70.5); h2b_set10_1->Draw("L*"); fio2b_set10->Write(); }