AliPhysics  b6f8e44 (b6f8e44)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 {
42  // Default constructor.
43 }
44 
45 //______________________________________________________________________________
47  AliEmcalJetUtility(other),
48  fJetsSubName(other.fJetsSubName),
49  fParticlesSubName(other.fParticlesSubName),
50  fUseExternalBkg(other.fUseExternalBkg),
51  fRhoName(other.fRhoName),
52  fRhomName(other.fRhomName),
53  fRho(other.fRho),
54  fRhom(other.fRhom),
55  fJetsSub(other.fJetsSub),
56  fParticlesSub(other.fParticlesSub),
57  fRhoParam(other.fRhoParam),
58  fRhomParam(other.fRhomParam)
59 {
60  // Copy constructor.
61 }
62 
63 //______________________________________________________________________________
65 {
66  // Assignment.
67 
68  if (&other == this) return *this;
70  fJetsSubName = other.fJetsSubName;
73  fRhoName = other.fRhoName;
74  fRhomName = other.fRhomName;
75  fRho = other.fRho;
76  fRhom = other.fRhom;
77  fJetsSub = other.fJetsSub;
79  fRhoParam = other.fRhoParam;
80  fRhomParam = other.fRhomParam;
81  return *this;
82 }
83 
84 //______________________________________________________________________________
86 {
87  // Initialize the utility.
88  // Add constituent subtracted jets to event
89  if (!fJetsSubName.IsNull()) {
90  if (!(fJetTask->InputEvent()->FindListObject(fJetsSubName)) ) {
91  fJetsSub = new TClonesArray("AliEmcalJet");
92  fJetsSub->SetName(fJetsSubName);
93  fJetTask->InputEvent()->AddObject(fJetsSub);
94  }
95  else {
96  AliError(Form("%s: Object for subtracted jet branch with name %s already in event! Returning", GetName(), fJetsSubName.Data()));
97  return;
98  }
99  }
100 
101  // Add tracks from constituent subtracted jets to event
102  if (!fParticlesSubName.IsNull()) {
103  if (!(fJetTask->InputEvent()->FindListObject(fParticlesSubName))) {
104  fParticlesSub = new TClonesArray("AliEmcalParticle");
106  fJetTask->InputEvent()->AddObject(fParticlesSub);
107  } else {
108  AliError(Form("%s: Object with name %s already in event! Returning", GetName(), fParticlesSubName.Data()));
109  return;
110  }
111  }
112 
113  if (!fRhoName.IsNull() && !fRhoParam) { // get rho from the event
114  fRhoParam = dynamic_cast<AliRhoParameter*>(fJetTask->InputEvent()->FindListObject(fRhoName));
115  if (!fRhoParam) {
116  AliError(Form("%s: Could not retrieve rho %s!", GetName(), fRhoName.Data()));
117  return;
118  }
119  }
120 
121  if (!fRhomName.IsNull() && !fRhomParam) { // get rhom from the event
122  fRhomParam = dynamic_cast<AliRhoParameter*>(fJetTask->InputEvent()->FindListObject(fRhomName));
123  if (!fRhomParam) {
124  AliError(Form("%s: Could not retrieve rho_m %s!", GetName(), fRhomName.Data()));
125  return;
126  }
127  }
128 
129  // Create particle container in the main jet task so the indices of the constituents
130  // added later are properly mapped by the jet task.
131  // It is safe to create it before the actual jet finding because the underlying array
132  // will be empty until after jet finding.
134 
135  fInit = kTRUE;
136 }
137 
138 //______________________________________________________________________________
140 {
141  // Prepare the utility.
142 
143 }
144 
145 //______________________________________________________________________________
147 {
148  // Prepare the utility.
149 
150  if (!fInit) return;
151 
152  if (fRhoParam) fRho = fRhoParam->GetVal();
153  if (fRhomParam) fRhom = fRhomParam->GetVal();
154 
155  if(fRho < 1e-6) {
156  fRho = 1e-6;
157  }
158  if(fRhom < 1e-6) {
159  fRhom = 1e-6;
160  }
161 
162  if (fJetsSub) fJetsSub->Delete();
163 
166 }
167 
168 //______________________________________________________________________________
170 {
171  // Process each jet.
172 }
173 
174 //______________________________________________________________________________
176 {
177  // Run termination of the utility (after each event).
178 
179  if (!fInit) return;
180 
181  if (!fJetsSub) {
182  AliWarning(Form("No jet branch to write to for subtracted jets. fJetsSubName: %s", fJetsSubName.Data()));
183  return;
184  }
185 
186 #ifdef FASTJET_VERSION
187  std::vector<fastjet::PseudoJet> jets_sub;
188  jets_sub = fjw.GetConstituentSubtrJets();
189  AliDebug(1,Form("%d constituent subtracted jets found", (Int_t)jets_sub.size()));
190  for (UInt_t ijet = 0, jetCount = 0; ijet < jets_sub.size(); ++ijet) {
191  //Only storing 4-vector and jet area of unsubtracted jet
192  if(jets_sub[ijet].E()>0.) {
193  AliEmcalJet *jet_sub = new ((*fJetsSub)[ijet])
194  AliEmcalJet(jets_sub[ijet].perp(), jets_sub[ijet].eta(), jets_sub[ijet].phi(), jets_sub[ijet].m());
195  jet_sub->SetLabel(ijet);
196  jet_sub->SetJetAcceptanceType(fJetTask->FindJetAcceptanceType(jet_sub->Eta(), jet_sub->Phi_0_2pi(), fJetTask->GetRadius()));
197 
198  fastjet::PseudoJet area(fjw.GetJetAreaVector(ijet));
199  jet_sub->SetArea(area.perp());
200  jet_sub->SetAreaEta(area.eta());
201  jet_sub->SetAreaPhi(area.phi());
202  jet_sub->SetAreaEmc(area.perp());
203 
204  // Fill constituent info
205  std::vector<fastjet::PseudoJet> constituents_unsub(fjw.GetJetConstituents(ijet));
206  std::vector<fastjet::PseudoJet> constituents_sub = jets_sub[ijet].constituents();
207  fJetTask->FillJetConstituents(jet_sub, constituents_sub, constituents_unsub, 1, fParticlesSubName);
208  jetCount++;
209  }
210  }
211 
212 #endif
213 
214 }
215 
fastjet::PseudoJet GetJetAreaVector(UInt_t idx) const
void SetUseExternalBkg(Bool_t b, Double_t rho, Double_t rhom)
Definition: AliFJWrapper.h:120
AliEmcalJetUtility & operator=(const AliEmcalJetUtility &jet)
Double_t Eta() const
Definition: AliEmcalJet.h:114
AliEmcalJetUtilityConstSubtractor & operator=(const AliEmcalJetUtilityConstSubtractor &jet)
void SetArea(Double_t a)
Definition: AliEmcalJet.h:185
Double_t GetRadius()
void SetLabel(Int_t l)
Definition: AliEmcalJet.h:184
TClonesArray * fParticlesSub
subtracted jet collection
void SetJetAcceptanceType(UInt_t type)
Definition: AliEmcalJet.h:261
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
ClassImp(AliEmcalJetUtilityConstSubtractor) AliEmcalJetUtilityConstSubtractor
AliParticleContainer * AddParticleContainer(const char *n)
Create new particle container and attach it to the task.
Double_t Phi_0_2pi() const
Definition: AliEmcalJet.h:122
AliEmcalJetTask * fJetTask
std::vector< fastjet::PseudoJet > GetJetConstituents(UInt_t idx) const
void SetAreaEta(Double_t a)
Definition: AliEmcalJet.h:186
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:44
void SetAreaPhi(Double_t a)
Definition: AliEmcalJet.h:187
void SetAreaEmc(Double_t a)
Definition: AliEmcalJet.h:189