ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/cbrown/Development/Plotting/Modules/FSRStudy.C
(Generate patch)

Comparing UserCode/cbrown/Development/Plotting/Modules/FSRStudy.C (file contents):
Revision 1.2 by buchmann, Mon Oct 15 11:53:03 2012 UTC vs.
Revision 1.3 by buchmann, Mon Oct 15 22:12:14 2012 UTC

# Line 220 | Line 220 | void GenPhotons::EfficiencyPurity() {
220   //    binPt.push_back(0);binPt.push_back(1000);binPt.push_back(1001);
221      
222      
223 <    TH2F *dR_FSR   = PhotonSamples.Draw("dR_FSR",  "genPhotonsPt:min(genPhotonsdR1,genPhotonsdR2)", bindR, binPt,"min DR","#gamma pT",BaseCut && FSRcut   ,mc,PlottingSetup::luminosity, PhotonSamples.FindSample("o"),false);
224 <    TH2F *dR_Any  = PhotonSamples.Draw("dR_Any", "genPhotonsPt:min(genPhotonsdR1,genPhotonsdR2)",bindR,binPt, "min DR","#gamma pT",BaseCut  ,mc,PlottingSetup::luminosity, PhotonSamples.FindSample("o"),false);
225 <    
226 <    TGraph *purity[dR_FSR->GetNbinsY()+1];
227 <    TGraph *efficiency[dR_FSR->GetNbinsY()+1];
228 <    TGraph *purity_n_efficiency[dR_FSR->GetNbinsY()+1];
229 <    for(int i=1;i<dR_FSR->GetNbinsY();i++) {
230 <        //do this for each pt range
231 <        int NPhotons=0;
232 <        int NFSRPhotons=0;
233 <        int totalNFSRphotons=0;
234 <        for(int k=1;k<dR_FSR->GetNbinsX();k++) totalNFSRphotons+=dR_FSR->GetBinContent(k,i);
235 <        cout << i << " : " << totalNFSRphotons << " FSR photons in pt range " << dR_FSR->GetYaxis()->GetBinLowEdge(i) << " , " << dR_FSR->GetYaxis()->GetBinLowEdge(i)+dR_FSR->GetYaxis()->GetBinWidth(i) << endl;
236 <        purity[i-1]=new TGraph(dR_FSR->GetNbinsX());
237 <        efficiency[i-1]=new TGraph(dR_FSR->GetNbinsX());
238 <        purity_n_efficiency[i-1]=new TGraph(dR_FSR->GetNbinsX());
239 <        for(int j=1;j<=dR_FSR->GetNbinsX();j++) {
240 <            NPhotons+=dR_Any->GetBinContent(j,i);
241 <            NFSRPhotons+=dR_FSR->GetBinContent(j,i);
242 <
243 < //            cout << "For the pt range " << dR_FSR->GetYaxis()->GetBinLowEdge(i) << " , " << dR_FSR->GetYaxis()->GetBinLowEdge(i)+dR_FSR->GetYaxis()->GetBinWidth(i) << " we find a purity of " << (float)NFSRPhotons/NPhotons << " and an efficiency of " << (float)NFSRPhotons/totalNFSRphotons << endl;
244 <            cout << "       ::::::::" << j << " : " << NPhotons << " : " << NFSRPhotons << " : " << totalNFSRphotons << endl;
245 < /*            if(NPhotons>0) purity[i-1]->SetPoint(j-1,dR_FSR->GetXaxis()->GetBinCenter(j)+dR_FSR->GetBinWidth(j),(float)NFSRPhotons/NPhotons);
246 <            else purity[i-1]->SetPoint(j-1,dR_FSR->GetXaxis()->GetBinCenter(j)+dR_FSR->GetBinWidth(j),-1);
247 <            if(totalNFSRphotons>0) efficiency[i-1]->SetPoint(j,dR_FSR->GetXaxis()->GetBinCenter(j)+dR_FSR->GetBinWidth(j),(float)NFSRPhotons/totalNFSRphotons);
248 <            else efficiency[i-1]->SetPoint(j-1,dR_FSR->GetXaxis()->GetBinCenter(j)+dR_FSR->GetBinWidth(j),-1);
249 <         //   if(NPhotons>0 && totalNFSRphotons>0) purity_n_efficiency->SetPoint(j-1,(float)NFSRPhotons/totalNFSRphotons,(float)NFSRPhotons/NPhotons);
250 <         //   else purity_n_efficiency->SetPoint(j-1,-1,-1);*/
223 >    TGraph *purity[binPt.size()];
224 >    TGraph *efficiency[binPt.size()];
225 >    TGraph *purity_n_efficiency[binPt.size()];
226 >    TH1F *FSR[binPt.size()];
227 >    TH1F *Any[binPt.size()];
228 >    for(int i=1;i<binPt.size();i++) {
229 >       //do this for each pt range
230 >       float ptlow=binPt[i-1];
231 >       float pthi =binPt[i];
232 >       stringstream ptcut;
233 >       ptcut << "genPhotonsPt>" << ptlow << " && genPhotonsPt<" << pthi << " && min(genPhotonsdR1,genPhotonsdR2)<5";
234 >      
235 >       FSR[i-1]  = PhotonSamples.Draw("FSR", "min(genPhotonsdR1,genPhotonsdR2)", bindR,"min DR","events",TCut(ptcut.str().c_str()) && BaseCut && FSRcut ,mc,PlottingSetup::luminosity);
236 >       Any[i-1]  = PhotonSamples.Draw("Any", "min(genPhotonsdR1,genPhotonsdR2)", bindR,"min DR","events",TCut(ptcut.str().c_str()) && BaseCut  ,mc,PlottingSetup::luminosity);
237 >      
238 >       float NPhotons=0;
239 >       float NFSRPhotons=0;
240 >       float totalNFSRphotons=0;
241 >      
242 >       for(int k=1;k<FSR[i-1]->GetNbinsX();k++) totalNFSRphotons+=FSR[i-1]->GetBinContent(k);
243 >       cout << i << " : " << totalNFSRphotons << " FSR photons in pt range " << ptlow << " , " << pthi << endl;
244 >       purity[i-1]=new TGraph(FSR[i-1]->GetNbinsX());
245 >       efficiency[i-1]=new TGraph(FSR[i-1]->GetNbinsX());
246 >       purity_n_efficiency[i-1]=new TGraph(FSR[i-1]->GetNbinsX());
247 >       for(int j=1;j<=FSR[i-1]->GetNbinsX();j++) {
248 >         NPhotons+=(int)Any[i-1]->GetBinContent(j);
249 >         NFSRPhotons+=FSR[i-1]->GetBinContent(j);
250 > //            cout << "       ::::::::" << j << " : " << NPhotons << " : " << NFSRPhotons << " : " << totalNFSRphotons << endl;
251 >            if(NPhotons>0) purity[i-1]->SetPoint(j-1,FSR[i-1]->GetXaxis()->GetBinCenter(j)+FSR[i-1]->GetBinWidth(j),(float)NFSRPhotons/NPhotons);
252 >            else purity[i-1]->SetPoint(j-1,FSR[i-1]->GetXaxis()->GetBinCenter(j)+FSR[i-1]->GetBinWidth(j),-1);
253 >            if(totalNFSRphotons>0) efficiency[i-1]->SetPoint(j,FSR[i-1]->GetXaxis()->GetBinCenter(j)+FSR[i-1]->GetBinWidth(j),(float)NFSRPhotons/totalNFSRphotons);
254 >            else efficiency[i-1]->SetPoint(j-1,FSR[i-1]->GetXaxis()->GetBinCenter(j)+FSR[i-1]->GetBinWidth(j),-1);
255 >            if(totalNFSRphotons>0&&NPhotons>0) purity_n_efficiency[i-1]->SetPoint(j-1,(float)NFSRPhotons/totalNFSRphotons,(float)NFSRPhotons/NPhotons);
256          }
257          cout << "Done for pt range" << endl;
258      }
259      cout << "Done with graphs" << endl;
260 <    TFile *f = new TFile("out.root","RECREATE");
261 <    dR_Any->Write();
262 <    dR_FSR->Write();
263 <    f->Close();
259 <    cout << "Artificially aborting ... " << endl;return;
260 <    for(int i=0;i<dR_FSR->GetNbinsY();i++) {
260 > //    cout << "Artificially aborting ... " << endl;return;
261 >    for(int i=0;i<binPt.size()-1;i++) {
262 >      cout << "About to draw purity for i=" << i << endl;
263 >      cout << "( this corresponds to the Pt range from " << binPt[i] << " to " << binPt[i+1] << ")" << endl;
264          if(i==0) purity[i]->Draw("AC");
265          else purity[i]->Draw("C");
266      }
267      CompleteSave(can,"PhotonStudies/Purity");
268      
269 <    for(int i=0;i<dR_FSR->GetNbinsY();i++) {
269 >    for(int i=0;i<binPt.size()-1;i++) {
270 >      cout << "About to draw efficiency for i=" << i << endl;
271          if(i==0) efficiency[i]->Draw("AC");
272          else efficiency[i]->Draw("C");
273      }
274      CompleteSave(can,"PhotonStudies/Efficiency");
275      
276 <    for(int i=0;i<dR_FSR->GetNbinsY();i++) {
276 >    for(int i=0;i<binPt.size()-1;i++) {
277          if(i==0) purity_n_efficiency[i]->Draw("AC");
278          else purity_n_efficiency[i]->Draw("C");
279      }
280      CompleteSave(can,"PhotonStudies/Purity_n_efficiency");
277    
278    dR_FSR->Draw("COLZ");
279    CompleteSave(can,"PhotonStudies/dR_Pt_Diag_FSR");
280    dR_Any->Draw("COLZ");
281    CompleteSave(can,"PhotonStudies/dR_Pt_Diag_Any");
282    
283    
281   }
282  
283  
# Line 288 | Line 285 | void GenPhotons::GenLevelStudies() {
285      TCut essential_bkp = essentialcut;
286      essentialcut=TCut("");
287      
288 <  CompareZmassToFinalStateLeptons();
289 <  NumberOfPhotonsPerEvent();
290 <  CharacterizingFSRPhotons();
291 <  CompareGenJZBDistributions();
292 <  dR2DPlots();
288 > //  CompareZmassToFinalStateLeptons();
289 > //  NumberOfPhotonsPerEvent();
290 > //  CharacterizingFSRPhotons();
291 > //  CompareGenJZBDistributions();
292 > //  dR2DPlots();
293      
294    EfficiencyPurity();
295    

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines