Int_t read_parms (Int_t j, TString filename, Float_t *yparms, Float_t *yparms_err ) { vector <TString> sdme; vector <double> parms; vector <double> parms_err; TString infile = filename+".fit2"; // file with parameters cout << "Opening parameters file: " << infile.Data() << endl; // now read and print fitted values ifstream parameters; parameters.open (infile.Data()); if (!parameters) { cout << "ERROR: Failed to open data file= " << infile.Data() << endl; return 1; // failed to open data file } TString CanvasName = filename; // cout << "j=" << j << " CanvasName=" << CanvasName << endl; c[j] = new TCanvas(CanvasName,CanvasName,200,10,1000,700); TString line; while (line.ReadLine(parameters)){ TObjArray *tokens = line.Tokenize("\t"); Int_t ntokens = tokens->GetEntries(); // cout << " ntokens=" << ntokens << " line=" << line.Data() << endl; Int_t jmax=ntokens/3; for (Int_t j=0; j<jmax; j++){ sdme.push_back( (((TObjString*)tokens->At(3*j))->GetString()) ); parms.push_back( (((TObjString*)tokens->At(3*j+1))->GetString()).Atof() ); parms_err.push_back( (((TObjString*)tokens->At(3*j+2))->GetString()).Atof()); } } // end loop over lines TString title = filename; TLatex *t1 = new TLatex(0.2,0.85,title); t1->SetNDC(); t1->SetTextSize(0.04); t1->Draw(); for (Int_t j=0; j<sdme.size()-2; j++) { // -2 to eliminate Sigma and P cout << sdme[j] << "=" << parms[j] << " err=" << parms_err[j] << endl; TString sdmename; sdmename = sdme[j]; title.Form("%s = \t%.3f #pm %.3f\n",sdmename.Data(),parms[j],parms_err[j]); // cout << "title=" << title << endl; TLatex *t1 = new TLatex(0.2,0.75 - 0.05*j,title); t1->SetNDC(); t1->SetTextSize(0.04); t1->Draw(); } // cout << " parms.size()=" << parms.size() << endl; for (jj=0; jj<parms.size()-2; jj++) { yparms[jj] = parms[jj]; yparms_err[jj] = parms_err[jj]; } parameters.close(); return 0; }
int convertToInt(const TObjArray& run_ls_event, int idx) { TObjString* entry = dynamic_cast<TObjString*>(run_ls_event.At(idx)); assert(entry); return atoi(entry->GetString().Data()); }
int64_t gr_engine (const char* name, int rx, int ry, int rdx, int rdy) { double x[64000],y[64000],dy[64000],dx[64000], bu; int i,j; FILE * pFile; int MAXLINES=64000; // char mystring[1500];// one line TString oneline, title=name, token; printf("i... gr_engine: going to open filename=%s\n", name ); pFile=fopen( name ,"r" ); if (pFile==NULL) { printf("cannot open %s,STOPping\n", name ); return 0; } // error // printf("file opened\n%s",""); //.......................readout HERE.......i i=0; int lastlen;// remove spaces while ((i<MAXLINES)&&( feof(pFile)==0) ){ // printf(" reading line %d...\n", i ); if ( oneline.Gets (pFile, kTRUE) ){//chop true ... continue if not eof // printf(" string==%s\n", oneline.Data() ); //purify .................. start do { lastlen=oneline.Length(); if (oneline.Index(" ")==0){oneline=oneline(1,oneline.Length()-1);} lastlen=oneline.Length(); if (oneline.Index(" ")==lastlen){oneline=oneline(0,oneline.Length()-1);} oneline.ReplaceAll("\t"," "); oneline.ReplaceAll(" "," "); oneline.ReplaceAll(" "," "); // printf(" --- string==<%s> (%d)\n", oneline.Data(), lastlen ); }while( lastlen!=oneline.Length()); // printf(" string==<%s> (%d)\n", oneline.Data(), lastlen ); //purify .................. stop //printf("S=%s\n", oneline.Data() ); //........ parse oneline if ( (oneline.Index("#")==0) || (oneline.Index("@")==0) || (oneline.Index("END")==0) ){ // starts with # - COMMENT HERE // printf( "COMM:%s\n", oneline.Data() ); if (title.Length()==0){ title=oneline( 1,oneline.Length()-1 );} // title=oneline( oneline.Length(),oneline.Length()-1 ); }else{// DATA HERE TObjArray *tar; if (oneline.Length()>0){ // 1digit also exist... if (oneline.Index("#")>0){oneline.Remove(oneline.Index("#") );}// # if (oneline.Index("@")>0){oneline.Remove(oneline.Index("@") );}// # if (oneline.Index("END")>0){oneline.Remove(oneline.Index("END") );}// # // oneline.ReplaceAll(oneline.Index("\t"),1," "); oneline.ReplaceAll("\t"," "); x[i]=0; y[i] =0;dx[i]=0;dy[i]=0; j=0; // go through the columns // printf( "NotCM:%s\n", oneline.Data() ); /* * r?? contains a column to use for x,dx,y,dy: */ tar= oneline.Tokenize(" "); // printf("entries==%d\n", tar->GetEntries() ); while( (j<=rx && rx>=0) || (j<=ry && ry>=0) || (j<=rdy && rdy>=0)|| (j<=rdx && rdx>=0)){ if (j<tar->GetEntries()){ token= ((TObjString*)(tar->At(j)))->GetString(); // printf(" %3d %3d token <%s>\n", i,j, token.Data() ); bu= token.Atof(); if (i<5){ printf("%3d. token <%s> = %f\n", i, token.Data(), bu ); } if (rx==j) { x[i] =bu;} if (ry==j) { y[i] =bu;} if (rdx==j) { dx[i] =bu;} if (rdy==j) { dy[i] =bu;} }//j<entries j++; }//small while //tar->Delete(); // abandon tar i++;// skip to a next datum if point }// if oneline lenght>1 go thru all //back the loop }//DATAH ERE end // printf("%s","data line ended\n"); }//if oneline.Gets false //........ parse oneline }//while //.......................readout HERE end....i //.......................close, create the TGraphErrors fclose( pFile); // TITLE HERE---------------- // title=name; DONE earlier title.ReplaceAll(".","_"); title.ReplaceAll(" ","_"); printf("i... %d elements read. title= /%s/\n", i-1, title.Data() ); TGraphErrors *g=new TGraphErrors(i,x,y,dx,dy); g->SetMarkerStyle(22); g->SetTitle( title.Data() ); g->SetName( title.Data() ); // g->Print();// DONT PRINT TABLES //========================ADDED 2013: AUTO!push to getlistofspecials (4multigraph) // if the name already exists: TObject *o=gROOT->GetListOfSpecials()->FindObject( g->GetName() ); if (o!=NULL){ printf("x... removing existing object named: /%s/\n", g->GetName() ); gROOT->GetListOfSpecials()->Remove( o ); } gROOT->GetListOfSpecials()->Add( g ); printf("added to GetListOfSpecials: %s \n", g->GetName() ); //========================= return (int64_t)g; //----------------------------------------------------- }// end of the new 201004 version of gr_engine
void analysis(int firstrun, int lastrun){//inclusive // CF252 (neutron) runs: 1040-1158 // Note that the 'skimmed' runs need to exist before this macro will run // To run over all CF252 runs (1040-1158, inclusive): // root // .L analysis.C // analysis(1040, 1158) //For running at dcnode, the input file location needs to be changed //The program creates some relevant histograms and a TTree. The TTree is only relevant if this program is run in parallel for processing a large number of runs. // All of the cuts that are utilized are explained in arXiv:1108.4894 double lightCalib = 9.19; double chargeCalib = 823./4440; double mmperpixel = 166.6/1024; bool useRadial=true; gROOT->SetStyle("Plain"); gStyle->SetPalette(1,0); gSystem->Load("libMaxCam"); gSystem->Load("libWaveformTools.so"); std::stringstream sstm; vector<double> noiseVector; DmtpcSkimDataset d; int totalevents = 0; int passTrack = 0; int passTrig = 0; int passAll = 0; int ntotalTrack = 0; int ntrig=0; int ntotalTrig = 0; int lastSpark = -100; int cutnum=0; int spark, runnum, evnum; double xx, yy, diff, E1, E2, phi; double range_ccd=-1.; double Etrack=-1.; double Etrig=-1.; double TrackX=-1.; double TrackY=-1.; double bestDiff=-1.; double phi=-10.; double r2=-1.; double exposure=0.; double anodeRMS=0.; double meshRMS=0.; TH1D *hist_diff=new TH1D("Charge-light diff","Charge-light diff",50,-300,300); TH1D *hist_energy_ccd=new TH1D("CCD energy","CCD energy",50,10,1000); TH1D *hist_energy_anode=new TH1D("Anode energy","Anode energy",50,10,1000); TH1D *hist_phi=new TH1D("phi","phi",50,-180.,180.); TH2D *hist_pos=new TH2D("pos","pos",128,-512,512,128,-512,512); TH2D *hist_energy=new TH2D("Energy","Energy",50,10,1000,50,0,1000); TH2D *hist_energy_range_ccd=new TH2D("Energy Range CCD","Energy Range CCD",50,10,1000,50,0,20); TH1F* ehist = new TH1F("ehist",";E_{anode} [keVee];N [arb. units]",100,0,1000); TH1F* eh1 = new TH1F("eh1","",50,0,1000); TH1F* effHist = new TH1F("effHist",";E_{anode} [keVee];Efficiency",50,0,1000); TH1F* effHist2 = new TH1F("effHist2",";E_{anode} [keVee];Efficiency",50,0,1000); TFile *histfile=new TFile(Form("outtree_%d_%d.root",firstrun,lastrun), "RECREATE"); tree = new TTree("dctpc", "Event info"); tree->Branch("RunNum", &runnum, "runnum/I"); tree->Branch("EventNum", &evnum, "evnum/I"); tree->Branch("Spark", &spark, "spark/I"); tree->Branch("PassTrack", &passTrack, "passTrack/I"); tree->Branch("PassTrig", &passTrig, "passTrig/I"); tree->Branch("PassAll", &passAll, "passAll/I"); tree->Branch("Ntrig", &ntrig, "ntrig/I"); tree->Branch("Etrack_kev", &Etrack, "Etrack/D"); tree->Branch("Etrig_kev", &Etrig, "Etrig/D"); tree->Branch("deltaE_kev", &bestDiff, "bestDiff/D"); tree->Branch("Phi_deg", &phi, "phi/D"); tree->Branch("TrackX_pix", &TrackX, "TrackX/D"); tree->Branch("TrackY_pix", &TrackY, "TrackY/D"); tree->Branch("Rangeccd_mm", &range_ccd, "range_ccd/D"); tree->Branch("r2_mm2", &r2, "r2/D"); tree->Branch("exposure_s", &exposure, "exposure/D"); tree->Branch("cutnum", &cutnum, "cutnum/I"); tree->Branch("anodeRMS", &anodeRMS, "anodeRMS/D"); tree->Branch("meshRMS", &meshRMS, "meshRMS/D"); for (int x = firstrun; x <= lastrun; x++) { runnum=x; string origfile = "/sps/dchooz/spitzj/DCTPC/data/dmtpc_DC_"; string skimfile = "/sps/dchooz/spitzj/DCTPC/skim/dmtpc_DC_"; string skimend = "skim.root"; string origend = ".root"; string origfilename; string skimfilename; sstm.str(""); if (x<10000){ origfile+="0"; skimfile+="0"; } if (x<1000){ origfile+="0"; skimfile+="0"; } if (x<100){ origfile+="0"; skimfile+="0"; } if (x<10){ origfile+="0"; skimfile+="0"; } sstm << origfile << x << origend; origfilename = sstm.str(); sstm.str(""); sstm << skimfile << x << skimend; skimfilename = sstm.str(); cout << origfilename << endl; ifstream ifile(origfilename.c_str()); if(!ifile) continue; DmtpcSkimDataset d; d.openRootFile(skimfilename.c_str()); d.loadDmtpcEvent(true,origfilename.c_str()); Long_t nEvents=d.tree()->GetEntriesFast(); //start event loop for(int i=0; i<nEvents; i++){ if(i%100==0) cout<<"Event: "<<i<<" / "<<nEvents<<endl; d.getEvent(i); DmtpcSkimEvent* ev=d.event(); evnum=i; Etrack=0.; Etrig=0.; passTrack=0; passTrig=0; cutnum=0; passAll=0; spark=0; exposure=0; ntrig=0; r2=0.; TrackX=0.; TrackY=0.; range_ccd=0.; anodeRMS=0.; meshRMS=0.; if(ev->spark(0)){ lastSpark = ev->eventNumber();spark=1;tree->Fill();continue;} if(ev-lastSpark<6){spark=1;tree->Fill(); continue;} totalevents++; exposure=1; if(ev->ntracks(0)==0){tree->Fill(); continue;} range_ccd=0.; bestDiff=1e9; //loop over tracks in each event for(int k=0;k<ev->ntracks(0);k++) { if (ev->E(0,k)<1) continue; if (ev->nburnin(0,k)) continue; if (ev->edge(0,k)) continue; if (ev->range(0,k)<=0) continue; if (ev->range(0,k)>160) continue; if (ev->maxpixel(0,k)>250) continue; if (ev->x(0,k)<24) continue; if (ev->y(0,k)<24) continue; if (ev->x(0,k)>1000) continue; if (ev->y(0,k)>1000) continue; if (ev->maxpixel(0,k)/ev->E(0,k)>0.25) continue; xx = ev->x(0,k)-512; yy = ev->y(0,k)-512; //if (yy >760-512&&yy<780-512) continue;//what is this? r2 = (xx*xx+yy*yy)* 16.66/1024*16.66/1024; passTrig=0; passTrack++; if(passTrack==1) { E1 = ev->E(0,k)/lightCalib; if (useRadial) E1 *= pow(1+ r2/(16.123*16.123),3.5857/2 ); Etrack = E1; phi = ev->phi(0,k); phi = atan2(sin(phi),cos(phi)) * 180./ 3.1416; TrackX = xx; TrackY = yy; range_ccd=ev->range(0,k)*mmperpixel; eh1->Fill(Etrack); } else continue; TObjArray* arr = ev->waveform_vectors(); FastWfVector* mesh = (FastWfVector*) arr->At(0); CspWfVector* anode = (CspWfVector*) arr->At(1); CspWfVector* veto = (CspWfVector*) arr->At(2); //loop over triggers ntrig=mesh->size(); for (int nt = 0; nt < mesh->size(); nt++){ diff=1e9; anodeRMS=mesh->at(nt).getRMS(); meshRMS=anode->at(nt).getRMS(); if (mesh->at(nt).getRMS() >0.004){cutnum=1; continue;}//for neutron calib run: >0.002 if (anode->at(nt).getRMS()>0.0006){cutnum=2; continue;}//for neutron calib run: >0.003 if (fabs(mesh->at(nt,0).getFastRise0())>0.5){cutnum=3; continue;} if (fabs(mesh->at(nt,0).getFastRise10())>0.5){cutnum=4; continue;} if (fabs(mesh->at(nt,0).getFastRise25())>0.5){cutnum=5; continue;} if (fabs(mesh->at(nt,0).getFastRise50())>0.5){cutnum=6; continue;} if (fabs(mesh->at(nt,0).getFastRise75())>0.5){cutnum=7; continue;} if (fabs(mesh->at(nt,0).getFastRise90())>0.5){cutnum=8; continue;} if (fabs(mesh->at(nt,0).getRise0())>0.5){cutnum=9; continue;} if (fabs(mesh->at(nt,0).getRise10())>0.5){cutnum=10; continue;} if (fabs(mesh->at(nt,0).getRise25())>0.5){cutnum=11; continue;} if (fabs(mesh->at(nt,0).getRise50())>0.5){cutnum=12; continue;} if (fabs(mesh->at(nt,0).getRise75())>0.5){cutnum=13; continue;} if (fabs(mesh->at(nt,0).getRise90())>0.5){cutnum=14; continue;} if (fabs(mesh->at(nt,0).getSlowFall0())>0.5){cutnum=15; continue;} if (fabs(mesh->at(nt,0).getSlowFall10())>0.5){cutnum=16; continue;} if (fabs(mesh->at(nt,0).getSlowFall25())>0.5){cutnum=17; continue;} if (fabs(mesh->at(nt,0).getSlowFall50())>0.5){cutnum=18; continue;} if (fabs(mesh->at(nt,0).getSlowFall75())>0.5){cutnum=19; continue;} if (fabs(mesh->at(nt,0).getSlowFall90())>0.5){cutnum=20; continue;} if (fabs(mesh->at(nt,0).getFall0())>0.5){cutnum=21; continue;} if (fabs(mesh->at(nt,0).getFall10())>0.5){cutnum=22; continue;} if (fabs(mesh->at(nt,0).getFall25())>0.5){cutnum=23; continue;} if (fabs(mesh->at(nt,0).getFall50())>0.5){cutnum=24; continue;} if (fabs(mesh->at(nt,0).getFall75())>0.5){cutnum=25; continue;} if (fabs(mesh->at(nt,0).getFall90())>0.5){cutnum=26; continue;} if (mesh->at(nt).getWfMax() >0.39 || mesh->at(nt).getWfMin() < -0.39){cutnum=27; continue;} if (anode->at(nt).getWfMax() >0.195 || anode->at(nt).getWfMin() < -0.195){cutnum=28; continue;} if (veto->at(nt).getWfMax() >0.195 || veto->at(nt).getWfMin() < -0.195){cutnum=29; continue;} if (mesh->at(nt,0).getIntegral()<0.5){cutnum=30; continue;} if (anode->at(nt,0).getPeak()<0.01){cutnum=31; continue;} if (anode->at(nt,0).getPeak() < 3 * veto->at(nt,0).getPeak()){cutnum=32; continue;} if (veto->at(nt,0).getRise10() - veto->at(nt,0).getRise90()>800e-9){cutnum=33; continue;} if (mesh->at(nt,0).getPeak() > 3 * anode->at(nt,0).getPeak()){cutnum=34;continue;} if (mesh->at(nt,0).getPeak() < 1.3 * anode->at(nt,0).getPeak()){cutnum=35; continue;} if (anode->at(nt,0).getRise10() - anode->at(nt,0).getRise90()>1.25e-6){cutnum=36; continue;} passTrig++; E2 = (anode->at(nt,0).getPeak()*1000)/chargeCalib; diff = E1 - fitPoly12Percent(E2); if (fabs(diff)<fabs(bestDiff)) { bestDiff = diff; Etrig = E2; } } // end trigger loop }//end track loop ntotalTrig+=passTrig; ntotalTrack+=passTrack; if (passTrack!=1){tree->Fill(); continue;} if (passTrig==0){tree->Fill(); continue;} if (Etrig < 250 && bestDiff > 75){cutnum=37;tree->Fill(); continue;} if (Etrig>=250&&Etrig<500&& bestDiff>125){cutnum=38;tree->Fill(); continue;} if (Etrig>=500&& bestDiff>150){cutnum=39;tree->Fill(); continue;} passAll=1; effHist->Fill(Etrack); if(Etrack>0 && Etrig>0) { //cout<<i<<" Energies: "<<Etrack<<" "<<Etrig<<" "<<phi<<endl; hist_energy->Fill(Etrack,Etrig); hist_energy_anode->Fill(Etrig); hist_energy_ccd->Fill(Etrack); hist_diff->Fill(bestDiff); hist_energy_range_ccd->Fill(Etrack,range_ccd); hist_phi->Fill(phi); hist_pos->Fill(TrackX,TrackY); } tree->Fill(); }//end event loop }//end file loop for (int i = 1; i<=effHist->GetNbinsX(); i++) { double n1 = eh1->GetBinContent(i); double n2 = effHist->GetBinContent(i); if (!n1) continue; effHist2->SetBinContent(i,n2/n1); effHist2->SetBinError(i,sqrt(n2/n1 * (1-n2/n1)/n1)); } cout <<"Total seconds of exposure: "<<totalevents<<endl; new TCanvas; hist_energy->SetTitle("CCD Energy vs. Anode Energy"); hist_energy->SetXTitle("E_{CCD} (keV)"); hist_energy->SetYTitle("E_{anode} (keV)"); hist_energy->Draw("COLZ"); new TCanvas; hist_energy_range_ccd->SetTitle("Range vs. CCD Energy"); hist_energy_range_ccd->SetXTitle("E_{CCD} (keV)"); hist_energy_range_ccd->SetYTitle("2D range (mm)"); hist_energy_range_ccd->Draw("COLZ"); new TCanvas; hist_energy_anode->Draw(); hist_energy_anode->SetTitle("Anode Energy"); hist_energy_anode->SetXTitle("E_{anode} (keV)"); new TCanvas; hist_energy_ccd->Draw(); hist_energy_ccd->SetTitle("CCD Energy"); hist_energy_ccd->SetXTitle("E_{CCD} (keV)"); new TCanvas; hist_diff->Draw(); hist_diff->SetTitle("CCD and Anode #Delta_{energy}"); hist_diff->SetXTitle("E_{CCD} - E_{anode} (keV)"); hist_diff->Fit("gaus"); new TCanvas; hist_phi->Draw(); hist_phi->SetTitle("Track angle"); hist_phi->SetXTitle("#phi (degrees)"); new TCanvas; hist_pos->Draw("colz"); hist_pos->SetTitle("Track position"); hist_pos->SetXTitle("X (pixels)"); hist_pos->SetYTitle("Y (pixels)"); new TCanvas; effHist2->Draw("e1"); // hist_energy->Write(); // hist_energy_range_ccd->Write(); // hist_energy_anode->Write(); // hist_energy_ccd->Write(); // hist_diff->Write(); // hist_phi->Write(); // hist_pos->Write(); // effHist->Write(); // eh1->Write(); histfile = tree->GetCurrentFile(); histfile->Write(); histfile->Close(); //gApplication->Terminate(); }
void ContourList(){ const Double_t PI = TMath::Pi(); TCanvas* c = new TCanvas("c","Contour List",0,0,600,600); c->SetRightMargin(0.15); c->SetTopMargin(0.15); Int_t i, j, TotalConts; Int_t nZsamples = 80; Int_t nPhiSamples = 80; Double_t HofZwavelength = 4.0; // 4 meters Double_t dZ = HofZwavelength/(Double_t)(nZsamples - 1); Double_t dPhi = 2*PI/(Double_t)(nPhiSamples - 1); TArrayD z(nZsamples); TArrayD HofZ(nZsamples); TArrayD phi(nPhiSamples); TArrayD FofPhi(nPhiSamples); // Discretized Z and Phi Values for ( i = 0; i < nZsamples; i++) { z[i] = (i)*dZ - HofZwavelength/2.0; HofZ[i] = SawTooth(z[i], HofZwavelength); } for(Int_t i=0; i < nPhiSamples; i++){ phi[i] = (i)*dPhi; FofPhi[i] = sin(phi[i]); } // Create Histogram TH2D *HistStreamFn = new TH2D("HstreamFn", "#splitline{Histogram with negative and positive contents. Six contours are defined.}{It is plotted with options CONT LIST to retrieve the contours points in TGraphs}", nZsamples, z[0], z[nZsamples-1], nPhiSamples, phi[0], phi[nPhiSamples-1]); // Load Histogram Data for (Int_t i = 0; i < nZsamples; i++) { for(Int_t j = 0; j < nPhiSamples; j++){ HistStreamFn->SetBinContent(i,j, HofZ[i]*FofPhi[j]); } } gStyle->SetPalette(1); gStyle->SetOptStat(0); gStyle->SetTitleW(0.99); gStyle->SetTitleH(0.08); Double_t contours[6]; contours[0] = -0.7; contours[1] = -0.5; contours[2] = -0.1; contours[3] = 0.1; contours[4] = 0.4; contours[5] = 0.8; HistStreamFn->SetContour(6, contours); // Draw contours as filled regions, and Save points HistStreamFn->Draw("CONT Z LIST"); c->Update(); // Needed to force the plotting and retrieve the contours in TGraphs // Get Contours TObjArray *conts = (TObjArray*)gROOT->GetListOfSpecials()->FindObject("contours"); TList* contLevel = NULL; TGraph* curv = NULL; Int_t nGraphs = 0; Int_t TotalConts = 0; if (conts == NULL){ printf("*** No Contours Were Extracted!\n"); TotalConts = 0; return; } else { TotalConts = conts->GetSize(); } printf("TotalConts = %d\n", TotalConts); for(i = 0; i < TotalConts; i++){ contLevel = (TList*)conts->At(i); printf("Contour %d has %d Graphs\n", i, contLevel->GetSize()); nGraphs += contLevel->GetSize(); } nGraphs = 0; TCanvas* c1 = new TCanvas("c1","Contour List",610,0,600,600); c1->SetTopMargin(0.15); TH2F *hr = new TH2F("hr", "#splitline{Negative contours are returned first (highest to lowest). Positive contours are returned from}{lowest to highest. On this plot Negative contours are drawn in red and positive contours in blue.}", 2, -2, 2, 2, 0, 6.5); hr->Draw(); Double_t x0, y0, z0; TLatex l; l.SetTextSize(0.03); char val[20]; for(i = 0; i < TotalConts; i++){ contLevel = (TList*)conts->At(i); if (i<3) z0 = contours[2-i]; else z0 = contours[i]; printf("Z-Level Passed in as: Z = %f\n", z0); // Get first graph from list on curves on this level curv = (TGraph*)contLevel->First(); for(j = 0; j < contLevel->GetSize(); j++){ curv->GetPoint(0, x0, y0); if (z0<0) curv->SetLineColor(kRed); if (z0>0) curv->SetLineColor(kBlue); nGraphs ++; printf("\tGraph: %d -- %d Elements\n", nGraphs,curv->GetN()); curv->Draw("C"); sprintf(val,"%g",z0); l.DrawLatex(x0,y0,val); curv = (TGraph*)contLevel->After(curv); // Get Next graph } } c1->Update(); printf("\n\n\tExtracted %d Contours and %d Graphs \n", TotalConts, nGraphs ); }
void fitter( const string workDirName="Test", // Working directory // Select the type of datasets to fit bool fitData = true, // Fits Data if true, otherwise fits MC bool fitPbPb = true, // Fits PbPb datasets bool fitPP = true, // Fits PP datasets // Select the type of object to fit bool incJpsi = true, // Includes Jpsi model bool incPsi2S = true, // Includes Psi(2S) model bool incBkg = true, // Includes Background model // Select the fitting options bool cutCtau = false, // Apply prompt ctau cuts bool doSimulFit = false, // Do simultaneous fit bool wantPureSMC = false, // Flag to indicate if we want to fit pure signal MC int numCores = 2, // Number of cores used for fitting // Select the drawing options bool setLogScale = true, // Draw plot with log scale bool incSS = false, // Include Same Sign data bool zoomPsi = false, // Zoom Psi(2S) peak on extra pad int nBins = 54 // Number of bins used for plotting ) { // ------------------------------------------------------------------------------- // STEP 0: INITIALIZE THE FITTER WORK ENVIROMENT // The work enviroment is divided as follows: /* main |-> Macros: Contain all the macros |-> Input |-> <WorkDir> : Contain Input File, Bin and Parameter List for a given work directory (e.g. 20160201) |-> Output |-> <WorkDir> : Contain Output Plots and Results for a given work directory (e.g. 20160201) |-> DataSet : Contain all the datasets (MC and Data) */ if (!checkSettings(fitData, fitPbPb, fitPP, incJpsi, incPsi2S, incBkg, cutCtau, doSimulFit, wantPureSMC, setLogScale, zoomPsi, incSS, numCores, nBins)) { return; } map<string,string> DIR; if(!iniWorkEnv(DIR, workDirName)){ return; } // ------------------------------------------------------------------------------- // STEP 1: CREATE/LOAD THE ROODATASETS /* Input : List of TTrees with format: TAG <tab> FILE_NAME Output: Collection of RooDataSets splitted by tag name, including OS and SS dimuons. */ const string InputTrees = DIR["input"] + "InputTrees.txt"; map<string, vector<string> > InputFileCollection; if(!getInputFileNames(InputTrees, InputFileCollection)){ return; } TObjArray* aDSTAG = new TObjArray(); // Array to store the different tags in the list of trees aDSTAG->SetOwner(true); map<string, RooWorkspace> Workspace; for(map<string, vector<string> >::iterator FileCollection=InputFileCollection.begin(); FileCollection!=InputFileCollection.end(); ++FileCollection) { // Get the file tag which has the following format: DSTAG_COLL , i.e. DATA_PP string FILETAG = FileCollection->first; string DSTAG = FILETAG; if (FILETAG.size()) { DSTAG.erase(DSTAG.find("_")); } else { cout << "[ERROR] FILETAG is empty!" << endl; } // Extract the filenames vector<string> InputFileNames = FileCollection->second; string OutputFileName; // If we have data, check if the user wants to fit data if ( (FILETAG.find("DATA")!=std::string::npos) && fitData==true ) { if ( (FILETAG.find("PP")!=std::string::npos) && !fitPP ) continue; // If we find PP, check if the user wants PP if ( (FILETAG.find("PbPb")!=std::string::npos) && !fitPbPb ) continue; // If we find PbPb, check if the user wants PbPb OutputFileName = DIR["dataset"] + "DATASET_" + FILETAG + ".root"; if(!tree2DataSet(Workspace[DSTAG], InputFileNames, FILETAG, OutputFileName)){ return; } if (!aDSTAG->FindObject(DSTAG.c_str())) aDSTAG->Add(new TObjString(DSTAG.c_str())); } // If we find MC, check if the user wants to fit MC if ( (FILETAG.find("MC")!=std::string::npos) && fitData==false ) { if ( (FILETAG.find("PP")!=std::string::npos) && !fitPP ) continue; // If we find PP, check if the user wants PP if ( (FILETAG.find("PbPb")!=std::string::npos) && !fitPbPb ) continue; // If we find PbPb, check if the user wants PbPb if ( (FILETAG.find("JPSI")!=std::string::npos) && !incJpsi ) continue; // If we find Jpsi MC, check if the user wants to include Jpsi if ( (FILETAG.find("PSI2S")!=std::string::npos) && !incPsi2S ) continue; // If we find Psi2S MC, check if the user wants to include Psi2S OutputFileName = DIR["dataset"] + "DATASET_" + FILETAG + ".root"; if(!tree2DataSet(Workspace[DSTAG], InputFileNames, FILETAG, OutputFileName)){ return; } if (!aDSTAG->FindObject(DSTAG.c_str())) aDSTAG->Add(new TObjString(DSTAG.c_str())); if (wantPureSMC) { OutputFileName = DIR["dataset"] + "DATASET_" + FILETAG + "_PureS" + ".root"; if(!tree2DataSet(Workspace[Form("%s_PureS",DSTAG.c_str())], InputFileNames, FILETAG, OutputFileName)){ return; } } } } if (Workspace.size()==0) { cout << "[ERROR] No onia tree files were found matching the user's input settings!" << endl; return; } // ------------------------------------------------------------------------------- // STEP 2: LOAD THE INITIAL PARAMETERS /* Input : List of initial parameters with format PT <tab> RAP <tab> CEN <tab> iniPar ... Output: two vectors with one entry per kinematic bin filled with the cuts and initial parameters */ string InputFile; vector< struct KinCuts > cutVector; vector< map<string, string> > parIniVector; if (fitPbPb && incBkg) { // Add initial parameters for PbPb background models InputFile = (DIR["input"] + "InitialParam_MASS_BKG_PbPb.csv"); if (!addParameters(InputFile, cutVector, parIniVector, true)) { return; } } if (fitPbPb && incJpsi) { // Add initial parameters for PbPb jpsi models InputFile = (DIR["input"] + "InitialParam_MASS_JPSI_PbPb.csv"); if (!addParameters(InputFile, cutVector, parIniVector, true)) { return; } } if (fitPbPb && incPsi2S) { // Add initial parameters for PbPb psi(2S) models InputFile = (DIR["input"] + "InitialParam_MASS_PSI2S_PbPb.csv"); if (!addParameters(InputFile, cutVector, parIniVector, true)) { return; } } if (fitPP && incBkg) { // Add initial parameters for PP background models InputFile = (DIR["input"] + "InitialParam_MASS_BKG_PP.csv"); if (!addParameters(InputFile, cutVector, parIniVector, false)) { return; } } if (fitPP && incJpsi) { // Add initial parameters for PP jpsi models InputFile = (DIR["input"] + "InitialParam_MASS_JPSI_PP.csv"); if (!addParameters(InputFile, cutVector, parIniVector, false)) { return; } } if (fitPP && incPsi2S) { // Add initial parameters for PP psi(2S) models InputFile = (DIR["input"] + "InitialParam_MASS_PSI2S_PP.csv"); if (!addParameters(InputFile, cutVector, parIniVector, false)) { return; } } // ------------------------------------------------------------------------------- // STEP 3: FIT THE DATASETS /* Input : -> The cuts and initial parameters per kinematic bin -> The workspace with the full datasets included. Output: -> Plots (png, pdf and root format) of each fit. -> The local workspace used for each fit. */ TIter nextDSTAG(aDSTAG); string outputDir = DIR["output"]; for (unsigned int i=0; i<cutVector.size(); i++) { nextDSTAG.Reset(); TObjString* soDSTAG(0x0); while ( (soDSTAG = static_cast<TObjString*>(nextDSTAG.Next())) ) { TString DSTAG = static_cast<TString>(soDSTAG->GetString()); if (Workspace.count(DSTAG.Data())>0) { // DATA/MC datasets were loaded if (doSimulFit) { // If do simultaneous fits, then just fits once if (!fitCharmonia( Workspace[DSTAG.Data()], cutVector.at(i), parIniVector.at(i), outputDir, // Select the type of datasets to fit DSTAG.Data(), false, // dummy flag when fitting simultaneously since both PP and PbPb are used // Select the type of object to fit incJpsi, // Includes Jpsi model incPsi2S, // Includes Psi(2S) model incBkg, // Includes Background model // Select the fitting options cutCtau, // Apply prompt ctau cuts true, // Do simultaneous fit wantPureSMC, // Flag to indicate if we want to fit pure signal MC numCores, // Number of cores used for fitting // Select the drawing options setLogScale, // Draw plot with log scale incSS, // Include Same Sign data zoomPsi, // Zoom Psi(2S) peak on extra pad nBins, // Number of bins used for plotting false // Compute the mean PT (NEED TO FIX) ) ) { return; } } else { // If don't want simultaneous fits, then fit PbPb or PP separately if ( DSTAG.Contains("MCJPSI") ) { incJpsi = true; incPsi2S = false; } if ( DSTAG.Contains("MCPSI2S") ) { incJpsi = false; incPsi2S = true; } if (fitPbPb) { if (!fitCharmonia( Workspace[DSTAG.Data()], cutVector.at(i), parIniVector.at(i), outputDir, // Select the type of datasets to fit DSTAG.Data(), true, // In this case we are fitting PbPb // Select the type of object to fit incJpsi, // Includes Jpsi model incPsi2S, // Includes Psi(2S) model incBkg, // Includes Background model // Select the fitting options cutCtau, // Apply prompt ctau cuts false, // Do simultaneous fit false, // Flag to indicate if we want to fit pure signal MC numCores, // Number of cores used for fitting // Select the drawing options setLogScale, // Draw plot with log scale incSS, // Include Same Sign data zoomPsi, // Zoom Psi(2S) peak on extra pad nBins, // Number of bins used for plotting false // Compute the mean PT (NEED TO FIX) ) ) { return; } if (DSTAG.Contains("MC") && wantPureSMC) { if (!fitCharmonia( Workspace[Form("%s_PureS",DSTAG.Data())], cutVector.at(i), parIniVector.at(i), outputDir, // Select the type of datasets to fit DSTAG.Data(), true, // In this case we are fitting PbPb // Select the type of object to fit incJpsi, // Includes Jpsi model incPsi2S, // Includes Psi(2S) model incBkg, // Includes Background model // Select the fitting options cutCtau, // Apply prompt ctau cuts false, // Do simultaneous fit true, // Flag to indicate if we want to fit pure signal MC numCores, // Number of cores used for fitting // Select the drawing options setLogScale, // Draw plot with log scale incSS, // Include Same Sign data zoomPsi, // Zoom Psi(2S) peak on extra pad nBins, // Number of bins used for plotting false // Compute the mean PT (NEED TO FIX) ) ) { return; } } } if (fitPP) { if (!fitCharmonia( Workspace[DSTAG.Data()], cutVector.at(i), parIniVector.at(i), outputDir, // Select the type of datasets to fit DSTAG.Data(), false, // In this case we are fitting PP // Select the type of object to fit incJpsi, // Includes Jpsi model incPsi2S, // Includes Psi(2S) model incBkg, // Includes Background model // Select the fitting options cutCtau, // Apply prompt ctau cuts false, // Do simultaneous fit false, // Flag to indicate if we want to fit pure signal MC numCores, // Number of cores used for fitting // Select the drawing options setLogScale, // Draw plot with log scale incSS, // Include Same Sign data zoomPsi, // Zoom Psi(2S) peak on extra pad nBins, // Number of bins used for plotting false // Compute the mean PT (NEED TO FIX) ) ) { return; } if (DSTAG.Contains("MC") && wantPureSMC) { if (!fitCharmonia( Workspace[Form("%s_PureS",DSTAG.Data())], cutVector.at(i), parIniVector.at(i), outputDir, // Select the type of datasets to fit DSTAG.Data(), false, // In this case we are fitting PP // Select the type of object to fit incJpsi, // Includes Jpsi model incPsi2S, // Includes Psi(2S) model incBkg, // Includes Background model // Select the fitting options cutCtau, // Apply prompt ctau cuts false, // Do simultaneous fit true, // Flag to indicate if we want to fit pure signal MC numCores, // Number of cores used for fitting // Select the drawing options setLogScale, // Draw plot with log scale incSS, // Include Same Sign data zoomPsi, // Zoom Psi(2S) peak on extra pad nBins, // Number of bins used for plotting false // Compute the mean PT (NEED TO FIX) ) ) { return; } } } } } else { cout << "[ERROR] The workspace for " << DSTAG.Data() << " was not found!" << endl; return; } } } delete aDSTAG; };
//_____________________________ void muIDCutsOptim::Loop() { // In a ROOT session, you can do: // root> .L muIDCutsOptim.C // root> muIDCutsOptim 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 // if (fChain == 0) return; //===== Definition of file type, particle and if we want the high purity cut included in the soft muon ID cuts const char* fileType = "MC"; const char* particle = "JPsi"; fIspp = kFALSE; fIncludeHighPurity = kFALSE; //===== Long64_t nentries(0); if ( !strcmp(fileType,"MC") ) nentries = fChain->GetEntries(); else nentries = 1500000; std::cout << "# Events = " << nentries << std::endl; //===== Definition of some cuts Double_t leMinvSig = 3.0; // Signal range Double_t ueMinvSig = 3.2; Double_t leMinvBkg1 = 2.7; // Bkg 1 range (sideband) Double_t ueMinvBkg1 = 2.9; Double_t leMinvBkg2 = 3.3; // Bkg 1 range (sideband) Double_t ueMinvBkg2 = 3.5; Double_t Ptmin = 3.0; // Pt cut (6.5) (3.0) Double_t Ptmax = 6.5; // (12.0) (6.5) Double_t Ymin = 2.0; // Y cut (0.0) (2.0) Double_t Ymax = 2.4; // (2.4) (2.4) //===== //===== Definition of MuID variables and binning const int nvar = 19; const char* varname[19] = {"isGoodMuon", "highPurity", "TrkMuArb", "TMOneStaTight", "nPixValHits", "nMuValHits", "nTrkHits", "normChi2_inner", "normChi2_global", "nPixWMea", "nTrkWMea", "StationsMatched", "dxy", "dxyErr", "dz", "dzErr", "ptErr_inner", "ptErr_global","VtxProb"}; const int nbins[19] = {2, 2, 2, 2, 11, 56, 36, 100, 100, 6, 19, 7, 100, 100, 100, 100, 100, 100, 200}; const double lowedge[19] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; const double hiedge[19] = {2, 2, 2, 2, 11, 56, 36, 10, 50, 6, 19, 7, 2, 0.25, 20, 5, 0.15, 0.15, 1.}; //===== SelectBranches(nvar,varname); // Activates only desired branches (General and MuID ones in this case) //====== Create histograms and arrays to store them ======== TObjArray* aDistr = new TObjArray(); TObjArray* aSig = new TObjArray(); TObjArray* aBkg = new TObjArray(); TObjArray* aSigC = new TObjArray(); TObjArray* aBkgC = new TObjArray(); TObjArray* aGlob = new TObjArray(); TObjArray* aMinvCuts = new TObjArray(); TObjArray* aSigSoftMuCutsButOne = new TObjArray(); TObjArray* aBkgSoftMuCutsButOne = new TObjArray(); TObjArray* aSigSoftMuCuts = new TObjArray(); TObjArray* aBkgSoftMuCuts = new TObjArray(); map<TString, TH1F*> hists_sig, hists_bkg, hists_sig_distr, hists_bkg_distr, hists_distr, hists_sig_distr_CutTest, hists_bkg_distr_CutTest, hists_sig_SofMu, hists_bkg_SofMu; TString sHPName(""); if ( fIncludeHighPurity ) sHPName += "highPurity"; // This is for the histograms creation TObjArray* dummyA(0x0); TString partType(""); for (int i=0; i<nvar; i++) { // Single cuts histos hists_sig[Form("%s",varname[i])] = new TH1F(Form("h%s_sig",varname[i]),Form("Signal di-#mu %s cut distribution",varname[i]),nbins[i],lowedge[i],hiedge[i]); hists_bkg[Form("%s",varname[i])] = new TH1F(Form("h%s_bkg",varname[i]),Form("Background di-#mu %s cut distribution",varname[i]),nbins[i],lowedge[i],hiedge[i]); // Variable distributions histos hists_sig_distr[Form("%s",varname[i])] = new TH1F(Form("h%s_sig_distr",varname[i]),Form("Signal single-#mu %s distribution",varname[i]),nbins[i],lowedge[i],hiedge[i]); hists_bkg_distr[Form("%s",varname[i])] = new TH1F(Form("h%s_bkg_distr",varname[i]),Form("Background single-#mu %s distribution",varname[i]),nbins[i],lowedge[i],hiedge[i]); partType.Clear(); if ( !strcmp(varname[i],"VtxProb") ) partType += "di-#mu"; else partType += "di-#mu"; hists_distr[Form("%s",varname[i])] = new TH1F(Form("h%s_distr",varname[i]),Form("Sig+Bkg %s %s distribution",partType.Data(),varname[i]),nbins[i],lowedge[i],hiedge[i]); dummyA = new TObjArray(); dummyA->SetName(Form("mInv_%s",varname[i])); aMinvCuts->Add(dummyA); if ( !strcmp(varname[i],"isGoodMuon") || !strcmp(varname[i],sHPName.Data()) || !strcmp(varname[i],"nPixWMea") || !strcmp(varname[i],"nTrkWMea") || !strcmp(varname[i],"dxy") || !strcmp(varname[i],"dz") ) { // Histos for all the soft muon cuts applied but the one on the histo hists_sig_distr_CutTest[Form("%s",varname[i])] = new TH1F(Form("hSoftMuNoCut_%s_sig",varname[i]),Form("Signal single-#mu %s distribution (w/ rest of soft MuID cuts)",varname[i]),nbins[i],lowedge[i],hiedge[i]); hists_bkg_distr_CutTest[Form("%s",varname[i])] = new TH1F(Form("hSoftMuNoCut_%s_bkg",varname[i]),Form("Background single-#mu %s distribution (w/ rest of soft MuID cuts)",varname[i]),nbins[i],lowedge[i],hiedge[i]); hists_sig_SofMu[Form("%s",varname[i])] = new TH1F(Form("hSoftMuCut_%s_sig",varname[i]),Form("Signal di-#mu %s cut distribution (w/ all Soft MuID cuts except %s)",varname[i],varname[i]),nbins[i],lowedge[i],hiedge[i]); hists_bkg_SofMu[Form("%s",varname[i])] = new TH1F(Form("hSoftMuCut_%s_bkg",varname[i]),Form("Background di-#mu %s cut distribution (w/ all Soft MuID cuts except %s)",varname[i],varname[i]),nbins[i],lowedge[i],hiedge[i]); } else { // Histos for all the soft muon cuts applied hists_sig_distr_CutTest[Form("%s",varname[i])] = new TH1F(Form("hSoftMuFull_%s_sig",varname[i]),Form("Signal %s %s distribution (w/ all Soft MuID cuts)",partType.Data(),varname[i]),nbins[i],lowedge[i],hiedge[i]); hists_bkg_distr_CutTest[Form("%s",varname[i])] = new TH1F(Form("hSoftMuFull_%s_bkg",varname[i]),Form("Signal %s %s distribution (w/ all Soft MuID cuts)",partType.Data(),varname[i]),nbins[i],lowedge[i],hiedge[i]); hists_sig_SofMu[Form("%s",varname[i])] = new TH1F(Form("hSoftMuCut_%s_sig",varname[i]),Form("Signal di-#mu %s cut distribution (w/ all Soft MuID cuts)",varname[i]),nbins[i],lowedge[i],hiedge[i]); hists_bkg_SofMu[Form("%s",varname[i])] = new TH1F(Form("hSoftMuCut_%s_bkg",varname[i]),Form("Background di-#mu %s cut distribution (w/ all Soft MuID cuts)",varname[i]),nbins[i],lowedge[i],hiedge[i]); } } // Histos for global distributions TH1* hpt = new TH1D("hPtSig",Form("Dimuon p_{T} distribution (%2.1f < m_{#mu^{+}#mu^{-}} < %2.1f)",leMinvSig,ueMinvSig),300,0.0,15.0); TH1* hptw = new TH1D("hPtSigW",Form("Dimuon p_{T} distribution weighted (%2.1f < m_{#mu^{+}#mu^{-}} < %2.1f)",leMinvSig,ueMinvSig),300,0.0,15.0); TH1* hMinvw = new TH1D("hmInv","Dimuon m_{inv} distribution",600,0.,15.0); TH1* hRapw = new TH1D("hRap","Dimuon rapidity distribution",180,-4.5,4.5); TH1* hPtw = new TH1D("hPt","Dimuon p_{T} distribution",300,0.0,15.0); TH1* hCent = new TH1D("hCent","Centrality distribution",200,0.,100); TH1* hCentw = new TH1D("hCentw","Weighted centrality distribution",200,0.,100); //====================== TLorentzVector *tlvmupl(0x0); TLorentzVector *tlvmumi(0x0); TLorentzVector *tlvqq(0x0); Long64_t nbytes = 0, nb = 0; //*************** Event loop for (Long64_t jentry=0; jentry<nentries;jentry++) { Long64_t ientry = LoadTree(jentry); if (ientry < 0) break; nb = fChain->GetEntry(jentry); nbytes += nb; if ( jentry % 1000 == 0 ) std::cout << jentry << "/" << nentries << std::endl; Double_t weight = fChain->GetWeight()*GetNColl(Centrality); // This is the weight for the Pt and centrality. The weight stored in the chain is filterEficiency/nentries //Fill centrality histo hCentw->Fill(Centrality/2.,weight); hCent->Fill(Centrality/2.); //*************** Loop on reco dimuons // for (int i=0; i<Reco_QQ_size; i++) // { Int_t i(0); Bool_t kQQfound(kFALSE); while ( i < Reco_QQ_size && !kQQfound ) // This is just to take only the first dimuon passing the basic conditions, to not double count single muons { if ( !isTriggerSelected(i) || Reco_QQ_sign[i]!=0 ) { i++; continue; // Checks if the event is selected by the trigger } // if (Reco_QQ_sign[i]!=0) continue; tlvmupl = (TLorentzVector*) Reco_QQ_mupl_4mom->At(i); tlvmumi = (TLorentzVector*) Reco_QQ_mumi_4mom->At(i); if (!IsAccept(tlvmupl->Pt(), tlvmupl->Eta()) || !IsAccept(tlvmumi->Pt(), tlvmumi->Eta())) { i++; continue; // Basic single muon kinematic cuts } tlvqq = (TLorentzVector*) Reco_QQ_4mom->At(i); Double_t mass = tlvqq->M(); Double_t QQPt = tlvqq->Pt(); Double_t QQY = TMath::Abs(tlvqq->Rapidity()); if ( QQPt < Ptmin || QQPt > Ptmax || QQY < Ymin || QQY > Ymax ) { i++; continue; // The simulation is restricted to pt in [Ptmin,Ptmax], so this rejects background dmuons outside the range } bool issig = (mass>leMinvSig && mass<ueMinvSig); bool isbkg = ((mass>leMinvBkg1 && mass<ueMinvBkg1) || (mass>leMinvBkg2 && mass<ueMinvBkg2)); if ( !issig && ! isbkg ) { i++; continue; // We keep only dimuons in the sidebands and signal ranges } kQQfound = kTRUE; // If at this point the dimuon has passed the basic conditions we keep only this dimuon from the event const double varValP[19] = {Reco_QQ_mupl_isGoodMuon[i],Reco_QQ_mupl_highPurity[i],Reco_QQ_mupl_TrkMuArb[i],Reco_QQ_mupl_TMOneStaTight[i],Reco_QQ_mupl_nPixValHits[i],Reco_QQ_mupl_nMuValHits[i],Reco_QQ_mupl_nTrkHits[i],Reco_QQ_mupl_normChi2_inner[i],Reco_QQ_mupl_normChi2_global[i],Reco_QQ_mupl_nPixWMea[i],Reco_QQ_mupl_nTrkWMea[i],Reco_QQ_mupl_StationsMatched[i],Reco_QQ_mupl_dxy[i],Reco_QQ_mupl_dxyErr[i],Reco_QQ_mupl_dz[i],Reco_QQ_mupl_dzErr[i],Reco_QQ_mupl_ptErr_inner[i],Reco_QQ_mupl_ptErr_global[i],Reco_QQ_VtxProb[i]}; const double varValM[19] = {Reco_QQ_mumi_isGoodMuon[i],Reco_QQ_mumi_highPurity[i],Reco_QQ_mumi_TrkMuArb[i],Reco_QQ_mumi_TMOneStaTight[i],Reco_QQ_mumi_nPixValHits[i],Reco_QQ_mumi_nMuValHits[i],Reco_QQ_mumi_nTrkHits[i],Reco_QQ_mumi_normChi2_inner[i],Reco_QQ_mumi_normChi2_global[i],Reco_QQ_mumi_nPixWMea[i],Reco_QQ_mumi_nTrkWMea[i],Reco_QQ_mumi_StationsMatched[i],Reco_QQ_mumi_dxy[i],Reco_QQ_mumi_dxyErr[i],Reco_QQ_mumi_dz[i],Reco_QQ_mumi_dzErr[i],Reco_QQ_mumi_ptErr_inner[i],Reco_QQ_mumi_ptErr_global[i],0.}; //Reco_QQ_VtxProb set to 0. since it is a dimuon variable //************************************************** //*************** Fill histos ********************** //************************************************** //===== General distributions hMinvw->Fill(mass,weight); hRapw->Fill(tlvqq->Rapidity(),weight); hPtw->Fill(QQPt,weight); if (issig) { hpt->Fill(QQPt); hptw->Fill(QQPt,weight); } //===== //===== MuID distributions for (int ihist=0; ihist<nvar; ihist++) { Bool_t isQQVar = kFALSE; if ( !strcmp(varname[ihist],"VtxProb") ) isQQVar = kTRUE; // Just to avoid filling the histos twice if testing a variable corresponding to a dimuon hists_distr[varname[ihist]]->Fill(varValP[ihist],weight); // Signal+ Background variable distribution if ( !isQQVar ) hists_distr[varname[ihist]]->Fill(varValM[ihist],weight); if (issig) { hists_sig_distr[varname[ihist]]->Fill(varValP[ihist],weight); // Signal variable distribution if ( !isQQVar ) hists_sig_distr[varname[ihist]]->Fill(varValM[ihist],weight); } if (isbkg) { hists_bkg_distr[varname[ihist]]->Fill(varValP[ihist],weight); // Background variable distribution if ( !isQQVar ) hists_bkg_distr[varname[ihist]]->Fill(varValM[ihist],weight); } ////_______ Soft muons cut testing MuID distributions Int_t nTest = whichMuIDVar(varname[ihist]); // If the variable is not on the soft muon cuts the full cut is applied if (isSoftMuon(varValP,nTest)) { if (issig) hists_sig_distr_CutTest[varname[ihist]]->Fill(varValP[ihist],weight); // Variable distribution with the rest of soft MuID cuts applied (all the soft muon cuts if the variable does't belong to the soft cut) if (isbkg) hists_bkg_distr_CutTest[varname[ihist]]->Fill(varValP[ihist],weight); } if ( !isQQVar && isSoftMuon(varValM,nTest) ) { if (issig) hists_sig_distr_CutTest[varname[ihist]]->Fill(varValM[ihist],weight); if (isbkg) hists_bkg_distr_CutTest[varname[ihist]]->Fill(varValM[ihist],weight); } ////_______ dummyA = static_cast<TObjArray*>(aMinvCuts->FindObject(Form("mInv_%s",varname[ihist]))); TH1* dummyH(0x0); Double_t nBins = hists_sig[varname[ihist]]->GetNbinsX(); for ( Int_t j=1 ; j<=nBins ; j++) { //// Cuts on MuID variables Double_t cutVal = hists_sig[varname[ihist]]->GetBinLowEdge(j); if (Cut(varname[ihist],i,cutVal)) { if (issig) hists_sig[varname[ihist]]->Fill(hists_sig[varname[ihist]]->GetBinCenter(j),weight); // Variable cut distribution if (isbkg) hists_bkg[varname[ihist]]->Fill(hists_bkg[varname[ihist]]->GetBinCenter(j),weight); if ( !(dummyH = static_cast<TH1*>(dummyA->FindObject(Form("mInv_%s_Cut%2.4f",varname[ihist],cutVal)))) ) // Creates the minv histogram and store in array (only once) { dummyH = new TH1D(Form("mInv_%s_Cut%2.4f",varname[ihist],cutVal),Form("Dimuon m_{inv} distribution (cut on %s: %2.4f)",varname[ihist],cutVal),600,0.,15.0); dummyA->Add(dummyH); } dummyH->Fill(mass,weight); // Invariant mass histo for each variable cut if ( isSoftMuon(varValP,nTest) && isSoftMuon(varValM,nTest) ) // If the variable is not in the soft MuID cut, the full soft cut is applied and the variable cut distribution is filled { if (issig) hists_sig_SofMu[varname[ihist]]->Fill(hists_sig[varname[ihist]]->GetBinCenter(j),weight); if (isbkg) hists_bkg_SofMu[varname[ihist]]->Fill(hists_bkg[varname[ihist]]->GetBinCenter(j),weight); } } } } //======= i++; } } //====== Save histos ====== TFile *f = new TFile(Form("histos_%s_%s_%s_Pt%2.1f_%2.1f_Y%2.1f_%2.1f.root",fileType,particle,fIncludeHighPurity ? "HPincl" : "NoHPincl",Ptmin,Ptmax,Ymin,Ymax),"RECREATE"); for (int i=0; i<nvar; i++) { aSigC->Add(hists_sig[varname[i]]); aBkgC->Add(hists_bkg[varname[i]]); aSig->Add(hists_sig_distr[varname[i]]); aBkg->Add(hists_bkg_distr[varname[i]]); aDistr->Add(hists_distr[varname[i]]); aSigSoftMuCutsButOne->Add(hists_sig_distr_CutTest[varname[i]]); aBkgSoftMuCutsButOne->Add(hists_bkg_distr_CutTest[varname[i]]); aSigSoftMuCuts->Add(hists_sig_SofMu[varname[i]]); aBkgSoftMuCuts->Add(hists_bkg_SofMu[varname[i]]); } aSigC->Write("SigSingleCut", TObject::kOverwrite | TObject::kSingleKey); aBkgC->Write("BkgSingleCut", TObject::kOverwrite | TObject::kSingleKey); aSig->Write("SigDistr", TObject::kOverwrite | TObject::kSingleKey); aBkg->Write("BkgDistr", TObject::kOverwrite | TObject::kSingleKey); aDistr->Write("Distr", TObject::kOverwrite | TObject::kSingleKey); aSigSoftMuCutsButOne->Write("SigDistrSoftMuCutButOne", TObject::kOverwrite | TObject::kSingleKey); aBkgSoftMuCutsButOne->Write("BkgDistrSoftMuCutButOne", TObject::kOverwrite | TObject::kSingleKey); aSigSoftMuCuts->Write("SigSoftMuCut", TObject::kOverwrite | TObject::kSingleKey); aBkgSoftMuCuts->Write("BkgSoftMuCut", TObject::kOverwrite | TObject::kSingleKey); aGlob->Add(hMinvw); aGlob->Add(hRapw); aGlob->Add(hPtw); aGlob->Add(hpt); aGlob->Add(hptw); aGlob->Add(hCent); aGlob->Add(hCentw); aGlob->Write("Global", TObject::kOverwrite | TObject::kSingleKey); aMinvCuts->Write("MinvWCuts", TObject::kOverwrite | TObject::kSingleKey); f->Close(); //========= }
// // *** Configuration script for phi->KK analysis with 2010 runs *** // // A configuration script for RSN package needs to define the followings: // // (1) decay tree of each resonance to be studied, which is needed to select // true pairs and to assign the right mass to all candidate daughters // (2) cuts at all levels: single daughters, tracks, events // (3) output objects: histograms or trees // Bool_t RsnConfigPhiTPC ( AliRsnAnalysisTask *task, Bool_t isMC, Bool_t isMix, Bool_t useCentrality, AliRsnCutSet *eventCuts ) { if (!task) ::Error("RsnConfigPhiTPC", "NULL task"); // we define here a suffix to differentiate names of different setups for the same resonance // and we define also the name of the list of tracks we want to select for the analysis // (if will fail if no lists with this name were added to the RsnInputHandler) const char *suffix = "tpc"; const char *listName = "kaonTPC"; Bool_t useCharged = kTRUE; Int_t listID = -1; // find the index of the corresponding list in the RsnInputHandler AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); AliMultiInputEventHandler *multi = dynamic_cast<AliMultiInputEventHandler*>(mgr->GetInputEventHandler()); if (multi) { TObjArray *array = multi->InputEventHandlers(); AliRsnInputHandler *rsn = (AliRsnInputHandler*)array->FindObject("rsnInputHandler"); if (rsn) { AliRsnDaughterSelector *sel = rsn->GetSelector(); listID = sel->GetID(listName, useCharged); } } if (listID >= 0) ::Info ("RsnConfigPhiTPC.C", "Required list '%s' stays in position %d", listName, listID); else { ::Error("RsnConfigPhiTPC.C", "Required list '%s' absent in handler!", listName); return kFALSE; } // ---------------------------------------------------------------------------------------------- // -- DEFINITIONS ------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------------- // PAIR DEFINITIONS: // this contains the definition of particle species and charge for both daughters of a resonance, // which are used for the following purposes: // --> species is used to assign the mass to the daughter (e.g. for building invariant mass) // --> charge is used to select what tracks to use when doing the computation loops // When a user wants to compute a like-sign background, he must define also a pair definition // for each like-sign: in case of charged track decays, we need one for ++ and one for -- // Last two arguments are necessary only in some cases (but it is not bad to well initialize them): // --> PDG code of resonance, which is used for selecting true pairs, when needed // --> nominal resonance mass, which is used for computing quantities like Y or Mt AliRsnPairDef *phi_kaonP_kaonM = new AliRsnPairDef(AliRsnDaughter::kKaon, '+', AliRsnDaughter::kKaon, '-', 333, 1.019455); AliRsnPairDef *phi_kaonP_kaonP = new AliRsnPairDef(AliRsnDaughter::kKaon, '+', AliRsnDaughter::kKaon, '+', 333, 1.019455); AliRsnPairDef *phi_kaonM_kaonM = new AliRsnPairDef(AliRsnDaughter::kKaon, '-', AliRsnDaughter::kKaon, '-', 333, 1.019455); // PAIR LOOPS: // these are the objects which drive the computations and fill the output histograms // each one requires to be initialized with an AliRsnPairDef object, which provided masses, // last argument tells if the pair is for mixing or not (this can be also set afterwards, anyway) const Int_t nPairs = 5; Bool_t addPair[nPairs] = {1, 1, 1, 1, 1}; AliRsnLoopPair *phiLoop[nPairs]; phiLoop[0] = new AliRsnLoopPair(Form("%s_phi_kaonP_kaonM" , suffix), phi_kaonP_kaonM, kFALSE); phiLoop[1] = new AliRsnLoopPair(Form("%s_phi_kaonP_kaonM_true", suffix), phi_kaonP_kaonM, kFALSE); phiLoop[2] = new AliRsnLoopPair(Form("%s_phi_kaonP_kaonM_mix" , suffix), phi_kaonP_kaonM, kTRUE ); phiLoop[3] = new AliRsnLoopPair(Form("%s_phi_kaonP_kaonP" , suffix), phi_kaonP_kaonP, kFALSE); phiLoop[4] = new AliRsnLoopPair(Form("%s_phi_kaonM_kaonM" , suffix), phi_kaonM_kaonM, kFALSE); // set additional option for true pairs // 1) we select only pairs coming from the same mother, which must have the right PDG code (from pairDef) // 2) we select only pairs decaying according to the right channel (from pairDef species+charge definitions) phiLoop[1]->SetOnlyTrue(kTRUE); phiLoop[1]->SetCheckDecay(kTRUE); // don't add true pairs if not MC if (!isMC) addPair[1] = 0; addPair[0] = !isMix; addPair[1] = !isMix; addPair[2] = isMix; addPair[3] = !isMix; addPair[4] = !isMix; // ---------------------------------------------------------------------------------------------- // -- COMPUTED VALUES & OUTPUTS ----------------------------------------------------------------- // ---------------------------------------------------------------------------------------------- // All values which should be computed are defined here and passed to the computation objects, // since they define all that is computed bye each one, and, in case one output is a histogram // they define the binning and range for that value // // NOTE: // --> multiplicity bins have variable size Double_t mult[] = { 0., 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., 13., 14., 15., 16., 17., 18., 19., 20., 21., 22., 23., 24., 25., 30., 35., 40., 50., 60., 70., 80., 90., 100., 120., 140., 160., 180., 200., 500.}; Int_t nmult = sizeof(mult) / sizeof(mult[0]); AliRsnValuePair *axisIM = new AliRsnValuePair("IM" , AliRsnValuePair::kInvMass ); AliRsnValuePair *axisRes = new AliRsnValuePair("RES", AliRsnValuePair::kInvMassRes); AliRsnValuePair *axisPt = new AliRsnValuePair("PT" , AliRsnValuePair::kPt ); AliRsnValuePair *axisY = new AliRsnValuePair("Y" , AliRsnValuePair::kY); AliRsnValueEvent*axisCentV0 = new AliRsnValueEvent("CNT" , AliRsnValueEvent::kCentralityV0); AliRsnValueEvent*axisMultESD = new AliRsnValueEvent("MESD", AliRsnValueEvent::kMultESDCuts ); AliRsnValueEvent*axisMultSPD = new AliRsnValueEvent("MSPD", AliRsnValueEvent::kMultSPD ); AliRsnValueEvent*axisMultTRK = new AliRsnValueEvent("MTRK", AliRsnValueEvent::kMult ); AliRsnValueEvent*axisMultMC = new AliRsnValueEvent("MMC" , AliRsnValueEvent::kMultMC ); axisIM ->SetBins(500, 0.9, 1.4); axisRes ->SetBins(-0.5, 0.5, 0.001); axisPt ->SetBins(50, 0.0, 5.0); axisY ->SetBins(1, -0.5, 0.5); axisCentV0 ->SetBins(20, 0.0, 100.0); axisMultESD->SetBins(nmult, mult); axisMultSPD->SetBins(nmult, mult); axisMultTRK->SetBins(nmult, mult); axisMultMC ->SetBins(nmult, mult); // create outputs: // we define one for true pairs, where we add resolution, and another without it, for all others // it seems that it is much advantageous to use sparse histograms when adding more than 2 axes AliRsnListOutput *out[2]; out[0] = new AliRsnListOutput("res" , AliRsnListOutput::kHistoSparse); out[1] = new AliRsnListOutput("nores", AliRsnListOutput::kHistoSparse); // add values to outputs: // if centrality is required, we add it only, otherwise we add all multiplicities // other axes (invmass, pt) are always added for (Int_t i = 0; i < 2; i++) { out[i]->AddValue(axisIM); out[i]->AddValue(axisPt); out[i]->AddValue(axisY); if (useCentrality) { ::Info("RsnConfigPhiTPC.C", "Adding centrality axis"); out[i]->AddValue(axisCentV0); } else { ::Info("RsnConfigPhiTPC.C", "Adding multiplicity axes"); //out[i]->AddValue(axisMultESD); //out[i]->AddValue(axisMultSPD); out[i]->AddValue(axisMultTRK); if (isMC) out[i]->AddValue(axisMultMC); } } // resolution only in the first out[0]->AddValue(axisRes); // ---------------------------------------------------------------------------------------------- // -- ADD SETTINGS TO LOOPS AND LOOPS TO TASK --------------------------------------------------- // ---------------------------------------------------------------------------------------------- for (Int_t ip = 0; ip < nPairs; ip++) { // skip pairs not to be added if (!addPair[ip]) continue; // assign list IDs phiLoop[ip]->SetListID(0, listID); phiLoop[ip]->SetListID(1, listID); // assign event cuts phiLoop[ip]->SetEventCuts(eventCuts); // assign outputs if (ip != 1) phiLoop[ip]->AddOutput(out[1]); else phiLoop[ip]->AddOutput(out[0]); // add to task task->AddLoop(phiLoop[ip]); } return kTRUE; }
void browseStacks( bool makePictures=false, bool wait=true , bool addHistName = false, Double_t maxYScaleF = 1., bool logScale = false, bool setMinZero = true) { gStyle->SetOptTitle(0); bool keep2D=false; //fix the hNJet histos TList *list = gDirectory->GetList(); TIterator *iter = list->MakeIterator(); TObject *obj = 0; while(obj = iter->Next()) { if(TString(obj->GetName()).Contains("hnJet") && obj->InheritsFrom(TH1::Class())) { int nbins = ((TH1F*)obj)->GetNbinsX(); float overflow = ((TH1F*)obj)->GetBinContent(nbins+1); float lastbinval = ((TH1F*)obj)->GetBinContent(nbins); ((TH1F*)obj)->SetBinContent(nbins, overflow+lastbinval); ((TH1F*)obj)->GetXaxis()->SetBinLabel(nbins, "#geq4"); } } // Find out what the names of the existing histograms are // The histogram names are XX_YY_ZZ, where XX is the sample, // eg, "tt", YY is the actual name, ZZ is the final state, eg, "ee" TObjArray* myNames = getMyHistosNames("ttdil","ee",keep2D); // Now loop over histograms, and make stacks TCanvas *c = new TCanvas(); c->Divide(2,2); char* suffix[4]; suffix[0] = "ee"; suffix[1] = "mm"; suffix[2] = "em"; suffix[3] = "all"; if (makePictures) c->Print("out/stacks.ps["); for (int i=0; i<myNames->GetEntries(); i++) { for (int sample=0; sample<4; sample++) { hist::stack(Form("st_%s_%s",myNames->At(i)->GetName(),suffix[sample]), Form("%s_%s$",myNames->At(i)->GetName(), suffix[sample])); THStack* thisStack = (THStack*) gROOT->FindObjectAny( Form("st_%s_%s", myNames->At(i)->GetName(), suffix[sample])); thisStack->SetMaximum(thisStack->GetMaximum()*maxYScaleF); if(TString(myNames->At(i)->GetName()).Contains("hnJet")) { TList* histolist = thisStack->GetHists(); int hatchcount = 0; // for(int j = 0; j<histolist->GetSize();j++) { // if(TString(histolist->At(j)->GetName()).Contains("tt") || // TString(histolist->At(j)->GetName()).Contains("tautau") || // TString(histolist->At(j)->GetName()).Contains("ww") ) continue; // hatch(histolist->At(j)->GetName(), FavoriteHatches[hatchcount]); // hatchcount++; // } } TLegend* thisLeg = hist::legend(thisStack, "lpf", 0, 0, 0.75, 0.65, 0.99, 0.99); c->cd(sample+1); if (logScale) gPad->SetLogy(); else gPad->SetLogy(0); double stackMax = ((TH1*)thisStack->GetHists()->At(0))->GetMaximum(); double stackMin = ((TH1*)thisStack->GetHists()->At(0))->GetMinimum(); thisStack->SetMinimum(stackMin); if (setMinZero) thisStack->SetMinimum(0); if (logScale && stackMin <=0) thisStack->SetMinimum(1e-2*stackMax); if (logScale && stackMax == 0) thisStack->SetMinimum(1e-12); thisStack->Draw("hist"); string xtitle( ((TH1*)gROOT->FindObjectAny(Form("ttdil_%s_%s", myNames->At(i)->GetName(), suffix[sample])))->GetXaxis()->GetTitle()); string ytitle( ((TH1*)gROOT->FindObjectAny(Form("ttdil_%s_%s", myNames->At(i)->GetName(), suffix[sample])))->GetYaxis()->GetTitle()); thisStack->GetXaxis()->SetTitle(xtitle.c_str()); thisStack->GetYaxis()->SetTitle(ytitle.c_str()); TString hname = thisStack->GetName(); if(hname.Contains("hnJet")) { thisStack->GetXaxis()->SetLabelSize(0.075); thisStack->GetYaxis()->SetLabelSize(0.05); thisStack->GetXaxis()->SetTitle("N_{jets}"); } thisLeg->Draw(); TPaveText *pt1 = new TPaveText(0.1, 0.95, 0.4, 0.999, "brNDC"); pt1->SetName("pt1name"); pt1->SetBorderSize(0); pt1->SetFillStyle(0); TText *blah; if (addHistName) blah = pt1->AddText(hname); else blah = pt1->AddText("CMS Preliminary"); blah->SetTextSize(0.05); pt1->Draw(); c->Modified(); c->Update(); } if (makePictures) { c->Print("out/stacks.ps"); // c->Print(Form("out/stacks_%d.png",i+1)); //c->Print(Form("out/stacks_%s.png",myNames->At(i)->GetName())); c->Print(Form("out/stacks_%s.eps",myNames->At(i)->GetName())); } if (wait) { cout << "Enter carriage return for the next set of plots....q to quit" << endl; char in = getchar(); if (in == 'q') break; } } if (makePictures) c->Print("out/stacks.ps]"); }
void GeomAcc::Calculate(TString geomTuple, TString saveName){ TFile* file = new TFile(geomTuple); TTree* tree=(TTree*)file->Get("SelectJpsi/JpsiGen"); double JpsiPT, JpsiRap, CosTheta; double MuNegDau, MuPosDau; tree->SetBranchAddress("JPsi_PT",&JpsiPT); tree->SetBranchAddress("JPsi_RAPIDITY",&JpsiRap); tree->SetBranchAddress("JPsi_COSTHETA",&CosTheta); tree->SetBranchAddress("MuMinus_THETA",&MuNegDau); tree->SetBranchAddress("MuPlus_THETA",&MuPosDau); int xbin = 20; int ybin = 5; TH2D *Num = new TH2D("Num","Num",xbin,0.0,10000.0, ybin,2.0,4.2); TH2D *Den = new TH2D("Den","Den",xbin,0.0,10000.0, ybin,2.0,4.2); TH2D *NumLong = new TH2D("NumLong","NumLong",xbin,0.0,10000.0, ybin,2.0,4.2); TH2D *DenLong = new TH2D("DenLong","DenLong",xbin,0.0,10000.0, ybin,2.0,4.2); TH2D *NumTrans = new TH2D("NumTrans","NumTrans",xbin,0.0,10000.0, ybin,2.0,4.2); TH2D *DenTrans = new TH2D("DenTrans","DenTrans",xbin,0.0,10000.0, ybin,2.0,4.2); for(int i=0; i<tree->GetEntries(); i++) { tree->GetEntry(i); Den->Fill(JpsiPT,JpsiRap); DenLong->Fill(JpsiPT,JpsiRap,(1-CosTheta*CosTheta)); DenTrans->Fill(JpsiPT,JpsiRap,(1+CosTheta*CosTheta)); // //Calculate Daughters in acceptance criteria // bool inAcc = Cut(MuPosDau, MuNegDau); if(inAcc) { Num->Fill(JpsiPT,JpsiRap); NumLong->Fill(JpsiPT,JpsiRap,(1-CosTheta*CosTheta)); NumTrans->Fill(JpsiPT,JpsiRap,(1+CosTheta*CosTheta)); } } // //Calculate efficiency // TH2D GeoEff = (Eff(Num, Den, xbin, ybin, "GeoEff")); TH2D GeoLongEff = (Eff(NumLong, DenLong, xbin, ybin,"GeoLongEff")); TH2D GeoTransEff = (Eff(NumTrans, DenTrans, xbin, ybin,"GeoTransEff")); TObjArray* histList = new TObjArray(0); histList->Add(Num); histList->Add(Den); histList->Add(&GeoEff); histList->Add(NumLong); histList->Add(DenLong); histList->Add(&GeoLongEff); histList->Add(NumTrans); histList->Add(DenTrans); histList->Add(&GeoTransEff); TFile* saveFile = new TFile("Output/"+saveName, "recreate"); histList->Write(); saveFile->Close(); // // Save into final usable format in Efficiency folder // Format(saveName, "NoPol/"); Format(saveName, "Long/"); Format(saveName, "Trans/"); return; }
int main(int argc, char* argv[]){ if (argc != 6){ std::cout << "wrong number of arguments: usage ./topDataClass_doAnalysis <file name> <mod #> <row #> <col #> <ch #>" << std::endl; return 0; } //define application object theApp = new TApplication("App", &argc, argv); TString inputFileName = theApp->Argv()[1]; std::cout << "Input file name " << inputFileName << std::endl; //create target6 interface object topDataClass *data = new topDataClass(); //specify channel of interest int inMod = atoi(theApp->Argv()[2]); int inRow = atoi(theApp->Argv()[3]); int inCol = atoi(theApp->Argv()[4]); int inCh = atoi(theApp->Argv()[5]); data->setAnalysisChannel( inMod, inRow, inCol, inCh ); //specify timing marker channel data->setTimingMarkerChannel( 0, 0, 1, 2 ); //specify time window data->windowTime = windowTime; //open summary tree file data->openSummaryTree(inputFileName); //create output file TObjArray* strings = inputFileName.Tokenize("/"); TObjString* objstring = (TObjString*) strings->At(strings->GetLast()); TString inputFileNameBase(objstring->GetString()); TString outputFileName = "output_topDataClass_doAnalysis_doublePulseSampleDTFit_"; outputFileName += inMod; outputFileName += "_"; outputFileName += inRow; outputFileName += "_"; outputFileName += inCol; outputFileName += "_"; outputFileName += inCh; outputFileName += "_"; outputFileName += inputFileNameBase; //outputFileName += ".root"; std::cout << " outputFileName " << outputFileName << std::endl; outputFile = new TFile( outputFileName , "RECREATE"); //initialize histograms initializeGlobalHistograms(); //initialize tree branches data->setTreeBranches(); //load pulse info into arrays data->selectPulsesForArray(); //loop over selected events, apply corrections histogram pulse time distributions //monitor pulse time vs event # gPulseTimeVsEventNum = new TGraphErrors(); for(int entry = 0; entry < data->numUsed; entry++) { //skip events not in arrays if( entry >= maxNumEvt ) continue; double pulseTime = data->measurePulseTimeArrayEntry(entry,1); double pulseHeight = data->adc_0_A[entry]; int smpBinNumIn128Array = data->getSmpBinNumIn128Array(entry); double smpPos = data->getSmpPos(entry); //apply analysis cuts //if( smpBinNumIn128Array >= 127 ) // continue; //measure pulse time vs event # gPulseTimeVsEventNum->SetPoint( gPulseTimeVsEventNum->GetN() , data->eventNum_A[entry], pulseTime ); //cut on event # if( data->eventNum_A[entry] < 0 ) continue; //histogram selected pulse distributions hPulseHeightInitial->Fill( data->adc_0_A[entry] ); hPulseTimeInitial->Fill( pulseTime ); hPulseSampleInitial->Fill(data->smp_0_A[entry]); hPulseSmp128Initial->Fill(smpBinNumIn128Array); hPulseTimeVsSmp128Initial->Fill(smpBinNumIn128Array, pulseTime ); hPulseTimeVsSmp128PosInitial->Fill(smpBinNumIn128Array + smpPos, pulseTime ); hPulseTimeVsHeightInitial->Fill(pulseHeight, pulseTime ); hPulseTimeVsFTSWInitial->Fill(data->ftsw_A[entry], pulseTime ); hFTSWVsSmp128Initial->Fill(smpBinNumIn128Array, data->ftsw_A[entry]); } //loop over selected events, measure time difference between timing marker and selected channel pulses gTest = new TGraphErrors(); data->measurePulseMarkerTimeDifferenceDistribution(hPulseTimeMarkTimeDiffInitial,hPulseTimeMarkTimeDiffVsMarkSmpBinNumInitial ); //run fit analysis doDoublePulseFit(data); //write output file writeOutputFile(); //delete target6 data object delete data; return 1; }
void AliNDLocalRegressionTest(Int_t npoints=10000, Int_t ndim=2, const char *sfromula="cos(7*x[0]/pi)*sin(11*x[1]/pi)", Double_t err=0.1){ // // Local regression test method // // Int_t npoints=100000; Int_t ndim=2; const char *sfromula="cos(10*x[0])*cos(15*x[1])"; // gStyle->SetPadRightMargin(0.05); gStyle->SetPadTopMargin(0.05); gStyle->SetPadLeftMargin(0.14); gStyle->SetPadBottomMargin(0.12); gStyle->SetPadTickX(1); gStyle->SetPadTickY(1); gStyle->SetPadGridX(1); gStyle->SetPadGridY(1); gStyle->SetOptStat(0); // pformula=new TFormula("pformula", sfromula); pfitNDIdeal = new AliNDLocalRegression("pfitNDIdeal","pfitNDIdeal"); pfitNDGaus0 = new AliNDLocalRegression("pfitNDGaus0","pfitNDGaus0"); pfitNDGaus1 = new AliNDLocalRegression("pfitNDGaus1","pfitNDGaus1"); pfitNDGaus2 = new AliNDLocalRegression("pfitNDGaus2","pfitNDGaus2"); pfitNDGaus3 = new AliNDLocalRegression("pfitNDGaus3","pfitNDGaus3"); pfitNDBreit0 = new AliNDLocalRegression("pfitNDBreit0","pfitNDBreit0"); pfitNDBreit1 = new AliNDLocalRegression("pfitNDBreit1","pfitNDBreit1"); pfitNDBreit2 = new AliNDLocalRegression("pfitNDBreit2","pfitNDBreit2"); // // 0.) Initialization of variables and THn // TTreeSRedirector *pcstreamIn = new TTreeSRedirector("fitNDLocalTestInput.root","recreate"); TTreeSRedirector *pcstreamOutIdeal = new TTreeSRedirector("fitNDLocalTestOutputIdeal.root","recreate"); TTreeSRedirector *pcstreamOutGaus0 = new TTreeSRedirector("fitNDLocalTestOutputGaus0.root","recreate"); TTreeSRedirector *pcstreamOutGaus1 = new TTreeSRedirector("fitNDLocalTestOutputGaus1.root","recreate"); TTreeSRedirector *pcstreamOutGaus2 = new TTreeSRedirector("fitNDLocalTestOutputGaus2.root","recreate"); TTreeSRedirector *pcstreamOutGaus3 = new TTreeSRedirector("fitNDLocalTestOutputGaus3.root","recreate"); TTreeSRedirector *pcstreamOutBreit0 = new TTreeSRedirector("fitNDLocalTestOutputBreit0.root","recreate"); TTreeSRedirector *pcstreamOutBreit1 = new TTreeSRedirector("fitNDLocalTestOutputBreit1.root","recreate"); TTreeSRedirector *pcstreamOutBreit2 = new TTreeSRedirector("fitNDLocalTestOutputBreit2.root","recreate"); Double_t *xyz = new Double_t[ndim]; Double_t *sxyz = new Double_t[ndim]; Int_t *nbins = new Int_t[ndim]; Double_t *xmin = new Double_t[ndim]; Double_t *xmax = new Double_t[ndim]; TString **chxyz = new TString*[ndim]; for (Int_t idim=0; idim<ndim; idim++) { chxyz[idim]=new TString(TString::Format("xyz%d=",idim).Data()); nbins[idim]=40; xmin[idim]=0; xmax[idim]=1; } hN= new THnF("exampleFit","exampleFit", ndim, nbins, xmin,xmax); // // 1.) generate random input points // for (Int_t ipoint=0; ipoint<TMath::Abs(npoints); ipoint++){ for (Int_t idim=0; idim<ndim; idim++){ xyz[idim]=gRandom->Rndm(); } Double_t value=pformula->EvalPar(xyz,0); Double_t noise = gRandom->Gaus()*err; Double_t noise2 = noise*(1+(gRandom->Rndm()<0.1)*100); // noise with 10 percent of outliers Double_t noiseBreit = gRandom->BreitWigner()*err; (*pcstreamIn)<<"testInput"<< "val="<<value<< "err="<<err<< "noise="<<noise<< // gausian noise "noise2="<<noise2<< // gausian noise + 10% of outliers "noiseBreit="<<noiseBreit; for (Int_t idim=0; idim<ndim; idim++){ (*pcstreamIn)<<"testInput"<<chxyz[idim]->Data()<<xyz[idim]; } (*pcstreamIn)<<"testInput"<<"\n"; } delete pcstreamIn; pcstreamIn = new TTreeSRedirector("fitNDLocalTestInput.root"); treeIn= (TTree*)(pcstreamIn->GetFile()->Get("testInput")); // treeIn->Draw("val:xyz0:xyz1>>his(20,0,1,20,0,1)","","profsurf2",10000); // visualization of input // // 2.) Make local fits // if (npoints>0){ pfitNDIdeal->SetStreamer(pcstreamOutIdeal); pfitNDGaus0->SetStreamer(pcstreamOutGaus0); pfitNDGaus1->SetStreamer(pcstreamOutGaus1); pfitNDGaus2->SetStreamer(pcstreamOutGaus2); pfitNDGaus3->SetStreamer(pcstreamOutGaus3); pfitNDBreit0->SetStreamer(pcstreamOutBreit0); pfitNDBreit1->SetStreamer(pcstreamOutBreit1); pfitNDBreit2->SetStreamer(pcstreamOutBreit2); } // pfitNDIdeal->SetHistogram((THn*)(hN->Clone())); pfitNDGaus0->SetHistogram((THn*)(hN->Clone())); pfitNDGaus1->SetHistogram((THn*)(hN->Clone())); pfitNDGaus2->SetHistogram((THn*)(hN->Clone())); pfitNDGaus3->SetHistogram((THn*)(hN->Clone())); pfitNDGaus2->SetCuts(3,0.8,1); pfitNDGaus3->SetCuts(0,0.8,0); pfitNDBreit0->SetCuts(3,0.8,1); pfitNDBreit1->SetCuts(3,0.8,1); pfitNDBreit2->SetCuts(0,0.8,1); pfitNDBreit0->SetHistogram((THn*)(hN->Clone())); pfitNDBreit1->SetHistogram((THn*)(hN->Clone())); pfitNDBreit2->SetHistogram((THn*)(hN->Clone())); // pfitNDIdeal->MakeFit(treeIn, "val:err", "xyz0:xyz1","Entry$%2==1", "0.02:0.02","2:2",0.0001); pfitNDGaus0->MakeFit(treeIn, "val+noise:err", "xyz0:xyz1","Entry$%2==0", "0.02:0.02","2:2",0.0001); // sample Gaussian1 pfitNDGaus1->MakeFit(treeIn, "val+noise:err", "xyz0:xyz1","Entry$%2==1", "0.02:0.02","2:2",0.0001); // sample Gaussian2 pfitNDGaus2->MakeFit(treeIn, "val+noise2:err", "xyz0:xyz1","Entry$%2==1", "0.02:0.02","2:2",0.0001); // sample Gaussian2 - with tails robust pfitNDGaus3->MakeFit(treeIn, "val+noise2:err", "xyz0:xyz1","Entry$%2==1", "0.02:0.02","2:2",0.0001); // sample Gaussian2 - with tails non robust pfitNDBreit0->MakeFit(treeIn, "val+noiseBreit:err", "xyz0:xyz1","Entry$%2==0", "0.02:0.02","2:2",0.0001); // sample Breit0 pfitNDBreit1->MakeFit(treeIn, "val+noiseBreit:err", "xyz0:xyz1","Entry$%2==1", "0.02:0.02","2:2",0.0001); // sample Breit1 pfitNDBreit2->MakeFit(treeIn, "val+noiseBreit:err", "xyz0:xyz1","Entry$%2==1", "0.02:0.02","2:2",0.0001); // sample Breit2 without outlier filtering // if (npoints<0) return; // callgrind mode of operation pfitNDIdeal->AddVisualCorrection(pfitNDIdeal,1); pfitNDGaus0->AddVisualCorrection(pfitNDGaus0,2); pfitNDGaus1->AddVisualCorrection(pfitNDGaus1,3); pfitNDGaus2->AddVisualCorrection(pfitNDGaus2,7); pfitNDGaus3->AddVisualCorrection(pfitNDGaus3,8); pfitNDBreit0->AddVisualCorrection(pfitNDBreit0,4); pfitNDBreit1->AddVisualCorrection(pfitNDBreit1,5); pfitNDBreit2->AddVisualCorrection(pfitNDBreit2,6); // TObjArray * array = AliNDLocalRegression::GetVisualCorrections(); for (Int_t i=0; i<array->GetEntries(); i++){ AliNDLocalRegression * regression = ( AliNDLocalRegression *)array->At(i); if (regression==NULL) continue; regression->AddVisualCorrection(regression); Int_t hashIndex = regression->GetVisualCorrectionIndex(); treeIn->SetAlias( regression->GetName(), TString::Format("AliNDLocalRegression::GetCorrND(%d,xyz0,xyz1+0)",hashIndex).Data()); } delete pcstreamOutGaus0; delete pcstreamOutGaus1; delete pcstreamOutGaus2; delete pcstreamOutGaus3; delete pcstreamOutBreit0; delete pcstreamOutBreit1; delete pcstreamOutBreit2; UnitTestGaussNoise(); UnitTestGaussNoisePlusOutliers(); UnitTestBreitWignerNoise(); UnitTestStreamer(); UnitTestContrain(); }
void PlotPubHisto(TObjArray histograms,TEnv *params){ // This is a modification of the AddHistos macro // Number of histos to plot: Int_t ntot = histograms.GetEntries(); // Check we have what we expect (the order should be: data, qcd, wjets, etc...) for(Int_t i = 0; i<ntot; i++){ if(histograms[i]==0) { cout<<"Error in AddHistos: histogram "<<i<<" is a NULL pointer!"<<endl; return; } TH1F * hthis = (TH1F*) histograms[i]; // include the overflow/underflow bins: int numbins = hthis->GetNbinsX(); //this is the last bin plotted double hicontent = hthis->GetBinContent(numbins); double overflow = hthis->GetBinContent(numbins+1);// this bin contains the overflow double locontent = hthis->GetBinContent(1);// this is the first bin plotted double underflow = hthis->GetBinContent(0);// this bin contains the underflow if (underflow>0 || overflow>0){ //printf("%-20s numbins=%4i hicontent=%4.2f over=%4.2f locontent=%4.2f underflow=%4.2f \n", // title.Data(),numbins,hicontent,overflow,locontent,underflow); } hthis->SetBinContent(numbins,hicontent+overflow); hthis->SetBinContent(1,locontent+underflow); } // define a few additional line styles: gStyle->SetLineStyleString(5,"20 12 4 12"); gStyle->SetLineStyleString(6,"20 12 4 12 4 12 4 12"); gStyle->SetLineStyleString(7,"20 20"); gStyle->SetLineStyleString(8,"20 12 4 12 4 12"); gStyle->SetLineStyleString(9,"80 25"); gStyle->SetLineStyleString(10,"50 10 10 10"); gStyle->SetLineStyleString(17,"30 25"); gStyle->SetLineStyleString(20,"60 20"); gStyle->SetLineStyleString(21,"60 20 20 20"); int lineStyle[20]; for(int i=0;i<20;i++) { lineStyle[i]=i; } // the first histogram in the list: TH1F *h0=((TH1F*) histograms[0])->Clone(); // histogram output filename TString oFileName=params->GetValue("Histo.Output.Filename","bogus.eps"); // figure out the number of signals Int_t nsig=1; if(params->Defined("Histo.Signal.Title.1")) nsig=1; if(params->Defined("Histo.Signal.Title.2")) nsig=2; if(params->Defined("Histo.Signal.Title.3")) nsig=3; cout << " I will use nsig = " << nsig << " signal sources" << endl; // Do the cumulative summing, except for the data TObjArray addedhistos; addedhistos.Clear(); TObjArray signalhistos; signalhistos.Clear(); TString sampletitles[20]; Int_t nbkg=0; for(Int_t i = 1; i<ntot; i++){// i runs over histograms[i], so data is for i=0 ostringstream baseSrcName; baseSrcName << "Files." << i+1 << ".";// Counting starts at 1: Files.1.Name: Data TString bSrcName(baseSrcName.str().c_str()); // skip some if we want to show them as lines TString htitle=params->GetValue(bSrcName+"Title",""); sampletitles[i-1]=htitle; if(params->GetValue("Histo.ShowSignalSeparately",0)==1 && // skip the last two if the signal title is not defined: ( ( !(params->Defined("Histo.Signal.Title")||params->Defined("Histo.Signal.Title.1")) && i>=ntot-nsig) // skip the signal if the signal title is defined || params->GetValue("Histo.Signal.Title",".")==htitle || params->GetValue("Histo.Signal.Title.1",".")==htitle || params->GetValue("Histo.Signal.Title.2",".")==htitle || params->GetValue("Histo.Signal.Title.3",".")==htitle ) ) { TH1F * hthis = (TH1F*) histograms[i]->Clone(); cout<<" Found signal in location "<<i+1<<" with name "<<htitle.Data()<<endl; signalhistos.Add(hthis); } else { TH1F * hthis = (TH1F*) histograms[i]->Clone(); addedhistos.Add(hthis); // Fill in the new TObjArray with a copy //cout << " Adding bkg " << i << " " << htitle.Data() << " " << hthis->Integral() << endl; // add all of the backgrounds if (i>1) {// i=0 is the data, and we must start with the second // background to add the previous TH1F * hprevious = (TH1F*) addedhistos[i-2]; if ( hthis->GetXaxis()->GetNbins() != hprevious->GetXaxis()->GetNbins() ) { // Protection against _whoran histogram. // We cannot add two histograms with different numbers of bins! cout<<"Error in AddHistos: incompatible number of bins!"<<endl; return; } hthis->Add(hprevious); // Do the addition addedhistos.RemoveAt(i-1); // And substitute whatever we had addedhistos.AddAt(hthis,i-1); nbkg++; //cout << "Substituing bkg " << i << " + " << i-1 << " in addedhistos["<< i-1 <<"]" << endl; } } // end of: if adding histograms } cout << " nbkg = " << nbkg << endl; // Rebin histos if necessary, but first calculate KS: TH1F *hbkg = (TH1F*) addedhistos[nbkg]; double KS = h0->KolmogorovTest(hbkg); double chi2ndf = h0->Chi2Test(hbkg, "UWUFOFCHI2/NDF"); //cout << title.Data() << " KS = " << KS << " chi2/NDF = " << chi2ndf << endl; // Rebin? Set nrebin = 0 to NOT do rebinning. // Will rebin only histos whose maximum x axis value exceeds 20. // Anything with less will most probably be already made of integers, so no // need to rebin that! Int_t nbinsx = h0->GetXaxis()->GetNbins(); Int_t nbinsy = 100; Int_t nrebin = 5; if ( nbinsx > 750 && nbinsx <= 1000) nrebin = 30; if ( nbinsx > 400 && nbinsx <= 750 ) nrebin = 25;//20 if ( nbinsx > 300 && nbinsx <= 400 ) nrebin = 25;//15 if ( nbinsx > 200 && nbinsx <= 300 ) nrebin = 25;//15 if ( nbinsx > 150 && nbinsx <= 200 ) nrebin = 10;//10 if ( nbinsx > 100 && nbinsx <= 150 ) nrebin = 10;//10 if ( nbinsx > 50 && nbinsx <= 100 ) nrebin = 10;//10 if ( nbinsx > 20 && nbinsx <= 50 ) nrebin = 2; if ( nbinsx <= 20 ) nrebin = 1; printf(" Saw nbins =%4i, rebinning by nrebin =%2i to final %3i bins \n",nbinsx,nrebin,int(nbinsx/nrebin)); if ( nrebin != 0 ) { h0->Rebin(nrebin); // data for (Int_t i = 0; i<=nbkg; i++){ TH1F * h = (TH1F*) addedhistos[i]; h->Rebin(nrebin); } for (Int_t i = 0; i<nsig; i++){ TH1F * h = (TH1F*) signalhistos[i]; h->Rebin(nrebin); } } // default text size: 0.045 // make it bigger for the paper float textSize = 0.045; if(params->GetValue("Histo.Preliminary","yes")==TString("paper")) textSize=0.07; if(params->Defined("Histo.TextSize")) textSize=params->GetValue("Histo.TextSize",0.07); // Now, check largest dimensions so that we can plot all histograms at once. Float_t xmin=9999., xmax=-9999., ymin=9999., ymax=-9999.; for(Int_t i = 0; i<=nbkg; i++){ TH1F * h = (TH1F*) addedhistos[i]; ostringstream baseSrcName; baseSrcName << "Files." << i+1 << "."; TString bSrcName(baseSrcName.str().c_str()); TAxis *axis = h->GetXaxis(); if( axis->GetXmin() < xmin ) xmin = axis->GetXmin(); if( axis->GetXmax() > xmax ) xmax = axis->GetXmax(); if( h->GetMinimum() < ymin ) ymin = h->GetMinimum(); if( h->GetMaximum() > ymax ) ymax = h->GetMaximum(); } ymax = TMath::Nint(ymax*1.25+1); // Make enough room for the big legend TString title = h0->GetTitle(); // // now check if we should simply use the ranges that was passed to us. if(params->Defined("Histo.Xmin")) xmin = params->GetValue("Histo.Xmin",0.); if(params->Defined("Histo.Xmax")) xmax = params->GetValue("Histo.Xmax",0.); if(params->Defined("Histo.Ymin")) ymin = params->GetValue("Histo.Ymin",0.); if(params->Defined("Histo.Ymax")) ymax = params->GetValue("Histo.Ymax",0.); // Now make the frame: TH2F * frame = new TH2F("frame","",nbinsx,xmin,xmax,nbinsy,ymin,ymax); cout<<" frame has xmin "<<xmin<<", xmax "<<xmax<<", ymax "<<ymax<<endl; // get the x- and y-axis titles TString ytitle=params->GetValue("Histo.YTitle",""); if ( params->Defined("Histo.XTitle")) { frame->SetXTitle(params->GetValue("Histo.XTitle","")); } else { frame->SetXTitle(h0->GetTitle()); } frame->SetYTitle(ytitle.Data()); // also set the text size for the X and Y axis titles and numbers // do this globally for the style we are using float axisLabelSize=textSize; frame->GetXaxis()->SetLabelSize(axisLabelSize); frame->GetYaxis()->SetLabelSize(axisLabelSize); frame->GetXaxis()->SetTitleSize(axisLabelSize); frame->GetYaxis()->SetTitleSize(axisLabelSize); frame->SetStats(false); // reduce the axis title offset if the fonts are very large if(textSize>0.055) frame->GetXaxis()->SetTitleOffset(1.0); // also change the X axis title offset to move it farther away from the numbers if(params->Defined("Histo.XTitle.Offset")) { float xtitoffset=params->GetValue("Histo.XTitle.Offset",1.0); frame->GetXaxis()->SetTitleOffset(xtitoffset); } // also change the y axis title offset to move it farther away from the numbers frame->GetYaxis()->SetTitleOffset(1.0); // reduce the axis title offset if the fonts are very large if(textSize>0.055) frame->GetYaxis()->SetTitleOffset(1.0); // set the axes divisions frame->GetXaxis()->SetNdivisions(505,true); if(params->Defined("Histo.XNdivisions")) frame->GetXaxis()->SetNdivisions(params->GetValue("Histo.XNdivisions",505),kTRUE); if(params->Defined("Histo.YNdivisions")) frame->GetYaxis()->SetNdivisions(params->GetValue("Histo.YNdivisions",505),kTRUE); // make sure the X axis title and Y axis title are in black! frame->GetXaxis()->SetTitleColor(1); frame->GetYaxis()->SetTitleColor(1); // Could plot in log scale... //gPad->SetLogy(); // finally: Draw frame->Draw(); // Draw the background ones: for(Int_t i=nbkg; i>=0; i--){ TH1F * h = (TH1F*) addedhistos[i]; h->SetStats(kFALSE); ostringstream baseSrcName; baseSrcName << "Files." << i+2 << ".";// to account for the data which is Files.1 TString bSrcName(baseSrcName.str().c_str()); Int_t hcolor=params->GetValue(bSrcName+"Color",1); h->SetLineColor(1); h->SetFillColor(hcolor); if (i==nbkg) printf(" Data Yield = %5.2f ; SumBkg = %5.2f ; Data-SumBkg diff = %5.2f%% \n", h0->Integral(),h->Integral(),(h0->Integral()-h->Integral())*100./h0->Integral()); printf(" plotting bkg i=%2i name=%20.20s file=%2i integral=%5.1f color=%2i\n", i,sampletitles[i].Data(),i+2,h->Integral(),hcolor); int fillStyle=params->GetValue(bSrcName+"FillStyle",1001); h->SetFillStyle(fillStyle); h->DrawCopy("Hist,Same"); } // // and draw the signal ones // draw them in reverse order so that the last one will be on top. //for(Int_t i=ntot-3; i<ntot; i++){ for(Int_t i=nsig-1; i>=0; i--){ ostringstream baseSrcName; baseSrcName << "Files." << ntot+1-nsig+i << "."; TString bSrcName(baseSrcName.str().c_str()); Int_t hcolor=params->GetValue(bSrcName+"Color",1); TH1F * h = (TH1F*) signalhistos[i]; if (sampletitles[ntot-1-nsig+i].Contains("m_{H}=90")) h->Add (h, 1.07874865 -1.000); else if (sampletitles[ntot-1-nsig+i].Contains("m_{H}=100")) h->Add (h, 1.62317373 -1.000); else if (sampletitles[ntot-1-nsig+i].Contains("m_{H}=110")) h->Add (h, 2.31347600 -1.000); else if (sampletitles[ntot-1-nsig+i].Contains("m_{H}=120")) h->Add (h, 3.25275183 -1.000); else if (sampletitles[ntot-1-nsig+i].Contains("m_{H}=130")) h->Add (h, 4.54142919 -1.000); else if (sampletitles[ntot-1-nsig+i].Contains("m_{H}=140")) h->Add (h, 6.19195046 -1.000); else if (sampletitles[ntot-1-nsig+i].Contains("m_{H}=150")) h->Add (h, 8.38307290 -1.000); else if (sampletitles[ntot-1-nsig+i].Contains("m_{H}=160")) h->Add (h, 11.31721008 -1.000); else if (sampletitles[ntot-1-nsig+i].Contains("m_{H}=170")) h->Add (h, 14.85376469 -1.000); else if (sampletitles[ntot-1-nsig+i].Contains("m_{H}=180")) h->Add (h, 19.54537459 -1.000); else if (sampletitles[ntot-1-nsig+i].Contains("m_{H}=190")) h->Add (h, 25.44594010 -1.000); else if (sampletitles[ntot-1-nsig+i].Contains("m_{H}=200")) h->Add (h, 32.94784356 -1.000); else if (sampletitles[ntot-1-nsig+i].Contains("m_{H}=220")) h->Add (h, 54.09499080 -1.000); else if (sampletitles[ntot-1-nsig+i].Contains("m_{H}=240")) h->Add (h, 86.85079034 -1.000); else if (sampletitles[ntot-1-nsig+i].Contains("m_{H}=260")) h->Add (h, 136.31406761-1.000); else if (sampletitles[ntot-1-nsig+i].Contains("m_{H}=280")) h->Add (h, 210.70375053-1.000); else if (sampletitles[ntot-1-nsig+i].Contains("m_{H}=300")) h->Add (h, 319.79533099-1.000); printf(" plotting sig i=%2i name=%20.20s file=%2i integral=%5.1f color=%2i\n", i,sampletitles[ntot-1-nsig+i].Data(),ntot+1-nsig+i,h->Integral(),hcolor); // create a white background around each line (helps readibility): TH1F *h1=h->Clone(); h1->SetStats(kFALSE); h1->SetLineWidth(6); h1->SetLineColor(0);h1->SetFillColor(0); h1->SetLineStyle(1); h1->SetFillStyle(0); h1->Draw("HIST,SAME"); // now draw the proper line: h->SetStats(kFALSE); h->SetLineWidth(6); h->SetLineColor(hcolor);h->SetFillColor(0); Int_t hlinestyle = params->GetValue(bSrcName+"LineStyle",1); h->SetLineStyle(hlinestyle); h->SetFillStyle(0); // finally, draw! h->Draw("HIST,SAME"); } // end of: drawing signal as separate lines // Data is special: // change the default size of the little bar at the end of the error bar here gStyle->SetEndErrorSize(3); // also, maybe don't display the error bars along the X axis: //gStyle->SetErrorX(0); // X error bars not displayed gStyle->SetErrorX(0.5); // X error bars have width of a bin // now set the rest h0->SetMarkerSize(2); // if there are too many points (>80), keep the marker size smaller if(h0->GetNbinsX()>=50) h0->SetMarkerSize(1); //if(h0->GetNbinsX()>=100) h0->SetMarkerSize(1); h0->SetLineWidth(3); h0->SetMarkerStyle(8); h0->SetMarkerColor(1); h0->Draw("E1,SAME"); // Print some comparison: //ostringstream basefactor; //basefactor << "Files." << nbkg+3 << "." << "Factor"; //TString timesfactor(basefactor.str().c_str()); //Double_t nprod = params->GetValue(timesfactor,1.000); //printf("Data Yield = %5.2f ; SumBkg = %5.2f ; SumBkg+Sig = %5.2f ; Data-SumBkg diff = %5.2f%% \n", // h0->Integral(),hbkg2->Integral,(hbkg2->Integral()+(signalhistos[0]->Integral()/nprod), // (h0->Integral()-hbkg2->Integral)*100./h0->Integral())); // // Print D0 and lumi: // TText *t1 = new TText(); t1->SetTextFont(62); t1->SetTextColor(1); t1->SetNDC(); t1->SetTextAlign(12); t1->SetTextSize(textSize); TString prelim="D\328 Preliminary"; if(oFileName.EndsWith(".eps")) { prelim="D\349 Preliminary L=3.7 fb^-1#"; } else if(oFileName.EndsWith(".gif")) { prelim="D\328 Preliminary L=3.7 fb^-1#"; } t1->DrawTextNDC(0.13,0.965,prelim.Data()); // a counter of how much text we have added from the top int nAddTextLines=0; // any additional text? for(int iText=1;iText<20;iText++) { ostringstream baseTextName; baseTextName << "Histo.AddText." << iText; TString bTextName(baseTextName.str().c_str()); if(params->Defined(bTextName)) { // we are adding a line of text TLatex *t2 = new TLatex(); t2->SetTextFont(62); t2->SetTextColor(13); t2->SetTextAlign(32); t2->SetNDC(); t2->SetTextSize(textSize); TString addText(params->GetValue(bTextName,".")); float x0=0.94; float y0=0.96-(nAddTextLines)*0.05; // check if the user specified an alternative location for the text if(params->Defined(bTextName+".X0")) x0=params->GetValue(bTextName+".X0",0.94); if(params->Defined(bTextName+".Y0")) y0=params->GetValue(bTextName+".Y0",0.8); if(params->Defined(bTextName+".TextSize")) t2->SetTextSize(params->GetValue(bTextName+".TextSize",textSize)); // and increment the counter keeping track of how much we added, // but only if the user didn't move the label around. if(!params->Defined(bTextName+".X0")) nAddTextLines++; printf("AddText %4.2f %4.2f %s\n",x0,y0,addText.Data()); t2->DrawLatex(x0,y0,addText.Data()); } }// end additional text // now draw the frame axis again so that we can see the tick marks frame->Draw("sameaxis"); // Legend: TString showLegend(params->GetValue("Histo.ShowLegend",".")); if( showLegend != "no" ){ float lgdxmin=.65, lgdxmax=.90, lgdymin=.50, lgdymax=.91; if(showLegend=="yes" || showLegend=="right") { } else if (showLegend=="left"){ lgdxmin=.16; lgdxmax=.42; } TLegend *lgd = new TLegend(lgdxmin,lgdymin,lgdxmax,lgdymax); // This line makes the legend transparent (not grey, ewwww!): lgd->SetBorderSize(0); lgd->SetTextSize(textSize*0.9);// 10% less size lgd->SetTextFont(62); lgd->SetFillColor(0); // Plot the legend in reverse order (but data goes first): NiceAddEntry(lgd,h0,params->GetValue("Files.1.Title","Data"),"PL"); for(Int_t i = nbkg; i>=0; i--){ TH1F * h = (TH1F*) addedhistos[i]; TString lgd_entry= sampletitles[i]; // sampletitles runs from 0 (firstbkg) to ntot-1 NiceAddEntry(lgd,h,lgd_entry.Data(),"F"); } for(Int_t i = nsig-1; i>=0; i--){ TH1F * h = (TH1F*) signalhistos[i]; TString lgd_entry = sampletitles[i+nbkg+1]; // sampletitles runs from 0 (firstbkg) to ntot-1 ostringstream basefactor; basefactor << "Files." << i+nbkg+3 << "." << "Factor"; TString timesfactor(basefactor.str().c_str()); Double_t nprod = params->GetValue(timesfactor,1.000); if (nprod != 1.0 ) lgd_entry.Form("%s x%2.0f",lgd_entry.Data(),nprod); //cout << i+nbkg+3 << " " << nprod << " " << lgd_entry.Data() << endl; NiceAddEntry(lgd,h,lgd_entry.Data(),"L"); } lgd->Draw("SAME"); }// show legend // Draw the KS: TLatex *ks = new TLatex(); ks->SetTextFont(62); ks->SetTextColor(1); TString ks_val = Form("KS = %3.2f",KS); ks->SetTextAlign(11); ks->SetTextSize(0.03); // ks->SetTextAngle(90); ks->DrawTextNDC(0.83,0.93,ks_val.Data()); TString chi2_val = Form("#chi^{2}/ndf = %3.1f",chi2ndf); ks->SetNDC(true); ks->DrawLatex(0.83,0.97,chi2_val.Data()); // // Voila! // }
void RayTrace(AOpticsManager* manager, TCanvas* can3D) { const int kNdeg = 8; TH2D* h2[kNdeg]; TGraph* graph = new TGraph(); TCanvas* can = new TCanvas("can", "can", 900, 900); TCanvas* can2= new TCanvas("can2", "can2", 900, 900); can->Divide(3, 3, 1e-10, 1e-10); TH2D* hMirror = new TH2D("hMirror", ";X (mm);Y (mm)", 1000, -7, 7, 1000, -7, 7); for(int i = 0; i < kNdeg; i++){ double deg = i*0.5; TGeoTranslation raytr("raytr", -2*kF*TMath::Sin(deg*TMath::DegToRad()), 0, 2*kF*TMath::Cos(deg*TMath::DegToRad())); TVector3 dir; dir.SetMagThetaPhi(1, TMath::Pi() - deg*TMath::DegToRad(), 0); double lambda = 400*nm; // dummy ARayArray* array = ARayShooter::Square(lambda, 14*m, 401, 0, &raytr, &dir); manager->TraceNonSequential(*array); h2[i] = new TH2D("", Form("#it{#theta} = %3.1f#circ;x (mm); y (mm)", deg), 200, -40, 100, 200, -70, 70); TH2D tmp("", "", 100, -1e5, 1e5, 100, -1e5, 1e5); TObjArray* focused = array->GetFocused(); for(Int_t j = 0; j <= focused->GetLast(); j++){ ARay* ray = (ARay*)(*focused)[j]; Double_t p[4]; ray->GetLastPoint(p); tmp.Fill(p[0], p[1]); if (i == 0) { int n = ray->FindNodeNumberStartWith("mirror"); const double* pn = ray->GetPoint(n); hMirror->Fill(pn[0]/m, pn[1]/m); } // if if (i == kNdeg - 1 && gRandom->Uniform() < 0.001) { TPolyLine3D* pol = ray->MakePolyLine3D(); pol->SetLineColor(2); can3D->cd(); pol->Draw(); } // if } // j double meanx = tmp.GetMean(); for(Int_t j = 0; j <= focused->GetLast(); j++){ ARay* ray = (ARay*)(*focused)[j]; Double_t p[4]; ray->GetLastPoint(p); h2[i]->Fill((p[0] - meanx)/mm, p[1]/mm); } // j can->cd(i + 1); h2[i]->Draw("colz"); if(i == 0){ can2->cd(); hMirror->Draw("colz"); } // i delete array; } // i }
bool TreeReader::Initialize(vector <string> br, string opt) { if(!init) { if( !fChain ) { cout << endl; cout << "No tree to initialize" << endl; cout << endl; return false; } TObjArray *fileElements = fChain->GetListOfFiles(); if( !fileElements || ( fileElements->GetEntries() == 0 )) { cout << endl; cout << "No file(s) to initialize" << endl; cout << endl; return false; } } varList.clear(); TObjArray* branches = fChain->GetListOfBranches(); int nBranches = branches->GetEntries(); for (int i = 0; i < nBranches; ++i) { TBranch* branch = (TBranch*)branches->At(i); string brname = branch->GetName(); TLeaf* leaf = branch->GetLeaf(branch->GetName()); if ( leaf == 0 ) // leaf name is different from branch name { TObjArray* leafs = branch->GetListOfLeaves(); leaf = (TLeaf*)leafs->At(0); } string curtype = leaf->GetTypeName(); int id = TypeDB::getType(curtype.c_str()); int arreysize = 1; string title = leaf->GetTitle(); //cout << curtype << " " << title << endl; // Find out whether we have array by inspecting leaf title if ( title.find("[")!=std::string::npos ) { TLeaf * nelem = leaf->GetLeafCounter(arreysize); if(arreysize == 1 && nelem != NULL) arreysize = nelem->GetMaximum() + 1; //search for maximum value of the lenght } if(id >= 0) { bool addVar = true; if(br.size()>0) { addVar = false; for(unsigned b = 0; b < br.size(); b++) { if(opt == "names" || opt == "except") { if(br[b] == brname) { addVar = true; break;} } else if(opt.find("contains")!=string::npos) { if((string(brname)).find(br[b])!=string::npos) { addVar = true; break;} } else if(opt.find("except")==string::npos) cout << "Option " << opt << " not found" << endl; } if(opt.find("except")!=string::npos) addVar = !addVar; } if(addVar) { variable * tmpVar = new variable(id,arreysize); tmpVar->name = leaf->GetName(); tmpVar->bname = branch->GetName(); tmpVar->title = title; varList.push_back(tmpVar); fChain->SetBranchAddress(tmpVar->bname,tmpVar->value.address); } } else { cout << curtype << ": type not found" << endl; exit(1); return false; } } init = true; continueSorting = true; if(pmode=="v") cout << endl << "Set up " << varList.size() << " / " << nBranches << " branches" << endl; return true; }
//_________________________________________________________________________________________ Int_t checkPullTree(TString pathTree, TString pathNameThetaMap, TString pathNameSigmaMap, TString mapSuffix, const Int_t collType /*0: pp, 1: pPb, 2: PbPb*/, const Bool_t plotPull = kTRUE, const Double_t downScaleFactor = 1, TString pathNameSplinesFile = "", TString prSplinesName = "", TString fileNameTree = "bhess_PIDetaTree.root", TString treeName = "fTree") { const Bool_t isNonPP = collType != 0; const Double_t massProton = AliPID::ParticleMass(AliPID::kProton); Bool_t recalculateExpecteddEdx = pathNameSplinesFile != ""; TFile* f = 0x0; f = TFile::Open(Form("%s/%s", pathTree.Data(), fileNameTree.Data())); if (!f) { std::cout << "Failed to open tree file \"" << Form("%s/%s", pathTree.Data(), fileNameTree.Data()) << "\"!" << std::endl; return -1; } // Extract the data Tree TTree* tree = dynamic_cast<TTree*>(f->Get(treeName.Data())); if (!tree) { std::cout << "Failed to load data tree!" << std::endl; return -1; } // Extract the splines, if desired TSpline3* splPr = 0x0; if (recalculateExpecteddEdx) { std::cout << "Loading splines to recalculate expected dEdx!" << std::endl << std::endl; TFile* fSpl = TFile::Open(pathNameSplinesFile.Data()); if (!fSpl) { std::cout << "Failed to open spline file \"" << pathNameSplinesFile.Data() << "\"!" << std::endl; return 0x0; } TObjArray* TPCPIDResponse = (TObjArray*)fSpl->Get("TPCPIDResponse"); if (!TPCPIDResponse) { splPr = (TSpline3*)fSpl->Get(prSplinesName.Data()); // If splines are in file directly, without TPCPIDResponse object, try to load them if (!splPr) { std::cout << "Failed to load object array from spline file \"" << pathNameSplinesFile.Data() << "\"!" << std::endl; return 0x0; } } else { splPr = (TSpline3*)TPCPIDResponse->FindObject(prSplinesName.Data()); if (!splPr) { std::cout << "Failed to load splines from file \"" << pathNameSplinesFile.Data() << "\"!" << std::endl; return 0x0; } } } else std::cout << "Taking dEdxExpected from Tree..." << std::endl << std::endl; // Extract the correction maps TFile* fMap = TFile::Open(pathNameThetaMap.Data()); if (!fMap) { std::cout << "Failed to open thetaMap file \"" << pathNameThetaMap.Data() << "\"! Will not additionally correct data...." << std::endl; } TH2D* hMap = 0x0; if (fMap) { hMap = dynamic_cast<TH2D*>(fMap->Get(Form("hRefined%s", mapSuffix.Data()))); if (!hMap) { std::cout << "Failed to load theta map!" << std::endl; return -1; } } TFile* fSigmaMap = TFile::Open(pathNameSigmaMap.Data()); if (!fSigmaMap) { std::cout << "Failed to open simgaMap file \"" << pathNameSigmaMap.Data() << "\"!" << std::endl; return -1; } TH2D* hThetaMapSigmaPar1 = dynamic_cast<TH2D*>(fSigmaMap->Get("hThetaMapSigmaPar1")); if (!hThetaMapSigmaPar1) { std::cout << "Failed to load sigma map for par 1!" << std::endl; return -1; } Double_t c0 = -1; TNamed* c0Info = dynamic_cast<TNamed*>(fSigmaMap->Get("c0")); if (!c0Info) { std::cout << "Failed to extract c0 from file with sigma map!" << std::endl; return -1; } TString c0String = c0Info->GetTitle(); c0 = c0String.Atof(); printf("Loaded parameter 0 for sigma: %f\n\n", c0); if (plotPull) std::cout << "Plotting pull..." << std::endl << std::endl; else std::cout << "Plotting delta'..." << std::endl << std::endl; Long64_t nTreeEntries = tree->GetEntriesFast(); Double_t dEdx = 0.; // Measured dE/dx Double_t dEdxExpected = 0.; // Expected dE/dx according to parametrisation Double_t tanTheta = 0.; // Tangens of (local) theta at TPC inner wall Double_t pTPC = 0.; // Momentum at TPC inner wall UShort_t tpcSignalN = 0; // Number of clusters used for dEdx UChar_t pidType = 0; Int_t fMultiplicity = 0; //Double_t phiPrime = 0; // Only activate the branches of interest to save processing time tree->SetBranchStatus("*", 0); // Disable all branches tree->SetBranchStatus("pTPC", 1); tree->SetBranchStatus("dEdx", 1); tree->SetBranchStatus("dEdxExpected", 1); tree->SetBranchStatus("tanTheta", 1); tree->SetBranchStatus("tpcSignalN", 1); tree->SetBranchStatus("pidType", 1); //tree->SetBranchStatus("phiPrime", 1); if (isNonPP) tree->SetBranchStatus("fMultiplicity", 1); tree->SetBranchAddress("dEdx", &dEdx); tree->SetBranchAddress("dEdxExpected", &dEdxExpected); tree->SetBranchAddress("tanTheta", &tanTheta); tree->SetBranchAddress("tpcSignalN", &tpcSignalN); tree->SetBranchAddress("pTPC", &pTPC); tree->SetBranchAddress("pidType", &pidType); //tree->SetBranchAddress("phiPrime", &phiPrime); if (isNonPP) tree->SetBranchAddress("fMultiplicity", &fMultiplicity); // Output file TDatime daTime; TString savefileName = Form("%s%s_checkPullSigma_%04d_%02d_%02d__%02d_%02d.root", fileNameTree.ReplaceAll(".root", "").Data(), recalculateExpecteddEdx ? "_recalcdEdx" : "", daTime.GetYear(), daTime.GetMonth(), daTime.GetDay(), daTime.GetHour(), daTime.GetMinute()); TFile* fSave = TFile::Open(Form("%s/%s", pathTree.Data(), savefileName.Data()), "recreate"); if (!fSave) { std::cout << "Failed to open save file \"" << Form("%s/%s", pathTree.Data(), savefileName.Data()) << "\"!" << std::endl; return -1; } const Double_t pBoundLow = 0.1; const Double_t pBoundUp = 5; const Int_t nBins1 = TMath::Ceil(180 / downScaleFactor); const Int_t nBins2 = TMath::Ceil(100 / downScaleFactor); const Int_t nBins3 = TMath::Ceil(60 / downScaleFactor); const Int_t nPbinsForMap = nBins1 + nBins2 + nBins3; Double_t binsPforMap[nPbinsForMap + 1]; Double_t binWidth1 = (1.0 - pBoundLow) / nBins1; Double_t binWidth2 = (2.0 - 1.0 ) / nBins2; Double_t binWidth3 = (pBoundUp - 2.0) / nBins3; for (Int_t i = 0; i < nBins1; i++) { binsPforMap[i] = pBoundLow + i * binWidth1; } for (Int_t i = nBins1, j = 0; i < nBins1 + nBins2; i++, j++) { binsPforMap[i] = 1.0 + j * binWidth2; } for (Int_t i = nBins1 + nBins2, j = 0; i < nBins1 + nBins2 + nBins3; i++, j++) { binsPforMap[i] = 2.0 + j * binWidth3; } binsPforMap[nPbinsForMap] = pBoundUp; TH2D* hPull = new TH2D("hPull", "Pull vs. p_{TPC} integrated over tan(#Theta);p_{TPC} (GeV/c);Pull", nPbinsForMap, binsPforMap, plotPull ? 120 : 240, plotPull ? -6 : -0.6, plotPull ? 6 : 0.6); TH2D* hPullAdditionalCorr = (TH2D*)hPull->Clone("hPullAdditionalCorr"); hPullAdditionalCorr->SetTitle("Pull vs. p_{TPC} integrated over tan(#Theta) with additional dEdx correction w.r.t. tan(#Theta)"); /* const Int_t nThetaHistos = 3; TH2D* hPullTheta[nThetaHistos]; TH2D* hPullAdditionalCorrTheta[nThetaHistos]; Double_t tThetaLow[nThetaHistos] = { 0.0, 0.4, 0.9 }; Double_t tThetaHigh[nThetaHistos] = { 0.1, 0.5, 1.0 }; */ const Int_t nThetaHistos = 10; TH2D* hPullTheta[nThetaHistos]; TH2D* hPullAdditionalCorrTheta[nThetaHistos]; Double_t tThetaLow[nThetaHistos] = { 0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9 }; Double_t tThetaHigh[nThetaHistos] = { 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0 }; for (Int_t i = 0; i < nThetaHistos; i++) { hPullTheta[i] = new TH2D(Form("hPullTheta_%d", i), Form("Pull vs. p_{TPC} for %.2f <= |tan(#Theta)| < %.2f;p_{TPC} (GeV/c);Pull", tThetaLow[i], tThetaHigh[i]), nPbinsForMap, binsPforMap, plotPull ? 120 : 240, plotPull ? -6 : -0.6, plotPull ? 6 : 0.6); hPullAdditionalCorrTheta[i] = new TH2D(Form("hPullAdditionalCorrTheta_%d", i), Form("Pull vs. p_{TPC} for %.2f <= |tan(#Theta)| < %.2f with additional dEdx correction w.r.t. tan(#Theta);p_{TPC} (GeV/c);Pull", tThetaLow[i], tThetaHigh[i]), nPbinsForMap, binsPforMap, plotPull ? 120 : 240, plotPull ? -6 : -0.6, plotPull ? 6 : 0.6); } TF1 corrFuncMult("corrFuncMult", "[0] + [1]*TMath::Max([4], TMath::Min(x, [3])) + [2] * TMath::Power(TMath::Max([4], TMath::Min(x, [3])), 2)", 0., 0.2); TF1 corrFuncMultTanTheta("corrFuncMultTanTheta", "[0] * (x -[2]) + [1] * (x * x - [2] * [2])", -1.5, 1.5); TF1 corrFuncSigmaMult("corrFuncSigmaMul", "TMath::Max(0, [0] + [1]*TMath::Min(x, [3]) + [2] * TMath::Power(TMath::Min(x, [3]), 2))", 0., 0.2); // LHC13b.pass2 if (isNonPP) printf("Using corr Parameters for 13b.pass2\n!"); corrFuncMult.SetParameter(0, -5.906e-06); corrFuncMult.SetParameter(1, -5.064e-04); corrFuncMult.SetParameter(2, -3.521e-02); corrFuncMult.SetParameter(3, 2.469e-02); corrFuncMult.SetParameter(4, 0); corrFuncMultTanTheta.SetParameter(0, -5.32e-06); corrFuncMultTanTheta.SetParameter(1, 1.177e-05); corrFuncMultTanTheta.SetParameter(2, -0.5); corrFuncSigmaMult.SetParameter(0, 0.); corrFuncSigmaMult.SetParameter(1, 0.); corrFuncSigmaMult.SetParameter(2, 0.); corrFuncSigmaMult.SetParameter(3, 0.); /* OK, but PID task was not very satisfying corrFuncMult.SetParameter(0, -6.27187e-06); corrFuncMult.SetParameter(1, -4.60649e-04); corrFuncMult.SetParameter(2, -4.26450e-02); corrFuncMult.SetParameter(3, 2.40590e-02); corrFuncMult.SetParameter(4, 0); corrFuncMultTanTheta.SetParameter(0, -5.338e-06); corrFuncMultTanTheta.SetParameter(1, 1.220e-05); corrFuncMultTanTheta.SetParameter(2, -0.5); corrFuncSigmaMult.SetParameter(0, 7.89237e-05); corrFuncSigmaMult.SetParameter(1, -1.30662e-02); corrFuncSigmaMult.SetParameter(2, 8.91548e-01); corrFuncSigmaMult.SetParameter(3, 1.47931e-02); */ /* // LHC11a10a if (isNonPP) printf("Using corr Parameters for 11a10a\n!"); corrFuncMult.SetParameter(0, 6.90133e-06); corrFuncMult.SetParameter(1, -1.22123e-03); corrFuncMult.SetParameter(2, 1.80220e-02); corrFuncMult.SetParameter(3, 0.1); corrFuncMult.SetParameter(4, 6.45306e-03); corrFuncMultTanTheta.SetParameter(0, -2.85505e-07); corrFuncMultTanTheta.SetParameter(1, -1.31911e-06); corrFuncMultTanTheta.SetParameter(2, -0.5); corrFuncSigmaMult.SetParameter(0, -4.29665e-05); corrFuncSigmaMult.SetParameter(1, 1.37023e-02); corrFuncSigmaMult.SetParameter(2, -6.36337e-01); corrFuncSigmaMult.SetParameter(3, 1.13479e-02); */ /* OLD without saturation and large error for negative slopes corrFuncSigmaMult.SetParameter(0, -4.79684e-05); corrFuncSigmaMult.SetParameter(1, 1.49938e-02); corrFuncSigmaMult.SetParameter(2, -7.15269e-01); corrFuncSigmaMult.SetParameter(3, 1.06855e-02); */ /* OLD very good try, but with fewer pBins for the fitting corrFuncMult.SetParameter(0, 6.88365e-06); corrFuncMult.SetParameter(1, -1.22324e-03); corrFuncMult.SetParameter(2, 1.81625e-02); corrFuncMult.SetParameter(3, 0.1); corrFuncMult.SetParameter(4, 6.36890e-03); corrFuncMultTanTheta.SetParameter(0, -2.85505e-07); corrFuncMultTanTheta.SetParameter(1, -1.31911e-06); corrFuncMultTanTheta.SetParameter(2, -0.5); corrFuncSigmaMult.SetParameter(0, -4.28401e-05); corrFuncSigmaMult.SetParameter(1, 1.24812e-02); corrFuncSigmaMult.SetParameter(2, -5.28531e-01); corrFuncSigmaMult.SetParameter(3, 1.25147e-02); */ /*OLD good try corrFuncMult.SetParameter(0, 7.50321e-06); corrFuncMult.SetParameter(1, -1.25250e-03); corrFuncMult.SetParameter(2, 1.85437e-02); corrFuncMult.SetParameter(3, 0.1); corrFuncMult.SetParameter(4, 6.21192e-03); corrFuncMultTanTheta.SetParameter(0, -1.43112e-07); corrFuncMultTanTheta.SetParameter(1, -1.53e-06); corrFuncMultTanTheta.SetParameter(2, 0.3); corrFuncSigmaMult.SetParameter(0, -2.54019e-05); corrFuncSigmaMult.SetParameter(1, 8.68883e-03); corrFuncSigmaMult.SetParameter(2, -3.36176e-01); corrFuncSigmaMult.SetParameter(3, 1.29230e-02); */ /* // LHC10h.pass2 if (isNonPP) printf("Using corr Parameters for 10h.pass2\n!"); corrFuncMult.SetParameter(0, 3.21636e-07); corrFuncMult.SetParameter(1, -6.65876e-04); corrFuncMult.SetParameter(2, 1.28786e-03); corrFuncMult.SetParameter(3, 1.47677e-02); corrFuncMult.SetParameter(4, 0.); corrFuncMultTanTheta.SetParameter(0, 7.23591e-08); corrFuncMultTanTheta.SetParameter(1, 2.7469e-06); corrFuncMultTanTheta.SetParameter(2, -0.5); corrFuncSigmaMult.SetParameter(0, -1.22590e-05); corrFuncSigmaMult.SetParameter(1, 6.88888e-03); corrFuncSigmaMult.SetParameter(2, -3.20788e-01); corrFuncSigmaMult.SetParameter(3, 1.07345e-02); */ /*OLD bad try corrFuncMult.SetParameter(0, 2.71514e-07); corrFuncMult.SetParameter(1, -6.92031e-04); corrFuncMult.SetParameter(2, 3.56042e-03); corrFuncMult.SetParameter(3, 1.47497e-02); corrFuncMult.SetParameter(4, 0.); corrFuncMultTanTheta.SetParameter(0, 8.53204e-08); corrFuncMultTanTheta.SetParameter(1, 2.85591e-06); corrFuncMultTanTheta.SetParameter(2, -0.5); corrFuncSigmaMult.SetParameter(0, -6.82477e-06); corrFuncSigmaMult.SetParameter(1, 4.97051e-03); corrFuncSigmaMult.SetParameter(2, -1.64954e-01); corrFuncSigmaMult.SetParameter(3, 9.21061e-03); */ //TODO NOW TF1* fShapeSmallP = new TF1("fShapeSmallP", "pol5", -0.4, 0.4); fShapeSmallP->SetParameters(1.01712, -0.0202725, -0.260692, 0.261623, 0.671854, -1.14014); for (Long64_t i = 0; i < nTreeEntries; i++) { tree->GetEntry(i); if (dEdx <= 0 || dEdxExpected <= 0 || tpcSignalN <= 10) continue; /* Double_t pT = pTPC*TMath::Sin(-TMath::ATan(tanTheta)+TMath::Pi()/2.0); if ((phiPrime > 0.072/pT+TMath::Pi()/18.0-0.035 && phiPrime < 0.07/pT/pT+0.1/pT+TMath::Pi()/18.0+0.035)) continue; */ if (pidType != kMCid) { if (pidType == kTPCid && pTPC > 0.6) continue; if (pidType == kTPCandTOFid && (pTPC < 0.6 || pTPC > 2.0)) continue; if ((collType == 2) && pidType == kTPCandTOFid && pTPC > 1.0) continue;// Only V0's in case of PbPb above 1.0 GeV/c if (pidType == kV0idPlusTOFrejected) //TODO NOW NEW continue; } if (recalculateExpecteddEdx) { dEdxExpected = 50. * splPr->Eval(pTPC / massProton); //WARNING: What, if MIP is different from 50.? Seems not to be used (tested for pp, MC_pp, PbPb and MC_PbPb), but can in principle happen } //TODO NOW /* if (TMath::Abs(tanTheta) <= 0.4) { Double_t p0 = fShapeSmallP->Eval(tanTheta) - 1.0; // Strength of the correction Double_t p1 = -9.0; // How fast the correction is turned off Double_t p2 = -0.209; // Turn off correction around 0.2 GeV/c Double_t p3 = 1.0; // Delta' for large p should be 1 Double_t corrFactor = TMath::Erf((pTPC + p2) * p1) * p0 + p3 + p0; // Add p0 to have 1 for p3 = 1 and large pTPC dEdxExpected *= corrFactor; }*/ /*TODO old unsuccessful try Double_t thetaGlobalTPC = -TMath::ATan(tanTheta) + TMath::Pi() / 2.; Double_t pTtpc = pTPC * TMath::Sin(thetaGlobalTPC); Double_t pTtpcInv = (pTtpc > 0) ? 1. / pTtpc : 0; Double_t p0 = 1.0; Double_t p1 = 1./ 0.5;//TODO 2.0; Double_t p2 = -0.2;//TODO 0.1 Double_t pTcorrFactor = p0 + (pTtpcInv > p1) * p2 * (pTtpcInv - p1); dEdxExpected *= pTcorrFactor; */ // From the momentum (via dEdxExpected) and the tanTheta of the track, the expected dEdx can be calculated (correctedDeDxExpected). // If the splines are correct, this should give in average the same value as dEdx. // Now valid: Maps created from corrected data with splines adopted to corrected data, so lookup should be for dEdxExpected=dEdxSplines (no further // eta correction) or the corrected dEdx from the track (which should ideally be = dEdxSplines) // Tested with corrected data for LHC10d.pass2: using dEdx for the lookup (which is the corrected value and should ideally be = dEdxSplines): // Results almost the same. Maybe slightly better for dEdxExpected. // No longer valid: Note that the maps take always the uncorrected dEdx w.r.t. // tanTheta, so that correctedDeDxExpected is needed here normally. However, the information for the correction will be lost at some point. // Therefore, dEdxExpected can be used instead and should provide a good approximation. Double_t c1FromSigmaMap = hThetaMapSigmaPar1->GetBinContent(getBinX(hThetaMapSigmaPar1, tanTheta), getBinY(hThetaMapSigmaPar1, 1./dEdxExpected)); Double_t expectedSigma = dEdxExpected * TMath::Sqrt( c0 * c0 + (c1FromSigmaMap * c1FromSigmaMap) / tpcSignalN); Double_t pull = (dEdx - dEdxExpected) / (plotPull ? expectedSigma: dEdxExpected); // Fill pull histo hPull->Fill(pTPC, pull); Double_t tanThetaAbs = TMath::Abs(tanTheta); for (Int_t j = 0; j < nThetaHistos; j++) { if (tanThetaAbs >= tThetaLow[j] && tanThetaAbs < tThetaHigh[j]) { hPullTheta[j]->Fill(pTPC, pull); } } if (!hMap) continue; Double_t correctionFactor = 1.; if (isNonPP) { // 1. Correct eta dependence correctionFactor = hMap->GetBinContent(getBinX(hMap, tanTheta), getBinY(hMap, 1./dEdxExpected)); // 2. Correct for multiplicity dependence: Double_t multCorrectionFactor = 1.; if (fMultiplicity > 0) { Double_t relSlope = corrFuncMult.Eval(1. / (dEdxExpected * correctionFactor)); relSlope += corrFuncMultTanTheta.Eval(tanTheta); multCorrectionFactor = 1. + relSlope * fMultiplicity; } c1FromSigmaMap = hThetaMapSigmaPar1->GetBinContent(getBinX(hThetaMapSigmaPar1, tanTheta), getBinY(hThetaMapSigmaPar1, 1./dEdxExpected)); // Multiplicity dependence of sigma depends on the real dEdx at zero multiplicity, i.e. the eta (only) corrected dEdxExpected value has to be used // since all maps etc. have been created for ~zero multiplicity Double_t relSigmaSlope = corrFuncSigmaMult.Eval(1. / (dEdxExpected * correctionFactor)); Double_t multSigmaCorrectionFactor = 1. + relSigmaSlope * fMultiplicity; dEdxExpected *= correctionFactor * multCorrectionFactor; expectedSigma = dEdxExpected * TMath::Sqrt( c0 * c0 + (c1FromSigmaMap * c1FromSigmaMap) / tpcSignalN); expectedSigma *= multSigmaCorrectionFactor; pull = (dEdx - dEdxExpected) / (plotPull ? expectedSigma: dEdxExpected); } else { correctionFactor = hMap->GetBinContent(getBinX(hMap, tanTheta), getBinY(hMap, 1./dEdxExpected)); c1FromSigmaMap = hThetaMapSigmaPar1->GetBinContent(getBinX(hThetaMapSigmaPar1, tanTheta), getBinY(hThetaMapSigmaPar1, 1./dEdxExpected)); dEdxExpected *= correctionFactor; // If data is not corrected, but the sigma map is for corrected data, re-do analysis with corrected dEdx expectedSigma = dEdxExpected * TMath::Sqrt( c0 * c0 + (c1FromSigmaMap * c1FromSigmaMap) / tpcSignalN); pull = (dEdx - dEdxExpected) / (plotPull ? expectedSigma: dEdxExpected); } pull = (dEdx - dEdxExpected) / (plotPull ? expectedSigma: dEdxExpected); hPullAdditionalCorr->Fill(pTPC, pull); for (Int_t j = 0; j < nThetaHistos; j++) { if (tanThetaAbs >= tThetaLow[j] && tanThetaAbs < tThetaHigh[j]) { hPullAdditionalCorrTheta[j]->Fill(pTPC, pull); } } } /* // Mean, Sigma, chi^2/NDF of pull of different theta bins and all in one plot TCanvas* canvPullMean = new TCanvas("canvPullMean", "canvPullMean", 100,10,1380,800); canvPullMean->SetLogx(kTRUE); canvPullMean->SetGridx(kTRUE); canvPullMean->SetGridy(kTRUE); TCanvas* canvPullSigma = new TCanvas("canvPullSigma", "canvPullSigma", 100,10,1380,800); canvPullSigma->SetLogx(kTRUE); canvPullSigma->SetGridx(kTRUE); canvPullSigma->SetGridy(kTRUE); TCanvas* canvPullChi2 = new TCanvas("canvPullChi2", "canvPullChi2", 100,10,1380,800); canvPullChi2->SetLogx(kTRUE); canvPullChi2->SetGridx(kTRUE); canvPullChi2->SetGridy(kTRUE); TCanvas* canvPull[nThetaHistos + 1]; for (Int_t i = 0, j = nThetaHistos; i < nThetaHistos + 1; i++, j--) { canvPull[i] = new TCanvas(Form("canvPull_%d", i), "canvPull", 100,10,1380,800); canvPull[i]->cd(); canvPull[i]->SetLogx(kTRUE); canvPull[i]->SetLogz(kTRUE); canvPull[i]->SetGrid(kTRUE, kTRUE); TH2D* hTemp = 0x0; TString thetaString = ""; if (i == nThetaHistos) { hTemp = hPull; thetaString = "tan(#Theta) integrated"; } else { hTemp = hPullTheta[i]; thetaString = Form("%.2f #leq |tan(#Theta)| < %.2f", tThetaLow[i], tThetaHigh[i]); } normaliseHisto(hTemp); hTemp->FitSlicesY(); hTemp->GetYaxis()->SetNdivisions(12); hTemp->GetXaxis()->SetMoreLogLabels(kTRUE); TH1D* hTempMean = (TH1D*)gDirectory->Get(Form("%s_1", hTemp->GetName())); hTempMean->SetTitle(Form("mean(pull), %s", thetaString.Data())); hTempMean->GetXaxis()->SetMoreLogLabels(kTRUE); hTempMean->SetLineWidth(2); hTempMean->SetMarkerStyle(20); TH1D* hTempSigma = (TH1D*)gDirectory->Get(Form("%s_2", hTemp->GetName())); hTempSigma->SetTitle(Form("#sigma(pull), %s", thetaString.Data())); hTempSigma->GetXaxis()->SetMoreLogLabels(kTRUE); hTempSigma->SetLineColor(kMagenta); hTempSigma->SetMarkerStyle(20); hTempSigma->SetMarkerColor(kMagenta); hTempSigma->SetLineWidth(2); TH1D* hTempChi2 = (TH1D*)gDirectory->Get(Form("%s_chi2", hTemp->GetName())); hTempChi2->SetTitle(Form("#chi^{2} / NDF (pull), %s", thetaString.Data())); hTempChi2->GetXaxis()->SetMoreLogLabels(kTRUE); hTempChi2->SetLineColor(kMagenta + 2); hTempChi2->SetMarkerStyle(20); hTempChi2->SetMarkerColor(kMagenta + 2); hTempChi2->SetLineWidth(2); hTemp->DrawCopy("colz"); hTempMean->DrawCopy("same"); hTempSigma->DrawCopy("same"); hTempChi2->Scale(-1./10.); hTempChi2->DrawCopy("same"); hTempChi2->Scale(-10.); canvPullMean->cd(); hTempMean->SetLineColor(1 + ((j >= 9) ? (39 + 2 * (j - 9)) : j)); hTempMean->SetMarkerColor(1 + ((j >= 9) ? (39 + 2 * (j - 9)) : j)); hTempMean->DrawCopy((i == 0 ? "" : "same")); canvPullSigma->cd(); hTempSigma->SetLineColor(1 + ((j >= 9) ? (39 + 2 * (j - 9)) : j)); hTempSigma->SetMarkerColor(1 + ((j >= 9) ? (39 + 2 * (j - 9)) : j)); hTempSigma->DrawCopy((i == 0 ? "" : "same")); canvPullChi2->cd(); hTempChi2->SetLineColor(1 + ((j >= 9) ? (39 + 2 * (j - 9)) : j)); hTempChi2->SetMarkerColor(1 + ((j >= 9) ? (39 + 2 * (j - 9)) : j)); hTempChi2->DrawCopy((i == 0 ? "" : "same")); } canvPullMean->BuildLegend(); canvPullSigma->BuildLegend(); canvPullChi2->BuildLegend(); */ // Histograms with additional correction TCanvas* canvPullMeanCorr = 0x0; TCanvas* canvPullSigmaCorr = 0x0; TCanvas* canvPullChi2Corr = 0x0; TCanvas* canvPullCorr[nThetaHistos + 1]; for (Int_t i = 0; i < nThetaHistos + 1; i++) canvPullCorr[i] = 0x0; if (hMap) { // Mean, Sigma, chi^2/NDF of pull of different theta bins and all in one plot canvPullMeanCorr = new TCanvas("canvPullMeanCorr", "canvPullMeanCorr", 100,10,1380,800); canvPullMeanCorr->SetLogx(kTRUE); canvPullMeanCorr->SetGridx(kTRUE); canvPullMeanCorr->SetGridy(kTRUE); canvPullSigmaCorr = new TCanvas("canvPullSigmaCorr", "canvPullSigmaCorr", 100,10,1380,800); canvPullSigmaCorr->SetLogx(kTRUE); canvPullSigmaCorr->SetGridx(kTRUE); canvPullSigmaCorr->SetGridy(kTRUE); canvPullChi2Corr = new TCanvas("canvPullChi2Corr", "canvPullChi2Corr", 100,10,1380,800); canvPullChi2Corr->SetLogx(kTRUE); canvPullChi2Corr->SetGridx(kTRUE); canvPullChi2Corr->SetGridy(kTRUE); for (Int_t i = 0, j = nThetaHistos; i < nThetaHistos + 1; i++, j--) { canvPullCorr[i] = new TCanvas(Form("canvPullCorr_%d", i), "canvPullCorr", 100,10,1380,800); canvPullCorr[i]->cd(); canvPullCorr[i]->SetLogx(kTRUE); canvPullCorr[i]->SetLogz(kTRUE); canvPullCorr[i]->SetGrid(kTRUE, kTRUE); TH2D* hTemp = 0x0; TString thetaString = ""; if (i == nThetaHistos) { hTemp = hPullAdditionalCorr; thetaString = "tan(#Theta) integrated"; } else { hTemp = hPullAdditionalCorrTheta[i]; thetaString = Form("%.2f #leq |tan(#Theta)| < %.2f", tThetaLow[i], tThetaHigh[i]); } normaliseHisto(hTemp); hTemp->FitSlicesY(); hTemp->GetYaxis()->SetNdivisions(12); hTemp->GetXaxis()->SetMoreLogLabels(kTRUE); TH1D* hTempMean = (TH1D*)gDirectory->Get(Form("%s_1", hTemp->GetName())); hTempMean->SetTitle(Form("mean(pull), %s", thetaString.Data())); hTempMean->GetXaxis()->SetMoreLogLabels(kTRUE); hTempMean->SetLineWidth(2); hTempMean->SetMarkerStyle(20); TH1D* hTempSigma = (TH1D*)gDirectory->Get(Form("%s_2", hTemp->GetName())); hTempSigma->SetTitle(Form("#sigma(pull), %s", thetaString.Data())); hTempSigma->GetXaxis()->SetMoreLogLabels(kTRUE); hTempSigma->SetLineColor(kMagenta); hTempSigma->SetMarkerStyle(20); hTempSigma->SetMarkerColor(kMagenta); hTempSigma->SetLineWidth(2); TH1D* hTempChi2 = (TH1D*)gDirectory->Get(Form("%s_chi2", hTemp->GetName())); hTempChi2->SetTitle(Form("#chi^{2} / NDF (pull), %s", thetaString.Data())); hTempChi2->GetXaxis()->SetMoreLogLabels(kTRUE); hTempChi2->SetLineColor(kMagenta + 2); hTempChi2->SetMarkerStyle(20); hTempChi2->SetMarkerColor(kMagenta + 2); hTempChi2->SetLineWidth(2); hTemp->DrawCopy("colz"); hTempMean->DrawCopy("same"); hTempSigma->DrawCopy("same"); hTempChi2->Scale(-1./10.); hTempChi2->DrawCopy("same"); hTempChi2->Scale(-10.); canvPullMeanCorr->cd(); hTempMean->SetLineColor(1 + ((j >= 9) ? (39 + 2 * (j - 9)) : j)); hTempMean->SetMarkerColor(1 + ((j >= 9) ? (39 + 2 * (j - 9)) : j)); hTempMean->DrawCopy((i == 0 ? "" : "same")); canvPullSigmaCorr->cd(); hTempSigma->SetLineColor(1 + ((j >= 9) ? (39 + 2 * (j - 9)) : j)); hTempSigma->SetMarkerColor(1 + ((j >= 9) ? (39 + 2 * (j - 9)) : j)); hTempSigma->DrawCopy((i == 0 ? "" : "same")); canvPullChi2Corr->cd(); hTempChi2->SetLineColor(1 + ((j >= 9) ? (39 + 2 * (j - 9)) : j)); hTempChi2->SetMarkerColor(1 + ((j >= 9) ? (39 + 2 * (j - 9)) : j)); hTempChi2->DrawCopy((i == 0 ? "" : "same")); } canvPullMeanCorr->BuildLegend(); canvPullSigmaCorr->BuildLegend(); canvPullChi2Corr->BuildLegend(); } fSave->cd(); /*canvPullMean->Write(); canvPullSigma->Write(); canvPullChi2->Write(); for (Int_t i = 0; i < nThetaHistos + 1; i++) { canvPull[i]->Write(); }*/ canvPullMeanCorr->Write(); canvPullSigmaCorr->Write(); canvPullChi2Corr->Write(); for (Int_t i = 0; i < nThetaHistos + 1; i++) { canvPullCorr[i]->Write(); } TNamed* info = new TNamed(Form("Theta map: %s\n\nSigma map: %s\n\nSplines file: %s\n\nSplines name: %s", pathNameThetaMap.Data(), pathNameSigmaMap.Data(), pathNameSplinesFile.Data(), prSplinesName.Data()), "info"); info->Write(); fSave->Close(); return 0; }
int makesigback(){ TFile * infile = new TFile("../root/combo115.root"); // TFile * infile = new TFile("../root/combo160.root"); Int_t type1 = 1; Int_t type2 = 0; Double_t weight; Int_t switchpoint; TTree * intree = (TTree*)infile->Get("combotree"); TTree * inmeta = (TTree*)infile->Get("metadata"); inmeta->SetBranchAddress("BeginIndex", &switchpoint); inmeta->GetEntry(2); cout << switchpoint << endl; TObjArray* lob = intree->GetListOfBranches(); intree->SetBranchStatus("*",0); for (Int_t i = 0; i < lob->GetEntriesFast(); ++i) { TBranch * branch = (TBranch *)lob->At(i); string bname = string(branch -> GetName()); if(string(bname).compare(0,4,"type")){ if (bname == "weight") { continue; } intree->SetBranchStatus(bname.c_str(),1); } } TFile *newfile = new TFile("../root/combo115sb.root","recreate"); TTree *newtree = intree->CloneTree(0); newtree->Branch("type1", &type1); newtree->Branch("type2", &type2); newtree->Branch("weight", &weight); weight = (1. / Double_t(switchpoint) ); for (UInt_t j = 0; j < intree->GetEntriesFast(); ++j) { if (j == switchpoint) { type1 = 0; type2 = 1; weight = (1. / Double_t(intree->GetEntriesFast() - switchpoint) ); } intree->GetEntry(j); newtree->Fill(); } Int_t newbegin; Int_t newend; TString newchannelname; TTree * newmeta = new TTree("metadata", "metadata"); newmeta->Branch("BeginIndex", &newbegin); newmeta->Branch("EndIndex", &newend); newmeta->Branch("ChannelName",&newchannelname,256000,0); newbegin = 0; newend = switchpoint - 1; newchannelname = "signal"; newmeta->Fill(); newbegin = switchpoint; newend = (intree->GetEntriesFast()) - 1; newchannelname = "backgr"; newmeta->Fill(); newfile->Write(); delete infile; delete newfile; // vector <TFile*> files; // vector <TTree*> trees; // vector < vector<Double_t> > Int_lum; // vector <TFile*> outfiles; // vector <TTree*> outtrees; // vector <string> names; // Int_lum.resize(15); // Int_lum[0].push_back(7852.); // Int_lum[1].push_back(3831.); // Int_lum[2].push_back(36823.); // Int_lum[3].push_back(11400.); // Int_lum[4].push_back(10.4); // Int_lum[5].push_back(8.4); // Int_lum[6].push_back(47.2); // Int_lum[7].push_back(6.28); // Int_lum[8].push_back(7.94); // Int_lum[9].push_back(18.1); // Int_lum[10].push_back(2562.); // Int_lum[11].push_back(243.); // Int_lum[12].push_back(3483.); // Int_lum[13].push_back(3483.); // Int_lum[14].push_back(331.); // names.push_back("AH115"); // names.push_back("AH115bb"); // names.push_back("AH160"); // names.push_back("AH160bb"); // names.push_back("QCD_BCtoE_Pt20to30"); // names.push_back("QCD_BCtoE_Pt30to80"); // names.push_back("QCD_BCtoE_Pt80to170"); // names.push_back("QCD_EMenriched_Pt20to30"); // names.push_back("QCD_EMenriched_Pt30to80"); // names.push_back("QCD_EMenriched_Pt80to170"); // names.push_back("TTplusJets"); // names.push_back("WplusJets"); // names.push_back("Zbb"); // names.push_back("Zcc"); // names.push_back("ZplusJets"); // for (UInt_t i = 0; i < names.size(); ++i) { // files.push_back(new TFile( ("../root/oldroot/"+names[i]+".root").c_str() )); // trees.push_back( (TTree*)files[i]->Get("bbAHCutTree") ); // outfiles.push_back(new TFile ( ("../root/"+names[i]+".root").c_str() , "RECREATE")); // outtrees.push_back( trees[i]->CloneTree(0) ); // outtrees[i]->Branch("intlum", &(Int_lum[i])); // for (UInt_t j = 0; j < trees[i]->GetEntriesFast(); ++j) { // trees[i]->GetEntry(j); // outtrees[i]->Fill(); // } // outfiles[i]->Write(); // } return 0; }
void plotLimit(TString outputDir="./", TString inputs="", TString inputXSec="", bool strengthLimit=true, bool blind=false, double energy=7, double luminosity=5.035, TString legendName="ee and #mu#mu channels") { //style options gStyle->SetCanvasBorderMode(0); gStyle->SetCanvasColor(kWhite); gStyle->SetFrameBorderMode(0); gStyle->SetFrameBorderSize(1); gStyle->SetFrameFillColor(0); gStyle->SetFrameFillStyle(0); gStyle->SetFrameLineColor(1); gStyle->SetFrameLineStyle(1); gStyle->SetFrameLineWidth(1); gStyle->SetOptFit(1); gStyle->SetFitFormat("5.4g"); gStyle->SetFuncColor(2); gStyle->SetOptFile(0); //gStyle->SetOptStat(0); gStyle->SetOptStat("mr"); gStyle->SetStatColor(kWhite); gStyle->SetStatFont(42); gStyle->SetStatFontSize(0.04); gStyle->SetStatTextColor(1); gStyle->SetStatFormat("6.4g"); gStyle->SetStatBorderSize(1); gStyle->SetStatH(0.1); gStyle->SetStatW(0.2); gStyle->SetPadTopMargin(0.05); gStyle->SetPadBottomMargin(0.13); gStyle->SetPadLeftMargin(0.16); gStyle->SetPadRightMargin(0.02); gStyle->SetOptTitle(0); gStyle->SetTitleFont(42); gStyle->SetTitleColor(1); gStyle->SetTitleTextColor(1); gStyle->SetTitleFillColor(10); gStyle->SetTitleFontSize(0.05); gStyle->SetAxisColor(1, "XYZ"); gStyle->SetStripDecimals(kTRUE); gStyle->SetTickLength(0.03, "XYZ"); gStyle->SetNdivisions(510, "XYZ"); gStyle->SetPadTickX(1); // To get tick marks on the opposite side of the frame gStyle->SetPadTickY(1); gStyle->SetEndErrorSize(2); gStyle->SetErrorX(0.); gStyle->SetMarkerStyle(20); gROOT->ForceStyle(); gStyle->SetPadTopMargin (0.06); gStyle->SetPadBottomMargin(0.12); gStyle->SetPadRightMargin (0.06); gStyle->SetPadLeftMargin (0.14); gStyle->SetTitleSize(0.04, "XYZ"); gStyle->SetTitleXOffset(1.1); gStyle->SetTitleYOffset(1.45); gStyle->SetPalette(1); gStyle->SetNdivisions(505); string suffix = string(outputDir.Data()); double cprime=1.0; double brnew=0.0; double XSecScaleFactor = 1.0; if(suffix.find("_cp")!=string::npos){ sscanf(suffix.c_str()+suffix.find("_cp"), "_cp%lf_brn%lf", &cprime, &brnew); XSecScaleFactor = pow(cprime,2) * (1-brnew); } //get xsec * br from summary file getXSecXBR(inputXSec); //get the limits from the tree TFile* file = TFile::Open(inputs); printf("Looping on %s\n",inputs.Data()); if(!file) return; if(file->IsZombie()) return; TTree* tree = (TTree*)file->Get("limit"); tree->GetBranch("mh" )->SetAddress(&Tmh ); tree->GetBranch("limit" )->SetAddress(&Tlimit ); tree->GetBranch("limitErr" )->SetAddress(&TlimitErr); tree->GetBranch("quantileExpected")->SetAddress(&TquantExp); int N = tree->GetEntriesFast() / 6 ;// 6Limits per mass point (observed, meand , +-1sigma, +-2sigma) double* MassAxis = new double[N]; double* ObsLimit = new double[N]; fillLimitArray(tree,-1 ,ObsLimit,MassAxis); if(!strengthLimit)scaleLimitsByXSecXBR(N, MassAxis, ObsLimit); double* ExpLimitm2 = new double[N]; fillLimitArray(tree,0.025,ExpLimitm2); if(!strengthLimit)scaleLimitsByXSecXBR(N, MassAxis, ExpLimitm2); double* ExpLimitm1 = new double[N]; fillLimitArray(tree,0.160,ExpLimitm1); if(!strengthLimit)scaleLimitsByXSecXBR(N, MassAxis, ExpLimitm1); double* ExpLimit = new double[N]; fillLimitArray(tree,0.500,ExpLimit ); if(!strengthLimit)scaleLimitsByXSecXBR(N, MassAxis, ExpLimit); double* ExpLimitp1 = new double[N]; fillLimitArray(tree,0.840,ExpLimitp1); if(!strengthLimit)scaleLimitsByXSecXBR(N, MassAxis, ExpLimitp1); double* ExpLimitp2 = new double[N]; fillLimitArray(tree,0.975,ExpLimitp2); if(!strengthLimit)scaleLimitsByXSecXBR(N, MassAxis, ExpLimitp2); file->Close(); //make TH Cross-sections double* ThXSec = new double[N]; for(unsigned int i=0;i<N;i++){ThXSec[i] = xsecXbr[MassAxis[i]];} //scale TH cross-section and limits according to scale factor //this only apply to NarrowResonnance case for(unsigned int i=0;i<N;i++){ if(strengthLimit){ ObsLimit[i] /= XSecScaleFactor; ExpLimitm2[i]/= XSecScaleFactor; ExpLimitm1[i]/= XSecScaleFactor; ExpLimit [i]/= XSecScaleFactor; ExpLimitp1[i]/= XSecScaleFactor; ExpLimitp2[i]/= XSecScaleFactor; } ThXSec[i] *= XSecScaleFactor; } //limits in terms of signal strength TCanvas* c = new TCanvas("c", "c",600,600); TH1F* framework = new TH1F("Graph","Graph",1,15,70); framework->SetStats(false); framework->SetTitle(""); framework->GetXaxis()->SetTitle("A boson mass [GeV]"); framework->GetYaxis()->SetTitleOffset(1.70); if(strengthLimit){ framework->GetYaxis()->SetTitle("#mu = #sigma_{95%} / #sigma_{th}"); framework->GetYaxis()->SetRangeUser(5E-2,5E1); c->SetLogy(true); }else{ framework->GetYaxis()->SetTitle("#sigma_{95%} (fb)"); framework->GetYaxis()->SetRangeUser(1E-1,1E3); c->SetLogy(true); } framework->Draw(); TGraph* TGObsLimit = new TGraph(N,MassAxis,ObsLimit); TGObsLimit->SetLineWidth(2); TGraph* TGExpLimit = new TGraph(N,MassAxis,ExpLimit); TGExpLimit->SetLineWidth(2); TGExpLimit->SetLineStyle(2); TCutG* TGExpLimit1S = GetErrorBand("1S", N, MassAxis, ExpLimitm1, ExpLimitp1); TCutG* TGExpLimit2S = GetErrorBand("2S", N, MassAxis, ExpLimitm2, ExpLimitp2); TGExpLimit2S->SetFillColor(5); TGraph* THXSec = new TGraph(N,MassAxis,ThXSec); THXSec->SetLineWidth(2); THXSec->SetLineStyle(1); THXSec->SetLineColor(4); TGExpLimit->SetLineColor(2); TGExpLimit->SetLineStyle(1); TGObsLimit->SetLineWidth(2); TGObsLimit->SetMarkerStyle(20); TGExpLimit2S->Draw("fc same"); TGExpLimit1S->Draw("fc same"); if(!blind) TGObsLimit->Draw("same CP"); TGExpLimit->Draw("same C"); if(strengthLimit){ TLine* SMLine = new TLine(framework->GetXaxis()->GetXmin(),1.0,framework->GetXaxis()->GetXmax(),1.0); SMLine->SetLineWidth(2); SMLine->SetLineStyle(1); SMLine->SetLineColor(4); SMLine->Draw("same C"); }else{ THXSec->Draw("same C"); } TPaveText *pave = new TPaveText(0.1,0.96,0.99,0.99,"NDC"); char LumiLabel[1024]; if(energy<9){ sprintf(LumiLabel,"CMS preliminary, #sqrt{s}=%.0f TeV, #scale[0.5]{#int} L=%6.1ffb^{-1} - %20s",energy, luminosity,legendName.Data()); }else{ sprintf(LumiLabel,"CMS preliminary, #sqrt{s}=%.0f TeV #scale[0.5]{#int} L=%6.1ffb^{-1}, #sqrt{s}=%.0f TeV #scale[0.5]{#int} L=%6.1ffb^{-1}",7.0,5.0,8.0,19.7); } pave->SetBorderSize(0); pave->SetFillStyle(0); pave->SetTextFont(42); TObjArray* tokens = (TString(LumiLabel)).Tokenize("\\\\"); int nt = tokens->GetEntries(); for(int it=0; it<nt; ++it){ TObjString * t = (TObjString *)tokens->At(it); pave->AddText(t->GetString()); } pave->Draw("same"); TLegend* LEG = new TLegend(0.55,0.75,0.85,0.95); LEG->SetHeader("Signal XSec x 1000"); LEG->SetFillColor(0); LEG->SetFillStyle(0); LEG->SetTextFont(42); LEG->SetBorderSize(0); LEG->AddEntry(THXSec , "TH prediction" ,"L"); LEG->AddEntry(TGExpLimit , "median expected" ,"L"); LEG->AddEntry(TGExpLimit1S , "expected #pm 1#sigma" ,"F"); LEG->AddEntry(TGExpLimit2S , "expected #pm 2#sigma" ,"F"); if(!blind) LEG->AddEntry(TGObsLimit , "observed" ,"LP"); LEG->Draw(); c->RedrawAxis(); c->SaveAs(outputDir+"Limit.png"); c->SaveAs(outputDir+"Limit.C"); c->SaveAs(outputDir+"Limit.pdf"); //save a summary of the limits FILE* pFileSum = fopen((outputDir+"LimitSummary").Data(),"w"); for(int i=0;i<N;i++){ fprintf(pFileSum, "$%8.6E$ & $%8.6E$ & $[%8.6E,%8.6E]$ & $[%8.6E,%8.6E]$ & $%8.6E$ & Th=$%8.6E$\\\\\\hline\n",MassAxis[i], ExpLimit[i], ExpLimitm1[i], ExpLimitp1[i], ExpLimitm2[i], ExpLimitp2[i], ObsLimit[i], ThXSec[i]); if(int(MassAxis[i])%50!=0)continue; printf("%f ",ObsLimit[i]); }printf("\n"); fclose(pFileSum); pFileSum = fopen((outputDir+"LimitRange").Data(),"w"); fprintf(pFileSum, "EXPECTED LIMIT --> "); printLimits(pFileSum,TGExpLimit, MassAxis[0], MassAxis[N-1]); if(!blind) fprintf(pFileSum, "OBSERVED LIMIT --> "); printLimits(pFileSum,TGObsLimit, MassAxis[0], MassAxis[N-1]); fprintf(pFileSum, "Exp Limits for Model are: "); for(int i=0;i<N;i++){if(int(MassAxis[i])%50!=0)continue; fprintf(pFileSum, "%f+-%f ",ExpLimit[i], (ExpLimitp1[i]-ExpLimitm1[i]))/2.0;}fprintf(pFileSum,"\n"); if(!blind) { fprintf(pFileSum, "Obs Limits for Model are: "); for(int i=0;i<N;i++){if(int(MassAxis[i])%50!=0)continue; fprintf(pFileSum, "%f ",ObsLimit[i]);}fprintf(pFileSum,"\n"); } fclose(pFileSum); }
void compClusHitsMod2(int nev=-1) { const int kSplit=0x1<<22; const int kSplCheck=0x1<<23; // gSystem->Load("libITSUpgradeBase"); gSystem->Load("libITSUpgradeSim"); gSystem->Load("libITSUpgradeRec"); gROOT->SetStyle("Plain"); AliCDBManager* man = AliCDBManager::Instance(); man->SetDefaultStorage("local://$ALICE_ROOT/OCDB"); man->SetSpecificStorage("GRP/GRP/Data", Form("local://%s",gSystem->pwd())); man->SetSpecificStorage("ITS/Align/Data", Form("local://%s",gSystem->pwd())); man->SetSpecificStorage("ITS/Calib/RecoParam", Form("local://%s",gSystem->pwd())); man->SetRun(0); TH1F* hL0A = new TH1F("hL0A", "Layer 0, polar angle", 20, 0, TMath::PiOver2()); hL0A->SetDirectory(0); hL0A->GetXaxis()->SetTitle("#alpha"); TH1F* hL0B = new TH1F("hL0B", "Layer 0, azimuthal angle", 20, 0, TMath::PiOver2()); hL0B->SetDirectory(0); hL0B->GetXaxis()->SetTitle("#beta"); TH1F* hL1A = new TH1F("hL1A", "Layer 1, polar angle", 20, 0, TMath::PiOver2()); hL1A->SetDirectory(0); hL1A->GetXaxis()->SetTitle("#alpha"); TH1F* hL1B = new TH1F("hL1B", "Layer 1, azimuthal angle", 20, 0, TMath::PiOver2()); hL1B->SetDirectory(0); hL1B->GetXaxis()->SetTitle("#beta"); TH1F* hL2A = new TH1F("hL2A", "Layer 2, polar angle", 20, 0, TMath::PiOver2()); hL2A->SetDirectory(0); hL2A->GetXaxis()->SetTitle("#alpha"); TH1F* hL2B = new TH1F("hL2B", "Layer 2, azimuthal angle", 20, 0, TMath::PiOver2()); hL2B->SetDirectory(0); hL2B->GetXaxis()->SetTitle("#beta"); TH1F* hL3A = new TH1F("hL3A", "Layer 3, polar angle", 20, 0, TMath::PiOver2()); hL3A->SetDirectory(0); hL3A->GetXaxis()->SetTitle("#alpha"); TH1F* hL3B = new TH1F("hL3B", "Layer 3, azimuthal angle", 20, 0, TMath::PiOver2()); hL3B->SetDirectory(0); hL3B->GetXaxis()->SetTitle("#beta"); TH1F* hL4A = new TH1F("hL4A", "Layer 4, polar angle", 20, 0, TMath::PiOver2()); hL4A->SetDirectory(0); hL4A->GetXaxis()->SetTitle("#alpha"); TH1F* hL4B = new TH1F("hL4B", "Layer 4, azimuthal angle", 20, 0, TMath::PiOver2()); hL4B->SetDirectory(0); hL4B->GetXaxis()->SetTitle("#beta"); TH1F* hL5A = new TH1F("hL5A", "Layer 5, polar angle", 20, 0, TMath::PiOver2()); hL5A->SetDirectory(0); hL5A->GetXaxis()->SetTitle("#alpha"); TH1F* hL5B = new TH1F("hL5B", "Layer 5, azimuthal angle", 20, 0, TMath::PiOver2()); hL5B->SetDirectory(0); hL5B->GetXaxis()->SetTitle("#beta"); TH1F* hL6A = new TH1F("hL6A", "Layer 6, polar angle", 20, 0, TMath::PiOver2()); hL6A->SetDirectory(0); hL6A->GetXaxis()->SetTitle("#alpha"); TH1F* hL6B = new TH1F("hL6B", "Layer 6, azimuthal angle", 20, 0, TMath::PiOver2()); hL6B->SetDirectory(0); hL6B->GetXaxis()->SetTitle("#beta"); gAlice=NULL; AliRunLoader* runLoader = AliRunLoader::Open("galice.root"); runLoader->LoadgAlice(); gAlice = runLoader->GetAliRun(); runLoader->LoadHeader(); runLoader->LoadKinematics(); runLoader->LoadRecPoints(); runLoader->LoadSDigits(); runLoader->LoadHits(); AliLoader *dl = runLoader->GetDetectorLoader("ITS"); AliGeomManager::LoadGeometry("geometry.root"); TObjArray algITS; AliGeomManager::LoadAlignObjsFromCDBSingleDet("ITS",algITS); AliGeomManager::ApplyAlignObjsToGeom(algITS); // AliITSUGeomTGeo* gm = new AliITSUGeomTGeo(kTRUE); AliITSMFTClusterPix::SetGeom(gm); // AliITSURecoDet *its = new AliITSURecoDet(gm, "ITSinterface"); its->CreateClusterArrays(); // Double_t xg1,yg1,zg1=0.,xg0,yg0,zg0=0.,tg0; Double_t xExit,yExit,zExit,xEnt,yEnt,zEnt,tof1; // TTree *cluTree = 0x0; TTree *hitTree = 0x0; TClonesArray *hitList=new TClonesArray("AliITSMFTHit"); // Float_t xyzClGloF[3]; Double_t xyzClGlo[3],xyzClTr[3]; Int_t labels[3]; int nLab = 0; int nlr=its->GetNLayersActive(); int ntotev = (Int_t)runLoader->GetNumberOfEvents(); printf("N Events : %i \n",ntotev); if (nev>0) ntotev = TMath::Min(nev,ntotev); // // output tree TFile* flOut = TFile::Open("clInfo.root","recreate"); TTree* trOut = new TTree("clitsu","clitsu"); clSumm cSum; trOut->Branch("evID", &cSum.evID ,"evID/I"); trOut->Branch("volID",&cSum.volID,"volID/I"); trOut->Branch("lrID", &cSum.lrID ,"lrID/I"); trOut->Branch("clID", &cSum.clID ,"clID/I"); trOut->Branch("nPix", &cSum.nPix ,"nPix/I"); trOut->Branch("nX" , &cSum.nX ,"nX/I"); trOut->Branch("nZ" , &cSum.nZ ,"nZ/I"); trOut->Branch("q" , &cSum.q ,"q/I"); trOut->Branch("pt" , &cSum.pt ,"pt/F"); trOut->Branch("eta" ,&cSum.eta ,"eta/F"); trOut->Branch("phi" , &cSum.phi ,"phi/F"); trOut->Branch("xyz", cSum.xyz, "xyz[3]/F"); trOut->Branch("dX" , &cSum.dX ,"dX/F"); trOut->Branch("dY" , &cSum.dY ,"dY/F"); trOut->Branch("dZ" , &cSum.dZ ,"dZ/F"); trOut->Branch("split",&cSum.split,"split/O"); trOut->Branch("prim", &cSum.prim, "prim/O"); trOut->Branch("pdg", &cSum.pdg, "pdg/I"); trOut->Branch("ntr", &cSum.ntr, "ntr/I"); trOut->Branch("alpha", &cSum.alpha, "alpha/F"); trOut->Branch("beta", &cSum.beta, "beta/F"); trOut->Branch("nRowPatt", &cSum.nRowPatt, "nRowPatt/I"); trOut->Branch("nColPatt", &cSum.nColPatt, "nColPatt/I"); TopDatabase DB; for (Int_t iEvent = 0; iEvent < ntotev; iEvent++) { printf("\n Event %i \n",iEvent); runLoader->GetEvent(iEvent); AliStack *stack = runLoader->Stack(); cluTree=dl->TreeR(); hitTree=dl->TreeH(); hitTree->SetBranchAddress("ITS",&hitList); // // read clusters for (int ilr=nlr;ilr--;) { TBranch* br = cluTree->GetBranch(Form("ITSRecPoints%d",ilr)); if (!br) {printf("Did not find cluster branch for lr %d\n",ilr); exit(1);} br->SetAddress(its->GetLayerActive(ilr)->GetClustersAddress()); } cluTree->GetEntry(0); its->ProcessClusters(); // // read hits for(Int_t iEnt=0;iEnt<hitTree->GetEntries();iEnt++){//entries loop of the hits hitTree->GetEntry(iEnt); int nh = hitList->GetEntries(); for(Int_t iHit=0; iHit<nh;iHit++){ AliITSMFTHit *pHit = (AliITSMFTHit*)hitList->At(iHit); int mcID = pHit->GetTrack(); //printf("MCid: %d %d %d Ch %d\n",iEnt,iHit, mcID, pHit->GetChip()); TClonesArray* harr = arrMCTracks.GetEntriesFast()>mcID ? (TClonesArray*)arrMCTracks.At(mcID) : 0; if (!harr) { harr = new TClonesArray("AliITSMFTHit"); // 1st encounter of the MC track arrMCTracks.AddAtAndExpand(harr,mcID); } // new ( (*harr)[harr->GetEntriesFast()] ) AliITSMFTHit(*pHit); } } // return; // // compare clusters and hits // printf(" tree entries: %lld\n",cluTree->GetEntries()); // for (int ilr=0;ilr<nlr;ilr++) { AliITSURecoLayer* lr = its->GetLayerActive(ilr); TClonesArray* clr = lr->GetClusters(); int nClu = clr->GetEntries(); //printf("Layer %d : %d clusters\n",ilr,nClu); // for (int icl=0;icl<nClu;icl++) { AliITSMFTClusterPix *cl = (AliITSMFTClusterPix*)clr->At(icl); int modID = cl->GetVolumeId(); //------------ check if this is a split cluster int sInL = modID - gm->GetFirstChipIndex(ilr); if (!cl->TestBit(kSplCheck)) { cl->SetBit(kSplCheck); // check if there is no other cluster with same label on this module AliITSURecoSens* sens = lr->GetSensor(sInL); int nclSn = sens->GetNClusters(); int offs = sens->GetFirstClusterId(); // printf("To check for %d (mod:%d) N=%d from %d\n",icl,modID,nclSn,offs); for (int ics=0;ics<nclSn;ics++) { AliITSMFTClusterPix* clusT = (AliITSMFTClusterPix*)lr->GetCluster(offs+ics); // access to clusters if (clusT==cl) continue; for (int ilb0=0;ilb0<3;ilb0++) { int lb0 = cl->GetLabel(ilb0); if (lb0<=-1) break; for (int ilb1=0;ilb1<3;ilb1++) { int lb1 = clusT->GetLabel(ilb1); if (lb1<=-1) break; if (lb1==lb0) { cl->SetBit(kSplit); clusT->SetBit(kSplit); /* printf("Discard clusters of module %d:\n",modID); cl->Print(); clusT->Print(); */ break; } } } } } //------------ const AliITSMFTSegmentationPix* segm = gm->GetSegmentation(ilr); // cl->GetGlobalXYZ(xyzClGloF); int clsize = cl->GetNPix(); for (int i=3;i--;) xyzClGlo[i] = xyzClGloF[i]; const TGeoHMatrix* mat = gm->GetMatrixSens(modID); if (!mat) {printf("failed to get matrix for module %d\n",cl->GetVolumeId());} mat->MasterToLocal(xyzClGlo,xyzClTr); // int col,row; segm->LocalToDet(xyzClTr[0],xyzClTr[2],row,col); // effective col/row nLab = 0; for (int il=0;il<3;il++) { if (cl->GetLabel(il)>=0) labels[nLab++] = cl->GetLabel(il); else break; } // find hit info for (int il=0;il<nLab;il++) { TClonesArray* htArr = (TClonesArray*)arrMCTracks.At(labels[il]); //printf("check %d/%d LB %d %p\n",il,nLab,labels[il],htArr); if (!htArr) {printf("did not find MChits for label %d ",labels[il]); cl->Print(); continue;} // int nh = htArr->GetEntriesFast(); AliITSMFTHit *pHit=0; for (int ih=nh;ih--;) { AliITSMFTHit* tHit = (AliITSMFTHit*)htArr->At(ih); if (tHit->GetChip()!=modID) continue; pHit = tHit; break; } if (!pHit) { printf("did not find MChit for label %d on module %d ",il,modID); cl->Print(); htArr->Print(); continue; } // pHit->GetPositionG(xg1,yg1,zg1); pHit->GetPositionG0(xg0,yg0,zg0,tg0); // double txyzH[3],gxyzH[3] = { (xg1+xg0)/2, (yg1+yg0)/2, (zg1+zg0)/2 }; mat->MasterToLocal(gxyzH,txyzH); double rcl = TMath::Sqrt(xyzClTr[0]*xyzClTr[0]+xyzClTr[1]*xyzClTr[1]); double rht = TMath::Sqrt(txyzH[0]*txyzH[0]+txyzH[1]*txyzH[1]); // //Angles determination pHit->GetPositionL(xExit,yExit,zExit,gm); pHit->GetPositionL0(xEnt,yEnt,zEnt,tof1,gm); Double_t dirHit[3]={(xExit-xEnt),(yExit-yEnt),(zExit-zEnt)}; /*double PG[3] = {(double)pHit->GetPXG(), (double)pHit->GetPYG(), (double)pHit->GetPZG()}; //Momentum at hit-point in Global Frame double PL[3]; if (TMath::Abs(PG[0])<10e-7 && TMath::Abs(PG[1])<10e-7) { pHit->Dump(); int lb = pHit->GetTrack(); stack->Particle(lb)->Print(); continue; } mat->MasterToLocalVect(PG,PL); //Momentum in local Frame //printf(">> %e %e %e %e %e %e\n",PG[0],PL[0],PG[1],PL[1],PG[2],PL[2]);*/ Double_t alpha1 = TMath::ACos(TMath::Abs(dirHit[1])/TMath::Sqrt(dirHit[0]*dirHit[0]+dirHit[1]*dirHit[1]+dirHit[2]*dirHit[2])); //Polar Angle Float_t alpha2 = (Float_t) alpha1; //convert to float cSum.alpha = alpha2; Double_t beta1; beta1 = TMath::ATan2(dirHit[0],dirHit[2]); //Azimuthal angle, values from -Pi to Pi Float_t beta2 = (Float_t) beta1; cSum.beta = beta2; if(ilr==0){ hL0A->Fill(alpha2); hL0B->Fill(beta2); } if(ilr==1){ hL1A->Fill(alpha2); hL1B->Fill(beta2); } if(ilr==2){ hL2A->Fill(alpha2); hL2B->Fill(beta2); } if(ilr==3){ hL3A->Fill(alpha2); hL3B->Fill(beta2); } if(ilr==4){ hL4A->Fill(alpha2); hL4B->Fill(beta2); } if(ilr==5){ hL5A->Fill(alpha2); hL5B->Fill(beta2); } if(ilr==6){ hL6A->Fill(alpha2); hL6B->Fill(beta2); } GetHistoClSize(clsize,kDR,&histoArr)->Fill((rht-rcl)*1e4); if (cl->TestBit(kSplit)) { if (col%2) GetHistoClSize(clsize,kDTXoddSPL,&histoArr)->Fill((txyzH[0]-xyzClTr[0])*1e4); else GetHistoClSize(clsize,kDTXevenSPL,&histoArr)->Fill((txyzH[0]-xyzClTr[0])*1e4); GetHistoClSize(clsize,kDTZSPL,&histoArr)->Fill((txyzH[2]-xyzClTr[2])*1e4); GetHistoClSize(0,kNPixSPL,&histoArr)->Fill(clsize); } if (col%2) GetHistoClSize(clsize,kDTXodd,&histoArr)->Fill((txyzH[0]-xyzClTr[0])*1e4); else GetHistoClSize(clsize,kDTXeven,&histoArr)->Fill((txyzH[0]-xyzClTr[0])*1e4); GetHistoClSize(clsize,kDTZ,&histoArr)->Fill((txyzH[2]-xyzClTr[2])*1e4); GetHistoClSize(0,kNPixAll,&histoArr)->Fill(clsize); // cSum.evID = iEvent; cSum.volID = cl->GetVolumeId(); cSum.lrID = ilr; cSum.clID = icl; cSum.nPix = cl->GetNPix(); cSum.nX = cl->GetNx(); cSum.nZ = cl->GetNz(); cSum.q = cl->GetQ(); cSum.split = cl->TestBit(kSplit); cSum.dX = (txyzH[0]-xyzClTr[0])*1e4; cSum.dY = (txyzH[1]-xyzClTr[1])*1e4; cSum.dZ = (txyzH[2]-xyzClTr[2])*1e4; cSum.nRowPatt = cl-> GetPatternRowSpan(); cSum.nColPatt = cl-> GetPatternColSpan(); DB.AccountTopology(*cl, cSum.dX, cSum.dZ, cSum.alpha, cSum.beta); GetHistoClSize(clsize,kDR,&histoArr)->Fill((rht-rcl)*1e4); if (cl->TestBit(kSplit)) { if (col%2) GetHistoClSize(clsize,kDTXoddSPL,&histoArr)->Fill((txyzH[0]-xyzClTr[0])*1e4); else GetHistoClSize(clsize,kDTXevenSPL,&histoArr)->Fill((txyzH[0]-xyzClTr[0])*1e4); GetHistoClSize(clsize,kDTZSPL,&histoArr)->Fill((txyzH[2]-xyzClTr[2])*1e4); GetHistoClSize(0,kNPixSPL,&histoArr)->Fill(clsize); } if (col%2) GetHistoClSize(clsize,kDTXodd,&histoArr)->Fill((txyzH[0]-xyzClTr[0])*1e4); else GetHistoClSize(clsize,kDTXeven,&histoArr)->Fill((txyzH[0]-xyzClTr[0])*1e4); GetHistoClSize(clsize,kDTZ,&histoArr)->Fill((txyzH[2]-xyzClTr[2])*1e4); GetHistoClSize(0,kNPixAll,&histoArr)->Fill(clsize); // cSum.evID = iEvent; cSum.volID = cl->GetVolumeId(); cSum.lrID = ilr; cSum.clID = icl; cSum.nPix = cl->GetNPix(); cSum.nX = cl->GetNx(); cSum.nZ = cl->GetNz(); cSum.q = cl->GetQ(); cSum.split = cl->TestBit(kSplit); cSum.dX = (txyzH[0]-xyzClTr[0])*1e4; cSum.dY = (txyzH[1]-xyzClTr[1])*1e4; cSum.dZ = (txyzH[2]-xyzClTr[2])*1e4; cSum.nRowPatt = cl-> GetPatternRowSpan(); cSum.nColPatt = cl-> GetPatternColSpan(); int label = cl->GetLabel(0); TParticle* part = 0; if (label>=0 && (part=stack->Particle(label)) ) { cSum.pdg = part->GetPdgCode(); cSum.eta = part->Eta(); cSum.pt = part->Pt(); cSum.phi = part->Phi(); cSum.prim = stack->IsPhysicalPrimary(label); } cSum.ntr = 0; for (int ilb=0;ilb<3;ilb++) if (cl->GetLabel(ilb)>=0) cSum.ntr++; for (int i=0;i<3;i++) cSum.xyz[i] = xyzClGloF[i]; // trOut->Fill(); /* if (clsize==5) { printf("\nL%d(%c) Mod%d, Cl:%d | %+5.1f %+5.1f (%d/%d)|H:%e %e %e | C:%e %e %e\n",ilr,cl->TestBit(kSplit) ? 'S':'N', modID,icl,(txyzH[0]-xyzClTr[0])*1e4,(txyzH[2]-xyzClTr[2])*1e4, row,col, gxyzH[0],gxyzH[1],gxyzH[2],xyzClGlo[0],xyzClGlo[1],xyzClGlo[2]); cl->Print(); pHit->Print(); // double a0,b0,c0,a1,b1,c1,e0; pHit->GetPositionL0(a0,b0,c0,e0); pHit->GetPositionL(a1,b1,c1); float cloc[3]; cl->GetLocalXYZ(cloc); printf("LocH: %e %e %e | %e %e %e\n",a0,b0,c0,a1,b1,c1); printf("LocC: %e %e %e | %e %e %e\n",cloc[0],cloc[1],cloc[2],xyzClTr[0],xyzClTr[1],xyzClTr[2]); } */ // } } } // layerClus.Clear(); // arrMCTracks.Delete(); }//event loop // DB.EndAndSort(); DB.SetThresholdCumulative(0.95); cout << "Over threshold: : "<< DB.GetOverThr()<<endl; DB.Grouping(10,10); DB.PrintDB("Database1.txt"); flOut->cd(); trOut->Write(); delete trOut; flOut->Close(); flOut->Delete(); DrawReport("clinfo.ps",&histoArr); TFile* flDB = TFile::Open("TopologyDatabase.root", "recreate"); flDB->WriteObject(&DB,"DB","kSingleKey"); flDB->Close(); delete flDB; TCanvas* cnv123 = new TCanvas("cnv123","cnv123"); cnv123->Divide(1,2); cnv123->Print("anglesdistr.pdf["); cnv123->cd(1); hL0A->Draw(); cnv123->cd(2); hL0B->Draw(); cnv123->Print("anglesdistr.pdf"); cnv123->cd(1); hL1A->Draw(); cnv123->cd(2); hL1B->Draw(); cnv123->Print("anglesdistr.pdf"); cnv123->cd(1); hL2A->Draw(); cnv123->cd(2); hL2B->Draw(); cnv123->Print("anglesdistr.pdf"); cnv123->cd(1); hL3A->Draw(); cnv123->cd(2); hL3B->Draw(); cnv123->Print("anglesdistr.pdf"); cnv123->cd(1); hL4A->Draw(); cnv123->cd(2); hL4B->Draw(); cnv123->Print("anglesdistr.pdf"); cnv123->cd(1); hL5A->Draw(); cnv123->cd(2); hL5B->Draw(); cnv123->Print("anglesdistr.pdf"); cnv123->cd(1); hL6A->Draw(); cnv123->cd(2); hL6B->Draw(); cnv123->Print("anglesdistr.pdf"); cnv123->Print("anglesdistr.pdf]"); // }
void ClusterDensityFromQA(const char* qaFile="") { if ( TString(qaFile).BeginsWith("alien")) { TGrid::Connect("alien://"); } TFile* f = TFile::Open(qaFile); std::vector<IntegrationRange> rangesLow; std::vector<IntegrationRange> rangesHigh; rangesLow.push_back(IntegrationRange{-10,10, 80, 85}); rangesLow.push_back(IntegrationRange{-10,10, 80, 85}); rangesLow.push_back(IntegrationRange{-10,10, 95,100}); rangesLow.push_back(IntegrationRange{-10,10, 95,100}); for ( int i = 0; i < 4; ++i ) { IntegrationRange ref = rangesLow[i]; TObjArray* a = static_cast<TObjArray*>(f->Get("MUON_QA/expert")); TH2* h = static_cast<TH2*>(a->FindObject(Form("hClusterHitMapInCh%d",i+1))); // derive other symetric ranges from that one std::vector<IntegrationRange> ranges; double ysize = ref.ymax - ref.ymin; double xsize = (ref.xmax - ref.xmin)/2.0; ranges.push_back(ref); ranges.push_back(IntegrationRange{ref.xmin,ref.xmax,-ref.ymax,-ref.ymin}); ranges.push_back(IntegrationRange{ref.ymin+ysize/2.0,ref.ymax,ref.xmin,ref.xmax}); TCanvas* c = new TCanvas(Form("Chamber%d",i+1),Form("Chamber%d",i+1)); h->Draw("colz"); std::cout << "CHAMBER " << i+1 << " LOW = "; for ( auto r : ranges ) { double count = h->Integral( h->GetXaxis()->FindBin(r.xmin), h->GetXaxis()->FindBin(r.xmax), h->GetYaxis()->FindBin(r.ymin), h->GetYaxis()->FindBin(r.ymax) ); std::cout << " " << count << "(" << r.Surface() << " cm^2)"; std::vector<double> x = { r.xmin,r.xmax,r.xmax,r.xmin,r.xmin }; std::vector<double> y = { r.ymax,r.ymax,r.ymin,r.ymin,r.ymax }; TPolyLine* l = new TPolyLine(5,&x[0],&y[0]); l->SetLineColor(1); l->SetLineStyle(9); l->Draw(); } std::cout << std::endl; } }
void paracoor( TString fin = "TMVA.root", Bool_t useTMVAStyle = kTRUE ) { // set style and remove existing canvas' TMVAGlob::Initialize( useTMVAStyle ); // checks if file with name "fin" is already open, and if not opens one TFile* file = TMVAGlob::OpenFile( fin ); TTree* tree = (TTree*)file->Get("TestTree"); if(!tree) { cout << "--- No TestTree saved in ROOT file. Parallel coordinates will not be plotted" << endl; return; } // first get list of leaves in tree TObjArray* leafList = tree->GetListOfLeaves(); vector<TString> vars; vector<TString> mvas; for (Int_t iar=0; iar<leafList->GetSize(); iar++) { TLeaf* leaf = (TLeaf*)leafList->At(iar); if (leaf != 0) { TString leafName = leaf->GetName(); if (leafName != "type" && leafName != "weight" && leafName != "boostweight" && leafName != "class" && leafName != "className" && leafName != "classID" && !leafName.Contains("prob_")) { // is MVA ? if (TMVAGlob::ExistMethodName( leafName )) { mvas.push_back( leafName ); } else { vars.push_back( leafName ); } } } } cout << "--- Found: " << vars.size() << " variables" << endl; cout << "--- Found: " << mvas.size() << " MVA(s)" << endl; TString type[2] = { "Signal", "Background" }; const UInt_t nmva = mvas.size(); TCanvas* csig[nmva]; TCanvas* cbkg[nmva]; for (UInt_t imva=0; imva<mvas.size(); imva++) { cout << "--- Plotting parallel coordinates for : " << mvas[imva] << " & input variables" << endl; for (Int_t itype=0; itype<2; itype++) { // create draw option TString varstr = mvas[imva] + ":"; for (UInt_t ivar=0; ivar<vars.size(); ivar++) varstr += vars[ivar] + ":"; varstr.Resize( varstr.Last( ':' ) ); // create canvas TString mvashort = mvas[imva]; mvashort.ReplaceAll("MVA_",""); TCanvas* c1 = (itype == 0) ? csig[imva] : cbkg[imva]; c1 = new TCanvas( Form( "c1_%i_%s",itype,mvashort.Data() ), Form( "Parallel coordinate representation for %s and input variables (%s events)", mvashort.Data(), type[itype].Data() ), 50*(itype), 50*(itype), 750, 500 ); tree->Draw( varstr.Data(), Form("classID==%i",1-itype) , "para" ); c1->ToggleEditor(); gStyle->SetOptTitle(0); TParallelCoord* para = (TParallelCoord*)gPad->GetListOfPrimitives()->FindObject( "ParaCoord" ); TParallelCoordVar* mvavar = (TParallelCoordVar*)para->GetVarList()->FindObject( mvas[imva] ); Double_t minrange = tree->GetMinimum( mvavar->GetName() ); Double_t maxrange = tree->GetMaximum( mvavar->GetName() ); Double_t width = 0.2*(maxrange - minrange); Double_t x1 = minrange, x2 = x1 + width; TParallelCoordRange* parrange = new TParallelCoordRange( mvavar, x1, x2 ); parrange->SetLineColor(4); mvavar->AddRange( parrange ); para->AddSelection("-1"); for (Int_t ivar=1; ivar<TMath::Min(Int_t(vars.size()) + 1,3); ivar++) { TParallelCoordVar* var = (TParallelCoordVar*)para->GetVarList()->FindObject( vars[ivar] ); minrange = tree->GetMinimum( var->GetName() ); maxrange = tree->GetMaximum( var->GetName() ); width = 0.2*(maxrange - minrange); switch (ivar) { case 0: { x1 = minrange; x2 = x1 + width; break; } case 1: { x1 = 0.5*(maxrange + minrange - width)*0.02; x2 = x1 + width*0.02; break; } case 2: { x1 = maxrange - width; x2 = x1 + width; break; } } parrange = new TParallelCoordRange( var, x1, x2 ); parrange->SetLineColor( ivar == 0 ? 2 : ivar == 1 ? 5 : 6 ); var->AddRange( parrange ); para->AddSelection( Form("%i",ivar) ); } c1->Update(); TString fname = Form( "root_mva/plots/paracoor_c%i_%s", imva, itype == 0 ? "S" : "B" ); TMVAGlob::imgconv( c1, fname ); } } }
void simall(Int_t nEvents = 1, TObjArray& fDetList, Bool_t fVis=kFALSE, TString fMC="TGeant3", TString fGenerator="mygenerator", Bool_t fUserPList= kFALSE ) { TString dir = getenv("VMCWORKDIR"); TString simdir = dir + "/macros"; TString sim_geomdir = dir + "/geometry"; gSystem->Setenv("GEOMPATH",sim_geomdir.Data()); TString sim_confdir = dir + "gconfig"; gSystem->Setenv("CONFIG_DIR",sim_confdir.Data()); // Output files TString OutFile = "simout.root"; TString ParFile = "simpar.root"; // In general, the following parts need not be touched // ======================================================================== // ---- Debug option ------------------------------------------------- gDebug = 0; // ------------------------------------------------------------------------ // ----- Timer -------------------------------------------------------- TStopwatch timer; timer.Start(); // ------------------------------------------------------------------------ // ---- Load libraries ------------------------------------------------- gROOT->LoadMacro("$VMCWORKDIR/gconfig/basiclibs.C"); basiclibs(); gSystem->Load("libGenVector"); gSystem->Load("libGeoBase"); gSystem->Load("libFairDB"); gSystem->Load("libParBase"); gSystem->Load("libBase"); gSystem->Load("libMCStack"); gSystem->Load("libField"); gSystem->Load("libGen"); //---- Load specific libraries --------------------------------------- gSystem->Load("libEnsarbase"); gSystem->Load("libEnsarGen"); gSystem->Load("libEnsarData"); gSystem->Load("libEnsarMyDet"); // ----- Create simulation run ---------------------------------------- FairRunSim* run = new FairRunSim(); run->SetName(fMC.Data()); // Transport engine run->SetOutputFile(OutFile.Data()); // Output file FairRuntimeDb* rtdb = run->GetRuntimeDb(); // R3B Special Physics List in G4 case if ( (fUserPList == kTRUE ) && (fMC.CompareTo("TGeant4") == 0) ){ run->SetUserConfig("g4Config.C"); run->SetUserCuts("SetCuts.C"); } // ----- Create media ------------------------------------------------- //run->SetMaterials("media_r3b.geo"); // Materials // Magnetic field map type // Int_t fFieldMap = 0; // Global Transformations //- Two ways for a Volume Rotation are supported //-- 1) Global Rotation (Euler Angles definition) //-- This represent the composition of : first a rotation about Z axis with //-- angle phi, then a rotation with theta about the rotated X axis, and //-- finally a rotation with psi about the new Z axis. Double_t phi,theta,psi; //-- 2) Rotation in Ref. Frame of the Volume //-- Rotation is Using Local Ref. Frame axis angles Double_t thetaX,thetaY,thetaZ; //- Global Translation Lab. frame. Double_t tx,ty,tz; // ----- Create geometry -------------------------------------------- if (fDetList.FindObject("MYDET") ) { //My Detector definition EnsarDetector* mydet = new EnsarMyDet("MyDet", kTRUE); // Global position of the Module phi = 0.0; // (deg) theta = 0.0; // (deg) psi = 0.0; // (deg) // Rotation in Ref. Frame. thetaX = 0.0; // (deg) thetaY = 0.0; // (deg) thetaZ = 0.0; // (deg) // Global translation in Lab tx = 0.0; // (cm) ty = 0.0; // (cm) tz = 0.0; // (cm) mydet->SetRotAnglesXYZ(thetaX,thetaY,thetaZ); mydet->SetTranslation(tx,ty,tz); run->AddModule(mydet); } // ----- Create PrimaryGenerator -------------------------------------- // 1 - Create the Main API class for the Generator FairPrimaryGenerator* primGen = new FairPrimaryGenerator(); if (fGenerator.CompareTo("mygenerator") == 0 ) { // 2- Define the generator Double_t pdgId=211; // pion beam Double_t theta1= 0.; // polar angle distribution Double_t theta2= 7.; Double_t momentum=.8; // 10 GeV/c Int_t multiplicity = 50; // multiplicity (nb particles per event) FairBoxGenerator* boxGen = new FairBoxGenerator(pdgId,multiplicity); boxGen->SetThetaRange ( theta1, theta2); boxGen->SetPRange (momentum,momentum*2.); boxGen->SetPhiRange (0.,360.); boxGen->SetXYZ(0.0,0.0,-1.5); // add the box generator primGen->AddGenerator(boxGen); } run->SetGenerator(primGen); //-------Set visualisation flag to true------------------------------------ if (fVis==kTRUE){ run->SetStoreTraj(kTRUE); }else{ run->SetStoreTraj(kFALSE); } // ----- Initialize simulation run ------------------------------------ run->Init(); // ------ Increase nb of step Int_t nSteps = -15000; gMC->SetMaxNStep(nSteps); // ----- Runtime database --------------------------------------------- Bool_t kParameterMerged = kTRUE; FairParRootFileIo* parOut = new FairParRootFileIo(kParameterMerged); parOut->open(ParFile.Data()); rtdb->setOutput(parOut); rtdb->saveOutput(); rtdb->print(); // ----- Start run ---------------------------------------------------- if (nEvents>0) run->Run(nEvents); // ----- Finish ------------------------------------------------------- timer.Stop(); Double_t rtime = timer.RealTime(); Double_t ctime = timer.CpuTime(); cout << endl << endl; cout << "Macro finished succesfully." << endl; cout << "Output file is " << OutFile << endl; cout << "Parameter file is " << ParFile << endl; cout << "Real time " << rtime << " s, CPU time " << ctime << "s" << endl << endl; // ------------------------------------------------------------------------ cout << " Test passed" << endl; cout << " All ok " << endl; }
Bool_t CheckESD(const char* gAliceFileName = "galice.root", const char* esdFileName = "AliESDs.root") { // check the content of the ESD // check values Int_t checkNGenLow = 1; Double_t checkEffLow = 0.5; Double_t checkEffSigma = 3; Double_t checkFakeHigh = 0.5; Double_t checkFakeSigma = 3; Double_t checkResPtInvHigh = 5; Double_t checkResPtInvSigma = 3; Double_t checkResPhiHigh = 10; Double_t checkResPhiSigma = 3; Double_t checkResThetaHigh = 10; Double_t checkResThetaSigma = 3; Double_t checkPIDEffLow = 0.5; Double_t checkPIDEffSigma = 3; Double_t checkResTOFHigh = 500; Double_t checkResTOFSigma = 3; Double_t checkPHOSNLow = 5; Double_t checkPHOSEnergyLow = 0.3; Double_t checkPHOSEnergyHigh = 1.0; Double_t checkEMCALNLow = 50; Double_t checkEMCALEnergyLow = 0.05; Double_t checkEMCALEnergyHigh = 1.0; Double_t checkMUONNLow = 1; Double_t checkMUONPtLow = 0.5; Double_t checkMUONPtHigh = 10.; Double_t cutPtV0 = 0.3; Double_t checkV0EffLow = 0.02; Double_t checkV0EffSigma = 3; Double_t cutPtCascade = 0.5; Double_t checkCascadeEffLow = 0.01; Double_t checkCascadeEffSigma = 3; // open run loader and load gAlice, kinematics and header AliRunLoader* runLoader = AliRunLoader::Open(gAliceFileName); if (!runLoader) { Error("CheckESD", "getting run loader from file %s failed", gAliceFileName); return kFALSE; } runLoader->LoadgAlice(); gAlice = runLoader->GetAliRun(); if (!gAlice) { Error("CheckESD", "no galice object found"); return kFALSE; } runLoader->LoadKinematics(); runLoader->LoadHeader(); // open the ESD file TFile* esdFile = TFile::Open(esdFileName); if (!esdFile || !esdFile->IsOpen()) { Error("CheckESD", "opening ESD file %s failed", esdFileName); return kFALSE; } AliESDEvent * esd = new AliESDEvent; TTree* tree = (TTree*) esdFile->Get("esdTree"); if (!tree) { Error("CheckESD", "no ESD tree found"); return kFALSE; } esd->ReadFromTree(tree); //PMD plots TH1F *fhM[48]; for(Int_t i = 0; i < 48; i++) fhM[i] = Create1DHistos(i,"hEsDMod"); // PMD XY Plots histograms TH2F *fhEsdXYC = new TH2F("hEsdXYC"," Scattered Plot for CPV (ESD) ",100,-100. ,100.,100,-100.,100.); TH2F *fhEsdXYP = new TH2F("hEsdXYP"," Scattered Plot for PRE (ESD) ",100,-100. ,100.,100,-100.,100.); // efficiency and resolution histograms Int_t nBinsPt = 15; Float_t minPt = 0.1; Float_t maxPt = 3.1; TH1F* hGen = CreateHisto("hGen", "generated tracks", nBinsPt, minPt, maxPt, "p_{t} [GeV/c]", "N"); TH1F* hRec = CreateHisto("hRec", "reconstructed tracks", nBinsPt, minPt, maxPt, "p_{t} [GeV/c]", "N"); Int_t nGen = 0; Int_t nRec = 0; Int_t nFake = 0; TH1F* hResPtInv = CreateHisto("hResPtInv", "", 100, -10, 10, "(p_{t,rec}^{-1}-p_{t,sim}^{-1}) / p_{t,sim}^{-1} [%]", "N"); TH1F* hResPhi = CreateHisto("hResPhi", "", 100, -20, 20, "#phi_{rec}-#phi_{sim} [mrad]", "N"); TH1F* hResTheta = CreateHisto("hResTheta", "", 100, -20, 20, "#theta_{rec}-#theta_{sim} [mrad]", "N"); // PID Int_t partCode[AliPID::kSPECIES] = {kElectron, kMuonMinus, kPiPlus, kKPlus, kProton}; const char* partName[AliPID::kSPECIES+1] = {"electron", "muon", "pion", "kaon", "proton", "other"}; Double_t partFrac[AliPID::kSPECIES] = {0.01, 0.01, 0.85, 0.10, 0.05}; Int_t identified[AliPID::kSPECIES+1][AliPID::kSPECIES]; for (Int_t iGen = 0; iGen < AliPID::kSPECIES+1; iGen++) { for (Int_t iRec = 0; iRec < AliPID::kSPECIES; iRec++) { identified[iGen][iRec] = 0; } } Int_t nIdentified = 0; // dE/dx and TOF TH2F* hDEdxRight = new TH2F("hDEdxRight", "", 300, 0, 3, 100, 0, 400); hDEdxRight->SetStats(kFALSE); hDEdxRight->GetXaxis()->SetTitle("p [GeV/c]"); hDEdxRight->GetYaxis()->SetTitle("dE/dx_{TPC}"); hDEdxRight->SetMarkerStyle(kFullCircle); hDEdxRight->SetMarkerSize(0.4); TH2F* hDEdxWrong = new TH2F("hDEdxWrong", "", 300, 0, 3, 100, 0, 400); hDEdxWrong->SetStats(kFALSE); hDEdxWrong->GetXaxis()->SetTitle("p [GeV/c]"); hDEdxWrong->GetYaxis()->SetTitle("dE/dx_{TPC}"); hDEdxWrong->SetMarkerStyle(kFullCircle); hDEdxWrong->SetMarkerSize(0.4); hDEdxWrong->SetMarkerColor(kRed); TH1F* hResTOFRight = CreateHisto("hResTOFRight", "", 100, -1000, 1000, "t_{TOF}-t_{track} [ps]", "N"); TH1F* hResTOFWrong = CreateHisto("hResTOFWrong", "", 100, -1000, 1000, "t_{TOF}-t_{track} [ps]", "N"); hResTOFWrong->SetLineColor(kRed); // calorimeters TH1F* hEPHOS = CreateHisto("hEPHOS", "PHOS", 100, 0, 50, "E [GeV]", "N"); TH1F* hEEMCAL = CreateHisto("hEEMCAL", "EMCAL", 100, 0, 50, "E [GeV]", "N"); // muons TH1F* hPtMUON = CreateHisto("hPtMUON", "MUON", 100, 0, 20, "p_{t} [GeV/c]", "N"); // V0s and cascades TH1F* hMassK0 = CreateHisto("hMassK0", "K^{0}", 100, 0.4, 0.6, "M(#pi^{+}#pi^{-}) [GeV/c^{2}]", "N"); TH1F* hMassLambda = CreateHisto("hMassLambda", "#Lambda", 100, 1.0, 1.2, "M(p#pi^{-}) [GeV/c^{2}]", "N"); TH1F* hMassLambdaBar = CreateHisto("hMassLambdaBar", "#bar{#Lambda}", 100, 1.0, 1.2, "M(#bar{p}#pi^{+}) [GeV/c^{2}]", "N"); Int_t nGenV0s = 0; Int_t nRecV0s = 0; TH1F* hMassXi = CreateHisto("hMassXi", "#Xi", 100, 1.2, 1.5, "M(#Lambda#pi) [GeV/c^{2}]", "N"); TH1F* hMassOmega = CreateHisto("hMassOmega", "#Omega", 100, 1.5, 1.8, "M(#LambdaK) [GeV/c^{2}]", "N"); Int_t nGenCascades = 0; Int_t nRecCascades = 0; // loop over events for (Int_t iEvent = 0; iEvent < runLoader->GetNumberOfEvents(); iEvent++) { runLoader->GetEvent(iEvent); // select simulated primary particles, V0s and cascades AliStack* stack = runLoader->Stack(); Int_t nParticles = stack->GetNtrack(); TArrayF vertex(3); runLoader->GetHeader()->GenEventHeader()->PrimaryVertex(vertex); TObjArray selParticles; TObjArray selV0s; TObjArray selCascades; for (Int_t iParticle = 0; iParticle < nParticles; iParticle++) { TParticle* particle = stack->Particle(iParticle); if (!particle) continue; if (particle->Pt() < 0.001) continue; if (TMath::Abs(particle->Eta()) > 0.9) continue; TVector3 dVertex(particle->Vx() - vertex[0], particle->Vy() - vertex[1], particle->Vz() - vertex[2]); if (dVertex.Mag() > 0.0001) continue; switch (TMath::Abs(particle->GetPdgCode())) { case kElectron: case kMuonMinus: case kPiPlus: case kKPlus: case kProton: { if (particle->Pt() > minPt) { selParticles.Add(particle); nGen++; hGen->Fill(particle->Pt()); } break; } case kK0Short: case kLambda0: { if (particle->Pt() > cutPtV0) { nGenV0s++; selV0s.Add(particle); } break; } case kXiMinus: case kOmegaMinus: { if (particle->Pt() > cutPtCascade) { nGenCascades++; selCascades.Add(particle); } break; } default: break; } } // get the event summary data tree->GetEvent(iEvent); if (!esd) { Error("CheckESD", "no ESD object found for event %d", iEvent); return kFALSE; } //------------- Loop over PMD track ---- Int_t npmdcl = 0; npmdcl = esd->GetNumberOfPmdTracks(); while (npmdcl--) { AliESDPmdTrack *pmdtr = esd->GetPmdTrack(npmdcl); Int_t det = pmdtr->GetDetector(); Int_t smn = pmdtr->GetSmn(); Float_t adc = pmdtr->GetClusterADC(); Int_t ncell = pmdtr->GetClusterCells(); Float_t clsX = pmdtr->GetClusterX(); Float_t clsY = pmdtr->GetClusterY(); if(det == 0) { fhEsdXYP->Fill(clsX,clsY); if(ncell < 3) fhM[smn]->Fill(adc); } else if(det == 1) { fhEsdXYC->Fill(clsX,clsY); if(ncell < 3)fhM[24+smn]->Fill(adc); } } //----------------------- // loop over tracks for (Int_t iTrack = 0; iTrack < esd->GetNumberOfTracks(); iTrack++) { AliESDtrack* track = esd->GetTrack(iTrack); // select tracks of selected particles Int_t label = TMath::Abs(track->GetLabel()); if (label > stack->GetNtrack()) continue; // background TParticle* particle = stack->Particle(label); if (!selParticles.Contains(particle)) continue; if ((track->GetStatus() & AliESDtrack::kITSrefit) == 0) continue; if (track->GetConstrainedChi2() > 1e9) continue; selParticles.Remove(particle); // don't count multiple tracks nRec++; hRec->Fill(particle->Pt()); if (track->GetLabel() < 0) nFake++; // resolutions hResPtInv->Fill(100. * (TMath::Abs(track->GetSigned1Pt()) - 1./particle->Pt()) * particle->Pt()); hResPhi->Fill(1000. * (track->Phi() - particle->Phi())); hResTheta->Fill(1000. * (track->Theta() - particle->Theta())); // PID if ((track->GetStatus() & AliESDtrack::kESDpid) == 0) continue; Int_t iGen = 5; for (Int_t i = 0; i < AliPID::kSPECIES; i++) { if (TMath::Abs(particle->GetPdgCode()) == partCode[i]) iGen = i; } Double_t probability[AliPID::kSPECIES]; track->GetESDpid(probability); Double_t pMax = 0; Int_t iRec = 0; for (Int_t i = 0; i < AliPID::kSPECIES; i++) { probability[i] *= partFrac[i]; if (probability[i] > pMax) { pMax = probability[i]; iRec = i; } } identified[iGen][iRec]++; if (iGen == iRec) nIdentified++; // dE/dx and TOF Double_t time[AliPID::kSPECIES]; track->GetIntegratedTimes(time); if (iGen == iRec) { hDEdxRight->Fill(particle->P(), track->GetTPCsignal()); if ((track->GetStatus() & AliESDtrack::kTOFpid) != 0) { hResTOFRight->Fill(track->GetTOFsignal() - time[iRec]); } } else { hDEdxWrong->Fill(particle->P(), track->GetTPCsignal()); if ((track->GetStatus() & AliESDtrack::kTOFpid) != 0) { hResTOFWrong->Fill(track->GetTOFsignal() - time[iRec]); } } } // loop over muon tracks { for (Int_t iTrack = 0; iTrack < esd->GetNumberOfMuonTracks(); iTrack++) { AliESDMuonTrack* muonTrack = esd->GetMuonTrack(iTrack); Double_t ptInv = TMath::Abs(muonTrack->GetInverseBendingMomentum()); if (ptInv > 0.001) { hPtMUON->Fill(1./ptInv); } } } // loop over V0s for (Int_t iV0 = 0; iV0 < esd->GetNumberOfV0s(); iV0++) { AliESDv0* v0 = esd->GetV0(iV0); if (v0->GetOnFlyStatus()) continue; v0->ChangeMassHypothesis(kK0Short); hMassK0->Fill(v0->GetEffMass()); v0->ChangeMassHypothesis(kLambda0); hMassLambda->Fill(v0->GetEffMass()); v0->ChangeMassHypothesis(kLambda0Bar); hMassLambdaBar->Fill(v0->GetEffMass()); Int_t negLabel = TMath::Abs(esd->GetTrack(v0->GetNindex())->GetLabel()); if (negLabel > stack->GetNtrack()) continue; // background Int_t negMother = stack->Particle(negLabel)->GetMother(0); if (negMother < 0) continue; Int_t posLabel = TMath::Abs(esd->GetTrack(v0->GetPindex())->GetLabel()); if (posLabel > stack->GetNtrack()) continue; // background Int_t posMother = stack->Particle(posLabel)->GetMother(0); if (negMother != posMother) continue; TParticle* particle = stack->Particle(negMother); if (!selV0s.Contains(particle)) continue; selV0s.Remove(particle); nRecV0s++; } // loop over Cascades for (Int_t iCascade = 0; iCascade < esd->GetNumberOfCascades(); iCascade++) { AliESDcascade* cascade = esd->GetCascade(iCascade); Double_t v0q; cascade->ChangeMassHypothesis(v0q,kXiMinus); hMassXi->Fill(cascade->GetEffMassXi()); cascade->ChangeMassHypothesis(v0q,kOmegaMinus); hMassOmega->Fill(cascade->GetEffMassXi()); Int_t negLabel = TMath::Abs(esd->GetTrack(cascade->GetNindex()) ->GetLabel()); if (negLabel > stack->GetNtrack()) continue; // background Int_t negMother = stack->Particle(negLabel)->GetMother(0); if (negMother < 0) continue; Int_t posLabel = TMath::Abs(esd->GetTrack(cascade->GetPindex()) ->GetLabel()); if (posLabel > stack->GetNtrack()) continue; // background Int_t posMother = stack->Particle(posLabel)->GetMother(0); if (negMother != posMother) continue; Int_t v0Mother = stack->Particle(negMother)->GetMother(0); if (v0Mother < 0) continue; Int_t bacLabel = TMath::Abs(esd->GetTrack(cascade->GetBindex()) ->GetLabel()); if (bacLabel > stack->GetNtrack()) continue; // background Int_t bacMother = stack->Particle(bacLabel)->GetMother(0); if (v0Mother != bacMother) continue; TParticle* particle = stack->Particle(v0Mother); if (!selCascades.Contains(particle)) continue; selCascades.Remove(particle); nRecCascades++; } // loop over the clusters { for (Int_t iCluster=0; iCluster<esd->GetNumberOfCaloClusters(); iCluster++) { AliESDCaloCluster * clust = esd->GetCaloCluster(iCluster); if (clust->IsPHOS()) hEPHOS->Fill(clust->E()); if (clust->IsEMCAL()) hEEMCAL->Fill(clust->E()); } } } // perform checks if (nGen < checkNGenLow) { Warning("CheckESD", "low number of generated particles: %d", Int_t(nGen)); } TH1F* hEff = CreateEffHisto(hGen, hRec); Info("CheckESD", "%d out of %d tracks reconstructed including %d " "fake tracks", nRec, nGen, nFake); if (nGen > 0) { // efficiency Double_t eff = nRec*1./nGen; Double_t effError = TMath::Sqrt(eff*(1.-eff) / nGen); Double_t fake = nFake*1./nGen; Double_t fakeError = TMath::Sqrt(fake*(1.-fake) / nGen); Info("CheckESD", "eff = (%.1f +- %.1f) %% fake = (%.1f +- %.1f) %%", 100.*eff, 100.*effError, 100.*fake, 100.*fakeError); if (eff < checkEffLow - checkEffSigma*effError) { Warning("CheckESD", "low efficiency: (%.1f +- %.1f) %%", 100.*eff, 100.*effError); } if (fake > checkFakeHigh + checkFakeSigma*fakeError) { Warning("CheckESD", "high fake: (%.1f +- %.1f) %%", 100.*fake, 100.*fakeError); } // resolutions Double_t res, resError; if (FitHisto(hResPtInv, res, resError)) { Info("CheckESD", "relative inverse pt resolution = (%.1f +- %.1f) %%", res, resError); if (res > checkResPtInvHigh + checkResPtInvSigma*resError) { Warning("CheckESD", "bad pt resolution: (%.1f +- %.1f) %%", res, resError); } } if (FitHisto(hResPhi, res, resError)) { Info("CheckESD", "phi resolution = (%.1f +- %.1f) mrad", res, resError); if (res > checkResPhiHigh + checkResPhiSigma*resError) { Warning("CheckESD", "bad phi resolution: (%.1f +- %.1f) mrad", res, resError); } } if (FitHisto(hResTheta, res, resError)) { Info("CheckESD", "theta resolution = (%.1f +- %.1f) mrad", res, resError); if (res > checkResThetaHigh + checkResThetaSigma*resError) { Warning("CheckESD", "bad theta resolution: (%.1f +- %.1f) mrad", res, resError); } } // PID if (nRec > 0) { Double_t eff = nIdentified*1./nRec; Double_t effError = TMath::Sqrt(eff*(1.-eff) / nRec); Info("CheckESD", "PID eff = (%.1f +- %.1f) %%", 100.*eff, 100.*effError); if (eff < checkPIDEffLow - checkPIDEffSigma*effError) { Warning("CheckESD", "low PID efficiency: (%.1f +- %.1f) %%", 100.*eff, 100.*effError); } } printf("%9s:", "gen\\rec"); for (Int_t iRec = 0; iRec < AliPID::kSPECIES; iRec++) { printf("%9s", partName[iRec]); } printf("\n"); for (Int_t iGen = 0; iGen < AliPID::kSPECIES+1; iGen++) { printf("%9s:", partName[iGen]); for (Int_t iRec = 0; iRec < AliPID::kSPECIES; iRec++) { printf("%9d", identified[iGen][iRec]); } printf("\n"); } if (FitHisto(hResTOFRight, res, resError)) { Info("CheckESD", "TOF resolution = (%.1f +- %.1f) ps", res, resError); if (res > checkResTOFHigh + checkResTOFSigma*resError) { Warning("CheckESD", "bad TOF resolution: (%.1f +- %.1f) ps", res, resError); } } // calorimeters if (hEPHOS->Integral() < checkPHOSNLow) { Warning("CheckESD", "low number of PHOS particles: %d", Int_t(hEPHOS->Integral())); } else { Double_t mean = hEPHOS->GetMean(); if (mean < checkPHOSEnergyLow) { Warning("CheckESD", "low mean PHOS energy: %.1f GeV", mean); } else if (mean > checkPHOSEnergyHigh) { Warning("CheckESD", "high mean PHOS energy: %.1f GeV", mean); } } if (hEEMCAL->Integral() < checkEMCALNLow) { Warning("CheckESD", "low number of EMCAL particles: %d", Int_t(hEEMCAL->Integral())); } else { Double_t mean = hEEMCAL->GetMean(); if (mean < checkEMCALEnergyLow) { Warning("CheckESD", "low mean EMCAL energy: %.1f GeV", mean); } else if (mean > checkEMCALEnergyHigh) { Warning("CheckESD", "high mean EMCAL energy: %.1f GeV", mean); } } // muons if (hPtMUON->Integral() < checkMUONNLow) { Warning("CheckESD", "low number of MUON particles: %d", Int_t(hPtMUON->Integral())); } else { Double_t mean = hPtMUON->GetMean(); if (mean < checkMUONPtLow) { Warning("CheckESD", "low mean MUON pt: %.1f GeV/c", mean); } else if (mean > checkMUONPtHigh) { Warning("CheckESD", "high mean MUON pt: %.1f GeV/c", mean); } } // V0s if (nGenV0s > 0) { Double_t eff = nRecV0s*1./nGenV0s; Double_t effError = TMath::Sqrt(eff*(1.-eff) / nGenV0s); if (effError == 0) effError = checkV0EffLow / TMath::Sqrt(1.*nGenV0s); Info("CheckESD", "V0 eff = (%.1f +- %.1f) %%", 100.*eff, 100.*effError); if (eff < checkV0EffLow - checkV0EffSigma*effError) { Warning("CheckESD", "low V0 efficiency: (%.1f +- %.1f) %%", 100.*eff, 100.*effError); } } // Cascades if (nGenCascades > 0) { Double_t eff = nRecCascades*1./nGenCascades; Double_t effError = TMath::Sqrt(eff*(1.-eff) / nGenCascades); if (effError == 0) effError = checkV0EffLow / TMath::Sqrt(1.*nGenCascades); Info("CheckESD", "Cascade eff = (%.1f +- %.1f) %%", 100.*eff, 100.*effError); if (eff < checkCascadeEffLow - checkCascadeEffSigma*effError) { Warning("CheckESD", "low Cascade efficiency: (%.1f +- %.1f) %%", 100.*eff, 100.*effError); } } } // draw the histograms if not in batch mode if (!gROOT->IsBatch()) { new TCanvas; hEff->DrawCopy(); new TCanvas; hResPtInv->DrawCopy("E"); new TCanvas; hResPhi->DrawCopy("E"); new TCanvas; hResTheta->DrawCopy("E"); new TCanvas; hDEdxRight->DrawCopy(); hDEdxWrong->DrawCopy("SAME"); new TCanvas; hResTOFRight->DrawCopy("E"); hResTOFWrong->DrawCopy("SAME"); new TCanvas; hEPHOS->DrawCopy("E"); new TCanvas; hEEMCAL->DrawCopy("E"); new TCanvas; hPtMUON->DrawCopy("E"); new TCanvas; hMassK0->DrawCopy("E"); new TCanvas; hMassLambda->DrawCopy("E"); new TCanvas; hMassLambdaBar->DrawCopy("E"); new TCanvas; hMassXi->DrawCopy("E"); new TCanvas; hMassOmega->DrawCopy("E"); } // write the output histograms to a file TFile* outputFile = TFile::Open("check.root", "recreate"); if (!outputFile || !outputFile->IsOpen()) { Error("CheckESD", "opening output file check.root failed"); return kFALSE; } hEff->Write(); hResPtInv->Write(); hResPhi->Write(); hResTheta->Write(); hDEdxRight->Write(); hDEdxWrong->Write(); hResTOFRight->Write(); hResTOFWrong->Write(); hEPHOS->Write(); hEEMCAL->Write(); hPtMUON->Write(); hMassK0->Write(); hMassLambda->Write(); hMassLambdaBar->Write(); hMassXi->Write(); hMassOmega->Write(); for(Int_t i = 0; i < 48; i++) fhM[i]->Write(); fhEsdXYP->Write(); fhEsdXYC->Write(); outputFile->Close(); delete outputFile; // clean up delete fhEsdXYC; delete fhEsdXYP; delete [] fhM; delete hGen; delete hRec; delete hEff; delete hResPtInv; delete hResPhi; delete hResTheta; delete hDEdxRight; delete hDEdxWrong; delete hResTOFRight; delete hResTOFWrong; delete hEPHOS; delete hEEMCAL; delete hPtMUON; delete hMassK0; delete hMassLambda; delete hMassLambdaBar; delete hMassXi; delete hMassOmega; delete esd; esdFile->Close(); delete esdFile; runLoader->UnloadHeader(); runLoader->UnloadKinematics(); delete runLoader; // result of check Info("CheckESD", "check of ESD was successfull"); return kTRUE; }
const char *Name(int idx) { if (!idx) return "__ALL__"; TObject *tn = mArray.At(idx); return (tn)? tn->GetName():0;}
TObjArray* ProcessSummary(TObjArray* arrs, int icl, const char* pref) { // Process TObjArray (e.g. for set of pt bins) of TObjArray of KMCTrackSummary objects: // pick the KMCTrackSummary for "summary class" icl (definition of acceptable track) and create // graphs vs bin. // These graphs are returned in new TObjArray // TString prefs = pref; if (!gs) gs = new TF1("gs","gaus",-1,1); // int nb = arrs->GetEntriesFast(); TObjArray* sums = (TObjArray*) arrs->At(0); int nclass = sums->GetEntriesFast(); if (icl>=nclass) {printf("summary set has %d classes only, %d requested\n",nclass,icl);return 0;} // KMCTrackSummary* sm = (KMCTrackSummary*)sums->At(icl); // TH1* h; // h = sm->GetHMCSigDCARPhi(); // MC resolution in transverse DCA TGraphErrors * grSigD = 0; if (h) { grSigD = new TGraphErrors(nb); grSigD->SetName(Form("%s%s",prefs.Data(),h->GetName())); grSigD->SetTitle(Form("%s%s",prefs.Data(),h->GetTitle())); } // TGraphErrors * grSigZ = 0; h = sm->GetHMCSigDCAZ(); // MC resolution in Z DCA if (h) { grSigZ = new TGraphErrors(nb); grSigZ->SetName(Form("%s%s",prefs.Data(),h->GetName())); grSigZ->SetTitle(Form("%s%s",prefs.Data(),h->GetTitle())); } // TGraphErrors * grSigAD = 0; // anaitical estimate for resolution in transverse DCA { grSigAD = new TGraphErrors(nb); grSigAD->SetName(Form("%s%s",prefs.Data(),"sigmaDan")); grSigAD->SetTitle(Form("%s%s",prefs.Data(),"#sigmaD an")); } // TGraphErrors * grSigAZ = 0; // anaitical estimate for resolution in Z DCA { grSigAZ = new TGraphErrors(nb); grSigAZ->SetName(Form("%s%s",prefs.Data(),"sigmaZan")); grSigAZ->SetTitle(Form("%s%s",prefs.Data(),"#sigmaZ an")); } // // TGraphErrors * grSigPt = 0; // MC res. in pt { grSigPt = new TGraphErrors(nb); grSigPt->SetName(Form("%s%s",prefs.Data(),"sigmaPt")); grSigPt->SetTitle(Form("%s%s",prefs.Data(),"#sigmaPt")); } // TGraphErrors * grSigAPt = 0; // analitycal res. in pt { grSigAPt = new TGraphErrors(nb); grSigAPt->SetName(Form("%s%s",prefs.Data(),"sigmaPtan")); grSigAPt->SetTitle(Form("%s%s",prefs.Data(),"#sigmaPt an")); } // TGraphErrors * grEff = 0; // MC efficiency { grEff = new TGraphErrors(nb); grEff->SetName(Form("%s_rate",prefs.Data())); grEff->SetTitle(Form("%s Rate",prefs.Data())); } // TGraphErrors * grUpd = 0; // number of Kalman track updates { grUpd = new TGraphErrors(nb); grUpd->SetName(Form("%s_updCalls",prefs.Data())); grUpd->SetTitle(Form("%s Updates",prefs.Data())); } // for (int ib=0;ib<nb;ib++) { sums = (TObjArray*) arrs->At(ib); sm = (KMCTrackSummary*)sums->At(icl); KMCProbe& prbRef = sm->GetRefProbe(); KMCProbe& prbAn = sm->GetAnProbe(); double pt = prbRef.Pt(); // if (grSigAD) { grSigAD->SetPoint(ib, pt,prbAn.GetSigmaY2()>0 ? TMath::Sqrt(prbAn.GetSigmaY2()) : 0.); } // if (grSigAZ) { grSigAZ->SetPoint(ib, pt,prbAn.GetSigmaZ2()>0 ? TMath::Sqrt(prbAn.GetSigmaZ2()) : 0.); } // if (grSigAPt) { double pts = TMath::Sqrt(prbAn.GetSigma1Pt2()); grSigAPt->SetPoint(ib, pt,pts>0 ? pts*pt : 0.); } // if (grSigPt) { h = sm->GetHMCSigPt(); h->Fit(gs,"0q"); grSigPt->SetPoint(ib, pt, gs->GetParameter(2)); grSigPt->SetPointError(ib, 0, gs->GetParError(2)); } // if (grSigD) { h = sm->GetHMCSigDCARPhi(); h->Fit(gs,"0q"); grSigD->SetPoint(ib, pt,gs->GetParameter(2)); grSigD->SetPointError(ib, 0,gs->GetParError(2)); } // if (grSigZ) { h = sm->GetHMCSigDCAZ(); h->Fit(gs,"0q"); grSigZ->SetPoint(ib, pt,gs->GetParameter(2)); grSigZ->SetPointError(ib, 0,gs->GetParError(2)); } // if (grEff) { grEff->SetPoint(ib, pt,sm->GetEff()); grEff->SetPointError(ib, 0,sm->GetEffErr()); } // if (grUpd) { grUpd->SetPoint(ib, pt,sm->GetUpdCalls()); grUpd->SetPointError(ib, 0, 0); } } // TObjArray* dest = new TObjArray(); dest->AddAtAndExpand(grSigAD,kSigAD); dest->AddAtAndExpand(grSigAZ,kSigAZ); dest->AddAtAndExpand(grSigAPt,kSigAPt); dest->AddAtAndExpand(grSigD,kSigD); dest->AddAtAndExpand(grSigZ,kSigZ); dest->AddAtAndExpand(grSigPt,kSigPt); dest->AddAtAndExpand(grEff,kEff); dest->AddAtAndExpand(grUpd,kUpd); // if (!prefs.IsNull()) dest->SetName(pref); return dest; }
void MultiHistoOverlap(TString namesandlabels, Int_t nOfFiles, const TString& outDir="./"){ gROOT->Reset(); gROOT->ProcessLine(".L tdrstyle.C"); gROOT->ProcessLine("setTDRStyle()"); // gSystem->Load("libRooFit"); // using namespace RooFit; // preamble TPaveText *cmsprel = new TPaveText(0.19, 0.95, 0.95, 0.99, "NDC"); cmsprel->SetTextSize(0.03); cmsprel->SetTextFont(42); cmsprel->SetFillColor(0); cmsprel->SetBorderSize(0); cmsprel->SetMargin(0.01); cmsprel->SetTextAlign(12); // align left TString text = "CMS Preliminary 2011"; cmsprel->AddText(0.0, 0.5,text); TString text2 = "#sqrt{s} = 7 TeV |#eta_{#mu}|<2.4"; cmsprel->AddText(0.8, 0.5, text2); TList* FileList = new TList(); TList* LabelList = new TList(); TObjArray *nameandlabelpairs = namesandlabels.Tokenize(","); for (Int_t i = 0; i < nameandlabelpairs->GetEntries(); ++i) { TObjArray *aFileLegPair = TString(nameandlabelpairs->At(i)->GetName()).Tokenize("="); if(aFileLegPair->GetEntries() == 2) { FileList->Add( TFile::Open(aFileLegPair->At(0)->GetName()) ); LabelList->Add( aFileLegPair->At(1) ); } else { std::cout << "Please give file name and legend entry in the following form:\n" << " filename1=legendentry1,filename2=legendentry2\n"; } } Int_t NOfFiles = FileList->GetSize(); if ( NOfFiles!=nOfFiles ){ std::cout<<"&MSG-e: NOfFiles = "<<nOfFiles<<std::endl; return; } std::vector<TString> LegLabels; LegLabels.reserve(nOfFiles); for(Int_t j=0; j < nOfFiles; j++) { TObjString* legend = (TObjString*)LabelList->At(j); LegLabels.push_back(legend->String()); std::cout<<"LegLabels["<<j<<"]"<<LegLabels[j]<<std::endl; } TLegend *leg=0; TCanvas* c0 = new TCanvas("c0", "c0",50, 20, 800,600); TCanvas* c1 = new TCanvas("c1", "c1",50, 20, 800,600); TCanvas* c2 = new TCanvas("c2", "c2",50, 20, 800,600); TCanvas* c3 = new TCanvas("c3", "c3",50, 20, 800,600); TCanvas* c4 = new TCanvas("c4", "c4",50, 20, 800,600); TCanvas* c5 = new TCanvas("c5", "c5",50, 20, 1200,800); TCanvas* c6 = new TCanvas("c6", "c6",50, 20, 1200,800); TCanvas* c0s = new TCanvas("c0s", "c0s",50, 20, 800,600); TCanvas* c1s = new TCanvas("c1s", "c1s",50, 20, 800,600); TCanvas* c2s = new TCanvas("c2s", "c2s",50, 20, 800,600); TCanvas* c3s = new TCanvas("c3s", "c3s",50, 20, 800,600); TCanvas* cFit = new TCanvas("cFit", "cFit",50, 20, 1600, 800); //----------------- CANVAS C0 --------------// c0->SetFillColor(0); c0->cd(); leg = new TLegend(0.50,0.25,0.90,0.40); leg->SetBorderSize(1); leg->SetFillColor(0); leg->SetTextFont(42); // Mass VS muon phi plus ------------------------------- TH1D *histoMassVsPhiPlus[nOfFiles]; for(Int_t j=0; j < nOfFiles; j++) { TFile *fin = (TFile*)FileList->At(j); if (( histoMassVsPhiPlus[j] = (TH1D*)fin->Get("MassVsPhiPlus/allHistos/meanHisto"))){ histoMassVsPhiPlus[j]->SetLineStyle(linestylelist[j]); histoMassVsPhiPlus[j]->SetMarkerColor(colorlist[j]); histoMassVsPhiPlus[j]->SetLineColor(colorlist[j]); histoMassVsPhiPlus[j]->SetMarkerStyle(markerstylelist[j]); // histoMassVsPhiPlus[j]->SetMarkerSize(0.75); if ( j == 0 ) { histoMassVsPhiPlus[j]->GetXaxis()->SetTitle("positive muon #phi (rad)"); histoMassVsPhiPlus[j]->GetYaxis()->SetTitle("M_{#mu#mu} (GeV)"); // histoMassVsPhiPlus[j]->GetYaxis()->SetRangeUser(88.5,93.5); histoMassVsPhiPlus[j]->GetYaxis()->SetRangeUser(90.0,91.5); histoMassVsPhiPlus[j]->GetXaxis()->SetRangeUser(-3.14,3.14); histoMassVsPhiPlus[j]->Draw(); } else { histoMassVsPhiPlus[j]->Draw("SAME"); } leg->AddEntry(histoMassVsPhiPlus[j],LegLabels[j],"PL"); } } //cmsprel->Draw("same"); leg->Draw("same"); c0->SaveAs(outDir+"MassVsPhiPlus.png"); //----------------- CANVAS C1 --------------// c1->SetFillColor(0); c1->cd(); leg = new TLegend(0.50,0.25,0.90,0.40); leg->SetBorderSize(1); leg->SetFillColor(0); leg->SetTextFont(42); // Mass VS muon eta plus ------------------------------- TH1D *histoMassVsEtaPlus[nOfFiles]; for(Int_t j=0; j < nOfFiles; j++) { TFile *fin = (TFile*)FileList->At(j); if (( histoMassVsEtaPlus[j] = (TH1D*)fin->Get("MassVsEtaPlus/allHistos/meanHisto"))){ histoMassVsEtaPlus[j]->SetLineStyle(linestylelist[j]); histoMassVsEtaPlus[j]->SetMarkerColor(colorlist[j]); histoMassVsEtaPlus[j]->SetLineColor(colorlist[j]); histoMassVsEtaPlus[j]->SetMarkerStyle(markerstylelist[j]); // histoMassVsEtaPlus[j]->SetMarkerSize(0.75); if ( j == 0 ) { histoMassVsEtaPlus[j]->GetXaxis()->SetTitle("positive muon #eta"); histoMassVsEtaPlus[j]->GetYaxis()->SetTitle("M_{#mu#mu} (GeV)"); // histoMassVsEtaPlus[j]->GetYaxis()->SetRangeUser(88.5,93.5); histoMassVsEtaPlus[j]->GetYaxis()->SetRangeUser(90.0,91.5); histoMassVsEtaPlus[j]->GetXaxis()->SetRangeUser(-2.41,2.41); histoMassVsEtaPlus[j]->Draw(); } else { histoMassVsEtaPlus[j]->Draw("SAME"); } leg->AddEntry(histoMassVsEtaPlus[j],LegLabels[j],"PL"); } } //cmsprel->Draw("same"); leg->Draw("same"); c1->SaveAs(outDir+"MassVsEtaPlus.png"); //----------------- CANVAS C2 --------------// c2->SetFillColor(0); c2->cd(); leg = new TLegend(0.50,0.25,0.90,0.40); leg->SetBorderSize(1); leg->SetFillColor(0); leg->SetTextFont(42); // Mass VS muon eta plus - eta minus ------------------------------- TH1D *histoMassVsEtaPlusMinusDiff[nOfFiles]; for(Int_t j=0; j < nOfFiles; j++) { TFile *fin = (TFile*)FileList->At(j); if (( histoMassVsEtaPlusMinusDiff[j] = (TH1D*)fin->Get("MassVsEtaPlusMinusDiff/allHistos/meanHisto"))){ histoMassVsEtaPlusMinusDiff[j]->SetLineStyle(linestylelist[j]); histoMassVsEtaPlusMinusDiff[j]->SetMarkerColor(colorlist[j]); histoMassVsEtaPlusMinusDiff[j]->SetLineColor(colorlist[j]); histoMassVsEtaPlusMinusDiff[j]->SetMarkerStyle(markerstylelist[j]); // histoMassVsEtaPlusMinusDiff[j]->SetMarkerSize(0.75); if ( j == 0 ) { histoMassVsEtaPlusMinusDiff[j]->GetXaxis()->SetTitle("#eta pos. muon #eta neg. muon"); histoMassVsEtaPlusMinusDiff[j]->GetYaxis()->SetTitle("M_{#mu#mu} (GeV)"); // histoMassVsEtaPlusMinusDiff[j]->GetYaxis()->SetRangeUser(88.0,96.0); histoMassVsEtaPlusMinusDiff[j]->GetYaxis()->SetRangeUser(90.0,91.5); histoMassVsEtaPlusMinusDiff[j]->GetXaxis()->SetRangeUser(-3,3); histoMassVsEtaPlusMinusDiff[j]->Draw(); } else { histoMassVsEtaPlusMinusDiff[j]->Draw("SAME"); } leg->AddEntry(histoMassVsEtaPlusMinusDiff[j],LegLabels[j],"PL"); } } //cmsprel->Draw("same"); leg->Draw("same"); c2->SaveAs(outDir+"MassVsEtaPlusMinusDiff.png"); //----------------- CANVAS C3 --------------// c3->SetFillColor(0); c3->cd(); leg = new TLegend(0.50,0.25,0.90,0.40); leg->SetBorderSize(1); leg->SetFillColor(0); leg->SetTextFont(42); // Mass VS muon phi minus ------------------------------- TH1D *histoMassVsPhiMinus[nOfFiles]; for(Int_t j=0; j < nOfFiles; j++) { TFile *fin = (TFile*)FileList->At(j); if (( histoMassVsPhiMinus[j] = (TH1D*)fin->Get("MassVsPhiMinus/allHistos/meanHisto"))){ histoMassVsPhiMinus[j]->SetLineStyle(linestylelist[j]); histoMassVsPhiMinus[j]->SetMarkerColor(colorlist[j]); histoMassVsPhiMinus[j]->SetLineColor(colorlist[j]); histoMassVsPhiMinus[j]->SetMarkerStyle(markerstylelist[j]); // histoMassVsPhiMinus[j]->SetMarkerSize(0.75); if ( j == 0 ) { histoMassVsPhiMinus[j]->GetXaxis()->SetTitle("negative muon #phi (rad)"); histoMassVsPhiMinus[j]->GetYaxis()->SetTitle("M_{#mu#mu} (GeV)"); // histoMassVsPhiMinus[j]->GetYaxis()->SetRangeUser(88.5,93.5); histoMassVsPhiMinus[j]->GetYaxis()->SetRangeUser(90.0,91.5); histoMassVsPhiMinus[j]->GetXaxis()->SetRangeUser(-3.14,3.14); histoMassVsPhiMinus[j]->Draw(); } else { histoMassVsPhiMinus[j]->Draw("SAME"); } leg->AddEntry(histoMassVsPhiMinus[j],LegLabels[j],"PL"); } } //cmsprel->Draw("same"); leg->Draw("same"); c3->SaveAs(outDir+"MassVsPhiMinus.png"); //----------------- CANVAS C4 --------------// c4->SetFillColor(0); c4->cd(); leg = new TLegend(0.50,0.25,0.90,0.40); leg->SetBorderSize(1); leg->SetFillColor(0); leg->SetTextFont(42); // Mass VS muon eta minus ------------------------------- TH1D *histoMassVsEtaMinus[nOfFiles]; for(Int_t j=0; j < nOfFiles; j++) { TFile *fin = (TFile*)FileList->At(j); if (( histoMassVsEtaMinus[j] = (TH1D*)fin->Get("MassVsEtaMinus/allHistos/meanHisto"))){ histoMassVsEtaMinus[j]->SetLineStyle(linestylelist[j]); histoMassVsEtaMinus[j]->SetMarkerColor(colorlist[j]); histoMassVsEtaMinus[j]->SetLineColor(colorlist[j]); histoMassVsEtaMinus[j]->SetMarkerStyle(markerstylelist[j]); // histoMassVsEtaMinus[j]->SetMarkerSize(0.75); if ( j == 0 ) { histoMassVsEtaMinus[j]->GetXaxis()->SetTitle("negative muon #eta"); histoMassVsEtaMinus[j]->GetYaxis()->SetTitle("M_{#mu#mu} (GeV)"); // histoMassVsEtaMinus[j]->GetYaxis()->SetRangeUser(88.5,93.5); histoMassVsEtaMinus[j]->GetYaxis()->SetRangeUser(90.0,91.5); histoMassVsEtaMinus[j]->GetXaxis()->SetRangeUser(-2.41,2.41); histoMassVsEtaMinus[j]->Draw(); } else { histoMassVsEtaMinus[j]->Draw("SAME"); } leg->AddEntry(histoMassVsEtaMinus[j],LegLabels[j],"PL"); } } //cmsprel->Draw("same"); leg->Draw("same"); c4->SaveAs(outDir+"MassVsEtaMinus.png"); //----------------- CANVAS C5 --------------// c5->SetFillColor(0); c5->cd(); leg = new TLegend(0.50,0.25,0.90,0.40); leg->SetBorderSize(1); leg->SetFillColor(0); leg->SetTextFont(42); // Mass VS muon phi plus ------------------------------- TH2D *histoMassVsEtaPhiPlus[nOfFiles]; TStyle *newStyle; newStyle->SetPalette(1); // newStyle->SetOptTitle(1); Double_t zMin(82.); Double_t zMax(96.); for(Int_t j=0; j < nOfFiles; j++) { TFile *fin = (TFile*)FileList->At(j); if (( histoMassVsEtaPhiPlus[j] = (TH2D*)fin->Get("MassVsEtaPhiPlus/allHistos/meanHisto"))){ if ( j == 0 ) { histoMassVsEtaPhiPlus[j]->SetTitle(LegLabels[j]); histoMassVsEtaPhiPlus[j]->GetXaxis()->SetTitle("positive muon #phi (rad)"); histoMassVsEtaPhiPlus[j]->GetYaxis()->SetTitle("positive muon #eta"); zMin = histoMassVsEtaPhiPlus[j]->GetMinimum(); zMax = histoMassVsEtaPhiPlus[j]->GetMaximum(); histoMassVsEtaPhiPlus[j]->Draw("COLZ"); c5->SaveAs(outDir+"MassVsEtaPhiPlus_file0.png"); } else { histoMassVsEtaPhiPlus[j]->SetTitle(LegLabels[j]); histoMassVsEtaPhiPlus[j]->SetMinimum(zMin); histoMassVsEtaPhiPlus[j]->SetMaximum(zMax); histoMassVsEtaPhiPlus[j]->Draw("COLZ"); c5->SaveAs(outDir+"MassVsEtaPhiPlus_file"+(TString)Form("%d",(Int_t)j)+".png"); } } } //cmsprel->Draw("same"); // //----------------- CANVAS C6 --------------// // c6->SetFillColor(0); // c6->cd(); // leg = new TLegend(0.50,0.25,0.90,0.40); // leg->SetBorderSize(1); // leg->SetFillColor(0); // leg->SetTextFont(42); // // Mass VS muon phi minus ------------------------------- // TH2D *histoMassVsEtaPhiMinus[nOfFiles]; // for(Int_t j=0; j < nOfFiles; j++) { // TFile *fin = (TFile*)FileList->At(j); // if (( histoMassVsEtaPhiMinus[j] = (TH2D*)fin->Get("MassVsEtaPhiMinus/allHistos/meanHisto"))){ // if ( j == 0 ) { // histoMassVsEtaPhiMinus[j]->GetXaxis()->SetTitle("negative muon #phi (rad)"); // histoMassVsEtaPhiMinus[j]->GetYaxis()->SetTitle("negative muon #eta"); // zMin = histoMassVsEtaPhiMinus[j]->GetMinimum(); // zMax = histoMassVsEtaPhiMinus[j]->GetMaximum(); // histoMassVsEtaPhiMinus[j]->Draw(); // } else { // histoMassVsEtaPhiMinus[j]->SetMinimum(zMin); // histoMassVsEtaPhiMinus[j]->SetMaximum(zMax); // histoMassVsEtaPhiMinus[j]->Draw("SAME"); // } // leg->AddEntry(histoMassVsEtaPhiMinus[j],LegLabels[j],"PL"); // } // } // //cmsprel->Draw("same"); // leg->Draw("same"); // c6->SaveAs(outDir+"MassVsEtaPhiMinus.png"); // newStyle->SetOptTitle(0); const Color_t colorlist_resol[7]={kBlack,kGreen,kBlue,kMagenta,kCyan,kTeal,kRed}; const Int_t linestylelist_resol[7]={1,1,1,1,1,1,1}; const Int_t stylelist_resol[7]={1,1,1,1,1,1,1}; const Style_t markerstylelist_resol[7]={kOpenCircle,kOpenTriangleUp,kOpenTriangleUp,kOpenCircle,kOpenTriangleUp,kOpenCircle,kOpenTriangleUp}; // //----------------- CANVAS C0S --------------// // c0s->SetFillColor(0); // c0s->cd(); // leg = new TLegend(0.50,0.25,0.90,0.40); // leg->SetBorderSize(1); // leg->SetFillColor(0); // leg->SetTextFont(42); // // Sigma VS muon phi plus ------------------------------- // TH1D *histoSigmaVsPhiPlus[nOfFiles]; // for(Int_t j=0; j < nOfFiles; j++) { // TFile *fin = (TFile*)FileList->At(j); // if (( histoSigmaVsPhiPlus[j] = (TH1D*)fin->Get("MassVsPhiPlus/allHistos/sigmaHisto"))){ // histoSigmaVsPhiPlus[j]->SetLineStyle(linestylelist_resol[j]); // histoSigmaVsPhiPlus[j]->SetMarkerColor(colorlist_resol[j]); // histoSigmaVsPhiPlus[j]->SetLineColor(colorlist_resol[j]); // histoSigmaVsPhiPlus[j]->SetMarkerStyle(markerstylelist_resol[j]); // // histoSigmaVsPhiPlus[j]->SetMarkerSize(0.75); // if ( j == 0 ) { // histoSigmaVsPhiPlus[j]->GetXaxis()->SetTitle("positive muon #phi (rad)"); // histoSigmaVsPhiPlus[j]->GetYaxis()->SetTitle("#sigma(M_{#mu#mu}) (GeV)"); // // histoSigmaVsPhiPlus[j]->GetYaxis()->SetRangeUser(88.5,93.5); // histoSigmaVsPhiPlus[j]->GetYaxis()->SetRangeUser(0.,3.); // histoSigmaVsPhiPlus[j]->GetXaxis()->SetRangeUser(-3.14,3.14); // histoSigmaVsPhiPlus[j]->Draw(); // } else { // histoSigmaVsPhiPlus[j]->Draw("SAME"); // } // leg->AddEntry(histoSigmaVsPhiPlus[j],LegLabels[j],"PL"); // } // } // //cmsprel->Draw("same"); // leg->Draw("same"); // c0s->SaveAs(outDir+"SigmaVsPhiPlus.png"); //----------------- CANVAS C1S --------------// c1s->SetFillColor(0); c1s->cd(); leg = new TLegend(0.50,0.25,0.90,0.40); leg->SetBorderSize(1); leg->SetFillColor(0); leg->SetTextFont(42); // Sigma VS muon eta plus ------------------------------- TH1D *histoSigmaVsEtaPlus[nOfFiles]; for(Int_t j=0; j < nOfFiles; j++) { TFile *fin = (TFile*)FileList->At(j); if (( histoSigmaVsEtaPlus[j] = (TH1D*)fin->Get("MassVsEtaPlus/allHistos/sigmaHisto"))){ histoSigmaVsEtaPlus[j]->SetLineStyle(linestylelist_resol[j]); histoSigmaVsEtaPlus[j]->SetMarkerColor(colorlist_resol[j]); histoSigmaVsEtaPlus[j]->SetLineColor(colorlist_resol[j]); histoSigmaVsEtaPlus[j]->SetMarkerStyle(markerstylelist_resol[j]); // histoSigmaVsEtaPlus[j]->SetMarkerSize(0.75); if ( j == 0 ) { histoSigmaVsEtaPlus[j]->GetXaxis()->SetTitle("positive muon #eta"); histoSigmaVsEtaPlus[j]->GetYaxis()->SetTitle("#sigma(M_{#mu#mu}) (GeV)"); // histoSigmaVsEtaPlus[j]->GetYaxis()->SetRangeUser(88.5,93.5); histoSigmaVsEtaPlus[j]->GetYaxis()->SetRangeUser(0.,3.); histoSigmaVsEtaPlus[j]->GetXaxis()->SetRangeUser(-2.41,2.41); histoSigmaVsEtaPlus[j]->Draw(); } else { histoSigmaVsEtaPlus[j]->Draw("SAME"); } leg->AddEntry(histoSigmaVsEtaPlus[j],LegLabels[j],"PL"); } } //cmsprel->Draw("same"); leg->Draw("same"); c1s->SaveAs(outDir+"SigmaVsEtaPlus.png"); // //----------------- CANVAS C2S --------------// // c2s->SetFillColor(0); // c2s->cd(); // leg = new TLegend(0.50,0.25,0.90,0.40); // leg->SetBorderSize(1); // leg->SetFillColor(0); // leg->SetTextFont(42); // // Sigma VS muon eta plus - eta minus ------------------------------- // TH1D *histoSigmaVsEtaPlusMinusDiff[nOfFiles]; // for(Int_t j=0; j < nOfFiles; j++) { // TFile *fin = (TFile*)FileList->At(j); // if (( histoSigmaVsEtaPlusMinusDiff[j] = (TH1D*)fin->Get("MassVsEtaPlusMinusDiff/allHistos/sigmaHisto"))){ // histoSigmaVsEtaPlusMinusDiff[j]->SetLineStyle(linestylelist_resol[j]); // histoSigmaVsEtaPlusMinusDiff[j]->SetMarkerColor(colorlist_resol[j]); // histoSigmaVsEtaPlusMinusDiff[j]->SetLineColor(colorlist_resol[j]); // histoSigmaVsEtaPlusMinusDiff[j]->SetMarkerStyle(markerstylelist_resol[j]); // // histoSigmaVsEtaPlusMinusDiff[j]->SetMarkerSize(0.75); // if ( j == 0 ) { // histoSigmaVsEtaPlusMinusDiff[j]->GetXaxis()->SetTitle("#eta pos. muon - #eta neg. muon"); // histoSigmaVsEtaPlusMinusDiff[j]->GetYaxis()->SetTitle("#sigma(M_{#mu#mu}) (GeV)"); // // histoSigmaVsEtaPlusMinusDiff[j]->GetYaxis()->SetRangeUser(88.0,96.0); // histoSigmaVsEtaPlusMinusDiff[j]->GetYaxis()->SetRangeUser(0.,3.); // //histoSigmaVsEtaPlusMinusDiff[j]->GetYaxis()->SetRangeUser(90.60,90.75); // histoSigmaVsEtaPlusMinusDiff[j]->GetXaxis()->SetRangeUser(-3.2,3.2); // histoSigmaVsEtaPlusMinusDiff[j]->Draw(); // } else { // histoSigmaVsEtaPlusMinusDiff[j]->Draw("SAME"); // } // leg->AddEntry(histoSigmaVsEtaPlusMinusDiff[j],LegLabels[j],"PL"); // } // } // //cmsprel->Draw("same"); // leg->Draw("same"); // c2s->SaveAs(outDir+"SigmaVsEtaPlusMinusDiff.png"); // //----------------- CANVAS C3S --------------// // c3s->SetFillColor(0); // c3s->cd(); // leg = new TLegend(0.35,0.15,0.55,0.35); // leg->SetBorderSize(1); // leg->SetFillColor(0); // leg->SetTextFont(42); // // Sigma VS muon pT ------------------------------- // TH1D *histoSigmaVsPt[nOfFiles]; // for(Int_t j=0; j < nOfFiles; j++) { // TFile *fin = (TFile*)FileList->At(j); // if (( histoSigmaVsPt[j] = (TH1D*)fin->Get("MassVsPt/allHistos/sigmaHisto"))){ // histoSigmaVsPt[j]->SetLineStyle(linestylelist_resol[j]); // histoSigmaVsPt[j]->SetMarkerColor(colorlist_resol[j]); // histoSigmaVsPt[j]->SetLineColor(colorlist_resol[j]); // histoSigmaVsPt[j]->SetMarkerStyle(markerstylelist_resol[j]); // // histoSigmaVsPt[j]->SetMarkerSize(0.75); // if ( j == 0 ) { // histoSigmaVsPt[j]->GetXaxis()->SetTitle("muon p_T (GeV)"); // histoSigmaVsPt[j]->GetYaxis()->SetTitle("#sigma(M_{#mu#mu}) (GeV)"); // // histoSigmaVsPt[j]->GetYaxis()->SetRangeUser(88.0,96.0); // histoSigmaVsPt[j]->GetYaxis()->SetRangeUser(0.,3.); // //histoSigmaVsPt[j]->GetYaxis()->SetRangeUser(90.60,90.75); // histoSigmaVsPt[j]->GetXaxis()->SetRangeUser(15.,105.); // histoSigmaVsPt[j]->Draw(); // } else { // histoSigmaVsPt[j]->Draw("SAME"); // } // leg->AddEntry(histoSigmaVsPt[j],LegLabels[j],"PL"); // } // } // //cmsprel->Draw("same"); // leg->Draw("same"); // c3s->SaveAs(outDir+"SigmaVsPt.png"); //----------------- CANVAS CFIT --------------// cFit->SetFillColor(0); cFit->cd(); Float_t nN = TMath::Sqrt(nOfFiles); Int_t nX = (Int_t)nN; if ( nN-nX > 0.5 ) nX++; Int_t nY = (Int_t)(nOfFiles/nX); std::cout << nX << " ," << nY << std::endl; cFit->Divide(nOfFiles,1); // Mass VS muon phi plus ------------------------------- TFile *ZFitFile = new TFile("ZFitFile.root","RECREATE"); RooPlot *histoLineShape[nOfFiles]; for(Int_t j=0; j < nOfFiles; j++) { TFile *fin = (TFile*)FileList->At(j); if (( histoLineShape[j] = (RooPlot*)fin->Get("hRecBestResAllEvents_Mass_frame"))){ std::cout<<"Writing fit histogrem file n. "<<j<<std::endl; histoLineShape[j]->Write(); cFit->cd(j+1); histoLineShape[j]->SetTitle(LegLabels[j]); histoLineShape[j]->Draw(); histoLineShape[j]->GetXaxis()->SetTitle("M_{#mu#mu} (GeV)"); // TPaveText *cmsprel2 = new TPaveText(0.19, 0.95, 0.95, 0.99, "NDC"); // cmsprel2->SetTextSize(0.03); // cmsprel2->SetTextFont(42); // cmsprel2->SetFillColor(0); // cmsprel2->SetBorderSize(0); // cmsprel2->SetMargin(0.01); // cmsprel2->SetTextAlign(12); // align left // cmsprel2->AddText(0.666666, 0.5, LegLabels[j]); } } ZFitFile->Close(); // cmsprel2->Draw("same"); cFit->SaveAs("ZFitFile.root"); return; };
int mergeDigits(TString digitdir, Int_t /*simEvOffset*/) { AliRunLoader *rl = AliRunLoader::Open(digitdir+TString("/galice.root")); AliPHOSLoader *prl = (AliPHOSLoader*)rl->GetDetectorLoader("PHOS"); prl->LoadDigits("UPDATE"); //prl->LoadDigits(); Int_t nEvents = rl->GetNumberOfEvents(); TClonesArray *mydigits = 0; simTree->SetBranchAddress("Digits", &mydigits); Int_t nDigits = 0; Int_t nEmbedDigits = 0; Int_t nOverlappingDigits = 0; Int_t nNewDigits = 0; Int_t nPhosDigits = prl->Digits()->GetEntries(); Int_t nMyEvents = simTree->GetEntries(); std::cout << "Number of real events: " << nEvents << std::endl; std::cout << "Number of sim events: " << nMyEvents << std::endl; nEvents = TMath::Min(nEvents, nMyEvents); std::cout << "Looping over: " << nEvents << std::endl; for (Int_t ev = 0; ev < nEvents; ev++) { rl->GetEvent(ev); simTree->GetEntry(ev); Int_t nMyDigits = mydigits->GetEntries(); //Int_t nDigsFound = 0; nEmbedDigits += nMyDigits; TClonesArray *phosDigits = prl->Digits(); nPhosDigits = prl->Digits()->GetEntries(); for (Int_t iDig = 0; iDig < nPhosDigits; iDig++) { //const AliPHOSDigit *digit = prl->Digit(iDig); AliPHOSDigit *digit = (AliPHOSDigit*)phosDigits->At(iDig); nDigits++; for (Int_t n = 0; n < nMyDigits; n++) { AliPHOSDigit *myDigit = (AliPHOSDigit*)mydigits->At(n); if (digit->GetId() == myDigit->GetId()) { nOverlappingDigits++; break; } } } if(nOverlappingDigits == nMyDigits) { std::cout << "Digits alredy embedded!" << std::endl; continue; } for (Int_t iDig = 0; iDig < nMyDigits; iDig++) { AliPHOSDigit *myDigit = (AliPHOSDigit*)mydigits->At(iDig); if (myDigit) { for (Int_t n = 0; n < nPhosDigits; n++) { //const AliPHOSDigit *digit = prl->Digit(n); AliPHOSDigit *digit = (AliPHOSDigit*)phosDigits->At(n); if (digit->GetId() == myDigit->GetId()) { digit->SetALTROSamplesHG(0, 0); digit->SetALTROSamplesLG(0, 0); *digit += *myDigit; myDigit = 0; break; } } if (myDigit) { TClonesArray *digArray = prl->Digits(); AliPHOSDigit *newDig = new((*digArray)[nPhosDigits+nNewDigits]) AliPHOSDigit(*myDigit); newDig->SetALTROSamplesHG(0, 0); newDig->SetALTROSamplesLG(0, 0); nNewDigits++; } } } phosDigits->Compress(); Int_t ndigits = phosDigits->GetEntries() ; phosDigits->Sort(); // Remove digits that are flagged bad in BCM. Then remove digits that are below threshold for (Int_t i = 0 ; i < ndigits ; i++) { AliPHOSDigit *digit = static_cast<AliPHOSDigit*>( phosDigits->At(i) ) ; //std::cout << digit->GetId() << std::endl; if(digit->GetId()) { vector<Int_t>::iterator it; it = std::find (badChannels.begin(), badChannels.end(), digit->GetId() ); if(*it) { digit->SetEnergy(0.0); } } if(digit->GetEnergy() <= recoParam->GetGlobalAltroThreshold()) { phosDigits->RemoveAt(i); } } //Set indexes in list of digits and make true digitization of the energy phosDigits->Compress(); phosDigits->Sort(); ndigits = phosDigits->GetEntries(); for (Int_t i = 0 ; i < ndigits ; i++) { AliPHOSDigit *digit = static_cast<AliPHOSDigit*>( phosDigits->At(i) ) ; digit->SetIndexInList(i) ; } // -- create Digits branch Int_t bufferSize = 32000 ; TObjArray *branchList = prl->TreeD()->GetListOfBranches(); branchList->RemoveAt(0); TBranch * digitsBranch = prl->TreeD()->Branch("PHOS","TClonesArray",&phosDigits,bufferSize); digitsBranch->Fill() ; prl->WriteDigits("OVERWRITE"); } prl->WriteDigits("OVERWRITE"); std::cout << "# Digits: " << nDigits << std::endl; std::cout << "# Embedded digits: " << nEmbedDigits << std::endl; std::cout << "# Overlapping digits: " << nOverlappingDigits << std::endl; std::cout << "# New digits: " << nNewDigits << std::endl; return 0; }
Int_t runsim(){ TString macro_all= getenv("VMCWORKDIR"); macro_all+="/macros/simall.C"; // Load the Main Simulation macro gROOT->LoadMacro(macro_all.Data()); //------------------------------------------------- // Monte Carlo type | fMC (TString) //------------------------------------------------- // Geant3: "TGeant3" // Geant4: "TGeant4" // Fluka : "TFluka" TString fMC ="TGeant4"; //------------------------------------------------- // Primaries generation // Event Generator Type | fGene (TString) //------------------------------------------------- TString fGene="mygenerator"; //------------------------------------------------- // Secondaries generation (G4 only) // R3B Spec. PhysicList | fUserPList (Bool_t) // ---------------------------------------------- // VMC Standard kFALSE // R3B Special kTRUE; Bool_t fUserPList= kTRUE; //------------------------------------------------- //- Geometrical Setup Definition //- Non Sensitive | fDetName (String) //------------------------------------------------- // Target: // Magnet: //------------------------------------------------- //- Sensitive | fDetName //------------------------------------------------- // My Detector: MYDET TObjString det0("MYDET"); TObjArray fDetList; fDetList.Add(&det0); //------------------------------------------------- //- N# of Sim. Events | nEvents (Int_t) //------------------------------------------------- Int_t nEvents = 100; //------------------------------------------------- //- EventDisplay | fEventDisplay (Bool_t) //------------------------------------------------- // connected: kTRUE // not connected: kFALSE Bool_t fEventDisplay=kTRUE; // Main Sim function call simall( nEvents, fDetList, fEventDisplay, fMC, fGene, fUserPList ); }
//=================================== VERY DIRTY==COPY OF GRENG // but it knows to replace the specials;!! int64_t gr_engineX (const char* name, int rx, int ry, int rdx, int rdy) { double x[64000],y[64000],dy[64000],dx[64000], bu; int i,j; FILE * pFile; int MAXLINES=64000; // char mystring[1500];// one line TString oneline, title=name, token; // printf("gr_engineX: going to open filename=%s\n", name ); pFile=fopen( name ,"r" ); if (pFile==NULL) { printf("cannot open %s,STOPping\n", name ); return 0; } // error // printf("file opened\n%s",""); //.......................readout HERE.......i i=0; int lastlen;// remove spaces while ((i<MAXLINES)&&( feof(pFile)==0) ){ // printf(" reading line %d...\n", i ); if ( oneline.Gets (pFile, kTRUE) ){//chop true ... continue if not eof // printf(" string==%s\n", oneline.Data() ); //purify .................. start do { lastlen=oneline.Length(); if (oneline.Index(" ")==0){oneline=oneline(1,oneline.Length()-1);} lastlen=oneline.Length(); if (oneline.Index(" ")==lastlen){oneline=oneline(0,oneline.Length()-1);} oneline.ReplaceAll("\t"," "); oneline.ReplaceAll(" "," "); oneline.ReplaceAll(" "," "); // printf(" --- string==<%s> (%d)\n", oneline.Data(), lastlen ); }while( lastlen!=oneline.Length()); // printf(" string==<%s> (%d)\n", oneline.Data(), lastlen ); //purify .................. stop //printf("S=%s\n", oneline.Data() ); //........ parse oneline if ( (oneline.Index("#")==0) || (oneline.Index("@")==0) || (oneline.Index("END")==0) ){ // starts with # - COMMENT HERE // printf( "COMM:%s\n", oneline.Data() ); if (title.Length()==0){ title=oneline( 1,oneline.Length()-1 );} // title=oneline( oneline.Length(),oneline.Length()-1 ); }else{// DATA HERE TObjArray *tar; if (oneline.Length()>0){ // THAT WAS A HECK - 1digit! if (oneline.Index("#")>0){oneline.Remove(oneline.Index("#") );}// # if (oneline.Index("@")>0){oneline.Remove(oneline.Index("@") );}// # if (oneline.Index("END")>0){oneline.Remove(oneline.Index("END") );}// # // oneline.ReplaceAll(oneline.Index("\t"),1," "); oneline.ReplaceAll("\t"," "); x[i]=0; y[i] =0;dx[i]=0;dy[i]=0; j=0; // go through the columns // printf( "NotCM:%s\n", oneline.Data() ); /* * r?? contains a column to use for x,dx,y,dy: */ tar= oneline.Tokenize(" "); // printf("entries==%d\n", tar->GetEntries() ); while( (j<=rx && rx>=0) || (j<=ry && ry>=0) || (j<=rdy && rdy>=0)|| (j<=rdx && rdx>=0)){ if (j<tar->GetEntries()){ token= ((TObjString*)(tar->At(j)))->GetString(); //printf(" %3d %3d token <%s>\n", i,j, token.Data() ); bu= token.Atof(); // if (i<5){ printf(" token <%s> = %f\n", token.Data(), bu ); } if (rx==j) { x[i] =bu;} if (ry==j) { y[i] =bu;} if (rdx==j) { dx[i] =bu;} if (rdy==j) { dy[i] =bu;} }//j<entries j++; }//small while //tar->Delete(); // abandon tar i++;// skip to a next datum if point }// if oneline lenght>1 go thru all //back the loop }//DATA HERE end // printf("%s","data line ended\n"); }//if oneline.Gets false //........ parse oneline }//while //.......................readout HERE end....i //.......................close, create the TGraphErrors fclose( pFile); // TITLE HERE---------------- // title=name; DONE earlier title.ReplaceAll(".","_"); title.ReplaceAll(" ","_"); if (ry>1){title.Append( char(96+ry) ); } // multigraphs from mysql:columns printf("%d elements read. title= /%s/\n", i-1, title.Data() ); // // //IF ALREADY THE GRAPH EXISTS============+> if (gROOT->GetListOfSpecials()->FindObject(title.Data())!=NULL){ TGraphErrors *oldg=(TGraphErrors*)gROOT->GetListOfSpecials()->FindObject(title.Data()); printf(" ... same name already exists in specials tidis=%d\n", oldg->GetXaxis()->GetTimeDisplay() ); // printf("TIMEDISP %d\n",oldg->GetXaxis()->GetTimeDisplay() ); int timdis=oldg->GetXaxis()->GetTimeDisplay(); int lcol=oldg->GetLineColor(); char timc[100]; strcpy(timc,oldg->GetXaxis()->GetTimeFormat() ); for (int jj=0;jj<i;jj++){ //I believe that set 'new' point doesnot crash... oldg->SetPoint(jj,x[jj],y[jj]); oldg->SetPointError(jj,dx[jj],dy[jj]); }//for all jj //however if jj<graph points, it looks nasty while(i<oldg->GetN() ){ //printf("remove point %d < %d\n", i, oldg->GetN() ); oldg->RemovePoint(oldg->GetN()-1);//last? } // printf("TIMEDISP %d\n",oldg->GetXaxis()->GetTimeDisplay() ); oldg->GetXaxis()->SetTimeDisplay( timdis); oldg->GetXaxis()->SetTimeFormat(timc); //if this is already exists: oldg->SetLineColor( lcol) ; return (int64_t)oldg; }else{//if not exists in groot specials : TGraphErrors *g=new TGraphErrors(i,x,y,dx,dy); g->SetMarkerStyle(22); g->SetTitle( title.Data() ); g->SetName( title.Data() ); gROOT->GetListOfSpecials()->Add( g ); printf("added to GetListOfSpecials: %s \n", g->GetName() ); return (int64_t)g; }//if exists already in gROOT Specials // g->Print();// DONT PRINT TABLES //----------------------------------------------------- }// end of the new 201004 version of gr_engine
//___________________________________________________________________ Int_t extractPtResolution(TString pathNameData, TString listName, Int_t chargeMode /*kNegCharge = -1, kAllCharged = 0, kPosCharge = 1*/, Double_t lowerCentrality /*= -2*/, Double_t upperCentrality /*= -2*/, Double_t lowerJetPt /*= -1*/ , Double_t upperJetPt/* = -1*/) { if (listName == "") { listName = pathNameData; listName.Replace(0, listName.Last('/') + 1, ""); listName.ReplaceAll(".root", ""); } TString pathData = pathNameData; pathData.Replace(pathData.Last('/'), pathData.Length(), ""); TH1D* hPtResolutionFit[AliPID::kSPECIES] = {0x0, }; TH2D* hPtResolution[AliPID::kSPECIES] = {0x0, }; THnSparse* hPtResolutionRaw[AliPID::kSPECIES] = {0x0, }; TFile* fileData = TFile::Open(pathNameData.Data()); if (!fileData) { printf("Failed to open data file \"%s\"\n", pathNameData.Data()); return -1; } TObjArray* histList = (TObjArray*)(fileData->Get(listName.Data())); if (!histList) { printf("Failed to load list!\n"); return -1; } Double_t actualLowerCentrality = -2; Double_t actualUpperCentrality = -2; Double_t actualLowerJetPt = -1.; Double_t actualUpperJetPt = -1.; Bool_t restrictJetPtAxis = (lowerJetPt >= 0 && upperJetPt >= 0); const Bool_t restrictCentrality = ((lowerCentrality >= -1) && (upperCentrality >= -1)); for (Int_t species = 0; species < AliPID::kSPECIES; species++) { const TString sparseName = Form("fPtResolution_%s", AliPID::ParticleShortName(species)); hPtResolutionRaw[species] = (THnSparse*)histList->FindObject(sparseName.Data()); if (!hPtResolutionRaw[species]) { printf("Failed to load THnSparse for %s: %s!\n", AliPID::ParticleShortName(species), sparseName.Data()); return -1; } // Set proper errors, if not yet calculated if (!hPtResolutionRaw[species]->GetCalculateErrors()) { std::cout << "Re-calculating errors of " << hPtResolutionRaw[species]->GetName() << "..." << std::endl; hPtResolutionRaw[species]->Sumw2(); Long64_t nBinsPtResolutionRaw = hPtResolutionRaw[species]->GetNbins(); Double_t binContent = 0; for (Long64_t bin = 0; bin < nBinsPtResolutionRaw; bin++) { binContent = hPtResolutionRaw[species]->GetBinContent(bin); hPtResolutionRaw[species]->SetBinError(bin, TMath::Sqrt(binContent)); } } // Integral(lowerCentBinLimit, uppCentBinLimit) will not be restricted if these values are kept const Int_t lowerCentralityBinLimit = restrictCentrality ? hPtResolutionRaw[species]->GetAxis(kPtResCentrality)->FindBin(lowerCentrality + 0.001) : -1; const Int_t upperCentralityBinLimit = restrictCentrality ? hPtResolutionRaw[species]->GetAxis(kPtResCentrality)->FindBin(upperCentrality - 0.001) : -2; if (restrictCentrality) { actualLowerCentrality = hPtResolutionRaw[species]->GetAxis(kPtResCentrality)->GetBinLowEdge(lowerCentralityBinLimit); actualUpperCentrality = hPtResolutionRaw[species]->GetAxis(kPtResCentrality)->GetBinLowEdge(upperCentralityBinLimit); hPtResolutionRaw[species]->GetAxis(kPtResCentrality)->SetRange(lowerCentralityBinLimit, upperCentralityBinLimit); } const Bool_t restrictCharge = (chargeMode != kAllCharged); Int_t lowerChargeBinLimit = -1; Int_t upperChargeBinLimit = -2; if (restrictCharge) { // Add subtract a very small number to avoid problems with values right on the border between to bins if (chargeMode == kNegCharge) { lowerChargeBinLimit = hPtResolutionRaw[species]->GetAxis(kPtResCharge)->FindBin(-1. + 0.001); upperChargeBinLimit = hPtResolutionRaw[species]->GetAxis(kPtResCharge)->FindBin(0. - 0.001); } else if (chargeMode == kPosCharge) { lowerChargeBinLimit = hPtResolutionRaw[species]->GetAxis(kPtResCharge)->FindBin(0. + 0.001); upperChargeBinLimit = hPtResolutionRaw[species]->GetAxis(kPtResCharge)->FindBin(1. - 0.001); } // Check if the values look reasonable if (lowerChargeBinLimit <= upperChargeBinLimit && lowerChargeBinLimit >= 1 && upperChargeBinLimit <= hPtResolutionRaw[species]->GetAxis(kPtResCharge)->GetNbins()) { // OK } else { std::cout << std::endl; std::cout << "Requested charge range out of limits or upper and lower limit are switched!" << std::endl; return -1; } hPtResolutionRaw[species]->GetAxis(kPtResCharge)->SetRange(lowerChargeBinLimit, upperChargeBinLimit); } // If desired, restrict jetPt axis Int_t lowerJetPtBinLimit = -1; Int_t upperJetPtBinLimit = -1; if (restrictJetPtAxis) { // Add subtract a very small number to avoid problems with values right on the border between to bins lowerJetPtBinLimit = hPtResolutionRaw[species]->GetAxis(kPtResJetPt)->FindBin(lowerJetPt + 0.001); upperJetPtBinLimit = hPtResolutionRaw[species]->GetAxis(kPtResJetPt)->FindBin(upperJetPt - 0.001); // Check if the values look reasonable if (lowerJetPtBinLimit <= upperJetPtBinLimit && lowerJetPtBinLimit >= 1 && upperJetPtBinLimit <= hPtResolutionRaw[species]->GetAxis(kPtResJetPt)->GetNbins()) { actualLowerJetPt = hPtResolutionRaw[species]->GetAxis(kPtResJetPt)->GetBinLowEdge(lowerJetPtBinLimit); actualUpperJetPt = hPtResolutionRaw[species]->GetAxis(kPtResJetPt)->GetBinUpEdge(upperJetPtBinLimit); restrictJetPtAxis = kTRUE; } else { std::cout << std::endl; std::cout << "Requested jet pT range out of limits or upper and lower limit are switched!" << std::endl; return -1; } } std::cout << "jet pT: "; if (restrictJetPtAxis) { std::cout << actualLowerJetPt << " - " << actualUpperJetPt << std::endl; hPtResolutionRaw[species]->GetAxis(kPtResJetPt)->SetRange(lowerJetPtBinLimit, upperJetPtBinLimit); } else { std::cout << "All" << std::endl; } hPtResolution[species] = hPtResolutionRaw[species]->Projection(kPtResGenPt, kPtResRecPt, "e"); hPtResolution[species]->SetName(Form("hPtResolution_%s", AliPID::ParticleShortName(species))); hPtResolution[species]->SetTitle(Form("%s", AliPID::ParticleLatexName(species))); hPtResolution[species]->SetStats(kFALSE); hPtResolution[species]->SetLineColor(getLineColorAliPID(species)); hPtResolution[species]->SetMarkerColor(getLineColorAliPID(species)); normaliseHist(hPtResolution[species]); TObjArray aSlices; hPtResolution[species]->FitSlicesY(0, 0, -1, 0, "QNR", &aSlices); TH1D* hMean = (TH1D*)(aSlices.At(1)); TH1D* hSigma = (TH1D*)(aSlices.At(2)); hPtResolutionFit[species] = new TH1D(*hSigma); hPtResolutionFit[species]->SetName(Form("hPtResolutionFit_%s", AliPID::ParticleShortName(species))); hPtResolutionFit[species]->SetTitle(Form("%s", AliPID::ParticleLatexName(species))); hPtResolutionFit[species]->SetLineColor(getLineColorAliPID(species)); hPtResolutionFit[species]->SetMarkerColor(getLineColorAliPID(species)); hPtResolutionFit[species]->Divide(hSigma, hMean); } // Save results to file TString chargeString = ""; if (chargeMode == kPosCharge) chargeString = "_posCharge"; else if (chargeMode == kNegCharge) chargeString = "_negCharge"; TString saveFileName = pathNameData; saveFileName.Replace(0, pathNameData.Last('/') + 1, ""); TString savePath = pathNameData; savePath.ReplaceAll(Form("/%s", saveFileName.Data()), ""); saveFileName.Prepend("output_extractedPTResolution_"); TString centralityString = restrictCentrality ? Form("_centrality_%.0f_%.0f.root", actualLowerCentrality, actualUpperCentrality) : "_centrality_all"; TString jetPtString = restrictJetPtAxis ? Form("_jetPt_%.0f_%.0f.root", actualLowerJetPt, actualUpperJetPt) : ""; saveFileName.ReplaceAll(".root", Form("%s%s%s.root", centralityString.Data(), jetPtString.Data(), chargeString.Data())); TString saveFilePathName = Form("%s/%s", savePath.Data(), saveFileName.Data()); TFile* saveFile = TFile::Open(saveFilePathName.Data(), "RECREATE"); if (!saveFile) { printf("Failed to save results to file \"%s\"!\n", saveFilePathName.Data()); return -1; } saveFile->cd(); for (Int_t species = 0; species < AliPID::kSPECIES; species++) { if (hPtResolution[species]) hPtResolution[species]->Write(); if (hPtResolutionFit[species]) hPtResolutionFit[species]->Write(); } TNamed* settings = new TNamed( Form("Settings: Data file \"%s\", lowerCentrality %.3f, upperCentrality %.3f, lowerJetPt %.1f, upperJetPt %.1f\n", pathNameData.Data(), lowerCentrality, upperCentrality, lowerJetPt, upperJetPt), ""); settings->Write(); saveFile->Close(); return 0; }