void flux(){ TChain ch("PSFlux_Tree"); int runs[240]; //ifstream in("runs.dat"); ifstream in("runs_all.dat"); for (int i=0;i<240;i++){ in >> runs[i]; } in.close(); char myfile[200]; for (int j=0;j<240;j++){ for (int i=0;i<5;i++){ sprintf(myfile,"/cache/halld/offline_monitoring/RunPeriod-2017-01/ver11/tree_PSFlux/030%d/tree_PSFlux_030%d_00%d.root",runs[j],runs[j],i); ch.Add(myfile); } } TCut c5="abs(PSCtimeL-PSCtimeR)<2.&&abs(PStimeL-PStimeR)<2."; TCut c1="abs(0.5*(PSCtimeL+PSCtimeR)-0.5*(PStimeL+PStimeR))<2"; TCut c2h="abs(PSPairEnergy-TAGHenergy)<0.1"; TCut c2m="abs(PSPairEnergy-TAGMenergy-0.02276)<0.1"; TCut c3m="abs(0.5*(PStimeL+PStimeR)-TAGMtime-0.28)<2"; TCut c3h="abs(0.5*(PStimeL+PStimeR)-TAGHtime)<2"; TCut c4m="abs(0.5*(PStimeL+PStimeR)-TAGMtime-0.28-8.)<2"; TCut c4h="abs(0.5*(PStimeL+PStimeR)-TAGHtime-8.)<2"; TH1D *hm=new TH1D("hm","PS,taggerM coincidences",24,7.0,11.8); TH1D *accm=new TH1D("accm","PS,taggerM accidental coincidences",24,7.0,11.8); TH1D *hh=new TH1D("hh","PS,taggerH coincidences",24,7.0,11.8); TH1D *acch=new TH1D("acch","PS,taggerH accidental coincidences",24,7.0,11.8); ch.Draw("TAGMenergy>>hm",c1&&c2m&&c3m&&c5); ch.Draw("TAGMenergy>>accm",c1&&c2m&&c4m&&c5,"same"); ch.Draw("TAGHenergy>>hh",(c1&&c2h&&c3h&&c5)); ch.Draw("TAGHenergy>>acch",(c1&&c2h&&c4h&&c5),"same"); hh->Add(hm); acch->Add(accm); hh->Draw(); acch->Draw(); ofstream out("ps_flux.dat"); for (int j=1;j<=24;j++){ out << hh->GetBinContent(j)-acch->GetBinContent(j) << endl; } out.close(); }