AliPhysics  fde8a9f (fde8a9f)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliAnalysisTaskPrepareInputForEmbedding.cxx
Go to the documentation of this file.
1 #include <TTree.h>
2 #include <TLorentzVector.h>
3 
4 #include <AliLog.h>
5 #include <AliEmcalJet.h>
6 #include <AliAnalysisManager.h>
7 #include <TFile.h>
8 #include <THnSparse.h>
9 #include "AliJetContainer.h"
11 
12 
14 
15 //________________________________________________________________________________________________
17 fContainer(0),
18 fMinFractionShared(-1),
19 fLeadingJetOnly(0),
20 fHardCoreTag(0),
21 fTreeJets(0),
22 fJetDet(0),
23 fJetPart(0),
24 fJetDetL(0),
25 fJetPartL(0),
26 fNumberOfJets(0),
27 fhFractionSharedpT(0),
28 fNAccJets(0),
29 fhResponse(0)
30 {
32 
33  SetMakeGeneralHistograms(kTRUE);
34 
35  DefineOutput(2, TTree::Class());
36 }
37 
38 //________________________________________________________________________________________________
40 fContainer(0),
41 fMinFractionShared(-1),
42 fLeadingJetOnly(0),
43 fHardCoreTag(0),
44 fTreeJets(0),
45 fJetDet(0),
46 fJetPart(0),
47 fJetDetL(0),
48 fJetPartL(0),
49 fNumberOfJets(0),
50 fhFractionSharedpT(0),
51 fNAccJets(0),
52 fhResponse(0)
53 
54 {
56 
58  AliInfo("standard constructor");
59  DefineOutput(2, TTree::Class());
60 }
61 //________________________________________________________________________________________________
62 
66 
67  fJetDet = new TLorentzVector();
68  fJetPart = new TLorentzVector();
69  fJetDetL = new TLorentzVector();
70  fJetPartL = new TLorentzVector();
71 
72  fTreeJets = new TTree(Form("fTreeJet%s%s", fLeadingJetOnly ? "Lj" : "", fHardCoreTag ? "HC" : ""), "fTreeJet");
73  //Important! 'dot' after the name needed -- see TTree doc! otherwise the objects in the branches have all the same name and the output cannot be properly retrieved (only with the TBrowser)
74  if(fLeadingJetOnly){
75  fTreeJets->Branch("fJetDetL.", fJetDetL);
76  fTreeJets->Branch("fJetPartL.",fJetPartL);
77  } else {
78  fTreeJets->Branch("fJetDet.", fJetDet);
79  fTreeJets->Branch("fJetPart.",fJetPart);
80  }
81  //fOutput->Add(fTreeJets);
82  PostData(2, fTreeJets);
83 
84  //check
85  const Int_t nBinsPt = 40;
86  const Int_t nBinsFraction = 101;
87  const Int_t nBinsfineM = 200;
88  const Int_t nBinsfinePt = 200;
89 
90  const Double_t minPt = 0.;
91  const Double_t maxPt = 200.;
92  const Double_t minM = 0.;
93  const Double_t maxM = 50.;
94  const Double_t minFraction = -0.005;
95  const Double_t maxFraction = 1.005;
96 
97  fNumberOfJets = new TH1F("fNumberOfJets", "Number of Jets", 6, -0.5, 5.5);
98  fOutput->Add(fNumberOfJets);
99 
100  fhFractionSharedpT = new TH2F("fhFractionSharedpT", "Reco/particle shared #it{p}_{T} fraction;#it{p}_{T} (GeV/c); Fraction shared #it{p}_{T}", nBinsPt, minPt, maxPt, nBinsFraction, minFraction, maxFraction);
102 
103  fNAccJets = new TH1F("fNAccJets","fNAccJets;N/ev",11,-0.5, 9.5);
104  fOutput->Add(fNAccJets);
105 
106  const Int_t dim = 5;
107  Int_t nBins[dim] = {nBinsfineM, nBinsfineM, nBinsfinePt, nBinsfinePt, 40};
108  Double_t xmin[dim] = {minM, minM, minPt, minPt, 0.};
109  Double_t xmax[dim] = {maxM, maxM, maxPt, maxPt, 2.};
110  TString hsptitle = "Mass-pT response; #it{M}_{part}; #it{M}_{det}; #it{p}_{T,part}; #it{p}_{T,det}; #it{N}_{const}^{det}/#it{N}_{const}^{part}";
111  fhResponse = new THnSparseF("hResponse", hsptitle.Data(), dim, nBins, xmin, xmax);
112  fOutput->Add(fhResponse);
113 
114 }
115 
116 
117 //________________________________________________________________________________________________
120 
121  //TTree *tree = AliAnalysisManager::GetAnalysisManager()->GetTree();
122  //if (!tree) {
123  // AliError(Form("%s : No current tree!",GetName()));
124  // return kFALSE;
125  //}
126  //TFile *curfile = tree->GetCurrentFile();
127  //if (!curfile) {
128  // AliError(Form("%s : No current file!",GetName()));
129  // return kFALSE;
130  //}
131  //PythiaInfoFromFile(curfile->GetName(), fXsec, fNtrials, fPthardB);
132 
133  return kTRUE;
134 }
135 //________________________________________________________________________________________________
139 
140  // Get container with area-based subtraction
141  AliEmcalJet* jet = NULL;
143  if(!jetCont) {
144  AliError(Form("Container position %d (area based) not found", fContainer));
145  return kFALSE;
146  }
147  //TVector for leading jet
148  fJetDetL ->SetPtEtaPhiM(0,0,0,0);
149  fJetPartL->SetPtEtaPhiM(0,0,0,0);
150 
151  Int_t count = 0;
152  jetCont->ResetCurrentID();
153 
154  while((jet = jetCont->GetNextJet())) {
155  UInt_t rejectionReason = 0;
156  Bool_t acc = jetCont->AcceptJet(jet, rejectionReason);
157  if(!acc) {
158  continue;
159  }
160  //jet hard core tagging (if requested)
161  if(fHardCoreTag && jet->GetTagStatus()<1 && !jet->GetTaggedJet()) continue;
162 
163  fJetDet ->SetPtEtaPhiM(0,0,0,0);
164  fJetPart ->SetPtEtaPhiM(0,0,0,0);
165 
166  count++;
167  fNumberOfJets->Fill(0.);
168 
169  AliEmcalJet *jetP = jet->ClosestJet();
170  if(!jetP) continue;
171  fNumberOfJets->Fill(1.);
172  Double_t fraction = jetCont->GetFractionSharedPt(jet);
173  //fill the TLorentsVectors with the jet 4-vectors
174  //Printf("MC jet %p, Fraction %.4f, pT %f, eta %f, phi %f, m %f",jetP, fraction, jet->Pt(), jet->Eta(), jet->Phi(), jet->M());
175  fhFractionSharedpT->Fill(jet->Pt(), fraction);
176  if(fMinFractionShared<0. || fraction>fMinFractionShared) {
177  fNumberOfJets->Fill(2.);
178  fJetDet ->SetPtEtaPhiM(jet->Pt(), jet->Eta(), jet->Phi(), jet->M());
179  fJetPart->SetPtEtaPhiM(jetP->Pt(), jetP->Eta(), jetP->Phi(), jetP->M());
180 
181  if(fJetDet->Pt() > fJetDetL->Pt()){
182  fJetDetL->SetPtEtaPhiM(fJetDet->Pt(), fJetDet->Eta(), fJetDet->Phi(), fJetDet->M());
183  fJetPartL->SetPtEtaPhiM(fJetPart->Pt(), fJetPart->Eta(), fJetPart->Phi(), fJetPart->M());
184 
185  }
186  if(!fLeadingJetOnly) fTreeJets->Fill();
187 
188  Double_t response[5] = {jetP->M(), jet->M(), jetP->Pt(), jet->Pt(), (Double_t)jet->GetNumberOfConstituents()/(Double_t)jetP->GetNumberOfConstituents()};
189  fhResponse->Fill(response);
190  }
191 
192  }
193  fNAccJets->Fill(count);
194 
195  if(fLeadingJetOnly) {
196  if(fJetPartL->Pt() > 0){ // fill only when there is a leading jet
197  fTreeJets->Fill();
198  }
199  }
200 
201  return kTRUE;
202 }
203 
204 
205 //________________________________________________________________________________________________
206 
209 
210  }
211 
212 //________________________________________________________________________________________________
213 
215 {
217 
218 }
double Double_t
Definition: External.C:58
AliEmcalJet * GetTaggedJet() const
Definition: AliEmcalJet.h:223
Definition: External.C:236
AliEmcalJet * ClosestJet() const
Definition: AliEmcalJet.h:213
AliJetContainer * GetJetContainer(Int_t i=0) const
Int_t GetTagStatus() const
Definition: AliEmcalJet.h:224
Double_t Eta() const
Definition: AliEmcalJet.h:108
Double_t Phi() const
Definition: AliEmcalJet.h:104
Bool_t fHardCoreTag
Request also hard-core tagging of the det level jet (requires tagging task to be run). Default is off.
virtual Bool_t AcceptJet(Int_t i, UInt_t &rejectionReason) const
TH1F * fNumberOfJets
! histograms with number of jets selected
UShort_t GetNumberOfConstituents() const
Definition: AliEmcalJet.h:127
Save in a TTree the 4-momentum vector of the jets at reco and particle level.
int Int_t
Definition: External.C:63
unsigned int UInt_t
Definition: External.C:33
Double_t fMinFractionShared
minimum pT fraction shared between reco and part level jets
Double_t Pt() const
Definition: AliEmcalJet.h:96
AliEmcalJet * GetNextJet()
TH2F * fhFractionSharedpT
! histogram pT jet (area based), fraction shared pT with Pythia jet
AliEmcalList * fOutput
!output list
void SetMakeGeneralHistograms(Bool_t g)
Base task in the EMCAL jet framework.
TLorentzVector * fJetPartL
! particle level leading jet
Represent a jet reconstructed using the EMCal jet framework.
Definition: AliEmcalJet.h:44
TLorentzVector * fJetDetL
! reconstucted leading jet
Double_t GetFractionSharedPt(const AliEmcalJet *jet, AliParticleContainer *cont2=0x0) const
const char Option_t
Definition: External.C:48
ClassImp(AliAnalysisTaskPrepareInputForEmbedding) AliAnalysisTaskPrepareInputForEmbedding
TTree * fTreeJets
! tree with the TLorentzVector of the jet detector and particle level
bool Bool_t
Definition: External.C:53
Double_t M() const
Definition: AliEmcalJet.h:107
Bool_t fLeadingJetOnly
fill TTrees with leading jet only
Container for jet within the EMCAL jet framework.