void TotXSBin() { Int_t ebin, i, count, chan; Double_t eg[27], deg[27], xs[27], dxs[27]; Double_t egam, xxs, junk; TString name; c1 = new TCanvas( "c1", "Total Cross Sections", 200, 10, 700, 500); c1->SetGrid(); c1->GetFrame()->SetFillColor( 21); c1->GetFrame()->SetBorderSize( 12); // Calculate the bin cross sections // For total cross sections, the theta bin is 0 for 0-180 deg. for ( ebin = 0; ebin < 24; BinXS( ebin+=2, 0)); name = "xs/compton/xs/tot_xs_ebin.out"; ofstream outFile( name); if ( !outFile.is_open()) { cout << "Error opening file "; cout << name; cout << endl; break; } count = 0; for ( ebin = 0; ebin < 24; ebin+=2) { eg[count] = tcdbin[ebin].energy; deg[count] = 0; xs[count] = tcdbin[ebin].xs[0]; dxs[count] = tcdbin[ebin].dxs[0]; outFile << eg[count] << " " << xs[count] << " " << dxs[count++] << endl ; } outFile.close(); // Plot Results gr = new TGraphErrors( count-1, eg, xs, deg, dxs); gr->SetTitle( "Preliminary #gamma p #rightarrow #gamma p Total Cross Section"); gr->SetMarkerStyle( 20); gr->SetMarkerSize( 1.0); gr->SetLineWidth( 3); gr->GetXaxis()->SetTitleOffset( 1.1); gr->GetYaxis()->SetTitleOffset( 1.0); gr->GetYaxis()->SetTitleSize( 0.05); gr->GetXaxis()->SetTitle( "E_{#gamma} (MeV)"); gr->GetYaxis()->SetTitle( "#sigma (#mub)"); gr->GetXaxis()->SetLabelSize( 0.03); gr->GetYaxis()->SetLabelSize( 0.03); gr->GetXaxis()->CenterTitle(); gr->GetYaxis()->CenterTitle(); gr->GetXaxis()->SetRangeUser( 220, 310); gr->SetMaximum( 3); gr->SetMinimum( -0.1); gr->Draw( "AP"); pt = new TLegend( 0.3, 0.7, 0.6, 0.85); pt->SetFillColor( 0); pt->SetBorderSize( 0); pt->SetTextSize( 0.04); pt->AddEntry( gr, "This Work", "p"); // Theory name = "xs/compton/theory/totxs_params.dat"; ifstream inFile( name); if ( !inFile.is_open()) { cout << "Error opening file "; cout << name; cout << endl; break; } i = 0; while( !inFile.eof()) { inFile >> egam >> xxs >> junk >> junk >> junk; eg[i] = egam; xs[i++] = xxs; } inFile.close(); count = i-1; // Plot Results gr1 = new TGraph( count, eg, xs); gr1->SetLineWidth( 2); // gr1->SetLineStyle( 2); // gr1->SetLineColor( 2); gr1->Draw( "Lsame"); pt->AddEntry( gr1, "Pasquini", "l"); pt->Draw(); name = "plots/Compton/xstot_ebin"; name.Append( ".pdf"); c1->Print( name); }
void TMVAMulticlass( TString myMethodList = "" ) { // This loads the library TMVA::Tools::Instance(); // to get access to the GUI and all tmva macros // // TString tmva_dir(TString(gRootDir) + "/tmva"); // if(gSystem->Getenv("TMVASYS")) // tmva_dir = TString(gSystem->Getenv("TMVASYS")); // gROOT->SetMacroPath(tmva_dir + "/test/:" + gROOT->GetMacroPath() ); // gROOT->ProcessLine(".L TMVAMultiClassGui.C"); //--------------------------------------------------------------- // Default MVA methods to be trained + tested std::map<std::string,int> Use; Use["MLP"] = 1; Use["BDTG"] = 1; Use["DNN"] = 0; Use["FDA_GA"] = 0; Use["PDEFoam"] = 0; //--------------------------------------------------------------- std::cout << std::endl; std::cout << "==> Start TMVAMulticlass" << std::endl; if (myMethodList != "") { for (std::map<std::string,int>::iterator it = Use.begin(); it != Use.end(); it++) it->second = 0; std::vector<TString> mlist = TMVA::gTools().SplitString( myMethodList, ',' ); for (UInt_t i=0; i<mlist.size(); i++) { std::string regMethod(mlist[i]); if (Use.find(regMethod) == Use.end()) { std::cout << "Method \"" << regMethod << "\" not known in TMVA under this name. Choose among the following:" << std::endl; for (std::map<std::string,int>::iterator it = Use.begin(); it != Use.end(); it++) std::cout << it->first << " "; std::cout << std::endl; return; } Use[regMethod] = 1; } } // Create a new root output file. TString outfileName = "TMVAMulticlass.root"; TFile* outputFile = TFile::Open( outfileName, "RECREATE" ); TMVA::Factory *factory = new TMVA::Factory( "TMVAMulticlass", outputFile, "!V:!Silent:Color:DrawProgressBar:Transformations=I;D;P;G,D:AnalysisType=multiclass" ); TMVA::DataLoader *dataloader=new TMVA::DataLoader("dataset"); dataloader->AddVariable( "var1", 'F' ); dataloader->AddVariable( "var2", "Variable 2", "", 'F' ); dataloader->AddVariable( "var3", "Variable 3", "units", 'F' ); dataloader->AddVariable( "var4", "Variable 4", "units", 'F' ); TFile *input(0); TString fname = "./tmva_example_multiple_background.root"; if (!gSystem->AccessPathName( fname )) { // first we try to find the file in the local directory std::cout << "--- TMVAMulticlass : Accessing " << fname << std::endl; input = TFile::Open( fname ); } else { std::cout << "Creating testdata...." << std::endl; TString createDataMacro = TString(gROOT->GetTutorialsDir()) + "/tmva/createData.C"; gROOT->ProcessLine(TString::Format(".L %s",createDataMacro.Data())); gROOT->ProcessLine("create_MultipleBackground(2000)"); std::cout << " created tmva_example_multiple_background.root for tests of the multiclass features"<<std::endl; input = TFile::Open( fname ); } if (!input) { std::cout << "ERROR: could not open data file" << std::endl; exit(1); } TTree *signalTree = (TTree*)input->Get("TreeS"); TTree *background0 = (TTree*)input->Get("TreeB0"); TTree *background1 = (TTree*)input->Get("TreeB1"); TTree *background2 = (TTree*)input->Get("TreeB2"); gROOT->cd( outfileName+TString(":/") ); dataloader->AddTree (signalTree,"Signal"); dataloader->AddTree (background0,"bg0"); dataloader->AddTree (background1,"bg1"); dataloader->AddTree (background2,"bg2"); dataloader->PrepareTrainingAndTestTree( "", "SplitMode=Random:NormMode=NumEvents:!V" ); if (Use["BDTG"]) // gradient boosted decision trees factory->BookMethod( dataloader, TMVA::Types::kBDT, "BDTG", "!H:!V:NTrees=1000:BoostType=Grad:Shrinkage=0.10:UseBaggedBoost:BaggedSampleFraction=0.50:nCuts=20:MaxDepth=2"); if (Use["MLP"]) // neural network factory->BookMethod( dataloader, TMVA::Types::kMLP, "MLP", "!H:!V:NeuronType=tanh:NCycles=1000:HiddenLayers=N+5,5:TestRate=5:EstimatorType=MSE"); if (Use["FDA_GA"]) // functional discriminant with GA minimizer factory->BookMethod( dataloader, TMVA::Types::kFDA, "FDA_GA", "H:!V:Formula=(0)+(1)*x0+(2)*x1+(3)*x2+(4)*x3:ParRanges=(-1,1);(-10,10);(-10,10);(-10,10);(-10,10):FitMethod=GA:PopSize=300:Cycles=3:Steps=20:Trim=True:SaveBestGen=1" ); if (Use["PDEFoam"]) // PDE-Foam approach factory->BookMethod( dataloader, TMVA::Types::kPDEFoam, "PDEFoam", "!H:!V:TailCut=0.001:VolFrac=0.0666:nActiveCells=500:nSampl=2000:nBin=5:Nmin=100:Kernel=None:Compress=T" ); if (Use["DNN"]) { TString layoutString ("Layout=TANH|100,TANH|50,TANH|10,LINEAR"); TString training0 ("LearningRate=1e-1, Momentum=0.5, Repetitions=1, ConvergenceSteps=10," " BatchSize=256, TestRepetitions=10, Multithreading=True"); TString training1 ("LearningRate=1e-2, Momentum=0.0, Repetitions=1, ConvergenceSteps=10," " BatchSize=256, TestRepetitions=7, Multithreading=True"); TString trainingStrategyString ("TrainingStrategy="); trainingStrategyString += training0 + "|" + training1; TString nnOptions ("!H:V:ErrorStrategy=CROSSENTROPY:VarTransform=N:" "WeightInitialization=XAVIERUNIFORM:Architecture=STANDARD"); nnOptions.Append (":"); nnOptions.Append (layoutString); nnOptions.Append (":"); nnOptions.Append (trainingStrategyString); factory->BookMethod(dataloader, TMVA::Types::kDNN, "DNN", nnOptions ); } // Train MVAs using the set of training events factory->TrainAllMethods(); // Evaluate all MVAs using the set of test events factory->TestAllMethods(); // Evaluate and compare performance of all configured MVAs factory->EvaluateAllMethods(); // -------------------------------------------------------------- // Save the output outputFile->Close(); std::cout << "==> Wrote root file: " << outputFile->GetName() << std::endl; std::cout << "==> TMVAClassification is done!" << std::endl; delete factory; delete dataloader; // Launch the GUI for the root macros if (!gROOT->IsBatch()) TMVAMultiClassGui( outfileName ); }
int MC_Ratio(int leptonId, double* par1, int npar1bins, double* par2, int npar2bins, TString sel_den , TString sel_num, double cut_num , TString par_x , TString par_y , TString option ){ setTDRStyle(); /////////////// //Get the TTree /////////////// //Location of the .root file TString location2 = "/Users/GLP/Desktop/CERN_data/dyjetsnew/postprocessed/"; //Reading the tree // TChain* tree = new TChain("treeProducerSusyMultilepton"); //DY events //tree->Add(location+"DYJetsToLLM50_PU_S14_POSTLS170.root"); tree->Add(location2+"dyjets_good.root"); //Plot the result Long64_t n = tree->GetEntries(); //Path for input and output file. Written in FitDataPath.txt TString _path = "/Users/GLP/Dropbox/Physique/Master_Thesis/plots_root/MC_eff/"; ////////////////////// //Name for the plots// ////////////////////// TString _filetag = ""; TString pname; TString _pname; TString _par; TString _sel_num; TString _sel_den; TString _option; ////Writing string //particle string if(abs(leptonId) == 11){pname = "e"; _pname = "e";} if(abs(leptonId) == 13){pname = " #mu"; _pname = "mu";} //Parameter string if(par_x == "Pt"){_par = "P_{t}";} else if(par_x == "eta"){_par = "#eta";} else if(par_x == "phi"){_par = "#phi";} //sel_den string if((sel_den == "tightmva")&&(leptonId == 13)){cout<<"ERROR: no tightId MVA defined for the muon !"<<endl;return 1;} if(sel_den == "tightcut"){_sel_den = "tightcut";} else if(sel_den == "tightmva"){_sel_den = "tightmva";} else if(sel_den == "loose"){_sel_den = "loose";} else if(sel_den == ""){_sel_den = "";} else{cout<<"ERROR: wrong sel_denion !";return 1;} //sel_num string if((sel_num == "tightmva")&&(leptonId == 13)){cout<<"ERROR: no tightId MVA defined for the muon !"<<endl;return 1;} if(sel_num == "tightcut"){_sel_num = "tightcut";} else if(sel_num == "tightmva"){_sel_num = "tightmva";} else if(sel_num == ""){_sel_num = "";} else if(sel_num == "loose"){_sel_num = "loose";} else if(sel_num == "reliso3"){_sel_num = Form("reliso3_%0.3lf",cut_num);} else if(sel_num == "reliso4"){_sel_num = Form("reliso4_%0.3lf",cut_num);} else if(sel_num == "chiso3"){_sel_num = Form("chiso3_%0.3lf",cut_num);} else if(sel_num == "chiso4"){_sel_num = Form("chiso4_%0.3lf",cut_num);} else if(sel_num == "dxy"){_sel_num = Form("dxy_%0.3lf",cut_num);} else if(sel_num == "dz"){_sel_num = Form("dz_%0.3lf",cut_num);} else{cout<<"ERROR: wrong numerator name !";return 1;} //option string option.Append(" "); option.Prepend(" "); if(option.Contains(" ll ")){_option += "_ll";} if(option.Contains(" unmatched ")){_option += "_unmatched";} if(option.Contains(" alleta ")){_option += "_alleta";} if(option.Contains(" short ")){_option += "_short";} _option += "_"; //parameter range string TString _par1range; _par1range = Form("%0.3f_"+par_x+"%0.3f",par1[0],par1[npar1bins]); TString _par2range; _par2range = Form("%0.3f_"+par_y+"%0.3f",par2[0],par2[npar2bins]); ///////////////////////////////////// //Write the name of the output file// ///////////////////////////////////// TString _fname = "MCeff"+_filetag+_option+_pname+_par1range+"_"+_par2range+"_den_"+_sel_den+"_num_"+_sel_num; //Output file cout<<"going to create the file"<<endl; //Check if the file exists TFile *fcheck = TFile::Open(_path+_fname+".root", "READ"); if (fcheck) { cout << "File "<<_fname<<" exists ! Please change name" << endl; return 1; } TFile* file_out = new TFile(_path+_fname+".root","recreate"); cout<<"done ! "<<endl; //Declaration of histogram TH1D **histo_num = new TH1D*[npar2bins]; TH1D **histo_den = new TH1D*[npar2bins]; TH1D **eff = new TH1D*[npar2bins]; //Par1 distribution histogram TH1D** histo_par1 = new TH1D*[npar2bins]; //Distribution of the cut parameter whose efficiency is studied TH1D *histo_other_sel = new TH1D("histo_other_sel","h",5,0,5); TH1D *histo_good_sel = new TH1D("histo_good_sel","h",5,0,5); //Histo separate in Lep_good Lep_other // TH1D **histo_num_O = new TH1D*[npar2bins]; TH1D **histo_den_O = new TH1D*[npar2bins]; TH1D **eff_O = new TH1D*[npar2bins]; TH1D **histo_num_G = new TH1D*[npar2bins]; TH1D **histo_den_G = new TH1D*[npar2bins]; TH1D **eff_G = new TH1D*[npar2bins]; //Counter LepGood vs LepOther TH1D **histo_counter = new TH1D*[npar2bins]; TH1D **histo_counter_G_par1 = new TH1D*[npar2bins]; TH1D **histo_counter_O_par1 = new TH1D*[npar2bins]; TH1D **histo_counter_par1 = new TH1D*[npar2bins]; for(int _i = 0; _i < npar2bins; ++_i){ histo_num[_i] = new TH1D("histo_num","Pt",npar1bins,par1[0],par1[npar1bins]); histo_den[_i] = new TH1D("histo_den","Pt",npar1bins,par1[0],par1[npar1bins]); eff[_i] = new TH1D("eff","Pt",npar1bins,par1[0],par1[npar1bins]); // histo_par1[_i] = new TH1D("histo_par1","par1",npar1bins*25,par1[0],par1[npar1bins]); // histo_num_O[_i] = new TH1D("histo_num_O","Pt",npar1bins,par1[0],par1[npar1bins]); histo_den_O[_i] = new TH1D("histo_den_O","Pt",npar1bins,par1[0],par1[npar1bins]); eff_O[_i] = new TH1D("eff_O","Pt",npar1bins,par1[0],par1[npar1bins]); histo_num_G[_i] = new TH1D("histo_num_G","Pt",npar1bins,par1[0],par1[npar1bins]); histo_den_G[_i] = new TH1D("histo_den_G","Pt",npar1bins,par1[0],par1[npar1bins]); eff_G[_i] = new TH1D("eff_G","Pt",npar1bins,par1[0],par1[npar1bins]); histo_counter_G_par1[_i] = new TH1D("histo_counter_G_par1","count",npar1bins,par1[0],par1[npar1bins]); histo_counter_O_par1[_i] = new TH1D("histo_counter_O_par1","count",npar1bins,par1[0],par1[npar1bins]); histo_counter_par1[_i] = new TH1D("histo_counter_par1","count",npar1bins,par1[0],par1[npar1bins]); histo_counter[_i] = new TH1D("histo_counter","count",2,0,2); } //Event variables Int_t evt_id; Double_t scale; //Generated Double_t gen_phi[200]; Double_t gen_eta[200]; Double_t Pt[200]; Double_t m[200]; Int_t Id[200]; Int_t Mo[200]; Double_t charge[200]; Int_t status[200]; Int_t GrMa[200]; Int_t ngenPart; Int_t source[200]; Int_t pile_up; //not loose Int_t On; Int_t Oid[200]; Double_t Opt[200]; Double_t Om[200]; Double_t Oeta[200]; Double_t Ophi[200]; Int_t Oq[200]; Int_t Otight[200]; Int_t Otighte[200]; //Double_t Omvaid[200]; Int_t Oloose[200]; Double_t Oiso3[200]; Double_t Oiso4[200]; Double_t Ochiso3[200]; Double_t Ochiso4[200]; Double_t Odxy[200]; Double_t Odz[200]; //loose Int_t Gn; Int_t Gid[200]; Double_t Gpt[200]; Double_t Gm[200]; Double_t Geta[200]; Double_t Gphi[200]; Int_t Gq[200]; Int_t Gtight[200]; Int_t Gtighte[200]; Int_t Gloose[200]; Double_t Giso3[200]; Double_t Giso4[200]; Double_t Gchiso3[200]; Double_t Gchiso4[200]; Double_t Gdxy[200]; Double_t Gdz[200]; //Assigne branches tree->SetBranchAddress("evt_scale1fb", &scale); tree->SetBranchAddress("evt_id", &evt_id); //generated tree->SetBranchAddress("nGenPart", &ngenPart); tree->SetBranchAddress("GenPart_pdgId", &Id); tree->SetBranchAddress("GenPart_sourceId", &source); tree->SetBranchAddress("GenPart_eta", &gen_eta); tree->SetBranchAddress("GenPart_phi", &gen_phi); tree->SetBranchAddress("GenPart_pt", &Pt); tree->SetBranchAddress("GenPart_mass", &m); tree->SetBranchAddress("GenPart_charge", &charge); tree->SetBranchAddress("GenPart_status", &status); //not loose tree->SetBranchAddress("nLepOther",&On); tree->SetBranchAddress("LepOther_pdgId",&Oid); tree->SetBranchAddress("LepOther_pt",&Opt); tree->SetBranchAddress("LepOther_mass",&Om); tree->SetBranchAddress("LepOther_eta",&Oeta); tree->SetBranchAddress("LepOther_phi",&Ophi); tree->SetBranchAddress("LepOther_charge",&Oq); tree->SetBranchAddress("LepOther_tightId",&Otight); tree->SetBranchAddress("LepOther_eleCutIdCSA14_50ns_v1",&Otighte); tree->SetBranchAddress("LepOther_relIso03",&Oiso3); tree->SetBranchAddress("LepOther_relIso04",&Oiso4); tree->SetBranchAddress("LepOther_chargedHadRelIso03",&Ochiso3); tree->SetBranchAddress("LepOther_chargedHadRelIso04",&Ochiso4); tree->SetBranchAddress("LepOther_dxy",&Odxy); tree->SetBranchAddress("LepOther_dz",&Odz); //Loose tree->SetBranchAddress("nLepGood",&Gn); tree->SetBranchAddress("LepGood_pdgId",&Gid); tree->SetBranchAddress("LepGood_pt",&Gpt); tree->SetBranchAddress("LepGood_mass",&Gm); tree->SetBranchAddress("LepGood_eta",&Geta); tree->SetBranchAddress("LepGood_phi",&Gphi); tree->SetBranchAddress("LepGood_charge",&Gq); tree->SetBranchAddress("LepGood_tightId",&Gtight); tree->SetBranchAddress("LepGood_eleCutIdCSA14_50ns_v1",&Gtighte); tree->SetBranchAddress("LepGood_relIso03",&Giso3); tree->SetBranchAddress("LepGood_relIso04",&Giso4); tree->SetBranchAddress("LepGood_chargedHadRelIso03",&Gchiso3); tree->SetBranchAddress("LepGood_chargedHadRelIso04",&Gchiso4); tree->SetBranchAddress("LepGood_dxy",&Gdxy); tree->SetBranchAddress("LepGood_dz",&Gdz); int count = 0; //Count lepgood/other int goodcount = 0; int othercount = 0; if(option.Contains(" short ")){n = 100000;} //Start loop over all events for (int k = 0; k < n; ++k) { //Declaration of event parameters Int_t evtn; Int_t evtloose[200]; Int_t evtid[200]; Double_t evtpt[200]; Double_t evtm[200]; Double_t evteta[200]; Double_t evtphi[200]; Int_t evtq[200]; Int_t evttight[200]; Int_t evttighte[200]; Double_t evtiso3[200]; Double_t evtiso4[200]; Double_t evtchiso3[200]; Double_t evtchiso4[200]; Double_t evtdxy[200]; Double_t evtdz[200]; if( 100*(double)k/n> count){cout<<count<<endl;++count;} tree->GetEntry(k); //Selection on denominator for(int j = 0; j < Gn+On; ++j){ //Separate here other from loose if(j < On){ evtloose[j] = 0; evtid[j] = Oid[j]; evtpt[j] = Opt[j]; evtm[j] = Om[j]; evteta[j] = Oeta[j]; evtphi[j] = Ophi[j]; evtq[j] = Oq[j]; evttight[j] = Otight[j]; evttighte[j] = Otighte[j]; evtiso3[j] = Oiso3[j]; evtiso4[j] = Oiso4[j]; evtchiso3[j] = Ochiso3[j]; evtchiso4[j] = Ochiso4[j]; evtdxy[j] = Odxy[j]; evtdz[j] = Odz[j]; }else if((j >= On)&&(j < Gn+On)){ evtloose[j] = 1; evtid[j] = Gid[j-On]; evtpt[j] = Gpt[j-On]; evtm[j] = Gm[j-On]; evteta[j] = Geta[j-On]; evtphi[j] = Gphi[j-On]; evtq[j] = Gq[j-On]; evttight[j] = Gtight[j-On]; evttighte[j] = Gtighte[j-On]; evtiso3[j] = Giso3[j-On]; evtiso4[j] = Giso4[j-On]; evtchiso3[j] = Gchiso3[j-On]; evtchiso4[j] = Gchiso4[j-On]; evtdxy[j] = Gdxy[j-On]; evtdz[j] = Gdz[j-On]; } if((!option.Contains(" ll "))||((option.Contains(" ll "))&&(Gn+On == 2)&&(evtq[0] == -evtq[1]))){ if(abs(evtid[j]) == leptonId){ //Cut on the denominator //if((sel_den != "loose")||(evtloose[j] == 1)){ //if(evtloose[j] == 1){ if((sel_den != "tightcut")||(((abs(evtid[j]) == 13)&&(sel_den == "tightcut")&&(evttight[j] == 1 ))||((abs(evtid[j]) == 11)&&(sel_den == "tightcut")&&(evttighte[j] >= 3)))){ if((sel_den != "tightmva")||((abs(evtid[j]) == 11)&&(sel_den == "tightmva")&&(evttight[j] == 1))){ //Veto the EE-EB gape //Variable for matching double R = 999; double delta_P = 999; double delta_charge = 999; //Parameter on the xaxis double par; double par_2; //loop over all generated particles to do the matching for (int i = 0; i < ngenPart; ++i) { if((abs(Id[i]) == leptonId)){ //Electrons selection double R2 = DeltaR(gen_eta[i],evteta[j],gen_phi[i],evtphi[j] ); //Minimise DeltaR and Fill the other variables if (R > R2) { R = R2; delta_P = abs(evtpt[j]-Pt[i])/Pt[i]; delta_charge = abs(evtq[j] - charge[i]); } } } //Choose the parameter to be filled for the eff. if(par_x == "Pt"){par = evtpt[j];} else if(par_x == "eta"){par = evteta[j];} else if(par_x == "phi"){par = evtphi[j];} if(par_y == "Pt"){par_2 = evtpt[j];} else if(par_y == "eta"){par_2 = abs(evteta[j]);} else if(par_y == "phi"){par_2 = abs(evtphi[j]);} //Fill Pt only for matched events if(((R<0.1)&&(delta_P < 0.2)&&(delta_charge < 0.5))||option.Contains(" unmatched ")){ for(int ii = 0; ii < npar2bins; ++ii){ if((par_2 > par2[ii])&&(par_2 <= par2[ii+1])){histo_den[ii]->Fill(par);histo_par1[ii]->Fill(par); if(evtloose[j] == 1){histo_good_sel->Fill(evttighte[j]);} else if(evtloose[j] == 0){histo_other_sel->Fill(evttighte[j]);} else{cout<<"Error !"<<endl; return 1;} } } //Additional cut on the numerator int a = 0; if((sel_num == "tightcut")&&(abs(evtid[j]) == 13)&&(evttight[j] == 1)){a = 1;} if((sel_num == "tightcut")&&(abs(evtid[j]) == 11)&&(evttighte[j] >= 3)){a = 1;} if((sel_num == "reliso3")&&(evtiso3[j] <= cut_num)){a = 2;} if((sel_num == "reliso4")&&(evtiso4[j] <= cut_num)){a = 3;} if((sel_num == "chiso3")&&(evtchiso3[j] <= cut_num)){a = 4;} if((sel_num == "chiso4")&&(evtchiso4[j] <= cut_num)){a = 5;} if((sel_num == "dxy")&&(abs(evtdxy[j]) <= cut_num)){a = 6;} if((sel_num == "dz")&&(abs(evtdz[j]) <= cut_num)){a = 7;} if((sel_num == "tightmva")&&(abs(evtid[j]) == 11)&&(evttight[j] == 1)){a = 9;} if((sel_num == "loose")&&(evtloose[j]) == 1){a = 8;} //Find the corresponding histogram for par2 TH1D* hist; TH1D* hist_evt; bool found = false; for(int _i = 0; _i < npar2bins; ++_i){ if((par_2 > par2[_i])&&(par_2 <= par2[_i+1])){hist = histo_num[_i];found = true;} } if(!found){a = 0;} switch(a){ case 0: break; case 1: hist->Fill(par); break; case 2: hist->Fill(par); break; case 3: hist->Fill(par); break; case 4: hist->Fill(par); break; case 5: hist->Fill(par); break; case 6: hist->Fill(par); break; case 7: hist->Fill(par); break; case 8: hist->Fill(par); break; case 9: hist->Fill(par); break; } } } } } //} } } } mkdir(_path+_fname+"_PDF/", S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); /////////////////// //Draw histograms// /////////////////// //Canvas declaration for(int i = 0; i < npar2bins; ++i){ //////////////////// //Build histograms// //////////////////// histo_num[i]->Sumw2(); histo_den[i]->Sumw2(); eff[i]->Divide(histo_num[i],histo_den[i],1,1,"B"); //histo_num_O[i]->Sumw2(); //histo_den_O[i]->Sumw2(); //eff_O[i]->Divide(histo_num_O[i],histo_den_O[i],1,1,"B"); //histo_num_G[i]->Sumw2(); //histo_den_G[i]->Sumw2(); //eff_G[i]->Divide(histo_num_G[i],histo_den_G[i],1,1,"B"); //histo_counter_G_par1[i]->Sumw2(); //histo_counter_O_par1[i]->Sumw2(); //histo_counter_par1[i]->Divide(histo_counter_O_par1[i],histo_counter_G_par1[i],1,1,"B"); //histo_counter[i]->Fill(0.5,goodcount); //histo_counter[i]->Fill(1.5,othercount); //String for name of the ouput files and histograms titles // TString _parybin; //Parameter string if(par_y == "Pt"){_parybin = Form("%0.f_Pt%0.f",par2[i],par2[i+1]);} else if(par_y == "eta"){_parybin = Form("%0.3f_eta%0.3f",par2[i],par2[i+1]);cout<<"it works !"<<endl;} else if(par_y == "phi"){_parybin = Form("%0.3f_phi%0.3f",par2[i],par2[i+1]);} TString _parytitle; //Title string if(par_y == "Pt"){_parytitle = Form("%0.f #leq P_{t} #leq %0.f",par2[i],par2[i+1]);} else if(par_y == "eta"){_parytitle = Form("%0.3f #leq #||{#eta} #leq %0.3f",par2[i],par2[i+1]);cout<<"it works !"<<endl;} else if(par_y == "phi"){_parytitle = Form("%0.3f #leq #||{#phi} #leq %0.3f",par2[i],par2[i+1]);} //Draw histograms TCanvas* c1 = new TCanvas("c1","c1"); c1->cd(); eff[i]->Draw(); eff[i]->GetYaxis()->SetTitle("#epsilon"); eff[i]->GetXaxis()->SetTitle(_par); eff[i]->GetYaxis()->SetRangeUser(0,1.1); eff[i]->SetMarkerStyle(20); eff[i]->SetMarkerSize(1); eff[i]->SetMarkerColor(4); eff[i]->SetLineColor(4); eff[i]->SetTitle(_sel_num+" for "+_sel_den+" "+pname+" "+_parytitle); TCanvas* c_par1 = new TCanvas("cpar1","cpar1"); TString _partitle = _par + (TString)" distribution for "+pname+", "+_parytitle+", "+sel_num; c_par1->cd(); histo_par1[i]->Draw(); histo_par1[i]->SetTitle(_partitle); histo_par1[i]->GetXaxis()->SetTitle(_par); histo_par1[i]->SetLineWidth(2); histo_par1[i]->SetLineColor(4); histo_par1[i]->SetMarkerColor(4); histo_good_sel->Add(histo_other_sel); TCanvas* csel = new TCanvas("csel","csel"); csel->cd(); histo_good_sel->Draw(); ///////////////////// //Saving the output// ///////////////////// //Write pdf TString cname = "eff"+_filetag+_option+_pname+_par1range+"_"+_parybin+"_den_"+_sel_den+"_num_"+_sel_num; c1->SaveAs(_path+_fname+"_PDF/"+cname+".pdf"); c_par1->SaveAs(_path+_fname+"_PDF/"+cname+"par_distr.pdf"); csel->SaveAs(_path+_fname+"_PDF/"+cname+"sel.pdf"); //Write in output file file_out->cd(); eff[i]->Write("eff"+_parybin); histo_good_sel->Write("sel"+_parybin); //histo_par1[i]->Write("histo_par1_"+_parybin); } file_out->Close(); return 0; }
// iSyst = 0 : Cent // +1 : // -1 : void initIntWght(std::string wFile , int iType , int iSyst, float Hmass = 350, float cprime = 1.0) { // c'=1.0 --> SM if ( iType == 0 ) { //---- ggH TFile* f = new TFile(wFile.c_str() , "READ"); gROOT->cd(); if (hInt_ggH) hInt_ggH->Delete(); hInt_ggH = new TH1F("h_MWW_rel_NNLO_cen","h_MWW_rel_NNLO_cen",2000,0.,4000.); TH1F* hCen = (TH1F*) f->Get("h_MWW_rel_NNLO_cen"); TH1F* hUp = (TH1F*) f->Get("h_MWW_rel_NNLO_mul"); TH1F* hDo = (TH1F*) f->Get("h_MWW_rel_NNLO_add"); // low/high Mass -> no value float firstM = 9999.; float lastM = -1. ; float firstVal = -1; float lastVal = -1; bool foundFirst=false; bool foundLast =false; for ( int iBin = 1 ; iBin <= hCen->GetNbinsX() ; ++iBin ) { float m = hCen->GetBinCenter(iBin); float v = hCen->GetBinContent(iBin); if (v != 0 && ! foundFirst && m < Hmass ) { firstVal = v ; firstM = m ; foundFirst = true; } if ( m > Hmass && v==0) foundLast = true; if (!foundLast) { lastVal = v ; lastM = m ; } } // Create Histograms for ( int iBin = 1 ; iBin <= hInt_ggH->GetNbinsX() ; ++iBin ) { float m = hInt_ggH->GetBinCenter(iBin); if ( m >= hCen->GetXaxis()->GetXmin() && m <= hCen->GetXaxis()->GetXmax() ) { int jBin = hCen->FindBin(m); if (iSyst == 0) hInt_ggH->SetBinContent(iBin,hCen->GetBinContent(jBin)); if (iSyst == 1) hInt_ggH->SetBinContent(iBin,hUp->GetBinContent(jBin)); if (iSyst == -1) hInt_ggH->SetBinContent(iBin,hDo->GetBinContent(jBin)); } if ( m < firstM || m < hCen->GetXaxis()->GetXmin() ) { if (iSyst == 0) hInt_ggH->SetBinContent(iBin,firstVal); if (iSyst == 1) hInt_ggH->SetBinContent(iBin,firstVal*2); if (iSyst == -1) hInt_ggH->SetBinContent(iBin,0. ); } if ( m > lastM || m > hCen->GetXaxis()->GetXmax() ) { if (iSyst == 0) hInt_ggH->SetBinContent(iBin,lastVal); if (iSyst == 1) hInt_ggH->SetBinContent(iBin,0. ); if (iSyst == -1) hInt_ggH->SetBinContent(iBin,lastVal*2); } } //hInt_ggH->Draw(); //hUp->Draw("same"); wInt_ggH = new TSpline3(hInt_ggH) ; wInt_ggH->SetLineColor(kRed); wInt_ggH->Draw("same"); //gPad->WaitPrimitive(); f->Close(); } else if ( iType ==1 ) { //---- qqH TString *readfile = new TString ("data/InterferenceVBF/file_for_interpolation.root"); //file with the values of the all parameters TFile* SI = new TFile(readfile->Data()); Double_t fill_param[16]; // 9 + 7 = 16 for (int i=0; i<9; i++) { TString *name = new TString (parameters_normal[i]); name->Append("_SI.txt"); variables_SI[i] = (TGraph2D*)SI->Get(name->Data()); } for (int i=0; i<7; i++) { TString *name = new TString (parameters_normal[i]); name->Append("_S.txt"); variables_S[i] = (TGraph2D*)SI->Get(name->Data()); } crystal_Icorr_qqH = new TF1("crystal_Icorr_qqH",CrystalBallLowHighPlusExpDividedByCrystalBallLowHigh,0,3000,16); for (int iVar = 0; iVar<9; iVar++) { crystal_Icorr_qqH->SetParameter(iVar, variables_SI[iVar]->Interpolate(Hmass, cprime)); } for (int iVar = 0; iVar<7; iVar++) { crystal_Icorr_qqH->SetParameter(iVar+9, variables_S[iVar]->Interpolate(Hmass, cprime)); } } }
//-------------------------------------------------------------------------------------------------- void plot(long int xStart, long int xStop, TString text, TString save) { // Save names (after machine name) TString sc1 = TString("lagTime") + save + TString(".png"); TString sc2 = TString("downloadSpeed") + save + TString(".png"); TString sc = save + (".png"); // Rates file, pruned by shell script TString inName("./requests.txt"); // File contents TString file, content, version; long int n1, tRequest, n2, tReceived, tComplete; Double_t size; TString machine; // Variables Double_t tLag = 0, tDown = 0, rate = 0; Double_t maxLag = 0, maxDown = 0, maxRate = 0; Int_t nLines = 0, e = 0; bool empty = 0; printf("\nPreview of input file (%s) contents:\n",inName.Data()); ifstream input; input.open(inName.Data()); // First loop to find limits while (1) { // Read file input >> file >> content >> version >> n1 >> tRequest >> n2 >> tReceived >> tComplete >> size >> machine; // Good file? if (! input.good()) break; // During time interval? if (xStart > tReceived) continue; if (xStop < tReceived) continue; // Filter invalid older data if (rejectT3btch(machine)) continue; appendMachine(machine); tLag = tReceived - tRequest; tDown = tComplete - tReceived; rate = size/double(tDown); if (tDown <= 0) { e++; continue; } if (size <= 0) continue; // Preview of input file if (nLines < 5) printf("%s %s %s %d %d %d %d %d %f %s\n", file.Data(),content.Data(),version.Data(), n1,tRequest,n2,tReceived,tComplete,size,machine.Data()); // Find limits if (tLag > maxLag) maxLag = tLag; if (tDown > maxDown) maxDown = tDown; if (rate > maxRate) maxRate = rate; nLines++; } input.close(); printf("\n"); printf("Found %i good requests in interval",nLines); printf("\nMaximum download rate [GB/sec] = %f",maxRate); printf("\nMaximum time for request receipt [sec] = %f",maxLag); printf("\n"); printf("\nFound %i files with negative download time",e); printf("\n"); // Prepare histograms MitRootStyle::Init(); MitRootStyle::SetStyleWide(); gStyle->SetPadRightMargin(0.07); // to make sure the exponent is on the picture TString hist1("hist1"), hist2("hist2"); hist1.Prepend(save.Data()); hist2.Prepend(save.Data()); TH1D* h1 = new TH1D(hist1.Data(),"Lag time between request and start",100,0,maxLag); MitRootStyle::InitHistWide(h1,"","",kBlack); TH1D* h2 = new TH1D(hist2.Data(),"Average download speed",100,0,maxRate); MitRootStyle::InitHistWide(h2,"","",kBlack); const Int_t n = Int_t(machines.size()); Int_t i = 0; Double_t null = 0; TH1D* h[n]; for (int i=0; i<machines.size(); i++) { TString machineName = TString(machines[i]); machineName.Prepend(save.Data()); h[i] = new TH1D(machineName.Data(),"Average download speed",100,0,maxRate); MitRootStyle::InitHistWide(h[i],"","",kBlack); } if (nLines < 1) { empty = 1; printf("\nFound no good requests in interval :(\n"); goto go; } input.open(inName.Data()); // Second loop to fill histograms while (1) { // Read file input >> file >> content >> version >> n1 >> tRequest >> n2 >> tReceived >> tComplete >> size >> machine; // Good file? if (! input.good()) break; // During time interval? if (xStart > tReceived) continue; if (xStop < tComplete) continue; // Filter invalid older data if (rejectT3btch(machine)) continue; tLag = tReceived - tRequest; tDown = tComplete - tReceived; rate = size/double(tDown); if (tDown <= 0) continue; if (size <= 0) continue; if (tLag != 0) h1->Fill(float(tLag)); h2->Fill(rate,size); for (int i=0; i<machines.size(); i++) { TString machineName = TString(machines[i]); if (machineName == machine) { h[i]->Fill(rate,size); break; } } i++; } input.close(); go: if (empty) { h1->Fill(null,null); h2->Fill(null,null); } if (empty) { for (int i=0; i<machines.size(); i++) { h[i]->Fill(null,null); } } // Draw the histograms, each to its own canvas TCanvas *c1 = new TCanvas("c1","Overall lag time between request and receipt"); TCanvas *c2 = new TCanvas("c2","Overall average download speed"); c1->cd(); h1->GetXaxis()->SetTitle("Lag time [sec]"); h1->GetYaxis()->SetTitle("Number of requests"); h1->Draw(); //overlayFrame(TString("t3 cluster"),1); overlayFrame(text,0); c1->SaveAs(sc1.Data()); c2->cd(); h2->GetXaxis()->SetTitle("Speed [GB/sec]"); h2->GetYaxis()->SetTitle("Data downloaded [GB]"); h2->Draw(); overlayFrame(TString("t3 cluster"),1); overlayFrame(text,0); c2->SaveAs(sc2.Data()); for (int i=0; i<machines.size(); i++) { TString machineName = TString(machines[i]); TCanvas *c = new TCanvas("c",machineName.Data()); TString s = machineName.Append(sc.Data()); c->cd(); h[i]->GetXaxis()->SetTitle("Speed [GB/sec]"); h[i]->GetYaxis()->SetTitle("Data downloaded [GB]"); h[i]->Draw(); overlayFrame(TString(machines[i]),1); overlayFrame(text,0); c->SaveAs(s.Data()); } return; }
void RestoreXML( vector<string> input_filenames, vector<string> other_params ) { string SaveAs="--SaveAs"; string SaveAs2="-SaveAs"; TString XMLName = "XMLFile_"; for( unsigned int i=0; i< other_params.size(); ++i ) { string thisString = other_params[i]; size_t found = thisString.find(SaveAs); size_t found2 = thisString.find(SaveAs2); if( found2 != string::npos ) { found = found2; } if( found != string::npos ) { string newName = StringOperations::SplitString( thisString, ':' )[1]; string xmlext=".xml"; size_t foundext = newName.find(xmlext); if( foundext != string::npos ) newName = StringOperations::SplitString( thisString, '.' )[0]; XMLName = newName.c_str(); XMLName.Append("_"); } } for( unsigned int i=0; i< input_filenames.size(); ++i ) { TString thisXMLName = XMLName; thisXMLName+=i; thisXMLName.Append("_"); thisXMLName.Append( StringOperations::TimeString() ); thisXMLName.Append( ".xml" ); TTree* runtimeXML = ROOT_File_Processing::GetTree( input_filenames[i], "FittingXML" ); vector<string>* thisXML = new vector<string>(); runtimeXML->SetBranchAddress( "FittingXML", &thisXML ); runtimeXML->GetEntry(0); cout << "Saving output XML to file:\t" << thisXMLName << endl; cout << endl; stringstream full_xml; for( unsigned int j=0; j< thisXML->size(); ++j ) { full_xml << (*thisXML)[j] << endl; } ofstream output_xmlFile; output_xmlFile.open( thisXMLName.Data() ); output_xmlFile << full_xml.str(); output_xmlFile.close(); } }
/** * Analyse the reweighting option string and set options on task * appropriately. The string is a comma or space separated list of * what to reweigh and how to do it. * * What to reweigh can be specfied using one or more of the strings * * - pt Reweight in pT * - pid Reweight particle abundance of pi, K, proton * - str Reweight particles from strange weak decays * * How to reweigh can be specifed as * * - + or up Increase weights (for pt < 0.05 by +30%) * - - or down Decrease weights (for pt < 0.05 by -30%) * - If none of these are given, then the weights are used as is. * * If pid rewighting is done and one of up or down are given, then * one can specify which particle type to reweigh * * - pi or pion Reweight (up or down) pions * - K or kaon Reweight (up or down) kaons * - p or proton Reweight (up or down) protons * * Note, if PID, with explicit selection of pions, and strangeness * reweighting are specified, then the up/down flag applies to both * PID reweighting and the strangeness reweighting * * @param task The task to modify */ void SetupReweighting(AliAnalysisTaskSE* task) { TString sel = fOptions.AsString("reweight"); sel.ToLower(); if (sel.IsNull() || sel.BeginsWith("no")) return; TList files; Int_t what = 0; Int_t opt = 0; TObjArray* tokens = sel.Tokenize(", "); TIter next(tokens); TObjString* ostr; // First find what should be done while ((ostr = static_cast<TObjString*>(next()))) { const TString& token = ostr->String(); if (token.EqualTo("pt")) { what |= 0x1; files.Add(new TObjString("REWEIGHTpt.root")); Printf("Will reweigh in pT"); } else if (token.EqualTo("pid")) { what |= 0x2; Printf("Will reweigh particle species"); } else if (token.EqualTo("str")) { what |= 0x4; Printf("Will reweight particles from strange weak decays"); } } if (what == 0x0) return; // Now figure out how to do it next.Reset(); TString part; while ((ostr = static_cast<TObjString*>(next()))) { const TString& token = ostr->String(); Int_t aOpt = TMath::Abs(opt); if (token.EqualTo("up") || token.EqualTo("+")) opt = (aOpt==0 ? +1 : +aOpt); else if (token.EqualTo("down") || token.EqualTo("-")) opt = (aOpt==0 ? -1 : -aOpt); else if (token.EqualTo("pi") || token.EqualTo("pion")){ opt = 1; part = "pi"; } else if (token.EqualTo("k") || token.EqualTo("kaon")) { opt = 2; part = "ka"; } else if (token.EqualTo("p") || token.EqualTo("proton")) { opt = 3; part = "pr"; } } if (opt != 0) Printf("Will reweigh %s (%c30%% for pT<0.05)", opt < 0 ? "down" : "up", opt < 0 ? '-' : '+'); if (what & 0x2) { if (!part.IsNull()) { Printf("Will reweight %s in particular", part.Data()); part.Prepend("_"); part.Append(opt < 0 ? "-" : "+"); } files.Add(new TObjString(Form("REWEIGHTpid%s.root", part.Data()))); } if (what & 0x4) files.Add(new TObjString(Form("REWEIGHTstr%s.root", opt == -1 ? "-" : opt == +1 ? "+" : ""))); delete tokens; Printf("Setting reweighing flag=0x%x with option=%d", what, opt); SetOnTask(task, "ReweightStack", what); SetOnTask(task, "ReweightFlag", opt); TIter nextF(&files); while ((ostr = static_cast<TObjString*>(nextF()))) { Printf("Loading reweighting file %s", ostr->GetName()); fRailway->LoadAux(ostr->GetName()); } }
/// \file /// \ingroup tutorial_tree /// \notebook /// Playing with a Tree containing variables of type character /// \macro_image /// \macro_code /// \author Rene Brun void cernstaff () { TString dir = gROOT->GetTutorialsDir(); dir.Append("/tree/cernstaff.C"); if (gSystem->AccessPathName("cernstaff.root")) { gROOT->SetMacroPath(dir); gROOT->ProcessLine(".x cernbuild.C"); } TFile *f = new TFile("cernstaff.root"); TTree *T = (TTree*)f->Get("T"); TCanvas *c1 = new TCanvas("c1","CERN staff",10,10,1000,750); c1->Divide(2,2); // make table of number of people per Nation & Division c1->cd(1); gPad->SetGrid(); T->Draw("Nation:Division>>hN","","text"); TH2F *hN = (TH2F*)gDirectory->Get("hN"); hN->SetMarkerSize(1.6); hN->SetStats(0); //make profile of Average cost per Nation c1->cd(2); gPad->SetGrid(); gPad->SetLeftMargin(0.12); T->Draw("Cost:Nation>>hNation","","prof,goff"); TH1F *hNation = (TH1F*)gDirectory->Get("hNation"); hNation->SetTitle("Average Cost per Nation"); hNation->LabelsOption(">"); //sort by decreasing bin contents hNation->SetMaximum(13000); hNation->SetMinimum(7000); hNation->SetStats(0); hNation->SetMarkerStyle(21); hNation->Draw(); //make stacked plot of Nations versus Grade c1->cd(3); gPad->SetGrid(); THStack *hGrades = new THStack("hGrades","Nations versus Grade"); TH1F *hFR = new TH1F("hFR","FR",12,3,15); hFR->SetFillColor(kCyan); hGrades->Add(hFR); T->Draw("Grade>>hFR","Nation==\"FR\""); TH1F *hCH = new TH1F("hCH","CH",12,3,15); hCH->SetFillColor(kRed); hGrades->Add(hCH); T->Draw("Grade>>hCH","Nation==\"CH\""); TH1F *hIT = new TH1F("hIT","IT",12,3,15); hIT->SetFillColor(kGreen); hGrades->Add(hIT); T->Draw("Grade>>hIT","Nation==\"IT\""); TH1F *hDE = new TH1F("hDE","DE",12,3,15); hDE->SetFillColor(kYellow); hGrades->Add(hDE); T->Draw("Grade>>hDE","Nation==\"DE\""); TH1F *hGB = new TH1F("hGB","GB",12,3,15); hGB->SetFillColor(kBlue); hGrades->Add(hGB); T->Draw("Grade>>hGB","Nation==\"GB\""); hGrades->Draw(); TLegend *legend = new TLegend(0.7,0.65,0.86,0.88); legend->AddEntry(hGB,"GB","f"); legend->AddEntry(hDE,"DE","f"); legend->AddEntry(hIT,"IT","f"); legend->AddEntry(hCH,"CH","f"); legend->AddEntry(hFR,"FR","f"); legend->Draw(); //make histogram of age distribution c1->cd(4); gPad->SetGrid(); T->Draw("Age"); T->Draw("Age>>hRetired","Age>(65-2002+1988)","same"); TH1F *hRetired = (TH1F*)gDirectory->Get("hRetired"); hRetired->SetFillColor(kRed); hRetired->SetFillStyle(3010); TArrow *arrow = new TArrow(32,169,55,74,0.03,"|>"); arrow->SetFillColor(1); arrow->SetFillStyle(1001); arrow->Draw(); TPaveText *pt = new TPaveText(0.12,0.8,0.55,0.88,"brNDC"); pt->SetFillColor(kWhite); pt->AddText("People at CERN in 1988"); pt->AddText("and retired in 2002"); pt->Draw(); c1->cd(); }
int plotAll(){ TFile *file = new TFile("/hadoop/cms/store/group/snt/phys14/TTJets_MSDecaysCKM_central_Tune4C_13TeV-madgraph-tauola_Phys14DR-PU20bx25_PHYS14_25_V1-v1/V07-02-08/merged_ntuple_4.root"); TTree *tree = (TTree*)file->Get("Events"); int nEntries = tree->GetEntries(); TList *t_list = tree->GetListOfAliases(); for(int i = 0; i < t_list->GetSize(); i++) { TString aliasname(t_list->At(i)->GetName()); cout << aliasname.Data() << endl; TString command = aliasname; //Support Lorentz Vectors TBranch *branch = tree->GetBranch(tree->GetAlias(aliasname.Data())); TString branchname(branch->GetName()); if( branchname.Contains("LorentzVector") ) { command.Append(".Pt()"); } //Don't support vectors of vectors if(branchname.BeginsWith("intss") || branchname.BeginsWith("floatss") || branchname.BeginsWith("doubless") || branchname.Contains("LorentzVectorss") || branchname.Contains("timestamp") ){ cout << "Sorry, I dont support vector of vectors of objects, will be skipping " << aliasname << endl; continue; } //Don't support TStrings if(branchname.Contains("TString") ) { cout << "Sorry, I dont support strings, will be skipping " << aliasname << endl; continue; } TString histname = "hist_" + aliasname + ".pdf"; TH1F* null = new TH1F("","",1,0,1); command.Append(">>hist"); tree->Draw(command.Data(), (aliasname)+"!=-9999 &&"+(aliasname)+"!=-999"); TH1F *hist = (TH1F*)gDirectory->Get("hist"); if (hist->Integral() == 0) tree->Draw(command.Data()); hist = (TH1F*)gDirectory->Get("hist"); vector <TH1F*> hists; hists.push_back(hist); vector <string> titles; titles.push_back(""); //Overflow and Underflow hist->SetBinContent(1, hist->GetBinContent(1)+hist->GetBinContent(0)); hist->SetBinContent(hist->GetNbinsX(), hist->GetBinContent(hist->GetNbinsX())+hist->GetBinContent(hist->GetNbinsX()+1)); if (hist->GetXaxis()->GetXmax() == hist->GetXaxis()->GetXmin()){ ofstream myfile; myfile.open("names.txt", ios_base::app); myfile << aliasname.Data() << "\n"; myfile.close(); } float max = hist->GetMaximum()*100; string subtitle = aliasname.Data(); string histname2 = histname.Data(); dataMCplotMaker(null, hists, titles, subtitle, "CMS3 4.02 Validation", Form("--outputName %s --noFill --noLegend --setMaximum %f --energy 13 --lumi 0 --xAxisLabel %s --noXaxisUnit --noDivisionLabel", subtitle.c_str(), max, histname2.c_str())); } system("mkdir plots"); system("mv *.pdf plots/"); system("gs -sDEVICE=pdfwrite -dNOPAUSE -dBATCH -dSAFER -sOutputFile=merged.pdf plots/*pdf"); return 0; }
void Config() { // Get settings from environment variables ProcessEnvironmentVars(); gRandom->SetSeed(seed); cerr<<"Seed for random number generation= "<<seed<<endl; // Libraries required by geant321 #if defined(__CINT__) gSystem->Load("liblhapdf"); // Parton density functions gSystem->Load("libEGPythia6"); // TGenerator interface gSystem->Load("libpythia6"); // Pythia gSystem->Load("libAliPythia6"); // ALICE specific implementations gSystem->Load("libgeant321"); #endif new TGeant3TGeo("C++ Interface to Geant3"); //======================================================================= // Create the output file AliRunLoader* rl=0x0; cout<<"Config.C: Creating Run Loader ..."<<endl; rl = AliRunLoader::Open("galice.root", AliConfig::GetDefaultEventFolderName(), "recreate"); if (rl == 0x0) { gAlice->Fatal("Config.C","Can not instatiate the Run Loader"); return; } rl->SetCompressionLevel(2); rl->SetNumberOfEventsPerFile(1000); gAlice->SetRunLoader(rl); // gAlice->SetGeometryFromFile("geometry.root"); // gAlice->SetGeometryFromCDB(); // Set the trigger configuration: proton-proton gAlice->SetTriggerDescriptor("p-p"); // //======================================================================= // ************* STEERING parameters FOR ALICE SIMULATION ************** // --- Specify event type to be tracked through the ALICE setup // --- All positions are in cm, angles in degrees, and P and E in GeV gMC->SetProcess("DCAY",1); gMC->SetProcess("PAIR",1); gMC->SetProcess("COMP",1); gMC->SetProcess("PHOT",1); gMC->SetProcess("PFIS",0); gMC->SetProcess("DRAY",0); gMC->SetProcess("ANNI",1); gMC->SetProcess("BREM",1); gMC->SetProcess("MUNU",1); gMC->SetProcess("CKOV",1); gMC->SetProcess("HADR",1); gMC->SetProcess("LOSS",2); gMC->SetProcess("MULS",1); gMC->SetProcess("RAYL",1); Float_t cut = 1.e-3; // 1MeV cut by default Float_t tofmax = 1.e10; gMC->SetCut("CUTGAM", cut); gMC->SetCut("CUTELE", cut); gMC->SetCut("CUTNEU", cut); gMC->SetCut("CUTHAD", cut); gMC->SetCut("CUTMUO", cut); gMC->SetCut("BCUTE", cut); gMC->SetCut("BCUTM", cut); gMC->SetCut("DCUTE", cut); gMC->SetCut("DCUTM", cut); gMC->SetCut("PPCUTM", cut); gMC->SetCut("TOFMAX", tofmax); //======================// // Set External decayer // //======================// TVirtualMCDecayer* decayer = new AliDecayerPythia(); decayer->SetForceDecay(kAll); decayer->Init(); gMC->SetExternalDecayer(decayer); //=========================// // Generator Configuration // //=========================// AliGenerator* gener = 0x0; if (proc == kPythia6) { gener = MbPythia(); } else if (proc == kPhojet) { gener = MbPhojet(); } // PRIMARY VERTEX // gener->SetOrigin(0., 0., 0.); // vertex position // // // Size of the interaction diamond // Longitudinal Float_t sigmaz = 5.4 / TMath::Sqrt(2.); // [cm] if (energy == 900) sigmaz = 10.5 / TMath::Sqrt(2.); // [cm] // // Transverse Float_t betast = 10; // beta* [m] Float_t eps = 3.75e-6; // emittance [m] Float_t gamma = energy / 2.0 / 0.938272; // relativistic gamma [1] Float_t sigmaxy = TMath::Sqrt(eps * betast / gamma) / TMath::Sqrt(2.) * 100.; // [cm] printf("\n \n Diamond size x-y: %10.3e z: %10.3e\n \n", sigmaxy, sigmaz); gener->SetSigma(sigmaxy, sigmaxy, sigmaz); // Sigma in (X,Y,Z) (cm) on IP position gener->SetCutVertexZ(3.); // Truncate at 3 sigma gener->SetVertexSmear(kPerEvent); gener->Init(); // FIELD // AliMagWrapCheb* field = 0x0; if (mag == kNoField) { comment = comment.Append(" | L3 field 0.0 T"); field = new AliMagWrapCheb("Maps","Maps", 2, 0., 10., AliMagWrapCheb::k2kG); } else if (mag == k5kG) { comment = comment.Append(" | L3 field 0.5 T"); field = new AliMagWrapCheb("Maps","Maps", 2, 1., 10., AliMagWrapCheb::k5kG); } printf("\n \n Comment: %s \n \n", comment.Data()); rl->CdGAFile(); gAlice->SetField(field); Int_t iABSO = 1; Int_t iACORDE= 0; Int_t iDIPO = 1; Int_t iEMCAL = 0; Int_t iFMD = 1; Int_t iFRAME = 1; Int_t iHALL = 1; Int_t iITS = 1; Int_t iMAG = 1; Int_t iMUON = 1; Int_t iPHOS = 1; Int_t iPIPE = 1; Int_t iPMD = 0; Int_t iHMPID = 1; Int_t iSHIL = 1; Int_t iT0 = 1; Int_t iTOF = 1; Int_t iTPC = 1; Int_t iTRD = 1; Int_t iVZERO = 1; Int_t iZDC = 1; //=================== Alice BODY parameters ============================= AliBODY *BODY = new AliBODY("BODY", "Alice envelop"); if (iMAG) { //=================== MAG parameters ============================ // --- Start with Magnet since detector layouts may be depending --- // --- on the selected Magnet dimensions --- AliMAG *MAG = new AliMAG("MAG", "Magnet"); } if (iABSO) { //=================== ABSO parameters ============================ AliABSO *ABSO = new AliABSOv3("ABSO", "Muon Absorber"); } if (iDIPO) { //=================== DIPO parameters ============================ AliDIPO *DIPO = new AliDIPOv3("DIPO", "Dipole version 3"); } if (iHALL) { //=================== HALL parameters ============================ AliHALL *HALL = new AliHALLv3("HALL", "Alice Hall"); } if (iFRAME) { //=================== FRAME parameters ============================ AliFRAMEv2 *FRAME = new AliFRAMEv2("FRAME", "Space Frame"); FRAME->SetHoles(1); } if (iSHIL) { //=================== SHIL parameters ============================ AliSHIL *SHIL = new AliSHILv3("SHIL", "Shielding Version 3"); } if (iPIPE) { //=================== PIPE parameters ============================ AliPIPE *PIPE = new AliPIPEv3("PIPE", "Beam Pipe"); } if (iITS) { //=================== ITS parameters ============================ AliITS *ITS = new AliITSv11Hybrid("ITS","ITS v11Hybrid"); } if (iTPC) { //============================ TPC parameters ===================== AliTPC *TPC = new AliTPCv2("TPC", "Default"); } if (iTOF) { //=================== TOF parameters ============================ AliTOF *TOF = new AliTOFv6T0("TOF", "normal TOF"); } if (iHMPID) { //=================== HMPID parameters =========================== AliHMPID *HMPID = new AliHMPIDv3("HMPID", "normal HMPID"); } if (iZDC) { //=================== ZDC parameters ============================ AliZDC *ZDC = new AliZDCv3("ZDC", "normal ZDC"); } if (iTRD) { //=================== TRD parameters ============================ AliTRD *TRD = new AliTRDv1("TRD", "TRD slow simulator"); AliTRDgeometry *geoTRD = TRD->GetGeometry(); // Partial geometry: modules at 0,8,9,17 // starting at 3h in positive direction geoTRD->SetSMstatus(1,0); geoTRD->SetSMstatus(2,0); geoTRD->SetSMstatus(3,0); geoTRD->SetSMstatus(4,0); geoTRD->SetSMstatus(5,0); geoTRD->SetSMstatus(6,0); geoTRD->SetSMstatus(7,0); geoTRD->SetSMstatus(10,0); geoTRD->SetSMstatus(11,0); geoTRD->SetSMstatus(12,0); geoTRD->SetSMstatus(13,0); geoTRD->SetSMstatus(14,0); geoTRD->SetSMstatus(15,0); geoTRD->SetSMstatus(16,0); } if (iFMD) { //=================== FMD parameters ============================ AliFMD *FMD = new AliFMDv1("FMD", "normal FMD"); } if (iMUON) { //=================== MUON parameters =========================== // New MUONv1 version (geometry defined via builders) AliMUON *MUON = new AliMUONv1("MUON", "default"); } if (iPHOS) { //=================== PHOS parameters =========================== AliPHOS *PHOS = new AliPHOSv1("PHOS", "IHEP"); //Set simulation parameters different from the default ones. AliPHOSSimParam* simEmc = AliPHOSSimParam::GetInstance() ; // APD noise of warm (+20C) PHOS: // a2 = a1*(Y1/Y2)*(M1/M2), where a1 = 0.012 is APD noise at -25C, // Y1 = 4.3 photo-electrons/MeV, Y2 = 1.7 p.e/MeV - light yields at -25C and +20C, // M1 = 50, M2 = 50 - APD gain factors chosen for t1 = -25C and t2 = +20C, // Y = MeanLightYield*APDEfficiency. Float_t apdNoise = 0.012*2.5; simEmc->SetAPDNoise(apdNoise); //Raw Light Yield at +20C simEmc->SetMeanLightYield(18800); //ADC channel width at +18C. simEmc->SetADCchannelW(0.0125); } if (iPMD) { //=================== PMD parameters ============================ AliPMD *PMD = new AliPMDv1("PMD", "normal PMD"); } if (iT0) { //=================== T0 parameters ============================ AliT0 *T0 = new AliT0v1("T0", "T0 Detector"); } if (iEMCAL) { //=================== EMCAL parameters ============================ AliEMCAL *EMCAL = new AliEMCALv2("EMCAL", "SHISH_77_TRD1_2X2_FINAL_110DEG"); } if (iACORDE) { //=================== ACORDE parameters ============================ AliACORDE *ACORDE = new AliACORDEv1("ACORDE", "normal ACORDE"); } if (iVZERO) { //=================== ACORDE parameters ============================ AliVZERO *VZERO = new AliVZEROv7("VZERO", "normal VZERO"); } }
AliGenerator* MbPythiaTuneATLAS_Flat() { AliGenPythia* pythia = MbPythiaTuneATLAS(); comment = comment.Append("; flat multiplicity distribution"); // set high multiplicity trigger // this weight achieves a flat multiplicity distribution TH1 *weight = new TH1D("weight","weight",201,-0.5,200.5); weight->SetBinContent(1,5.49443); weight->SetBinContent(2,8.770816); weight->SetBinContent(6,0.4568624); weight->SetBinContent(7,0.2919915); weight->SetBinContent(8,0.6674189); weight->SetBinContent(9,0.364737); weight->SetBinContent(10,0.8818444); weight->SetBinContent(11,0.531885); weight->SetBinContent(12,1.035197); weight->SetBinContent(13,0.9394057); weight->SetBinContent(14,0.9643193); weight->SetBinContent(15,0.94543); weight->SetBinContent(16,0.9426507); weight->SetBinContent(17,0.9423649); weight->SetBinContent(18,0.789456); weight->SetBinContent(19,1.149026); weight->SetBinContent(20,1.100491); weight->SetBinContent(21,0.6350525); weight->SetBinContent(22,1.351941); weight->SetBinContent(23,0.03233504); weight->SetBinContent(24,0.9574557); weight->SetBinContent(25,0.868133); weight->SetBinContent(26,1.030998); weight->SetBinContent(27,1.08897); weight->SetBinContent(28,1.251382); weight->SetBinContent(29,0.1391099); weight->SetBinContent(30,1.192876); weight->SetBinContent(31,0.448944); weight->SetBinContent(32,1); weight->SetBinContent(33,1); weight->SetBinContent(34,1); weight->SetBinContent(35,1); weight->SetBinContent(36,0.9999997); weight->SetBinContent(37,0.9999997); weight->SetBinContent(38,0.9999996); weight->SetBinContent(39,0.9999996); weight->SetBinContent(40,0.9999995); weight->SetBinContent(41,0.9999993); weight->SetBinContent(42,1); weight->SetBinContent(43,1); weight->SetBinContent(44,1); weight->SetBinContent(45,1); weight->SetBinContent(46,1); weight->SetBinContent(47,0.9999999); weight->SetBinContent(48,0.9999998); weight->SetBinContent(49,0.9999998); weight->SetBinContent(50,0.9999999); weight->SetBinContent(51,0.9999999); weight->SetBinContent(52,0.9999999); weight->SetBinContent(53,0.9999999); weight->SetBinContent(54,0.9999998); weight->SetBinContent(55,0.9999998); weight->SetBinContent(56,0.9999998); weight->SetBinContent(57,0.9999997); weight->SetBinContent(58,0.9999996); weight->SetBinContent(59,0.9999995); weight->SetBinContent(60,1); weight->SetBinContent(61,1); weight->SetBinContent(62,1); weight->SetBinContent(63,1); weight->SetBinContent(64,1); weight->SetBinContent(65,0.9999999); weight->SetBinContent(66,0.9999998); weight->SetBinContent(67,0.9999998); weight->SetBinContent(68,0.9999999); weight->SetBinContent(69,1); weight->SetBinContent(70,1); weight->SetBinContent(71,0.9999997); weight->SetBinContent(72,0.9999995); weight->SetBinContent(73,0.9999994); weight->SetBinContent(74,1); weight->SetBinContent(75,1); weight->SetBinContent(76,1); weight->SetBinContent(77,1); weight->SetBinContent(78,0.9999999); weight->SetBinContent(79,1); weight->SetBinContent(80,1); weight->SetEntries(526); Int_t limit = weight->GetRandom(); pythia->SetTriggerChargedMultiplicity(limit, 1.4); comment = comment.Append(Form("; multiplicity threshold set to %d in |eta| < 1.4", limit)); return pythia; }
void DiffXSChan( UInt_t i) { UInt_t i, j, k, eg; Double_t tageff, deteff; Double_t tth[9], dtth[9], xxs[9], dxxs[9]; TString name; eg = tcd[i].egamma; cout << "Energy = " << eg << endl; // Output results to a file name = Form( "xs/compton/xs/diff_xs_%d.out", eg); ofstream outFile( name); if ( !outFile.is_open()) { cout << "Error opening file "; cout << name; cout << endl; break; } k = 0; for ( j = 1; j <= 9; j++) { ChanXS( i, j); name = Form( "%3d %6.4f %5.4f", tbin[j].th, tcd[i].xs[j], tcd[i].dxs[j]); outFile << name << endl; tth[k] = tbin[j].theta; dtth[k] = 0; xxs[k] = tcd[i].xs[j]; dxxs[k++] = tcd[i].dxs[j]; } outFile.close(); c1 = new TCanvas( "c1", "Differential Sections", 200, 10, 700, 500); c1->SetGrid(); c1->GetFrame()->SetFillColor( 21); c1->GetFrame()->SetBorderSize( 12); // Plot Results gr = new TGraphErrors( 9, tth, xxs, dtth, dxxs); name = Form( "#gammap#rightarrow#gammap Differential Cross Section" " E_{#gamma} = %5.1f MeV", tcd[i].energy); gr->SetTitle( name); gr->SetMarkerColor( 4); gr->SetMarkerStyle( 21); gr->SetLineWidth( 2); gr->SetLineColor( 4); gr->GetXaxis()->SetTitleOffset( 1.1); gr->GetYaxis()->SetTitleOffset( 0.8); gr->GetYaxis()->SetTitleSize( 0.05); gr->GetXaxis()->SetTitle("#theta^{*}_{#pi^{0}} (MeV)"); gr->GetYaxis()->SetTitle("d#sigma/d#Omega (#mub/sr)"); gr->GetXaxis()->SetLabelSize( 0.03); gr->GetYaxis()->SetLabelSize( 0.03); gr->GetXaxis()->CenterTitle(); gr->GetYaxis()->CenterTitle(); gr->SetMinimum( 0); gr->Draw( "AP"); /* c1->cd(); TPad *npad = new TPad( "npad", "Transparent Pad", 0, 0, 1, 1); npad->SetFillStyle( 4000); npad->Draw(); npad->cd(); // "Preliminary" // TPaveLabel *pl = new TPaveLabel( 100, 50, 380, 380, "PRELIMINARY"); TPaveLabel *pl = new TPaveLabel( 0, 0, 1, 1, "PRELIMINARY"); pl->SetTextAngle(30); pl->SetTextColor(14); // pl->SetTextFont(82); pl->SetBorderSize(0); pl->SetFillStyle(4000); pl->Draw(); */ name = Form( "plots/Compton/diff_xs_chan%d", i); // name.Append( ".eps"); name.Append( ".pdf"); c1->Print( name); }
void DiffComp( UInt_t ebin) { UInt_t i, ct, eg; Double_t th, cth, x, dx, cmth[100], dth[100], xs[100], dxs[100]; Double_t max; TString name; eg = 200 + ebin*10; c1 = new TCanvas( "c1", "Differential Sections", 200, 10, 700, 500); c1->SetGrid(); c1->GetFrame()->SetFillColor( 21); c1->GetFrame()->SetBorderSize( 12); // Theory results name = Form( "xs/compton/theory/compton_%d.dat", eg); ifstream inFile( name); if ( !inFile.is_open()) { cout << "Error opening file "; cout << name; cout << endl; break; } i = 0; while( !inFile.eof()) { inFile >> th >> cth >> x; cmth[i] = cth; xs[i++] = x; cout << i-1; cout << " " << th; cout << " " << cth; cout << " " << x; cout << endl; } inFile.close(); ct = i-1; if ( ebin <= 4) max = 0.18; else if ( ebin <= 6) max = 0.25; else if ( ebin <= 7) max = 0.3; else if ( ebin <= 8) max = 0.4; else if ( ebin <= 10) max = 0.5; // Plot Theory Results gr = new TGraph( ct, cmth, xs); name = Form( "Preliminary #gammap#rightarrow#gammap " "Differential Cross Section for E_{#gamma} = %d MeV", eg); gr->SetTitle( name); gr->GetXaxis()->SetTitleOffset( 1.1); gr->GetYaxis()->SetTitleOffset( 1.0); gr->GetYaxis()->SetTitleSize( 0.05); gr->GetXaxis()->SetTitle( "#theta^{cm}_{#gamma} (deg)"); gr->GetYaxis()->SetTitle( "d#sigma/d#Omega (#mub/sr)"); gr->GetXaxis()->SetLabelSize( 0.03); gr->GetYaxis()->SetLabelSize( 0.03); gr->GetXaxis()->CenterTitle(); gr->GetYaxis()->CenterTitle(); gr->GetXaxis()->SetRangeUser( 0, 180); gr->SetLineWidth( 2); // gr->SetLineColor( 2); gr->SetMinimum( 0.0); gr->SetMaximum( max); gr->Draw( "AL"); // My results i = 0; name = Form( "xs/compton/xs/diff_xs_ebin%d.out", ebin); ifstream inFile( name); if ( !inFile.is_open()) { cout << "Error opening file "; cout << name; cout << endl; break; } ifstream inFile( name); while( !inFile.eof()) { inFile >> th >> x >> dx; cout << i; cout << " " << th; cout << " " << x; cout << " " << dx; cout << endl; if ( dx != 0) { cmth[i] = th; dth[i] = 0; xs[i] = x; dxs[i++] = dx; } } inFile.close(); ct = i-1; // Plot Results gr1 = new TGraphErrors( ct, cmth, xs, dth, dxs); gr1->SetLineWidth( 2); // gr1->SetLineColor( 4); // gr1->SetMarkerColor( 4); gr1->SetMarkerSize( 1.0); gr1->SetMarkerStyle( 20); gr1->Draw( "Psame"); pt = new TLegend( 0.4, 0.65, 0.6, 0.80); pt->SetTextSize( 0.04); pt->SetFillColor( 0); pt->SetBorderSize( 0); pt->AddEntry( gr, "Pasquini", "l"); pt->AddEntry( gr1, "This Work", "p"); pt->Draw(); name = Form( "plots/Compton/dxs_comp_%d", eg); // name.Append( ".eps"); name.Append( ".pdf"); c1->Print( name); }
void DiffXSBin( UInt_t ebin) { UInt_t start, stop; UInt_t j, k, chan_lo, chan_hi; Double_t temin, temax; Double_t tageff, deteff; Double_t th[9], dth[9], xs[9], dxs[9]; TString name; TFile* file; chan_lo = tchan[ebin] - 2; chan_hi = tchan[ebin] + 2; temin = tcd[chan_hi].energy - tcd[chan_hi].denergy/2; temax = tcd[chan_lo].energy + tcd[chan_lo].denergy/2; if ( ebin <= 6) start = 6; else start = 5; stop = 8; name = Form( "xs/compton/xs/diff_xs_ebin%d.out", ebin); ofstream outFile( name); if ( !outFile.is_open()) { cout << "Error opening file "; cout << name; cout << endl; break; } k = 0; for ( j = start; j <= stop; j++) { if ( BinXS( ebin, j) == kTRUE) { name = Form( "%3d %6.4f %5.4f", tbin[j].th, tcdbin[ebin].xs[j], tcdbin[ebin].dxs[j]); outFile << name << endl; th[k] = tbin[j].theta; dth[k] = 0; xs[k] = tcdbin[ebin].xs[j]; dxs[k++] = tcdbin[ebin].dxs[j]; } } outFile.close(); cout << "Weighted Energy = " << tcdbin[ebin].energy << endl; // Output results to a file c1 = new TCanvas( "c1", "Differential Sections", 200, 10, 700, 500); c1->SetGrid(); c1->GetFrame()->SetFillColor( 21); c1->GetFrame()->SetBorderSize( 12); // Plot Results gr = new TGraphErrors( k, th, xs, dth, dxs); name = Form( "#gammap#rightarrow#gammap Differential Cross Section" " E_{#gamma} = %5.1f (%5.1f - %5.1f) MeV", tcdbin[ebin].energy, temin, temax); gr->SetTitle( name); gr->SetMarkerColor( 4); gr->SetMarkerStyle( 21); gr->SetLineWidth( 2); gr->SetLineColor( 4); gr->GetXaxis()->SetTitleOffset( 1.1); gr->GetYaxis()->SetTitleOffset( 0.8); gr->GetYaxis()->SetTitleSize( 0.05); gr->GetXaxis()->SetTitle("#theta^{*}_{#pi^{0}} (MeV)"); gr->GetYaxis()->SetTitle("d#sigma/d#Omega (#mub/sr)"); gr->GetXaxis()->SetLabelSize( 0.03); gr->GetYaxis()->SetLabelSize( 0.03); gr->GetXaxis()->CenterTitle(); gr->GetYaxis()->CenterTitle(); gr->SetMinimum( 0); gr->Draw( "AP"); /* c1->cd(); TPad *npad = new TPad( "npad", "Transparent Pad", 0, 0, 1, 1); npad->SetFillStyle( 4000); npad->Draw(); npad->cd(); // "Preliminary" // TPaveLabel *pl = new TPaveLabel( 100, 50, 380, 380, "PRELIMINARY"); TPaveLabel *pl = new TPaveLabel( 0, 0, 1, 1, "PRELIMINARY"); pl->SetTextAngle(30); pl->SetTextColor(14); // pl->SetTextFont(82); pl->SetBorderSize(0); pl->SetFillStyle(4000); pl->Draw(); */ name = Form( "plots/Compton/diff_xs_ebin%d", ebin); // name.Append( ".eps"); name.Append( ".pdf"); // c1->Print( name); }
void createPlot(TCanvas *canvas, TFile *file, TString type, TString name, int nbins, double xMin, double xMax, bool runSecTrackColl, TText* te, char * option, double startingY, double startingX = .1, bool fit = false, bool logx=false, bool logy=false, int normScale){ TTree *tree; tree = file->GetObject("tree",tree); TH1F *h1; // for ctf trk h1 = new TH1F("h1", "h1", nbins, xMin, xMax); TH1F *h2; // for sectrk h2 = new TH1F("h2","h2",nbins,xMin,xMax); TString x_title = ""; TString y_title = "Number of Tracks"; // If the histogram is filled per track, cut on the event and track. // Otherwise, cut only on the event level TString basecut="isTechBit40&&!isBeamHalo&&hasGoodPvtx==1"; TString evtcutstring=basecut; evtcutstring.Append("&&EVTSELECTION"); TString trkcutstring=basecut; trkcutstring.Append("&&EVTSELECTION&&TRKSELECTION"); TString ctf_name = "ctf_"; if( name.Contains("cluster_charge",TString::kExact) ) { ctf_name = "ctf"; ctf_name.Append(name); tree->Project("h1",ctf_name, evtcutstring); } else if (name == "recz_pxlpvtx") { tree->Project("h1",name, evtcutstring); y_title="Number of pixelVertices"; } else if( name.Contains("pvtx")) { if(name.Contains("rec")) { y_title="Number of Real PrimaryVertices"; TString vtxcutstring=evtcutstring; tree->Project("h1",name, vtxcutstring.Append("&&isFake_pvtx==0")); } else { y_title="Number of Valid PrimaryVertices"; tree->Project("h1",name, evtcutstring); } } else if ( name.Contains("nVertices",TString::kExact) || name.Contains("hasGoodPvtx",TString::kExact) || name.Contains("nPixelVertices",TString::kExact) || name.Contains("isTechBit40",TString::kExact) || name.Contains("isBSC",TString::kExact) || name.Contains("bsX0",TString::kExact) || name.Contains("bsY0",TString::kExact) || name.Contains("bsZ0",TString::kExact) || name.Contains("glob_ls",TString::kExact) || name.Contains("glob_bx",TString::kExact) ) { tree->Project("h1",name, evtcutstring); y_title = "Number of Events"; } else { ctf_name.Append(name); tree->Project("h1",ctf_name, trkcutstring); } if(runSecTrackColl && ctf_name.Contains("ctf")) { TString sectrk_name = ctf_name.ReplaceAll("ctf","sectrk"); tree->Project("h2",sectrk_name,evtcutstring); } // Set the x_tile if( name == "n" ) { x_title = "Tracks per Event" ; y_title = "Number of Events"; } // All Clusters if( name.Contains("clusterCharge_all",TString::kExact) ) x_title = "All Cluster Charge (ADC Counts)"; if( name.Contains("clusterCharge_TIB",TString::kExact) ) x_title = "All TIB Cluster Charge (ADC Counts)"; if( name.Contains("clusterCharge_TID",TString::kExact) ) x_title = "All TID Cluster Charge (ADC Counts)"; if( name.Contains("clusterCharge_TOB",TString::kExact) ) x_title = "All TOB Cluster Charge (ADC Counts)"; if( name.Contains("clusterCharge_TEC",TString::kExact) ) x_title = "All TEC Cluster Charge (ADC Counts)"; if( name.Contains("cluster_charge",TString::kExact) ) { x_title = " Strip Cluster Charge (ADC Counts)"; y_title = "Number of Clusters"; } // Histograms filled per Track if( name.Contains("nHit",TString::kExact) ) x_title = "Number of Valid Hits per Track" ; if( name.Contains("nLostHit",TString::kExact) ) x_title = "Number of Lost Hits per Track" ; if( name.Contains("nPXBhit",TString::kExact) ) x_title = "Number of PixelBarrel Hits per Track" ; if( name.Contains("nPXFhit",TString::kExact) ) x_title = "Number of PixEndcap Hits per Track" ; if( name.Contains("nTIBhit",TString::kExact) ) x_title = "Number of TIB Hits per Track" ; if( name.Contains("nTOBhit",TString::kExact) ) x_title = "Number of TOB Hits per Track" ; if( name.Contains("nTIDhit",TString::kExact) ) x_title = "Number of TID Hits per Track" ; if( name.Contains("nTEChit",TString::kExact) ) x_title = "Number of TEC Hits per Track" ; if( name.Contains("nPixelHit",TString::kExact) ) x_title = "Number of Pixel Hits per Track" ; if( name.Contains("nLayers",TString::kExact) ) x_title = "Number of Layers per Track" ; if( name.Contains("nLayers3D",TString::kExact) ) x_title = "Number of 3D Layers per Track" ; if( name.Contains("nPXBLayers",TString::kExact) ) x_title = "Number of PixelBarrel Layers per Track" ; if( name.Contains("nPXFLayers",TString::kExact) ) x_title = "Number of PixEndcap Layers per Track" ; if( name.Contains("eta",TString::kExact) ) x_title = "Track Pseudorapidity" ; if( name.Contains("pt",TString::kExact) ) x_title = "p_{T} (GeV)" ; if( name.Contains("phi",TString::kExact) ) x_title = "Track Azimuthal Angle" ; if( name.Contains("dxy",TString::kExact) ) x_title = "Track dxy wrt (0,0,0) (cm)" ; if( name.Contains("dz",TString::kExact) ) x_title = "Track dz wrt (0,0,0) (cm)" ; if( name.Contains("dxyCorr",TString::kExact) ) x_title = "Track dxy wrt BS (cm)" ; if( name.Contains("dzCorr",TString::kExact) ) x_title = "Track dz wrt BS (cm)" ; if( name.Contains("xPCA",TString::kExact) ) x_title = "x PCA (cm)" ; if( name.Contains("yPCA",TString::kExact) ) x_title = "y PCA (cm)" ; if( name.Contains("zPCA",TString::kExact) ) x_title = "z PCA (cm)" ; if( name.Contains("chi2ndof",TString::kExact) ) x_title = "#chi^{2}/ndf" ; if( name.Contains("algo",TString::kExact) ) x_title = "Track Algorithm" ; if( name.Contains("isHighPurity",TString::kExact) ) x_title = "isHighPurity" ; // pvtx stuff if( name.Contains("recx_pvtx",TString::kExact) ) x_title = "PrimaryVertex Position X (cm)" ; if( name.Contains("recy_pvtx",TString::kExact) ) x_title = "PrimaryVertex Position Y (cm)" ; if( name.Contains("recz_pvtx",TString::kExact) ) x_title = "PrimaryVertex Position Z (cm)" ; if( name.Contains("isFake_pvtx",TString::kExact) ) x_title = "PrimaryVertex isFake()"; if( name.Contains("recz_pxlpvtx",TString::kExact) ) x_title = "pixelVertices Position Z (cm)" ; //beamspot if( name.Contains("bsX0",TString::kExact) ) x_title = "BeamSpot X (cm)" ; if( name.Contains("bsY0",TString::kExact) ) x_title = "BeamSpot Y (cm)" ; if( name.Contains("bsZ0",TString::kExact) ) x_title = "BeamSpot Z (cm)" ; if( name.Contains("nVertices",TString::kExact) ) x_title = "Number of PrimaryVertices"; if( name.Contains("nPixelVertices",TString::kExact) ) x_title = "Number of pixelVertices"; if( name.Contains("hasGoodPvtx",TString::kExact) ) x_title = "hasRealPrimaryVertex"; if( name.Contains("isTechBit40",TString::kExact) ) x_title = "isTechBit40"; if( name.Contains("isBSC",TString::kExact) ) x_title = "isBSC"; if( name.Contains("glob_bx",TString::kExact) ) x_title = "bunchCrossing"; if(logx) gPad->SetLogx(); else gPad->SetLogx(0); if(logy) gPad->SetLogy(); else gPad->SetLogy(0); h1->SetLineColor(4); h1->SetMarkerColor(4); h1->SetMarkerStyle(21); h1->SetMarkerSize(0.7); //h1->StatOverflows(kTRUE); h1->SetLineWidth(3); h1->GetXaxis()->SetTitle(x_title); h1->GetYaxis()->SetTitle(y_title); if(runSecTrackColl) { h2->SetLineColor(2); h2->SetMarkerColor(2); h2->SetMarkerStyle(21); h2->SetMarkerSize(0.7); //h2->StatOverflows(kTRUE); h2->SetLineWidth(3); h2->GetXaxis()->SetTitle(x_title); h2->GetYaxis()->SetTitle(y_title); } if(runSecTrackColl) { setStats(h1, h2, startingY, startingX, fit); NormalizeHistograms(h1, h2, normScale); if(!logy && !logx) fixRangeY(h1,h2); //I don't know why, with logy or logx, this line creates trouble in overlaying two plots if there is an Y=0 bin } else { setStats(h1, startingY, startingX, fit); } gPad->Update(); h1->Draw(); if(runSecTrackColl) h2->Draw("sames"); canvas->Update(); TLegend *leg = new TLegend(0.16,0.93,0.60,0.995); leg->SetTextSize(0.04); leg->SetTextFont(42); leg->SetFillColor(0); leg->SetBorderSize(1); leg->AddEntry(h1, "TRACKCOLLECTION" , "L" ); if(runSecTrackColl) leg->AddEntry(h2, "SECTRKCOLLECTION" , "L" ); if(type == "perTrk" || name == "n" || name == "cluster_charge") leg->Draw("SAME"); TString pngdirname ="PNGDIR/SAMPLE/CUTSTRING/"; TString pngfilename = pngdirname; pngfilename.Append(name); pngfilename.Append(".png"); canvas->Print(pngfilename); TString epsdirname ="EPSDIR/SAMPLE/CUTSTRING/"; TString epsfilename = epsdirname; epsfilename.Append(name); epsfilename.Append(".eps"); canvas->Print(epsfilename); delete h1; delete h2; }
int TMVAKaggleHiggs ( TString myMethodList = "" ) { // The explicit loading of the shared libTMVA is done in TMVAlogon.C, defined in .rootrc // if you use your private .rootrc, or run from a different directory, please copy the // corresponding lines from .rootrc // methods to be processed can be given as an argument; use format: // // mylinux~> root -l TMVAClassification.C\(\"myMethod1,myMethod2,myMethod3\"\) // // if you like to use a method via the plugin mechanism, we recommend using // // mylinux~> root -l TMVAClassification.C\(\"P_myMethod\"\) // (an example is given for using the BDT as plugin (see below), // but of course the real application is when you write your own // method based) //--------------------------------------------------------------- // This loads the library TMVA::Tools::Instance(); // Default MVA methods to be trained + tested std::map<std::string,int> Use; // --- Cut optimisation Use["Cuts"] = 0; Use["CutsD"] = 0; Use["CutsPCA"] = 0; Use["CutsGA"] = 0; Use["CutsSA"] = 0; // // --- 1-dimensional likelihood ("naive Bayes estimator") Use["Likelihood"] = 0; Use["LikelihoodD"] = 0; // the "D" extension indicates decorrelated input variables (see option strings) Use["LikelihoodPCA"] = 0; // the "PCA" extension indicates PCA-transformed input variables (see option strings) Use["LikelihoodKDE"] = 0; Use["LikelihoodMIX"] = 0; // // --- Mutidimensional likelihood and Nearest-Neighbour methods Use["PDERS"] = 0; Use["PDERSD"] = 0; Use["PDERSPCA"] = 0; Use["PDEFoam"] = 0; Use["PDEFoamBoost"] = 0; // uses generalised MVA method boosting Use["KNN"] = 0; // k-nearest neighbour method // // --- Linear Discriminant Analysis Use["LD"] = 0; // Linear Discriminant identical to Fisher Use["Fisher"] = 0; Use["FisherG"] = 0; Use["BoostedFisher"] = 0; // uses generalised MVA method boosting Use["HMatrix"] = 0; // // --- Function Discriminant analysis Use["FDA_GA"] = 0; // minimisation of user-defined function using Genetics Algorithm Use["FDA_SA"] = 0; Use["FDA_MC"] = 0; Use["FDA_MT"] = 0; Use["FDA_GAMT"] = 0; Use["FDA_MCMT"] = 0; // // --- Neural Networks (all are feed-forward Multilayer Perceptrons) Use["MLP"] = 0; // Recommended ANN Use["MLPBFGS"] = 0; // Recommended ANN with optional training method Use["MLPBNN"] = 0; // Recommended ANN with BFGS training method and bayesian regulator Use["CFMlpANN"] = 0; // Depreciated ANN from ALEPH Use["TMlpANN"] = 0; // ROOT's own ANN Use["NN"] = 1; // improved implementation of a NN // // --- Support Vector Machine Use["SVM"] = 0; // // --- Boosted Decision Trees Use["BDT"] = 1; // uses Adaptive Boost Use["BDTG"] = 0; // uses Gradient Boost Use["BDTB"] = 0; // uses Bagging Use["BDTD"] = 0; // decorrelation + Adaptive Boost Use["BDTF"] = 0; // allow usage of fisher discriminant for node splitting // // --- Friedman's RuleFit method, ie, an optimised series of cuts ("rules") Use["RuleFit"] = 0; // --------------------------------------------------------------- std::cout << std::endl; std::cout << "==> Start TMVAKaggleHiggs" << std::endl; // Select methods (don't look at this code - not of interest) if (myMethodList != "") { for (std::map<std::string,int>::iterator it = Use.begin(); it != Use.end(); it++) it->second = 0; std::vector<TString> mlist = TMVA::gTools().SplitString( myMethodList, ',' ); for (UInt_t i=0; i<mlist.size(); i++) { std::string regMethod(mlist[i]); if (Use.find(regMethod) == Use.end()) { std::cout << "Method \"" << regMethod << "\" not known in TMVA under this name. Choose among the following:" << std::endl; for (std::map<std::string,int>::iterator it = Use.begin(); it != Use.end(); it++) std::cout << it->first << " "; std::cout << std::endl; return 1; } Use[regMethod] = 1; } } // -------------------------------------------------------------------------------------------------- // --- Here the preparation phase begins // Read training and test data // (it is also possible to use ASCII format as input -> see TMVA Users Guide) TString fname = "./training.root"; if (gSystem->AccessPathName( fname )) // file does not exist in local directory gSystem->Exec("curl -O http://root.cern.ch/files/tmva_class_example.root"); TFile *input = TFile::Open( fname ); std::cout << "--- TMVAClassification : Using input file: " << input->GetName() << std::endl; // --- Register the training and test trees TTree *tree = (TTree*)input->Get("data"); // Create a ROOT output file where TMVA will store ntuples, histograms, etc. TString outfileName( "TMVA.root" ); TFile* outputFile = TFile::Open( outfileName, "RECREATE" ); // Create the factory object. Later you can choose the methods // whose performance you'd like to investigate. The factory is // the only TMVA object you have to interact with // // The first argument is the base of the name of all the // weightfiles in the directory weight/ // // The second argument is the output file for the training results // All TMVA output can be suppressed by removing the "!" (not) in // front of the "Silent" argument in the option string TMVA::Factory *factory = new TMVA::Factory( "TMVAClassification", outputFile, "!V:!Silent:Color:DrawProgressBar:Transformations=I:AnalysisType=Classification" ); // If you wish to modify default settings // (please check "src/Config.h" to see all available global options) // (TMVA::gConfig().GetVariablePlotting()).fTimesRMS = 8.0; // (TMVA::gConfig().GetIONames()).fWeightFileDir = "myWeightDirectory"; // Define the input variables that shall be used for the MVA training // note that you may also use variable expressions, such as: "3*var1/var2*abs(var3)" // [all types of expressions that can also be parsed by TTree::Draw( "expression" )] // factory->AddVariable( "myvar1 := var1+var2", 'F' ); // factory->AddVariable( "myvar2 := var1-var2", "Expression 2", "", 'F' ); // factory->AddVariable( "var3", "Variable 3", "units", 'F' ); // factory->AddVariable( "var4", "Variable 4", "units", 'F' ); TString limit ("-900.0"); TString replacementValue ("0.0"); std::vector<std::string> vars = {"DER_mass_MMC","DER_mass_transverse_met_lep","DER_mass_vis","DER_pt_h","DER_deltaeta_jet_jet","DER_mass_jet_jet","DER_prodeta_jet_jet","DER_deltar_tau_lep","DER_pt_tot","DER_sum_pt","DER_pt_ratio_lep_tau","DER_met_phi_centrality","DER_lep_eta_centrality","PRI_tau_pt","PRI_tau_eta","PRI_tau_phi","PRI_lep_pt","PRI_lep_eta","PRI_lep_phi","PRI_met","PRI_met_phi","PRI_met_sumet","PRI_jet_num","PRI_jet_leading_pt","PRI_jet_leading_eta","PRI_jet_leading_phi","PRI_jet_subleading_pt","PRI_jet_subleading_eta","PRI_jet_subleading_phi","PRI_jet_all_pt"}; for (std::vector<std::string>::iterator it = vars.begin (), itEnd = vars.end (); it != itEnd; ++it) { std::string s = *it; TString current; current.Form ("%s:=(%s<%s?%s:%s)",s.c_str (), s.c_str (), limit.Data (), replacementValue.Data (), s.c_str ()); factory->AddVariable (current, 'F'); } // You can add so-called "Spectator variables", which are not used in the MVA training, // but will appear in the final "TestTree" produced by TMVA. This TestTree will contain the // input variables, the response values of all trained MVAs, and the spectator variables // factory->AddSpectator( "spec1 := var1*2", "Spectator 1", "units", 'F' ); // factory->AddSpectator( "spec2 := var1*3", "Spectator 2", "units", 'F' ); // global event weights per tree (see below for setting event-wise weights) Double_t weight = 1.0; // Double_t backgroundWeight = 1.0; // You can add an arbitrary number of signal or background trees // factory->AddBackgroundTree( background, backgroundWeight ); factory->AddTree(tree, "Signal", 1., "Label == 1"); factory->AddTree(tree, "Background", 1., "Label == 0"); // To give different trees for training and testing, do as follows: // factory->AddSignalTree( signalTrainingTree, signalTrainWeight, "Training" ); // factory->AddSignalTree( signalTestTree, signalTestWeight, "Test" ); // Use the following code instead of the above two or four lines to add signal and background // training and test events "by hand" // NOTE that in this case one should not give expressions (such as "var1+var2") in the input // variable definition, but simply compute the expression before adding the event // // // --- begin ---------------------------------------------------------- // std::vector<Double_t> vars( 4 ); // vector has size of number of input variables // Float_t treevars[4], weight; // // // Signal // for (UInt_t ivar=0; ivar<4; ivar++) signal->SetBranchAddress( Form( "var%i", ivar+1 ), &(treevars[ivar]) ); // for (UInt_t i=0; i<signal->GetEntries(); i++) { // signal->GetEntry(i); // for (UInt_t ivar=0; ivar<4; ivar++) vars[ivar] = treevars[ivar]; // // add training and test events; here: first half is training, second is testing // // note that the weight can also be event-wise // if (i < signal->GetEntries()/2.0) factory->AddSignalTrainingEvent( vars, signalWeight ); // else factory->AddSignalTestEvent ( vars, signalWeight ); // } // // // Background (has event weights) // background->SetBranchAddress( "weight", &weight ); // for (UInt_t ivar=0; ivar<4; ivar++) background->SetBranchAddress( Form( "var%i", ivar+1 ), &(treevars[ivar]) ); // for (UInt_t i=0; i<background->GetEntries(); i++) { // background->GetEntry(i); // for (UInt_t ivar=0; ivar<4; ivar++) vars[ivar] = treevars[ivar]; // // add training and test events; here: first half is training, second is testing // // note that the weight can also be event-wise // if (i < background->GetEntries()/2) factory->AddBackgroundTrainingEvent( vars, backgroundWeight*weight ); // else factory->AddBackgroundTestEvent ( vars, backgroundWeight*weight ); // } // --- end ------------------------------------------------------------ // // --- end of tree registration // Set individual event weights (the variables must exist in the original TTree) // for signal : factory->SetSignalWeightExpression ("weight1*weight2"); // for background: factory->SetBackgroundWeightExpression("weight1*weight2"); factory->SetSignalWeightExpression( "Weight" ); factory->SetBackgroundWeightExpression( "Weight" ); // Apply additional cuts on the signal and background samples (can be different) TCut mycuts = "Label==1"; // for example: TCut mycuts = "abs(var1)<0.5 && abs(var2-0.5)<1"; TCut mycutb = "Label==0"; // for example: TCut mycutb = "abs(var1)<0.5"; // Tell the factory how to use the training and testing events // // If no numbers of events are given, half of the events in the tree are used // for training, and the other half for testing: // factory->PrepareTrainingAndTestTree( mycut, "SplitMode=random:!V" ); // To also specify the number of testing events, use: // factory->PrepareTrainingAndTestTree( mycut, // "NSigTrain=3000:NBkgTrain=3000:NSigTest=3000:NBkgTest=3000:SplitMode=Random:!V" ); factory->PrepareTrainingAndTestTree( mycuts, mycutb, "nTrain_Signal=0:nTrain_Background=0:nTest_Signal=0:nTest_Background=0:SplitMode=Random:NormMode=NumEvents:!V" ); // factory->PrepareTrainingAndTestTree( mycuts, mycutb, // "nTrain_Signal=5000:nTrain_Background=5000:nTest_Signal=5000:nTest_Background=5000:SplitMode=Random:NormMode=NumEvents:!V" ); // ---- Book MVA methods // // Please lookup the various method configuration options in the corresponding cxx files, eg: // src/MethoCuts.cxx, etc, or here: http://tmva.sourceforge.net/optionRef.html // it is possible to preset ranges in the option string in which the cut optimisation should be done: // "...:CutRangeMin[2]=-1:CutRangeMax[2]=1"...", where [2] is the third input variable // Cut optimisation if (Use["Cuts"]) factory->BookMethod( TMVA::Types::kCuts, "Cuts", "!H:!V:FitMethod=MC:EffSel:SampleSize=200000:VarProp=FSmart" ); if (Use["CutsD"]) factory->BookMethod( TMVA::Types::kCuts, "CutsD", "!H:!V:FitMethod=MC:EffSel:SampleSize=200000:VarProp=FSmart:VarTransform=Decorrelate" ); if (Use["CutsPCA"]) factory->BookMethod( TMVA::Types::kCuts, "CutsPCA", "!H:!V:FitMethod=MC:EffSel:SampleSize=200000:VarProp=FSmart:VarTransform=PCA" ); if (Use["CutsGA"]) factory->BookMethod( TMVA::Types::kCuts, "CutsGA", "H:!V:FitMethod=GA:CutRangeMin[0]=-10:CutRangeMax[0]=10:VarProp[1]=FMax:EffSel:Steps=30:Cycles=3:PopSize=400:SC_steps=10:SC_rate=5:SC_factor=0.95" ); if (Use["CutsSA"]) factory->BookMethod( TMVA::Types::kCuts, "CutsSA", "!H:!V:FitMethod=SA:EffSel:MaxCalls=150000:KernelTemp=IncAdaptive:InitialTemp=1e+6:MinTemp=1e-6:Eps=1e-10:UseDefaultScale" ); // Likelihood ("naive Bayes estimator") if (Use["Likelihood"]) factory->BookMethod( TMVA::Types::kLikelihood, "Likelihood", "H:!V:TransformOutput:PDFInterpol=Spline2:NSmoothSig[0]=20:NSmoothBkg[0]=20:NSmoothBkg[1]=10:NSmooth=1:NAvEvtPerBin=50" ); // Decorrelated likelihood if (Use["LikelihoodD"]) factory->BookMethod( TMVA::Types::kLikelihood, "LikelihoodD", "!H:!V:TransformOutput:PDFInterpol=Spline2:NSmoothSig[0]=20:NSmoothBkg[0]=20:NSmooth=5:NAvEvtPerBin=50:VarTransform=Decorrelate" ); // PCA-transformed likelihood if (Use["LikelihoodPCA"]) factory->BookMethod( TMVA::Types::kLikelihood, "LikelihoodPCA", "!H:!V:!TransformOutput:PDFInterpol=Spline2:NSmoothSig[0]=20:NSmoothBkg[0]=20:NSmooth=5:NAvEvtPerBin=50:VarTransform=PCA" ); // Use a kernel density estimator to approximate the PDFs if (Use["LikelihoodKDE"]) factory->BookMethod( TMVA::Types::kLikelihood, "LikelihoodKDE", "!H:!V:!TransformOutput:PDFInterpol=KDE:KDEtype=Gauss:KDEiter=Adaptive:KDEFineFactor=0.3:KDEborder=None:NAvEvtPerBin=50" ); // Use a variable-dependent mix of splines and kernel density estimator if (Use["LikelihoodMIX"]) factory->BookMethod( TMVA::Types::kLikelihood, "LikelihoodMIX", "!H:!V:!TransformOutput:PDFInterpolSig[0]=KDE:PDFInterpolBkg[0]=KDE:PDFInterpolSig[1]=KDE:PDFInterpolBkg[1]=KDE:PDFInterpolSig[2]=Spline2:PDFInterpolBkg[2]=Spline2:PDFInterpolSig[3]=Spline2:PDFInterpolBkg[3]=Spline2:KDEtype=Gauss:KDEiter=Nonadaptive:KDEborder=None:NAvEvtPerBin=50" ); // Test the multi-dimensional probability density estimator // here are the options strings for the MinMax and RMS methods, respectively: // "!H:!V:VolumeRangeMode=MinMax:DeltaFrac=0.2:KernelEstimator=Gauss:GaussSigma=0.3" ); // "!H:!V:VolumeRangeMode=RMS:DeltaFrac=3:KernelEstimator=Gauss:GaussSigma=0.3" ); if (Use["PDERS"]) factory->BookMethod( TMVA::Types::kPDERS, "PDERS", "!H:!V:NormTree=T:VolumeRangeMode=Adaptive:KernelEstimator=Gauss:GaussSigma=0.3:NEventsMin=400:NEventsMax=600" ); if (Use["PDERSD"]) factory->BookMethod( TMVA::Types::kPDERS, "PDERSD", "!H:!V:VolumeRangeMode=Adaptive:KernelEstimator=Gauss:GaussSigma=0.3:NEventsMin=400:NEventsMax=600:VarTransform=Decorrelate" ); if (Use["PDERSPCA"]) factory->BookMethod( TMVA::Types::kPDERS, "PDERSPCA", "!H:!V:VolumeRangeMode=Adaptive:KernelEstimator=Gauss:GaussSigma=0.3:NEventsMin=400:NEventsMax=600:VarTransform=PCA" ); // Multi-dimensional likelihood estimator using self-adapting phase-space binning if (Use["PDEFoam"]) factory->BookMethod( TMVA::Types::kPDEFoam, "PDEFoam", "!H:!V:SigBgSeparate=F:TailCut=0.001:VolFrac=0.0666:nActiveCells=500:nSampl=2000:nBin=5:Nmin=100:Kernel=None:Compress=T" ); if (Use["PDEFoamBoost"]) factory->BookMethod( TMVA::Types::kPDEFoam, "PDEFoamBoost", "!H:!V:Boost_Num=30:Boost_Transform=linear:SigBgSeparate=F:MaxDepth=4:UseYesNoCell=T:DTLogic=MisClassificationError:FillFoamWithOrigWeights=F:TailCut=0:nActiveCells=500:nBin=20:Nmin=400:Kernel=None:Compress=T" ); // K-Nearest Neighbour classifier (KNN) if (Use["KNN"]) factory->BookMethod( TMVA::Types::kKNN, "KNN", "H:nkNN=20:ScaleFrac=0.8:SigmaFact=1.0:Kernel=Gaus:UseKernel=F:UseWeight=T:!Trim" ); // H-Matrix (chi2-squared) method if (Use["HMatrix"]) factory->BookMethod( TMVA::Types::kHMatrix, "HMatrix", "!H:!V:VarTransform=None" ); // Linear discriminant (same as Fisher discriminant) if (Use["LD"]) factory->BookMethod( TMVA::Types::kLD, "LD", "H:!V:VarTransform=None:CreateMVAPdfs:PDFInterpolMVAPdf=Spline2:NbinsMVAPdf=50:NsmoothMVAPdf=10" ); // Fisher discriminant (same as LD) if (Use["Fisher"]) factory->BookMethod( TMVA::Types::kFisher, "Fisher", "H:!V:Fisher:VarTransform=None:CreateMVAPdfs:PDFInterpolMVAPdf=Spline2:NbinsMVAPdf=50:NsmoothMVAPdf=10" ); // Fisher with Gauss-transformed input variables if (Use["FisherG"]) factory->BookMethod( TMVA::Types::kFisher, "FisherG", "H:!V:VarTransform=Gauss" ); // Composite classifier: ensemble (tree) of boosted Fisher classifiers if (Use["BoostedFisher"]) factory->BookMethod( TMVA::Types::kFisher, "BoostedFisher", "H:!V:Boost_Num=20:Boost_Transform=log:Boost_Type=AdaBoost:Boost_AdaBoostBeta=0.2:!Boost_DetailedMonitoring" ); // Function discrimination analysis (FDA) -- test of various fitters - the recommended one is Minuit (or GA or SA) if (Use["FDA_MC"]) factory->BookMethod( TMVA::Types::kFDA, "FDA_MC", "H:!V:Formula=(0)+(1)*x0+(2)*x1+(3)*x2+(4)*x3:ParRanges=(-1,1);(-10,10);(-10,10);(-10,10);(-10,10):FitMethod=MC:SampleSize=100000:Sigma=0.1" ); if (Use["FDA_GA"]) // can also use Simulated Annealing (SA) algorithm (see Cuts_SA options]) factory->BookMethod( TMVA::Types::kFDA, "FDA_GA", "H:!V:Formula=(0)+(1)*x0+(2)*x1+(3)*x2+(4)*x3:ParRanges=(-1,1);(-10,10);(-10,10);(-10,10);(-10,10):FitMethod=GA:PopSize=300:Cycles=3:Steps=20:Trim=True:SaveBestGen=1" ); if (Use["FDA_SA"]) // can also use Simulated Annealing (SA) algorithm (see Cuts_SA options]) factory->BookMethod( TMVA::Types::kFDA, "FDA_SA", "H:!V:Formula=(0)+(1)*x0+(2)*x1+(3)*x2+(4)*x3:ParRanges=(-1,1);(-10,10);(-10,10);(-10,10);(-10,10):FitMethod=SA:MaxCalls=15000:KernelTemp=IncAdaptive:InitialTemp=1e+6:MinTemp=1e-6:Eps=1e-10:UseDefaultScale" ); if (Use["FDA_MT"]) factory->BookMethod( TMVA::Types::kFDA, "FDA_MT", "H:!V:Formula=(0)+(1)*x0+(2)*x1+(3)*x2+(4)*x3:ParRanges=(-1,1);(-10,10);(-10,10);(-10,10);(-10,10):FitMethod=MINUIT:ErrorLevel=1:PrintLevel=-1:FitStrategy=2:UseImprove:UseMinos:SetBatch" ); if (Use["FDA_GAMT"]) factory->BookMethod( TMVA::Types::kFDA, "FDA_GAMT", "H:!V:Formula=(0)+(1)*x0+(2)*x1+(3)*x2+(4)*x3:ParRanges=(-1,1);(-10,10);(-10,10);(-10,10);(-10,10):FitMethod=GA:Converger=MINUIT:ErrorLevel=1:PrintLevel=-1:FitStrategy=0:!UseImprove:!UseMinos:SetBatch:Cycles=1:PopSize=5:Steps=5:Trim" ); if (Use["FDA_MCMT"]) factory->BookMethod( TMVA::Types::kFDA, "FDA_MCMT", "H:!V:Formula=(0)+(1)*x0+(2)*x1+(3)*x2+(4)*x3:ParRanges=(-1,1);(-10,10);(-10,10);(-10,10);(-10,10):FitMethod=MC:Converger=MINUIT:ErrorLevel=1:PrintLevel=-1:FitStrategy=0:!UseImprove:!UseMinos:SetBatch:SampleSize=20" ); // TMVA ANN: MLP (recommended ANN) -- all ANNs in TMVA are Multilayer Perceptrons if (Use["MLP"]) factory->BookMethod( TMVA::Types::kMLP, "MLP", "H:!V:NeuronType=tanh:VarTransform=N:NCycles=600:HiddenLayers=N+5:TestRate=5:!UseRegulator" ); if (Use["MLPBFGS"]) factory->BookMethod( TMVA::Types::kMLP, "MLPBFGS", "H:!V:NeuronType=tanh:VarTransform=N:NCycles=600:HiddenLayers=N+5:TestRate=5:TrainingMethod=BFGS:!UseRegulator" ); if (Use["MLPBNN"]) factory->BookMethod( TMVA::Types::kMLP, "MLPBNN", "H:!V:NeuronType=tanh:VarTransform=N:NCycles=600:HiddenLayers=N+5:TestRate=5:TrainingMethod=BFGS:UseRegulator" ); // BFGS training with bayesian regulators // improved neural network implementation if (Use["NN"]) { // TString layoutString ("Layout=TANH|(N+100)*2,LINEAR"); // TString layoutString ("Layout=SOFTSIGN|100,SOFTSIGN|50,SOFTSIGN|20,LINEAR"); // TString layoutString ("Layout=RELU|300,RELU|100,RELU|30,RELU|10,LINEAR"); // TString layoutString ("Layout=SOFTSIGN|50,SOFTSIGN|30,SOFTSIGN|20,SOFTSIGN|10,LINEAR"); // TString layoutString ("Layout=TANH|50,TANH|30,TANH|20,TANH|10,LINEAR"); // TString layoutString ("Layout=SOFTSIGN|50,SOFTSIGN|20,LINEAR"); TString layoutString ("Layout=SOFTSIGN|70,SOFTSIGN|30,LINEAR"); std::vector<TString> strategy; strategy.push_back (TString ("LearningRate=1e-2,Momentum=0.9,Repetitions=1,ConvergenceSteps=70,BatchSize=120,TestRepetitions=7,WeightDecay=0.001,Regularization=NONE,DropConfig=0.5+0.5+0.5+0.5,DropRepetitions=1,Multithreading=True")); strategy.push_back (TString ("LearningRate=1e-4,Momentum=0.5,Repetitions=1,ConvergenceSteps=70,BatchSize=80,TestRepetitions=7,WeightDecay=0.001,Regularization=L2,Multithreading=True,DropConfig=0.1+0.1+0.1+0.1,DropRepetitions=1")); strategy.push_back (TString ("LearningRate=1e-5,Momentum=0.3,Repetitions=1,ConvergenceSteps=70,BatchSize=60,TestRepetitions=7,WeightDecay=0.0001,Regularization=L2,Multithreading=True")); strategy.push_back (TString ("LearningRate=1e-6,Momentum=0.0,Repetitions=1,ConvergenceSteps=70,BatchSize=40,TestRepetitions=7,WeightDecay=0.0001,Regularization=NONE,Multithreading=True")); // strategy.push_back (TString ("LearningRate=1e-6,Momentum=0.0,Repetitions=1,ConvergenceSteps=50,BatchSize=30,TestRepetitions=7,WeightDecay=0.0001,Regularization=NONE,Multithreading=True")); TString trainingStrategyString ("TrainingStrategy="); for (std::vector<TString>::const_iterator it = strategy.begin (), itEnd = strategy.end (); it != itEnd; ++it) { if (it != strategy.begin ()) trainingStrategyString += "|"; trainingStrategyString += *it; } // TString nnOptions ("!H:V:VarTransform=Normalize:ErrorStrategy=CROSSENTROPY"); TString nnOptions ("!H:V:ErrorStrategy=CROSSENTROPY:VarTransform=G:WeightInitialization=XAVIERUNIFORM"); // TString nnOptions ("!H:V:VarTransform=Normalize:ErrorStrategy=CHECKGRADIENTS"); nnOptions.Append (":"); nnOptions.Append (layoutString); nnOptions.Append (":"); nnOptions.Append (trainingStrategyString); factory->BookMethod( TMVA::Types::kNN, "NN", nnOptions ); // NN } // CF(Clermont-Ferrand)ANN if (Use["CFMlpANN"]) factory->BookMethod( TMVA::Types::kCFMlpANN, "CFMlpANN", "!H:!V:NCycles=2000:HiddenLayers=N+1,N" ); // n_cycles:#nodes:#nodes:... // Tmlp(Root)ANN if (Use["TMlpANN"]) factory->BookMethod( TMVA::Types::kTMlpANN, "TMlpANN", "!H:!V:NCycles=200:HiddenLayers=N+1,N:LearningMethod=BFGS:ValidationFraction=0.3" ); // n_cycles:#nodes:#nodes:... // Support Vector Machine if (Use["SVM"]) factory->BookMethod( TMVA::Types::kSVM, "SVM", "Gamma=0.25:Tol=0.001:VarTransform=Norm" ); // Boosted Decision Trees if (Use["BDTG"]) // Gradient Boost factory->BookMethod( TMVA::Types::kBDT, "BDTG", "!H:!V:NTrees=1000:MinNodeSize=2.5%:BoostType=Grad:Shrinkage=0.10:UseBaggedBoost:BaggedSampleFraction=0.5:nCuts=20:MaxDepth=2" ); if (Use["BDT"]) // Adaptive Boost factory->BookMethod( TMVA::Types::kBDT, "BDT", "!H:!V:NTrees=850:MinNodeSize=2.5%:MaxDepth=3:BoostType=AdaBoost:AdaBoostBeta=0.5:UseBaggedBoost:BaggedSampleFraction=0.5:SeparationType=GiniIndex:nCuts=20" ); if (Use["BDTB"]) // Bagging factory->BookMethod( TMVA::Types::kBDT, "BDTB", "!H:!V:NTrees=400:BoostType=Bagging:SeparationType=GiniIndex:nCuts=20" ); if (Use["BDTD"]) // Decorrelation + Adaptive Boost factory->BookMethod( TMVA::Types::kBDT, "BDTD", "!H:!V:NTrees=400:MinNodeSize=5%:MaxDepth=3:BoostType=AdaBoost:SeparationType=GiniIndex:nCuts=20:VarTransform=Decorrelate" ); if (Use["BDTF"]) // Allow Using Fisher discriminant in node splitting for (strong) linearly correlated variables factory->BookMethod( TMVA::Types::kBDT, "BDTMitFisher", "!H:!V:NTrees=50:MinNodeSize=2.5%:UseFisherCuts:MaxDepth=3:BoostType=AdaBoost:AdaBoostBeta=0.5:SeparationType=GiniIndex:nCuts=20" ); // RuleFit -- TMVA implementation of Friedman's method if (Use["RuleFit"]) factory->BookMethod( TMVA::Types::kRuleFit, "RuleFit", "H:!V:RuleFitModule=RFTMVA:Model=ModRuleLinear:MinImp=0.001:RuleMinDist=0.001:NTrees=20:fEventsMin=0.01:fEventsMax=0.5:GDTau=-1.0:GDTauPrec=0.01:GDStep=0.01:GDNSteps=10000:GDErrScale=1.02" ); // For an example of the category classifier usage, see: TMVAClassificationCategory // -------------------------------------------------------------------------------------------------- // ---- Now you can optimize the setting (configuration) of the MVAs using the set of training events // ---- STILL EXPERIMENTAL and only implemented for BDT's ! // factory->OptimizeAllMethods("SigEffAt001","Scan"); // factory->OptimizeAllMethods("ROCIntegral","FitGA"); // -------------------------------------------------------------------------------------------------- // ---- Now you can tell the factory to train, test, and evaluate the MVAs // Train MVAs using the set of training events factory->TrainAllMethods(); // ---- Evaluate all MVAs using the set of test events factory->TestAllMethods(); // ----- Evaluate and compare performance of all configured MVAs factory->EvaluateAllMethods(); // -------------------------------------------------------------- // Save the output outputFile->Close(); std::cout << "==> Wrote root file: " << outputFile->GetName() << std::endl; std::cout << "==> TMVAClassification is done!" << std::endl; delete factory; // Launch the GUI for the root macros if (!gROOT->IsBatch()) TMVA::TMVAGui( outfileName ); return 0; }
int MC_Ratio(int leptonId, double par_low, double par_upp, int nbins, TString sel_den , TString sel_num, double cut_den = 0., double cut_num = 0., TString par_x = "Pt", TString option = ""){ setTDRStyle(); /////////////// //Get the TTree /////////////// //Location of the .root file TString location = "/Users/GLP/Desktop/CERN_data/2014-11-13_skim2ll-mva-softbtag/postprocessed/"; //Reading the tree // TChain* tree = new TChain("treeProducerSusyMultilepton"); //DY events tree->Add(location+"DYJetsToLLM50_PU_S14_POSTLS170.root"); //Plot the result Long64_t n = tree->GetEntries(); //Path for input and output file. Written in FitDataPath.txt TString _path = "/Users/GLP/Dropbox/Physique/Master_Thesis/plots_root/MC_ratio/"; ////////////////////// //Name for the plots// ////////////////////// TString pname; TString _pname; TString _par; TString _sel_num; TString _sel_den; TString _cut_den; TString _option; //Writing string if (leptonId == 11) {pname = "e";_pname = "e";} else if (leptonId == 13){pname = " #mu";_pname = "mu";} if(par_x == "Pt"){_par = "P_{t}";} else if(par_x == "eta"){_par = "#eta";} else if(par_x == "phi"){_par = "#phi";} else{cout<<"ERROR: wrong parameter name !";return 1;} if(sel_num == ""){_sel_num = "unsel";} else if(sel_num == "tight"){_sel_num = "tight";} else if(sel_num == "tightmva"){_sel_num = "tightmva";} if((sel_num == "tightmva")&&(leptonId == 13)){cout<<"ERROR: no tightId MVA defined for the muon !";return 1;} //else if(sel_num == "mvaid"){_sel_num = Form("tightmva%0.3lf",cut_num) ;} else if(sel_num == "loose"){_sel_num = "loose";} else if(sel_num == "reliso3"){_sel_num = Form("reliso3_%0.3lf",cut_num);} else if(sel_num == "reliso4"){_sel_num = Form("reliso4_%0.3lf",cut_num);} else if(sel_num == "chiso3"){_sel_num = Form("chiso3_%0.3lf",cut_num);} else if(sel_num == "chiso4"){_sel_num = Form("chiso4_%0.3lf",cut_num);} else if(sel_num == "dxy"){_sel_num = Form("dxy_%0.3lf",cut_num);} else if(sel_num == "dz"){_sel_num = Form("dz_%0.3lf",cut_num);} else{cout<<"ERROR: wrong numerator name !";return 1;} //Selection on the denominator if(sel_den == ""){_sel_den = "unsel";} else if(sel_den == "tight"){_sel_den = "tight";} else if(sel_den == "tightmva"){_sel_den = "tightmva";} if((sel_den == "tightmva")&&(leptonId == 13)){cout<<"ERROR: no tightId MVA defined for the muon !";return 1;} //else if(sel_den == "mvaid"){_sel_den = Form("tightmva%0.3lf",cut_den) ;} else if(sel_den == "loose"){_sel_den = "loose";} else{cout<<"ERROR: wrong denominator selection name !";return 1;} option.Append(" "); option.Prepend(" "); if(option.Contains(" ll ")){_option += "_ll";} if(option.Contains(" unmatched ")){_option += "_unmatched";} if(option.Contains(" alleta ")){_option += "_alleta";} _option += "_"; //Name of the output //TString _fname = file_name("eff3",leptonId, par_low,par_upp,sel_den,sel_num,cut_den,cut_num,par_x,option); //TString _output= _path+_fname + ".root"; TString _output = _path+"eff4"+_option+_pname+"_den_"+_sel_den+"_num_"+_sel_num+"_"+par_x+".root"; //Declaration of histogram // //Preparation for general range in eta/pt //TH1D **histo_num = new TH1D*[nrange]; //TH1D **histo_den = new TH1D*[nrange]; //TH1D **eff = new TH1D*[nrange]; //int nrange = 3; //double par2[nrange] = {0,1.2,2.4}; //for(int _i = 0; _i < nrange; ++_i){ // //Barrel // histo_num[_i] = new TH1D("histo_num","Pt",nbins,min(par_low,0.),par_upp); // histo_den[_i] = new TH1D("histo_den","Pt",nbins,min(par_low,0.),par_upp); // eff[_i] = new TH1D("eff","Pt",nbins,min(par_low,0.),par_upp); // //} //efficiency of the isolation cut TH1D *histo_numB= new TH1D("histo_numB","Pt",nbins,min(par_low,0.),par_upp); TH1D *histo_denB= new TH1D("histo_denB","Pt",nbins,min(par_low,0.),par_upp); TH1D *histo_numE= new TH1D("histo_numE","Pt",nbins,min(par_low,0.),par_upp); TH1D *histo_denE= new TH1D("histo_denE","Pt",nbins,min(par_low,0.),par_upp); //Histo in all eta region TH1D *histo_num= new TH1D("histo_num","Pt",nbins,min(par_low,0.),par_upp); TH1D *histo_den= new TH1D("histo_den","Pt",nbins,min(par_low,0.),par_upp); //efficiency of the selection TH1D* effB = new TH1D ("effB","Pt",nbins,min(par_low,0.),par_upp); TH1D* effE = new TH1D ("effE","Pt",nbins,min(par_low,0.),par_upp); //efficiency all eta TH1D* eff = new TH1D ("eff","Pt",nbins,min(par_low,0.),par_upp);k //Event variables Int_t evt_id; Float_t scale; //Generated Float_t gen_phi[200]; Float_t gen_eta[200]; Float_t Pt[200]; Float_t m[200]; Int_t Id[200]; Int_t Mo[200]; Float_t charge[200]; Int_t status[200]; Int_t GrMa[200]; Int_t ngenPart; Int_t source[200]; Int_t pile_up; //not loose Int_t On; Int_t Oid[200]; Float_t Opt[200]; Float_t Om[200]; Float_t Oeta[200]; Float_t Ophi[200]; Int_t Oq[200]; Int_t Otight[200]; Int_t Otighte[200]; //Float_t Omvaid[200]; Int_t Oloose[200]; Float_t Oiso3[200]; Float_t Oiso4[200]; Float_t Ochiso3[200]; Float_t Ochiso4[200]; Float_t Odxy[200]; Float_t Odz[200]; //loose Int_t Gn; Int_t Gid[200]; Float_t Gpt[200]; Float_t Gm[200]; Float_t Geta[200]; Float_t Gphi[200]; Int_t Gq[200]; Int_t Gtight[200]; Int_t Gtighte[200]; //Float_t Gmvaid[200]; Int_t Gloose[200]; Float_t Giso3[200]; Float_t Giso4[200]; Float_t Gchiso3[200]; Float_t Gchiso4[200]; Float_t Gdxy[200]; Float_t Gdz[200]; //Assigne branches tree->SetBranchAddress("evt_scale1fb", &scale); tree->SetBranchAddress("evt_id", &evt_id); //generated tree->SetBranchAddress("ngenLep", &ngenPart); tree->SetBranchAddress("genLep_pdgId", &Id); tree->SetBranchAddress("genLep_sourceId", &source); tree->SetBranchAddress("genLep_eta", &gen_eta); tree->SetBranchAddress("genLep_phi", &gen_phi); tree->SetBranchAddress("genLep_pt", &Pt); tree->SetBranchAddress("genLep_mass", &m); tree->SetBranchAddress("genLep_charge", &charge); tree->SetBranchAddress("genLep_status", &status); tree->SetBranchAddress("nTrueInt",&pile_up); //not loose tree->SetBranchAddress("nLepOther",&On); tree->SetBranchAddress("LepOther_pdgId",&Oid); tree->SetBranchAddress("LepOther_pt",&Opt); tree->SetBranchAddress("LepOther_mass",&Om); tree->SetBranchAddress("LepOther_eta",&Oeta); tree->SetBranchAddress("LepOther_phi",&Ophi); tree->SetBranchAddress("LepOther_charge",&Oq); tree->SetBranchAddress("LepOther_tightId",&Otight); tree->SetBranchAddress("LepOther_eleCutIdCSA14_50ns_v1",&Otighte); //tree->SetBranchAddress("LepOther_mvaId",&Omvaid); tree->SetBranchAddress("LepOther_looseIdSusy",Oloose); tree->SetBranchAddress("LepOther_relIso03",&Oiso3); tree->SetBranchAddress("LepOther_relIso04",&Oiso4); tree->SetBranchAddress("LepOther_chargedHadRelIso03",&Ochiso3); tree->SetBranchAddress("LepOther_chargedHadRelIso04",&Ochiso4); tree->SetBranchAddress("LepOther_dxy",&Odxy); tree->SetBranchAddress("LepOther_dz",&Odz); //Loose tree->SetBranchAddress("nLepGood",&Gn); tree->SetBranchAddress("LepGood_pdgId",&Gid); tree->SetBranchAddress("LepGood_pt",&Gpt); tree->SetBranchAddress("LepGood_mass",&Gm); tree->SetBranchAddress("LepGood_eta",&Geta); tree->SetBranchAddress("LepGood_phi",&Gphi); tree->SetBranchAddress("LepGood_charge",&Gq); tree->SetBranchAddress("LepGood_tightId",&Gtight); tree->SetBranchAddress("LepGood_eleCutIdCSA14_50ns_v1",&Gtighte); //tree->SetBranchAddress("LepGood_mvaId",&Gmvaid); tree->SetBranchAddress("LepGood_looseIdSusy",&Gloose); tree->SetBranchAddress("LepGood_relIso03",&Giso3); tree->SetBranchAddress("LepGood_relIso04",&Giso4); tree->SetBranchAddress("LepGood_chargedHadRelIso03",&Gchiso3); tree->SetBranchAddress("LepGood_chargedHadRelIso04",&Gchiso4); tree->SetBranchAddress("LepGood_dxy",&Gdxy); tree->SetBranchAddress("LepGood_dz",&Gdz); int count = 0; //Start loop over all events for (int k = 0; k < 100000; ++k) { if( 100*(double)k/n> count){cout<<count<<endl;++count;} tree->GetEntry(k); //loop on loose if(sel_den != "loose"){ for(int j=0; j<On;++j){ if((!option.Contains(" ll "))||((option.Contains(" ll "))&&(On == 2)&&(Oid[0] == -Oid[1]))){ if(abs(Oid[j]) == leptonId){ if((sel_den != "tight")||((sel_den == "tight")&&(Otight[j] == 1 ))){ //if((sel_den != "mvaid")||((sel_den == "mvaid")&&(abs(Omvaid[j]) > cut_den))){ //Veto the EE-EB gape //Variable for matching double R = 999; double delta_P = 999; double delta_charge = 999; //Parameter on the xaxis double par; //loop over all generated particles to do the matching for (int i = 0; i < ngenPart; ++i) { if((abs(Id[i]) == leptonId)&&(status[i]== 1)){ //Electrons selection double R2 = DeltaR(gen_eta[i],Oeta[j],gen_phi[i],Ophi[j] ); //Minimise DeltaR and Fill the other variables if (R > R2) { R = R2; delta_P = abs(Opt[j]-Pt[i])/Pt[i]; delta_charge = abs(Oq[j] - charge[i]); } } } //Choose the parameter to be filled for the eff. if(par_x == "Pt"){par = Opt[j];} else if(par_x == "eta"){par = Oeta[j];} else if(par_x == "phi"){par = Ophi[j];} //Fill Pt only for matched events if(((R<0.1)&&(delta_P < 0.2)&&(delta_charge < 0.5))||option.Contains("unmat")){ //Filling the den if(option.Contains(" alleta ")){ histo_den->Fill(par); }else{ if(abs(Oeta[j]) < 1.2){histo_denB->Fill(par);} if(abs(Oeta[j]) >= 1.2){histo_denE->Fill(par);} } //Additional cut on the numerator int a = 0; if((sel_num == "tight")&&(Otight[j] == 1)){a = 1;} if((sel_num == "reliso3")&&(Oiso3[j] <= cut_num)){a = 2;} if((sel_num == "reliso4")&&(Oiso4[j] <= cut_num)){a = 3;} if((sel_num == "chiso3")&&(Ochiso3[j] <= cut_num)){a = 4;} if((sel_num == "chiso4")&&(Ochiso4[j] <= cut_num)){a = 5;} if((sel_num == "dxy")&&(abs(Odxy[j]) <= cut_num)){a = 6;} if((sel_num == "dz")&&(abs(Odz[j]) <= cut_num)){a = 7;} //Never filled here if(sel_num == "loose"){a = 8;} //cout<<"again, the mva value is"<<abs(Omvaid[j])<<endl; //if((sel_num == "mvaid")&&(abs(Omvaid[j]) >= cut_num)){a = 9;} switch(a){ case 0: break; case 1: if(option.Contains(" alleta ")){ histo_num->Fill(par); }else{ if(abs(Oeta[j]) < 1.2){histo_numB->Fill(par);} if(abs(Oeta[j]) >= 1.2){histo_numE->Fill(par);}; } break; case 2: if(option.Contains(" alleta ")){ histo_num->Fill(par); }else{ if(abs(Oeta[j]) < 1.2)histo_numB->Fill(par); if(abs(Oeta[j]) >= 1.2)histo_numE->Fill(par); } break; case 3: if(option.Contains(" alleta ")){ histo_num->Fill(par); }else{ if(abs(Oeta[j]) < 1.2)histo_numB->Fill(par); if(abs(Oeta[j]) >= 1.2)histo_numE->Fill(par); } break; case 4: if(option.Contains(" alleta ")){ histo_num->Fill(par); }else{ if(abs(Oeta[j]) < 1.2)histo_numB->Fill(par); if(abs(Oeta[j]) >= 1.2)histo_numE->Fill(par); } break; case 5: if(option.Contains(" alleta ")){ histo_num->Fill(par); }else{ if(abs(Oeta[j]) < 1.2)histo_numB->Fill(par); if(abs(Oeta[j]) >= 1.2)histo_numE->Fill(par); } break; case 6: if(option.Contains(" alleta ")){ histo_num->Fill(par); }else{ if(abs(Oeta[j]) < 1.2)histo_numB->Fill(par); if(abs(Oeta[j]) >= 1.2)histo_numE->Fill(par); } break; case 7: if(option.Contains(" alleta ")){ histo_num->Fill(par); }else{ if(abs(Oeta[j]) < 1.2)histo_numB->Fill(par); if(abs(Oeta[j]) >= 1.2)histo_numE->Fill(par); } break; case 8: //Nothing to fill break; case 9: if(option.Contains(" alleta ")){ histo_num->Fill(par); }else{ if(abs(Oeta[j]) < 1.2)histo_numB->Fill(par); if(abs(Oeta[j]) >= 1.2)histo_numE->Fill(par); } break; } } } } } } } //} //loop on tight for(int j=0; j<Gn;++j){ if((!option.Contains(" ll "))||((option.Contains(" ll "))&&(Gn == 2)&&(Gid[0] == -Gid[1]))){ if(abs(Gid[j]) == leptonId){ //Cut on the denominator if((sel_den != "tight")||((sel_den == "tight")&&(Gtight[j] == 1 ))){ //if((sel_den != "mvaid")||((sel_den == "mvaid")&&(abs(Gmvaid[j]) > cut_den))){ //Veto the EE-EB gape //Variable for matching double R = 999; double delta_P = 999; double delta_charge = 999; //Parameter on the xaxis double par; //loop over all generated particles to do the matching for (int i = 0; i < ngenPart; ++i) { if((abs(Id[i]) == leptonId)&&(status[i]== 1)){ //Electrons selection double R2 = DeltaR(gen_eta[i],Geta[j],gen_phi[i],Gphi[j] ); //Minimise DeltaR and Fill the other variables if (R > R2) { R = R2; delta_P = abs(Gpt[j]-Pt[i])/Pt[i]; delta_charge = abs(Gq[j] - charge[i]); } } } //Choose the parameter to be filled for the eff. if(par_x == "Pt"){par = Gpt[j];} else if(par_x == "eta"){par = Geta[j];} else if(par_x == "phi"){par = Gphi[j];} //Fill Pt only for matched events if(((R<0.1)&&(delta_P < 0.2)&&(delta_charge < 0.5))||option.Contains("unmat")){ //Filling the den if(option.Contains(" alleta ")){ histo_den->Fill(par); }else{ if(abs(Geta[j]) < 1.2){histo_denB->Fill(par);} if(abs(Geta[j]) >= 1.2){histo_denE->Fill(par);} } //Additional cut on the numerator int a = 0; if((sel_num == "tight")&&(Gtight[j] == 1)){a = 1;} if((sel_num == "reliso3")&&(Giso3[j] <= cut_num)){a = 2;} if((sel_num == "reliso4")&&(Giso4[j] <= cut_num)){a = 3;} if((sel_num == "chiso3")&&(Gchiso3[j] <= cut_num)){a = 4;} if((sel_num == "chiso4")&&(Gchiso4[j] <= cut_num)){a = 5;} if((sel_num == "dxy")&&(abs(Gdxy[j]) <= cut_num)){a = 6;} if((sel_num == "dz")&&(abs(Gdz[j]) <= cut_num)){a = 7;} //Only loose leptons here, so this is filled anyway if((sel_num == "loose")){a = 8;} //if((sel_num == "mvaid")&&(abs(Gmvaid[j]) >= cut_num)){a = 9;} switch(a){ case 0: break; case 1: if(option.Contains(" alleta ")){ histo_num->Fill(par); }else{ if(abs(Geta[j]) < 1.2){histo_numB->Fill(par);} if(abs(Geta[j]) >= 1.2){histo_numE->Fill(par);} } break; case 2: if(option.Contains(" alleta ")){ histo_num->Fill(par); }else{ if(abs(Geta[j]) < 1.2)histo_numB->Fill(par); if(abs(Geta[j]) >= 1.2)histo_numE->Fill(par); } break; case 3: if(option.Contains(" alleta ")){ histo_num->Fill(par); }else{ if(abs(Geta[j]) < 1.2)histo_numB->Fill(par); if(abs(Geta[j]) >= 1.2)histo_numE->Fill(par); } break; case 4: if(option.Contains(" alleta ")){ histo_num->Fill(par); }else{ if(abs(Geta[j]) < 1.2)histo_numB->Fill(par); if(abs(Geta[j]) >= 1.2)histo_numE->Fill(par); } break; case 5: if(option.Contains(" alleta ")){ histo_num->Fill(par); }else{ if(abs(Geta[j]) < 1.2)histo_numB->Fill(par); if(abs(Geta[j]) >= 1.2)histo_numE->Fill(par); } break; case 6: if(option.Contains(" alleta ")){ histo_num->Fill(par); }else{ if(abs(Geta[j]) < 1.2)histo_numB->Fill(par); if(abs(Geta[j]) >= 1.2)histo_numE->Fill(par); } break; case 7: if(option.Contains(" alleta ")){ histo_num->Fill(par); }else{ if(abs(Geta[j]) < 1.2)histo_numB->Fill(par); if(abs(Geta[j]) >= 1.2)histo_numE->Fill(par); } break; case 8: if(option.Contains(" alleta ")){ histo_num->Fill(par); }else{ if(abs(Geta[j]) < 1.2)histo_numB->Fill(par); if(abs(Geta[j]) >= 1.2)histo_numE->Fill(par); } break; case 9: if(option.Contains(" alleta ")){ histo_num->Fill(par); }else{ if(abs(Geta[j]) < 1.2)histo_numB->Fill(par); if(abs(Geta[j]) >= 1.2)histo_numE->Fill(par); } break; } } } } } } } //} if(option.Contains(" alleta ")){ histo_num->Sumw2(); histo_den->Sumw2(); //Divide histograms to get the efficiency eff->Divide(histo_num,histo_den,1,1,"B"); //Efficiency of the iso cut. TCanvas* c = new TCanvas("c","c"); eff->Draw(); eff->GetYaxis()->SetTitle("#epsilon"); eff->GetXaxis()->SetTitle(_par); //eff->GetXaxis()->SetRangeUser(0,250); eff->SetMarkerStyle(20); eff->SetMarkerSize(1); eff->SetMarkerColor(4); eff->SetLineColor(4); eff->SetTitle(_sel_num+" for "+_sel_den+" "+pname); //Define the name of the canvas TString cname = "eff4"+option+_pname+"_den_"+_sel_den+"_num_"+_sel_num+"_"+par_x; c->SaveAs(_path+"PDF/"+cname+".pdf"); TFile* output = new TFile(_output,"recreate"); eff->Write("eff"); output->Close(); }else{ //cout<<"Problem"<<endl; histo_numB->Sumw2(); histo_numE->Sumw2(); histo_denB->Sumw2(); histo_denE->Sumw2(); //Divide histograms to get the efficiency effB->Divide(histo_numB,histo_denB,1,1,"B"); effE->Divide(histo_numE,histo_denE,1,1,"B"); //Efficiency of the iso cut. TCanvas* c1 = new TCanvas("c1","c1"); effB->Draw(); effB->GetYaxis()->SetTitle("#epsilon"); effB->GetXaxis()->SetTitle(_par); //effB->GetXaxis()->SetRangeUser(0,250); effB->SetMarkerStyle(20); effB->SetMarkerSize(1); effB->SetMarkerColor(4); effB->SetLineColor(4); effB->SetTitle(_sel_num+" for "+_sel_den+" "+pname+" #||{#eta}<1.2"); TCanvas* c2 = new TCanvas("c2","c2"); effE->Draw(); effE->GetYaxis()->SetRangeUser(0,1.1); effE->GetYaxis()->SetTitle("#epsilon"); effE->GetXaxis()->SetTitle(_par); //effE->GetXaxis()->SetRangeUser(0,250); effE->SetMarkerStyle(20); effE->SetMarkerSize(1); effE->SetMarkerColor(4); effE->SetLineColor(4); effE->SetTitle(_sel_num+" for "+_sel_den+" "+pname+" #||{#eta}>1.2"); //Define the name of the canvas TString c1name = "eff4"+option+_pname+"_den_"+_sel_den+"_num_"+_sel_num+"_"+par_x+"_eta<1.2"; TString c2name = "eff4"+option+_pname+"_den_"+_sel_den+"_num_"+_sel_num+"_"+par_x+"_eta>1.2"; c1->SaveAs(_path+"PDF/"+c1name+".pdf"); c2->SaveAs(_path+"PDF/"+c2name+".pdf"); TFile* output = new TFile(_output,"recreate"); //c1->Write(); //c2->Write(); effB->Write("eff_eta<1.2"); effE->Write("eff_eta>1.2"); output->Close(); } return 0; }
void AnaGenPartonAndFFNtuplizer(bool save=false, bool applyQ = false, double fractQ = 0.3, double constQ = 30.0, double fractLogQ = 0.1, double fractLogQ_P2 = 1, bool fixedFracLogQ = true, float fractLogQ_low = 1.5, float fractLogQ_hig = 2.5, bool phiDepELoss = false, float ellipse_a = 7.0, float ellipse_b = 10.0){ // variables bool debug = false; /* bool applyQ = false; double fractQ = 0.3; double constQ = 30.0; // 10, 20, 30 double fractLogQ = 0.1; double fractLogQ_P2 = 1; // 1 = does nothing fractQ = -1; constQ = -1; fractLogQ = 2.0; fractLogQ_P2 = 1; bool fixedFracLogQ = true; float fractLogQ_low = 1.5; float fractLogQ_hig = 2.5; bool phiDepELoss = true; float ellipse_a = 7.0; // short path length float ellipse_b = 10.0; // long path length */ //TString infdir = "/net/hisrv0001/home/y_alive/scratch1/ana/jetquenching/pythia"; //TString infile = "spectAnaGEN_March26_PtAll_numEvents5000_proq20_FullExt_v3_VariedN.root"; TString infdir = "/net/hisrv0001/home/y_alive/scratch1/ana/jetquenching/pythia/proq20"; TString infile = "spectAnaGEN_March26_PtAll_Ntot24M_proq20_FullExt_Large_VariedN"; //TString infile = "spectAnaGEN_March26_PtAll_Ntot17M_proq20_FullExt_Large_VariedN"; //TString infile = "spectAnaGEN_March26_PtAll_Ntot8M_proq20_FullExt_Large_VariedN"; //TString infile = "spectAnaGEN_March26_PtAll_Ntot400K_proq20_FullExt_Large_VariedN"; //TString infile = "spectAnaGEN_March26_PtAll_numEvents5000_proq20_FullExt_v5_VariedN"; //TString infdir = "/net/hisrv0001/home/y_alive/cmssw_new/CMSSW_443_JetQuenchingAna/src/SpectraAna/GenPartonAndFFNtuplizer/test"; //TString infile = "spectAnaGEN_numEvent500.root"; TString outdir = "./root_output"; TString outfile; outfile.Append(Form("ANA_%s",infile.Data())); if(applyQ) { outfile.Append("_jetQ"); if(fractQ>0) outfile.Append(Form("_fract%1.2f",fractQ)); if(constQ>0) outfile.Append(Form("_const%1.2f",constQ)); if(fractLogQ>0) { if(!fixedFracLogQ) { // if parameter is not fixed outfile.Append(Form("_fractLog%1.2fto%1.2f",fractLogQ_low,fractLogQ_hig)); }else{ outfile.Append(Form("_fractLog%1.2f",fractLogQ)); } if(fractLogQ_P2!=1) outfile.Append(Form("_sp%1.2f",fractLogQ_P2)); } if(phiDepELoss){ outfile.Append(Form("_phidep_a%1.2f_b%1.2f",ellipse_a,ellipse_b)); } } cout<<"Check Parameters = "<<outfile.Data()<<endl; TFile *f1 = TFile::Open(Form("%s/%s.root",infdir.Data(),infile.Data())); if(!f1) { Error("<Input File Reading>","File is NULL"); return; } f1->cd("genSpectAna"); TTree *nt = (TTree*) f1->FindObjectAny("SpectraStudyTree"); if(!nt) { Error("<Input Tree Reading>","Tree is NULL"); return; } gSystem->Load("/net/hisrv0001/home/y_alive/cmssw_new/CMSSW_443_JetQuenchingAna/lib/slc5_amd64_gcc434/pluginSpectraAnaGenPartonAndFFNtuplizer.so"); SpectraStudyTreeClass stree; TClonesArray *asstrk = new TClonesArray("GenParticleInfo"); TClonesArray *alltrk = new TClonesArray("GenParticleInfo"); nt->SetBranchAddress("fPthat",&stree.fPthat); nt->SetBranchAddress("fCrossx",&stree.fCrossx); nt->SetBranchAddress("isMinPtHat",&stree.isMinPtHat); nt->SetBranchAddress("nNumEvt",&stree.nNumEvt); nt->SetBranchAddress("nJets",&stree.nJets); nt->SetBranchAddress("nTrks",stree.nTrks); nt->SetBranchAddress("fJPt",stree.fJPt); nt->SetBranchAddress("fJEt",stree.fJEt); nt->SetBranchAddress("fJEta",stree.fJEta); nt->SetBranchAddress("fJPhi",stree.fJPhi); nt->SetBranchAddress("AssParticles",&asstrk); nt->SetBranchAddress("AllParticles",&alltrk); // prepare histograms prepareHist(); int totN = 0; for (int i=0;i<nt->GetEntries();i++){ nt->GetEntry(i); float nevt = (float) stree.nNumEvt; //if(i>10000) break; if (i%50000==0) { cout<<"Cross-section = "<<stree.fCrossx<<" pTHat = "<<stree.fPthat <<" number of events = "<<nevt <<" number of jets = "<<stree.nJets<<" number of total tracks = "<<alltrk->GetEntriesFast()<<endl; } int ntotTrk = 0; dPtHat->Fill(stree.fPthat); /* Event-by-event Quenching Parameter Determination */ double pFracQ = 0.0; if(fixedFracLogQ){ pFracQ = fractLogQ; }else{ pFracQ = gRandom->Uniform(fractLogQ_low,fractLogQ_hig); } dPar1stFracLogQ->Fill(gRandom->Uniform(fractLogQ_low,fractLogQ_hig)); // 0. Parton/Jet and Associated Tracks ------------------------------------ for (int j=0; j<stree.nJets; ++j) { float jet = stree.fJEt[j]; float jpt = stree.fJPt[j]; float jeta = stree.fJEta[j]; float jphi = stree.fJPhi[j]; int ntrk = stree.nTrks[j]; float pathLength = 0.0; float pPhiFracQ = 0.0; // Without this cut, slightly more fragmented tracks in 4-5 GeV/c if(fabs(jeta)>2.0) continue; // eta cut if(debug) { cout<<" Found Jet (et,pt, eta,phi) = ("<<jet<<","<<jpt<<", "<<jeta<<","<<jphi <<") with "<<ntrk<<" associated charged tracks"<<endl; } /* Apply quenching scenarios */ if(applyQ){ if(fractQ>0){ /* fractional eloss: */ jet = jet*(1. - fractQ); }else if(constQ>0){ /* constant eloss: */ jet = jet - constQ; }else if(!phiDepELoss && fractLogQ>0){ /* e-dependent fractional eloss: */ jet = jet*(1. - pFracQ*(log(fractLogQ_P2*jet)/jet)); //}else if(phiDepELoss && fractLogQ>0){ }else if(phiDepELoss){ float pathLength = 0.0; float pPhiFracQ = 0.0; pathLength = getPathL(jphi,ellipse_a,ellipse_b); pPhiFracQ = getPar1stLinearPathL(pathLength,ellipse_a,ellipse_b); jet = jet*(1. - pPhiFracQ*(log(fractLogQ_P2*jet)/jet)); dPathL->Fill(pathLength,stree.fCrossx); dPhidPathL->Fill(jphi,pathLength,stree.fCrossx); dPhidPathL2->Fill(jphi,pathLength*pathLength,stree.fCrossx); dPar1stdPhi->Fill(pPhiFracQ,jphi,stree.fCrossx); dPar1stVsPhi->Fill(pPhiFracQ*cos(jphi),pPhiFracQ*sin(jphi),stree.fCrossx); dPathLVsPhi->Fill(pathLength*cos(jphi),pathLength*sin(jphi),stree.fCrossx); dPathLVsPhiWPar1st->Fill(pathLength*cos(jphi),pathLength*sin(jphi),pPhiFracQ*stree.fCrossx); // sure? } // THIS IS IMPORTANT --> JUSTIFIED? // THIS IS NOT NEEDED SINCE JET<0 FILLED IN UNDERFLOW BIN ANYWAY // if(jet<0) continue; } // end of apply jetQ // HIST FILLING dJetPhi->Fill(jphi,stree.fCrossx); dNJetdEt->Fill(jet,stree.fCrossx); dNJetdEtdPhi->Fill(jet,jphi,stree.fCrossx); dNJetdEtdCos2Phi->Fill(jet,cos(2.*jphi),stree.fCrossx); // v2 = <cos2(phi-psi)> dNJetdEtwCos2Phi->Fill(jet,stree.fCrossx*cos(2.*jphi)); // v2 = dNJetdEtwCos2Phi/dNJetdEtwNonePhi dNJetdEtwNonePhi->Fill(jet,stree.fCrossx*1.0); dNJetdEtdPtHat->Fill(jet,stree.fPthat,stree.fCrossx); dNJetdEtdPtHat_FF->Fill(jet,stree.fPthat,stree.fCrossx); // associated track loop for (int k=0; k<ntrk; ++k) { GenParticleInfo *AssParticles = (GenParticleInfo*)asstrk->At(ntotTrk); ntotTrk++; // ntotTrk = sum of ntrk_{i} float trkpt = AssParticles->fPt; float trketa = AssParticles->fEta; float trkphi = AssParticles->fPhi; float trkz = (jet>0) ? trkpt/jet : 100.0; if(fabs(trketa)>1.0) continue; // eta cut if(debug) { cout<<" Associated Tracks (pt,eta,phi) = ("<<trkpt<<","<<trketa<<","<<trkphi <<") and z = trkpt/jetet = "<<trkpt/jpt<<endl; } // HIST FILLING dNTrkdPtdPtHat->Fill(trkpt,stree.fPthat,stree.fCrossx); // weighted by cross section dNTrkdPtdJetEt->Fill(trkpt,jpt,stree.fCrossx); dNTrkdZdJetEt->Fill(trkz,jpt,stree.fCrossx); dNTrkdPtdPhi->Fill(trkpt,trkphi,stree.fCrossx); //dNTrkdPtdPhi->Fill(trkpt,trkphi,stree.fCrossx*(1.+applyCos(trkphi))); // ARTIFICAL V2 dNTrkdPtdJetEtdPhi->Fill(trkpt,jpt,trkphi,stree.fCrossx); dNTrkdPtdPtHatdJetEt->Fill(trkpt,stree.fPthat,jpt,stree.fCrossx); dNTrkdZdPtHatdJetEt->Fill(trkz,stree.fPthat,jpt,stree.fCrossx); //ntotTrk++; } // end of tracks } // end of nJets // 1. All Charged Tracks ---------------------------------------- for (int l=0; l<alltrk->GetEntriesFast(); ++l) { GenParticleInfo *AllParticles = (GenParticleInfo*)alltrk->At(l); float alltrkpt = AllParticles->fPt; float alltrketa = AllParticles->fEta; float alltrkphi = AllParticles->fPhi; if(fabs(alltrketa)>1.0) continue; // eta cut // HIST FILLING dNAllTrkdPtdPtHat->Fill(alltrkpt,stree.fPthat,stree.fCrossx); dNAllTrkdPtdPhi->Fill(alltrkpt,alltrkphi,stree.fCrossx); } if(stree.isMinPtHat==1) dNevtMinPtHat->Fill(1.1); totN++; } // end of all entries cout<<"Number of events = "<<totN<<endl; // Fragmentation Function Generator if(saveFF){ for(int j=0;j<dNTrkdPtdPtHatdJetEt->GetNbinsZ();j++){ //double dsigma = hdjetet_ff->GetBinContent(j+1); //if(dsigma<1E-22) continue; // no jet ET bins double etmin = dNTrkdPtdPtHatdJetEt->GetZaxis()->GetBinLowEdge(j+1); double etmax = dNTrkdPtdPtHatdJetEt->GetZaxis()->GetBinUpEdge(j+1); // Fragmentation Function (Be carefull not [j+1,j+2]) TH1D *hddtrkdpt_ff = (TH1D*) dNTrkdPtdPtHatdJetEt->ProjectionX("",0,-1,j+1,j+1,"e"); hddtrkdpt_ff->SetName(Form("hddTrkdPt_FF_et%1.0fto%1.0f",etmin,etmax)); hFF.push_back(hddtrkdpt_ff); } } // Save histograms in a root file if(save){ cout<<"Output file = "<<Form("%s/%s.root",outdir.Data(),outfile.Data())<<endl; TFile *outputFile = new TFile(Form("%s/%s.root",outdir.Data(),outfile.Data()),"recreate"); saveHistRoot(); } }
void AnalyzeClipping(TString inputWaveName = "sum trigger input ch5 960mV", TString outputWaveName = "sum trigger output ch5 - 2V clip - 960mV input", Double_t inputDelay = 1.1E-8, Double_t lowerCut = 16E-9, Double_t upperCut = 23E-9, const char *inFile = "Data.root",const char *WaveformsFile = "Waveforms.root") { //try to access data file and in case of failure return if(gSystem->AccessPathName(inFile,kFileExists)) { cout << "Error: file " << inFile << " does not exsist. Run .x DataParse.C to create it" << endl; return; } TFile *f = TFile::Open(inFile); TFolder *dataSet; TString dataFolderS = "SumTriggerBoardData"; dataFolderS.Append(";1"); dataSet = (TFolder*)f->Get(dataFolderS); cout << dataSet << endl; cout << dataSet->GetName() << endl; Int_t nScope = 150; // number of measurements done by the scope evey time //try to access waveforms file and in case of failure return if(gSystem->AccessPathName(WaveformsFile,kFileExists)) { cout << "Error: file " << WaveformsFile << " does not exsist. Run .x WaveformsFileMaker.C to create it" << endl; return; } TFile *f = TFile::Open(WaveformsFile); TList *listOfKeys = f->GetListOfKeys(); Int_t numberOfKeys = listOfKeys->GetEntries(); TList *listOfGraphs = new TList(); // if the waveform file name begins with the string "comparator" it goes in this list TList *listOfCompWaves = new TList(); // if the waveform file name begins with the string "sum output" it goes in this list TList *listOfAdderWaves = new TList(); for(Int_t i = 0; i < numberOfKeys; i++) { TString *keyName = new TString(listOfKeys->At(i)->GetName()); TTree *tree = (TTree*)f->Get(keyName->Data()); Float_t x = 0; Float_t y = 0; tree->SetBranchAddress("x",&x); tree->SetBranchAddress("y",&y); Int_t nentries = tree->GetEntries(); TString *gName = new TString(keyName->Data()); gName->Append(" graph"); TGraphErrors *gWave = new TGraphErrors(nentries); gWave->SetName(gName->Data()); gWave->SetTitle(gName->Data()); gWave->GetXaxis()->SetTitle("Time"); gWave->GetYaxis()->SetTitle("Voltage"); for (Int_t j = 0; j < nentries; j++) { tree->GetEntry(j); gWave->SetPoint(j,x,y); } listOfGraphs->Add(gWave); } // Global variables Double_t *xInput, *xOutput, *yInput, *yOutput; // V input 960 mV TString path = "Clipping/Output width analysis/Channel 5/V input 960mV/"; TGraphErrors *gClip960mV = TBGraphErrors(dataSet,path,"V clip","Output FWHM",1,nScope); gClip960mV->SetMarkerStyle(20); gClip960mV->SetMarkerSize(0.8); gClip960mV->GetXaxis()->SetTitle("V clipping (mV)"); gClip960mV->GetYaxis()->SetTitle("Output FWHM (ns)"); TCanvas *cClip960mV = new TCanvas("cClip960mV","Output FWHM in function of V clipping",800,600); gClip960mV->Draw("APEL"); // Expected output FWHM TGraphErrors *gInput960mV = listOfGraphs->FindObject("sum trigger input ch5 960mV graph"); Double_t *xClip = gClip960mV->GetX(); Int_t nClip = gClip960mV->GetN(); cout << "nClip = " << nClip << endl; Long64_t graphPoints = gInput960mV->GetN(); yInput = gInput960mV->GetY(); xInput = gInput960mV->GetX(); vector<double> xFirst(nClip); vector<double> xLast(nClip); Double_t half; Int_t flag = 0; vector<double> yConv(graphPoints); for(Int_t i = 0; i < graphPoints; i++) { yConv[i] = -(yInput[i]); yConv[i] *= 1000; if(xInput[i] + inputDelay < lowerCut || xInput[i] + inputDelay > upperCut) yConv[i] = 0; } Double_t yInput960mVMax = TMath::MaxElement(graphPoints,&yConv[0]); for(Int_t i = 0; i < nClip; i++) { if(xClip[i] > yInput960mVMax) half = yInput960mVMax; else half = xClip[i]; half /=2; cout << half << endl; flag = 0; for(Int_t j = 0; j < graphPoints - 3; j++) { if((yConv[j + 1] - half)*(yConv[j] - half) < 0 && flag == 0) { xFirst[i] = xInput[j]; flag = 1; cout << "found first point! " << xFirst[i] << endl; continue; } if((yConv[j + 1] - half)*(yConv[j] - half) < 0 && flag == 1) { xLast[i] = xInput[j]; cout << "found last point! " << xLast[i] << endl; break; } } } vector<double> expectedFWHM960mV(nClip); for(Int_t i = 0; i < expectedFWHM960mV.size(); i++) { expectedFWHM960mV[i] = xLast[i] - xFirst[i]; // convert from seconds to nanoseconds expectedFWHM960mV[i] *= 10E8; cout << "expectedFWHM960mV[" << i << "] = " << expectedFWHM960mV[i] << endl; } // expected FWHM 960 mV graph TGraphErrors *gExpClip960mV = new TGraphErrors(nClip,xClip,&expectedFWHM960mV[0],0,0); gExpClip960mV->SetLineStyle(7); gExpClip960mV->SetMarkerStyle(20); gExpClip960mV->SetMarkerSize(0.8); // V input 1.9 V path = "Clipping/Output width analysis/Channel 5/V input 1.9V/"; TGraphErrors *gClip1Point9V = TBGraphErrors(dataSet,path,"V clip","Output FWHM",1,nScope); gClip1Point9V->SetMarkerStyle(20); gClip1Point9V->SetMarkerSize(0.8); gClip1Point9V->SetLineColor(kRed); gClip1Point9V->GetXaxis()->SetTitle("V clipping (mV)"); gClip1Point9V->GetYaxis()->SetTitle("Output FWHM (ns)"); TCanvas *cClip1Point9V = new TCanvas("cClip1Point9V","Output FWHM in function of V clipping",800,600); gClip1Point9V->Draw("APEL"); // Expected output FWHM TGraphErrors *gInput1Point9V = listOfGraphs->FindObject("sum trigger input ch5 1900mV graph"); xClip = gClip1Point9V->GetX(); nClip = gClip1Point9V->GetN(); cout << "nClip = " << nClip << endl; graphPoints = gInput1Point9V->GetN(); yInput = gInput1Point9V->GetY(); xInput = gInput1Point9V->GetX(); vector<double> xFirst(nClip); vector<double> xLast(nClip); flag = 0; vector<double> yConv(graphPoints); for(Int_t i = 0; i < graphPoints; i++) { yConv[i] = -(yInput[i]); yConv[i] *= 1000; if(xInput[i] + inputDelay < lowerCut || xInput[i] + inputDelay > upperCut) yConv[i] = 0; } Double_t yInput1Point9VMax = TMath::MaxElement(graphPoints,&yConv[0]); for(Int_t i = 0; i < nClip; i++) { if(xClip[i] > yInput1Point9VMax) half = yInput1Point9VMax; else half = xClip[i]; half /= 2; cout << half << endl; flag = 0; for(Int_t j = 0; j < graphPoints - 3; j++) { if((yConv[j + 1] - half)*(yConv[j] - half) < 0 && flag == 0) { xFirst[i] = xInput[j]; flag = 1; cout << "found first point! " << xFirst[i] << endl; continue; } if((yConv[j + 1] - half)*(yConv[j] - half) < 0 && flag == 1) { xLast[i] = xInput[j]; cout << "found last point! " << xLast[i] << endl; break; } } } vector<double> expectedFWHM1Point9V(nClip); for(Int_t i = 0; i < expectedFWHM1Point9V.size(); i++) { expectedFWHM1Point9V[i] = xLast[i] - xFirst[i]; // convert from seconds to nanoseconds expectedFWHM1Point9V[i] *= 10E8; cout << "expectedFWHM1Point9V[" << i << "] = " << expectedFWHM1Point9V[i] << endl; } // expected FWHM 960 mV graph TGraphErrors *gExpClip1Point9V = new TGraphErrors(nClip,xClip,&expectedFWHM1Point9V[0],0,0); gExpClip1Point9V->SetLineStyle(7); gExpClip1Point9V->SetLineColor(kRed); gExpClip1Point9V->SetMarkerStyle(20); gExpClip1Point9V->SetMarkerSize(0.8); // Collection of Output FWHM graphs, 2 amplitudes, serveral V clipping TMultiGraph *mgClipOutputFWHM = new TMultiGraph(); mgClipOutputFWHM->SetTitle("Collection of Output FWHM graphs, 2 amplitudes, serveral V clipping"); mgClipOutputFWHM->Add(gClip1Point9V); mgClipOutputFWHM->Add(gClip960mV); mgClipOutputFWHM->Add(gExpClip960mV); mgClipOutputFWHM->Add(gExpClip1Point9V); TCanvas *cmgClipOutputFWHM = new TCanvas("cmgClipOutputFWHM","Collection of Output FWHM graphs, 2 amplitudes, serveral V clipping"); mgClipOutputFWHM->Draw("APEL"); cmgClipOutputFWHM->Modified(); mgClipOutputFWHM->GetXaxis()->SetTitle("V clipping (mV)"); mgClipOutputFWHM->GetYaxis()->SetTitle("Output FWHM (ns)"); cmgClipOutputFWHM->Update(); legend = new TLegend(0.6,0.67,0.89,0.86,"V input"); legend->AddEntry(gClip1Point9V, "1.9 V", "lp"); legend->AddEntry(gClip960mV, "960 mV", "lp"); legend->AddEntry(gExpClip960mV, "Exp 960 mV", "lp"); legend->AddEntry(gExpClip1Point9V, "Exp 1.9 V", "lp"); legend->SetTextSize(0.04); legend->SetMargin(0.5); legend->Draw(); // Hysteresis plot: V output (t) in function of V input (t) for several clipping values // variables used in the analysis Long64_t iInputMax, iOutputMax; Float_t xInputMax, xOutputMax, xInputHalf, xOutputHalf; Double_t InputMax, OutputMax, InputHalf, OutputHalf; Long64_t firstIndex = 0; Long64_t lastIndex = 0; Long64_t inputGraphPoints = 0; Long64_t outputGraphPoints = 0; // hard coded values to cut the x axis of both waves // Input wave inputWaveName += " graph"; TGraphErrors *gInput = listOfGraphs->FindObject(inputWaveName); gInput->SetLineColor(kRed); gInput->SetLineWidth(2); xInput = gInput->GetX(); yInput = gInput->GetY(); inputGraphPoints = gInput->GetN(); cout << inputGraphPoints << endl; // Invert the input wave for(Int_t i = 0; i < inputGraphPoints; i++) { yInput[i] = -(yInput[i]); } // find the x at which the graph reaches the max value iInputMax = TMath::LocMax(inputGraphPoints, yInput); xInputMax = xInput[iInputMax]; cout << "iInputMax = " << iInputMax << endl; cout << "xInputMax = " << xInputMax << endl; InputMax = gInput->Eval(xInput[iInputMax]); cout << "InputMax = " << InputMax << endl; // Output wave outputWaveName += " graph"; TGraphErrors *gOutput = listOfGraphs->FindObject(outputWaveName); gOutput->SetLineWidth(2); xOutput = gOutput->GetX(); yOutput = gOutput->GetY(); outputGraphPoints = gOutput->GetN(); // find the x at which the graph reaches the max value iOutputMax = TMath::LocMax(outputGraphPoints, yOutput); xOutputMax = xOutput[iOutputMax]; cout << "iOutputMax = " << iOutputMax << endl; cout << "xOutputMax = " << xOutputMax << endl; OutputMax = gOutput->Eval(xOutput[iOutputMax]); cout << "OutputMax = " << OutputMax << endl; // compute x delay between max points Double_t delay = xOutputMax - xInputMax; cout << "delay = " << delay << endl; // Shift the x axis of the input graph and create a new graph with only a portion of the first graph for(Int_t i = 0; i < inputGraphPoints; i++) { xInput[i] += inputDelay; if(xInput[i] >= lowerCut) { if(firstIndex == 0) firstIndex = i; } if(xInput[i] <= upperCut) lastIndex = i; } cout << "firstIndex = " << firstIndex << endl; cout << "lastIndex = " << lastIndex << endl; cout << "xInput[firstIndex] = " << xInput[firstIndex] << endl; cout << lastIndex - firstIndex << endl; Long64_t input2GraphPoints = lastIndex - firstIndex; TGraphErrors *gInput2 = new TGraphErrors(input2GraphPoints); gInput2->SetTitle(inputWaveName); for(Int_t i = firstIndex; i <= lastIndex; i++) { gInput2->SetPoint(i - firstIndex,xInput[i],yInput[i]); } TCanvas *cgInput2 = new TCanvas("cgInput2", "cgInput2", 1200,800); gInput2->Draw("AL"); // create a new graph with only a portion of the first graph firstIndex = 0; lastIndex = 0; for(Int_t i = 0; i < outputGraphPoints; i++) { if(xOutput[i] >= lowerCut) { if(firstIndex == 0) firstIndex = i; } if(xOutput[i] <= upperCut) lastIndex = i; } cout << "firstIndex = " << firstIndex << endl; cout << "lastIndex = " << lastIndex << endl; cout << "xOutput[firstIndex] = " << xOutput[firstIndex] << endl; cout << lastIndex - firstIndex << endl; Long64_t output2GraphPoints = lastIndex - firstIndex; TGraphErrors *gOutput2 = new TGraphErrors(output2GraphPoints); gOutput2->SetTitle(outputWaveName); for(Int_t i = firstIndex; i <= lastIndex; i++) { gOutput2->SetPoint(i - firstIndex,xOutput[i],yOutput[i]); } TCanvas *cgOutput2 = new TCanvas("cgOutput2", "cgOutput2", 1200,800); gOutput2->Draw("AL"); // first hysteresis plot Double_t step; Double_t *xInput2; xInput2 = gInput2->GetX(); cout << "xInput2[input2GraphPoints - 1] = " << xInput2[input2GraphPoints - 1] << endl; cout << "xInput2[0] = " << xInput2[0] << endl; step = (xInput2[input2GraphPoints - 1] - xInput2[0])/output2GraphPoints; cout << "step = " << step << endl; // in case gInput2 and gOutput2 contain a different number of points create the hysteresis plot with gOutput2 points // and modify the yInput2 to match the number of points of yOutput2 vector<double> yInput2; for(Int_t i = 0; i < output2GraphPoints; i++) { yInput2.push_back(gInput2->Eval(xInput2[0] + i*step)); } Double_t *yOutput2; yOutput2 = gOutput2->GetY(); TGraphErrors *gHyst = new TGraphErrors(output2GraphPoints, &yInput2.at(0),yOutput2); gHyst->SetTitle("Hysteresis plot"); gHyst->GetXaxis()->SetTitle("Vin(t) [mV]"); gHyst->GetYaxis()->SetTitle("Vout(t) [mV]"); gHyst->GetYaxis()->SetTitleOffset(1.4); TCanvas *cgHyst = new TCanvas("cgHyst", "cgHyst", 1200,800); cgHyst->SetLeftMargin(0.12); gHyst->Draw("AL"); // collection of graphs TMultiGraph *mgInputOutput = new TMultiGraph(); mgInputOutput->Add(gInput); mgInputOutput->Add(gOutput); mgInputOutput->SetTitle("Input and output"); TCanvas *cmgInputOutput = new TCanvas("cmgInputOutput", "Input and output", 1200,800); mgInputOutput->Draw("AL"); cmgInputOutput->Update(); legend = new TLegend(0.65,0.68,0.86,0.86); legend->AddEntry(gInput, "Input", "lp"); legend->AddEntry(gOutput, "Output", "lp"); legend->SetMargin(0.4); legend->SetTextSize(0.04); legend->Draw(); cmgInputOutput->Modified(); }
void compareEff_EGM(int iBr=0, int iBin=0, int vsEt=1, int doSave=0, double transLegendY_user=0., double ratioTitleOffset=0.58, TString *outFileName_ptr=NULL, TString *outDir_ptr=NULL) { TString path1, path2; TString effKindLongStr1,effKindLongStr2; TString fnameBase="efficiency_TnP_1D_Full2012_"; TString label1; TString label2; TString fnameTag; TString path3=""; TString effKindLongStr3=""; TString label3=""; double transLegendX=-0.2; double transLegendY=-0.6; if (1) { // 2014.05.07 path1="../root_files_reg/tag_and_probe/DY_j22_19712pb_egamma_Unregressed_energy/"; path2= path1; effKindLongStr1="dataRECO_fit-fitEtBins6EtaBins5egamma_PU"; effKindLongStr2="mcRECO_count-countEtBins6EtaBins5egamma_PU"; label1="data"; label2="simulation"; fnameTag="-reco"; transLegendX=0.1; } // ------------------------------- // processing // ------------------------------- if (transLegendY_user!=0.) transLegendY=transLegendY_user; if ((iBr==0) || (iBr==2)) { if (iBr==2) fnameTag.Append("extraSyst"); } else if ((iBr==1) || (iBr==3)) { effKindLongStr1.ReplaceAll("RECO","ID"); effKindLongStr2.ReplaceAll("RECO","ID"); fnameTag="-id"; if (iBr==3) fnameTag.Append("extraSyst"); } else { std::cout << "unknown branch = " << iBr << "\n"; return; } TString fname1=path1 + fnameBase + effKindLongStr1 + TString(".root"); TString fname2=path2 + fnameBase + effKindLongStr2 + TString(".root"); DYTools::TEtBinSet_t etBinSet1=DetermineEtBinSet(effKindLongStr1); DYTools::TEtaBinSet_t etaBinSet1=DetermineEtaBinSet(effKindLongStr1); DYTools::TEtBinSet_t etBinSet2=DetermineEtBinSet(effKindLongStr2); DYTools::TEtaBinSet_t etaBinSet2=DetermineEtaBinSet(effKindLongStr2); std::cout << "sets: "<< EtBinSetName(etBinSet1) << "," << EtaBinSetName(etaBinSet1) << " " << EtBinSetName(etBinSet2) << "," << EtaBinSetName(etaBinSet2) << "\n"; TString effKind =effDataKindString(effKindLongStr1); TString effKind2=effDataKindString(effKindLongStr2); if (effKind == effKind2) { if ( !efficiencyIsHLT(DetermineEfficiencyKind(effKind )) || !efficiencyIsHLT(DetermineEfficiencyKind(effKind2)) ) { std::cout << "effKind1=<" << effKind << ">\n"; std::cout << "effKind2=<" << effDataKindString(effKindLongStr2) << ">\n"; return; } } TString dataKind=effKind + TString(" "); int weighted1=(effKindLongStr1.Index("count-count")!=-1) ? 1 : 0; int weighted2=(effKindLongStr2.Index("count-count")!=-1) ? 1 : 0; //int iEta=0; TMatrixD *eff1=NULL, *eff1ErrLo=NULL, *eff1ErrHi=NULL; TMatrixD *eff2=NULL, *eff2ErrLo=NULL, *eff2ErrHi=NULL; TH1D *histo1=NULL, *histo2=NULL; const char *histo1Name="histo1"; const char *histo2Name="histo2"; if (!loadEff(fname1,weighted1,&eff1,&eff1ErrLo,&eff1ErrHi)) { std::cout << "failed to get fields from <" << fname1 << "> (1)\n"; return ; } if (!loadEff(fname2,weighted2,&eff2,&eff2ErrLo,&eff2ErrHi)) { std::cout << "failed to get fields from <" << fname2 << "> (2)\n"; return ; } if (etaBinSet1==DYTools::ETABINS5egamma) etaBinSet1=DYTools::ETABINS5_max25; if (etaBinSet2==DYTools::ETABINS5egamma) etaBinSet2=DYTools::ETABINS5_max25; if (etBinSet1==DYTools::ETBINS6) etBinSet1=DYTools::ETBINS6short; if (etBinSet2==DYTools::ETBINS6) etBinSet2=DYTools::ETBINS6short; TGraphAsymmErrors* gr1=getAsymGraph(vsEt,etBinSet1,etaBinSet1,iBin,*eff1,*eff1ErrLo,*eff1ErrHi,&histo1,histo1Name); //std::cout << gr1->GetTitle() << ": "; gr1->Print("range"); TGraphAsymmErrors* gr2=getAsymGraph(vsEt,etBinSet2,etaBinSet2,iBin,*eff2,*eff2ErrLo,*eff2ErrHi,&histo2,histo2Name); //std::cout << gr2->GetTitle() << ": "; gr2->Print("range"); if (1) { gr1->Print("range"); gr2->Print("range"); } TGraphAsymmErrors* div=(TGraphAsymmErrors*)gr1->Clone("div"); //TH1D *div=(TH1D*)histo1->Clone("div"); //div->Divide(histo1,histo2,1.,1.,"b"); div->Divide(histo1,histo2,"pois"); div->Print("range"); TMatrixD *sfSystErrEgamma=loadMatrix(fname1,"sf_syst_rel_error_egamma", 6,5,1); TMatrixD *sfSystErr25=loadMatrix(fname1,"sf_syst_rel_error_maxEta25", 6,5,1); sfSystErrEgamma->Print(); sfSystErr25->Print(); TVectorD egmSystErr(6), ourSystErr(6); for (int ic=0; ic<6; ++ic) { egmSystErr(ic) = (*sfSystErrEgamma)(ic,iBin); ourSystErr(ic) = (*sfSystErr25)(ic,iBin); } TGraphAsymmErrors* sfEG=addErrors(div,egmSystErr,"sfEG",1); TGraphAsymmErrors* sfOur=addErrors(sfEG,ourSystErr,"sfOur",1); sfEG->Print(); double *loc_etBinLimits=DYTools::getEtBinLimits(etBinSet1); double *loc_etaBinLimits=DYTools::getEtaBinLimits(etaBinSet1); int signedEta=DYTools::signedEtaBinning(etaBinSet1); TString cpTitle; if (vsEt) cpTitle= dataKind+ TString(Form(" %5.3lf #leq %s #leq %5.3lf",loc_etaBinLimits[iBin],(signedEta)?"#eta":"abs(#eta)",loc_etaBinLimits[iBin+1])); else cpTitle= dataKind+ TString(Form(" %2.0lf #leq #it{E}_{T} #leq %2.0lf GeV",loc_etBinLimits[iBin],loc_etBinLimits[iBin+1])); TString xaxisTitle=(vsEt) ? "#it{E}_{T}" : ((signedEta) ? "#eta" : "|#eta|"); ComparisonPlot_t cp(ComparisonPlot_t::_ratioPlain,"comp",cpTitle, xaxisTitle,"efficiency","ratio"); cp.SetRefIdx(-111); // do not plot lower panel //if (vsEt) cp.SetLogx(); cp.SetLogx(0); cp.SetGridx(1); cp.SetGridy(1); cp.SetYRange(0.0, 1.1); cp.SetXRange(0,100); // Square canvas if ratio is not plotted TCanvas *cx=new TCanvas("cx","cx",700,700); if (0) { cp.Prepare2Pads(cx); } else { cx->Divide(2,1); cp.PreparePads(cx,1,2,"comp",0.29,0.001); } SetSideSpaces(cx,0,-0.1, 0.12, 0.0,1); SetSideSpaces(cx,0,-0.1,-0.08,-0.18,2); gr1->GetYaxis()->SetTitleOffset(1.4); gr1->GetXaxis()->SetNdivisions(506); gr2->SetFillStyle(3001); gr2->SetFillColor(38); gr1->SetMarkerSize(0.8); gr2->SetMarkerSize(0.8); cp.AddGraph(gr1,label1,"LPE1",kBlack,20, 1,1,1.); cp.AddGraph(gr2,label2,"LPE2",38,22, 1,1,1.); cp.Draw(cx,0,"png",1); cp.TransLegend(transLegendX, transLegendY); //cp.WidenLegend(0.2,0.); ComparisonPlot_t cpSF(ComparisonPlot_t::_ratioPlain,"compSF","", xaxisTitle,"scale factor","ratio"); cpSF.SetRefIdx(-111); cpSF.NoLegend(1); cpSF.SetGridx(1); cpSF.SetGridy(1); //cpSF.SetXAxisTextSizes(0.08,1.1,0.08); //cpSF.SetYAxisTextSizes(0.08,1.0,0.08); cpSF.SetXAxisTextSizes(0.11,1.10,0.11); cpSF.SetYAxisTextSizes(0.14,0.57,0.11); cpSF.SetYRange(0.8,1.2); if ((iBr==1) || (iBr==3)) cpSF.SetYRange(0.7,1.3); cpSF.SetXRange(0,100); int color=38; sfEG->SetLineColor(color); sfEG->SetMarkerColor(color); sfEG->SetMarkerSize(0.8); sfEG->SetFillColor(color); sfEG->SetFillStyle(3001); sfOur->SetFillStyle(3002); if ((iBr==2) || (iBr==3)) { cpSF.AddGraph(sfOur,"","LPE2",kRed,1, 1,1,1.); TGraphAsymmErrors *sfEG3=(TGraphAsymmErrors*)sfEG->Clone("sfEG_clone3"); sfEG3->SetFillStyle(3002); cpSF.AddGraph(sfEG3,"","LPE2", 9,1, 1,1,1.); } cpSF.AddGraph(sfEG,"","LPE2",color,20, 1,1,1.); TGraphAsymmErrors *sfEG2=(TGraphAsymmErrors*)sfEG->Clone("sfEG_clone"); cpSF.AddGraph(sfEG2,"","LPE1", 9,20, 1,1,1.); cpSF.Draw(cx,0,"png",2); // ---------- line at 1 if (0) { double one= 1.; TLine *lineAtOne = new TLine(0,one, 100,one); lineAtOne->SetLineStyle(kDashed); lineAtOne->SetLineWidth(1); lineAtOne->SetLineColor(kBlack); lineAtOne->Draw(); } cx->Update(); if (fnameTag.Length()) { TString fname=TString("fig-eff-") + fnameTag + cpTitle; fname.ReplaceAll(" #leq "," "); fname.ReplaceAll(" ","_"); fname.ReplaceAll("(#eta)","Eta"); fname.ReplaceAll("#eta","eta"); fname.ReplaceAll(".","_"); fname.ReplaceAll("#it{E}_{T}","Et"); //fname.Append(".png"); TString locOutDir=TString("plots") + fnameTag; locOutDir.ReplaceAll("--",""); std::cout << "fnameBase=<" << fname << "> in <" << locOutDir << ">\n"; if (outFileName_ptr) *outFileName_ptr=fname; if (outDir_ptr) *outDir_ptr=locOutDir; if (doSave) { SaveCanvas(cx,fname,locOutDir); } else { std::cout << " ... not saved (as requested)\n"; } } return ; }
void Foam::Init() { //Retrieve the maxima and minima, to use in the coordinate transforms for (unsigned int continuousIndex = 0; continuousIndex < continuousNames.size(); ++continuousIndex ) { double maximum = generationBoundary->GetConstraint( *continuousNames_ref[continuousIndex] )->GetMaximum(); double minimum = generationBoundary->GetConstraint( *continuousNames_ref[continuousIndex] )->GetMinimum(); minima.push_back(minimum); ranges.push_back( maximum - minimum ); } double rand = rootRandom->Rndm(); //Make a Foam generator for each combination for( unsigned int combinationIndex = 0; combinationIndex < discreteCombinations.size(); ++combinationIndex ) { //Make the data point for the combination DataPoint * init_temporaryDataPoint = new DataPoint(allNames); for( unsigned int discreteIndex = 0; discreteIndex < discreteNames.size(); ++discreteIndex ) { IConstraint* thisConst=NULL; try { thisConst=generationBoundary->GetConstraint( *discreteNames_ref[discreteIndex] ); } catch(...) { cout << endl; exit(52); } string unit = thisConst->GetUnit(); init_temporaryDataPoint->SetObservable( discreteNames[discreteIndex], discreteCombinations[combinationIndex][discreteIndex], unit ); } for (unsigned int continuousIndex = 0; continuousIndex < continuousNames.size(); ++continuousIndex ) { IConstraint* thisConst=NULL; try { thisConst=generationBoundary->GetConstraint( *continuousNames_ref[continuousIndex] ); } catch(...) { cout << endl; exit(53); } string unit = thisConst->GetUnit(); init_temporaryDataPoint->SetObservable( continuousNames[continuousIndex], 0.0, unit ); } //init_temporaryDataPoint->Print(); //Make the function wrapper IntegratorFunction* combinationFunction = new IntegratorFunction( InputPDF, init_temporaryDataPoint, continuousNames, discreteNames, minima, ranges, generationBoundary ); //cout << InputPDF->GET_ID() << endl; //if( InputPDF->GetCacheStatus() ) cout << "HAS CACHED FOAM" << endl; //else cout << "HAS NOT CACHED FOAM" << endl; TFile* MC_Cache = NULL; TFoam * foamGenerator = NULL; if( !InputPDF->GetMCCacheStatus() ) { // Generate unique name for this foam instance TString Name("Foam-"); Name.Append(InputPDF->GetLabel()); Name.Append("-"); Name+=combinationIndex; Name.Append("_");Name+=rand; string CleanName=Name.Data(); replace( CleanName.begin(), CleanName.end(), '.', '_' ); Name=CleanName.c_str(); TString FoamName("Foam_");FoamName+=combinationIndex; // Create a root file to store the TFoam universe TString RootName(Name); RootName.Append(".root"); cout << "FOAM NOT Cached, Generating Foam:\t" << Name << endl; MC_Cache = new TFile( RootName, "RECREATE" ); MC_Cache->Write( "", TObject::kOverwrite ); /* if( debug != NULL ) { if( debug->DebugThisClass("Foam") ) { cout << "File Created" << endl; } } */ //Initialise Foam foamGenerator = new TFoam( Name ); foamGenerator->SetkDim( Int_t(continuousNames.size()) ); foamGenerator->SetPseRan( rootRandom ); foamGenerator->SetRho( combinationFunction ); // Can afford to Boot Foam's ability if we're using just one cached instance :D foamGenerator->SetnCells( 1000 ); // 1000 Total number of bins to construct foamGenerator->SetnSampl( 200 ); // 200 Samples to take when constructing bins foamGenerator->SetnBin( 8 ); // 8 Bins along each axis foamGenerator->SetOptRej( 1 ); // 1/0 Don't/Use Weighted Distribution foamGenerator->SetOptDrive( 2 ); // 1/2 Best Varience/Weights foamGenerator->SetEvPerBin( 25 ); // 25 Weights per bin... This doesn't Saturate as object is written before generating events foamGenerator->SetChat( 0 ); // 0 verbosity foamGenerator->SetMaxWtRej( 1.1 ); // 1.1 Unknown what effect this has, something to do with weights /* if( debug != NULL ) { if( debug->DebugThisClass("Foam") ) { cout << "Initializing Foam" << endl; } } */ foamGenerator->Initialize(); // foamGenerator->ResetPseRan( rootRandom ); // foamGenerator->ResetRho( combinationFunction ); // Can afford to Boot Foam's ability if we're using just one cached instance :D // foamGenerator->Initialize(); // As we haven't cached yet, write to file foamGenerator->Write( Name, TObject::kOverwrite ); cout << "Storing TFOAM TObject in:\t\t" << RootName << endl; /* if( debug != NULL ) { if( debug->DebugThisClass("Foam") ) { cout << "Adding Cache" << endl; } } */ InputPDF->AddCacheObject( Name.Data() ); MC_Cache->Write( "", TObject::kOverwrite ); InputPDF->Can_Remove_Cache( true ); //MC_Cache->Close(); } else { TString Name = InputPDF->GetMCCacheNames()[combinationIndex]; TString RootName(Name); RootName.Append(".root"); TString FoamName("Foam_");FoamName+=combinationIndex; rootRandom = RapidFitRandom::GetRandomFunction(); cout << "FOAM Cached, Re-Aquiring TFOAM TObject:\t" << Name << endl; ifstream input_file; input_file.open( RootName.Data(), ifstream::in ); input_file.close(); bool access_fail = input_file.fail(); if( access_fail ) { cout << "\nWe have Failed to re-aquire the TFoam File, Regenerating one for the Fit\n" << endl; InputPDF->Remove_Cache(); // Generate unique name for this foam instance Name="Foam-"; Name.Append(InputPDF->GetLabel()); Name.Append("-"); Name+=combinationIndex; Name.Append("_");Name+=rand; string CleanName=Name.Data(); replace( CleanName.begin(), CleanName.end(), '.', '_' ); Name=CleanName.c_str(); FoamName="Foam_";FoamName+=combinationIndex; // Create a root file to store the TFoam universe RootName=Name; RootName.Append(".root"); cout << "FOAM NOT Cached, Generating Foam:\t" << Name << endl; MC_Cache = new TFile( RootName, "RECREATE" ); MC_Cache->Write( "", TObject::kOverwrite ); //Initialise Foam foamGenerator = new TFoam( Name ); foamGenerator->SetkDim( Int_t(continuousNames.size()) ); foamGenerator->SetPseRan( rootRandom ); foamGenerator->SetRho( combinationFunction ); // Can afford to Boot Foam's ability if we're using just one cached instance :D foamGenerator->SetnCells( 1000 ); // 1000 Total number of bins to construct foamGenerator->SetnSampl( 200 ); // 200 Samples to take when constructing bins foamGenerator->SetnBin( 8 ); // 8 Bins along each axis foamGenerator->SetOptRej( 1 ); // 1/0 Don't/Use Weighted Distribution foamGenerator->SetOptDrive( 2 ); // 1/2 Best Varience/Weights foamGenerator->SetEvPerBin( 25 ); // 25 Weights per bin... This doesn't Saturate as object is written before generating events foamGenerator->SetChat( 0 ); // 0 verbosity foamGenerator->SetMaxWtRej( 1.1 ); // 1.1 Unknown what effect this has, something to do with weights foamGenerator->Initialize(); // foamGenerator->ResetPseRan( rootRandom ); // foamGenerator->ResetRho( combinationFunction ); // Can afford to Boot Foam's ability if we're using just one cached instance :D // foamGenerator->Initialize(); // As we haven't cached yet, write to file //MC_Cache->Write( "", TObject::kOverwrite ); foamGenerator->Write( Name, TObject::kOverwrite ); cout << "Storing TFOAM TObject in:\t\t" << RootName << endl; InputPDF->AddCacheObject( Name.Data() ); MC_Cache->Write( "", TObject::kOverwrite ); InputPDF->Can_Remove_Cache( true ); } else { MC_Cache = new TFile( RootName, "READ" ); //gDirectory->ls(); //Cached_Files.back()->Map(); //Cached_Files.back()->ShowStreamerInfo(); //Cached_Files.back()->GetListOfKeys()->Print(); foamGenerator = (TFoam*) MC_Cache->Get( Name ); // This code has been production testeted enough such that I think this is pointlessly scaring users //cout << "Checking Consistancy, will crash if this fails... this is unavoidable" << endl; //cout << MC_Cache << endl; //cout << foamGenerator << endl; if( MC_Cache == NULL || foamGenerator == NULL ) { cerr << "Error re-aquiring TFOAM object. This is unrecoverable" << endl; cout << "Error re-aquiring TFOAM object. This is unrecoverable" << endl; exit(-6542); } foamGenerator->ResetPseRan( rootRandom ); foamGenerator->ResetRho( combinationFunction ); foamGenerator->SetnCells( 1000 ); // 1000 Total number of bins to construct foamGenerator->SetnSampl( 200 ); // 200 Samples to take when constructing bins foamGenerator->SetnBin( 8 ); // 8 Bins along each axis foamGenerator->SetOptRej( 1 ); // 1/0 Don't/Use Weighted Distribution foamGenerator->SetOptDrive( 2 ); // 1/2 Best Varience/Weights foamGenerator->SetEvPerBin( 25 ); // 25 Weights per bin... This doesn't Saturate as object is written before generating events foamGenerator->SetChat( 0 ); // 0 verbosity foamGenerator->SetMaxWtRej( 1.1 ); // 1.1 Unknown what effect this has, something to do with weights foamGenerator->CheckAll(0); // Make one event here to check everything was processed correctly foamGenerator->MakeEvent(); cout << "Check OK" << endl; } } Open_Files.push_back( MC_Cache ); //Debug //char filename[100]; //sprintf( filename, "DebugFoamPlot.%d.c", combinationIndex ); //foamGenerator->RootPlot2dim(filename); //foamGenerator->PrintCells(); //Store the foam generator foamGenerators.push_back( foamGenerator ); storedIntegrator.push_back( combinationFunction ); delete init_temporaryDataPoint; } InputPDF->SetMCCacheStatus( true ); }
void TBDataParser::OnStartElement(const char *element, const TList *attributes) { TXMLAttr *attr; TIter next(attributes); char *name = element; _currentElement = new TString(element); char *method = NULL; while ((attr = (TXMLAttr*) next())) { char *attrName = attr->GetName(); char *attrValue = attr->GetValue(); if(!strcmp(attrName, "name")) { name = attrValue; } if(!strcmp(attrName, "method")) { method = attrValue; _currentMethod = new TString(method); } } TFolder *currentFolder = _foldersStack->Last(); if(!strcmp(element, "vector")) { TString *nameString = new TString(name); vector<float> *values = new vector<float>; _values = values; nameString->ReplaceAll(" ","_"); TObjString *currentVector = new TObjString(nameString->Data()); TObjArray *vectorsStack = _vectorsStack; vectorsStack->AddLast(currentVector); TString *joinedName = new TString(((TObjString *) vectorsStack->First())->GetString().Data()); for(Int_t i = 1; i < vectorsStack->GetEntries(); i++) { joinedName->Append("_"); joinedName->Append(((TObjString *) vectorsStack->At(i))->GetString().Data()); } TObjString *joinedNameObj = new TObjString(joinedName->Data()); TObjArray *joinedNameStack = _joinedNameStack; TNtuple *vector = new TNtuple(joinedName->Data(),joinedName->Data(),"values"); _vector = vector; currentFolder->Add(vector); if(joinedNameStack->Contains(joinedName->Data())) cout << joinedName->Data() << "Error: " << "vector already exists. Be sure that in your XML file every vector has a unique path + name combination" << endl; joinedNameStack->Add(joinedNameObj); return; } _foldersStack->AddLast(currentFolder->AddFolder(name, name)); }
void Config() { // Get settings from environment variables ProcessEnvironmentVars(); gRandom->SetSeed(seed); cerr<<"Seed for random number generation= "<<seed<<endl; // Libraries required by geant321 #if defined(__CINT__) gSystem->Load("liblhapdf"); // Parton density functions gSystem->Load("libEGPythia6"); // TGenerator interface gSystem->Load("libpythia6"); // Pythia gSystem->Load("libIlcPythia6"); // ILC specific implementations gSystem->Load("libgeant321"); gSystem->Load("libTTherminator"); #endif new TGeant3TGeo("C++ Interface to Geant3"); //======================================================================= // Create the output file IlcRunLoader* rl=0x0; cout<<"Config.C: Creating Run Loader ..."<<endl; rl = IlcRunLoader::Open("gilc.root", IlcConfig::GetDefaultEventFolderName(), "recreate"); if (rl == 0x0) { gIlc->Fatal("Config.C","Can not instatiate the Run Loader"); return; } rl->SetCompressionLevel(2); rl->SetNumberOfEventsPerFile(3); gIlc->SetRunLoader(rl); // Set the trigger configuration if ((embedrun == kBackground) || (embedrun == kMerged)) { IlcSimulation::Instance()->SetTriggerConfig("Pb-Pb"); cout<<"Trigger configuration is set to Pb-Pb"<<endl; } else { // Set the trigger configuration: proton-proton IlcSimulation::Instance()->SetTriggerConfig("p-p"); } // // Set External decayer TVirtualMCDecayer *decayer = new IlcDecayerPythia(); decayer->SetForceDecay(kAll); decayer->Init(); gMC->SetExternalDecayer(decayer); //======================================================================= // ************* STEERING parameters FOR ILC SIMULATION ************** // --- Specify event type to be tracked through the ILC setup // --- All positions are in cm, angles in degrees, and P and E in GeV gMC->SetProcess("DCAY",1); gMC->SetProcess("PAIR",1); gMC->SetProcess("COMP",1); gMC->SetProcess("PHOT",1); gMC->SetProcess("PFIS",0); gMC->SetProcess("DRAY",0); gMC->SetProcess("ANNI",1); gMC->SetProcess("BREM",1); gMC->SetProcess("MUNU",1); gMC->SetProcess("CKOV",1); gMC->SetProcess("HADR",1); gMC->SetProcess("LOSS",2); gMC->SetProcess("MULS",1); gMC->SetProcess("RAYL",1); Float_t cut = 1.e-3; // 1MeV cut by default Float_t tofmax = 1.e10; gMC->SetCut("CUTGAM", cut); gMC->SetCut("CUTELE", cut); gMC->SetCut("CUTNEU", cut); gMC->SetCut("CUTHAD", cut); gMC->SetCut("CUTMUO", cut); gMC->SetCut("BCUTE", cut); gMC->SetCut("BCUTM", cut); gMC->SetCut("DCUTE", cut); gMC->SetCut("DCUTM", cut); gMC->SetCut("PPCUTM", cut); gMC->SetCut("TOFMAX", tofmax); //======================// // Set External decayer // //======================// TVirtualMCDecayer* decayer = new IlcDecayerPythia(); decayer->SetForceDecay(kAll); decayer->Init(); gMC->SetExternalDecayer(decayer); if ((embedrun == kMerged) || (embedrun == kSignal)) { //=========================// // Generator Configuration // //=========================// IlcGenerator* gener = 0x0; if (proc == kPythia6) { gener = MbPythia(); } else if (proc == kPhojet) { gener = MbPhojet(); } } else { IlcGenCocktail *gener = new IlcGenCocktail(); gener->SetPhiRange(0, 360); // Set pseudorapidity range from -8 to 8. Float_t thmin = EtaToTheta(1); // theta min. <---> eta max Float_t thmax = EtaToTheta(-1); // theta max. <---> eta min gener->SetThetaRange(thmin,thmax); gener->SetProjectile("A",208,82); gener->SetTarget("A",208,82); IlcGenTherminator *genther = new IlcGenTherminator(); genther->SetFileName("event.out"); genther->SetEventNumberInFile(1); genther->SetTemperature(0.145); genther->SetMiuI(-0.0009); genther->SetMiuS(0.000); genther->SetMiuB(0.0008); genther->SetAlfaRange(8.0); genther->SetRapRange(4.0); genther->SetRhoMax(7.74); genther->SetTau(9.74); genther->SetModel("Lhyquid3D"); genther->SetLhyquidSet("LHC500C2030"); gener->AddGenerator(genther, "THERMINATOR LHYQUID3D", 1); } // PRIMARY VERTEX // gener->SetOrigin(0., 0., 0.); // vertex position // // // Size of the interaction diamond // Longitudinal Float_t sigmaz; if (embedrun == kBackground) { sigmaz = 7.55 / TMath::Sqrt(2.); // [cm] } else { Float_t sigmaz = 5.4 / TMath::Sqrt(2.); // [cm] if (energy == 900) sigmaz = 10.5 / TMath::Sqrt(2.); // [cm] } // // Transverse Float_t betast = 10; // beta* [m] Float_t eps = 3.75e-6; // emittance [m] Float_t gamma = energy / 2.0 / 0.938272; // relativistic gamma [1] Float_t sigmaxy = TMath::Sqrt(eps * betast / gamma) / TMath::Sqrt(2.) * 100.; // [cm] printf("\n \n Diamond size x-y: %10.3e z: %10.3e\n \n", sigmaxy, sigmaz); gener->SetSigma(sigmaxy, sigmaxy, sigmaz); // Sigma in (X,Y,Z) (cm) on IP position gener->SetCutVertexZ(3.); // Truncate at 3 sigma gener->SetVertexSmear(kPerEvent); gener->Init(); // FIELD // // Field // IlcMagF* field = 0x0; if (mag == kNoField) { comment = comment.Append(" | L3 field 0.0 T"); TGeoGlobalMagField::Instance()->SetField(new IlcMagF("Maps","Maps", 0., 0., IlcMagF::k5kGUniform)); } else if (mag == k5kG) { comment = comment.Append(" | L3 field 0.5 T"); TGeoGlobalMagField::Instance()->SetField(new IlcMagF("Maps","Maps", -1., -1., IlcMagF::k5kG)); } printf("\n \n Comment: %s \n \n", comment.Data()); // TGeoGlobalMagField::Instance()->SetField(field); rl->CdGAFile(); Int_t iABSO = 1; Int_t iACORDE= 0; Int_t iDIPO = 1; Int_t iEMCAL = 1; Int_t iFMD = 1; Int_t iFRAME = 1; Int_t iHALL = 1; Int_t iITS = 1; Int_t iMAG = 1; Int_t iMUON = 1; Int_t iPHOS = 1; Int_t iPIPE = 1; Int_t iPMD = 1; Int_t iHMPID = 1; Int_t iSHIL = 1; Int_t iT0 = 1; Int_t iTOF = 1; Int_t iTPC = 1; Int_t iTRD = 1; Int_t iVZERO = 1; Int_t iZDC = 1; //=================== Ilc BODY parameters ============================= IlcBODY *BODY = new IlcBODY("BODY", "Ilc envelop"); if (iMAG) { //=================== MAG parameters ============================ // --- Start with Magnet since detector layouts may be depending --- // --- on the selected Magnet dimensions --- IlcMAG *MAG = new IlcMAG("MAG", "Magnet"); } if (iABSO) { //=================== ABSO parameters ============================ IlcABSO *ABSO = new IlcABSOv3("ABSO", "Muon Absorber"); } if (iDIPO) { //=================== DIPO parameters ============================ IlcDIPO *DIPO = new IlcDIPOv3("DIPO", "Dipole version 3"); } if (iHALL) { //=================== HALL parameters ============================ IlcHALL *HALL = new IlcHALLv3("HALL", "Ilc Hall"); } if (iFRAME) { //=================== FRAME parameters ============================ IlcFRAMEv2 *FRAME = new IlcFRAMEv2("FRAME", "Space Frame"); FRAME->SetHoles(1); } if (iSHIL) { //=================== SHIL parameters ============================ IlcSHIL *SHIL = new IlcSHILv3("SHIL", "Shielding Version 3"); } if (iPIPE) { //=================== PIPE parameters ============================ IlcPIPE *PIPE = new IlcPIPEv3("PIPE", "Beam Pipe"); } if (iITS) { //=================== ITS parameters ============================ IlcITS *ITS = new IlcITSv11("ITS","ITS v11"); } if (iTPC) { //============================ TPC parameters ===================== IlcTPC *TPC = new IlcTPCv2("TPC", "Default"); } if (iTOF) { //=================== TOF parameters ============================ IlcTOF *TOF = new IlcTOFv6T0("TOF", "normal TOF"); } if (iHMPID) { //=================== HMPID parameters =========================== IlcHMPID *HMPID = new IlcHMPIDv3("HMPID", "normal HMPID"); } if (iZDC) { //=================== ZDC parameters ============================ IlcZDC *ZDC = new IlcZDCv4("ZDC", "normal ZDC"); } if (iTRD) { //=================== TRD parameters ============================ IlcTRD *TRD = new IlcTRDv1("TRD", "TRD slow simulator"); } if (iFMD) { //=================== FMD parameters ============================ IlcFMD *FMD = new IlcFMDv1("FMD", "normal FMD"); } if (iMUON) { //=================== MUON parameters =========================== // New MUONv1 version (geometry defined via builders) IlcMUON *MUON = new IlcMUONv1("MUON", "default"); } if (iPHOS) { //=================== PHOS parameters =========================== IlcPHOS *PHOS = new IlcPHOSv1("PHOS", "IHEP"); } if (iPMD) { //=================== PMD parameters ============================ IlcPMD *PMD = new IlcPMDv1("PMD", "normal PMD"); } if (iT0) { //=================== T0 parameters ============================ IlcT0 *T0 = new IlcT0v1("T0", "T0 Detector"); } if (iEMCAL) { //=================== EMCAL parameters ============================ IlcEMCAL *EMCAL = new IlcEMCALv2("EMCAL", "EMCAL_COMPLETEV1"); } if (iACORDE) { //=================== ACORDE parameters ============================ IlcACORDE *ACORDE = new IlcACORDEv1("ACORDE", "normal ACORDE"); } if (iVZERO) { //=================== ACORDE parameters ============================ IlcVZERO *VZERO = new IlcVZEROv7("VZERO", "normal VZERO"); } }
void Config() { // Get settings from environment variables ProcessEnvironmentVars(); // Random Number seed if (gSystem->Getenv("CONFIG_SEED")) { seed = atoi(gSystem->Getenv("CONFIG_SEED")); } else if(gSystem->Getenv("DC_EVENT") && gSystem->Getenv("DC_RUN")){ seed = runNumber * 100000 + eventNumber; } gRandom->SetSeed(seed); cout<<"Seed for random number generation= "<<gRandom->GetSeed()<<endl; // libraries required by geant321 #if defined(__CINT__) gSystem->Load("liblhapdf"); // Parton density functions gSystem->Load("libEGPythia6"); // TGenerator interface gSystem->Load("libpythia6"); // Pythia gSystem->Load("libAliPythia6"); // ALICE specific implementations gSystem->Load("libgeant321"); #endif new TGeant3TGeo("C++ Interface to Geant3"); // Output every 100 tracks ((TGeant3*)gMC)->SetSWIT(4,100); //======================================================================= // Run loader AliRunLoader* rl=0x0; AliLog::Message(AliLog::kInfo, "Creating Run Loader", "", "", "Config()"," ConfigPPR.C", __LINE__); rl = AliRunLoader::Open("galice.root", AliConfig::GetDefaultEventFolderName(), "recreate"); if (rl == 0x0) { gAlice->Fatal("Config.C","Can not instatiate the Run Loader"); return; } rl->SetCompressionLevel(2); rl->SetNumberOfEventsPerFile(100); gAlice->SetRunLoader(rl); // Set the trigger configuration AliSimulation::Instance()->SetTriggerConfig(TrigConfName[trig]); cout<<"Trigger configuration is set to "<<TrigConfName[trig]<<endl; //======================// // Set External decayer // //======================// TVirtualMCDecayer* decayer = new AliDecayerPythia(); // DECAYS // switch(decHvFl) { case kNature: decayer->SetForceDecay(kAll); break; case kHadr: decayer->SetForceDecay(kHadronicD); break; case kSemiEl: decayer->SetForceDecay(kSemiElectronic); break; case kSemiMu: decayer->SetForceDecay(kSemiMuonic); break; } decayer->Init(); gMC->SetExternalDecayer(decayer); if(proc == kPyJetJetPHOSv2) // in this case we decay the pi0 decayer->SetForceDecay(kNeutralPion); // //======================================================================= // ************* STEERING parameters FOR ALICE SIMULATION ************** // --- Specify event type to be tracked through the ALICE setup // --- All positions are in cm, angles in degrees, and P and E in GeV gMC->SetProcess("DCAY",1); gMC->SetProcess("PAIR",1); gMC->SetProcess("COMP",1); gMC->SetProcess("PHOT",1); gMC->SetProcess("PFIS",0); gMC->SetProcess("DRAY",0); gMC->SetProcess("ANNI",1); gMC->SetProcess("BREM",1); gMC->SetProcess("MUNU",1); gMC->SetProcess("CKOV",1); gMC->SetProcess("HADR",1); gMC->SetProcess("LOSS",2); gMC->SetProcess("MULS",1); gMC->SetProcess("RAYL",1); Float_t cut = 1.e-3; // 1MeV cut by default Float_t tofmax = 1.e10; gMC->SetCut("CUTGAM", cut); gMC->SetCut("CUTELE", cut); gMC->SetCut("CUTNEU", cut); gMC->SetCut("CUTHAD", cut); gMC->SetCut("CUTMUO", cut); gMC->SetCut("BCUTE", cut); gMC->SetCut("BCUTM", cut); gMC->SetCut("DCUTE", cut); gMC->SetCut("DCUTM", cut); gMC->SetCut("PPCUTM", cut); gMC->SetCut("TOFMAX", tofmax); //=========================// // Generator Configuration // //=========================// AliGenPythia* gener = 0x0; if (proc <= kBeautypp14000wmi) { AliGenPythia *pythia = PythiaHVQ(proc); // FeedDown option pythia->SetFeedDownHigherFamily(kFALSE); // Stack filling option if(!stars) pythia->SetStackFillOpt(AliGenPythia::kParentSelection); // Set Count mode if(nEvts>0) pythia->SetCountMode(AliGenPythia::kCountParents); // // DECAYS // switch(decHvFl) { case kNature: pythia->SetForceDecay(kAll); break; case kHadr: pythia->SetForceDecay(kHadronicD); break; case kSemiEl: pythia->SetForceDecay(kSemiElectronic); break; case kSemiMu: pythia->SetForceDecay(kSemiMuonic); break; } // // GEOM & KINE CUTS // pythia->SetMomentumRange(0,99999999); pythia->SetPhiRange(0., 360.); pythia->SetThetaRange(0,180); switch(ycut) { case kFull: pythia->SetYRange(-999,999); break; case kBarrel: pythia->SetYRange(-2,2); break; case kMuonArm: pythia->SetYRange(1,6); break; } gener = pythia; } else if (proc == kPyMbNoHvq) { gener = MbCocktail(); } else if (proc == kPyOmegaMinus) { gener = PyMbTriggered(3334); } else if (proc == kPyOmegaPlus) { gener = PyMbTriggered(-3334); } else if (proc <= kPyGammaBremsEMCAL) { AliGenPythia *pythia = PythiaHard(proc); // FeedDown option pythia->SetFeedDownHigherFamily(kFALSE); // Set Count mode if(nEvts>0) pythia->SetCountMode(AliGenPythia::kCountParents); // // GEOM & KINE CUTS // pythia->SetMomentumRange(0,99999999); // pythia->SetJetEtaRange(-1.5, 1.5);// Final state kinematic cuts // pythia->SetJetPhiRange(0., 360.); // pythia->SetThetaRange(45,135); if(proc == kPyJetJetPHOSv2) pythia->SetForceDecay(kNeutralPion); else pythia->SetForceDecay(kAll); pythia->SetPycellParameters(2., 274, 432, 0., 4., 5., 1.0); pythia->SetPtKick(5); // set the intrinsic kt to 5 GeV/c gener = pythia; } // PRIMARY VERTEX gener->SetOrigin(0., 0., 0.); // vertex position // Size of the interaction diamond // Longitudinal Float_t sigmaz = 7.55 / TMath::Sqrt(2.); // [cm] // Transverse Float_t betast = 10; // beta* [m] Float_t eps = 3.75e-6; // emittance [m] Float_t gamma = 7000. / 0.938272; // relativistic gamma [1] Float_t sigmaxy = TMath::Sqrt(eps * betast / gamma) / TMath::Sqrt(2.) * 100.; // [cm] printf("\n \n Diamond size x-y: %10.3e z: %10.3e\n \n", sigmaxy, sigmaz); gener->SetSigma(sigmaxy, sigmaxy, sigmaz); // Sigma in (X,Y,Z) (cm) on IP position gener->SetCutVertexZ(3.); // Truncate at 3 sigma gener->SetVertexSmear(kPerEvent); gener->Init(); //Quenching gener->SetQuench(iquenching); if(iquenching == 1){ Float_t k = 6e5*(qhat/1.7) ; //qhat=1.7, k = 6e5, default value AliPythia::Instance()->InitQuenching(0.,0.1,k,0,0.95,6); } // FIELD if (mag == AliMagF::k2kG) { comment = comment.Append(" | L3 field 0.2 T"); } else if (mag == AliMagF::k5kG) { comment = comment.Append(" | L3 field 0.5 T"); } printf("\n \n Comment: %s \n \n", comment.Data()); // to use constant field in the barrel use: // AliMagF* field = new AliMagF("Maps","Maps", -1., -1., AliMagF::k5kGUniform); AliMagF* field = new AliMagF("Maps","Maps", -1., -1., mag); TGeoGlobalMagField::Instance()->SetField(field); rl->CdGAFile(); Int_t iABSO = 1; Int_t iACORDE= 1; Int_t iDIPO = 1; Int_t iEMCAL = 1; Int_t iFMD = 1; Int_t iFRAME = 1; Int_t iHALL = 1; Int_t iITS = 1; Int_t iMAG = 1; Int_t iMUON = 1; Int_t iPHOS = 1; Int_t iPIPE = 1; Int_t iPMD = 1; Int_t iHMPID = 1; Int_t iSHIL = 1; Int_t iT0 = 1; Int_t iTOF = 1; Int_t iTPC = 1; Int_t iTRD = 1; Int_t iVZERO = 1; Int_t iZDC = 1; //=================== Alice BODY parameters ============================= AliBODY *BODY = new AliBODY("BODY", "Alice envelop"); if (iMAG) { //=================== MAG parameters ============================ // --- Start with Magnet since detector layouts may be depending --- // --- on the selected Magnet dimensions --- AliMAG *MAG = new AliMAG("MAG", "Magnet"); } // // if (iABSO) { //=================== ABSO parameters ============================ AliABSO *ABSO = new AliABSOv3("ABSO", "Muon Absorber"); } if (iDIPO) { //=================== DIPO parameters ============================ AliDIPO *DIPO = new AliDIPOv3("DIPO", "Dipole version 3"); } if (iHALL) { //=================== HALL parameters ============================ AliHALL *HALL = new AliHALLv3("HALL", "Alice Hall"); } if (iFRAME) { //=================== FRAME parameters ============================ AliFRAMEv2 *FRAME = new AliFRAMEv2("FRAME", "Space Frame"); if (geo == kHoles) FRAME->SetHoles(1); else FRAME->SetHoles(0); } if (iSHIL) { //=================== SHIL parameters ============================ AliSHIL *SHIL = new AliSHILv3("SHIL", "Shielding Version 3"); } if (iPIPE) { //=================== PIPE parameters ============================ AliPIPE *PIPE = new AliPIPEv3("PIPE", "Beam Pipe"); } if(iITS) { //=================== ITS parameters ============================ // AliITS *ITS = new AliITSv11("ITS","ITS v11"); } if (iTPC) { //============================ TPC parameters ===================== AliTPC *TPC = new AliTPCv2("TPC", "Default"); } if (iTOF) { //=================== TOF parameters ============================ AliTOF *TOF = new AliTOFv6T0("TOF", "normal TOF"); } if (iHMPID) { //=================== HMPID parameters =========================== AliHMPID *HMPID = new AliHMPIDv3("HMPID", "normal HMPID"); } if (iZDC) { //=================== ZDC parameters ============================ AliZDC *ZDC = new AliZDCv4("ZDC", "normal ZDC"); } if (iTRD) { //=================== TRD parameters ============================ AliTRD *TRD = new AliTRDv1("TRD", "TRD slow simulator"); AliTRDgeometry *geoTRD = TRD->GetGeometry(); } if (iFMD) { //=================== FMD parameters ============================ AliFMD *FMD = new AliFMDv1("FMD", "normal FMD"); } if (iMUON) { //=================== MUON parameters =========================== // New MUONv1 version (geometry defined via builders) AliMUON *MUON = new AliMUONv1("MUON", "default"); } //=================== PHOS parameters =========================== if (iPHOS) { AliPHOS *PHOS = new AliPHOSv1("PHOS", "Run1"); } if (iPMD) { //=================== PMD parameters ============================ AliPMD *PMD = new AliPMDv1("PMD", "normal PMD"); } if (iT0) { //=================== T0 parameters ============================ AliT0 *T0 = new AliT0v1("T0", "T0 Detector"); } if (iEMCAL) { //=================== EMCAL parameters ============================ AliEMCAL *EMCAL = new AliEMCALv2("EMCAL", "EMCAL_COMPLETEV1 scTh=0.176 pbTh=0.144"); } if (iACORDE) { //=================== CRT parameters ============================ AliACORDE *ACORDE = new AliACORDEv1("ACORDE", "normal ACORDE"); } if (iVZERO) { //=================== CRT parameters ============================ AliVZERO *VZERO = new AliVZEROv7("VZERO", "normal VZERO"); } }
void Config() { cout << "==> Config.C..." << endl; // Set Random Number seed UInt_t at = (UInt_t) gSystem->Now() ; UInt_t seed = ((gSystem->GetPid()*111)%at)*137 ; // gRandom->SetSeed(seed); gRandom->SetSeed(12345); printf("MySeed: %d\n",seed) ; cout<<"Seed for random number generation= "<<gRandom->GetSeed()<<endl; // libraries required by fluka21 Bool_t isFluka = kFALSE; if (isFluka) { gSystem->Load("libGeom"); cout << "\t* Loading TFluka..." << endl; gSystem->Load("libTFluka"); cout << "\t* Instantiating TFluka..." << endl; new TFluka("C++ Interface to Fluka", 0/*verbositylevel*/); } else { cout << "\t* Loading Geant3..." << endl; gSystem->Load("libgeant321"); cout << "\t* Instantiating Geant3TGeo..." << endl; new TGeant3TGeo("C++ Interface to Geant3"); } IlcRunLoader* rl=0x0; cout<<"Config.C: Creating Run Loader ..."<<endl; rl = IlcRunLoader::Open("gilc.root", IlcConfig::GetDefaultEventFolderName(), "recreate"); if (rl == 0x0) { gIlc->Fatal("Config.C","Can not instatiate the Run Loader"); return; } rl->SetCompressionLevel(2); rl->SetNumberOfEventsPerFile(1000); gIlc->SetRunLoader(rl); // // Set External decayer IlcDecayer *decayer = new IlcDecayerPythia(); decayer->SetForceDecay(kAll); decayer->Init(); gMC->SetExternalDecayer(decayer); // // // // Physics process control gMC->SetProcess("DCAY",1); gMC->SetProcess("PAIR",1); gMC->SetProcess("COMP",1); gMC->SetProcess("PHOT",1); gMC->SetProcess("PFIS",0); gMC->SetProcess("DRAY",0); //AZ 1); gMC->SetProcess("ANNI",1); gMC->SetProcess("BREM",1); gMC->SetProcess("MUNU",1); gMC->SetProcess("CKOV",1); gMC->SetProcess("HADR",1); gMC->SetProcess("LOSS",2); gMC->SetProcess("MULS",1); gMC->SetProcess("RAYL",1); Float_t cut = 1.e-3; // 1MeV cut by default Float_t tofmax = 1.e10; gMC->SetCut("CUTGAM", cut); gMC->SetCut("CUTELE", cut); gMC->SetCut("CUTNEU", cut); gMC->SetCut("CUTHAD", cut); gMC->SetCut("CUTMUO", cut); gMC->SetCut("BCUTE", cut); gMC->SetCut("BCUTM", cut); gMC->SetCut("DCUTE", cut); gMC->SetCut("DCUTM", cut); gMC->SetCut("PPCUTM", cut); gMC->SetCut("TOFMAX", tofmax); ((IlcMC*)gMC)->SetTransPar("./gilc.cuts") ; // //======================================================================= // ************* STEERING parameters FOR ILC SIMULATION ************** // --- Specify event type to be tracked through the ILC setup // --- All positions are in cm, angles in degrees, and P and E in GeV IlcGenBox *gener = new IlcGenBox(5); gener->SetMomentumRange(0.5, 5.); gener->SetPhiRange(260., 280.); gener->SetThetaRange(82.,98.); gener->SetPart(kGamma); gener->SetOrigin(0, 0, 0); //vertex position gener->SetSigma(0, 0, 0); //Sigma in (X,Y,Z) (cm) on IP position gener->Init() ; // // Activate this line if you want the vertex smearing to happen // track by track // // gener->SetVertexSmear(kPerEvent) ; if (smag == IlcMagF::k2kG) { comment = comment.Append(" | L3 field 0.2 T"); } else if (smag == IlcMagF::k5kG) { comment = comment.Append(" | L3 field 0.5 T"); } if (srad == kGluonRadiation) { comment = comment.Append(" | Gluon Radiation On"); } else { comment = comment.Append(" | Gluon Radiation Off"); } if (sgeo == kHoles) { comment = comment.Append(" | Holes for PVBAR/RICH"); } else { comment = comment.Append(" | No holes for PVBAR/RICH"); } printf("\n \n Comment: %s \n \n", comment.Data()); // Field (L3 0.4 T) //Zero magnetic field IlcMagF* field = new IlcMagF("Maps","Maps", 0., 0., IlcMagF::k5kGUniform); // IlcMagF* field = new IlcMagF("Maps","Maps", 2, -1., -1., 10., smag); TGeoGlobalMagField::Instance()->SetField(field); rl->CdGAFile(); Int_t iABSO = 0; Int_t iCRT = 0; Int_t iDIPO = 0; Int_t iFMD = 0; Int_t iFRAME = 0; Int_t iHALL = 0; Int_t iITS = 0; Int_t iMAG = 0; Int_t iMUON = 0; Int_t iPVBAR = 1; Int_t iPIPE = 0; Int_t iPMD = 0; Int_t iRICH = 0; Int_t iSHIL = 0; Int_t iSTART = 0; Int_t iTOF = 0; Int_t iTPC = 0; Int_t iTRD = 0; Int_t iZDC = 0; Int_t iEMCAL = 0; Int_t iVZERO = 0; cout << "\t* Creating the detectors ..." << endl; //=================== Ilc BODY parameters ============================= //=================== Ilc BODY parameters ============================= IlcBODY *BODY = new IlcBODY("BODY", "Ilc envelop"); if (iMAG) { //=================== MAG parameters ============================ // --- Start with Magnet since detector layouts may be depending --- // --- on the selected Magnet dimensions --- IlcMAG *MAG = new IlcMAG("MAG", "Magnet"); } if (iABSO) { //=================== ABSO parameters ============================ IlcABSO *ABSO = new IlcABSOv0("ABSO", "Muon Absorber"); } if (iDIPO) { //=================== DIPO parameters ============================ IlcDIPO *DIPO = new IlcDIPOv2("DIPO", "Dipole version 2"); } if (iHALL) { //=================== HALL parameters ============================ IlcHALL *HALL = new IlcHALL("HALL", "Ilc Hall"); } if (iFRAME) { //=================== FRAME parameters ============================ IlcFRAMEv2 *FRAME = new IlcFRAMEv2("FRAME", "Space Frame"); if (sgeo == kHoles) { FRAME->SetHoles(1); } else { FRAME->SetHoles(0); } } if (iSHIL) { //=================== SHIL parameters ============================ IlcSHIL *SHIL = new IlcSHILv2("SHIL", "Shielding Version 2"); } if (iPIPE) { //=================== PIPE parameters ============================ IlcPIPE *PIPE = new IlcPIPEv0("PIPE", "Beam Pipe"); } if(iITS) { //=================== ITS parameters ============================ // // As the innermost detector in ILC, the Inner Tracking System "impacts" on // almost all other detectors. This involves the fact that the ITS geometry // still has several options to be followed in parallel in order to determine // the best set-up which minimizes the induced background. All the geometries // available to date are described in the following. Read carefully the comments // and use the default version (the only one uncommented) unless you are making // comparisons and you know what you are doing. In this case just uncomment the // ITS geometry you want to use and run Ilcroot. // // Detailed geometries: // // //IlcITS *ITS = new IlcITSv5symm("ITS","Updated ITS TDR detailed version with symmetric services"); // //IlcITS *ITS = new IlcITSv5asymm("ITS","Updates ITS TDR detailed version with asymmetric services"); // IlcITSvPPRasymmFMD *ITS = new IlcITSvPPRasymmFMD("ITS","New ITS PPR detailed version with asymmetric services"); ITS->SetMinorVersion(2); // don't touch this parameter if you're not an ITS developer ITS->SetReadDet(kTRUE); // don't touch this parameter if you're not an ITS developer // ITS->SetWriteDet("$ILC_ROOT/ITS/ITSgeometry_vPPRasymm2.det"); // don't touch this parameter if you're not an ITS developer ITS->SetThicknessDet1(200.); // detector thickness on layer 1 must be in the range [100,300] ITS->SetThicknessDet2(200.); // detector thickness on layer 2 must be in the range [100,300] ITS->SetThicknessChip1(200.); // chip thickness on layer 1 must be in the range [150,300] ITS->SetThicknessChip2(200.); // chip thickness on layer 2 must be in the range [150,300] ITS->SetRails(0); // 1 --> rails in ; 0 --> rails out ITS->SetCoolingFluid(1); // 1 --> water ; 0 --> freon // Coarse geometries (warning: no hits are produced with these coarse geometries and they unuseful // for reconstruction !): // // //IlcITSvPPRcoarseasymm *ITS = new IlcITSvPPRcoarseasymm("ITS","New ITS PPR coarse version with asymmetric services"); //ITS->SetRails(0); // 1 --> rails in ; 0 --> rails out //ITS->SetSupportMaterial(0); // 0 --> Copper ; 1 --> Aluminum ; 2 --> Carbon // //IlcITS *ITS = new IlcITSvPPRcoarsesymm("ITS","New ITS PPR coarse version with symmetric services"); //ITS->SetRails(0); // 1 --> rails in ; 0 --> rails out //ITS->SetSupportMaterial(0); // 0 --> Copper ; 1 --> Aluminum ; 2 --> Carbon // // // // Geant3 <-> EUCLID conversion // ============================ // // SetEUCLID is a flag to output (=1) or not to output (=0) both geometry and // media to two ASCII files (called by default ITSgeometry.euc and // ITSgeometry.tme) in a format understandable to the CAD system EUCLID. // The default (=0) means that you dont want to use this facility. // ITS->SetEUCLID(0); } if (iTPC) { //============================ TPC parameters ================================ // IlcTPC *TPC = new IlcTPCv0("TPC", "Default"); IlcTPC *TPC = new IlcTPCv2("TPC", "Default"); } if (iTOF) { //=================== TOF parameters ============================ IlcTOF *TOF = new IlcTOFv4T0("TOF", "normal TOF"); } if (iRICH) { //=================== RICH parameters =========================== IlcRICH *RICH = new IlcRICHv1("RICH", "normal RICH"); } if (iZDC) { //=================== ZDC parameters ============================ IlcZDC *ZDC = new IlcZDCv2("ZDC", "normal ZDC"); } if (iTRD) { //=================== TRD parameters ============================ IlcTRD *TRD = new IlcTRDv1("TRD", "TRD slow simulator"); // Select the gas mixture (0: 97% Xe + 3% isobutane, 1: 90% Xe + 10% CO2) TRD->SetGasMix(1); if (sgeo == kHoles) { // With hole in front of PVBAR TRD->SetPVBARhole(); // With hole in front of RICH TRD->SetRICHhole(); } // Switch on TR IlcTRDsim *TRDsim = TRD->CreateTR(); } if (iFMD) { //=================== FMD parameters ============================ IlcFMD *FMD = new IlcFMDv1("FMD", "normal FMD"); } if (iMUON) { //=================== MUON parameters =========================== IlcMUON *MUON = new IlcMUONv1("MUON", "default"); } //=================== PVBAR parameters =========================== if (iPVBAR) { IlcPVBAR *PVBAR = new IlcPVBARv1("PVBAR", "ORKA"); // IlcPVBAR *PVBAR = new IlcPVBARv1("PVBAR", "noCPV"); } if (iPMD) { //=================== PMD parameters ============================ IlcPMD *PMD = new IlcPMDv1("PMD", "normal PMD"); } if (iSTART) { //=================== START parameters ============================ IlcSTART *START = new IlcSTARTv1("START", "START Detector"); } if (iEMCAL) { //=================== EMCAL parameters ============================ IlcEMCAL *EMCAL = new IlcEMCALv2("EMCAL", "EMCAL_COMPLETEV1"); } if (iCRT) { //=================== CRT parameters ============================ IlcCRT *CRT = new IlcCRTv0("CRT", "normal ACORDE"); } if (iVZERO) { //=================== CRT parameters ============================ IlcVZERO *VZERO = new IlcVZEROv3("VZERO", "normal VZERO"); } }
AliGenPythia *PythiaHVQ(PDC07Proc_t proc) { //*******************************************************************// // Configuration file for charm / beauty generation with PYTHIA // // // // The parameters have been tuned in order to reproduce the inclusive// // heavy quark pt distribution given by the NLO pQCD calculation by // // Mangano, Nason and Ridolfi. // // // // For details and for the NORMALIZATION of the yields see: // // N.Carrer and A.Dainese, // // "Charm and beauty production at the LHC", // // ALICE-INT-2003-019, [arXiv:hep-ph/0311225]; // // PPR Chapter 6.6, CERN/LHCC 2005-030 (2005). // //*******************************************************************// AliGenPythia * gener = 0x0; switch(proc) { case kCharmPbPb5500: comment = comment.Append(" Charm in Pb-Pb at 5.5 TeV"); gener = new AliGenPythia(nEvts); gener->SetProcess(kPyCharmPbPbMNR); gener->SetStrucFunc(kCTEQ4L); gener->SetPtHard(2.1,-1.0); gener->SetEnergyCMS(5500.); gener->SetNuclei(208,208); break; case kCharmpPb8800: comment = comment.Append(" Charm in p-Pb at 8.8 TeV"); gener = new AliGenPythia(nEvts); gener->SetProcess(kPyCharmpPbMNR); gener->SetStrucFunc(kCTEQ4L); gener->SetPtHard(2.1,-1.0); gener->SetEnergyCMS(8800.); gener->SetProjectile("P",1,1); gener->SetTarget("Pb",208,82); break; case kCharmpp14000: comment = comment.Append(" Charm in pp at 14 TeV"); gener = new AliGenPythia(nEvts); gener->SetProcess(kPyCharmppMNR); gener->SetStrucFunc(kCTEQ4L); gener->SetPtHard(2.1,-1.0); gener->SetEnergyCMS(14000.); break; case kCharmpp14000wmi: comment = comment.Append(" Charm in pp at 14 TeV with mult. interactions"); gener = new AliGenPythia(-1); gener->SetProcess(kPyCharmppMNRwmi); gener->SetStrucFunc(kCTEQ5L); gener->SetPtHard(ptHardMin,ptHardMax); gener->SetEnergyCMS(14000.); break; case kD0PbPb5500: comment = comment.Append(" D0 in Pb-Pb at 5.5 TeV"); gener = new AliGenPythia(nEvts); gener->SetProcess(kPyD0PbPbMNR); gener->SetStrucFunc(kCTEQ4L); gener->SetPtHard(2.1,-1.0); gener->SetEnergyCMS(5500.); gener->SetNuclei(208,208); break; case kD0pPb8800: comment = comment.Append(" D0 in p-Pb at 8.8 TeV"); gener = new AliGenPythia(nEvts); gener->SetProcess(kPyD0pPbMNR); gener->SetStrucFunc(kCTEQ4L); gener->SetPtHard(2.1,-1.0); gener->SetEnergyCMS(8800.); gener->SetProjectile("P",1,1); gener->SetTarget("Pb",208,82); break; case kD0pp14000: comment = comment.Append(" D0 in pp at 14 TeV"); gener = new AliGenPythia(nEvts); gener->SetProcess(kPyD0ppMNR); gener->SetStrucFunc(kCTEQ4L); gener->SetPtHard(2.1,-1.0); gener->SetEnergyCMS(14000.); break; case kDPlusPbPb5500: comment = comment.Append(" DPlus in Pb-Pb at 5.5 TeV"); gener = new AliGenPythia(nEvts); gener->SetProcess(kPyDPlusPbPbMNR); gener->SetStrucFunc(kCTEQ4L); gener->SetPtHard(2.1,-1.0); gener->SetEnergyCMS(5500.); gener->SetNuclei(208,208); break; case kDPluspPb8800: comment = comment.Append(" DPlus in p-Pb at 8.8 TeV"); gener = new AliGenPythia(nEvts); gener->SetProcess(kPyDPluspPbMNR); gener->SetStrucFunc(kCTEQ4L); gener->SetPtHard(2.1,-1.0); gener->SetEnergyCMS(8800.); gener->SetProjectile("P",1,1); gener->SetTarget("Pb",208,82); break; case kDPluspp14000: comment = comment.Append(" DPlus in pp at 14 TeV"); gener = new AliGenPythia(nEvts); gener->SetProcess(kPyDPlusppMNR); gener->SetStrucFunc(kCTEQ4L); gener->SetPtHard(2.1,-1.0); gener->SetEnergyCMS(14000.); break; case kBeautyPbPb5500: comment = comment.Append(" Beauty in Pb-Pb at 5.5 TeV"); gener = new AliGenPythia(nEvts); gener->SetProcess(kPyBeautyPbPbMNR); gener->SetStrucFunc(kCTEQ4L); gener->SetPtHard(2.75,-1.0); gener->SetEnergyCMS(5500.); gener->SetNuclei(208,208); break; case kBeautypPb8800: comment = comment.Append(" Beauty in p-Pb at 8.8 TeV"); gener = new AliGenPythia(nEvts); gener->SetProcess(kPyBeautypPbMNR); gener->SetStrucFunc(kCTEQ4L); gener->SetPtHard(2.75,-1.0); gener->SetEnergyCMS(8800.); gener->SetProjectile("P",1,1); gener->SetTarget("Pb",208,82); break; case kBeautypp14000: comment = comment.Append(" Beauty in pp at 14 TeV"); gener = new AliGenPythia(nEvts); gener->SetProcess(kPyBeautyppMNR); gener->SetStrucFunc(kCTEQ4L); gener->SetPtHard(2.75,-1.0); gener->SetEnergyCMS(14000.); break; case kBeautypp14000wmi: comment = comment.Append(" Beauty in pp at 14 TeV with mult. interactions"); gener = new AliGenPythia(-1); gener->SetProcess(kPyBeautyppMNRwmi); gener->SetStrucFunc(kCTEQ5L); gener->SetPtHard(ptHardMin,ptHardMax); gener->SetEnergyCMS(14000.); break; } return gener; }
//_____________________________________________________________________________________________________________________________ void runAddUpSystematicErrors(Bool_t useCentralities = kFALSE, Bool_t useJetPt = kTRUE, Bool_t useDirectFit = kTRUE, Bool_t noMuons = kTRUE, TString date = "2013_12_11", TString chargeString = "", TString path = "/hera/alice/bhess/analysis/10d_e.pass2_merged/nclCut", Bool_t multRef = kTRUE, Bool_t newRefBinning = kTRUE) { gROOT->LoadMacro("AddUpSystematicErrors.C+"); const Double_t nSigma = 0; const TString sigmaString = Form("_nSigma%.1f", nSigma);// nSigma > 0 ? Form("_nSigma%.1f", nSigma) : ""; //const TString sigmaString = Form("%s_nSigma%.1f", chargeString.Data(), nSigma);// nSigma > 0 ? Form("_nSigma%.1f", nSigma) : ""; const Int_t numCentralities = 9; const Int_t centralities[numCentralities + 1] = { 0, 5, 10, 20, 30, 40, 50, 60, 80, 100 }; const Int_t numCentralitiesRefMultOld = 9; const Int_t centralitiesRefMultOldLowEdge[numCentralitiesRefMultOld] = { 0, 7, 13, 20, 29, 40, 50, 60, 0 }; const Int_t centralitiesRefMultOldUpEdge[numCentralitiesRefMultOld] = { 7, 13, 20, 29, 40, 50, 60, 95, 125 }; const Int_t numCentralitiesRefMultNew = 18; const Int_t centralitiesRefMultNewLowEdge[numCentralitiesRefMultNew] = { 1, 4, 7, 10, 15, 20, 25, 30, 40, 50, 60, 70, 100, 15, 25, 40, 60, 0 }; const Int_t centralitiesRefMultNewUpEdge[numCentralitiesRefMultNew] = { 4, 7, 10, 15, 20, 25, 30, 40, 50, 60, 70, 100, 9999, 25, 9999, 9999, 9999, 9999 }; const Int_t numCentralitiesV0Mpp = 15; const Double_t centralitiesV0MppLowEdge[numCentralitiesV0Mpp] = { 0, 0.01, 0.1, 1, 5, 10, 15, 20, 30, 40, 50, 70, 0, 0, 0}; const Double_t centralitiesV0MppUpEdge[numCentralitiesV0Mpp] = { 0.01, 0.1, 1, 5, 10, 15, 20, 30, 40, 50, 70, 100, 0.1, 1, 100 }; TString centralityString = ""; const Int_t numJetPtBins = 4; const Int_t jetPt[numJetPtBins + 3] = { 5, 10, 15, 20, 30, 10, 40 }; TString jetPtString = ""; /*pPb //TString path = "/hera/alice/bhess/analysis/13b.pass3"; //TString date = "2013_09_13"; for (Int_t iCent = 0; iCent < numCentralities; iCent++) { centralityString = useCentralities ? Form("_centrality%d_%d", centralities[iCent], centralities[iCent + 1]) : ""; const Int_t numFiles = 8; TString outFileTitle = Form("SummedSystematicErrors%s%s", centralityString.Data(), chargeString.Data()); TString fileNames[numFiles]; fileNames[0] = Form("%s/outputSystematics_Splines%s%s__%s.root", path.Data(), centralityString.Data(), sigmaString.Data(), date.Data()); fileNames[1] = Form("%s/outputSystematics_Sigma%s%s__%s.root", path.Data(), centralityString.Data(), sigmaString.Data(), date.Data()); fileNames[2] = Form("%s/outputSystematics_Multiplicity%s%s__%s.root", path.Data(), centralityString.Data(), sigmaString.Data(), date.Data()); fileNames[3] = Form("%s/outputSystematics_Eta%s%s__%s.root", path.Data(), centralityString.Data(), sigmaString.Data(), date.Data()); fileNames[4] = Form("%s/outputSystematics_Shape%s%s__%s.root", path.Data(), centralityString.Data(), sigmaString.Data(), date.Data()); fileNames[5] = Form("%s/outputSystematics_Muons%s%s__%s.root", path.Data(), centralityString.Data(), sigmaString.Data(), date.Data()); fileNames[6] = Form("%s/outputSystematics_PrePID%s%s__%s.root", path.Data(), centralityString.Data(), sigmaString.Data(), date.Data()); fileNames[7] = Form("%s/outputSystematics_Centrality%s%s__%s.root", path.Data(), centralityString.Data(), sigmaString.Data(), date.Data()); TString fileNameReference = Form("%s/bhess_PID_TPCdefaultPriors_ITS_PureGauss_results_LLFit__Pt_2_reg1_regFac1.00_muonToElTunedOnMCStandardTrackCutsPPB_idSpectra%s.root" , path.Data(), centralityString.Data()); AddUpSystematicErrors(path, outFileTitle, fileNames, numFiles, fileNameReference); if (!useCentralities) break; } */ // pp inclusive/Jets /* TString reference = ""; if (noMuons) { reference = useJetPt ? "bhess_PID_Jets_results_LLFit__Pt_2_reg1_regFac1.00_noMuons_idSpectra" : Form("bhess_PID_Jets_Inclusive_results_LLFit__Pt_2_reg1_regFac1.00_noMuons_idSpectra%s.root", chargeString.Data()); } else { reference = useJetPt ? "bhess_PID_Jets_results_LLFit__Pt_2_reg1_regFac1.00_muonToElTunedOnMCHybridTrackCutsJets_idSpectra" : Form("bhess_PID_Jets_Inclusive_results_LLFit__Pt_2_reg1_regFac1.00_muonToElTunedOnMCHybridTrackCuts_idSpectra%s.root", chargeString.Data()); } TString referenceCurrent = reference; TString modeString[3] = { "_pT", "_z", "_xi" }; TString modeString2[3] = { "Pt", "Z", "Xi" }; for (Int_t mode = -1; mode <= 2; mode++) { if (mode == -1 && useJetPt) continue; if (!useJetPt && mode >= 0) break; for (Int_t iJetPt = 0; iJetPt <= numJetPtBins; iJetPt++) { if (iJetPt == numJetPtBins) { // 10-40 bin iJetPt++; } TString modeTotString = ""; if (mode >= 0 && !useDirectFit) modeTotString = Form("__centrality_all_jetPt%d.0_%d.0%s", jetPt[iJetPt], jetPt[iJetPt + 1], modeString[mode].Data()); jetPtString = ""; if (mode >= 0) // => useJetPt jetPtString = Form("_jetPt%d.0_%d.0%s", jetPt[iJetPt], jetPt[iJetPt + 1], modeTotString.Data()); jetPtString.Append(chargeString); if (mode >= 0) {// => useJetPt if (useDirectFit) { // TODO no muons for direct fit vs. z, xi yet! referenceCurrent = Form("bhess_PID_Jets_results_LLFit__%s_2_reg1_regFac1.00_%s_idSpectra%s.root", modeString2[mode].Data(), (mode == 0 && !noMuons) ? "muonToElTunedOnMCHybridTrackCutsJets" : "noMuons", jetPtString.Data()); } else referenceCurrent = Form("output_extractedFFs_%s_jetPt%d.0_%d.0__centrality_all_jetPt%d.0_%d.0.root", reference.Data(), jetPt[iJetPt], jetPt[iJetPt + 1], jetPt[iJetPt], jetPt[iJetPt + 1]); } TString prefix = "outputSystematics"; if (mode >= 0 && useDirectFit) prefix = Form("%s_%s", prefix.Data(), modeString2[mode].Data()); const Int_t numFilesMax = 6; Int_t numFiles = 5; // TODO no muons for direct fit vs. z, xi yet! if ((!useDirectFit || mode < 1) && !noMuons) numFiles++; TString modeSuffix = ""; if (mode >= 0 && useDirectFit) modeSuffix = Form("_%s_", modeString2[mode].Data()); TString outFileTitle = Form("SummedSystematicErrors%s%s", modeSuffix.Data(), jetPtString.Data()); TString fileNames[numFilesMax]; fileNames[0] = Form("%s/%s_Splines%s%s__%s.root", path.Data(), prefix.Data(), jetPtString.Data(), sigmaString.Data(), date.Data()); fileNames[1] = Form("%s/%s_Sigma%s%s__%s.root", path.Data(), prefix.Data(), jetPtString.Data(), sigmaString.Data(), date.Data()); fileNames[2] = Form("%s/%s_Eta%s%s__%s.root", path.Data(), prefix.Data(), jetPtString.Data(), sigmaString.Data(), date.Data()); fileNames[3] = Form("%s/%s_Shape%s%s__%s.root", path.Data(), prefix.Data(), jetPtString.Data(), sigmaString.Data(), date.Data()); fileNames[4] = Form("%s/%s_PrePID%s%s__%s.root", path.Data(), prefix.Data(), jetPtString.Data(), sigmaString.Data(), date.Data()); if ((!useDirectFit || mode < 1) && !noMuons) fileNames[5] = Form("%s/%s_Muons%s%s__%s.root", path.Data(), prefix.Data(), jetPtString.Data(), sigmaString.Data(), date.Data()); TString fileNameReference = Form("%s/%s", path.Data(), referenceCurrent.Data()); AddUpSystematicErrors(path, outFileTitle, fileNames, numFiles, fileNameReference, mode, useDirectFit); if (!useJetPt) break; } } */ ///* // multRef/V0M: pp inclusive // e.g. a 'runAddUpSystematicErrors.C(kTRUE, kFALSE, kTRUE, kTRUE, "2014_07_18", "", "/hera/alice/bhess/analysis/10d_e.pass2_merged/nclCut/multiplicityDependencePP/trackletsMult/pileUpRejectionSPD/")' -b -q useCentralities = kTRUE; useJetPt = kFALSE; useDirectFit = kTRUE; noMuons = kTRUE; Int_t numCentralitiesRefMult = newRefBinning ? numCentralitiesRefMultNew : numCentralitiesRefMultOld; Int_t* centralitiesRefMultLowEdge = 0x0; Int_t* centralitiesRefMultUpEdge = 0x0; if (multRef) { centralitiesRefMultLowEdge = new Int_t[numCentralitiesRefMult]; centralitiesRefMultUpEdge = new Int_t[numCentralitiesRefMult]; for (Int_t i = 0; i < numCentralitiesRefMult; i++) { centralitiesRefMultLowEdge[i] = newRefBinning ? centralitiesRefMultNewLowEdge[i] : centralitiesRefMultOldLowEdge[i]; centralitiesRefMultUpEdge[i] = newRefBinning ? centralitiesRefMultNewUpEdge[i] : centralitiesRefMultOldUpEdge[i]; } } Int_t mode = 0; const Int_t numMults = multRef ? numCentralitiesRefMult : numCentralitiesV0Mpp; for (Int_t iMult = -1; iMult < numMults; iMult++) { if (multRef) { if (iMult == -1) centralityString = ""; else centralityString = Form("_centrality%d_%d", centralitiesRefMultLowEdge[iMult], centralitiesRefMultUpEdge[iMult]); } else { centralityString = ""; if (iMult >= 0) { Bool_t centralityHasDecimalsPlaces = CentralityHasDecimalsPlaces(centralitiesV0MppLowEdge[iMult]) || CentralityHasDecimalsPlaces(centralitiesV0MppUpEdge[iMult]); centralityString = Form(centralityHasDecimalsPlaces ? "_centrality%.0fem2_%.0fem2" : "_centrality%.0f_%.0f", centralityHasDecimalsPlaces ? 100.*centralitiesV0MppLowEdge[iMult] : centralitiesV0MppLowEdge[iMult], centralityHasDecimalsPlaces ? 100.*centralitiesV0MppUpEdge[iMult] : centralitiesV0MppUpEdge[iMult]); } } centralityString.Append(chargeString); TString reference = Form("bhess_PID_TPCdefaultPriors_ITS_results_LLFit__Pt_2_reg1_regFac1.00_noMuons_idSpectra%s.root", centralityString.Data()); TString prefix = "outputSystematics"; const Int_t numFilesMax = 5; Int_t numFiles = 5; TString outFileTitle = Form("SummedSystematicErrors%s", centralityString.Data()); TString fileNames[numFilesMax]; fileNames[0] = Form("%s/%s_Splines%s%s__%s.root", path.Data(), prefix.Data(), centralityString.Data(), sigmaString.Data(), date.Data()); fileNames[1] = Form("%s/%s_Sigma%s%s__%s.root", path.Data(), prefix.Data(), centralityString.Data(), sigmaString.Data(), date.Data()); fileNames[2] = Form("%s/%s_Eta%s%s__%s.root", path.Data(), prefix.Data(), centralityString.Data(), sigmaString.Data(), date.Data()); fileNames[3] = Form("%s/%s_Shape%s%s__%s.root", path.Data(), prefix.Data(), centralityString.Data(), sigmaString.Data(), date.Data()); fileNames[4] = Form("%s/%s_PrePID%s%s__%s.root", path.Data(), prefix.Data(), centralityString.Data(), sigmaString.Data(), date.Data()); TString fileNameReference = Form("%s/%s", path.Data(), reference.Data()); AddUpSystematicErrors(path, outFileTitle, fileNames, numFiles, fileNameReference, mode, useDirectFit); } //*/ }
AliGenPythia *PythiaHard(PDC07Proc_t proc) { //*******************************************************************// // Configuration file for hard QCD processes generation with PYTHIA // // // //*******************************************************************// AliGenPythia * gener = 0x0; switch(proc) { case kPyJetJet: comment = comment.Append(" pp->jet + jet over at 14 TeV, no restriction"); AliGenPythia * gener = new AliGenPythia(nEvts); gener->SetEnergyCMS(eCMS);// Centre of mass energy gener->SetProcess(kPyJets);// Process type gener->SetJetEtaRange(-1.5, 1.5);// Final state kinematic cuts gener->SetJetPhiRange(0., 360.); gener->SetJetEtRange(10., 1000.); gener->SetPtHard(ptHardMin, ptHardMax);// Pt transfer of the hard scattering gener->SetStrucFunc(kCTEQ4L); return gener; case kPyGammaJetPHOS: comment = comment.Append(" pp->jet + gamma over PHOS"); gener = new AliGenPythia(nEvts); gener->SetEnergyCMS(eCMS); gener->SetProcess(kPyDirectGamma); gener->SetStrucFunc(kCTEQ4L); gener->SetPtHard(ptHardMin,ptHardMax); //gener->SetYHard(-1.0,1.0); gener->SetGammaEtaRange(-0.13,0.13); gener->SetGammaPhiRange(218.,322.);//Over 5 modules +-2 deg break; case kPyJetJetPHOS: comment = comment.Append(" pp->jet + jet over PHOS"); gener = new AliGenPythia(nEvts); gener->SetEnergyCMS(eCMS); gener->SetProcess(kPyJets); gener->SetStrucFunc(kCTEQ4L); gener->SetPtHard(ptHardMin,ptHardMax); //gener->SetYHard(-1.0,1.0); gener->SetJetEtaRange(-1.,1.); gener->SetJetPhiRange(200.,340.); gener->SetPi0InPHOS(kTRUE); gener->SetFragPhotonOrPi0MinPt(ptGammaPi0Min); printf("\n \n Event generator: Minimum pT of particle in calorimeter %f \n \n", ptGammaPi0Min); break; case kPyGammaBremsPHOS: comment = comment.Append(" pp->jet + jet+bremsphoton over PHOS at 14 TeV"); gener = new AliGenPythia(nEvts); gener->SetEnergyCMS(eCMS); gener->SetProcess(kPyJets); gener->SetStrucFunc(kCTEQ4L); gener->SetPtHard(ptHardMin,ptHardMax); //gener->SetYHard(-1.0,1.0); gener->SetJetEtaRange(-1.,1.); gener->SetJetPhiRange(200.,340.); gener->SetFragPhotonInPHOS(kTRUE); gener->SetFragPhotonOrPi0MinPt(ptGammaPi0Min); printf("\n \n Event generator: Minimum pT of particle in calorimeter %f \n \n", ptGammaPi0Min); break; case kPyJetJetPHOSv2: comment = comment.Append(" pp->jet + jet over PHOS version2 "); gener = new AliGenPythia(nEvts); gener->SetEnergyCMS(eCMS); gener->SetProcess(kPyJets); gener->SetStrucFunc(kCTEQ4L); gener->SetPtHard(ptHardMin,ptHardMax); //gener->SetYHard(-1.0,1.0); gener->SetJetEtaRange(-1.,1.); gener->SetJetPhiRange(200.,340.); //gener->SetPi0InPHOS(kTRUE); gener->SetPhotonInPHOSeta(kTRUE); gener->SetPhotonMinPt(ptGammaPi0Min); gener->SetForceDecay(kAll); break; case kPyGammaJetEMCAL: comment = comment.Append(" pp->jet + gamma over EMCAL at 14 TeV"); gener = new AliGenPythia(nEvts); gener->SetEnergyCMS(eCMS); gener->SetProcess(kPyDirectGamma); gener->SetStrucFunc(kCTEQ4L); gener->SetPtHard(ptHardMin,ptHardMax); //gener->SetYHard(-1.0,1.0); gener->SetGammaEtaRange(-0.71,0.71); gener->SetGammaPhiRange(78.,192.);//Over 6 supermodules +-2 deg break; case kPyJetJetEMCAL: comment = comment.Append(" pp->jet + jet over EMCAL at 14 TeV"); gener = new AliGenPythia(nEvts); gener->SetEnergyCMS(eCMS); gener->SetProcess(kPyJets); gener->SetStrucFunc(kCTEQ4L); gener->SetPtHard(ptHardMin,ptHardMax); //gener->SetYHard(-1.0,1.0); gener->SetJetEtaRange(-1,1); gener->SetJetPhiRange(60.,210.); gener->SetPi0InEMCAL(kTRUE); gener->SetFragPhotonOrPi0MinPt(ptGammaPi0Min); printf("\n \n Event generator: Minimum pT of particle in calorimeter %f \n \n", ptGammaPi0Min); break; case kPyGammaBremsEMCAL: comment = comment.Append(" pp->jet + jet+bremsphoton over EMCAL at 14 TeV"); gener = new AliGenPythia(nEvts); gener->SetEnergyCMS(eCMS); gener->SetProcess(kPyJets); gener->SetStrucFunc(kCTEQ4L); gener->SetPtHard(ptHardMin,ptHardMax); //gener->SetYHard(-1.0,1.0); gener->SetJetEtaRange(-1,1); gener->SetJetPhiRange(60.,210.); //Over 2 uncovered PHOS modules gener->SetFragPhotonInEMCAL(kTRUE); gener->SetFragPhotonOrPi0MinPt(ptGammaPi0Min); printf("\n \n Event generator: Minimum pT of particle in calorimeter %f \n \n", ptGammaPi0Min); break; } return gener; }
//============================================================ // <T>将尾部项存入文件。</T> // // @param out 输出文件流。 //============================================================ void FCsvFooters::Store(TDataOutput& out){ FDictionary<FCsvFooter*>::TIteratorC it = _pFooters->IteratorC(); TString foot = TC("@footer.name\n"); TBool showLabel = EFalse; TBool showDescription = EFalse; TInt count = 0; TInt lastFooterIndex = _pFooters->Count() - 1; while(it.Next()){ FCsvFooter* pFoot = it.Value(); foot.Append(pFoot->Name()); if(count != lastFooterIndex){ foot.Append(','); }else{ foot.Append('\n'); } TInt labelLength = RString::Length(pFoot->Label()); if(labelLength){ showLabel = ETrue; } TInt desLength = RString::Length(pFoot->Description()); if(desLength){ showDescription= ETrue; } ++count; } if(showLabel){ foot.Append(TC("@footer.label\n")); count = 0; it.Reset(); while(it.Next()){ FCsvFooter* pFoot = it.Value(); foot.Append(pFoot->Label()); if(count != lastFooterIndex){ foot.Append(','); }else{ foot.Append('\n'); } } } if(showDescription){ foot.Append(TC("@head.description\n")); count = 0; it.Reset(); while(it.Next()){ FCsvFooter* pFoot = it.Value(); foot.Append(pFoot->Description()); if(count != lastFooterIndex){ foot.Append(','); }else{ foot.Append('\n'); } } } out.Write((TCharC*)foot, foot.Length()); }
void TotXS() { Int_t i, count, chan, chan_lo, chan_hi; Double_t enn[352], denn[352], xsn[352], dxsn[352]; Double_t eg, xs, junk, egg[352], xxs[352]; TString name; c1 = new TCanvas( "c1", "Total Cross Sections", 200, 10, 700, 500); c1->SetGrid(); c1->GetFrame()->SetFillColor( 21); c1->GetFrame()->SetBorderSize( 12); // Calculate the channel cross sections // For total cross sections, the theta bin is 0 for 0-180 deg. chan_lo = 245; chan_hi = 269; for ( i = 0; i <= 24; ChanXS( i++, 0)); name = "xs/compton/xs/tot_xs.out"; ofstream outFile( name); if ( !outFile.is_open()) { cout << "Error opening file "; cout << name; cout << endl; break; } count = 0; for ( chan = chan_lo; chan <= chan_hi; chan++) { enn[count] = tcd[chan].energy; denn[count] = 0; xsn[count] = tcd[chan].xs[0]; dxsn[count] = tcd[chan].dxs[0]; outFile << enn[count] << " " << xsn[count] << " " << dxsn[count++] << endl ; } outFile.close(); // Plot Results gr = new TGraphErrors( count-1, enn, xsn, denn, dxsn); gr->SetTitle( "Preliminary #gammap#rightarrowp#pi^{0} Total Cross Section"); gr->SetMarkerStyle( 20); gr->SetMarkerSize( 1.0); gr->SetLineWidth( 3); gr->GetXaxis()->SetTitleOffset( 1.1); gr->GetYaxis()->SetTitleOffset( 1.0); gr->GetYaxis()->SetTitleSize( 0.05); gr->GetXaxis()->SetTitle( "E_{#gamma} (MeV)"); gr->GetYaxis()->SetTitle( "#sigma (#mub)"); gr->GetXaxis()->SetLabelSize( 0.03); gr->GetYaxis()->SetLabelSize( 0.03); gr->GetXaxis()->CenterTitle(); gr->GetYaxis()->CenterTitle(); gr->GetXaxis()->SetRangeUser( tcd[chan_hi].energy - 10, tcd[chan_lo].energy + 10); gr->SetMaximum( 5); gr->SetMinimum( -0.1); gr->Draw( "AP"); pt = new TLegend( 0.3, 0.7, 0.6, 0.85); pt->SetFillColor( 0); pt->SetBorderSize( 0); pt->SetTextSize( 0.04); pt->AddEntry( gr, "This Work", "p"); // Theory name = "xs/compton/theory/totxs_params.dat"; ifstream inFile( name); if ( !inFile.is_open()) { cout << "Error opening file "; cout << name; cout << endl; break; } i = 0; while( !inFile.eof()) { inFile >> eg >> xs >> junk >> junk >> junk; egg[i] = eg; xxs[i++] = xs; } inFile.close(); count = i-1; // Plot Results gr1 = new TGraph( count, egg, xxs); gr1->SetMarkerColor( 2); gr1->SetMarkerSize( 1.2); gr1->SetLineWidth( 2); gr1->SetLineColor( 2); gr1->SetMarkerStyle( 20); gr1->Draw( "Lsame"); pt->AddEntry( gr1, "Pasquini", "l"); pt->Draw(); name = "plots/Compton/xstot_compton"; // name.Append( ".eps"); name.Append( ".pdf"); c1->Print( name); }