AliPhysics  35e5fca (35e5fca)
 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 
89  // Add constituent subtracted jets to event
90  if (!fJetsSubName.IsNull()) {
91  if (!(fJetTask->InputEvent()->FindListObject(fJetsSubName)) ) {
92  fJetsSub = new TClonesArray("AliEmcalJet");
93  fJetsSub->SetName(fJetsSubName);
94  fJetTask->InputEvent()->AddObject(fJetsSub);
95  }
96  else {
97  AliError(Form("%s: Object for subtracted jet branch with name %s already in event! Returning", GetName(), fJetsSubName.Data()));
98  return;
99  }
100  }
101 
102  // Add tracks from constituent subtracted jets to event
103  if (!fParticlesSubName.IsNull()) {
104  if (!(fJetTask->InputEvent()->FindListObject(fParticlesSubName))) {
105  fParticlesSub = new TClonesArray("AliEmcalParticle");
107  fJetTask->InputEvent()->AddObject(fParticlesSub);
108  } else {
109  AliError(Form("%s: Object with name %s already in event! Returning", GetName(), fParticlesSubName.Data()));
110  return;
111  }
112  }
113 
114  if (!fRhoName.IsNull() && !fRhoParam) { // get rho from the event
115  fRhoParam = dynamic_cast<AliRhoParameter*>(fJetTask->InputEvent()->FindListObject(fRhoName));
116  if (!fRhoParam) {
117  AliError(Form("%s: Could not retrieve rho %s!", GetName(), fRhoName.Data()));
118  return;
119  }
120  }
121 
122  if (!fRhomName.IsNull() && !fRhomParam) { // get rhom from the event
123  fRhomParam = dynamic_cast<AliRhoParameter*>(fJetTask->InputEvent()->FindListObject(fRhomName));
124  if (!fRhomParam) {
125  AliError(Form("%s: Could not retrieve rho_m %s!", GetName(), fRhomName.Data()));
126  return;
127  }
128  }
129 
130  fInit = kTRUE;
131 }
132 
133 //______________________________________________________________________________
135 {
136  // Prepare the utility.
137 
138  if (!fInit) return;
139 
140  if (fRhoParam) fRho = fRhoParam->GetVal();
141  if (fRhomParam) fRhom = fRhomParam->GetVal();
142 
143  if(fRho < 1e-6) {
144  fRho = 1e-6;
145  }
146  if(fRhom < 1e-6) {
147  fRhom = 1e-6;
148  }
149 
150  if (fJetsSub) fJetsSub->Delete();
151 
154 }
155 
156 //______________________________________________________________________________
158 {
159  // Process each jet.
160 }
161 
162 //______________________________________________________________________________
164 {
165  // Run termination of the utility (after each event).
166 
167  if (!fInit) return;
168 
169  if (!fJetsSub) {
170  AliWarning(Form("No jet branch to write to for subtracted jets. fJetsSubName: %s", fJetsSubName.Data()));
171  return;
172  }
173 
174 #ifdef FASTJET_VERSION
175  std::vector<fastjet::PseudoJet> jets_sub;
176  jets_sub = fjw.GetConstituentSubtrJets();
177  AliDebug(1,Form("%d constituent subtracted jets found", (Int_t)jets_sub.size()));
178  for (UInt_t ijet = 0, jetCount = 0; ijet < jets_sub.size(); ++ijet) {
179  //Only storing 4-vector and jet area of unsubtracted jet
180  if(jets_sub[ijet].E()>0.) {
181  AliEmcalJet *jet_sub = new ((*fJetsSub)[ijet])
182  AliEmcalJet(jets_sub[ijet].perp(), jets_sub[ijet].eta(), jets_sub[ijet].phi(), jets_sub[ijet].m());
183  jet_sub->SetLabel(ijet);
184  jet_sub->SetJetAcceptanceType(fJetTask->FindJetAcceptanceType(jet_sub->Eta(), jet_sub->Phi_0_2pi(), fJetTask->GetRadius()));
185 
186  fastjet::PseudoJet area(fjw.GetJetAreaVector(ijet));
187  jet_sub->SetArea(area.perp());
188  jet_sub->SetAreaEta(area.eta());
189  jet_sub->SetAreaPhi(area.phi());
190  jet_sub->SetAreaEmc(area.perp());
191 
192  // Fill constituent info
193  std::vector<fastjet::PseudoJet> constituents_unsub(fjw.GetJetConstituents(ijet));
194  std::vector<fastjet::PseudoJet> constituents_sub = jets_sub[ijet].constituents();
195  fJetTask->FillJetConstituents(jet_sub, constituents_sub, constituents_unsub, 1, fParticlesSub);
196  jetCount++;
197  }
198  }
199 
200 #endif
201 
202 }
203 
fastjet::PseudoJet GetJetAreaVector(UInt_t idx) const
void SetUseExternalBkg(Bool_t b, Double_t rho, Double_t rhom)
Definition: AliFJWrapper.h:113
AliEmcalJetUtility & operator=(const AliEmcalJetUtility &jet)
Double_t Eta() const
Definition: AliEmcalJet.h:114
void FillJetConstituents(AliEmcalJet *jet, std::vector< fastjet::PseudoJet > &constituents, std::vector< fastjet::PseudoJet > &constituents_sub, Int_t flag=0, TClonesArray *particles_sub=0)
AliEmcalJetUtilityConstSubtractor & operator=(const AliEmcalJetUtilityConstSubtractor &jet)
void SetArea(Double_t a)
Definition: AliEmcalJet.h:182
Double_t GetRadius()
void SetLabel(Int_t l)
Definition: AliEmcalJet.h:181
TClonesArray * fParticlesSub
subtracted jet collection
void SetJetAcceptanceType(UInt_t type)
Definition: AliEmcalJet.h:258
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
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:183
void ProcessJet(AliEmcalJet *jet, Int_t ij, AliFJWrapper &fjw)
AliRhoParameter * fRhoParam
subtracted particle collection
virtual Int_t DoConstituentSubtraction()
Represent a jet reconstructed using the EMCal jet framework.
Definition: AliEmcalJet.h:44
void SetAreaPhi(Double_t a)
Definition: AliEmcalJet.h:184
void SetAreaEmc(Double_t a)
Definition: AliEmcalJet.h:186