void Parity_pi(int cen=1) { //main_function struct StRefMultCorr refmultCorrUtil = StRefMultCorr("refmult") ; delete gRandom; gRandom = new TRandom3(0); float Eweight = 1; const int Phibin = 80; char fname[200]; float PsiShiftE1=0,PsiShiftE2=0,PsiShiftE3=0,PsiShiftE4=0; float PsiShiftW1=0,PsiShiftW2=0,PsiShiftW3=0,PsiShiftW4=0; float PsiShiftf1=0,PsiShiftf2=0,PsiShiftf3=0,PsiShiftf4=0; float PsiShiftb1=0,PsiShiftb2=0,PsiShiftb3=0,PsiShiftb4=0; float PsiShiftF1=0,PsiShiftF2=0,PsiShiftF3=0,PsiShiftF4=0; const int order = 1; float PhiMean[4*order]= {0,}; float PhiWgtFF[Phibin][4],PhiWgtRF[Phibin][4]; TProfile2D *TPCmean_FF, *TPCmean_RF; TH2D *TPCPhi_FF, *TPCPhi_RF; TProfile2D *Read_TPC_EP_full, *Read_TPC_EP_east, *Read_TPC_EP_west, *Read_TPC_EP_for, *Read_TPC_EP_bac; sprintf(fname,"cen%d.weight_pi_minbias5.root",cen); TFile *fWgt=new TFile(fname,"READ"); if(!fWgt->IsOpen()) cout<<"no phi weight files!"<<endl; if(fWgt->IsOpen()) { TPCmean_FF = (TProfile2D*)fWgt->Get("TPCmeanPhi_FF"); TPCmean_RF = (TProfile2D*)fWgt->Get("TPCmeanPhi_RF"); TPCPhi_FF = (TH2D*)fWgt->Get("Hist_Phi_FF"); TPCPhi_RF = (TH2D*)fWgt->Get("Hist_Phi_RF"); Read_TPC_EP_full = (TProfile2D*)fWgt->Get("pTPC_EP_full"); Read_TPC_EP_east = (TProfile2D*)fWgt->Get("pTPC_EP_east"); Read_TPC_EP_west = (TProfile2D*)fWgt->Get("pTPC_EP_west"); Read_TPC_EP_for = (TProfile2D*)fWgt->Get("pTPC_EP_for"); Read_TPC_EP_bac = (TProfile2D*)fWgt->Get("pTPC_EP_bac"); for(int j=0; j<4; j++) { float PhiMeanFF = TPCPhi_FF->ProjectionX("",j+1,j+1)->GetSum()/(float)Phibin; float PhiMeanRF = TPCPhi_RF->ProjectionX("",j+1,j+1)->GetSum()/(float)Phibin; for(int i=0; i<Phibin; i++) { PhiWgtFF[i][j] = (TPCPhi_FF->GetBinContent(i+1,j+1)>0)? PhiMeanFF/(TPCPhi_FF->GetBinContent(i+1,j+1)):1; PhiWgtRF[i][j] = (TPCPhi_RF->GetBinContent(i+1,j+1)>0)? PhiMeanRF/(TPCPhi_RF->GetBinContent(i+1,j+1)):1; //cout<<" PhiWgt= "<<PhiWgt[i][j]; } } } else { for(int j=0; j<4; j++) for(int i=0; i<Phibin; i++) { PhiWgtFF[i][j] = 1; PhiWgtRF[i][j] = 1; } } /* //prepare the files int nfile = 0; TChain* chain = new TChain("StrangenessDst"); std::ifstream inlist(InputFileList); if(!inlist)cout<<" can't open file "<<endl; //prepare the files char *fileName=new char[200]; while(!inlist.eof()) { inlist.getline(fileName,200,'\n'); if(!inlist.eof()) nfile += chain->Add(fileName); } */ TChain* chain = new TChain("StrangenessDst"); int nfile = 0; nfile += chain->Add("/media/Disk_Chen/Data/200GeV_run11/data_minbias5_new/*.flow.nt.root"); cout <<"Added "<<nfile<<" files"<<endl; cout<<"# entries in chain: "<<chain->GetEntries()<<endl; char fname_out[200]; sprintf(fname_out,"cen%d.ntuple_result_Parity_pi_minbias5_eff.root",cen); TFile fout(fname_out,"RECREATE"); //defining variables Float_t PVtxz, VPDvz, Bz, psi_E, psi_W, mod_E, mod_W, ZDCe, ZDCw, ZDCcoin, BBCco; //run, event info Int_t Run, Day, Day2, Day3, Event, Trigger, RefMult, TOFMult, Centrality, NPTracks; // Float_t Charge, ndEdx, nSigma_p, nSigma_pi, DCAGlobal, Eta, Theta, Phi, Pt; //track info //defining histograms TH1D* hEventTally = new TH1D("EventTally","Event Tally",10,0,1); hEventTally->SetBit(TH1::kCanRebin); hEventTally->SetStats(0); TProfile *Ref_Day3 = new TProfile("Ref_Day3","RefMult vs Run",100000,80000,180000,-0.5,999.5); TProfile *TOF_Day3 = new TProfile("TOF_Day3","TOFMult vs Run",100000,80000,180000,0,5000); TProfile *NPT_Day3 = new TProfile("NPT_Day3","NPTracks vs Run",100000,80000,180000,0,2000); TProfile *TPC_Day3_cos2 = new TProfile("TPC_Day3_cos2","cos(2*psi) vs Run", 100000,80000,180000,-1,1); TProfile *TPC_Day3_sin2 = new TProfile("TPC_Day3_sin2","sin(2*psi) vs Run", 100000,80000,180000,-1,1); TH1D *Hist_RefMult = new TH1D("Hist_RefMult","Hist_RefMult",1000,-0.5,999.5); TH1D *Hist_TOFMult = new TH1D("Hist_TOFMult","Hist_TOFMult",5000,-0.5,4999.5); TProfile *p_RefMult = new TProfile("p_RefMult","p_RefMult",50,0.5,1000.5, 0,1000, ""); TProfile *p_TOFMult = new TProfile("p_TOFMult","p_TOFMult",50,0.5,5000.5, 0,5000, ""); TH1D *hBz = new TH1D("hBz","magnetic field",10, -10, 10); TH1D *hTrigger = new TH1D("hTrigger","hTrigger",400, 0.5, 400.5); TH1D *hCentrality = new TH1D("hCentrality","hCentrality",10,0,10); TH1D *hVertexZ = new TH1D("hVertexZ","hVertexZ",100,-100,100); TH2D *hMult_Vz = new TH2D("hMult_Vz","hMult_Vz",1000,-0.5,999.5,100,-100,100); TH2D *hMult_Vz_new = new TH2D("hMult_Vz_new","hMult_Vz_new",1000,-0.5,999.5,100,-100,100); TH1D *hBBC_coin = new TH1D("hBBC_coin","hBBC_coin",120,0,60000); TProfile2D *pTPCmeanPhi_FF = new TProfile2D("TPCmeanPhi_FF","TPCmeanPhi_FF", 8*order,0.5,8*order+0.5,10000,8000,18000,-1,1,""); TProfile2D *pTPCmeanPhi_RF = new TProfile2D("TPCmeanPhi_RF","TPCmeanPhi_RF", 8*order,0.5,8*order+0.5,10000,8000,18000,-1,1,""); TH1D* Hist_proton = new TH1D("Hist_proton","Hist_proton",50,-0.5,49.5); TH1D* Hist_pbar = new TH1D("Hist_pbar","Hist_pbar",50,-0.5,49.5); TH1D* Hist_netP = new TH1D("Hist_netP","Hist_netP",99,-49.5,49.5); TH2D *hEtaPtDist = new TH2D("EtaPtDist","EtaPtDist",26, -1.3, 1.3,300,0,15); TH2D* Hist_Phi = new TH2D("Hist_Phi","Hist_Phi",Phibin,-PI,PI,4,0.5,4.5); TH2D* Hist_TPC_EP_east = new TH2D("Hist_TPC_EP_east","Hist_TPC_EP_east",36,0,PI,100,80,180); TH2D* Hist_TPC_EP_west = new TH2D("Hist_TPC_EP_west","Hist_TPC_EP_west",36,0,PI,100,80,180); TH2D* Hist_TPC_EP_for = new TH2D("Hist_TPC_EP_for","Hist_TPC_EP_for",36,0,PI,100,80,180); TH2D* Hist_TPC_EP_bac = new TH2D("Hist_TPC_EP_bac","Hist_TPC_EP_bac",36,0,PI,100,80,180); TH2D* Hist_TPC_EP_full = new TH2D("Hist_TPC_EP_full","Hist_TPC_EP_full",36,0,PI,100,80,180); TH2D* Hist_TPC_EP_east_flat = new TH2D("Hist_TPC_EP_east_flat","Hist_TPC_EP_east_flat",36,0,PI,100,80,180); TH2D* Hist_TPC_EP_west_flat = new TH2D("Hist_TPC_EP_west_flat","Hist_TPC_EP_west_flat",36,0,PI,100,80,180); TH2D* Hist_TPC_EP_for_flat = new TH2D("Hist_TPC_EP_for_flat","Hist_TPC_EP_for_flat",36,0,PI,100,80,180); TH2D* Hist_TPC_EP_bac_flat = new TH2D("Hist_TPC_EP_bac_flat","Hist_TPC_EP_bac_flat",36,0,PI,100,80,180); TH2D* Hist_TPC_EP_full_flat = new TH2D("Hist_TPC_EP_full_flat","Hist_TPC_EP_full_flat",36,0,PI,100,80,180); TProfile2D* pTPC_EP_east = new TProfile2D("pTPC_EP_east","pTPC_EP_east",4,0.5,4.5,100,80,180,-1,1,""); TProfile2D* pTPC_EP_west = new TProfile2D("pTPC_EP_west","pTPC_EP_west",4,0.5,4.5,100,80,180,-1,1,""); TProfile2D* pTPC_EP_for = new TProfile2D("pTPC_EP_for","pTPC_EP_for",4,0.5,4.5,100,80,180,-1,1,""); TProfile2D* pTPC_EP_bac = new TProfile2D("pTPC_EP_bac","pTPC_EP_bac",4,0.5,4.5,100,80,180,-1,1,""); TProfile2D* pTPC_EP_full = new TProfile2D("pTPC_EP_full","pTPC_EP_full",4,0.5,4.5,100,80,180,-1,1,""); TH1F* Hist_dif_count = new TH1F("Hist_dif_count","Hist_dif_count",500,-250,250); TH1F* Hist_ful_count = new TH1F("Hist_ful_count","Hist_ful_count",1000,0,1000); TH1D* Hist_Pt = new TH1D("Hist_Pt","Hist_Pt",300,0,15); TH1D* Hist_Pt_TOF = new TH1D("Hist_Pt_TOF","Hist_Pt_TOF",300,0,15); TH1D* rc; TH2D* Hist_Phi_FF = new TH2D("Hist_Phi_FF","Hist_Phi_FF",Phibin,-PI,PI,4,0.5,4.5); TH2D* Hist_Phi_RF = new TH2D("Hist_Phi_RF","Hist_Phi_RF",Phibin,-PI,PI,4,0.5,4.5); TH2D* Hist_Phi_FF_new = new TH2D("Hist_Phi_FF_new","Hist_Phi_FF_new",Phibin,-PI,PI,4,0.5,4.5); TH2D* Hist_Phi_RF_new = new TH2D("Hist_Phi_RF_new","Hist_Phi_RF_new",Phibin,-PI,PI,4,0.5,4.5); TProfile *Hist_cos = new TProfile("Hist_cos","Hist_cos",2,0.5,2.5,-1,1,""); TProfile2D *Hist_cos_RefMult = new TProfile2D("Hist_cos_RefMult","Hist_cos_RefMult",2,0.5,2.5, 50,0.5,1000.5,-1,1,""); TProfile2D *Hist_cos_TOFMult = new TProfile2D("Hist_cos_TOFMult","Hist_cos_TOFMult",2,0.5,2.5, 50,0.5,5000.5,-1,1,""); TProfile2D *Hist_cos_ZDC = new TProfile2D("Hist_cos_ZDC","Hist_cos_ZDC",2,0.5,2.5, 50,0.5,20000.5,-1,1,""); TProfile2D *Hist_cos_BBC_RefMult = new TProfile2D("Hist_cos_BBC_RefMult","Hist_cos_BBC_RefMult",60,0,60000, 50,0.5,1000.5,-1,1,""); TH1D* hDpt = new TH1D("hDpt","hDpt",200,0,2); TH1D* hQinv = new TH1D("hQinv","hQinv",1000,0,10); TH1D* hQinv2 = new TH1D("hQinv2","hQinv2",1100,-1,10); TProfile *p_v2_RefMult_obs = new TProfile("p_v2_RefMult_obs","p_v2_RefMult_obs",50,0.5, 1000.5,-100,100,""); TProfile *p_v2_TOFMult_obs = new TProfile("p_v2_TOFMult_obs","p_v2_TOFMult_obs",50,0.5,5000.5,-100,100,""); TProfile *p_v2_ZDC_obs = new TProfile("p_v2_ZDC_obs","p_v2_ZDC_obs",50,0.5,20000.5,-100,100,""); TProfile2D *p_v2_BBC_RefMult_obs = new TProfile2D("p_v2_BBC_RefMult_obs","p_v2_BBC_RefMult_obs",60,0,60000,50,0.5, 1000.5,-100,100,""); TProfile *p_RefMult_ZDC_obs = new TProfile("p_RefMult_ZDC_obs","p_RefMult_ZDC_obs",50,0.5,20000.5,0,1000,""); TProfile *p_TOFMult_ZDC_obs = new TProfile("p_TOFMult_ZDC_obs","p_TOFMult_ZDC_obs",50,0.5,20000.5,0,5000,""); TProfile *pParity_int_obs1 = new TProfile("Parity_int_obs1","Parity_int_obs1",4,0.5,4.5,-100,100,""); TProfile *pParity_int_obs2 = new TProfile("Parity_int_obs2","Parity_int_obs2",4,0.5,4.5,-100,100,""); TProfile *pParity_int_obs3 = new TProfile("Parity_int_obs3","Parity_int_obs3",4,0.5,4.5,-100,100,""); TProfile *pParity_int_r_obs1 = new TProfile("Parity_int_r_obs1","Parity_int_r_obs1",4,0.5,4.5,-1600,1600,""); TProfile *pParity_int_r_obs2 = new TProfile("Parity_int_r_obs2","Parity_int_r_obs2",4,0.5,4.5,-1600,1600,""); TProfile *pParity_int_r_obs3 = new TProfile("Parity_int_r_obs3","Parity_int_r_obs3",4,0.5,4.5,-1600,1600,""); TProfile *pParity_int_rr_obs1 = new TProfile("Parity_int_rr_obs1","Parity_int_rr_obs1",4,0.5,4.5,-1600,1600,""); TProfile *pParity_int_rr_obs2 = new TProfile("Parity_int_rr_obs2","Parity_int_rr_obs2",4,0.5,4.5,-1600,1600,""); TProfile *pParity_int_rr_obs3 = new TProfile("Parity_int_rr_obs3","Parity_int_rr_obs3",4,0.5,4.5,-1600,1600,""); TProfile *pParity_int_s_obs1 = new TProfile("Parity_int_s_obs1","Parity_int_s_obs1",4,0.5,4.5,-100,100,""); TProfile *pParity_int_s_obs2 = new TProfile("Parity_int_s_obs2","Parity_int_s_obs2",4,0.5,4.5,-100,100,""); TProfile *pParity_int_s_obs3 = new TProfile("Parity_int_s_obs3","Parity_int_s_obs3",4,0.5,4.5,-100,100,""); TProfile *pParity_int_ss_obs1 = new TProfile("Parity_int_ss_obs1","Parity_int_ss_obs1",4,0.5,4.5,-100,100,""); TProfile *pParity_int_ss_obs2 = new TProfile("Parity_int_ss_obs2","Parity_int_ss_obs2",4,0.5,4.5,-100,100,""); TProfile *pParity_int_ss_obs3 = new TProfile("Parity_int_ss_obs3","Parity_int_ss_obs3",4,0.5,4.5,-100,100,""); TProfile *pParity_int_w_obs1 = new TProfile("Parity_int_w_obs1","Parity_int_w_obs1",4,0.5,4.5,-100,100,""); TProfile *pParity_int_w_obs2 = new TProfile("Parity_int_w_obs2","Parity_int_w_obs2",4,0.5,4.5,-100,100,""); TProfile *pParity_int_w_obs3 = new TProfile("Parity_int_w_obs3","Parity_int_w_obs3",4,0.5,4.5,-100,100,""); TProfile *pParity_int_ww_obs1 = new TProfile("Parity_int_ww_obs1","Parity_int_ww_obs1",4,0.5,4.5,-100,100,""); TProfile *pParity_int_ww_obs2 = new TProfile("Parity_int_ww_obs2","Parity_int_ww_obs2",4,0.5,4.5,-100,100,""); TProfile *pParity_int_ww_obs3 = new TProfile("Parity_int_ww_obs3","Parity_int_ww_obs3",4,0.5,4.5,-100,100,""); TProfile *pParity_int_same_run = new TProfile("Parity_int_same_run","Parity_int_same_run",10000,8000,18000,-100,100,""); TProfile *pParity_int_rr_same_run = new TProfile("Parity_int_rr_same_run","Parity_int_rr_same_run",10000,8000,18000,-100,100,""); TProfile *pParity_int_ss_same_run = new TProfile("Parity_int_ss_same_run","Parity_int_ss_same_run",10000,8000,18000,-100,100,""); TProfile *pParity_int_ww_same_run = new TProfile("Parity_int_ww_same_run","Parity_int_ww_same_run",10000,8000,18000,-100,100,""); TProfile *pParity_int_oppo_run = new TProfile("Parity_int_oppo_run","Parity_int_oppo_run",10000,8000,18000,-100,100,""); TProfile *pParity_int_rr_oppo_run = new TProfile("Parity_int_rr_oppo_run","Parity_int_rr_oppo_run",10000,8000,18000,-100,100,""); TProfile *pParity_int_ss_oppo_run = new TProfile("Parity_int_ss_oppo_run","Parity_int_ss_oppo_run",10000,8000,18000,-100,100,""); TProfile *pParity_int_ww_oppo_run = new TProfile("Parity_int_ww_oppo_run","Parity_int_ww_oppo_run",10000,8000,18000,-100,100,""); TProfile *pParity_int_ss_ran_obs1 = new TProfile("Parity_int_ss_ran_obs1","Parity_int_ss_ran_obs1",4,0.5,4.5,-100,100,""); TProfile *pParity_int_ss_ran_obs2 = new TProfile("Parity_int_ss_ran_obs2","Parity_int_ss_ran_obs2",4,0.5,4.5,-100,100,""); TProfile *pParity_int_ss_ran_obs3 = new TProfile("Parity_int_ss_ran_obs3","Parity_int_ss_ran_obs3",4,0.5,4.5,-100,100,""); TProfile2D *pParity_eta_ss_obs1 = new TProfile2D("Parity_eta_ss_obs1","Parity_eta_ss_obs1",12,0.5,12.5,20,-1,1,-100,100,""); TProfile2D *pParity_eta_ss_obs2 = new TProfile2D("Parity_eta_ss_obs2","Parity_eta_ss_obs2",12,0.5,12.5,20,-1,1,-100,100,""); TProfile2D *pParity_eta_ss_obs3 = new TProfile2D("Parity_eta_ss_obs3","Parity_eta_ss_obs3",12,0.5,12.5,20,-1,1,-100,100,""); TProfile2D *pParity_Deta_ss_obs1 = new TProfile2D("Parity_Deta_ss_obs1","Parity_Deta_ss_obs1",12,0.5,12.5,20,0,2,-100,100,""); TProfile2D *pParity_Deta_ss_obs2 = new TProfile2D("Parity_Deta_ss_obs2","Parity_Deta_ss_obs2",12,0.5,12.5,20,0,2,-100,100,""); TProfile2D *pParity_Deta_ss_obs3 = new TProfile2D("Parity_Deta_ss_obs3","Parity_Deta_ss_obs3",12,0.5,12.5,20,0,2,-100,100,""); TProfile2D *pParity_pt_ss_obs1 = new TProfile2D("Parity_pt_ss_obs1","Parity_pt_ss_obs1",12,0.5,12.5,20,0,2.0,-100,100,""); TProfile2D *pParity_pt_ss_obs2 = new TProfile2D("Parity_pt_ss_obs2","Parity_pt_ss_obs2",12,0.5,12.5,20,0,2.0,-100,100,""); TProfile2D *pParity_pt_ss_obs3 = new TProfile2D("Parity_pt_ss_obs3","Parity_pt_ss_obs3",12,0.5,12.5,20,0,2.0,-100,100,""); TProfile2D *pParity_Dpt_ss_obs1 = new TProfile2D("Parity_Dpt_ss_obs1","Parity_Dpt_ss_obs1",12,0.5,12.5,200,0,2.0,-100,100,""); TProfile2D *pParity_Dpt_ss_obs2 = new TProfile2D("Parity_Dpt_ss_obs2","Parity_Dpt_ss_obs2",12,0.5,12.5,200,0,2.0,-100,100,""); TProfile2D *pParity_Dpt_ss_obs3 = new TProfile2D("Parity_Dpt_ss_obs3","Parity_Dpt_ss_obs3",12,0.5,12.5,200,0,2.0,-100,100,""); TProfile2D *pParity_Q_ss_obs1 = new TProfile2D("Parity_Q_ss_obs1","Parity_Q_ss_obs1",4,0.5,4.5,500,0,5.0,-100,100,""); TProfile2D *pParity_Q_ss_obs2 = new TProfile2D("Parity_Q_ss_obs2","Parity_Q_ss_obs2",4,0.5,4.5,500,0,5.0,-100,100,""); TProfile2D *pParity_Q_ss_obs3 = new TProfile2D("Parity_Q_ss_obs3","Parity_Q_ss_obs3",4,0.5,4.5,500,0,5.0,-100,100,""); TProfile *pParity_noHBT_ss_obs2 = new TProfile("Parity_noHBT_ss_obs2","Parity_noHBT_ss_obs2",4,0.5,4.5,-100,100,""); TProfile *pParity_noHBT_ss_obs3 = new TProfile("Parity_noHBT_ss_obs3","Parity_noHBT_ss_obs3",4,0.5,4.5,-100,100,""); Int_t nentries = chain->GetEntries(); // nentries = 50000; //loop through events for(int i = 0; i < nentries; i++) { if((i+1)%1000==0) cout<<"Processing entry == "<< i+1 <<" == out of "<<nentries<<".\n"; chain->GetEntry(i); TLeaf* leaf_RunId = chain->GetLeaf("mRunId"); TLeaf* leaf_EventId = chain->GetLeaf("mEventId"); TLeaf* leaf_Trigger = chain->GetLeaf("mTrigger"); TLeaf* leaf_Bz = chain->GetLeaf("mBfield"); TLeaf* leaf_PrimaryVertexZ = chain->GetLeaf("mPrimaryVertexPositionZ"); TLeaf* leaf_VPDVz = chain->GetLeaf("mVPDEWdiff"); TLeaf* leaf_RefMult = chain->GetLeaf("mRefMult"); TLeaf* leaf_TOFMult = chain->GetLeaf("mTOFmult"); TLeaf* leaf_Centrality = chain->GetLeaf("mCentrality"); TLeaf* leaf_ZDC_EP = chain->GetLeaf("mZDC_EP"); TLeaf* leaf_ZDC = chain->GetLeaf("mZDC"); TLeaf* leaf_ZDCcoin = chain->GetLeaf("mZDCCoin"); TLeaf* leaf_BBCco = chain->GetLeaf("mBBCCoin"); TLeaf* leaf_NoTracks = chain->GetLeaf("mNumberOfV0s"); Run = (int)leaf_RunId->GetValue(0); Event = (int)leaf_EventId->GetValue(0); Trigger = (int)leaf_Trigger->GetValue(0); Bz = leaf_Bz->GetValue(0); PVtxz = leaf_PrimaryVertexZ->GetValue(0); VPDvz = leaf_VPDVz->GetValue(0); RefMult = (int)leaf_RefMult->GetValue(0); TOFMult = (int)leaf_TOFMult->GetValue(0); NPTracks= (int)leaf_NoTracks->GetValue(0); ZDCw = leaf_ZDC->GetValue(1) + leaf_ZDC->GetValue(2) + leaf_ZDC->GetValue(3); ZDCe = leaf_ZDC->GetValue(5) + leaf_ZDC->GetValue(6) + leaf_ZDC->GetValue(7); ZDCcoin = leaf_ZDCcoin->GetValue(0); BBCco = leaf_BBCco->GetValue(0); psi_E = leaf_ZDC_EP->GetValue(0); psi_W = leaf_ZDC_EP->GetValue(2); mod_E = leaf_ZDC_EP->GetValue(1); mod_W = leaf_ZDC_EP->GetValue(3); Centrality = leaf_Centrality->GetValue(0); Day = (int)((Run-12000000)/1000); Day2 = (int)((Run-12000000)/10); Day3 = (int)((Run-12000000)/1); int Bad =0; for(int jj=0; jj<12; jj++) if(Day2== bad_Ref_day2[jj]) { Bad = 1; break; } if(Day3<=138024) { for(int jj=0; jj<Nrun_MB1; jj++) if(Day3 == bad_Ref_day3_MB1[jj]) { Bad = 1; break; } } else if(Day3<=145020) { for(int jj=0; jj<Nrun_MB2; jj++) if(Day3 == bad_Ref_day3_MB2[jj]) { Bad = 1; break; } } else if(Day3<=154021) {} else if(Day3<=165031) { for(int jj=0; jj<Nrun_MB5; jj++) if(Day3 == bad_Ref_day3_MB5[jj]) { Bad = 1; break; } } else { for(int jj=0; jj<Nrun_MB6; jj++) if(Day3 == bad_Ref_day3_MB6[jj]) { Bad = 1; break; } } if(Bad) continue; //bad run if(RefMult) { float gM = 0.9995 + 21.89/(4.191*RefMult-18.17) - 2.723e-5*(4.191*RefMult-18.17); Eweight = gM + 0.0009326*(gM-1)*PVtxz; } hBz->Fill(Bz); hTrigger->Fill(Trigger); if((Trigger%5)<2) continue; Centrality = 0; for(int j=0; j<9; j++) if(RefMult>cenDef[j]) Centrality = j+1; refmultCorrUtil.init(Run); if ( refmultCorrUtil.isBadRun(Run) ) continue; refmultCorrUtil.initEvent(RefMult, PVtxz, ZDCcoin) ; Int_t cent9 = 1 + refmultCorrUtil.getCentralityBin9() ; Eweight = refmultCorrUtil.getWeight(); if((i+1)%1000==0) cout<<Centrality<<" "<<Eweight<<endl; Centrality = cent9; hVertexZ->Fill(PVtxz); hEventTally->Fill("Total Event",1); if(TOFMult < -100+3.0*RefMult) continue; //remove pile-up if(TOFMult > 180 +5.2*RefMult) continue; if(TMath::Abs(PVtxz) > Vz_cut) continue; //Z-vertex cut; track quality cut done in PkNtupleMaker if((PVtxz-VPDvz)>3 || (PVtxz-VPDvz)<-3) continue; Ref_Day3->Fill(Day3,RefMult); TOF_Day3->Fill(Day3,TOFMult); NPT_Day3->Fill(Day3,NPTracks); Hist_RefMult->Fill(RefMult); Hist_TOFMult->Fill(TOFMult); if(RefMult>10) { p_RefMult->Fill(RefMult,RefMult,Eweight); p_TOFMult->Fill(TOFMult,TOFMult,Eweight); } hCentrality->Fill(Centrality,Eweight); hMult_Vz->Fill(RefMult,PVtxz); hMult_Vz_new->Fill(RefMult,PVtxz,Eweight); if(cen && Centrality != cen) continue; hBBC_coin->Fill(BBCco); p_RefMult_ZDC_obs->Fill(ZDCe+ZDCw,RefMult,Eweight); p_TOFMult_ZDC_obs->Fill(ZDCe+ZDCw,TOFMult,Eweight); TLeaf* leaf_PtV0 = chain->GetLeaf("fV0s.mPtV0"); TLeaf* leaf_EtaV0 = chain->GetLeaf("fV0s.mEtaV0"); TLeaf* leaf_PhiV0 = chain->GetLeaf("fV0s.mPhiV0"); TLeaf* leaf_ChargeV0 = chain->GetLeaf("fV0s.mChargeV0"); TLeaf* leaf_DCAglobalV0 = chain->GetLeaf("fV0s.mDcaV0"); TLeaf* leaf_ndEdxV0 = chain->GetLeaf("fV0s.mndEdxV0"); TLeaf* leaf_TofFlagV0 = chain->GetLeaf("fV0s.mTofFlagV0"); TLeaf* leaf_TofYLocalV0 = chain->GetLeaf("fV0s.mTofYLocalV0"); TLeaf* leaf_TofM2V0 = chain->GetLeaf("fV0s.mTofM2V0"); TLeaf* leaf_nSigmaPV0 = chain->GetLeaf("fV0s.mnSigma_pV0"); TLeaf* leaf_nSigmaPiV0 = chain->GetLeaf("fV0s.mnSigma_piV0"); TLeaf* leaf_nSigmaKV0 = chain->GetLeaf("fV0s.mnSigma_kV0"); TLeaf* leaf_nSigmaEV0 = chain->GetLeaf("fV0s.mnSigma_eV0"); int Np = 0, Npbar = 0; int Ntof = 0; //TPC EP reconstruction TVector2 mQ, mQ1, mQ2, mQ3, mQ4; Double_t mQx=0., mQy=0., mQx1=0., mQy1=0., mQx2=0., mQy2=0., mQx3=0., mQy3=0., mQx4=0., mQy4=0.; int Fcount = 0, Ecount = 0, Wcount =0; for(int trk = 0; trk < NPTracks; trk++) { float EtaAsso = leaf_EtaV0->GetValue(trk); float PtAsso = leaf_PtV0->GetValue(trk); float PhiAsso = leaf_PhiV0->GetValue(trk); float DCAglAsso = leaf_DCAglobalV0->GetValue(trk); float ChargeAsso= leaf_ChargeV0->GetValue(trk); nSigma_p = leaf_nSigmaPV0->GetValue(trk); float nSigma_K = leaf_nSigmaKV0->GetValue(trk); float nSigma_e = leaf_nSigmaEV0->GetValue(trk); float TOFflag = leaf_TofFlagV0->GetValue(trk); if(TOFflag>0) Ntof++; // also nSigma_e>1 if(PtAsso>0.4 && PtAsso<1 && DCAglAsso<1 && EtaAsso>-1 && EtaAsso<1 && nSigma_p>-2 && nSigma_p<2 && nSigma_K>2 && nSigma_e >1 && ChargeAsso >0) Np++; if(PtAsso>0.4 && PtAsso<1 && DCAglAsso<1 && EtaAsso>-1 && EtaAsso<1 && nSigma_p>-2 && nSigma_p<2 && nSigma_K>2 && nSigma_e >1 && ChargeAsso <0) Npbar++; if(PtAsso > pt_asso_up || PtAsso < pt_asso_lo) continue; if(DCAglAsso > DcaCut) continue; if(EtaAsso>EtaCut || EtaAsso<-EtaCut) continue; if(opt_TOF ==1 && TOFflag<1) continue; Fcount++; int n = (int)((PhiAsso+PI)/2./PI*Phibin); int fl = (PVtxz > 0)? ((ChargeAsso > 0)? 1:2):((ChargeAsso > 0)? 3:4); Hist_Phi->Fill(PhiAsso,fl,PtAsso); float W_phi = (EtaAsso>0)? PhiWgtFF[n][fl-1]:PhiWgtRF[n][fl-1]; mQx += W_phi*PtAsso * cos(PhiAsso * 2.); mQy += W_phi*PtAsso * sin(PhiAsso * 2.); if(EtaAsso>0 && PVtxz>0 && ChargeAsso > 0) Hist_Phi_FF->Fill(PhiAsso,1,Eweight); if(EtaAsso>0 && PVtxz>0 && ChargeAsso < 0) Hist_Phi_FF->Fill(PhiAsso,2,Eweight); if(EtaAsso<0 && PVtxz>0 && ChargeAsso > 0) Hist_Phi_RF->Fill(PhiAsso,1,Eweight); if(EtaAsso<0 && PVtxz>0 && ChargeAsso < 0) Hist_Phi_RF->Fill(PhiAsso,2,Eweight); if(EtaAsso>0 && PVtxz<0 && ChargeAsso > 0) Hist_Phi_FF->Fill(PhiAsso,1+2,Eweight); if(EtaAsso>0 && PVtxz<0 && ChargeAsso < 0) Hist_Phi_FF->Fill(PhiAsso,2+2,Eweight); if(EtaAsso<0 && PVtxz<0 && ChargeAsso > 0) Hist_Phi_RF->Fill(PhiAsso,1+2,Eweight); if(EtaAsso<0 && PVtxz<0 && ChargeAsso < 0) Hist_Phi_RF->Fill(PhiAsso,2+2,Eweight); } if(Ntof<2) continue; int net_Np = Np - Npbar; Hist_proton->Fill(Np); Hist_pbar->Fill(Npbar); Hist_netP->Fill(net_Np); int iTrack[Fcount], Scount = Fcount/2 -1; for(int q=0; q<Fcount; q++) iTrack[q] = q; random_shuffle(iTrack,iTrack+Fcount); Fcount = 0; for(int trk = 0; trk < NPTracks; trk++) { float EtaAsso = leaf_EtaV0->GetValue(trk); float PtAsso = leaf_PtV0->GetValue(trk); float PhiAsso = leaf_PhiV0->GetValue(trk); float DCAglAsso = leaf_DCAglobalV0->GetValue(trk); float ChargeAsso= leaf_ChargeV0->GetValue(trk); float TOFflag = leaf_TofFlagV0->GetValue(trk); if(PtAsso > pt_asso_up || PtAsso < pt_asso_lo) continue; if(DCAglAsso > DcaCut) continue; if(EtaAsso>EtaCut || EtaAsso<-EtaCut) continue; if(opt_TOF ==1 && TOFflag<1) continue; int n = (int)((PhiAsso+PI)/2./PI*Phibin); int fl = (PVtxz > 0)? ((ChargeAsso > 0)? 1:2):((ChargeAsso > 0)? 3:4); float W_phi = (EtaAsso>0)? PhiWgtFF[n][fl-1]:PhiWgtRF[n][fl-1]; if(iTrack[Fcount] > Scount) { mQx1 +=W_phi*PtAsso*cos(PhiAsso*2.); mQy1 +=W_phi*PtAsso*sin(PhiAsso * 2.); Ecount++; } else { mQx2 += W_phi*PtAsso * cos(PhiAsso * 2.); mQy2 += W_phi*PtAsso * sin(PhiAsso * 2.); Wcount++; } if(EtaAsso> 0.1) { mQx3 +=W_phi*PtAsso*cos(PhiAsso*2.); mQy3 +=W_phi*PtAsso*sin(PhiAsso * 2.); } if(EtaAsso<-0.1) { mQx4 +=W_phi*PtAsso*cos(PhiAsso*2.); mQy4 +=W_phi*PtAsso*sin(PhiAsso * 2.); } Fcount++; } if(mQx1==0 || mQy1==0 || mQx2==0 || mQy2==0) continue; if(mQx3==0 || mQy3==0 || mQx4==0 || mQy4==0) continue; mQ.Set(mQx, mQy); mQ1.Set(mQx1, mQy1); mQ2.Set(mQx2, mQy2); mQ3.Set(mQx3, mQy3); mQ4.Set(mQx4, mQy4); float TPC_EP_full = 0.5*mQ.Phi(); float TPC_EP_east = 0.5*mQ1.Phi(); float TPC_EP_west = 0.5*mQ2.Phi(); float TPC_EP_for = 0.5*mQ3.Phi(); float TPC_EP_bac = 0.5*mQ4.Phi(); Hist_TPC_EP_full->Fill(TPC_EP_full,Day); Hist_TPC_EP_east->Fill(TPC_EP_east,Day); Hist_TPC_EP_west->Fill(TPC_EP_west,Day); Hist_TPC_EP_for->Fill(TPC_EP_for,Day); Hist_TPC_EP_bac->Fill(TPC_EP_bac,Day); pTPC_EP_east->Fill(1,Day,cos(2*TPC_EP_east)); pTPC_EP_east->Fill(2,Day,sin(2*TPC_EP_east)); pTPC_EP_east->Fill(3,Day,cos(4*TPC_EP_east)); pTPC_EP_east->Fill(4,Day,sin(4*TPC_EP_east)); pTPC_EP_west->Fill(1,Day,cos(2*TPC_EP_west)); pTPC_EP_west->Fill(2,Day,sin(2*TPC_EP_west)); pTPC_EP_west->Fill(3,Day,cos(4*TPC_EP_west)); pTPC_EP_west->Fill(4,Day,sin(4*TPC_EP_west)); pTPC_EP_for->Fill(1,Day,cos(2*TPC_EP_for)); pTPC_EP_for->Fill(2,Day,sin(2*TPC_EP_for)); pTPC_EP_for->Fill(3,Day,cos(4*TPC_EP_for)); pTPC_EP_for->Fill(4,Day,sin(4*TPC_EP_for)); pTPC_EP_bac->Fill(1,Day,cos(2*TPC_EP_bac)); pTPC_EP_bac->Fill(2,Day,sin(2*TPC_EP_bac)); pTPC_EP_bac->Fill(3,Day,cos(4*TPC_EP_bac)); pTPC_EP_bac->Fill(4,Day,sin(4*TPC_EP_bac)); if(fWgt->IsOpen() && Read_TPC_EP_east->GetEntries()) { PsiShiftE1 = Read_TPC_EP_east->GetBinContent(1,Day-79); PsiShiftE2 = Read_TPC_EP_east->GetBinContent(2,Day-79); PsiShiftE3 = Read_TPC_EP_east->GetBinContent(3,Day-79); PsiShiftE4 = Read_TPC_EP_east->GetBinContent(4,Day-79); } if(fWgt->IsOpen() && Read_TPC_EP_west->GetEntries()) { PsiShiftW1 = Read_TPC_EP_west->GetBinContent(1,Day-79); PsiShiftW2 = Read_TPC_EP_west->GetBinContent(2,Day-79); PsiShiftW3 = Read_TPC_EP_west->GetBinContent(3,Day-79); PsiShiftW4 = Read_TPC_EP_west->GetBinContent(4,Day-79); } if(fWgt->IsOpen() && Read_TPC_EP_for->GetEntries()) { PsiShiftf1 = Read_TPC_EP_for->GetBinContent(1,Day-79); PsiShiftf2 = Read_TPC_EP_for->GetBinContent(2,Day-79); PsiShiftf3 = Read_TPC_EP_for->GetBinContent(3,Day-79); PsiShiftf4 = Read_TPC_EP_for->GetBinContent(4,Day-79); } if(fWgt->IsOpen() && Read_TPC_EP_bac->GetEntries()) { PsiShiftb1 = Read_TPC_EP_bac->GetBinContent(1,Day-79); PsiShiftb2 = Read_TPC_EP_bac->GetBinContent(2,Day-79); PsiShiftb3 = Read_TPC_EP_bac->GetBinContent(3,Day-79); PsiShiftb4 = Read_TPC_EP_bac->GetBinContent(4,Day-79); } float TPC_EP_east_new = TPC_EP_east, TPC_EP_west_new = TPC_EP_west; float TPC_EP_for_new = TPC_EP_for, TPC_EP_bac_new = TPC_EP_bac; TPC_EP_east_new += 2*(-PsiShiftE2*cos(2*TPC_EP_east)+PsiShiftE1*sin(2*TPC_EP_east))/(float)2 + 2*(-PsiShiftE4*cos(4*TPC_EP_east)+PsiShiftE3*sin(4*TPC_EP_east))/(float)4; TPC_EP_west_new += 2*(-PsiShiftW2*cos(2*TPC_EP_west)+PsiShiftW1*sin(2*TPC_EP_west))/(float)2 + 2*(-PsiShiftW4*cos(4*TPC_EP_west)+PsiShiftW3*sin(4*TPC_EP_west))/(float)4; TPC_EP_for_new += 2*(-PsiShiftf2*cos(2*TPC_EP_for)+PsiShiftf1*sin(2*TPC_EP_for))/(float)2 + 2*(-PsiShiftf4*cos(4*TPC_EP_for)+PsiShiftf3*sin(4*TPC_EP_for))/(float)4; TPC_EP_bac_new += 2*(-PsiShiftb2*cos(2*TPC_EP_bac)+PsiShiftb1*sin(2*TPC_EP_bac))/(float)2 + 2*(-PsiShiftb4*cos(4*TPC_EP_bac)+PsiShiftb3*sin(4*TPC_EP_bac))/(float)4; if(TPC_EP_east_new>PI) TPC_EP_east_new -= PI; if(TPC_EP_east_new< 0) TPC_EP_east_new += PI; if(TPC_EP_west_new>PI) TPC_EP_west_new -= PI; if(TPC_EP_west_new< 0) TPC_EP_west_new += PI; if(TPC_EP_for_new>PI) TPC_EP_for_new -= PI; if(TPC_EP_for_new< 0) TPC_EP_for_new += PI; if(TPC_EP_bac_new>PI) TPC_EP_bac_new -= PI; if(TPC_EP_bac_new< 0) TPC_EP_bac_new += PI; Hist_TPC_EP_east_flat->Fill(TPC_EP_east_new,Day); Hist_TPC_EP_west_flat->Fill(TPC_EP_west_new,Day); Hist_TPC_EP_for_flat->Fill(TPC_EP_for_new,Day); Hist_TPC_EP_bac_flat->Fill(TPC_EP_bac_new,Day); mQx = mQ1.Mod()*cos(2*TPC_EP_east_new) + mQ2.Mod()*cos(2*TPC_EP_west_new); mQy = mQ1.Mod()*sin(2*TPC_EP_east_new) + mQ2.Mod()*sin(2*TPC_EP_west_new); if(mQx==0 || mQy==0) continue; mQ.Set(mQx, mQy); TPC_EP_full = 0.5*mQ.Phi(); pTPC_EP_full->Fill(1,Day,cos(2*TPC_EP_full)); pTPC_EP_full->Fill(2,Day,sin(2*TPC_EP_full)); pTPC_EP_full->Fill(3,Day,cos(4*TPC_EP_full)); pTPC_EP_full->Fill(4,Day,sin(4*TPC_EP_full)); if(fWgt->IsOpen() && Read_TPC_EP_full->GetEntries()) { PsiShiftF1 = Read_TPC_EP_full->GetBinContent(1,Day-79); PsiShiftF2 = Read_TPC_EP_full->GetBinContent(2,Day-79); PsiShiftF3 = Read_TPC_EP_full->GetBinContent(3,Day-79); PsiShiftF4 = Read_TPC_EP_full->GetBinContent(4,Day-79); } float TPC_EP_full_new = TPC_EP_full; TPC_EP_full_new += 2*(-PsiShiftF2*cos(2*TPC_EP_full)+PsiShiftF1*sin(2*TPC_EP_full))/(float)2 + 2*(-PsiShiftF4*cos(4*TPC_EP_full)+PsiShiftF3*sin(4*TPC_EP_full))/(float)4; if(TPC_EP_full_new>PI) TPC_EP_full_new -= PI; if(TPC_EP_full_new< 0) TPC_EP_full_new += PI; Hist_TPC_EP_full_flat->Fill(TPC_EP_full_new,Day); mQx = mQ.Mod()*cos(2*TPC_EP_full_new); mQy = mQ.Mod()*sin(2*TPC_EP_full_new); Hist_cos->Fill(1,cos(2.*TPC_EP_for_new-2.*TPC_EP_bac_new), Eweight); Hist_cos->Fill(2,cos(2.*TPC_EP_east_new-2.*TPC_EP_west_new), Eweight); Hist_cos_RefMult->Fill(1,RefMult,cos(2.*TPC_EP_for_new-2.*TPC_EP_bac_new), Eweight); Hist_cos_RefMult->Fill(2,RefMult,cos(2.*TPC_EP_east_new-2.*TPC_EP_west_new), Eweight); Hist_cos_TOFMult->Fill(1,TOFMult,cos(2.*TPC_EP_for_new-2.*TPC_EP_bac_new), Eweight); Hist_cos_TOFMult->Fill(2,TOFMult,cos(2.*TPC_EP_east_new-2.*TPC_EP_west_new), Eweight); Hist_cos_ZDC->Fill(1,ZDCe+ZDCw,cos(2.*TPC_EP_for_new-2.*TPC_EP_bac_new), Eweight); Hist_cos_ZDC->Fill(2,ZDCe+ZDCw,cos(2.*TPC_EP_east_new-2.*TPC_EP_west_new), Eweight); Hist_cos_BBC_RefMult->Fill(BBCco,RefMult,cos(2.*TPC_EP_for_new-2.*TPC_EP_bac_new), Eweight); Hist_dif_count->Fill(Ecount - Wcount); Hist_ful_count->Fill(Ecount + Wcount); TPC_Day3_cos2->Fill(Day3, cos(2*TPC_EP_full)); TPC_Day3_sin2->Fill(Day3, sin(2*TPC_EP_full)); /////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //loop through matched primary tracks for(int trki = 0; trki < NPTracks; trki++) { Pt = leaf_PtV0->GetValue(trki); Eta = leaf_EtaV0->GetValue(trki); Theta = 2.*atan(exp(-Eta)); Charge = leaf_ChargeV0->GetValue(trki); Phi = leaf_PhiV0->GetValue(trki); ndEdx = leaf_ndEdxV0->GetValue(trki); DCAGlobal = leaf_DCAglobalV0->GetValue(trki); nSigma_p = leaf_nSigmaPV0->GetValue(trki); nSigma_pi = leaf_nSigmaPiV0->GetValue(trki); float TOFflag = leaf_TofFlagV0->GetValue(trki); float En = sqrt(0.1396*0.1396+pow(Pt*cosh(Eta),2)); float TofYLocal = leaf_TofYLocalV0->GetValue(trki); float TofM2 = leaf_TofM2V0->GetValue(trki); if(DCAGlobal > DcaCut) continue; if(Pt < pt_trig_lo || Pt > pt_trig_up) continue; if(Eta > EtaCut || Eta < -EtaCut) continue; Hist_Pt->Fill(Pt,Eweight); if(TOFflag>0) Hist_Pt_TOF->Fill(Pt,Eweight); if(ndEdx<15||nSigma_pi<-2 || nSigma_pi>2) continue; if(TOFflag<1||TofYLocal<-1.8||TofYLocal>1.8||TofM2<-0.01 || TofM2>0.1) continue; hEtaPtDist->Fill(Eta,Pt,Eweight); //Corrections if(fWgt->IsOpen() && (TPCmean_FF->GetEntries() || TPCmean_RF->GetEntries())) { for(int k=1; k<5; k++) { for(int kk=0; kk<order; kk++) { if(Eta>0 && PVtxz>0) PhiMean[k-1+4*kk] = TPCmean_FF->GetBinContent(k+8*kk,Day2-7999); if(Eta<0 && PVtxz>0) PhiMean[k-1+4*kk] = TPCmean_RF->GetBinContent(k+8*kk,Day2-7999); if(Eta>0 && PVtxz<0) PhiMean[k-1+4*kk] = TPCmean_FF->GetBinContent(k+4+8*kk,Day2-7999); if(Eta<0 && PVtxz<0) PhiMean[k-1+4*kk] = TPCmean_RF->GetBinContent(k+4+8*kk,Day2-7999); } } } float cos1 =0, cos2=0, sin1=0, sin2=0, Phi_new = Phi; // Recentering parameters if(Eta>0 && PVtxz>0) { if(Charge > 0) { for(int kk=0; kk<order; kk++) { pTPCmeanPhi_FF->Fill(1+8*kk,Day2,cos(kk*Phi+Phi),Eweight); pTPCmeanPhi_FF->Fill(2+8*kk,Day2,sin(kk*Phi+Phi),Eweight); } } if(Charge < 0) { for(int kk=0; kk<order; kk++) { pTPCmeanPhi_FF->Fill(3+8*kk,Day2,cos(kk*Phi+Phi),Eweight); pTPCmeanPhi_FF->Fill(4+8*kk,Day2,sin(kk*Phi+Phi),Eweight); } } } if(Eta<0 && PVtxz>0) { if(Charge > 0) { for(int kk=0; kk<order; kk++) { pTPCmeanPhi_RF->Fill(1+8*kk,Day2,cos(kk*Phi+Phi),Eweight); pTPCmeanPhi_RF->Fill(2+8*kk,Day2,sin(kk*Phi+Phi),Eweight); } } if(Charge < 0) { for(int kk=0; kk<order; kk++) { pTPCmeanPhi_RF->Fill(3+8*kk,Day2,cos(kk*Phi+Phi),Eweight); pTPCmeanPhi_RF->Fill(4+8*kk,Day2,sin(kk*Phi+Phi),Eweight); } } } if(Eta>0 && PVtxz<0) { if(Charge > 0) { for(int kk=0; kk<order; kk++) { pTPCmeanPhi_FF->Fill(1+4+8*kk,Day2,cos(kk*Phi+Phi),Eweight); pTPCmeanPhi_FF->Fill(2+4+8*kk,Day2,sin(kk*Phi+Phi),Eweight); } } if(Charge < 0) { for(int kk=0; kk<order; kk++) { pTPCmeanPhi_FF->Fill(3+4+8*kk,Day2,cos(kk*Phi+Phi),Eweight); pTPCmeanPhi_FF->Fill(4+4+8*kk,Day2,sin(kk*Phi+Phi),Eweight); } } } if(Eta<0 && PVtxz<0) { if(Charge > 0) { for(int kk=0; kk<order; kk++) { pTPCmeanPhi_RF->Fill(1+4+8*kk,Day2,cos(kk*Phi+Phi),Eweight); pTPCmeanPhi_RF->Fill(2+4+8*kk,Day2,sin(kk*Phi+Phi),Eweight); } } if(Charge < 0) { for(int kk=0; kk<order; kk++) { pTPCmeanPhi_RF->Fill(3+4+8*kk,Day2,cos(kk*Phi+Phi),Eweight); pTPCmeanPhi_RF->Fill(4+4+8*kk,Day2,sin(kk*Phi+Phi),Eweight); } } } } //Track } // Event rc = (TH1D*)Hist_Pt_TOF->Clone(); rc->SetName("rc"); rc->Divide(Hist_Pt); fout.Write(); char fname_new[200]; sprintf(fname_new,"cen%d.weight_pi_minbias5_new.root",cen); TFile *fWgtNew = new TFile(fname_new,"RECREATE"); pTPCmeanPhi_FF->Write(); pTPCmeanPhi_RF->Write(); Hist_Phi_FF->Write(); Hist_Phi_RF->Write(); pTPC_EP_east->Write(); pTPC_EP_west->Write(); pTPC_EP_for->Write(); pTPC_EP_bac->Write(); pTPC_EP_full->Write(); rc->Write(); fWgtNew->Close(); return; }
void Calc_Eff_200(int cen) { const float PI = TMath::Pi(); const float mean = 0.01166; const float rms = 0.05312; TFile *f1 = new TFile("cen6.ntuple_result_v2_11_subEP_dca1_pt015_eta1_noP_pionDca1_higherEP.root"); TH1* h_pt = (TH1*)f1->Get("Hist_Pt"); float real[9][7] = {{1.68441e+07,1.94857e+07,1.91433e+07,1.76339e+07,1.57031e+07,1.3709e+07,1.18246e+07}, {3.87595e+07,4.43888e+07,4.34577e+07,4.00144e+07,3.57267e+07,3.13252e+07,2.71556e+07}, {8.04378e+07,9.2009e+07,9.01896e+07,8.33911e+07,7.47927e+07,6.59201e+07,5.74707e+07}, {1.28651e+08,1.47865e+08,1.45606e+08,1.3528e+08,1.2199e+08,1.08084e+08,9.47436e+07}, {1.9998e+08,2.31542e+08,2.29316e+08,2.14124e+08,1.94076e+08,1.72786e+08,1.52079e+08}, {2.91541e+08,3.40818e+08,3.39637e+08,3.1877e+08,2.90097e+08,2.59203e+08,2.29072e+08}, {3.94517e+08,4.66796e+08,4.68155e+08,4.41467e+08,4.03254e+08,3.61425e+08,3.20203e+08}, {2.3895e+08,2.85928e+08,2.88314e+08,2.72767e+08,2.49768e+08,2.24261e+08,1.98897e+08}, {2.70925e+08,3.27361e+08,3.31383e+08,3.14285e+08,2.88208e+08,2.5899e+08,2.29898e+08}}; float emrc[9][7] = {{127.287,180.108,180.46,203.105,201.325,185.72,183.217}, {111.057,137.61,163.772,151.6,161.841,157.728,178.696}, {157.959,196.018,206.222,184.609,183.632,238.975,225.804}, {294.14,355.613,355.514,396.844,397.958,385.601,425}, {499,551,666,616,706,750,677}, {715,916,988,992,1031,1047,1070}, {1045,1247,1393,1414,1523,1589,1527}, {653,853,898,928,1016,1073,996}, {863,975,1199,1263,1262,1258,1314}}; const int cenDef[9] = {10, 22, 43, 76, 125, 193, 281, 396, 466}; float Eweight = 1; TChain* chain = new TChain("McV0PicoDst"); int nfile = 0; nfile += chain->Add("output_p/*.root"); nfile += chain->Add("output_pbar/*.root"); // nfile += chain->Add("output_test/*.root"); // nfile += chain->Add("output_km/*.root"); // nfile += chain->Add("output_kp/*.root"); cout <<"Added "<<nfile<<" files"<<endl; cout<<"# entries in chain: "<<chain->GetEntries()<<endl; char fname_out[200]; sprintf(fname_out,"cen%d.eff_200_p.root",cen); TFile fout(fname_out,"RECREATE"); TH1D* Hist_RefMult = new TH1D("Hist_RefMult","Hist_RefMult",500,-0.5,499.5); TH2D* Hist_mc_pt = new TH2D("Hist_mc_pt","Hist_mc_pt",28,0,560,200,0,10); TH1D* Hist_mc_pt_cen = new TH1D("Hist_mc_pt_cen","Hist_mc_pt_cen",200,0,10); TH1D* Hist_mc_pt_L = new TH1D("Hist_mc_pt_L","Hist_mc_pt_Lokesh",200,0,10); TH1D* Hist_mc_eta = new TH1D("Hist_mc_eta","Hist_mc_eta",200,-1,1); TH1D* Hist_rc_flag = new TH1D("Hist_rc_flag","Hist_rc_flag",3000,-1000+0.5,2000.5); TH2D* Hist_rc_pt = new TH2D("Hist_rc_pt","Hist_rc_pt",28,0,560,200,0,10); TH1D* Hist_rc_pt_cen = new TH1D("Hist_rc_pt_cen","Hist_rc_pt_cen",200,0,10); TH1D* Hist_rc_pt_scale = new TH1D("Hist_rc_pt_scale","Hist_rc_pt_scale",200,0,10); TH1D* Hist_rc_pt_L = new TH1D("Hist_rc_pt_L","Hist_rc_pt_Lokesh",200,0,10); TH1D* Hist_rc_eta = new TH1D("Hist_rc_eta","Hist_rc_eta",200,-1,1); TH1D* Hist_rc_dca = new TH1D("Hist_rc_dca","Hist_rc_dca",200,0,20); TH1D* Hist_rc_dca_scale = new TH1D("Hist_rc_dca_scale","Hist_rc_dca_scale",200,0,20); TH1D* Hist_rc_nfit = new TH1D("Hist_rc_nfit","Hist_rc_nfit",100,0,100); TH1D* Hist_rc_rat = new TH1D("Hist_rc_rat","Hist_rc_rat",100,0,2); TH1D* Hist_dphi = new TH1D("Hist_dphi","Hist_dphi",128,-3.2,3.2); TH1D* Hist_dphi1 = new TH1D("Hist_dphi1","Hist_dphi1",128,-3.2,3.2); TH1D* Hist_dphi2 = new TH1D("Hist_dphi2","Hist_dphi2",128,-3.2,3.2); TH1D* Hist_dphi3 = new TH1D("Hist_dphi3","Hist_dphi3",128,-3.2,3.2); TH1D* Hist_dphi4 = new TH1D("Hist_dphi4","Hist_dphi4",128,-3.2,3.2); TH1D* Hist_dphi_pion = new TH1D("Hist_dphi_pion","Hist_dphi_pion",128,-3.2,3.2); TH1D* Hist_ddphi = new TH1D("Hist_ddphi","Hist_ddphi",128,-3.2,3.2); TProfile* p_dphi = new TProfile("p_dphi","p_dphi",4,0.5,4.5,-100,100); TProfile* p_dphi_pt = new TProfile("p_dphi_pt","p_dphi_pt",200,0,10,-100,100); TProfile* p_dphi_L = new TProfile("p_dphi_L","p_dphi_L",4,0.5,4.5,-100,100); TProfile* p_dphi_LM= new TProfile("p_dphi_LM","p_dphi_LM",4,0.5,4.5,-100,100); TProfile* p_dphi_M = new TProfile("p_dphi_M","p_dphi_M",4,0.5,4.5,-100,100); TProfile* p_dphi_RM= new TProfile("p_dphi_RM","p_dphi_RM",4,0.5,4.5,-100,100); TProfile* p_dphi_R = new TProfile("p_dphi_R","p_dphi_R",4,0.5,4.5,-100,100); TProfile* p_ddphi = new TProfile("p_ddphi","p_ddphi",4,0.5,4.5,-100,100); TProfile* p_ddphi_L = new TProfile("p_ddphi_L","p_ddphi_L",4,0.5,4.5,-100,100); TProfile* p_ddphi_LM= new TProfile("p_ddphi_LM","p_ddphi_LM",4,0.5,4.5,-100,100); TProfile* p_ddphi_M = new TProfile("p_ddphi_M","p_ddphi_M",4,0.5,4.5,-100,100); TProfile* p_ddphi_RM= new TProfile("p_ddphi_RM","p_ddphi_RM",4,0.5,4.5,-100,100); TProfile* p_ddphi_R = new TProfile("p_ddphi_R","p_ddphi_R",4,0.5,4.5,-100,100); TH1D* Hist_asym = new TH1D("Hist_asym","Hist_asym",600,-1.5+0.0025,1.5+0.0025); TH1D* Hist_asym_L = new TH1D("Hist_asym_L","Hist_asym_L",600,-1.5+0.0025,1.5+0.0025); TH1D* Hist_asym_LM= new TH1D("Hist_asym_LM","Hist_asym_LM",600,-1.5+0.0025,1.5+0.0025); TH1D* Hist_asym_M = new TH1D("Hist_asym_M","Hist_asym_M",600,-1.5+0.0025,1.5+0.0025); TH1D* Hist_asym_RM= new TH1D("Hist_asym_RM","Hist_asym_RM",600,-1.5+0.0025,1.5+0.0025); TH1D* Hist_asym_R = new TH1D("Hist_asym_R","Hist_asym_R",600,-1.5+0.0025,1.5+0.0025); Int_t nentries = chain->GetEntries(); for(int i = 0; i < nentries; i++){ if((i+1)%1000==0) cout<<"Processing entry == "<< i+1 <<" == out of "<<nentries<<".\n"; chain->GetEntry(i); TLeaf* leaf_RunId = chain->GetLeaf("runnumber"); TLeaf* leaf_RefMult = chain->GetLeaf("nrefmult"); TLeaf* leaf_Px = chain->GetLeaf("primvertexX"); TLeaf* leaf_Py = chain->GetLeaf("primvertexY"); TLeaf* leaf_Pz = chain->GetLeaf("primvertexZ"); TLeaf* leaf_ZDCrate = chain->GetLeaf("zdcrate"); TLeaf* leaf_nmcv0 = chain->GetLeaf("nmcv0"); TLeaf* leaf_nv0 = chain->GetLeaf("nv0"); TLeaf* leaf_Np = chain->GetLeaf("numberP"); TLeaf* leaf_Nn = chain->GetLeaf("numberN"); int Run = leaf_RunId->GetValue(0); int RefMult = leaf_RefMult->GetValue(0); float PVtxz = leaf_Pz->GetValue(0); int NmcTracks = leaf_nmcv0->GetValue(0); int NrcTracks = leaf_nv0->GetValue(0); int Np = leaf_Np->GetValue(0); int Nn = leaf_Nn->GetValue(0); Hist_RefMult->Fill(RefMult); int Centrality = 0; for(int j=0;j<9;j++) if(RefMult>cenDef[j]) Centrality = j+1; if(RefMult) { float gM = 0.9995 + 21.89/(4.191*RefMult-18.17) - 2.723e-5*(4.191*RefMult-18.17); Eweight = gM + 0.0009326*(gM-1)*PVtxz; } if(cen && Centrality != cen) continue; TLeaf* leaf_mc_Pt = chain->GetLeaf("mcv0pt"); TLeaf* leaf_mc_Pz = chain->GetLeaf("mcv0pz"); TLeaf* leaf_mc_Px = chain->GetLeaf("mcv0px"); TLeaf* leaf_mc_Py = chain->GetLeaf("mcv0py"); TLeaf* leaf_mc_id = chain->GetLeaf("mcv0id"); for(int trk = 0; trk < NmcTracks; trk++) { float mc_pt = leaf_mc_Pt->GetValue(trk); float mc_pz = leaf_mc_Pz->GetValue(trk); float mc_theta = atan2(mc_pt,mc_pz); float mc_eta = -log(tan(mc_theta/2)); Hist_mc_eta->Fill(mc_eta, Eweight); if(mc_eta>-0.5 && mc_eta<0.5) {Hist_mc_pt->Fill(RefMult,mc_pt);} if(mc_eta>-1 && mc_eta<1) {Hist_mc_pt_cen->Fill(mc_pt);} if(mc_eta>-0.1 && mc_eta<0.1) Hist_mc_pt_L->Fill(mc_pt, Eweight); } TLeaf* leaf_rc_Pt = chain->GetLeaf("v0pt"); TLeaf* leaf_rc_Phi = chain->GetLeaf("v0phi"); TLeaf* leaf_rc_Eta = chain->GetLeaf("v0eta"); TLeaf* leaf_rc_Charge = chain->GetLeaf("v0charge"); TLeaf* leaf_rc_flag = chain->GetLeaf("v0flag"); TLeaf* leaf_rc_dca = chain->GetLeaf("v0dca"); TLeaf* leaf_rc_Nfithits = chain->GetLeaf("v0nfithits"); TLeaf* leaf_rc_Nmaxhits = chain->GetLeaf("v0nmaxhits"); TLeaf* leaf_rc_Ndedxhits = chain->GetLeaf("v0ndedxhits"); TLeaf* leaf_rc_id = chain->GetLeaf("v0mcid"); for(int trk = 0; trk < NrcTracks; trk++) { int flag = leaf_rc_flag->GetValue(trk); Hist_rc_flag->Fill(flag,Eweight); if(flag<0 || flag>1000) continue; float dca = leaf_rc_dca->GetValue(trk); float rc_pt = leaf_rc_Pt->GetValue(trk); float eta = leaf_rc_Eta->GetValue(trk); int nFitHits = leaf_rc_Nfithits->GetValue(trk); int nMaxHits = leaf_rc_Nmaxhits->GetValue(trk); float ratio = float(nFitHits)/nMaxHits; int ndEdxHits = leaf_rc_Ndedxhits->GetValue(trk); Hist_rc_nfit->Fill(nFitHits, Eweight); Hist_rc_rat->Fill(ratio, Eweight); if(nFitHits<20 || nFitHits>50) continue; if(ratio<0.52 || ratio>1.05) continue; if(dca>2) continue; int ptbin = 0; if(rc_pt>0.2) ptbin = 1; if(rc_pt>0.25) ptbin = 2; if(rc_pt>0.3) ptbin = 3; if(rc_pt>0.35) ptbin = 4; if(rc_pt>0.4) ptbin = 5; if(rc_pt>0.45) ptbin = 6; float ptW = 0.001*real[cen-1][ptbin]/emrc[cen-1][ptbin]; // if((i+1)%1000==0 && rc_pt<0.3 && rc_pt>0.25) cout<<ptW<<endl; Hist_rc_eta->Fill(eta, Eweight); if(rc_pt>0.15 && rc_pt<0.5) {Hist_rc_dca->Fill(dca, Eweight);Hist_rc_dca_scale->Fill(dca, Eweight*ptW);} if(eta>-0.5 && eta<0.5) {Hist_rc_pt->Fill(RefMult,rc_pt);} if(dca<2 && ndEdxHits>14) { if(eta>-1 && eta<1) Hist_rc_pt_cen->Fill(rc_pt); Hist_rc_pt_scale->Fill(rc_pt, Eweight*ptW); } if(dca<3 && nFitHits>=25 &&ndEdxHits>15 && eta>-0.1 && eta<0.1) Hist_rc_pt_L->Fill(rc_pt, Eweight); } ///////ONLY ABOVE THIS LINE IS NEEDED FOR EFFICIENCY/////////////////////////////////////////////////// float Mpt[30], Mdca[30], MndEdxHits[30], Mdphi[30], Mweight[30]; float integral = (float)h_pt->Integral(1,40); float bin_mean = integral/40.; int Mnmatch = 0; for(int trk = 0; trk < NrcTracks; trk++) { int flag = leaf_rc_flag->GetValue(trk); if(flag<0 || flag>1000) continue; float dca = leaf_rc_dca->GetValue(trk); float rc_pt = leaf_rc_Pt->GetValue(trk); float rc_phi = leaf_rc_Phi->GetValue(trk); float rc_charge = leaf_rc_Charge->GetValue(trk); float eta = leaf_rc_Eta->GetValue(trk); if(eta>1 || eta<-1) continue; int nFitHits = leaf_rc_Nfithits->GetValue(trk); int nMaxHits = leaf_rc_Nmaxhits->GetValue(trk); float ratio = float(nFitHits)/nMaxHits; int ndEdxHits = leaf_rc_Ndedxhits->GetValue(trk); if(nFitHits<20 || nFitHits>50) continue; if(ratio<0.52 || ratio>1.05) continue; int rc_id = leaf_rc_id->GetValue(trk); int bin = h_pt->FindBin(rc_pt); float weight = h_pt->GetBinContent(bin)/bin_mean; for(int tr = 0; tr < NmcTracks; tr++) { float mc_px = leaf_mc_Px->GetValue(tr); float mc_py = leaf_mc_Py->GetValue(tr); float mc_phi = atan2(mc_py,mc_px); int mc_id = leaf_mc_id->GetValue(tr); if(mc_id==rc_id) { Mpt[Mnmatch] = rc_pt; Mdca[Mnmatch] = dca; MndEdxHits[Mnmatch] = ndEdxHits; float dphi = rc_phi - mc_phi; if(dphi > PI) dphi -= 2*PI; if(dphi <-PI) dphi += 2*PI; if(rc_pt>0.15 && rc_pt<2) Hist_dphi->Fill(dphi,weight); if(rc_pt>0.15 && rc_pt<0.5) Hist_dphi1->Fill(dphi,weight); else if(rc_pt<1) Hist_dphi2->Fill(dphi,weight); else if(rc_pt<1.5) Hist_dphi3->Fill(dphi,weight); else if(rc_pt<2) Hist_dphi4->Fill(dphi,weight); Mdphi[Mnmatch] = dphi; Mweight[Mnmatch] = weight; Mnmatch++; if(rc_charge>0) Np--; else Nn--; } } } float asym = (float(Np)-float(Nn))/(Np+Nn); Hist_asym->Fill(asym); if(asym<mean-rms) Hist_asym_L->Fill(asym); else if(asym<mean-0.3*rms) Hist_asym_LM->Fill(asym); else if(asym<mean+0.3*rms) Hist_asym_M->Fill(asym); else if(asym<mean+rms) Hist_asym_RM->Fill(asym); else Hist_asym_R->Fill(asym); //cout<<"Nmatch = "<<Mnmatch<<endl; for(int ii=0;ii<Mnmatch;ii++) { float dphi = Mdphi[ii]; if(Mdca[ii]>1) continue; if(MndEdxHits[ii]<=10) continue; p_dphi_pt->Fill(Mpt[ii],100*cos(2*dphi)); if(Mpt[ii]<0.15 || Mpt[ii]>0.5) continue; Hist_dphi_pion->Fill(Mdphi[ii]); p_dphi->Fill(1,100*cos(2*dphi)); p_dphi->Fill(2,100*sin(2*dphi)); if(asym<mean-rms) {p_dphi_L->Fill(3,100*cos(2*dphi)); p_dphi_L->Fill(1,100*cos(2*dphi), Mweight[ii]); p_dphi_L->Fill(4,100*sin(2*dphi)); p_dphi_L->Fill(2,100*sin(2*dphi), Mweight[ii]);} else if(asym<mean-0.3*rms) {p_dphi_LM->Fill(3,100*cos(2*dphi)); p_dphi_LM->Fill(1,100*cos(2*dphi), Mweight[ii]); p_dphi_LM->Fill(4,100*sin(2*dphi)); p_dphi_LM->Fill(2,100*sin(2*dphi), Mweight[ii]);} else if(asym<mean+0.3*rms) {p_dphi_M->Fill(3,100*cos(2*dphi)); p_dphi_M->Fill(1,100*cos(2*dphi), Mweight[ii]); p_dphi_M->Fill(4,100*sin(2*dphi)); p_dphi_M->Fill(2,100*sin(2*dphi), Mweight[ii]);} else if(asym<mean+rms) {p_dphi_RM->Fill(3,100*cos(2*dphi)); p_dphi_RM->Fill(1,100*cos(2*dphi), Mweight[ii]); p_dphi_RM->Fill(4,100*sin(2*dphi)); p_dphi_RM->Fill(2,100*sin(2*dphi), Mweight[ii]);} else {p_dphi_R->Fill(3,100*cos(2*dphi)); p_dphi_R->Fill(1,100*cos(2*dphi), Mweight[ii]); p_dphi_R->Fill(4,100*sin(2*dphi)); p_dphi_R->Fill(2,100*sin(2*dphi), Mweight[ii]);} for(int jj=0;jj<Mnmatch;jj++) { if(ii==jj) continue; if(Mpt[jj]<0.15 || Mpt[jj]>2.0) continue; float ddphi = Mdphi[ii] - Mdphi[jj]; Hist_ddphi->Fill(ddphi); p_ddphi->Fill(1,100*cos(2*ddphi)); p_ddphi->Fill(2,100*sin(2*ddphi)); if(asym<mean-rms) {p_ddphi_L->Fill(3,100*cos(2*ddphi)); p_ddphi_L->Fill(1,100*cos(2*ddphi), Mweight[ii]*Mweight[jj]); p_ddphi_L->Fill(4,100*sin(2*ddphi)); p_ddphi_L->Fill(2,100*sin(2*ddphi), Mweight[ii]*Mweight[jj]);} else if(asym<mean-0.3*rms) {p_ddphi_LM->Fill(3,100*cos(2*ddphi)); p_ddphi_LM->Fill(1,100*cos(2*ddphi), Mweight[ii]*Mweight[jj]); p_ddphi_LM->Fill(4,100*sin(2*ddphi)); p_ddphi_LM->Fill(2,100*sin(2*ddphi), Mweight[ii]*Mweight[jj]);} else if(asym<mean+0.3*rms) {p_ddphi_M->Fill(3,100*cos(2*ddphi)); p_ddphi_M->Fill(1,100*cos(2*ddphi), Mweight[ii]*Mweight[jj]); p_ddphi_M->Fill(4,100*sin(2*ddphi)); p_ddphi_M->Fill(2,100*sin(2*ddphi), Mweight[ii]*Mweight[jj]);} else if(asym<mean+rms) {p_ddphi_RM->Fill(3,100*cos(2*ddphi)); p_ddphi_RM->Fill(1,100*cos(2*ddphi), Mweight[ii]*Mweight[jj]); p_ddphi_RM->Fill(4,100*sin(2*ddphi)); p_ddphi_RM->Fill(2,100*sin(2*ddphi), Mweight[ii]*Mweight[jj]);} else {p_ddphi_R->Fill(3,100*cos(2*ddphi)); p_ddphi_R->Fill(1,100*cos(2*ddphi), Mweight[ii]*Mweight[jj]); p_ddphi_R->Fill(4,100*sin(2*ddphi)); p_ddphi_R->Fill(2,100*sin(2*ddphi), Mweight[ii]*Mweight[jj]);} } } } fout.Write(); return; }
int main(int argc, char* argv[]) { vector<vector<double> >* voltages = new vector<vector<double> >; vector<vector<double> >* currents = new vector<vector<double> >; voltages->resize(52); currents->resize(52); TChain* chain = loadChain(argc, argv); int entries = chain->GetEntries(); cout << entries/2 << " files\n"; for(int i=0; i<entries; i++) { chain->GetEvent(i); for(int slot=0; slot<16; slot++) { TLeaf* vleaf = chain->GetLeaf(("VHS_"+target_card[slot]+".VM."+target_channel[slot]).c_str()); voltages->at(slot).push_back(vleaf->GetValue(0)); TLeaf* ileaf = chain->GetLeaf(("VHS_"+target_card[slot]+".IM."+target_channel[slot]).c_str()); currents->at(slot).push_back(ileaf->GetValue(0)); } for(int slot=0; slot<36; slot++) { if(veto_card[slot]=="4_3") { voltages->at(slot+16).push_back(-1); currents->at(slot+16).push_back(-1); } else { TLeaf* vleaf = chain->GetLeaf(("VHS_"+veto_card[slot]+".VM."+veto_channel[slot]).c_str()); voltages->at(slot+16).push_back(vleaf->GetValue(0)); TLeaf* ileaf = chain->GetLeaf(("VHS_"+veto_card[slot]+".IM."+veto_channel[slot]).c_str()); currents->at(slot+16).push_back(ileaf->GetValue(0)); } } } const double allowed_dv = 100; const double allowed_di = 50e-06; vector<bool> pmt_flags_v; vector<bool> pmt_flags_i; pmt_flags_v.resize(52,0); pmt_flags_i.resize(52,0); for( auto pmt = voltages->begin(); pmt!=voltages->end(); ++pmt ) { double meanvalue = mean(*pmt); double deviation = std_dev(*pmt); //cout << "Mean: " << meanvalue << " Dev: " << deviation << endl; for(auto it2 = (*pmt).begin(); it2!=(*pmt).end(); ++it2) { //cout << distance((*it).begin(), it2) << " "; if( abs(*it2-meanvalue) > allowed_dv ) pmt_flags_v.at( distance(voltages->begin(), pmt) ) = true; } } for( auto pmt = currents->begin(); pmt!=currents->end(); ++pmt ) { double meanvalue = mean(*pmt); double deviation = std_dev(*pmt); for(auto it2 = (*pmt).begin(); it2!=(*pmt).end(); ++it2) if( abs(*it2-meanvalue) > allowed_di ) pmt_flags_i.at( distance(currents->begin(), pmt) ) = true; } bool error = false; // Now if we managed to pick up some flags lets say so for(auto it = pmt_flags_v.begin(); it!=pmt_flags_v.end(); ++it) if(*it==true) { cout << "PMT: " << distance(pmt_flags_v.begin(), it) << " varied VOLTAGE more than " << allowed_dv << " from its mean value" << endl; error = true; } for(auto it = pmt_flags_i.begin(); it!=pmt_flags_i.end(); ++it) if(*it==true) { cout << "PMT: " << distance(pmt_flags_i.begin(), it) << " varied CURRENT more than " << allowed_di << " from its mean value" << endl; error = true; } if(error == true) { cout << ">>> See error.txt for full report <<<" << endl; writeReport(voltages, pmt_flags_v, currents, pmt_flags_i); } delete currents; delete voltages; return 0; }