CbmRoot
Loading...
Searching...
No Matches
PairAnalysis.h
Go to the documentation of this file.
1/* Copyright (C) 2015-2020 Justus-Liebig-Universitaet Giessen, Giessen
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Julian Book [committer] */
4
5#ifndef PAIRANALYSIS_H
6#define PAIRANALYSIS_H
7
8#include <THnBase.h>
9#include <TNamed.h>
10#include <TObjArray.h>
11#include <TSpline.h>
12
13#include "AnalysisFilter.h"
14#include "PairAnalysisCutQa.h"
15#include "PairAnalysisHF.h"
16#include "PairAnalysisHistos.h"
17
19class THashList;
24
25//________________________________________________________________
26class PairAnalysis : public TNamed {
27
28 friend class PairAnalysisMixingHandler; //mixing as friend class
29public:
30 enum class EPairType
31 {
32 kSEPP = 0,
33 kSEPM,
34 kSEMM,
35 kMEPP,
36 kMEMP,
37 kMEPM,
38 kMEMM,
41 };
42 static constexpr Int_t fNTypes = static_cast<Int_t>(EPairType::kPairTypes);
43 enum class ELegType
44 {
45 kSEP,
46 kSEM,
48 };
49 static constexpr Int_t fLegTypes = static_cast<Int_t>(ELegType::kLegTypes);
50 enum class ECutType
51 {
52 kBothLegs = 0,
53 kAnyLeg,
55 };
56
58 PairAnalysis(const char* name, const char* title);
59 virtual ~PairAnalysis();
60
61 void Init();
62
63 void Process(TObjArray* arr);
64 Bool_t Process(PairAnalysisEvent* ev1);
65
66 const AnalysisFilter& GetEventFilter() const { return fEventFilter; }
67 const AnalysisFilter& GetTrackFilter() const { return fTrackFilter; }
68 const AnalysisFilter& GetPairFilter() const { return fPairFilter; }
69
71 const AnalysisFilter& GetPairFilterMC() const { return fPairFilterMC; }
72
79
82
84 void SetCutQA(Bool_t qa = kTRUE) { fCutQA = qa; }
85 void SetNoPairing(Bool_t noPairing = kTRUE) { fNoPairing = noPairing; }
86 Bool_t IsNoPairing() { return fNoPairing; }
87 void SetProcessLS(Bool_t doLS = kTRUE) { fProcessLS = doLS; }
88 Bool_t DoProcessLS() { return fProcessLS; }
89 void SetUseKF(Bool_t useKF = kTRUE) { fUseKF = useKF; }
90
91 const TObjArray* GetTrackArray(Int_t i) const { return (i >= 0 && i < 4) ? &fTracks[i] : 0; }
92 const TObjArray* GetPairArray(Int_t i) const
93 {
94 return (i >= 0 && i < fNTypes) ? static_cast<TObjArray*>(fPairCandidates->UncheckedAt(i)) : 0;
95 }
96
97 TObjArray** GetPairArraysPointer() { return &fPairCandidates; }
98 void SetPairArraysPointer(TObjArray* arr) { fPairCandidates = arr; }
99
100 // outputs - hist array
101 void SetHistogramArray(PairAnalysisHF* const histoarray) { fHistoArray = histoarray; }
102 const TObjArray* GetHistogramArray() const { return fHistoArray ? fHistoArray->GetHistArray() : 0x0; }
103 const THashList* GetQAHistList() const { return fQAmonitor ? fQAmonitor->GetQAHistList() : 0x0; }
104 // outputs - histos
105 void SetHistogramManager(PairAnalysisHistos* const histos) { fHistos = histos; }
106 PairAnalysisHistos* GetHistoManager() const { return fHistos; }
107 const THashList* GetHistogramList() const { return fHistos ? fHistos->GetHistogramList() : 0x0; }
108 // outputs - cut detailed histos
109 THashList* GetCutStepHistogramList() const { return fCutStepHistos->GetSize() ? fCutStepHistos : 0x0; }
110
111 Bool_t HasCandidates() const { return GetPairArray(1) ? GetPairArray(1)->GetEntriesFast() > 0 : 0; }
112 Bool_t HasCandidatesTR() const { return GetPairArray(7) ? GetPairArray(7)->GetEntriesFast() > 0 : 0; }
114 {
115 return (GetPairArray(0) && GetPairArray(2))
116 ? (GetPairArray(0)->GetEntriesFast() > 0 || GetPairArray(2)->GetEntriesFast() > 0)
117 : 0;
118 }
119
120 // prefilter
121 void SetPreFilterUnlikeOnly(Bool_t setValue = kTRUE) { fPreFilterUnlikeOnly = setValue; };
122 void SetPreFilterAllSigns(Bool_t setValue = kTRUE) { fPreFilterAllSigns = setValue; };
123
124 // background estimator - track rotation
127 void SetStoreRotatedPairs(Bool_t storeTR) { fStoreRotatedPairs = storeTR; }
128 // background estimator - mixed events
131
132 void SetDontClearArrays(Bool_t dontClearArrays = kTRUE) { fDontClearArrays = dontClearArrays; }
133 Bool_t DontClearArrays() const { return fDontClearArrays; }
134
135 // mc specific
136 void SetHasMC(Bool_t hasMC) { fHasMC = hasMC; }
137 void AddSignalMC(PairAnalysisSignalMC* signal);
138 void SetMotherPdg(Int_t pdgMother) { fPdgMother = pdgMother; }
139 void SetLegPdg(Int_t pdgLeg1, Int_t pdgLeg2)
140 {
141 fPdgLeg1 = pdgLeg1;
142 fPdgLeg2 = pdgLeg2;
143 }
144 void SetRefitWithMassAssump(Bool_t setValue = kTRUE) { fRefitMassAssump = setValue; }
145 const TObjArray* GetMCSignals() const { return fSignalsMC; }
146 Bool_t GetHasMC() const { return fHasMC; }
147 Int_t GetMotherPdg() const { return fPdgMother; }
148 Int_t GetLeg1Pdg() const { return fPdgLeg1; }
149 Int_t GetLeg2Pdg() const { return fPdgLeg2; }
150
151 static const char* TrackClassName(Int_t i) { return (i >= 0 && i < 2) ? fgkTrackClassNames[i] : ""; }
152 static const char* PairClassName(Int_t i) { return (i >= 0 && i < 8) ? fgkPairClassNames[i] : ""; }
153
154 Bool_t DoEventProcess() const { return fEventProcess; }
155 void SetEventProcess(Bool_t setValue = kTRUE) { fEventProcess = setValue; }
156 void FillHistogramsFromPairArray(Bool_t pairInfoOnly = kFALSE);
157
158private:
159 Bool_t fCutQA = kFALSE; // monitor cuts
160 PairAnalysisCutQa* fQAmonitor = NULL; // monitoring of cuts
161
164 AnalysisFilter fPairPreFilterLegs; // leg filter before pair prefilter cuts
165 AnalysisFilter fPairPreFilter; // pair prefilter cuts
166 AnalysisFilter fFinalTrackFilter; // Leg filter after the pair prefilter cuts
168
169 AnalysisFilter fTrackFilterMC; // MCtruth leg cuts
170 AnalysisFilter fPairFilterMC; // MCtruth pair cuts
171
172 Int_t fPdgMother = 443; // pdg code of mother tracks
173 Int_t fPdgLeg1 = 11; // pdg code leg1
174 Int_t fPdgLeg2 = 11; // pdg code leg2
175 Bool_t fRefitMassAssump = kFALSE; // wether refit under pdgleg mass assumption should be done
176
177 TObjArray* fSignalsMC = NULL; // array of PairAnalysisSignalMC
178
179 ECutType fCutType = ECutType::kBothLegs; // type of pairprefilterleg cut logic
180 Bool_t fNoPairing = kFALSE; // if to skip pairing, can be used for track QA only
181 Bool_t fProcessLS = kTRUE; // do the like-sign pairing
182 Bool_t fUseKF = kFALSE; // use KF particle for pairing
183
184 THashList* fCutStepHistos = NULL; // list of histogram managers
185 PairAnalysisHF* fHistoArray = NULL; // matrix of histograms
186 PairAnalysisHistos* fHistos = NULL; // Histogram manager
187 // Streaming and merging should be handled
188 // by the analysis framework
189 TBits* fUsedVars; // used variables
190
191 TObjArray fTracks[4];
192 // 0: SameEvent, positive particles
193 // 1: SameEvent, negative particles
194 // 2: MixedEvent, positive particles (not used)
195 // 3: MixedEvent, negative particles (not used)
196
197 TObjArray* fPairCandidates;
198 //TODO: better way to store it? TClonesArray?
199
201 PairAnalysisMixingHandler* fMixing = NULL; // handler for event mixing
202
203 Bool_t fPreFilterUnlikeOnly = kFALSE; // Apply PreFilter either in +- or to ++/--/+- individually
204 Bool_t fPreFilterAllSigns = kFALSE; // Apply PreFilter find in ++/--/+- and remove from all
205 Bool_t fHasMC = kFALSE; // If we run with MC, at the moment only needed in AOD
206 Bool_t fStoreRotatedPairs = kFALSE; // If the rotated pairs should be stored in the pair array
208 kFALSE; // Don't clear the arrays at the end of the Process function, needed for external use of pair and tracks
209 Bool_t fEventProcess = kTRUE; // Process event (or pair array)
210
211 void FillTrackArrays(PairAnalysisEvent* const ev);
212 void PairPreFilter(Int_t arr1, Int_t arr2, TObjArray& arrTracks1, TObjArray& arrTracks2);
213 void FilterTrackArrays(TObjArray& arrTracks1, TObjArray& arrTracks2);
214 void FillPairArrays(Int_t arr1, Int_t arr2);
215 void FillPairArrayTR();
216
217 Int_t GetPairIndex(Int_t arr1, Int_t arr2) const;
218
220 void ClearArrays();
221
222 TObjArray* PairArray(Int_t i);
223
224 static const char* fgkTrackClassNames[2]; // Names for track arrays
225 static const char* fgkPairClassNames[8]; // Names for pair arrays
226
227 void ProcessMC();
228
229 void FillHistograms(const PairAnalysisEvent* ev, Bool_t pairInfoOnly = kFALSE);
230 Bool_t FillMCHistograms(Int_t label1, Int_t label2, Int_t nSignal);
232 void FillHistogramsPair(PairAnalysisPair* pair, Bool_t fromPreFilter = kFALSE);
233 void FillHistogramsTracks(TObjArray** tracks);
234 void FillHistogramsHits(const PairAnalysisEvent* ev, TBits* fillMC, PairAnalysisTrack* track, Bool_t trackIsLeg,
235 Double_t* values);
236 void FillCutStepHistograms(AnalysisFilter* filter, UInt_t cutmask, PairAnalysisTrack* trk, const Double_t* values);
237 void FillCutStepHistogramsMC(AnalysisFilter* filter, UInt_t cutmask, Int_t label, const Double_t* values);
238
241
242 ClassDef(PairAnalysis, 2); //Steering class to process the data
243};
244
245inline Int_t PairAnalysis::GetPairIndex(Int_t arr1, Int_t arr2) const
246{
247 //
248 // get pair index
249 //
250 if (arr1 == 0 && arr2 == arr1) return static_cast<Int_t>(EPairType::kSEPP);
251 if (arr1 == 0 && arr2 == 1) return static_cast<Int_t>(EPairType::kSEPM);
252 if (arr1 == 1 && arr2 == arr1) return static_cast<Int_t>(EPairType::kSEMM);
253 if (arr1 == 0 && arr2 == 2) return static_cast<Int_t>(EPairType::kMEPP);
254 if (arr1 == 1 && arr2 == 2) return static_cast<Int_t>(EPairType::kMEMP);
255 if (arr1 == 0 && arr2 == 3) return static_cast<Int_t>(EPairType::kMEPM);
256 if (arr1 == 1 && arr2 == 3) return static_cast<Int_t>(EPairType::kMEMM);
257 return static_cast<Int_t>(EPairType::kSEPMRot);
258}
259
260
262{
263 //
264 // initialise all pair candidate arrays
265 //
266 fPairCandidates->SetOwner();
267 for (Int_t i = 0; i < 8; ++i) {
268 TObjArray* arr = new TObjArray;
269 arr->SetName(fgkPairClassNames[i]);
270 fPairCandidates->AddAt(arr, i);
271 arr->SetOwner();
272 }
273}
274
275inline TObjArray* PairAnalysis::PairArray(Int_t i)
276{
277 //
278 // for internal use only: unchecked return of pair array for fast access
279 //
280 return static_cast<TObjArray*>(fPairCandidates->UncheckedAt(i));
281}
282
284{
285 //
286 // Reset the Arrays
287 //
288 for (Int_t i = 0; i < 4; ++i) {
289 fTracks[i].Clear();
290 }
291 for (Int_t i = 0; i < 8; ++i) {
292 if (PairArray(i)) PairArray(i)->Delete();
293 }
294}
295
296#endif
TClonesArray * tracks
const THashList * GetQAHistList() const
const TObjArray * GetHistArray() const
AnalysisFilter fPairPreFilterLegs
void SetUseKF(Bool_t useKF=kTRUE)
void FillCutStepHistograms(AnalysisFilter *filter, UInt_t cutmask, PairAnalysisTrack *trk, const Double_t *values)
void SetMixingHandler(PairAnalysisMixingHandler *mix)
void SetRefitWithMassAssump(Bool_t setValue=kTRUE)
PairAnalysisTrackRotator * fTrackRotator
Pair candidate arrays.
const TObjArray * GetMCSignals() const
AnalysisFilter & GetPairFilterMC()
AnalysisFilter & GetTrackFilterMC()
static const char * fgkPairClassNames[8]
AnalysisFilter fFinalTrackFilter
TObjArray * fSignalsMC
TObjArray * fPairCandidates
Selected track candidates.
Bool_t DontClearArrays() const
PairAnalysisHF * fHistoArray
const THashList * GetQAHistList() const
Bool_t HasCandidatesLikeSign() const
Bool_t fPreFilterUnlikeOnly
Int_t GetMotherPdg() const
void SetPreFilterAllSigns(Bool_t setValue=kTRUE)
const AnalysisFilter & GetPairFilterMC() const
const AnalysisFilter & GetTrackFilterMC() const
void SetHistogramArray(PairAnalysisHF *const histoarray)
void FillHistograms(const PairAnalysisEvent *ev, Bool_t pairInfoOnly=kFALSE)
void FillHistogramsHits(const PairAnalysisEvent *ev, TBits *fillMC, PairAnalysisTrack *track, Bool_t trackIsLeg, Double_t *values)
Int_t GetLeg2Pdg() const
PairAnalysis(const PairAnalysis &c)
PairAnalysisTrackRotator * GetTrackRotator() const
AnalysisFilter & GetEventFilter()
AnalysisFilter fPairFilter
AnalysisFilter & GetPairPreFilterLegs()
const TObjArray * GetPairArray(Int_t i) const
void SetHistogramManager(PairAnalysisHistos *const histos)
THashList * fCutStepHistos
AnalysisFilter & GetPairFilter()
void SetLegPdg(Int_t pdgLeg1, Int_t pdgLeg2)
AnalysisFilter & GetPairPreFilter()
AnalysisFilter fPairFilterMC
void SetNoPairing(Bool_t noPairing=kTRUE)
void FillTrackArrays(PairAnalysisEvent *const ev)
AnalysisFilter fPairPreFilter
const AnalysisFilter & GetPairFilter() const
AnalysisFilter & GetFinalTrackFilter()
const THashList * GetHistogramList() const
void SetPairArraysPointer(TObjArray *arr)
void ClearArrays()
virtual ~PairAnalysis()
Int_t GetPairIndex(Int_t arr1, Int_t arr2) const
Bool_t DoEventProcess() const
void SetCutQA(Bool_t qa=kTRUE)
Bool_t FillMCHistograms(Int_t label1, Int_t label2, Int_t nSignal)
Bool_t HasCandidates() const
TBits * fUsedVars
Bool_t fStoreRotatedPairs
void SetHasMC(Bool_t hasMC)
PairAnalysis()
pair prefilter leg cut logic
void SetPreFilterUnlikeOnly(Bool_t setValue=kTRUE)
void FillHistogramsMC(const PairAnalysisEvent *ev, PairAnalysisEvent *ev1)
Bool_t fPreFilterAllSigns
Bool_t DoProcessLS()
void SetProcessLS(Bool_t doLS=kTRUE)
Int_t GetLeg1Pdg() const
ECutType fCutType
void AddSignalMC(PairAnalysisSignalMC *signal)
const TObjArray * GetTrackArray(Int_t i) const
Bool_t GetHasMC() const
static constexpr Int_t fLegTypes
TObjArray * PairArray(Int_t i)
Bool_t fNoPairing
void SetPairPreFilterLegCutType(ECutType type)
Bool_t fProcessLS
THashList * GetCutStepHistogramList() const
TObjArray fTracks[4]
Bool_t fEventProcess
PairAnalysisHistos * GetHistoManager() const
void SetDontClearArrays(Bool_t dontClearArrays=kTRUE)
AnalysisFilter fTrackFilter
void PairPreFilter(Int_t arr1, Int_t arr2, TObjArray &arrTracks1, TObjArray &arrTracks2)
PairAnalysisHistos * fHistos
AnalysisFilter & GetTrackFilter()
ClassDef(PairAnalysis, 2)
void FillHistogramsTracks(TObjArray **tracks)
void FillHistogramsFromPairArray(Bool_t pairInfoOnly=kFALSE)
const AnalysisFilter & GetTrackFilter() const
PairAnalysisCutQa * fQAmonitor
void SetEventProcess(Bool_t setValue=kTRUE)
PairAnalysisMixingHandler * fMixing
void FillCutStepHistogramsMC(AnalysisFilter *filter, UInt_t cutmask, Int_t label, const Double_t *values)
void SetTrackRotator(PairAnalysisTrackRotator *const rot)
PairAnalysisMixingHandler * GetMixingHandler() const
Bool_t fRefitMassAssump
const AnalysisFilter & GetEventFilter() const
void SetStoreRotatedPairs(Bool_t storeTR)
AnalysisFilter fTrackFilterMC
static const char * fgkTrackClassNames[2]
const TObjArray * GetHistogramArray() const
Bool_t fDontClearArrays
void FillPairArrays(Int_t arr1, Int_t arr2)
static const char * PairClassName(Int_t i)
static const char * TrackClassName(Int_t i)
PairAnalysis & operator=(const PairAnalysis &c)
AnalysisFilter fEventFilter
static constexpr Int_t fNTypes
TObjArray ** GetPairArraysPointer()
Bool_t IsNoPairing()
void FilterTrackArrays(TObjArray &arrTracks1, TObjArray &arrTracks2)
void InitPairCandidateArrays()
void SetMotherPdg(Int_t pdgMother)
void Process(TObjArray *arr)
void FillHistogramsPair(PairAnalysisPair *pair, Bool_t fromPreFilter=kFALSE)
Bool_t HasCandidatesTR() const