TEntryList *elist; Bool_t useList, fillList; TH1F *hdmd; TH2F *h2; void h1analysisProxy_Begin(TTree *tree) { // function called before starting the event loop // -it performs some cleanup // -it creates histograms // -it sets some initialisation for the event list //print the option specified in the Process function. TString option = GetOption(); printf("Starting (begin) h1analysis with process option: %s\n",option.Data()); //process cases with event list fillList = kFALSE; useList = kFALSE; if (fChain) fChain->SetEntryList(0); delete gDirectory->GetList()->FindObject("elist"); // case when one creates/fills the event list if (option.Contains("fillList")) { fillList = kTRUE; elist = new TEntryList("elist","H1 selection from Cut"); // Add to the input list for processing in PROOF, if needed if (fInput) { fInput->Add(new TNamed("fillList","")); fInput->Add(elist); } } else elist = 0; // case when one uses the event list generated in a previous call if (option.Contains("useList")) { useList = kTRUE; if (fInput) { tree->SetEntryList(elist); TFile f("elist.root"); elist = (TEntryList*)f.Get("elist"); if (elist) elist->SetDirectory(0); //otherwise the file destructor will delete elist } else { // Option "useList" not supported in PROOF directly Warning("Begin", "option 'useList' not supported in PROOF - ignoring"); Warning("Begin", "the entry list must be set on the chain *before* calling Process"); } } } void h1analysisProxy_SlaveBegin(TTree *tree) { // function called before starting the event loop // -it performs some cleanup // -it creates histograms // -it sets some initialisation for the entry list //initialize the Tree branch addresses Init(tree); //print the option specified in the Process function. TString option = GetOption(); printf("Starting (slave) h1analysis with process option: %s\n",option.Data()); //create histograms hdmd = new TH1F("hdmd","dm_d",40,0.13,0.17); h2 = new TH2F("h2","ptD0 vs dm_d",30,0.135,0.165,30,-3,6); fOutput->Add(hdmd); fOutput->Add(h2); //process cases with entry list fillList = kFALSE; useList = kFALSE; // case when one creates/fills the entry list if (option.Contains("fillList")) { fillList = kTRUE; // Get the list if (fInput) { if ((elist = (TEntryList *) fInput->FindObject("elist"))) // Need to clone to avoid problems when destroying the selector elist = (TEntryList *) elist->Clone(); } if (elist) fOutput->Add(elist); else fillList = kFALSE; } else elist = 0; // case when one uses the entry list generated in a previous call if (option.Contains("useList")) { useList = kTRUE; TFile f("elist.root"); elist = (TEntryList*)f.Get("elist"); if (elist) elist->SetDirectory(0); //otherwise the file destructor will delete elist if (tree) tree->SetEntryList(elist); else { // Option "useList" not supported in PROOF directly Warning("Begin", "option 'useList' not supported in PROOF - ignoring"); Warning("Begin", "the entry list must be set on the chain *before* calling Process"); } } } Double_t h1analysisProxy() { return 0; } Bool_t h1analysisProxy_Process(Long64_t entry) { // entry is the entry number in the current Tree // Selection function to select D* and D0. //in case one entry list is given in input, the selection has already been done. if (!useList) { float f1 = md0_d; float f2 = md0_d-1.8646; bool test = TMath::Abs(md0_d-1.8646) >= 0.04; if (gDebug>0) fprintf(stderr,"entry #%lld f1=%f f2=%f test=%d\n", fChain->GetReadEntry(),f1,f2,test); if (TMath::Abs(md0_d-1.8646) >= 0.04) return kFALSE; if (ptds_d <= 2.5) return kFALSE; if (TMath::Abs(etads_d) >= 1.5) return kFALSE; int cik = ik-1; //original ik used f77 convention starting at 1 int cipi = ipi-1; //original ipi used f77 convention starting at 1 f1 = nhitrp[cik]; f2 = nhitrp[cipi]; test = nhitrp[cik]*nhitrp[cipi] <= 1; if (gDebug>0) fprintf(stderr,"entry #%lld f1=%f f2=%f test=%d\n", fChain->GetReadEntry(),f1,f2,test); if (nhitrp[cik]*nhitrp[cipi] <= 1) return kFALSE; if (rend[cik] -rstart[cik] <= 22) return kFALSE; if (rend[cipi]-rstart[cipi] <= 22) return kFALSE; if (nlhk[cik] <= 0.1) return kFALSE; if (nlhpi[cipi] <= 0.1) return kFALSE; // fix because read-only if (nlhpi[ipis-1] <= 0.1) return kFALSE; if (njets < 1) return kFALSE; } // if option fillList, fill the event list if (fillList) elist->Enter(entry); //fill some histograms hdmd->Fill(dm_d); h2->Fill(dm_d,rpd0_t/0.029979*1.8646/ptd0_d); return kTRUE; } void h1analysisProxy_SlaveTerminate() { // nothing to be done printf("Terminate (slave) h1analysis\n"); } void h1analysisProxy_Terminate() { printf("Terminate (final) h1analysis\n"); // function called at the end of the event loop hdmd = dynamic_cast(fOutput->FindObject("hdmd")); h2 = dynamic_cast(fOutput->FindObject("h2")); if (hdmd == 0 || h2 == 0) { Error("Terminate", "hdmd = %p , h2 = %p", hdmd, h2); return; } //create the canvas for the h1analysis fit gStyle->SetOptFit(); TCanvas *c1 = new TCanvas("c1","h1analysis analysis",10,10,800,600); c1->SetBottomMargin(0.15); hdmd->GetXaxis()->SetTitle("m_{K#pi#pi} - m_{K#pi}[GeV/c^{2}]"); hdmd->GetXaxis()->SetTitleOffset(1.4); //fit histogram hdmd with function f5 using the log-likelihood option TF1 *f5 = new TF1("f5",fdm5,0.139,0.17,5); f5->SetParameters(1000000, .25, 2000, .1454, .001); hdmd->Fit("f5","lr"); //create the canvas for tau d0 gStyle->SetOptFit(0); gStyle->SetOptStat(1100); TCanvas *c2 = new TCanvas("c2","tauD0",100,100,800,600); c2->SetGrid(); c2->SetBottomMargin(0.15); // Project slices of 2-d histogram h2 along X , then fit each slice // with function f2 and make a histogram for each fit parameter // Note that the generated histograms are added to the list of objects // in the current directory. TF1 *f2 = new TF1("f2",fdm2,0.139,0.17,2); f2->SetParameters(10000, 10); h2->FitSlicesX(f2,0,-1,1,"qln"); TH1D *h2_1 = (TH1D*)gDirectory->Get("h2_1"); h2_1->GetXaxis()->SetTitle("#tau[ps]"); h2_1->SetMarkerStyle(21); h2_1->Draw(); c2->Update(); TLine *line = new TLine(0,0,0,c2->GetUymax()); line->Draw(); // Have the number of entries on the first histogram (to cross check when running // with entry lists) TPaveStats *psdmd = (TPaveStats *)hdmd->GetListOfFunctions()->FindObject("stats"); psdmd->SetOptStat(1110); c1->Modified(); //save the entry list to a Root file if one was produced if (fillList) { elist = dynamic_cast(fOutput->FindObject("elist")); if (elist) { TFile efile("elist.root","recreate"); elist->Write(); } else { Error("Terminate", "entry list requested but not found in output"); } } }