//root macro for analysing big piles of reco data for the panda collab-meeting in dec 08 //and overhaul later :) #include "recotasks/TrackFitStat.h" #include "TFile.h" #include "TError.h" #include "TClonesArray.h" #include "TTree.h" #include "TH1D.h" #include "TString.h" #include "TF1.h" #include "TCanvas.h" #include #include #include #include #include void darmstadt_cluster_analysis_tool(int angle) { //create list of valid filenames ----------------------------------------------- int reference[17] = {15,20,25,30,35,40,50,60,70,80,90,100,110,120,130,140,150}; int ang=-1; //i-th angle of reference for (int i=0; i<17; i++) if(reference[i]==angle) { ang=i; std::cout<<"\n\nAngle "< namelist; //TODO: build in EOF check for(int line=0; line<119; line++) { char name[100]; infile.getline(name,100); if(line%17==ang) namelist.push_back(std::string(name)); } int size = namelist.size(); std::cout<<"\n\nDebug info: "< hists; for(int file=0; file74) // //lowBin=0.8; std::string histname = mom.c_str(); histname.append("GeV_"); //gives errors with + operand histname.append(angle_st); histname.append("_deg_"); std::cout<<"\ncreated histogram "<Get("cbmsim"); //TrackFitStat* fitstat = new TrackFitStat(); TClonesArray* fitstatarr = new TClonesArray("TrackFitStat"); TClonesArray* clustarr = new TClonesArray("PndTpcCluster"); int nE=0; if(tree!=0) { tree->SetBranchAddress("TrackFitStat", &fitstatarr); tree->SetBranchAddress("PndTpcCluster", &clustarr); nE = tree->GetEntries(); } std::cout<<"found "<GetEvent(ev); int nArr = fitstatarr->GetEntriesFast(); nClust += clustarr->GetEntriesFast(); //std::cout<<" found "<At(arr))->GetP(); histo->Fill(p); } } inFile->Close(); delete inFile; int entries=0; if(nE>0) entries = histo->GetEntries(); double mean_p, low_p, high_p; double RMS = histo->GetRMS(); if(entries!=0) { int b=histo->GetMaximumBin(); mean_p = b*histo->GetBinWidth(b)+lowBin; low_p = mean_p*0.85; high_p = mean_p*1.15; // // //improved fitting: // // double binWidth = histo->GetBinWidth(1); // // //test // // double max = lowBin + NBins*binWidth; // // if(fabs(max-highBin)>0.001) // // errCount++; // // bool found=false; // // int step = 1; // // int meanBin = (mean_p-lowBin)/binWidth; // // double cutValue=histo->GetMaximum()*0.05; // // int RMSbins = RMS/binWidth; // // while(found==false) { // // double right=histo->GetBinContent(meanBin+step+RMSbins); // // double left=histo->GetBinContent(meanBin-step-RMSbins); // // if(right0) { //automatic fitting char fname[20]; sprintf(fname,"fit%i",file); TF1* fitfunc = new TF1(fname, "gaus", low_p, high_p); fitfunc->SetLineColor(kRed); //fitfunc->SetParameters(mean_p,1); double* params; if (entries!=0) { histo->Fit(fitfunc,"","",low_p,high_p); //histo->DrawClone(); //fitfunc->DrawClone("same"); //histo->Write(); params = fitfunc->GetParameters(); std::cout<<"Fit parameters : "<Write(); }