1 #include "AliEmcalJetUtilityConstSubtractor.h"
2 #include "AliEmcalJet.h"
3 #include "AliRhoParameter.h"
4 #include "AliEmcalJetTask.h"
6 ClassImp(AliEmcalJetUtilityConstSubtractor)
8 //______________________________________________________________________________
9 AliEmcalJetUtilityConstSubtractor::AliEmcalJetUtilityConstSubtractor() :
12 fParticlesSubName(""),
13 fUseExternalBkg(kFALSE),
27 //______________________________________________________________________________
28 AliEmcalJetUtilityConstSubtractor::AliEmcalJetUtilityConstSubtractor(const char* name) :
29 AliEmcalJetUtility(name),
31 fParticlesSubName(""),
32 fUseExternalBkg(kFALSE),
42 // Default constructor.
45 //______________________________________________________________________________
46 AliEmcalJetUtilityConstSubtractor::AliEmcalJetUtilityConstSubtractor(const AliEmcalJetUtilityConstSubtractor &other) :
47 AliEmcalJetUtility(other),
48 fJetsSubName(other.fJetsSubName),
49 fParticlesSubName(other.fParticlesSubName),
50 fUseExternalBkg(other.fUseExternalBkg),
51 fRhoName(other.fRhoName),
52 fRhomName(other.fRhomName),
55 fJetsSub(other.fJetsSub),
56 fParticlesSub(other.fParticlesSub),
57 fRhoParam(other.fRhoParam),
58 fRhomParam(other.fRhomParam)
63 //______________________________________________________________________________
64 AliEmcalJetUtilityConstSubtractor& AliEmcalJetUtilityConstSubtractor::operator=(const AliEmcalJetUtilityConstSubtractor &other)
68 if (&other == this) return *this;
69 AliEmcalJetUtility::operator=(other);
70 fJetsSubName = other.fJetsSubName;
71 fParticlesSubName = other.fParticlesSubName;
72 fUseExternalBkg = other.fUseExternalBkg;
73 fRhoName = other.fRhoName;
74 fRhomName = other.fRhomName;
77 fJetsSub = other.fJetsSub;
78 fParticlesSub = other.fParticlesSub;
79 fRhoParam = other.fRhoParam;
80 fRhomParam = other.fRhomParam;
84 //______________________________________________________________________________
85 void AliEmcalJetUtilityConstSubtractor::Init()
87 // Initialize the utility.
89 // Add constituent subtracted jets to event
90 if (!fJetsSubName.IsNull()) {
91 if (!(fJetTask->GetEvent()->FindListObject(fJetsSubName)) ) {
92 fJetsSub = new TClonesArray("AliEmcalJet");
93 fJetsSub->SetName(fJetsSubName);
94 fJetTask->GetEvent()->AddObject(fJetsSub);
97 AliError(Form("%s: Object for subtracted jet branch with name %s already in event! Returning", GetName(), fJetsSubName.Data()));
102 // Add tracks from constituent subtracted jets to event
103 if (!fParticlesSubName.IsNull()) {
104 if (!(fJetTask->GetEvent()->FindListObject(fParticlesSubName))) {
105 fParticlesSub = new TClonesArray("AliEmcalParticle");
106 fParticlesSub->SetName(fParticlesSubName);
107 fJetTask->GetEvent()->AddObject(fParticlesSub);
109 AliError(Form("%s: Object with name %s already in event! Returning", GetName(), fParticlesSubName.Data()));
114 if (!fRhoName.IsNull() && !fRhoParam) { // get rho from the event
115 fRhoParam = dynamic_cast<AliRhoParameter*>(fJetTask->GetEvent()->FindListObject(fRhoName));
117 AliError(Form("%s: Could not retrieve rho %s!", GetName(), fRhoName.Data()));
122 if (!fRhomName.IsNull() && !fRhomParam) { // get rhom from the event
123 fRhomParam = dynamic_cast<AliRhoParameter*>(fJetTask->GetEvent()->FindListObject(fRhomName));
125 AliError(Form("%s: Could not retrieve rho_m %s!", GetName(), fRhomName.Data()));
133 //______________________________________________________________________________
134 void AliEmcalJetUtilityConstSubtractor::Prepare(AliFJWrapper& fjw)
136 // Prepare the utility.
140 if (fRhoParam) fRho = fRhoParam->GetVal();
141 if (fRhomParam) fRhom = fRhomParam->GetVal();
143 if (fJetsSub) fJetsSub->Delete();
145 fjw.SetUseExternalBkg(fUseExternalBkg, fRho, fRhom);
146 fjw.DoConstituentSubtraction();
149 //______________________________________________________________________________
150 void AliEmcalJetUtilityConstSubtractor::ProcessJet(AliEmcalJet* /*jet*/, Int_t /*ij*/, AliFJWrapper& /*fjw*/)
152 // Proceess each jet.
155 //______________________________________________________________________________
156 void AliEmcalJetUtilityConstSubtractor::Terminate(AliFJWrapper& fjw)
158 // Run termination of the utility (after each event).
163 AliWarning(Form("No jet branch to write to for subtracted jets. fJetsSubName: %s", fJetsSubName.Data()));
167 #ifdef FASTJET_VERSION
168 std::vector<fastjet::PseudoJet> jets_sub;
169 jets_sub = fjw.GetConstituentSubtrJets();
170 AliDebug(1,Form("%d constituent subtracted jets found", (Int_t)jets_sub.size()));
171 for (UInt_t ijet = 0, jetCount = 0; ijet < jets_sub.size(); ++ijet) {
172 //Only storing 4-vector and jet area of unsubtracted jet
173 AliEmcalJet *jet_sub = new ((*fJetsSub)[jetCount])
174 AliEmcalJet(jets_sub[ijet].perp(), jets_sub[ijet].eta(), jets_sub[ijet].phi(), jets_sub[ijet].m());
175 jet_sub->SetLabel(ijet);
177 fastjet::PseudoJet area(fjw.GetJetAreaVector(ijet));
178 jet_sub->SetArea(area.perp());
179 jet_sub->SetAreaEta(area.eta());
180 jet_sub->SetAreaPhi(area.phi());
181 jet_sub->SetAreaEmc(area.perp());
183 // Fill constituent info
184 std::vector<fastjet::PseudoJet> constituents_unsub(fjw.GetJetConstituents(ijet));
185 std::vector<fastjet::PseudoJet> constituents_sub = jets_sub[ijet].constituents();
186 jet_sub->SetNumberOfTracks(constituents_sub.size());
187 fJetTask->FillJetConstituents(jet_sub, constituents_sub, fJetTask->GetTracks(), fJetTask->GetClusters(), constituents_unsub, 1, fParticlesSub);