AliPhysics  56f1704 (56f1704)
AliEmcalJetUtilityEventSubtractor.cxx
Go to the documentation of this file.
2 #include "AliEmcalJet.h"
3 #include "AliRhoParameter.h"
4 #include "AliEmcalJetTask.h"
5 
7 
8 //______________________________________________________________________________
11  fJetsSubName(""),
12  fParticlesSubName(""),
13  fUseExternalBkg(kFALSE),
14  fRhoName(""),
15  fRhomName(""),
16  fRho(1e-6),
17  fRhom(1e-6),
18  fJetsSub(0x0),
19  fParticlesSub(0x0),
20  fRhoParam(0),
21  fRhomParam(0),
22  fMaxDelR(0)
23 {
24  // Dummy constructor.
25 
26 }
27 
28 //______________________________________________________________________________
30  AliEmcalJetUtility(name),
31  fJetsSubName(""),
32  fParticlesSubName(""),
33  fUseExternalBkg(kFALSE),
34  fRhoName(""),
35  fRhomName(""),
36  fRho(1e-6),
37  fRhom(1e-6),
38  fJetsSub(0x0),
39  fParticlesSub(0x0),
40  fRhoParam(0),
41  fRhomParam(0),
42  fMaxDelR(0)
43 {
44  // Default constructor.
45 }
46 
47 //______________________________________________________________________________
49  AliEmcalJetUtility(other),
53  fRhoName(other.fRhoName),
54  fRhomName(other.fRhomName),
55  fRho(other.fRho),
56  fRhom(other.fRhom),
57  fJetsSub(other.fJetsSub),
59  fRhoParam(other.fRhoParam),
60  fRhomParam(other.fRhomParam)
61 {
62  // Copy constructor.
63 }
64 
65 //______________________________________________________________________________
67 {
68  // Assignment.
69 
70  if (&other == this) return *this;
72  fJetsSubName = other.fJetsSubName;
75  fRhoName = other.fRhoName;
76  fRhomName = other.fRhomName;
77  fRho = other.fRho;
78  fRhom = other.fRhom;
79  fJetsSub = other.fJetsSub;
81  fRhoParam = other.fRhoParam;
82  fRhomParam = other.fRhomParam;
83  return *this;
84 }
85 
86 //______________________________________________________________________________
88 {
89  // Initialize the utility.
90  // Add constituent subtracted jets to event
91  if (!fJetsSubName.IsNull()) {
92  if (!(fJetTask->InputEvent()->FindListObject(fJetsSubName)) ) {
93  fJetsSub = new TClonesArray("AliEmcalJet");
94  fJetsSub->SetName(fJetsSubName);
95  fJetTask->InputEvent()->AddObject(fJetsSub);
96  }
97  else {
98  AliError(Form("%s: Object for subtracted jet branch with name %s already in event! Returning", GetName(), fJetsSubName.Data()));
99  return;
100  }
101  }
102 
103  // Add tracks from constituent subtracted jets to event
104  if (!fParticlesSubName.IsNull()) {
105  if (!(fJetTask->InputEvent()->FindListObject(fParticlesSubName))) {
106  fParticlesSub = new TClonesArray("AliEmcalParticle");
108  fJetTask->InputEvent()->AddObject(fParticlesSub);
109  } else {
110  AliError(Form("%s: Object with name %s already in event! Returning", GetName(), fParticlesSubName.Data()));
111  return;
112  }
113  }
114 
115  if (!fRhoName.IsNull() && !fRhoParam) { // get rho from the event
116  fRhoParam = dynamic_cast<AliRhoParameter*>(fJetTask->InputEvent()->FindListObject(fRhoName));
117  if (!fRhoParam) {
118  AliError(Form("%s: Could not retrieve rho %s!", GetName(), fRhoName.Data()));
119  return;
120  }
121  }
122 
123  if (!fRhomName.IsNull() && !fRhomParam) { // get rhom from the event
124  fRhomParam = dynamic_cast<AliRhoParameter*>(fJetTask->InputEvent()->FindListObject(fRhomName));
125  if (!fRhomParam) {
126  AliError(Form("%s: Could not retrieve rho_m %s!", GetName(), fRhomName.Data()));
127  return;
128  }
129  }
130 
131  // Create particle container in the main jet task so the indices of the constituents
132  // added later are properly mapped by the jet task.
133  // It is safe to create it before the actual jet finding because the underlying array
134  // will be empty until after jet finding.
136 
137  fInit = kTRUE;
138 }
139 
140 //______________________________________________________________________________
142 {
143  // Prepare the utility.
144  if (!fInit) return;
145  if (fRhoParam) fRho = fRhoParam->GetVal();
146  if (fRhomParam) fRhom = fRhomParam->GetVal();
147  if(fRho < 1e-6) {
148  fRho = 1e-6;
149  }
150  if(fRhom < 1e-6) {
151  fRhom = 1e-6;
152  }
153 
154  if (fJetsSub) fJetsSub->Delete();
155  fjw.SetEventSub(kTRUE);
156  fjw.SetMaxDelR(fMaxDelR);
158 }
159 
160 //______________________________________________________________________________
162 {
163  // Prepare the utility.
164 
165 }
166 
167 //______________________________________________________________________________
169 {
170  // Process each jet.
171 }
172 
173 //______________________________________________________________________________
175 {
176  // Run termination of the utility (after each event).
177 
178  if (!fInit) return;
179 
180  if (!fJetsSub) {
181  AliWarning(Form("No jet branch to write to for subtracted jets. fJetsSubName: %s", fJetsSubName.Data()));
182  return;
183  }
184 
185 #ifdef FASTJET_VERSION
186  std::vector<fastjet::PseudoJet> jets_event_sub;
187  jets_event_sub = fjw.GetEventSubJets();
188  AliDebug(1,Form("%d event constituent subtracted jets found", (Int_t)jets_event_sub.size()));
189  for (UInt_t ijet = 0, jetCount = 0; ijet < jets_event_sub.size(); ++ijet) {
190  //printf("Jet pt = %f, area = %f", jets_event_sub[ijet].perp(), fjw.GetEventSubJetArea(ijet));
191  //Only storing 4-vector and jet area of unsubtracted jet
192  if(jets_event_sub[ijet].E()>0.) {
193  AliEmcalJet *jet_event_sub = new ((*fJetsSub)[ijet])
194  AliEmcalJet(jets_event_sub[ijet].perp(), jets_event_sub[ijet].eta(), jets_event_sub[ijet].phi(), jets_event_sub[ijet].m());
195  jet_event_sub->SetLabel(ijet);
196  jet_event_sub->SetJetAcceptanceType(fJetTask->FindJetAcceptanceType(jet_event_sub->Eta(), jet_event_sub->Phi_0_2pi(), fJetTask->GetRadius()));
197 
198  fastjet::PseudoJet area(fjw.GetEventSubJetAreaVector(ijet));
199  jet_event_sub->SetArea(area.perp()); //changed from area.perp()
200  jet_event_sub->SetAreaEta(area.eta());
201  jet_event_sub->SetAreaPhi(area.phi());
202  jet_event_sub->SetAreaEmc(area.perp());
203 
204  // Fill constituent info
205  std::vector<fastjet::PseudoJet> constituents_sub = jets_event_sub[ijet].constituents();
206  fJetTask->FillJetConstituents(jet_event_sub, constituents_sub, constituents_sub, 1, fParticlesSubName);
207  jetCount++;
208  }
209  }
210 
211 #endif
212 
213 }
214 
fastjet::PseudoJet GetEventSubJetAreaVector(UInt_t idx) const
void SetUseExternalBkg(Bool_t b, Double_t rho, Double_t rhom)
Definition: AliFJWrapper.h:139
AliEmcalJetUtility & operator=(const AliEmcalJetUtility &jet)
Double_t Eta() const
Definition: AliEmcalJet.h:121
TClonesArray * fParticlesSub
subtracted jet collection
void SetArea(Double_t a)
Definition: AliEmcalJet.h:256
Double_t GetRadius()
AliEmcalJetUtilityEventSubtractor & operator=(const AliEmcalJetUtilityEventSubtractor &jet)
void SetLabel(Int_t l)
Definition: AliEmcalJet.h:255
void SetJetAcceptanceType(UInt_t type)
Definition: AliEmcalJet.h:366
UInt_t FindJetAcceptanceType(Double_t eta, Double_t phi, Double_t r)
int Int_t
Definition: External.C:63
unsigned int UInt_t
Definition: External.C:33
void ProcessJet(AliEmcalJet *jet, Int_t ij, AliFJWrapper &fjw)
AliParticleContainer * AddParticleContainer(const char *n)
Create new particle container and attach it to the task.
Double_t Phi_0_2pi() const
Definition: AliEmcalJet.h:129
const std::vector< fastjet::PseudoJet > & GetEventSubJets() const
Definition: AliFJWrapper.h:35
AliEmcalJetTask * fJetTask
void SetAreaEta(Double_t a)
Definition: AliEmcalJet.h:257
void SetMaxDelR(Double_t r)
Definition: AliFJWrapper.h:144
void FillJetConstituents(AliEmcalJet *jet, std::vector< fastjet::PseudoJet > &constituents, std::vector< fastjet::PseudoJet > &constituents_sub, Int_t flag=0, TString particlesSubName="")
Represent a jet reconstructed using the EMCal jet framework.
Definition: AliEmcalJet.h:51
void SetEventSub(Bool_t b)
Definition: AliFJWrapper.h:143
void SetAreaPhi(Double_t a)
Definition: AliEmcalJet.h:258
AliRhoParameter * fRhoParam
subtracted particle collection
void SetAreaEmc(Double_t a)
Definition: AliEmcalJet.h:260