FairRoot/PandaRoot
PndSoftTriggerLine.cxx
Go to the documentation of this file.
1 // ************************************************************************
2 //
3 // Online SoftTrigger TriggerLine class
4 //
5 // K.Goetzen 08/2014
6 //
7 // ************************************************************************
8 
9 // The header file
10 #include "PndSoftTriggerLine.h"
11 
12 // C++ headers
13 #include <iostream>
14 
15 // ROOT headers
16 #include "TDatabasePDG.h"
17 #include "TParticlePDG.h"
18 #include "TObjArray.h"
19 #include "TObjString.h"
20 
21 // RHO headers
23 #include "RhoTuple.h"
24 
25 using std::cout;
26 using std::endl;
27 
28 // -------------------------------------------------------------------------
29 // Default constructor
30 // -------------------------------------------------------------------------
32  fMode(-1), fName(""), fDecay(""), fPrefix(""), fNTupleName(""), fWriteQA(false), fActive(true), fCC(false), fAux(false),
33  fQAMassMin(0.), fQAMassMax(20.), fMean(0.), fSigma(0.01), fThresh(0.), fTagNSig(5.),
34  fQASelector(0), fSelector(0), fNTuple(0)
35 {
36  fPdg = TDatabasePDG::Instance();
37 }
38 
39 // -------------------------------------------------------------------------
40 // constructor
41 // -------------------------------------------------------------------------
43  fMode(mode), fName(name), fDecay(dec), fPrefix(pre), fNTupleName(ntpname), fWriteQA(false), fActive(true), fCC(false), fAux(false),
44  fQAMassMin(0.), fQAMassMax(20.), fMean(0.), fSigma(0.01), fThresh(0.), fTagNSig(5.),
45  fQASelector(0), fSelector(0), fNTuple(0)
46 {
47  fPdg = TDatabasePDG::Instance();
48 }
49 
50 // -------------------------------------------------------------------------
51 // Destructor
52 // -------------------------------------------------------------------------
54 {
55  if (fQASelector) delete fQASelector;
56  if (fSelector) delete fSelector;
57 }
58 
59 // -------------------------------------------------------------------------
60 // creates the Ntuple; user is responsible to call this function
61 // -------------------------------------------------------------------------
63 {
64  // initialize RhoTuple according to flag
66 
67  // parse the decay pattern string and transform to fPdgList
69 
70  // create the selectors
73 }
74 
75 
76 // -------------------------------------------------------------------------
77 // convert the decay pattern string to a list of pdg codes (fPdgList)
78 // E.g.: "D0 -> K- pi+" gets converted to 421 -321 211
79 // Example with auxiliary resonance: "D*0 -> D0 [K- pi+] pi0" converts to 432 421 -99 -321 211 -98 111
80 // -------------------------------------------------------------------------
82 {
83  if (fDecay=="") return false;
84 
85  fPdgList.clear();
86 
87  TString toks[20];
88  int n=SplitString(fDecay," ",toks,20);
89 
90  if (toks[1]!="->" || n<4)
91  {
92  cout <<"[PndSoftTriggerLine] **** Invalid decay pattern '"<<fDecay.Data()<<"'"<<endl;
93  return false;
94  }
95 
96  bool flag=false; // store if end of aux list codes
97 
98  for (int i=0;i<n;++i)
99  {
100  if (toks[i] == "cc") {fCC = true; continue;} // switch charged conjugation
101  if (toks[i] == "->") continue; // ignore the arrow
102  if (toks[i] == "pbp0") {fPdgList.push_back(88880); continue;} // treat shortcut for pbarpSystem0
103  if (toks[i] == "pbp") {fPdgList.push_back(88888); continue;} // treat shortcut for pbarpSystem
104  if (toks[i] == "[") {fPdgList.push_back(-99);fAux=true; continue;} // auxiliary resonance list starts
105  if (toks[i] == "]") {fPdgList.push_back(-98); continue;} // auxiliary resonance list ends
106 
107  if (toks[i].BeginsWith("[")) {toks[i]=toks[i](1,1000); fAux=true; fPdgList.push_back(-99);} // auxiliary resonance list starts
108  if (toks[i].EndsWith("]")) {toks[i]=toks[i](0,toks[i].Length()-1); flag = true;} // auxiliary resonance list ends
109 
110  TParticlePDG *part = fPdg->GetParticle(toks[i]);
111  if (part) fPdgList.push_back(part->PdgCode());
112  else
113  {
114  cout <<"[PndSoftTriggerLine] **** Unknown particle name '"<<toks[i].Data()<<"'"<<endl;
115  return false;
116  }
117  if (flag) {fPdgList.push_back(-98); flag = false;} // auxiliary resonance list ends
118  }
119 
120  return true;
121 }
122 
123 
124 // -------------------------------------------------------------------------
125 // set new parameters for the QA selector
126 // -------------------------------------------------------------------------
127 void PndSoftTriggerLine::SetQASelector(double m, double w)
128 {
129  if (fQASelector) delete fQASelector;
130  fQASelector = new RhoMassParticleSelector("QASel"+fName, m, w);
131 }
132 
133 
134 // -------------------------------------------------------------------------
135 // set new parameters for the mass selector
136 // -------------------------------------------------------------------------
137 void PndSoftTriggerLine::SetSelector(double m, double w)
138 {
139  if (fSelector) delete fSelector;
140  fSelector = new RhoMassParticleSelector("Sel"+fName, m, w);
141 }
142 
143 
144 // -------------------------------------------------------------------------
145 // splits a string into tokens; toks is the return array and has to created by the calling entity
146 // -------------------------------------------------------------------------
147 int PndSoftTriggerLine::SplitString(TString s, TString delim, TString *toks, int maxtoks)
148 {
149  TObjArray *tok = s.Tokenize(delim);
150  int N = tok->GetEntries();
151  for (int i=0;i<N;++i) if (i<maxtoks) toks[i] = (((TObjString*)tok->At(i))->String()).Strip(TString::kBoth);
152  return N;
153 }
154 
155 
156 // -------------------------------------------------------------------------
157 // prints summary of this trigger line
158 // -------------------------------------------------------------------------
160 {
161  cout << "PndSoftTriggerLine: " << fName.Data() << " ("<<fPrefix.Data()<<")"<< endl;
162  cout << " Mode code : " << fMode << endl;
163  cout << " Decay pattern : " << fDecay.Data();
164  if ( fPdgList.size()>0 )
165  {
166  cout << " ( " << fPdgList[0]<<" -> ";
167  for (size_t i=1;i<fPdgList.size();++i)
168  {
169  if (fPdgList[i]==-99) cout <<" [";
170  else if (fPdgList[i]==-98) cout <<" ]";
171  else cout <<" "<<fPdgList[i];
172  }
173  if (fCC) cout <<" (+cc)";
174  cout <<" )"<< endl;
175  }else cout <<endl;
176  cout << " QA Window : " << fQAMassMin << " < m < " << fQAMassMax << endl;
177  cout << " Selector Window : " << "| m - " << fMean << " | < " << fTagNSig << " x " << fSigma << endl;
178  cout << " Tag threshold : " << fThresh << endl;
179  cout << " QA enabled : " << fWriteQA << endl;
180  cout << " Tag active : " << fActive << endl;
181 }
182 
183 
Int_t i
Definition: run_full.C:25
__m128 m
Definition: P4_F32vec4.h:28
void SetSelector(double m, double w)
TLorentzVector s
Definition: Pnd2DStar.C:50
int n
RhoMassParticleSelector * fQASelector
TString ntpname[10]
Definition: full_core_ntp.C:43
Int_t mode
Definition: autocutx.C:47
std::vector< int > fPdgList
RhoMassParticleSelector * fSelector
int SplitString(TString s, TString delim, TString *toks, int maxtoks)
TString name
void SetQASelector(double m, double w)