ROOT logo
#ifndef __CINT__
#include "TTree.h"
#include "TFile.h"
#include "TList.h"
#include <iostream>
#endif

int trackMatchingEff(TString file = "Et.ESD.simPbPb.PHOS.root")
{
  TFile *f = TFile::Open(file, "READ");
  if(!f)
  {
    std::cout << "Could not open file: " << file << " !" << std::endl;
    return -1;
  }
  
  TList *l = (TList*)(f->Get("out1"));
  
  if(!l)
  {
    std::cout << "Could not find list!" << std::endl;
    return -1;
  }
  
  TTree *primTree = (TTree*)(l->FindObject("fPrimaryTreePhosMC"));
  
  if(!primTree)
  {
    std::cout << "Could not find tree!" << std::endl;
    return -1;
  }
  
  
  TString emSelect = "(fPrimaryCode==22||fPrimaryCode==221||TMath::Abs(fPrimaryCode)==11)";
  TString chargeSelect = "(fPrimaryCharge!=0 && TMath::Abs(fPrimaryCode)!=11)";
  TString neutralSelect = "(!"+emSelect+")&&fPrimaryCharge==0&&(!fSecondary)"; 
  TString secondarySelect = "(fSecondary)";
  emSelect += "&&(!fSecondary)";
  chargeSelect += "&&(!fSecondary)";
  
  TString matchedSelect = "fPrimaryMatched==1&&";
  TString notMatchedSelect = "fPrimaryMatched==0&&";
  
  
  int n = primTree->Draw("fDepositedEt", notMatchedSelect+ emSelect);
  int nRemoved = primTree->Draw("fDepositedEt", matchedSelect + emSelect);
  std::cout << "EM: " << float(n)/(n+nRemoved) << std::endl;
  
  n = primTree->Draw("fDepositedEt", notMatchedSelect+ chargeSelect);
  nRemoved = primTree->Draw("fDepositedEt", matchedSelect + chargeSelect);
  std::cout << "Charged: " << float(n)/(n+nRemoved) << std::endl;

  n = primTree->Draw("fDepositedEt", notMatchedSelect+ neutralSelect);
  nRemoved = primTree->Draw("fDepositedEt", matchedSelect + neutralSelect);
  std::cout << "Neutral: " << float(n)/(n+nRemoved) << std::endl;

  n = primTree->Draw("fDepositedEt", notMatchedSelect+ secondarySelect);
  nRemoved = primTree->Draw("fDepositedEt", matchedSelect + secondarySelect);
  if(n+nRemoved) std::cout << "Secondary: " << float(n)/(n+nRemoved) << std::endl;
  else std::cout << "No secondaries" << std::endl;
  return 0;
  
  
 trackMatchingEff.C:1
 trackMatchingEff.C:2
 trackMatchingEff.C:3
 trackMatchingEff.C:4
 trackMatchingEff.C:5
 trackMatchingEff.C:6
 trackMatchingEff.C:7
 trackMatchingEff.C:8
 trackMatchingEff.C:9
 trackMatchingEff.C:10
 trackMatchingEff.C:11
 trackMatchingEff.C:12
 trackMatchingEff.C:13
 trackMatchingEff.C:14
 trackMatchingEff.C:15
 trackMatchingEff.C:16
 trackMatchingEff.C:17
 trackMatchingEff.C:18
 trackMatchingEff.C:19
 trackMatchingEff.C:20
 trackMatchingEff.C:21
 trackMatchingEff.C:22
 trackMatchingEff.C:23
 trackMatchingEff.C:24
 trackMatchingEff.C:25
 trackMatchingEff.C:26
 trackMatchingEff.C:27
 trackMatchingEff.C:28
 trackMatchingEff.C:29
 trackMatchingEff.C:30
 trackMatchingEff.C:31
 trackMatchingEff.C:32
 trackMatchingEff.C:33
 trackMatchingEff.C:34
 trackMatchingEff.C:35
 trackMatchingEff.C:36
 trackMatchingEff.C:37
 trackMatchingEff.C:38
 trackMatchingEff.C:39
 trackMatchingEff.C:40
 trackMatchingEff.C:41
 trackMatchingEff.C:42
 trackMatchingEff.C:43
 trackMatchingEff.C:44
 trackMatchingEff.C:45
 trackMatchingEff.C:46
 trackMatchingEff.C:47
 trackMatchingEff.C:48
 trackMatchingEff.C:49
 trackMatchingEff.C:50
 trackMatchingEff.C:51
 trackMatchingEff.C:52
 trackMatchingEff.C:53
 trackMatchingEff.C:54
 trackMatchingEff.C:55
 trackMatchingEff.C:56
 trackMatchingEff.C:57
 trackMatchingEff.C:58
 trackMatchingEff.C:59
 trackMatchingEff.C:60
 trackMatchingEff.C:61
 trackMatchingEff.C:62
 trackMatchingEff.C:63
 trackMatchingEff.C:64