AliPhysics  b752f14 (b752f14)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliAnalysisTaskK0toPi0Pi0.cxx
Go to the documentation of this file.
1 /**************************************************************************************
2  * Copyright (C) 2017, Copyright Holders of the ALICE Collaboration *
3  * All rights reserved. *
4  * *
5  * Redistribution and use in source and binary forms, with or without *
6  * modification, are permitted provided that the following conditions are met: *
7  * * Redistributions of source code must retain the above copyright *
8  * notice, this list of conditions and the following disclaimer. *
9  * * Redistributions in binary form must reproduce the above copyright *
10  * notice, this list of conditions and the following disclaimer in the *
11  * documentation and/or other materials provided with the distribution. *
12  * * Neither the name of the <organization> nor the *
13  * names of its contributors may be used to endorse or promote products *
14  * derived from this software without specific prior written permission. *
15  * *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND *
17  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED *
18  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE *
19  * DISCLAIMED. IN NO EVENT SHALL ALICE COLLABORATION BE LIABLE FOR ANY *
20  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
21  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; *
22  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND *
23  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
25  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
26  **************************************************************************************/
27 #include <array>
28 
29 #include <THistManager.h>
30 #include <TLinearBinning.h>
31 #include <TList.h>
33 #include "AliAODConversionMother.h"
34 #include "AliAODConversionPhoton.h"
35 #include "AliCaloPhotonCuts.h"
36 #include "AliClusterContainer.h"
38 #include "AliConversionMesonCuts.h"
39 #include "AliConvEventCuts.h"
40 #include "AliLog.h"
41 #include "AliVCluster.h"
42 #include "AliV0ReaderV1.h"
44 
48 
51  fLocalInitialized(kFALSE),
52  fCurrentRun(-1),
53  fNewFile(kFALSE),
54  fV0Reader(nullptr),
55  fV0ReaderName("V0ReaderV1"),
56  fClusterContainer(nullptr),
57  fIsMC(false),
58  fWeightJetJetMC(1.),
59  fEventPlaneAngle(0.),
60  fEventCuts(nullptr),
61  fConvPhotonCuts(nullptr),
62  fCaloPhotonCuts(nullptr),
63  fPi0Cuts(nullptr),
64  fPi0CutsCaloCalo(nullptr),
65  fK0Cuts(nullptr),
66  fBGHandler(nullptr),
67  fHistos(nullptr),
68  fOutput(nullptr)
69 {
70 
71 }
72 
74  AliAnalysisTaskSE(name),
75  fLocalInitialized(kFALSE),
76  fCurrentRun(-1),
77  fNewFile(kFALSE),
78  fV0Reader(nullptr),
79  fV0ReaderName("V0ReaderV1"),
80  fClusterContainer(nullptr),
81  fIsMC(false),
82  fWeightJetJetMC(1.),
83  fEventPlaneAngle(0),
84  fEventCuts(nullptr),
85  fConvPhotonCuts(nullptr),
86  fCaloPhotonCuts(nullptr),
87  fPi0Cuts(nullptr),
88  fPi0CutsCaloCalo(nullptr),
89  fK0Cuts(nullptr),
90  fBGHandler(nullptr),
91  fHistos(nullptr),
92  fOutput(nullptr)
93 {
94  DefineOutput(1, TList::Class());
95 }
96 
97 
98 
100  if(fHistos) delete fHistos;
101 }
102 
103 //=================================== CREATE OUTPUT OBJECTS ====================================================================
105  fOutput = new TList();
106  fOutput->SetOwner(kTRUE);
107 
108 
109  // Connecting input V0 reader
110  fV0Reader=dynamic_cast<AliV0ReaderV1*>(AliAnalysisManager::GetAnalysisManager()->GetTask(fV0ReaderName.Data()));
111  if(!fV0Reader){
112  AliFatal("Error: No V0 Reader");
113  }// GetV0Reader
114 
115  // fEventCuts = fV0Reader->GetEventCuts();
116 
117 
118 
119  // Define histograms
120  fHistos = new THistManager("K0stoPi0Pi0");
121 
122  AliDebug(2, "************* Defining Event Counter Histograms ********************");
123 
124 
125  // Event counter histograms
126  fHistos->CreateTH1("hEventQualityBefore", "Event Quality (0 = good)", 13, -0.5, 12.5);
127  fHistos->CreateTH1("hEventQualityAfter", "Event Quality (0 = good)", 13, -0.5, 12.5);
128  fHistos->CreateTH1("hVertexZ", "z-component of the primary vertex; z (cm); Number of events", 1000, -40., 40.);
129  fHistos->CreateTH1("hCaloPhotonsBefore", "Number of Events", 13, -0.5, 12.5);
130  fHistos->CreateTH1("hCaloPhotonsAfter", "Number of Events", 13, -0.5, 12.5);
131  fHistos->CreateTH1("hConvPhotonsBefore", "Number of Events", 13, -0.5, 12.5);
132  fHistos->CreateTH1("hConvPhotonsAfter", "Number of Events", 13, -0.5, 12.5);
133 
134  AliDebug(2, "************* Defining Photon QA Histograms ********************");
135 
136  // Photon QA
137  fHistos->CreateTH1("hCaloPhotonPt", "p_{t}-distribution of the conversion photons; p_{t} (GeV); Yield", 300, 0., 30.);
138  fHistos->CreateTH1("hConvPhotonPt", "p_{t}-distribution of the conversion photons; p_{t} (GeV); Yield", 300, 0., 30.);
139  fHistos->CreateTH2("hConvPhotonEtaR", "#eta vs conversion radius of conversion photons; #eta; R (cm)", 200, -1.5, 1.5, 300, 0., 300);
140 
141  AliDebug(2, "************* Defining Pi0 Histograms ********************");
142 
143  // Pi0 invariant mass, alpha and opening angle distributions
144  const std::array<TString, 3> pi0rec = {"ConvConv", "ConvCalo", "CaloCalo"}; // aka PCM, EMCAL, PCM-EMCAL
145  for(const auto &reccase : pi0rec){
146  // before selection
147  // for candidates in a wide mass region
148  fHistos->CreateTH2("hMassvsPtPi0Before" + reccase + "All", "inv. mass vs. p_{t} for all #pi^{0} (" + reccase + ") candidates; inv. mass (GeV/c^{2}); p_{t} (GeV/c)", 500, 0., 0.5, 300, 0.3, 30.);
149  // only for candidates in the pi0 mass region
150  fHistos->CreateTH2("hMassvsPtPi0Before" + reccase + "Sel", "inv. mass vs. p_{t} for selected #pi^{0} (" + reccase + ") candidates; inv. mass (GeV/c^{2}); p_{t} (GeV/c)", 500, 0., 0.5, 300, 0.3, 30.);
151  fHistos->CreateTH2("hAlphavsPtPi0Before" + reccase, "#alpha vs p_{t} for selected #p^i{0} (" + reccase + ") candidates; #alpha; p_{t}", 200, -1., 1., 300, 0., 30.);
152  fHistos->CreateTH2("hOpeningAnglevsPtPi0Before" + reccase, "Opening angle vs. p_{t} for selected #pi^{0} (" + reccase + ") candidates; opening angle; p_{t} (GeV/c)", 100, 0., 1., 300., 0.3, 30.);
153 
154  // after selection
155  fHistos->CreateTH2("hMassvsPtPi0After" + reccase + "All", "inv. mass vs. p_{t} for all #pi^{0} (" + reccase + ") candidates; inv. mass (GeV/c^{2}); p_{t} (GeV/c)", 500, 0., 0.5, 300, 0.3, 30.);
156  // only for candidates in the pi0 mass region
157  fHistos->CreateTH2("hMassvsPtPi0After" + reccase + "Sel", "inv. mass vs. p_{t} for selected #pi^{0} (" + reccase + ") candidates; inv. mass (GeV/c^{2}); p_{t} (GeV/c)", 500, 0., 0.5, 300, 0.3, 30.);
158  fHistos->CreateTH2("hAlphavsPtPi0After" + reccase, "#alpha vs p_{t} for selected #p^i{0} (" + reccase + ") candidates; #alpha; p_{t}", 200, -1., 1., 300, 0., 30.);
159  fHistos->CreateTH2("hOpeningAnglevsPtPi0After" + reccase, "Opening angle vs. p_{t} for selected #pi^{0} (" + reccase + ") candidates; opening angle; p_{t} (GeV/c)", 100, 0., 1., 300., 0.3, 30.);
160 
161  }
162 
163  AliDebug(2, "************* Defining K0 Histograms ********************");
164 
165  // K0short invariant mass distribution and opening angle distributions
166  const std::array<TString, 6> k0Shortrec = {"AllConv", "AllCalo", "DiffMixed", "SameMixed", "ConvoCalo","CaloConvo" }; // aka 6 cases
167  for(const auto &reccase1 : k0Shortrec){
168  // before selection
169  fHistos->CreateTH2("hMassvsPtK0ShortBefore" + reccase1, "inv. mass vs. p_{t} for #k^{0}s (" + reccase1 + ") candidates; inv. mass (GeV/c^{2}); p_{t} (GeV/c)", 500, 0.3, 0.6, 300, 0.3, 30.);
170  fHistos->CreateTH2("hOpeningAnglevsPtK0ShortBefore"+ reccase1, "Opening angle vs. p_{t} for k0Short (" + reccase1 + ") candidates; opening angle; p_{t} (GeV/c)", 100, 0., 1., 300., 0.3, 30.);
171 
172 
173  // after selection
174  fHistos->CreateTH2("hMassvsPtK0ShortAfter" + reccase1, "inv. mass vs. p_{t} for #k^{0}s (" + reccase1 + ") candidates; inv. mass (GeV/c^{2}); p_{t} (GeV/c)", 500, 0.3, 0.6, 300, 0.3, 30.);
175  fHistos->CreateTH2("hOpeningAnglevsPtK0ShortAfter"+ reccase1, "Opening angle vs. p_{t} for k0Short (" + reccase1 + ") candidates; opening angle; p_{t} (GeV/c)", 100, 0., 1., 300., 0.3, 30.);
176 
177  /*
178  //background histograms
179  fHistos->CreateTH2("hMassvsPtK0ShortBKG" + reccase1, "inv. mass vs. p_{t} for #k^{0}s (" + reccase1 + ") candidates; inv. mass (GeV/c^{2}); p_{t} (GeV/c)", 500, 0.3, 0.6, 300, 0.3, 30.);
180  fHistos->CreateTH2("hOpeningAnglevsPtK0ShortBKG"+ reccase1, "Opening angle vs. p_{t} for k0Short (" + reccase1 + ") candidates; opening angle; p_{t} (GeV/c)", 100, 0., 1., 300., 0.3, 30.);
181  */
182  }
183 
184  for(auto hist : *(fHistos->GetListOfHistograms())) fOutput->Add(hist);
185 
186  // Adding cut QA
187 
188  TList *qaV0reader = new TList;
189  qaV0reader->SetName("QA_V0reader");
190  qaV0reader->SetOwner(kTRUE);
191  qaV0reader->Add(fV0Reader->GetEventCutHistograms());
192  qaV0reader->Add(fV0Reader->GetCutHistograms());
193  fOutput->Add(qaV0reader);
194 
200  fOutput->Add(fK0Cuts->GetCutHistograms());
201 
202 
203  PostData(1, fOutput);
204 
205 }
206 
207 //=================================== EXEC ONCE ====================================================================
209  if(!fClusterContainer) fClusterContainer = new AliClusterContainer(fInputEvent->IsA() == AliESDEvent::Class() ? "CaloClusters" : "caloClusters");
210  fClusterContainer->SetArray(fInputEvent);
211 
212  if(fConvPhotonCuts){
214  }
215 
216 }
217 
218 //=================================== USER EXEC ====================================================================
220  if(!fLocalInitialized) {
221  ExecOnce();
222  fLocalInitialized = kTRUE;
223  }
224 
225  if(fCurrentRun != fInputEvent->GetRunNumber()) {
226  RunChanged();
227  fCurrentRun = fInputEvent->GetRunNumber();
228  }
229 
230 
231  // do event selection
232  // Use the same event selection as for the v0 reader
233  // Good events defined as events with event quality 0
234  Int_t eventQuality = fEventCuts->GetEventQuality();
235  fHistos->FillTH1("hEventQualityBefore", eventQuality);
236 
237  if(fEventCuts->IsEventAcceptedByCut(fV0Reader->GetEventCuts(), fInputEvent, fMCEvent, false, false)) return;
238  fHistos->FillTH1("hEventQualityAfter", eventQuality);
239  fHistos->FillTH1("hVertexZ", fInputEvent->GetPrimaryVertex()->GetZ());
240 
241 
242  // get Photon candidates
243  fHistos->FillTH1("hConvPhotonsBefore",fV0Reader->GetNReconstructedGammas());
244  std::vector<AliAODConversionPhoton> conversionPhotons = MakeConversionPhotonCandidates(*fV0Reader, *fConvPhotonCuts);
245  MakePhotonQAConv(conversionPhotons, *fEventCuts);
246  Int_t numPhotons = conversionPhotons.size();
247  fHistos->FillTH1("hConvPhotonsAfter", numPhotons);
248 
249  fHistos->FillTH1("hCaloPhotonsBefore",fClusterContainer->GetNEntries());
250  std::vector<AliAODConversionPhoton> caloPhotons = MakeCaloPhotonCandidates(*fClusterContainer, *fCaloPhotonCuts);
251  MakePhotonQACalo(caloPhotons, *fEventCuts);
252  Int_t numCaloPhotons = caloPhotons.size();
253  fHistos->FillTH1("hCaloPhotonsAfter", numCaloPhotons);
254 
255 
256 
257  // get Pi0 candidates
258  std::vector<AliAODConversionMother> samePi0PCM = MakePi0Candidates(&conversionPhotons, nullptr, *fPi0Cuts),
259  samePi0EMCAL = MakePi0Candidates(&caloPhotons, nullptr, *fPi0CutsCaloCalo),
260  mixedPi0 = MakePi0Candidates(&conversionPhotons, &caloPhotons, *fPi0Cuts);
261 
262  /*
263  // create the BG Handlers and get the number of events
264  // collision system 0 for pp
265  // center min and center max don't really matter here
266  // nEvents is done by using ->GetNumberOfBGEvents()
267  // track mult is done by using ->UseTrackMultiplicity()
268  // mode, bins Z, bins multiplicity 0,8,5
269  AliGammaConversionBGHandler *samePCMHandler = new AliGammaConversionBGHandler(0,0,0,fPi0Cuts->GetNumberOfBGEvents(),fPi0Cuts->UseTrackMultiplicity(),0,8,5);
270  AliGammaConversionBGHandler *sameEMCALHandler = new AliGammaConversionBGHandler(0,0,0,fPi0CutsCaloCalo->GetNumberOfBGEvents(),fPi0CutsCaloCalo->UseTrackMultiplicity(),0,8,5);
271  AliGammaConversionBGHandler *mixedHandler = new AliGammaConversionBGHandler(0,0,0,fPi0Cuts->GetNumberOfBGEvents(),fPi0Cuts->UseTrackMultiplicity(),0,8,5);
272 
273  Int_t nEventsSamePCM = samePCMHandler->GetNBackgroundEventsInBuffer(binZ, multiplicity);
274  Int_t nEventsSameEMCAL = sameEMCALHandler->GetNBackgroundEventsInBuffer(binZ, multiplicity);
275  Int_t nEventsMixed = mixedHandler->GetNBackgroundEventsInBuffer(binZ, multiplicity);
276 
277 
278  std::vector<AliAODConversionMother> samePi0PCM_BG;
279  std::vector<AliAODConversionMother> samePi0EMCAL_BG;
280  std::vector<AliAODConversionMother> mixedPi0_BG;
281 
282 
283  // loop combine all pi0s with all of the events currently in the buffer
284  // add it to the buffer once it is already
285  // three for loops, one for each buffer event
286 
287  for(int i=0;i<nEventsSamePCM;i++){
288  samePi0PCM_BG.insert(handler->GetBGGoodMesons(binZ, multiplicity, i));
289  }
290 
291  for(int h=0;h<nEventsSameEMCAL;h++){
292  samePi0EMCAL_BG.insert(handler->GetBGGoodMesons(binZ, multiplicity, h));
293  }
294 
295  for(int h=0;h<nEventsSameEMCAL;h++){
296  mixedPi0_BG.insert(handler->GetBGGoodMesons(binZ, multiplicity, h));
297  }
298 
299  // add the events now as a tlist
300  handler->AddMesonEvent((TList*) samePi0PCM_BG, samePi0PCM_BG->At(i)->GetProductionX(), samePi0PCM_BG->At(i)->GetProductionY() , samePi0PCM_BG->At(i)->GetProductionZ(),multiplicity);
301  */
302 
303 
304  // fill the QA histograms before selection
305  MakePi0QA(samePi0PCM, "ConvConv", "Before");
306  MakePi0QA(samePi0EMCAL, "CaloCalo", "Before");
307  MakePi0QA(mixedPi0, "ConvCalo", "Before");
308 
309  //make the selections
310  std::vector<AliAODConversionMother> samePi0PCMSelection = SelectMeson(samePi0PCM, *fPi0Cuts);
311  std::vector<AliAODConversionMother> samePi0EMCALSelection = SelectMeson(samePi0EMCAL, *fPi0CutsCaloCalo);
312  std::vector<AliAODConversionMother> mixedPi0Selection = SelectMeson(mixedPi0, *fPi0Cuts);
313 
314  // Additionally fill the QA histograms after the selection
315  MakePi0QA(samePi0PCMSelection, "ConvConv", "After");
316  MakePi0QA(samePi0EMCALSelection, "CaloCalo", "After");
317  MakePi0QA(mixedPi0Selection, "ConvCalo", "After");
318 
319 
320 
321 
322 
323  // get K0Short candidates
324  std::vector<AliAODConversionMother> allPCM = MakeK0ShortCandidates(&samePi0PCMSelection, nullptr, *fK0Cuts);
325  std::vector<AliAODConversionMother> allEMC = MakeK0ShortCandidates(&samePi0EMCALSelection, nullptr, *fK0Cuts);
326  std::vector<AliAODConversionMother> PCMEMC = MakeK0ShortCandidates(&samePi0PCMSelection, &mixedPi0Selection, *fK0Cuts);
327  std::vector<AliAODConversionMother> EMCPCM = MakeK0ShortCandidates(&samePi0EMCALSelection, &mixedPi0Selection, *fK0Cuts);
328  std::vector<AliAODConversionMother> mixedSame = MakeK0ShortCandidates(&samePi0EMCALSelection, &samePi0PCMSelection, *fK0Cuts);
329  std::vector<AliAODConversionMother> mixedDiff = MakeK0ShortCandidates(&mixedPi0Selection, nullptr, *fK0Cuts);
330 
331  /*
332  // add duplicates for the background as well
333  std::vector<AliAODConversionMother> allPCM_BG = MakeK0ShortCandidates(&samePi0PCM_BG, nullptr, *fK0Cuts);
334  std::vector<AliAODConversionMother> allEMC_BG = MakeK0ShortCandidates(&samePi0EMCAL_BG, nullptr, *fK0Cuts);
335  std::vector<AliAODConversionMother> PCMEMC_BG = MakeK0ShortCandidates(&samePi0PCM_BG, &mixedPi0, *fK0Cuts);
336  std::vector<AliAODConversionMother> EMCPCM_BG = MakeK0ShortCandidates(&samePi0EMCAL_BG, &mixedPi0, *fK0Cuts);
337  std::vector<AliAODConversionMother> mixedSame_BG = MakeK0ShortCandidates(&samePi0EMCAL_BG, &samePi0PCM, *fK0Cuts);
338  std::vector<AliAODConversionMother> mixedDiff_BG = MakeK0ShortCandidates(&mixedPi0_BG, nullptr, *fK0Cuts);
339  */
340 
341  // fill the QA histograms prior to selection
342  MakeK0ShortQA(allPCM, "AllConv", "Before");
343  MakeK0ShortQA(allEMC,"AllCalo", "Before");
344  MakeK0ShortQA(PCMEMC,"ConvoCalo", "Before");
345  MakeK0ShortQA(EMCPCM,"CaloConvo", "Before");
346  MakeK0ShortQA(mixedSame, "SameMixed", "Before");
347  MakeK0ShortQA(mixedDiff, "DiffMixed", "Before");
348 
349  // make the selections
350  std::vector<AliAODConversionMother> allPCMSelection = SelectMeson(allPCM, *fK0Cuts);
351  std::vector<AliAODConversionMother> allEMCSelection = SelectMeson(allEMC, *fK0Cuts);
352  std::vector<AliAODConversionMother> PCMEMCSelection = SelectMeson(PCMEMC, *fK0Cuts);
353  std::vector<AliAODConversionMother> EMCPCMSelection = SelectMeson(EMCPCM,*fK0Cuts);
354  std::vector<AliAODConversionMother> mixedSameSelection = SelectMeson(mixedSame, *fK0Cuts);
355  std::vector<AliAODConversionMother> mixedDiffSelection = SelectMeson(mixedDiff, *fK0Cuts);
356 
357  // fill the QA histograms after selection
358  MakeK0ShortQA(allPCMSelection, "AllConv", "After");
359  MakeK0ShortQA(allEMCSelection,"AllCalo", "After");
360  MakeK0ShortQA(PCMEMCSelection,"ConvoCalo", "After");
361  MakeK0ShortQA(EMCPCMSelection,"CaloConvo", "After");
362  MakeK0ShortQA(mixedSameSelection, "SameMixed", "After");
363  MakeK0ShortQA(mixedDiffSelection, "DiffMixed", "After");
364 
365 
366  PostData(1, fOutput);
367 }
368 
369 
370 //=================================== MAKE CALO PHOTON CANDIDATES ====================================================================
371 std::vector<AliAODConversionPhoton> AliAnalysisTaskK0toPi0Pi0::MakeCaloPhotonCandidates(const AliClusterContainer &inputcont, AliCaloPhotonCuts &cuts){
372  std::vector<AliAODConversionPhoton> candidates;
373  cuts.FillHistogramsExtendedQA(fInputEvent, fIsMC);
374 
375  // vertex
376  Double_t vertex[3] = {0,0,0};
377  InputEvent()->GetPrimaryVertex()->GetXYZ(vertex);
378 
379  int clusterindex = 0;
380  for(auto c : inputcont.all()) {
381  clusterindex++;
382  if(!cuts.ClusterIsSelected(c, fInputEvent, fMCEvent, fIsMC, 1., c->GetID())) continue; // weight to be added later
383 
384  // TLorentzvector with cluster
385  TLorentzVector clusterVector;
386  c->GetMomentum(clusterVector,vertex);
387 
388  // convert to AODConversionPhoton
389  AliAODConversionPhoton photonCandidate(&clusterVector);
390 
391  // Flag Photon as CaloPhoton
392  photonCandidate.SetIsCaloPhoton();
393  photonCandidate.SetCaloClusterRef(clusterindex);
394 
395  // get MC label
396  if(fIsMC>0){
397  photonCandidate.SetNCaloPhotonMCLabels(c->GetNLabels());
398  for (UInt_t k = 0; k < c->GetNLabels(); k++){
399  if(k < 50) photonCandidate.SetCaloPhotonMCLabel(k,c->GetLabels()[k]);
400  }
401  }
402 
403  candidates.push_back(photonCandidate);
404  }
405 
406  return candidates;
407 }
408 
409 //=================================== MAKE CONVERSION PHOTON CANDIDATES ====================================================================
411  std::vector<AliAODConversionPhoton> candidates;
412  Int_t nV0 = 0;
413  std::vector<AliAODConversionPhoton *> GammaCandidatesStepOne;
414  TList GammaCandidatesStepTwo;
415 
416  // Loop over Photon Candidates allocated by ReaderV1
417  for(auto photon : reader){
418  if(!cuts.PhotonIsSelected(photon ,fInputEvent)) continue;
419  if(!cuts.InPlaneOutOfPlaneCut(photon->GetPhotonPhi(), fEventPlaneAngle)) continue;
420  if(!cuts.UseElecSharingCut() && !cuts.UseToCloseV0sCut()){
421  candidates.push_back(*(static_cast<AliAODConversionPhoton *>(photon))); // if no second loop is required add to events good gammas
422  }else if(cuts.UseElecSharingCut()){ // if Shared Electron cut is enabled, Fill array, add to step one
423  cuts.FillElectonLabelArray(static_cast<AliAODConversionPhoton *>(photon), nV0);
424  nV0++;
425  GammaCandidatesStepOne.push_back(static_cast<AliAODConversionPhoton *>(photon));
426  }else if(!cuts.UseElecSharingCut() && cuts.UseToCloseV0sCut()){ // shared electron is disabled, step one not needed -> step two
427  GammaCandidatesStepTwo.Add(static_cast<AliAODConversionPhoton *>(photon));
428  }
429  }
430 
431  if(cuts.UseElecSharingCut()){
432  int iV0 = 0;
433  for(auto photon : GammaCandidatesStepOne){
434  if(!cuts.RejectSharedElectronV0s(photon,iV0,GammaCandidatesStepOne.size())) continue;
435  if(!cuts.UseToCloseV0sCut()){ // To Close v0s cut diabled, step two not needed
436  candidates.push_back(*photon);
437  } else GammaCandidatesStepTwo.Add(photon); // Close v0s cut enabled -> add to list two
438  iV0++;
439  }
440  }
441 
442  if(cuts.UseToCloseV0sCut()){
443  for(int i = 0; i < GammaCandidatesStepTwo.GetEntries(); i++){
444  AliAODConversionPhoton *photon = static_cast<AliAODConversionPhoton *>(GammaCandidatesStepTwo.At(i));
445  if(!cuts.RejectToCloseV0s(photon, &GammaCandidatesStepTwo,i)) continue;
446  candidates.push_back(*photon); // Add gamma to current cut TList
447  }
448  }
449  return candidates;
450 }
451 
452 //=================================== SELECT MESON ====================================================================
453 std::vector<AliAODConversionMother> AliAnalysisTaskK0toPi0Pi0::SelectMeson(std::vector<AliAODConversionMother> &candidates,
454  AliConversionMesonCuts &cuts){
455  std::vector<AliAODConversionMother> selectedCandidates;
456 
457  for(auto candidate: candidates){
458  if(cuts.MesonIsSelected(&candidate, kTRUE, 0)) continue;
459  selectedCandidates.push_back(candidate);
460  }
461 
462  return selectedCandidates;
463 
464 
465 }
466 
467 //=================================== MAKE PI0 CANDIDATES ====================================================================
468 std::vector<AliAODConversionMother> AliAnalysisTaskK0toPi0Pi0::MakePi0Candidates(const std::vector<AliAODConversionPhoton> *primaryLeg,
469  const std::vector<AliAODConversionPhoton> *secondaryLeg,
470  AliConversionMesonCuts &cuts){
471  // secondary leg: optional argument, if different methods for photon identification (i.e. PCM-EMCAL) is used
472  std::vector<AliAODConversionMother> candidates;
473  if(secondaryLeg){
474  // Different methods for photon identification identification
475  for(auto primphoton : *primaryLeg){
476  for(auto secphoton : *secondaryLeg) {
477  AliAODConversionMother candidate(&primphoton, &secphoton);
478  if(!cuts.CheckWhetherInMassRange(candidate.M()))continue;
479  // Do Pi0 selection
480  //if(!cuts.MesonIsSelected(&candidate, kTRUE, 0)) continue; // Rapidity shift needed when going to asymmetric systems
481  candidates.push_back(candidate);
482  }
483  }
484  } else {
485  // Same method for photon identification
486  for(auto primiter = primaryLeg->begin(); primiter != primaryLeg->end(); ++primiter){
487  for(auto seciter = primiter + 1; seciter != primaryLeg->end(); ++seciter){
488  AliAODConversionMother candidate(&(*primiter), &(*seciter));
489  if(!cuts.CheckWhetherInMassRange(candidate.M()))continue;
490  // Do pi0 selection
491  //if(!cuts.MesonIsSelected(&candidate, kTRUE, 0)) continue; // Rapidity shift needed when going to asymmetric systems
492  candidates.push_back(candidate);
493  }
494  }
495  }
496  return candidates;
497 }
498 
499 // =================================== MAKE K0 SHORT CANDIDATES ====================================================================
500 std::vector<AliAODConversionMother> AliAnalysisTaskK0toPi0Pi0::MakeK0ShortCandidates(const std::vector<AliAODConversionMother> *primaryLeg,
501  const std::vector<AliAODConversionMother> *secondaryLeg,
502  AliConversionMesonCuts &cuts){
503  std::vector<AliAODConversionMother> candidates;
504  if(secondaryLeg) {
505  // Different methods for Pi0 identification (one same, one mixed)
506  for(auto primpi0 : *primaryLeg) {
507  for(auto secpi0 : *secondaryLeg) {
508  AliAODConversionMother candidate(&primpi0, &secpi0);
509  //if(!cuts.MesonIsSelected(&candidate, kTRUE, 0)) continue;
510  candidates.push_back(candidate);
511  }
512  }
513  } else {
514  // Same methods for Pi0 identification (both same or both mixed)
515  for(auto primpi0 = primaryLeg->begin(); primpi0 != primaryLeg->end(); ++primpi0) {
516  for(auto secpi0 = primpi0 + 1; secpi0 != primaryLeg->end(); ++secpi0) {
517  AliAODConversionMother candidate(&(*primpi0), &(*secpi0));
518  //if(!cuts.MesonIsSelected(&candidate, kTRUE, 0)) continue;
519  candidates.push_back(candidate);
520  }
521  }
522  }
523  return candidates;
524 }
525 
526 //=================================== MAKE PHOTON QA CALO ====================================================================
527 void AliAnalysisTaskK0toPi0Pi0::MakePhotonQACalo(const std::vector<AliAODConversionPhoton> &photons, AliConvEventCuts &cuts) {
528  for(auto photon : photons) {
529  fHistos->FillTH1("hCaloPhotonPt", photon.Pt());
530  }
531 }
532 
533 //=================================== MAKE PHOTON QA CONV ====================================================================
534 void AliAnalysisTaskK0toPi0Pi0::MakePhotonQAConv(const std::vector<AliAODConversionPhoton> &photons, AliConvEventCuts &cuts) {
535  for(auto photon : photons) {
536  fHistos->FillTH1("hConvPhotonPt", photon.Pt());
537  fHistos->FillTH2("hConvPhotonEtaR", photon.Eta(), photon.GetConversionRadius());
538  }
539 }
540 
541 //=================================== MAKE PI0 QA ====================================================================
542 void AliAnalysisTaskK0toPi0Pi0::MakePi0QA(const std::vector<AliAODConversionMother> &pi0s, const char *reccase, TString selectionStatus){
543  TString reccaseString = reccase;
544  for(auto pi0 : pi0s) {
545  if(selectionStatus == "Before"){
546  fHistos->FillTH2("hMassvsPtPi0Before" + reccaseString + "All", pi0.M(), pi0.Pt());
547  // if in the pi0 mass region
548  if((0.08 <=pi0.M()) && (pi0.M()<= 0.145)){
549  fHistos->FillTH2("hMassvsPtPi0Before"+ reccaseString + "Sel", pi0.M(),pi0.Pt());
550  fHistos->FillTH2("hAlphavsPtPi0Before" + reccaseString, pi0.GetAlpha(), pi0.Pt());
551  fHistos->FillTH2("hOpeningAnglevsPtPi0Before" + reccaseString, pi0.GetOpeningAngle(), pi0.Pt());
552  }
553  }
554  else if(selectionStatus == "After"){
555  fHistos->FillTH2("hMassvsPtPi0After" + reccaseString + "All", pi0.M(), pi0.Pt());
556  // if in the pi0 mass region
557  if((0.08 <=pi0.M()) && (pi0.M()<= 0.145)){
558  fHistos->FillTH2("hMassvsPtPi0After"+ reccaseString + "Sel", pi0.M(),pi0.Pt());
559  fHistos->FillTH2("hAlphavsPtPi0After" + reccaseString, pi0.GetAlpha(), pi0.Pt());
560  fHistos->FillTH2("hOpeningAnglevsPtPi0After" + reccaseString, pi0.GetOpeningAngle(), pi0.Pt());
561  }
562 
563  }
564  }
565 }
566 
567 //=================================== MAKE KO SHORT QA ====================================================================
568 void AliAnalysisTaskK0toPi0Pi0::MakeK0ShortQA(const std::vector<AliAODConversionMother> &k0s,const char *reccase, TString selectionStatus){
569  TString reccaseString = reccase;
570  for(auto k0: k0s) {
571  if(selectionStatus == "Before"){
572  fHistos->FillTH2("hMassvsPtK0ShortBefore" + reccaseString, k0.M(), k0.Pt());
573  fHistos->FillTH2("hOpeningAnglevsPtK0ShortBefore" + reccaseString, k0.GetOpeningAngle(), k0.Pt());
574  }
575  else if(selectionStatus == "After"){
576  fHistos->FillTH2("hMassvsPtK0ShortAfter" + reccaseString, k0.M(), k0.Pt());
577  fHistos->FillTH2("hOpeningAnglevsPtK0ShortAfter" + reccaseString, k0.GetOpeningAngle(), k0.Pt());
578  }
579  }
580 }
581 
582 //=================================== ADD CLUSTER CONTAINER ====================================================================
585  return fClusterContainer;
586 }
587 
588 
589 
Bool_t fIsMC
Switch whether we run over data or MC.
AliClusterContainer * AddClusterContainer(const char *name)
void MakePi0QA(const std::vector< AliAODConversionMother > &pi0s, const char *reccase, TString selectionStatus)
void SetCaloClusterRef(Long_t ref)
double Double_t
Definition: External.C:58
Bool_t RejectSharedElectronV0s(AliAODConversionPhoton *photon, Int_t nV0, Int_t nV0s)
Int_t GetNReconstructedGammas() const
Definition: AliV0ReaderV1.h:77
TList * GetCutHistograms()
std::vector< AliAODConversionMother > SelectMeson(std::vector< AliAODConversionMother > &candidates, AliConversionMesonCuts &cuts)
AliCaloPhotonCuts * fCaloPhotonCuts
Calo photon cuts.
void FillTH2(const char *hname, double x, double y, double weight=1., Option_t *opt="")
Fill a 2D histogram within the container.
TList * GetEventCutHistograms()
Definition: AliV0ReaderV1.h:84
TCanvas * c
Definition: TestFitELoss.C:172
TList * GetCutHistograms()
Definition: AliV0ReaderV1.h:82
virtual Bool_t CheckWhetherInMassRange(Double_t mass)
AliClusterContainer * fClusterContainer
Cluster container.
void SetCaloPhotonMCLabel(Int_t i, Int_t labelCaloPhoton)
Double_t fEventPlaneAngle
Event Plane Angle.
void FillElectonLabelArray(AliAODConversionPhoton *photon, Int_t nV0)
std::vector< AliAODConversionPhoton > MakeConversionPhotonCandidates(const AliV0ReaderV1 &reader, AliConversionPhotonCuts &cuts)
TList * fOutput
Global output container.
AliConversionMesonCuts * fPi0CutsCaloCalo
Cuts on the pi0 for the calo calo case.
AliConversionMesonCuts * fPi0Cuts
Cuts on the pi0.
Bool_t ClusterIsSelected(AliVCluster *cluster, AliVEvent *event, AliVEvent *mcEvent, Int_t isMC, Double_t weight=1., Long_t clusterID=-1)
const AliClusterIterableContainer all() const
Bool_t RejectToCloseV0s(AliAODConversionPhoton *photon, TList *photons, Int_t nV0)
void MakePhotonQACalo(const std::vector< AliAODConversionPhoton > &photons, AliConvEventCuts &cuts)
Bool_t InPlaneOutOfPlaneCut(Double_t photonPhi, Double_t eventPlaneAngle=-100, Bool_t fill=kTRUE)
TH2 * CreateTH2(const char *name, const char *title, int nbinsx, double xmin, double xmax, int nbinsy, double ymin, double ymax, Option_t *opt="")
Create a new TH2 within the container.
int Int_t
Definition: External.C:63
Bool_t fLocalInitialized
Check whether the task was initialized (triggers ExecOnce)
Class handling all kinds of selection cuts for Gamma Calo analysis.
unsigned int UInt_t
Definition: External.C:33
THashList * GetListOfHistograms() const
Get the list of histograms.
Definition: THistManager.h:671
void FillHistogramsExtendedQA(AliVEvent *event, Int_t isMC)
THistManager * fHistos
Container for Histograms.
AliConversionPhotonCuts * fConvPhotonCuts
Cuts on conversion photons.
TH1 * CreateTH1(const char *name, const char *title, int nbins, double xmin, double xmax, Option_t *opt="")
Create a new TH1 within the container.
Int_t IsEventAcceptedByCut(AliConvEventCuts *ReaderCuts, AliVEvent *InputEvent, AliMCEvent *MCEvent, Int_t isHeavyIon, Bool_t isEMCALAnalysis)
Class handling all kinds of selection cuts for Gamma Conversion analysis.
void MakeK0ShortQA(const std::vector< AliAODConversionMother > &k0s, const char *reccase, TString selectionStatus)
void FillTH1(const char *hname, double x, double weight=1., Option_t *opt="")
Fill a 1D histogram within the container.
std::vector< AliAODConversionMother > MakeK0ShortCandidates(const std::vector< AliAODConversionMother > *primaryLeg, const std::vector< AliAODConversionMother > *secondaryLeg, AliConversionMesonCuts &cuts)
ClassImp(AliAnalysisTaskDeltaPt) AliAnalysisTaskDeltaPt
AliV0ReaderV1 * fV0Reader
! V0 reader
void MakePhotonQAConv(const std::vector< AliAODConversionPhoton > &photons, AliConvEventCuts &cuts)
TString fV0ReaderName
Name of the V0 reader.
Class handling all kinds of selection cuts for Gamma Conversion analysis.
Bool_t MesonIsSelected(AliAODConversionMother *pi0, Bool_t IsSignal=kTRUE, Double_t fRapidityShift=0., Int_t leadingCellID1=0, Int_t leadingCellID2=0)
std::vector< AliAODConversionMother > MakePi0Candidates(const std::vector< AliAODConversionPhoton > *primaryLeg, const std::vector< AliAODConversionPhoton > *secondaryLeg, AliConversionMesonCuts &cuts)
std::vector< AliAODConversionPhoton > MakeCaloPhotonCandidates(const AliClusterContainer &inputcont, AliCaloPhotonCuts &cuts)
void SetNCaloPhotonMCLabels(Int_t nLabels)
Container class for histograms.
Definition: THistManager.h:99
Class handling all kinds of selection cuts for Gamma Conversion analysis.
void SetArray(const AliVEvent *event)
AliConvEventCuts * GetEventCuts()
Definition: AliV0ReaderV1.h:81
const char Option_t
Definition: External.C:48
Int_t fCurrentRun
Current run number (triggers RunChanged)
Container structure for EMCAL clusters.
AliConversionMesonCuts * fK0Cuts
Cuts on the K0.
Bool_t PhotonIsSelected(AliConversionPhotonBase *photon, AliVEvent *event)
AliConvEventCuts * fEventCuts
Event cuts.