FairRoot/PandaRoot
PndListProvider.cxx
Go to the documentation of this file.
1 //--------------------------------------------------------------------------
2 // Description:
3 // Class PndListProvider
4 //
5 // List Container for PndSimpleAnalysis
6 //
7 // This software was developed for the PANDA collaboration. If you
8 // use all or part of it, please give an appropriate acknowledgement.
9 //
10 // Author List:
11 // Klaus Goetzen Original Author
12 //
13 // Copyright Information:
14 // Copyright (C) 2008 GSI
15 //
16 //------------------------------------------------------------------------
17 
18 //-----------------------
19 // This Class's Header --
20 //-----------------------
21 #include "PndListProvider.h"
22 
23 //----------------------
24 // Base Class Headers --
25 //----------------------
26 
27 #include <string>
28 #include <iostream>
29 
30 //-------------------------------
31 // Collaborating class Headers --
32 //-------------------------------
33 #include "TDatabasePDG.h"
34 #include "TParticlePDG.h"
35 #include "TH1F.h"
36 
37 #include "RhoCandList.h"
38 #include "RhoCandidate.h"
39 
40 
41 //--------------------------------------------
42 // Collaborating class forward declarations --
43 // -------------------------------------------
44 #include "ArgList.h"
45 
46 using std::cout;
47 using std::endl;
48 
49 // -------------------------------------------------------------------------
50 
51 PndListProvider::PndListProvider(std::string name,std::string pdgType)
52 {
53  fName=name;
54  fNDaughters=0;
55  fIsGeneric=false;
56  fToDump=false;
57  fHistoFilled=false;
58  fCandsUptodate=false;
59 
60  fHisto=0;
61 
62  fDaughterListNames.clear();
63  fDaughterPDG.clear();
64 
65  fOwnList.Cleanup();
66 
69  fMassSel = 0;
70 
71  if (pdgType!="") {
72  fParticlePDG=TDatabasePDG::Instance()->GetParticle(pdgType.c_str());
73  } else {
74  fParticlePDG=0;
75  }
76 }
77 
78 // -------------------------------------------------------------------------
79 
80 PndListProvider::PndListProvider(std::string name,int pdgcode)
81 {
82  fName=name;
83  fNDaughters=0;
84  fIsGeneric=false;
85  fHistoFilled=false;
86  fToDump=false;
87  fCandsUptodate=false;
88 
89  fHisto=0;
90 
91  fDaughterListNames.clear();
92  fDaughterPDG.clear();
93 
94  fOwnList.Cleanup();
95 
98  fMassSel = 0;
99 
100  if (pdgcode!=0) {
101  fParticlePDG=TDatabasePDG::Instance()->GetParticle(pdgcode);
102  } else {
103  fParticlePDG=0;
104  }
105 }
106 
107 // -------------------------------------------------------------------------
108 
109 
111 {
112  delete fMinusSel;
113  delete fPlusSel;
114  delete fMassSel;
115  Reset();
116 }
117 
118 // -------------------------------------------------------------------------
119 
120 void PndListProvider::SetType(std::string pdgType)
121 {
122  fParticlePDG=TDatabasePDG::Instance()->GetParticle(pdgType.c_str());
123 }
124 
125 // -------------------------------------------------------------------------
126 
127 void PndListProvider::SetType(int pdgcode)
128 {
129  fParticlePDG=TDatabasePDG::Instance()->GetParticle(pdgcode);
130 }
131 
132 // -------------------------------------------------------------------------
133 
134 void PndListProvider::AddDaughterType(std::string dtype)
135 {
136  fDaughterPDG.push_back(TDatabasePDG::Instance()->GetParticle(dtype.c_str()));
137 }
138 
139 // -------------------------------------------------------------------------
140 
142 {
143  fDaughterPDG.push_back(TDatabasePDG::Instance()->GetParticle(pdgcode));
144 }
145 
146 // -------------------------------------------------------------------------
147 
149 {
150  if ((int)fDaughterPDG.size()>i) {
151  return fDaughterPDG[i]->PdgCode();
152  }
153  return -1;
154 }
155 
156 // -------------------------------------------------------------------------
157 
158 void PndListProvider::AddDecayProduct(std::string dname)
159 {
160  fDaughterListNames.push_back(std::string(dname));
161  fNDaughters++;
162 }
163 
164 // -------------------------------------------------------------------------
165 
167 {
168  cout <<"[";
169  if (fParticlePDG) { cout <<fParticlePDG->PdgCode(); }
170  cout <<"]("<<fName<<")";
171  if (!fIsGeneric) {
172  cout <<" -> ";
173  for (int i=0; i<fNDaughters; i++) {
174  cout <<"[";
175  if (fDaughterPDG[i]) { cout << fDaughterPointers[i]->GetType(); }//cout <<fDaughterPDG[i]->PdgCode();
176  cout <<"]("<<fDaughterPointers[i]->GetName()<<")";//fDaughterListNames[i]<<") ";
177  if (fDaughterPointers[i]->IsGeneric()) { cout<<"G "; }
178  else { cout <<" "; }
179  }
180  }
181  cout <<endl;
182 }
183 
184 // -------------------------------------------------------------------------
185 
187 {
188  fOwnList.Cleanup();
189  fCandsUptodate=false;
190  fHistoFilled=false;
191 }
192 
193 // -------------------------------------------------------------------------
194 
196 {
197  Reset();
198 
199  if (fParticlePDG->AntiParticle()) {
200  if (fParticlePDG->Charge()<0) {
202  } else {
204  }
205  } else {
206  fOwnList=cl;
207  }
208 
209  fCandsUptodate=true;
210 }
211 
212 // -------------------------------------------------------------------------
213 
215 {
216  //if (fOwnList && fAntiOwnList) return (fOwnList->GetLength()+fAntiOwnList->GetLength());
217  //else
218  return fOwnList.GetLength();
219 }
220 
221 // -------------------------------------------------------------------------
222 
223 void
225 {
226  tcl.Cleanup();
227 
228  if (!fCandsUptodate) {
229  // ********* 2 Daughters
230  if (fNDaughters==2) {
231  RhoCandList fD1List,fD2List;
232  fDaughterPointers[0]->GetCandList(fD1List);
234  fDaughterPointers[1]->GetCandList(fD2List);
235  fOwnList.Combine(fD1List,fD2List);
236  } else {
237  fOwnList.Combine(fD1List,fD1List);
238  }
239 
240  //cout <<"d1:"<<fD1List.GetLength()<<" d2:"<<fD1List.GetLength()<<endl;
241  }
242  // ********* 3 Daughters
243  else if (fNDaughters==3) {
244  RhoCandList fDList[3];
245  PndListProvider* lp[3];
246  for (int i=0; i<3; i++) {
247  lp[i]=fDaughterPointers[i];
248  lp[i]->GetCandList(fDList[i]);
249  }
250  //3 different lists
251  if (lp[0]!=lp[1] && lp[1]!=lp[2] && lp[0]!=lp[2]) {
252  RhoCandList tmpL;
253  tmpL.Combine(fDList[0],fDList[1]);
254  fOwnList.Combine(tmpL,fDList[2]);
255  }
256  //at least 2 different lists
257  else if (lp[0]!=lp[1] || lp[1]!=lp[2] || lp[0]!=lp[2]) {
258  int id1=-1,id2=-1;
259  if (lp[0]==lp[1] && lp[0]!=lp[2]) {id1=0; id2=2;}
260  if (lp[0]==lp[2] && lp[0]!=lp[1]) {id1=0; id2=1;}
261  if (lp[1]==lp[2] && lp[0]!=lp[1]) {id1=1; id2=0;}
262 
263  //exact 2 list are the same
264  if (id1!=-1 && id2!=-1) {
265  RhoCandList tmpL;
266  tmpL.Combine(fDList[id1],fDList[id1]);
267  fOwnList.Combine(tmpL,fDList[id2]);
268  }
269  }
270  //all 3 lists are the same
271  else {
272  /*
273  RhoCandList tmpL;
274 
275  tmpL.Combine(fDList[0],fDList[0]);
276  fOwnList.Combine(tmpL,fDList[0]);
277  //fOwnList.RemoveClones();
278  */
279 
280  TLorentzVector vl;
281  Double_t charge;
282  Bool_t nearby = kTRUE;
283  RhoCandList l1;
284  lp[0]->GetCandList(l1);
285 
286  int endpos = l1.GetNumberOfTracks();
287 
288  //combination of a list with itself 3x
289  for (Int_t comb_i=0; comb_i<endpos; ++comb_i) {
290  for (Int_t comb_j=comb_i+1; comb_j<endpos; ++comb_j) {
291  for (Int_t comb_k=comb_j+1; comb_k<endpos; ++comb_k) {
292  if ( !l1[comb_i]->Overlaps( l1[comb_j] )
293  && !l1[comb_j]->Overlaps( l1[comb_k] )
294  && !l1[comb_i]->Overlaps( l1[comb_k] ) ) {
295  vl=l1[comb_i]->P4()+l1[comb_j]->P4()+l1[comb_k]->P4();
296  charge=l1[comb_i]->Charge()+l1[comb_j]->Charge()+l1[comb_k]->Charge();
297  //if (selector) nearby = selector->Accept(l1[comb_i],l2[comb_k]);
298  if (nearby) {
299  //fill list with new candidate
300  RhoCandidate c(vl,charge);
301  c.SetMarker(l1[comb_i]->GetMarker(0)|l1[comb_j]->GetMarker(0)|l1[comb_k]->GetMarker(0),0);
302  c.SetMarker(l1[comb_i]->GetMarker(1)|l1[comb_j]->GetMarker(1)|l1[comb_k]->GetMarker(1),1);
303  c.SetMarker(l1[comb_i]->GetMarker(2)|l1[comb_j]->GetMarker(2)|l1[comb_k]->GetMarker(2),2);
304  c.SetMarker(l1[comb_i]->GetMarker(3)|l1[comb_j]->GetMarker(3)|l1[comb_k]->GetMarker(3),3);
305  //if (selector!=0)
306  //{
307  // c.SetPosition(selector->GetVertex());
308  // c.SetVect(selector->GetMomentum());
309  // c.SetEnergy(c.E());
310  //}
311  // *************** modified by K Goetzen
312  c.AddDaughterLinkSimple(l1[comb_i]);
313  c.AddDaughterLinkSimple(l1[comb_j]);
314  c.AddDaughterLinkSimple(l1[comb_k]);
315  // ****************
316  fOwnList.Put(&c);
317  } //if nearby
318  }// overlap
319  }//for k
320  }//for j
321  }// for i
322 
323  }//else 3x same
324 
325  }
326 
327  if (fHisto)
328  for (int i=0; i<fOwnList.GetLength(); ++i) { fHisto->Fill(fOwnList[i]->Mass()); }
329 
330  if (fMassSel) { fOwnList.Select(fMassSel); }
331 
332  fCandsUptodate=true;
333  }
334 
335 
336  //cout <<fName<<":"<<fParticlePDG->PdgCode()<<endl;
337  //cout <<fOwnList<<endl;
338 
339  tcl=fOwnList;
340 }
341 
342 // -------------------------------------------------------------------------
343 
344 
345 std::string
347 {
348  if (i<fNDaughters) {
349  return fDaughterListNames[i];
350  } else { return ""; }
351 }
352 
353 // -------------------------------------------------------------------------
354 
356 {
357  if (p) { fDaughterPointers.push_back(p); }
358 }
359 
360 // -------------------------------------------------------------------------
361 
362 int
364 {
365  if (fParticlePDG) { return fParticlePDG->PdgCode(); }
366  else { return 0; }
367 }
368 
369 // -------------------------------------------------------------------------
370 
372 {
373  if (fHisto && !fHistoFilled) {
374  for (int i=0; i<fOwnList.GetLength(); ++i) { fHisto->Fill(fOwnList[i]->Mass()); }
375  fHistoFilled=true;
376  }
377 }
378 
379 // -------------------------------------------------------------------------
380 
381 void PndListProvider::SetMassSelector(double mean, double width)
382 {
383  if (!fMassSel) {
384  fMassSel=new RhoMassParticleSelector((fName+"sel").c_str(),mean,width);
385  }
386 }
387 
388 
389 /*
390 void PndListProvider::SetHisto(double min, double max, int bins)
391 {
392  fFillHisto=true;
393  double tmp=0;
394  if (min>max)
395  {
396  tmp=min;
397  min=max;
398  max=tmp;
399  }
400  fHisto=new TH1F(fName,fName,bins,min,max);
401 }
402 */
PndListProvider(std::string name, std::string pdgType="")
void AddDaughterLinkSimple(const RhoCandidate *, bool verbose=true)
Double_t p
Definition: anasim.C:58
RhoMinusParticleSelector * fMinusSel
void SetType(std::string pdgType)
void Append(const RhoCandidate *c)
Definition: RhoCandList.h:52
void Cleanup()
Definition: RhoCandList.cxx:62
Int_t i
Definition: run_full.C:25
void AddDecayProduct(std::string dname)
Int_t GetLength() const
Definition: RhoCandList.h:46
RhoCandList fOwnList
RhoMassParticleSelector * fMassSel
std::vector< PndListProvider * > fDaughterPointers
virtual ~PndListProvider()
void Combine(RhoCandList &l1, RhoCandList &l2)
RhoPlusParticleSelector * fPlusSel
Double_t
void SetMassSelector(double mean, double width)
ArgVector fDaughterListNames
std::string fName
void Select(RhoParticleSelectorBase *pidmgr)
void AddDaughterPointer(PndListProvider *p)
TString name
Int_t GetNumberOfTracks() const
Definition: RhoCandList.cxx:72
std::string GetDecayProdName(int i)
int GetDaughterType(int i)
void SetCandList(RhoCandList &cl)
std::vector< TParticlePDG * > fDaughterPDG
void Put(const RhoCandidate *, Int_t i=-1)
Definition: RhoCandList.cxx:77
void SetMarker(UInt_t l, UInt_t m)
void AddDaughterType(std::string dtype)
Double_t mean[nsteps]
Definition: dedx_bands.C:65
TParticlePDG * fParticlePDG
void GetCandList(RhoCandList &tl)