TENDER becomes Tender
[u/mrichter/AliRoot.git] / PWGLF / totEt / macros / trackMatchingEff.C
1 #ifndef __CINT__
2 #include "TTree.h"
3 #include "TFile.h"
4 #include "TList.h"
5 #include <iostream>
6 #endif
7
8 int trackMatchingEff(TString file = "Et.ESD.simPbPb.PHOS.root")
9 {
10   TFile *f = TFile::Open(file, "READ");
11   if(!f)
12   {
13     std::cout << "Could not open file: " << file << " !" << std::endl;
14     return -1;
15   }
16   
17   TList *l = (TList*)(f->Get("out1"));
18   
19   if(!l)
20   {
21     std::cout << "Could not find list!" << std::endl;
22     return -1;
23   }
24   
25   TTree *primTree = (TTree*)(l->FindObject("fPrimaryTreePhosMC"));
26   
27   if(!primTree)
28   {
29     std::cout << "Could not find tree!" << std::endl;
30     return -1;
31   }
32   
33   
34   TString emSelect = "(fPrimaryCode==22||fPrimaryCode==221||TMath::Abs(fPrimaryCode)==11)";
35   TString chargeSelect = "(fPrimaryCharge!=0 && TMath::Abs(fPrimaryCode)!=11)";
36   TString neutralSelect = "(!"+emSelect+")&&fPrimaryCharge==0&&(!fSecondary)"; 
37   TString secondarySelect = "(fSecondary)";
38   emSelect += "&&(!fSecondary)";
39   chargeSelect += "&&(!fSecondary)";
40   
41   TString matchedSelect = "fPrimaryMatched==1&&";
42   TString notMatchedSelect = "fPrimaryMatched==0&&";
43   
44   
45   int n = primTree->Draw("fDepositedEt", notMatchedSelect+ emSelect);
46   int nRemoved = primTree->Draw("fDepositedEt", matchedSelect + emSelect);
47   std::cout << "EM: " << float(n)/(n+nRemoved) << std::endl;
48   
49   n = primTree->Draw("fDepositedEt", notMatchedSelect+ chargeSelect);
50   nRemoved = primTree->Draw("fDepositedEt", matchedSelect + chargeSelect);
51   std::cout << "Charged: " << float(n)/(n+nRemoved) << std::endl;
52
53   n = primTree->Draw("fDepositedEt", notMatchedSelect+ neutralSelect);
54   nRemoved = primTree->Draw("fDepositedEt", matchedSelect + neutralSelect);
55   std::cout << "Neutral: " << float(n)/(n+nRemoved) << std::endl;
56
57   n = primTree->Draw("fDepositedEt", notMatchedSelect+ secondarySelect);
58   nRemoved = primTree->Draw("fDepositedEt", matchedSelect + secondarySelect);
59   if(n+nRemoved) std::cout << "Secondary: " << float(n)/(n+nRemoved) << std::endl;
60   else std::cout << "No secondaries" << std::endl;
61   return 0;
62   
63   
64 }