AliPhysics  421aab4 (421aab4)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 {
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  if (!fInit) return;
143  if (fRhoParam) fRho = fRhoParam->GetVal();
144  if (fRhomParam) fRhom = fRhomParam->GetVal();
145  if(fRho < 1e-6) {
146  fRho = 1e-6;
147  }
148  if(fRhom < 1e-6) {
149  fRhom = 1e-6;
150  }
151 
152  if (fJetsSub) fJetsSub->Delete();
153  fjw.SetEventSub(kTRUE);
154  fjw.SetMaxDelR(fMaxDelR);
156 }
157 
158 //______________________________________________________________________________
160 {
161  // Prepare the utility.
162 
163 }
164 
165 //______________________________________________________________________________
167 {
168  // Process each jet.
169 }
170 
171 //______________________________________________________________________________
173 {
174  // Run termination of the utility (after each event).
175 
176  if (!fInit) return;
177 
178  if (!fJetsSub) {
179  AliWarning(Form("No jet branch to write to for subtracted jets. fJetsSubName: %s", fJetsSubName.Data()));
180  return;
181  }
182 
183 #ifdef FASTJET_VERSION
184  std::vector<fastjet::PseudoJet> jets_event_sub;
185  jets_event_sub = fjw.GetEventSubJets();
186  AliDebug(1,Form("%d event constituent subtracted jets found", (Int_t)jets_event_sub.size()));
187  for (UInt_t ijet = 0, jetCount = 0; ijet < jets_event_sub.size(); ++ijet) {
188  //printf("Jet pt = %f, area = %f", jets_event_sub[ijet].perp(), fjw.GetEventSubJetArea(ijet));
189  //Only storing 4-vector and jet area of unsubtracted jet
190  if(jets_event_sub[ijet].E()>0.) {
191  AliEmcalJet *jet_event_sub = new ((*fJetsSub)[ijet])
192  AliEmcalJet(jets_event_sub[ijet].perp(), jets_event_sub[ijet].eta(), jets_event_sub[ijet].phi(), jets_event_sub[ijet].m());
193  jet_event_sub->SetLabel(ijet);
194  jet_event_sub->SetJetAcceptanceType(fJetTask->FindJetAcceptanceType(jet_event_sub->Eta(), jet_event_sub->Phi_0_2pi(), fJetTask->GetRadius()));
195 
196  fastjet::PseudoJet area(fjw.GetEventSubJetAreaVector(ijet));
197  jet_event_sub->SetArea(area.perp()); //changed from area.perp()
198  jet_event_sub->SetAreaEta(area.eta());
199  jet_event_sub->SetAreaPhi(area.phi());
200  jet_event_sub->SetAreaEmc(area.perp());
201 
202  // Fill constituent info
203  std::vector<fastjet::PseudoJet> constituents_sub = jets_event_sub[ijet].constituents();
204  fJetTask->FillJetConstituents(jet_event_sub, constituents_sub, constituents_sub, 1, fParticlesSubName);
205  jetCount++;
206  }
207  }
208 
209 #endif
210 
211 }
212 
fastjet::PseudoJet GetEventSubJetAreaVector(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
TClonesArray * fParticlesSub
subtracted jet collection
void SetArea(Double_t a)
Definition: AliEmcalJet.h:185
Double_t GetRadius()
AliEmcalJetUtilityEventSubtractor & operator=(const AliEmcalJetUtilityEventSubtractor &jet)
void SetLabel(Int_t l)
Definition: AliEmcalJet.h:184
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
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:122
const std::vector< fastjet::PseudoJet > & GetEventSubJets() const
Definition: AliFJWrapper.h:35
AliEmcalJetTask * fJetTask
void SetAreaEta(Double_t a)
Definition: AliEmcalJet.h:186
void SetMaxDelR(Double_t r)
Definition: AliFJWrapper.h:125
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 SetEventSub(Bool_t b)
Definition: AliFJWrapper.h:124
void SetAreaPhi(Double_t a)
Definition: AliEmcalJet.h:187
AliRhoParameter * fRhoParam
subtracted particle collection
ClassImp(AliEmcalJetUtilityEventSubtractor) AliEmcalJetUtilityEventSubtractor
void SetAreaEmc(Double_t a)
Definition: AliEmcalJet.h:189