AliPhysics  2c6b7ad (2c6b7ad)
AliEmcalJetUtilityConstSubtractor.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 {
23  // Dummy constructor.
24 
25 }
26 
27 //______________________________________________________________________________
29  AliEmcalJetUtility(name),
30  fJetsSubName(""),
31  fParticlesSubName(""),
32  fUseExternalBkg(kFALSE),
33  fRhoName(""),
34  fRhomName(""),
35  fRho(1e-6),
36  fRhom(1e-6),
37  fJetsSub(0x0),
38  fParticlesSub(0x0),
39  fRhoParam(0),
40  fRhomParam(0),
41  fAlpha(0),
42  fMaxDelR(-1)
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  fAlpha(0),
62  fMaxDelR(-1)
63 {
64  // Copy constructor.
65 }
66 
67 //______________________________________________________________________________
69 {
70  // Assignment.
71 
72  if (&other == this) return *this;
74  fJetsSubName = other.fJetsSubName;
77  fRhoName = other.fRhoName;
78  fRhomName = other.fRhomName;
79  fRho = other.fRho;
80  fRhom = other.fRhom;
81  fJetsSub = other.fJetsSub;
83  fRhoParam = other.fRhoParam;
84  fRhomParam = other.fRhomParam;
85  return *this;
86 }
87 
88 //______________________________________________________________________________
90 {
91  // Initialize the utility.
92  // Add constituent subtracted jets to event
93  if (!fJetsSubName.IsNull()) {
94  if (!(fJetTask->InputEvent()->FindListObject(fJetsSubName)) ) {
95  fJetsSub = new TClonesArray("AliEmcalJet");
96  fJetsSub->SetName(fJetsSubName);
97  fJetTask->InputEvent()->AddObject(fJetsSub);
98  }
99  else {
100  AliError(Form("%s: Object for subtracted jet branch with name %s already in event! Returning", GetName(), fJetsSubName.Data()));
101  return;
102  }
103  }
104 
105  // Add tracks from constituent subtracted jets to event
106  if (!fParticlesSubName.IsNull()) {
107  if (!(fJetTask->InputEvent()->FindListObject(fParticlesSubName))) {
108  fParticlesSub = new TClonesArray("AliEmcalParticle");
110  fJetTask->InputEvent()->AddObject(fParticlesSub);
111  } else {
112  AliError(Form("%s: Object with name %s already in event! Returning", GetName(), fParticlesSubName.Data()));
113  return;
114  }
115  }
116 
117  if (!fRhoName.IsNull() && !fRhoParam) { // get rho from the event
118  fRhoParam = dynamic_cast<AliRhoParameter*>(fJetTask->InputEvent()->FindListObject(fRhoName));
119  if (!fRhoParam) {
120  AliError(Form("%s: Could not retrieve rho %s!", GetName(), fRhoName.Data()));
121  return;
122  }
123  }
124 
125  if (!fRhomName.IsNull() && !fRhomParam) { // get rhom from the event
126  fRhomParam = dynamic_cast<AliRhoParameter*>(fJetTask->InputEvent()->FindListObject(fRhomName));
127  if (!fRhomParam) {
128  AliError(Form("%s: Could not retrieve rho_m %s!", GetName(), fRhomName.Data()));
129  return;
130  }
131  }
132 
133  // Create particle container in the main jet task so the indices of the constituents
134  // added later are properly mapped by the jet task.
135  // It is safe to create it before the actual jet finding because the underlying array
136  // will be empty until after jet finding.
138 
139  fInit = kTRUE;
140 }
141 
142 //______________________________________________________________________________
144 {
145  // Prepare the utility.
146 
147 }
148 
149 //______________________________________________________________________________
151 {
152  // Prepare the utility.
153 
154  if (!fInit) return;
155 
156  if (fRhoParam) fRho = fRhoParam->GetVal();
157  if (fRhomParam) fRhom = fRhomParam->GetVal();
158 
159  if(fRho < 1e-6) {
160  fRho = 1e-6;
161  }
162  if(fRhom < 1e-6) {
163  fRhom = 1e-6;
164  }
165 
166  if (fJetsSub) fJetsSub->Delete();
167 
169  fjw.SetAlpha(fAlpha);
170  fjw.SetMaxDelR(fMaxDelR);
172 }
173 
174 //______________________________________________________________________________
176 {
177  // Process each jet.
178 }
179 
180 //______________________________________________________________________________
182 {
183  // Run termination of the utility (after each event).
184 
185  if (!fInit) return;
186 
187  if (!fJetsSub) {
188  AliWarning(Form("No jet branch to write to for subtracted jets. fJetsSubName: %s", fJetsSubName.Data()));
189  return;
190  }
191 
192 #ifdef FASTJET_VERSION
193  std::vector<fastjet::PseudoJet> jets_sub;
194  jets_sub = fjw.GetConstituentSubtrJets();
195  AliDebug(1,Form("%d constituent subtracted jets found", (Int_t)jets_sub.size()));
196  for (UInt_t ijet = 0, jetCount = 0; ijet < jets_sub.size(); ++ijet) {
197  //Only storing 4-vector and jet area of unsubtracted jet
198  if(jets_sub[ijet].E()>0.) {
199  AliEmcalJet *jet_sub = new ((*fJetsSub)[ijet])
200  AliEmcalJet(jets_sub[ijet].perp(), jets_sub[ijet].eta(), jets_sub[ijet].phi(), jets_sub[ijet].m());
201  jet_sub->SetLabel(ijet);
202  jet_sub->SetJetAcceptanceType(fJetTask->FindJetAcceptanceType(jet_sub->Eta(), jet_sub->Phi_0_2pi(), fJetTask->GetRadius()));
203 
204  fastjet::PseudoJet area(fjw.GetJetAreaVector(ijet));
205  jet_sub->SetArea(area.perp());
206  jet_sub->SetAreaEta(area.eta());
207  jet_sub->SetAreaPhi(area.phi());
208  jet_sub->SetAreaEmc(area.perp());
209 
210  // Fill constituent info
211  std::vector<fastjet::PseudoJet> constituents_unsub(fjw.GetJetConstituents(ijet));
212  std::vector<fastjet::PseudoJet> constituents_sub = jets_sub[ijet].constituents();
213  fJetTask->FillJetConstituents(jet_sub, constituents_sub, constituents_unsub, 1, fParticlesSubName);
214  jetCount++;
215  }
216  }
217 
218 #endif
219 
220 }
221 
fastjet::PseudoJet GetJetAreaVector(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
AliEmcalJetUtilityConstSubtractor & operator=(const AliEmcalJetUtilityConstSubtractor &jet)
void SetArea(Double_t a)
Definition: AliEmcalJet.h:256
Double_t GetRadius()
void SetLabel(Int_t l)
Definition: AliEmcalJet.h:255
TClonesArray * fParticlesSub
subtracted jet collection
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
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
AliEmcalJetTask * fJetTask
std::vector< fastjet::PseudoJet > GetJetConstituents(UInt_t idx) const
void SetAreaEta(Double_t a)
Definition: AliEmcalJet.h:257
void SetMaxDelR(Double_t r)
Definition: AliFJWrapper.h:144
void ProcessJet(AliEmcalJet *jet, Int_t ij, AliFJWrapper &fjw)
AliRhoParameter * fRhoParam
subtracted particle collection
virtual Int_t DoConstituentSubtraction()
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 SetAlpha(Double_t a)
Definition: AliFJWrapper.h:145
void SetAreaPhi(Double_t a)
Definition: AliEmcalJet.h:258
void SetAreaEmc(Double_t a)
Definition: AliEmcalJet.h:260