FairRoot/PandaRoot
softrig/PndSoftTriggerTask.h
Go to the documentation of this file.
1 #ifndef PndSoftTriggerTask_H
2 #define PndSoftTriggerTask_H 1
3 
4 
5 #include "FairTask.h"
6 #include <map>
7 #include <vector>
8 #include <string>
9 #include "TLorentzVector.h"
10 #include "RhoCandList.h"
11 #include "TDatabasePDG.h"
12 #include "RhoVtxPoca.h"
13 
14 class TClonesArray;
15 class TObjectArray;
16 class TH1F;
17 class TH2F;
18 
22 class PndAnalysis;
23 class RhoCandList;
24 class RhoTuple;
25 class RhoCandidate;
26 class PndEventShape;
27 class TDatabasePDG;
28 class PndRhoTupleQA;
29 class PndSoftTriggerLine;
30 
31 class PndSoftTriggerTask : public FairTask
32 {
33 
34  public:
35 
36  // *** Default constructor
37  PndSoftTriggerTask(double pmom, int mode=0, int runnum=0, TString trigfilename="");
38 
39  // *** Destructor
41 
42  // *** Virtual method Init
43  virtual InitStatus Init();
44 
45  // *** Virtual method Exec
46  virtual void Exec(Option_t* opt);
47 
48  virtual void Finish();
49 
50  // *** set default settings for fast and full sim
51  void SetFastSimDefaults();
52  void SetFullSimDefaults();
53 
54  // *** read selection configuration from file
55  void SetConfigurationFile(TString fname) {fCfgFileName = fname;}
56 
57  // switches between mass window only of full selection (selection defined in cfg file)
58  // 0: detailed selection turned off
59  // 1: exclusive mode (modes w/o detailed cut definitions are rejected)
60  // 2: open mode (modes w/o detailed cut definitions just have to fulfill their mass window criterion)
61  void ApplyFullSelection(int selmode=1) {fApplyFullSelection = selmode;}
62 
63  // *** set max number of sigmas deviation for tag
64  void SetTagNSigMode(int mode, double nsig);
65  void SetTagNSigAll(double nsig);
66  void SetAuxNSig(double nsig) {fNsigAux = nsig;} // n sigma cut for KS, pi0, eta
67  void SetDstMDiffCut(double cut) {fDstMDiffCut = cut;} // cut on delta M(D*, D); default = 10. GeV/c^2
68 
69  // *** set selection parameters for QA tuple
70  void SetPi0QASelection(double min, double max) {fPi0QaMin=min; fPi0QaMax=max;}
71  void SetKs0QASelection(double min, double max) {fKs0QaMin=min; fKs0QaMax=max;}
72  void SetEtaQASelection(double min, double max) {fEtaQaMin=min; fEtaQaMax=max;}
73 
75 
76  // *** set mean and sigma for tagging algos
80 
82 
83  // *** pre selection of neutral and charged + PID cut
84  void SetGammaMinE(double min) {fGammaMinE = min;}
85  void SetTrackMinP(double min) {fTrackMinP = min;}
86  void SetInitialPidCut(double cut) {fIniPidCut = cut;}
87 
88  // *** modifiers for PID selection string
89  void SetPidAlgoAll(TString algo);
90 
92  void SetPidAlgoMuon(TString algo) {fAlgoMuon=algo;}
93  void SetPidAlgoPion(TString algo) {fAlgoPion=algo;}
94  void SetPidAlgoKaon(TString algo) {fAlgoKaon=algo;}
96 
97  // *** Switch Tagging methods
98  void SetTagAll(bool tag=true);
99  // mode code as in triggerlines configuration file
100  void SetTagMode(int mode, bool tag=true);
101 
102  // *** Enable/Disable QA output
103  void SetQAPi0(bool qa=true) { fQAPi0 = qa;}
104  void SetQAEta(bool qa=true) { fQAEta = qa;}
105  void SetQAKs0(bool qa=true) { fQAKs0 = qa;}
106  void SetQAMc(bool qa=true) { fQAMc = qa;}
107  void SetQAMctOnly(bool qa=true) { fQAMctOnly = qa;}
108 
109  void SetQAEvent(bool qa=true) { fQAEvent = qa;}
110 
111  void SetQAAll(bool qa=true);
112  // mode code as in triggerlines configuration file
113  void SetQAMode(int mode, bool qa=true);
114 
115  // passed to PndAnalysis: this also allows mct match, when some soft photons are missing in decay
116  void McMatchAllowPhotos(int maxn=1, double thresh=0.05){fPhotosMax=maxn;fPhotosThresh=thresh;}
117 
118  void SetVerbose(int verb=10) {fVerbose=verb;}
119 
120  protected:
121 
122 
123  private:
124  // *** List preparation methods
125  void FillGlobalLists();
126  bool ReadConfiguration();
127  bool ReadTriggerLines();
128 
129  // *** methods for full candidate selection
130  int DoCombinatorics(RhoCandList &l, PndSoftTriggerLine *tl); // do combinatorics for certain trigger line
131  void CombineList(RhoCandList &l, int mothpdg, int amothpdg, std::vector<int> &idx, std::vector<int> &aidx, bool cc=false);
132  int AntiPdg(int pdg); // gives pdg code of antiparticle if exists
133  double GetVarValue(RhoCandidate *c, int id); // fill single candidate variable with index id
134  void FillVarArray(RhoCandidate *c, int id, Bool_t tmva=false); // fill candidate variable array for selection
135  void FillEventShapeVarArray(); // fill event shape variable array for selection
136 
137  bool AcceptCandidate(int mode, RhoCandidate *c, RhoParticleSelectorBase *sel=0); // accept candidate for full selection
138  bool AcceptDstCut(RhoCandidate *c); // accept the D* mass diff cut?
139  double GetPocaVtx(RhoCandidate* c, double &dist, double &ctau);
140  void GetAngles(RhoCandidate *c, double &oang, double &decang);
141 
142  // *** some helper functions
143  int SelectTruePid(RhoCandList &l);
144  int SelectPidProb(RhoCandList &l, int pididx, double cut);
145  int MultPidProb(RhoCandList &l, int pididx, double prob);
146  double DbMass(TString name) {if (fPdg->GetParticle(name)) return fPdg->GetParticle(name)->Mass(); else return 0.;}
147  int SplitString(TString s, TString delim, TString *toks, int maxtoks);
148  int DetermineRecoilMode(int &mode);
149  TLorentzVector BoostCms(TLorentzVector in);
150  int CodeVariable(TString v);
151 
152  // *** Created necessary composites
153  int CreateKs0Cands(RhoTuple *n);
154 
155  // *** General tagging method
156  int TagMode(PndSoftTriggerLine *tl, int &npre);
157 
158  // ----------------------------
159  // *** global vars
160  int fVerbose; // create verbose output
161  int fMode; // the signal or background mode code, to be set in the constructor
162  int fRecoilMode; // recoil mode code (0 = %, 1=gamma, 2=pi0, 3=eta, 4=2pi0, 5=2eta, 6=pi+pi-, 7=2pipi0, 8=K+K-, 9=K0 K0b)
163  int fRecoilCnt; // recoil counter (1*Ngamma + 10*Npi0 + 100*Npi+ + 1000*NK+ + 10000*NK0 + 100000*Neta)
164  int fEvtCount; // global event counter
165  int fRunNum; // run number
166  int fSigCount; // counter, unused for the time being
167  double fNsigTag; // max number of sigmas deviation of candidate to be tagged
168  double fNsigAux; // max number of sigmas deviation for auxilliary particle = pi0, K_S, eta
169  double fDstMDiffCut; // optional upper limit cut for D* -> DX decays on M(D*) - M(D) (explicit PDG codes 413, 423, 433)
170 
171  TString fCfgFileName; // file containing the detailed selection cuts
172  TString fTriggerFileName; // file containing the trigger setup
173  Int_t fPhotosMax; // passed over to PndAnalysis for MC match with photos on
174  Double_t fPhotosThresh; // passed over to PndAnalysis for MC match with photos on
175 
176  int fApplyFullSelection; // 0: detailed selection turned off
177  // 1: exclusive mode (modes w/o detailed cut definitions are rejected)
178  // 2: open mode (modes w/o detailed cut definitions just have to fulfill their mass window criterion)
179 
180  // *** initial pbar p system info
181  TLorentzVector fIniP4;
182  double fEcm;
183  double fPbarMom;
184  TVector3 fPrimVtx; // primary vertex estimate of all charged tracks by RhoVtxPoca
185  double fPrimVtxQa; // and primary vtx quality
186 
187  // ----------------------------
188  // *** flags for enable/disable QA ntuple output
189  bool fQAPi0; // QA tuple for pi0
190  bool fQAEta; // QA tuple for eta
191  bool fQAKs0; // QA tuple for KS
192  bool fQAEvent; // QA tuple for event (with tag info)
193  bool fQAMc; // QA tuple for MC lists
194  bool fQAMctOnly; // store QA info only for MCT
195 
196  // ----------------------------
197  // *** parameters for ntuple QA window
198  double fPi0QaMin; // min value for pi0 selection
199  double fPi0QaMax; // max value for pi0 selection
200 
201  double fEtaQaMin; // min value for eta(gg) selection
202  double fEtaQaMax; // max value for eta(gg) selection
203 
204  double fKs0QaMin; // min value for Ks selection
205  double fKs0QaMax; // max value for Ks selection
206 
207 
208  // ----------------------------
209  // *** signal parameters for different channels
210  double fPi0Mean; // mean value for pi0 signal
211  double fPi0Sigma; // sigma value for pi0 signal
212 
213  double fEtaMean; // mean value for eta(gg) signal
214  double fEtaSigma; // sigma value for eta(gg) signal
215 
216  double fKs0Mean; // mean value for Ks signal
217  double fKs0Sigma; // sigma value for Ks signal
218 
219  // *** general cuts
220  double fGammaMinE; // minimum energy for gamma candidates
221  double fPi0MinE; // minimum energy for pi0 candidates
222  double fEtaMinE; // minimum energy for eta candidates
223  double fTrackMinP; // minimum momentum for charged candidates
224  double fIniPidCut; // Tightness of initial PID (cut on probability)
225 
226  // *** global mass selectors
227  RhoMassParticleSelector *fPi0Sel; // pi0 selector (g g)
228  RhoMassParticleSelector *fPi0PreSel; // pi0 pre selector
229 
230  RhoMassParticleSelector *fEtaSel; // eta selector (g g)
231  RhoMassParticleSelector *fEtaPreSel; // eta pre selector
232 
233  RhoMassParticleSelector *fKs0Sel; // Ks0 selector (pi pi)
234  RhoMassParticleSelector *fKs0PreSel; // Ks0 pre selector
235 
236 
237  // *** global kin selectors
239  RhoEnergyParticleSelector *fEnergySel; // cut for minimum E
240 
241  // *** pid algos
242  TString fAlgoElectron; // Pid algo definition string electrons
243  TString fAlgoMuon; // Pid algo definition string muons
244  TString fAlgoPion; // Pid algo definition string pions
245  TString fAlgoKaon; // Pid algo definition string kaons
246  TString fAlgoProton; // Pid algo definition string protons
247 
248 
249  Int_t fPidMult_025[5]; // cache for the PID multiplicities with P>=0.25
250 
251 
252  // *** declare NTuples
253  RhoTuple *ntp; // overall info
254  RhoTuple *nks0; // Ks0 QA
255  RhoTuple *npi0; // pi0 QA
256  RhoTuple *neta; // eta QA
257  RhoTuple *nmc; // MC QA
258 
259  // *** the PndAnalysis object
261 
262  // *** Pointer to event shape object
264 
265  // *** RhoTuple QA helper class
267 
268  // *** Poca vertexer
270 
271  // PDG database object
272  TDatabasePDG *fPdg;
273 
274  // *** global RhoCandLists
280 
284 
285  // *** index PID lists with ordering: e+ e- mu+ mu- pi+ pi- K+ K- p pb gam pi0 KS eta
287 
288 
289  // *** Get parameter containers
290  virtual void SetParContainers();
291 
292  FairRootManager* fRootManager;
293  TClonesArray* fTcaOnlineFilterInfo;
294 
296 
297 };
298 
299 #endif
RhoMassParticleSelector * fEtaSel
RhoMassParticleSelector * fKs0Sel
double DbMass(TString name)
RhoEnergyParticleSelector * fEnergySel
void SetPidAlgoPion(TString algo)
void SetPi0QASelection(double min, double max)
void SetPidAlgoMuon(TString algo)
int SelectTruePid(RhoCandList &l)
Int_t tag
Definition: crosstag.C:23
TLorentzVector s
Definition: Pnd2DStar.C:50
int n
void SetConfigurationFile(TString fname)
void SetPidAlgoElectron(TString algo)
void SetKs0SignalParams(double mean, double sigma)
RhoMassParticleSelector * fPi0PreSel
Double_t sigma[nsteps]
Definition: dedx_bands.C:65
void SetPidAlgoKaon(TString algo)
friend F32vec4 max(const F32vec4 &a, const F32vec4 &b)
Definition: P4_F32vec4.h:26
void SetPi0SignalParams(double mean, double sigma)
int SelectPidProb(RhoCandList &l, int pididx, double cut)
__m128 v
Definition: P4_F32vec4.h:4
virtual void Exec(Option_t *opt)
void SetKs0QASelection(double min, double max)
double cut[MAX]
Definition: autocutx.C:36
int DoCombinatorics(RhoCandList &l, PndSoftTriggerLine *tl)
Int_t mode
Definition: autocutx.C:47
ClassDef(PndSoftTriggerTask, 1)
int idx[MAX]
Definition: autocutx.C:38
void FillVarArray(RhoCandidate *c, int id, Bool_t tmva=false)
RhoMassParticleSelector * fKs0PreSel
void SetEtaSignalParams(double mean, double sigma)
Double_t
bool AcceptCandidate(int mode, RhoCandidate *c, RhoParticleSelectorBase *sel=0)
double GetPocaVtx(RhoCandidate *c, double &dist, double &ctau)
TLorentzVector BoostCms(TLorentzVector in)
void SetQAMctOnly(bool qa=true)
friend F32vec4 min(const F32vec4 &a, const F32vec4 &b)
Definition: P4_F32vec4.h:25
void SetEtaQASelection(double min, double max)
TString name
void SetTagMode(int mode, bool tag=true)
void SetQAMode(int mode, bool qa=true)
int nsig
Definition: toy_core.C:46
int TagMode(PndSoftTriggerLine *tl, int &npre)
RhoMassParticleSelector * fEtaPreSel
void SetTagNSigMode(int mode, double nsig)
RhoMassParticleSelector * fPi0Sel
RhoMomentumParticleSelector * fMomentumSel
int MultPidProb(RhoCandList &l, int pididx, double prob)
Double_t mean[nsteps]
Definition: dedx_bands.C:65
void SetInitialPidCut(double cut)
void SetPidAlgoProton(TString algo)
bool AcceptDstCut(RhoCandidate *c)
void McMatchAllowPhotos(int maxn=1, double thresh=0.05)
void CombineList(RhoCandList &l, int mothpdg, int amothpdg, std::vector< int > &idx, std::vector< int > &aidx, bool cc=false)
double GetVarValue(RhoCandidate *c, int id)
void ApplyFullSelection(int selmode=1)
int SplitString(TString s, TString delim, TString *toks, int maxtoks)
void GetAngles(RhoCandidate *c, double &oang, double &decang)