AliPhysics  421aab4 (421aab4)
 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>
32 #include <TString.h>
34 #include "AliAODConversionMother.h"
35 #include "AliAODConversionPhoton.h"
36 #include "AliCaloPhotonCuts.h"
37 #include "AliClusterContainer.h"
39 #include "AliConversionMesonCuts.h"
40 #include "AliConvEventCuts.h"
41 #include "AliLog.h"
42 #include "AliVCluster.h"
43 #include "AliV0ReaderV1.h"
45 
49 
52  fLocalInitialized(kFALSE),
53  fCurrentRun(-1),
54  fNewFile(kFALSE),
55  fV0Reader(nullptr),
56  fV0ReaderName("V0ReaderV1"),
57  fClusterContainer(nullptr),
58  fIsMC(false),
59  fWeightJetJetMC(1.),
60  fEventPlaneAngle(0.),
61  fEventCuts(nullptr),
62  fConvPhotonCuts(nullptr),
63  fCaloPhotonCuts(nullptr),
64  fPi0CutsConvConv(nullptr),
65  fPi0CutsCaloCalo(nullptr),
66  fPi0CutsConvCalo(nullptr),
67  fK0Cuts(nullptr),
68  fBGHandler(nullptr),
69  fHistos(nullptr),
70  fOutput(nullptr)
71 {
72 
73 }
74 
76  AliAnalysisTaskSE(name),
77  fLocalInitialized(kFALSE),
78  fCurrentRun(-1),
79  fNewFile(kFALSE),
80  fV0Reader(nullptr),
81  fV0ReaderName("V0ReaderV1"),
82  fClusterContainer(nullptr),
83  fIsMC(false),
84  fWeightJetJetMC(1.),
85  fEventPlaneAngle(0),
86  fEventCuts(nullptr),
87  fConvPhotonCuts(nullptr),
88  fCaloPhotonCuts(nullptr),
89  fPi0CutsConvConv(nullptr),
90  fPi0CutsCaloCalo(nullptr),
91  fPi0CutsConvCalo(nullptr),
92  fK0Cuts(nullptr),
93  fBGHandler(nullptr),
94  fHistos(nullptr),
95  fOutput(nullptr)
96 {
97  DefineOutput(1, TList::Class());
98 }
99 
100 
101 
103  if(fHistos) delete fHistos;
104 }
105 
106 //=================================== CREATE OUTPUT OBJECTS ====================================================================
108  fOutput = new TList();
109  fOutput->SetOwner(kTRUE);
110 
111 
112  // Connecting input V0 reader
113  fV0Reader=dynamic_cast<AliV0ReaderV1*>(AliAnalysisManager::GetAnalysisManager()->GetTask(fV0ReaderName.Data()));
114  if(!fV0Reader){
115  AliFatal("Error: No V0 Reader");
116  }// GetV0Reader
117 
118  // fEventCuts = fV0Reader->GetEventCuts();
119 
120 
121 
122  // Define histograms
123  fHistos = new THistManager("K0stoPi0Pi0");
124 
125  AliDebug(2, "************* Defining Event Counter Histograms ********************");
126 
127 
128  // Event counter histograms
129  fHistos->CreateTH1("hEventQualityBefore", "V0 reader Event Quality (0 = good)", 13, -0.5, 12.5);
130  fHistos->CreateTH1("hEventQualityAfter", "V0 reader Event Quality (0 = good)", 13, -0.5, 12.5);
131  fHistos->CreateTH1("hEventSelectionStatusBefore", "Event selection status (0 = good)", 14, -0.5, 13.5);
132  fHistos->CreateTH1("hEventSelectionStatusAfter", "Event selection status (0 = good)", 14, -0.5, 13.5 );
133  fHistos->CreateTH1("hVertexZ", "z-component of the primary vertex; z (cm); Number of events", 1000, -40., 40.);
134  fHistos->CreateTH1("hCaloPhotonsBefore", "Number of Events", 13, -0.5, 12.5);
135  fHistos->CreateTH1("hCaloPhotonsAfter", "Number of Events", 13, -0.5, 12.5);
136  fHistos->CreateTH1("hConvPhotonsBefore", "Number of Events", 13, -0.5, 12.5);
137  fHistos->CreateTH1("hConvPhotonsAfter", "Number of Events", 13, -0.5, 12.5);
138 
139  AliDebug(2, "************* Defining Photon QA Histograms ********************");
140 
141  // Photon QA
142  fHistos->CreateTH1("hCaloPhotonPt", "p_{t}-distribution of the conversion photons; p_{t} (GeV); Yield", 300, 0., 30.);
143  fHistos->CreateTH1("hConvPhotonPt", "p_{t}-distribution of the conversion photons; p_{t} (GeV); Yield", 300, 0., 30.);
144  fHistos->CreateTH2("hConvPhotonEtaR", "#eta vs conversion radius of conversion photons; #eta; R (cm)", 200, -1.5, 1.5, 300, 0., 300);
145 
146  AliDebug(2, "************* Defining Pi0 Histograms ********************");
147 
148  // Pi0 invariant mass, alpha and opening angle distributions
149  const std::array<TString, 3> pi0rec = {"ConvConv", "ConvCalo", "CaloCalo"}; // aka PCM, EMCAL, PCM-EMCAL
150  for(const auto &reccase : pi0rec){
151  // before selection
152  // for candidates in a wide mass region
153  fHistos->CreateTH1("hNPi0CandidatesPerEventBefore" + reccase, "Number of pi0 candidates in event before selection", 101, -0.5, 100.5);
154  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.);
155  // only for candidates in the pi0 mass region
156  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.);
157  fHistos->CreateTH2("hAlphavsPtPi0Before" + reccase, "#alpha vs p_{t} for selected #p^i{0} (" + reccase + ") candidates; #alpha; p_{t}", 200, -1., 1., 300, 0., 30.);
158  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.);
159 
160  fHistos->CreateTH1("hPi0Selection" + reccase, "Pi0 selection status bit for reconstruction case " + reccase, 2, -0.5, 1.5);
161  // after selection
162  fHistos->CreateTH1("hNPi0CandidatesPerEventAfter" + reccase, "Number of pi0 candidates in event before selection", 101, -0.5, 100.5);
163  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.);
164  // only for candidates in the pi0 mass region
165  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.);
166  fHistos->CreateTH2("hAlphavsPtPi0After" + reccase, "#alpha vs p_{t} for selected #p^i{0} (" + reccase + ") candidates; #alpha; p_{t}", 200, -1., 1., 300, 0., 30.);
167  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.);
168 
169  }
170 
171  AliDebug(2, "************* Defining K0 Histograms ********************");
172 
173  // K0short invariant mass distribution and opening angle distributions
174  const std::array<TString, 6> k0Shortrec = {"AllConv", "AllCalo", "DiffMixed", "SameMixed", "ConvoCalo","CaloConvo" }; // aka 6 cases
175  for(const auto &reccase1 : k0Shortrec){
176  // before selection
177  fHistos->CreateTH1("hNK0CandidatesPerEventBefore" + reccase1, "Number of K0 candidates in event before selection", 101, -0.5, 100.5);
178  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.);
179  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.);
180 
181  fHistos->CreateTH1("hK0Selection" + reccase1, "Pi0 selection status bit for reconstruction case " + reccase1, 2, -0.5, 1.5);
182 
183  // after selection
184  fHistos->CreateTH1("hNK0CandidatesPerEventAfter" + reccase1, "Number of K0 candidates in event after selection", 101, -0.5, 100.5);
185  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.);
186  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.);
187 
188  /*
189  //background histograms
190  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.);
191  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.);
192  */
193  }
194 
195  for(auto hist : *(fHistos->GetListOfHistograms())) fOutput->Add(hist);
196 
197  // Adding cut QA
198 
199  TList *qaV0reader = new TList;
200  qaV0reader->SetName("QA_V0reader");
201  qaV0reader->SetOwner(kTRUE);
202  qaV0reader->Add(fV0Reader->GetEventCutHistograms());
203  qaV0reader->Add(fV0Reader->GetCutHistograms());
204  fOutput->Add(qaV0reader);
205 
206  // Adding to QA histos to the output - change name in order to
207  // better identify the histos
211  TList *histlist = fPi0CutsConvConv->GetCutHistograms();
212  TString histname = "Pi0CutsConvConv_" + TString(histlist->GetName());
213  histlist->SetName(histname);
214  fOutput->Add(histlist);
215  histlist = fPi0CutsCaloCalo->GetCutHistograms();
216  histname = "Pi0CutsCalo_" + TString(histlist->GetName());
217  histlist->SetName(histname);
218  fOutput->Add(histlist);
219  histlist = fPi0CutsConvCalo->GetCutHistograms();
220  histname = "Pi0CutsConvCalo_" + TString(histlist->GetName());
221  histlist->SetName(histname);
222  fOutput->Add(histlist);
223  histlist = fK0Cuts->GetCutHistograms();
224  histname = "K0cuts_" + TString(histlist->GetName());
225  histlist->SetName(histname);
226  fOutput->Add(histlist);
227 
228 
229  PostData(1, fOutput);
230 
231 }
232 
233 //=================================== EXEC ONCE ====================================================================
235  if(!fClusterContainer) fClusterContainer = new AliClusterContainer(fInputEvent->IsA() == AliESDEvent::Class() ? "CaloClusters" : "caloClusters");
236  fClusterContainer->SetArray(fInputEvent);
237 
238  if(fConvPhotonCuts){
240  }
241 
242 }
243 
244 //=================================== USER EXEC ====================================================================
246  if(!fLocalInitialized) {
247  ExecOnce();
248  fLocalInitialized = kTRUE;
249  }
250 
251  if(fCurrentRun != fInputEvent->GetRunNumber()) {
252  RunChanged();
253  fCurrentRun = fInputEvent->GetRunNumber();
254  }
255 
256 
257  // do event selection
258  // Use the same event selection as for the v0 reader
259  // Good events defined as events with event quality 0
260  Int_t selectionStatus = fEventCuts->IsEventAcceptedByCut(fV0Reader->GetEventCuts(), fInputEvent, fMCEvent, false, false);
261  Int_t eventQuality = fV0Reader->GetEventCuts()->GetEventQuality();
262  fHistos->FillTH1("hEventQualityBefore", eventQuality);
263  fHistos->FillTH1("hEventSelectionStatusBefore", selectionStatus);
264  if(selectionStatus || eventQuality) return;
265  fHistos->FillTH1("hEventQualityAfter", eventQuality);
266  fHistos->FillTH1("hEventSelectionStatusAfter", selectionStatus);
267  fHistos->FillTH1("hVertexZ", fInputEvent->GetPrimaryVertex()->GetZ());
268 
269 
270  // get Photon candidates
271  fHistos->FillTH1("hConvPhotonsBefore",fV0Reader->GetNReconstructedGammas());
272  std::vector<AliAODConversionPhoton> conversionPhotons = MakeConversionPhotonCandidates(*fV0Reader, *fConvPhotonCuts);
273  MakePhotonQAConv(conversionPhotons, *fEventCuts);
274  Int_t numPhotons = conversionPhotons.size();
275  fHistos->FillTH1("hConvPhotonsAfter", numPhotons);
276 
277  fHistos->FillTH1("hCaloPhotonsBefore",fClusterContainer->GetNEntries());
278  std::vector<AliAODConversionPhoton> caloPhotons = MakeCaloPhotonCandidates(*fClusterContainer, *fCaloPhotonCuts);
279  MakePhotonQACalo(caloPhotons, *fEventCuts);
280  Int_t numCaloPhotons = caloPhotons.size();
281  fHistos->FillTH1("hCaloPhotonsAfter", numCaloPhotons);
282 
283 
284 
285  // get Pi0 candidates
286  std::vector<AliAODConversionMother> samePi0PCM = MakePi0Candidates(&conversionPhotons, nullptr, *fPi0CutsConvConv),
287  samePi0EMCAL = MakePi0Candidates(&caloPhotons, nullptr, *fPi0CutsCaloCalo),
288  mixedPi0 = MakePi0Candidates(&conversionPhotons, &caloPhotons, *fPi0CutsConvCalo);
289 
290  /*
291  // create the BG Handlers and get the number of events
292  // collision system 0 for pp
293  // center min and center max don't really matter here
294  // nEvents is done by using ->GetNumberOfBGEvents()
295  // track mult is done by using ->UseTrackMultiplicity()
296  // mode, bins Z, bins multiplicity 0,8,5
297  AliGammaConversionBGHandler *samePCMHandler = new AliGammaConversionBGHandler(0,0,0,fPi0Cuts->GetNumberOfBGEvents(),fPi0Cuts->UseTrackMultiplicity(),0,8,5);
298  AliGammaConversionBGHandler *sameEMCALHandler = new AliGammaConversionBGHandler(0,0,0,fPi0CutsCaloCalo->GetNumberOfBGEvents(),fPi0CutsCaloCalo->UseTrackMultiplicity(),0,8,5);
299  AliGammaConversionBGHandler *mixedHandler = new AliGammaConversionBGHandler(0,0,0,fPi0Cuts->GetNumberOfBGEvents(),fPi0Cuts->UseTrackMultiplicity(),0,8,5);
300 
301  Int_t nEventsSamePCM = samePCMHandler->GetNBackgroundEventsInBuffer(binZ, multiplicity);
302  Int_t nEventsSameEMCAL = sameEMCALHandler->GetNBackgroundEventsInBuffer(binZ, multiplicity);
303  Int_t nEventsMixed = mixedHandler->GetNBackgroundEventsInBuffer(binZ, multiplicity);
304 
305 
306  std::vector<AliAODConversionMother> samePi0PCM_BG;
307  std::vector<AliAODConversionMother> samePi0EMCAL_BG;
308  std::vector<AliAODConversionMother> mixedPi0_BG;
309 
310 
311  // loop combine all pi0s with all of the events currently in the buffer
312  // add it to the buffer once it is already
313  // three for loops, one for each buffer event
314 
315  for(int i=0;i<nEventsSamePCM;i++){
316  samePi0PCM_BG.insert(handler->GetBGGoodMesons(binZ, multiplicity, i));
317  }
318 
319  for(int h=0;h<nEventsSameEMCAL;h++){
320  samePi0EMCAL_BG.insert(handler->GetBGGoodMesons(binZ, multiplicity, h));
321  }
322 
323  for(int h=0;h<nEventsSameEMCAL;h++){
324  mixedPi0_BG.insert(handler->GetBGGoodMesons(binZ, multiplicity, h));
325  }
326 
327  // add the events now as a tlist
328  handler->AddMesonEvent((TList*) samePi0PCM_BG, samePi0PCM_BG->At(i)->GetProductionX(), samePi0PCM_BG->At(i)->GetProductionY() , samePi0PCM_BG->At(i)->GetProductionZ(),multiplicity);
329  */
330 
331 
332  // fill the QA histograms before selection
333  AliDebug(1, "New event - make Pi0 candidates");
334  MakePi0QA(samePi0PCM, "ConvConv", "Before");
335  MakePi0QA(samePi0EMCAL, "CaloCalo", "Before");
336  MakePi0QA(mixedPi0, "ConvCalo", "Before");
337  AliDebug(1, "New event - finished pi0 candidates");
338 
339  //make the selections
340  std::vector<AliAODConversionMother> samePi0PCMSelection = SelectMeson(samePi0PCM, *fPi0CutsConvConv, kPi0, "ConvConv");
341  std::vector<AliAODConversionMother> samePi0EMCALSelection = SelectMeson(samePi0EMCAL, *fPi0CutsCaloCalo, kPi0, "CaloCalo");
342  std::vector<AliAODConversionMother> mixedPi0Selection = SelectMeson(mixedPi0, *fPi0CutsConvCalo, kPi0, "ConvCalo");
343 
344  // Additionally fill the QA histograms after the selection
345  MakePi0QA(samePi0PCMSelection, "ConvConv", "After");
346  MakePi0QA(samePi0EMCALSelection, "CaloCalo", "After");
347  MakePi0QA(mixedPi0Selection, "ConvCalo", "After");
348 
349 
350 
351 
352 
353  // get K0Short candidates
354  std::vector<AliAODConversionMother> allPCM = MakeK0ShortCandidates(&samePi0PCMSelection, nullptr, *fK0Cuts);
355  std::vector<AliAODConversionMother> allEMC = MakeK0ShortCandidates(&samePi0EMCALSelection, nullptr, *fK0Cuts);
356  std::vector<AliAODConversionMother> PCMEMC = MakeK0ShortCandidates(&samePi0PCMSelection, &mixedPi0Selection, *fK0Cuts);
357  std::vector<AliAODConversionMother> EMCPCM = MakeK0ShortCandidates(&samePi0EMCALSelection, &mixedPi0Selection, *fK0Cuts);
358  std::vector<AliAODConversionMother> mixedSame = MakeK0ShortCandidates(&samePi0EMCALSelection, &samePi0PCMSelection, *fK0Cuts);
359  std::vector<AliAODConversionMother> mixedDiff = MakeK0ShortCandidates(&mixedPi0Selection, nullptr, *fK0Cuts);
360 
361  /*
362  // add duplicates for the background as well
363  std::vector<AliAODConversionMother> allPCM_BG = MakeK0ShortCandidates(&samePi0PCM_BG, nullptr, *fK0Cuts);
364  std::vector<AliAODConversionMother> allEMC_BG = MakeK0ShortCandidates(&samePi0EMCAL_BG, nullptr, *fK0Cuts);
365  std::vector<AliAODConversionMother> PCMEMC_BG = MakeK0ShortCandidates(&samePi0PCM_BG, &mixedPi0, *fK0Cuts);
366  std::vector<AliAODConversionMother> EMCPCM_BG = MakeK0ShortCandidates(&samePi0EMCAL_BG, &mixedPi0, *fK0Cuts);
367  std::vector<AliAODConversionMother> mixedSame_BG = MakeK0ShortCandidates(&samePi0EMCAL_BG, &samePi0PCM, *fK0Cuts);
368  std::vector<AliAODConversionMother> mixedDiff_BG = MakeK0ShortCandidates(&mixedPi0_BG, nullptr, *fK0Cuts);
369  */
370 
371  // fill the QA histograms prior to selection
372  MakeK0ShortQA(allPCM, "AllConv", "Before");
373  MakeK0ShortQA(allEMC,"AllCalo", "Before");
374  MakeK0ShortQA(PCMEMC,"ConvoCalo", "Before");
375  MakeK0ShortQA(EMCPCM,"CaloConvo", "Before");
376  MakeK0ShortQA(mixedSame, "SameMixed", "Before");
377  MakeK0ShortQA(mixedDiff, "DiffMixed", "Before");
378 
379  // make the selections
380  std::vector<AliAODConversionMother> allPCMSelection = SelectMeson(allPCM, *fK0Cuts, kK0, "AllConv");
381  std::vector<AliAODConversionMother> allEMCSelection = SelectMeson(allEMC, *fK0Cuts, kK0, "AllCalo");
382  std::vector<AliAODConversionMother> PCMEMCSelection = SelectMeson(PCMEMC, *fK0Cuts, kK0, "ConvoCalo");
383  std::vector<AliAODConversionMother> EMCPCMSelection = SelectMeson(EMCPCM,*fK0Cuts, kK0, "CaloConvo");
384  std::vector<AliAODConversionMother> mixedSameSelection = SelectMeson(mixedSame, *fK0Cuts, kK0, "SameMixed");
385  std::vector<AliAODConversionMother> mixedDiffSelection = SelectMeson(mixedDiff, *fK0Cuts, kK0, "DiffMixed");
386 
387  // fill the QA histograms after selection
388  MakeK0ShortQA(allPCMSelection, "AllConv", "After");
389  MakeK0ShortQA(allEMCSelection,"AllCalo", "After");
390  MakeK0ShortQA(PCMEMCSelection,"ConvoCalo", "After");
391  MakeK0ShortQA(EMCPCMSelection,"CaloConvo", "After");
392  MakeK0ShortQA(mixedSameSelection, "SameMixed", "After");
393  MakeK0ShortQA(mixedDiffSelection, "DiffMixed", "After");
394 
395 
396  PostData(1, fOutput);
397 }
398 
399 
400 //=================================== MAKE CALO PHOTON CANDIDATES ====================================================================
401 std::vector<AliAODConversionPhoton> AliAnalysisTaskK0toPi0Pi0::MakeCaloPhotonCandidates(const AliClusterContainer &inputcont, AliCaloPhotonCuts &cuts){
402  std::vector<AliAODConversionPhoton> candidates;
403  cuts.FillHistogramsExtendedQA(fInputEvent, fIsMC);
404 
405  // vertex
406  Double_t vertex[3] = {0,0,0};
407  InputEvent()->GetPrimaryVertex()->GetXYZ(vertex);
408 
409  int clusterindex = 0;
410  for(auto c : inputcont.all()) {
411  clusterindex++;
412  if(!cuts.ClusterIsSelected(c, fInputEvent, fMCEvent, fIsMC, 1., c->GetID())) continue; // weight to be added later
413 
414  // TLorentzvector with cluster
415  TLorentzVector clusterVector;
416  c->GetMomentum(clusterVector,vertex);
417 
418  // convert to AODConversionPhoton
419  AliAODConversionPhoton photonCandidate(&clusterVector);
420 
421  // Flag Photon as CaloPhoton
422  photonCandidate.SetIsCaloPhoton();
423  photonCandidate.SetCaloClusterRef(clusterindex);
424 
425  // get MC label
426  if(fIsMC>0){
427  photonCandidate.SetNCaloPhotonMCLabels(c->GetNLabels());
428  for (UInt_t k = 0; k < c->GetNLabels(); k++){
429  if(k < 50) photonCandidate.SetCaloPhotonMCLabel(k,c->GetLabels()[k]);
430  }
431  }
432 
433  candidates.push_back(photonCandidate);
434  }
435 
436  return candidates;
437 }
438 
439 //=================================== MAKE CONVERSION PHOTON CANDIDATES ====================================================================
441  std::vector<AliAODConversionPhoton> candidates;
442  Int_t nV0 = 0;
443  std::vector<AliAODConversionPhoton *> GammaCandidatesStepOne;
444  TList GammaCandidatesStepTwo;
445 
446  // Loop over Photon Candidates allocated by ReaderV1
447  for(auto photon : reader){
448  if(!cuts.PhotonIsSelected(photon ,fInputEvent)) continue;
449  if(!cuts.InPlaneOutOfPlaneCut(photon->GetPhotonPhi(), fEventPlaneAngle)) continue;
450  if(!cuts.UseElecSharingCut() && !cuts.UseToCloseV0sCut()){
451  candidates.push_back(*(static_cast<AliAODConversionPhoton *>(photon))); // if no second loop is required add to events good gammas
452  }else if(cuts.UseElecSharingCut()){ // if Shared Electron cut is enabled, Fill array, add to step one
453  cuts.FillElectonLabelArray(static_cast<AliAODConversionPhoton *>(photon), nV0);
454  nV0++;
455  GammaCandidatesStepOne.push_back(static_cast<AliAODConversionPhoton *>(photon));
456  }else if(!cuts.UseElecSharingCut() && cuts.UseToCloseV0sCut()){ // shared electron is disabled, step one not needed -> step two
457  GammaCandidatesStepTwo.Add(static_cast<AliAODConversionPhoton *>(photon));
458  }
459  }
460 
461  if(cuts.UseElecSharingCut()){
462  int iV0 = 0;
463  for(auto photon : GammaCandidatesStepOne){
464  if(!cuts.RejectSharedElectronV0s(photon,iV0,GammaCandidatesStepOne.size())) continue;
465  if(!cuts.UseToCloseV0sCut()){ // To Close v0s cut diabled, step two not needed
466  candidates.push_back(*photon);
467  } else GammaCandidatesStepTwo.Add(photon); // Close v0s cut enabled -> add to list two
468  iV0++;
469  }
470  }
471 
472  if(cuts.UseToCloseV0sCut()){
473  for(int i = 0; i < GammaCandidatesStepTwo.GetEntries(); i++){
474  AliAODConversionPhoton *photon = static_cast<AliAODConversionPhoton *>(GammaCandidatesStepTwo.At(i));
475  if(!cuts.RejectToCloseV0s(photon, &GammaCandidatesStepTwo,i)) continue;
476  candidates.push_back(*photon); // Add gamma to current cut TList
477  }
478  }
479  return candidates;
480 }
481 
482 //=================================== SELECT MESON ====================================================================
483 std::vector<AliAODConversionMother> AliAnalysisTaskK0toPi0Pi0::SelectMeson(std::vector<AliAODConversionMother> &candidates,
484  AliConversionMesonCuts &cuts, MesonType_t meson, const char *reccase){
485  std::vector<AliAODConversionMother> selectedCandidates;
486  TString mesonName;
487  switch(meson) {
488  case kPi0: mesonName = "Pi0"; break;
489  case kK0: mesonName = "K0"; break;
490  };
491  TString qaname = "h" + mesonName + "Selection" + reccase;
492  for(auto candidate: candidates){
493  Int_t selectionStatus = cuts.MesonIsSelected(&candidate, kTRUE, 0);
494  fHistos->FillTH1(qaname, selectionStatus);
495  if(!selectionStatus) continue;
496  selectedCandidates.push_back(candidate);
497  }
498 
499  return selectedCandidates;
500 
501 
502 }
503 
504 //=================================== MAKE PI0 CANDIDATES ====================================================================
505 std::vector<AliAODConversionMother> AliAnalysisTaskK0toPi0Pi0::MakePi0Candidates(const std::vector<AliAODConversionPhoton> *primaryLeg,
506  const std::vector<AliAODConversionPhoton> *secondaryLeg,
507  AliConversionMesonCuts &cuts){
508  // secondary leg: optional argument, if different methods for photon identification (i.e. PCM-EMCAL) is used
509  AliDebug(1, Form("Make Pi0 candidates: Number of photons in first leg: %lu, second leg: %lu", primaryLeg->size(), secondaryLeg ? secondaryLeg->size() : 0));
510  std::vector<AliAODConversionMother> candidates;
511  if(secondaryLeg){
512  // Different methods for photon identification identification
513  for(auto primphoton : *primaryLeg){
514  for(auto secphoton : *secondaryLeg) {
515  AliAODConversionMother candidate(&primphoton, &secphoton);
516  AliDebug(2, Form("Made Pi0 candidate same - Mass %f [%f - %f] GeV/c2", candidate.M(), cuts.GetSelectionLow(), cuts.GetSelectionHigh()));
517  if(!cuts.CheckWhetherInMassRange(candidate.M()))continue;
518  AliDebug(2, "Candidate in mass window");
519  // Do Pi0 selection
520  //if(!cuts.MesonIsSelected(&candidate, kTRUE, 0)) continue; // Rapidity shift needed when going to asymmetric systems
521  candidates.push_back(candidate);
522  }
523  }
524  } else {
525  // Same method for photon identification
526  for(auto primiter = primaryLeg->begin(); primiter != primaryLeg->end(); ++primiter){
527  for(auto seciter = primiter + 1; seciter != primaryLeg->end(); ++seciter){
528  AliAODConversionMother candidate(&(*primiter), &(*seciter));
529  AliDebug(2, Form("Made Pi0 candidate mixed - Mass %f [%f - %f] GeV/c2", candidate.M(), cuts.GetSelectionLow(), cuts.GetSelectionHigh()));
530  if(!cuts.CheckWhetherInMassRange(candidate.M()))continue;
531  AliDebug(2, "Candidate in mass window");
532  // Do pi0 selection
533  //if(!cuts.MesonIsSelected(&candidate, kTRUE, 0)) continue; // Rapidity shift needed when going to asymmetric systems
534  candidates.push_back(candidate);
535  }
536  }
537  }
538  AliDebug(1, Form("Found %lu pi0 candidates in event\n", candidates.size()));
539  return candidates;
540 }
541 
542 // =================================== MAKE K0 SHORT CANDIDATES ====================================================================
543 std::vector<AliAODConversionMother> AliAnalysisTaskK0toPi0Pi0::MakeK0ShortCandidates(const std::vector<AliAODConversionMother> *primaryLeg,
544  const std::vector<AliAODConversionMother> *secondaryLeg,
545  AliConversionMesonCuts &cuts){
546  std::vector<AliAODConversionMother> candidates;
547  if(secondaryLeg) {
548  // Different methods for Pi0 identification (one same, one mixed)
549  for(const auto &primpi0 : *primaryLeg) {
550  for(const auto &secpi0 : *secondaryLeg) {
551  AliAODConversionMother candidate(&primpi0, &secpi0);
552  //if(!cuts.MesonIsSelected(&candidate, kTRUE, 0)) continue;
553  candidates.push_back(candidate);
554  }
555  }
556  } else {
557  // Same methods for Pi0 identification (both same or both mixed)
558  for(auto primpi0 = primaryLeg->begin(); primpi0 != primaryLeg->end(); ++primpi0) {
559  for(auto secpi0 = primpi0 + 1; secpi0 != primaryLeg->end(); ++secpi0) {
560  AliAODConversionMother candidate(&(*primpi0), &(*secpi0));
561  //if(!cuts.MesonIsSelected(&candidate, kTRUE, 0)) continue;
562  candidates.push_back(candidate);
563  }
564  }
565  }
566  return candidates;
567 }
568 
569 //=================================== MAKE PHOTON QA CALO ====================================================================
570 void AliAnalysisTaskK0toPi0Pi0::MakePhotonQACalo(const std::vector<AliAODConversionPhoton> &photons, AliConvEventCuts &cuts) {
571  for(const auto &photon : photons) {
572  fHistos->FillTH1("hCaloPhotonPt", photon.Pt());
573  }
574 }
575 
576 //=================================== MAKE PHOTON QA CONV ====================================================================
577 void AliAnalysisTaskK0toPi0Pi0::MakePhotonQAConv(const std::vector<AliAODConversionPhoton> &photons, AliConvEventCuts &cuts) {
578  for(const auto &photon : photons) {
579  fHistos->FillTH1("hConvPhotonPt", photon.Pt());
580  fHistos->FillTH2("hConvPhotonEtaR", photon.Eta(), photon.GetConversionRadius());
581  }
582 }
583 
584 //=================================== MAKE PI0 QA ====================================================================
585 void AliAnalysisTaskK0toPi0Pi0::MakePi0QA(const std::vector<AliAODConversionMother> &pi0s, const char *reccase, TString selectionStatus){
586  TString reccaseString = reccase;
587  fHistos->FillTH1("hNPi0CandidatesPerEvent" + selectionStatus + reccaseString, pi0s.size());
588  for(const auto &pi0 : pi0s) {
589  fHistos->FillTH2("hMassvsPtPi0" + selectionStatus + reccaseString + "All", pi0.M(), pi0.Pt());
590  // if in the pi0 mass region
591  if((0.08 <=pi0.M()) && (pi0.M()<= 0.145)){
592  fHistos->FillTH2("hMassvsPtPi0" + selectionStatus + reccaseString + "Sel", pi0.M(),pi0.Pt());
593  fHistos->FillTH2("hAlphavsPtPi0" + selectionStatus + reccaseString, pi0.GetAlpha(), pi0.Pt());
594  fHistos->FillTH2("hOpeningAnglevsPtPi0" + selectionStatus + reccaseString, pi0.GetOpeningAngle(), pi0.Pt());
595  }
596  }
597 }
598 
599 //=================================== MAKE KO SHORT QA ====================================================================
600 void AliAnalysisTaskK0toPi0Pi0::MakeK0ShortQA(const std::vector<AliAODConversionMother> &k0s,const char *reccase, TString selectionStatus){
601  TString reccaseString = reccase;
602  fHistos->FillTH1("hNK0CandidatesPerEvent" + selectionStatus + reccaseString, k0s.size());
603  for(const auto &k0: k0s) {
604  fHistos->FillTH2("hMassvsPtK0Short" + selectionStatus + reccaseString, k0.M(), k0.Pt());
605  fHistos->FillTH2("hOpeningAnglevsPtK0Short" + selectionStatus + reccaseString, k0.GetOpeningAngle(), k0.Pt());
606  }
607 }
608 
609 //=================================== ADD CLUSTER CONTAINER ====================================================================
612  return fClusterContainer;
613 }
614 
615 
616 
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:76
TList * GetCutHistograms()
AliCaloPhotonCuts * fCaloPhotonCuts
Calo photon cuts.
Bool_t ClusterIsSelected(AliVCluster *cluster, AliVEvent *event, AliMCEvent *mcEvent, Int_t isMC, Double_t weight=1., Long_t clusterID=-1)
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:83
TCanvas * c
Definition: TestFitELoss.C:172
TList * GetCutHistograms()
Definition: AliV0ReaderV1.h:81
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 * fPi0CutsConvConv
Cuts on the pi0 for the conv conv case.
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_t IsEventAcceptedByCut(AliConvEventCuts *ReaderCuts, AliVEvent *event, AliMCEvent *mcEvent, Int_t isHeavyIon, Bool_t isEMCALAnalysis)
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.
AliConversionMesonCuts * fPi0CutsConvCalo
Cuts on the pi0 for the conv calo case.
Double_t GetSelectionLow() const
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.
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)
Double_t GetSelectionHigh() const
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.
std::vector< AliAODConversionMother > SelectMeson(std::vector< AliAODConversionMother > &candidates, AliConversionMesonCuts &cuts, MesonType_t meson, const char *reccase)
void SetArray(const AliVEvent *event)
AliConvEventCuts * GetEventCuts()
Definition: AliV0ReaderV1.h:80
const char Option_t
Definition: External.C:48
Int_t fCurrentRun
Current run number (triggers RunChanged)
Container structure for EMCAL clusters.
TString meson
AliConversionMesonCuts * fK0Cuts
Cuts on the K0.
Bool_t PhotonIsSelected(AliConversionPhotonBase *photon, AliVEvent *event)
AliConvEventCuts * fEventCuts
Event cuts.