FairRoot/PandaRoot
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
Photospp::PhotosBranch Class Reference

#include <PhotosBranch.h>

Public Member Functions

 PhotosBranch (PhotosParticle *p)
 
PhotosParticlegetDecayingParticle ()
 
vector< PhotosParticle * > getMothers ()
 
vector< PhotosParticle * > getDaughters ()
 
vector< PhotosParticle * > getParticles ()
 
int getSuppressionStatus ()
 
int getForcingStatus ()
 
bool checkMomentumConservation ()
 
void process ()
 
 PhotosBranch (PhotosParticle *p)
 
PhotosParticlegetDecayingParticle ()
 
vector< PhotosParticle * > getMothers ()
 
vector< PhotosParticle * > getDaughters ()
 
vector< PhotosParticle * > getParticles ()
 
int getSuppressionStatus ()
 
int getForcingStatus ()
 
bool checkMomentumConservation ()
 
void process ()
 

Static Public Member Functions

static vector< PhotosBranch * > createBranches (vector< PhotosParticle * > particles)
 
static vector< PhotosBranch * > createBranches (vector< PhotosParticle * > particles)
 

Private Member Functions

int checkSuppressionLevel ()
 
int checkForcingLevel ()
 
int checkList (bool forceOrSuppress)
 
int checkSuppressionLevel ()
 
int checkForcingLevel ()
 
int checkList (bool forceOrSuppress)
 

Private Attributes

int suppression
 
int forcing
 
PhotosParticleparticle
 
vector< PhotosParticle * > mothers
 
vector< PhotosParticle * > daughters
 

Detailed Description

Definition at line 23 of file PhotosBranch.h.

Constructor & Destructor Documentation

PhotosBranch::PhotosBranch ( PhotosParticle p)

Create branch out of decaying particle

Definition at line 15 of file PhotosBranch.cxx.

References checkForcingLevel(), checkMomentumConservation(), checkSuppressionLevel(), daughters, Photospp::Log::Debug(), Photospp::PhotosParticle::findProductionMothers(), forcing, Photospp::PhotosParticle::getDaughters(), mothers, p, particle, suppression, and Photospp::Log::Warning().

Referenced by createBranches().

16 {
17  daughters = p->getDaughters();
18 
19  //Suppress if somehow got stable particle
20  if(daughters.size()==0)
21  {
22  Log::Debug(1)<<"Stable particle."<<endl;
23  suppression = 1;
24  forcing = 0;
25  particle = NULL;
26  return;
27  }
28  else if(daughters.at(0)->getMothers().size()==1)
29  {
30  // Regular case - one mother
31  Log::Debug(1)<<"Regular case."<<endl;
32  particle = p;
33  mothers = p->findProductionMothers();
34  }
35  else
36  {
37  // Advanced case - branch with multiple mothers - no mid-particle
38  Log::Debug(1)<<"Advanced case."<<endl;
39  particle = NULL;
40  mothers = daughters.at(0)->getMothers();
41  }
44  else suppression = 0;
45 
46  // Even if forced or passed suppression check, we still have to check few things
47  if(!suppression)
48  {
49  // Check momentum conservation
51  if(suppression) Log::Warning()<<"Branching ignored due to 4-momentum non conservation"<<endl;
52 
53  // Check if advanced case has only one daughter
54  if(!particle && daughters.size()==1) suppression=-1;
55 
56  // If any of special cases is true, we're not forcing this branch
57  if(suppression) forcing=0;
58  }
59 }
Double_t p
Definition: anasim.C:58
static ostream & Debug(unsigned short int code=0, bool count=true)
Definition: Log.cxx:30
vector< PhotosParticle * > daughters
Definition: PhotosBranch.h:75
PhotosParticle * particle
Definition: PhotosBranch.h:71
vector< PhotosParticle * > mothers
Definition: PhotosBranch.h:73
static ostream & Warning(bool count=true)
Definition: Log.cxx:46
Photospp::PhotosBranch::PhotosBranch ( PhotosParticle p)

Create branch out of decaying particle

Member Function Documentation

int Photospp::PhotosBranch::checkForcingLevel ( )
inlineprivate

Checks if branching is forced by PHOTOS.

Definition at line 61 of file PhotosBranch.h.

References checkList().

Referenced by PhotosBranch().

61 { return checkList(true); }
int checkList(bool forceOrSuppress)
int Photospp::PhotosBranch::checkForcingLevel ( )
inlineprivate

Checks if branching is forced by PHOTOS.

Definition at line 61 of file 3.52/src/photosCInterfaces/PhotosBranch.h.

References checkList().

61 { return checkList(true); }
int checkList(bool forceOrSuppress)
int PhotosBranch::checkList ( bool  forceOrSuppress)
private

Algorithm used for suppression/forcing check

Definition at line 206 of file PhotosBranch.cxx.

References daughters, Photospp::Photos::forceBremList, Photospp::PhotosParticle::getPdgID(), mothers, particle, and Photospp::Photos::supBremList.

Referenced by checkForcingLevel(), and checkSuppressionLevel().

207 {
208  vector< vector<int>* > *list = (forceOrSuppress) ? Photos::forceBremList : Photos::supBremList;
209  if(!list) return 0;
210 
211  // Can't check without pdgid
212  int motherID;
213  if(particle) motherID = particle->getPdgID();
214  else
215  {
216  if(mothers.size()==0) return 0;
217  motherID = mothers.at(0)->getPdgID();
218  }
219 
220  // Create list of daughters
221  vector<int> dID;
222  for(int j=0;j<(int)daughters.size();j++) dID.push_back(daughters[j]->getPdgID());
223 
224  vector< vector<int> *> &patternList = *list;
225 
226  // Check if the mother and list of daughters matches any of the declared patterns
227  for(int j=0; j<(int)patternList.size();j++)
228  {
229  // Skip patterns that don't have our mother
230  if(motherID!=(*patternList[j])[0]) continue;
231 
232  // Compare decay daughters with pattern - max O(n*m)
233  vector<int> &pattern = *patternList[j];
234  bool fullMatch=true;
235  for(int k = 1; k<(int)pattern.size()-1; k++)
236  {
237  bool oneMatch=false;
238  for(int l=0;l<(int)dID.size(); l++)
239  if(pattern[k]==dID[l]) { oneMatch=true; break; }
240  if(!oneMatch) { fullMatch=false; break; }
241  }
242  // Check if the matching pattern is set for consecutive suppression
243  /*
244  Currently minimal matching is used.
245  If e.g. 25 -> -15 is suppressed, then 25 -> 15,-15 and 25 -> 15,-15,22 etc. is suppressed too
246  For exact matching (then suppress 25 -> 15,-15 ; 25 -> 15,-15,22 etc. must be done separately) uncoment line ...:
247  */
248  // if(pattern.size()<=2 || (fullMatch && dID.size()==pattern.size()-2) )
249  // ...and comment out line:
250  if(pattern.size()<=2 || fullMatch)
251  return (pattern.back()==1) ? 2 : 1;
252  }
253  return 0;
254 }
static vector< vector< int > * > * forceBremList
Definition: Photos.h:163
static vector< vector< int > * > * supBremList
Definition: Photos.h:160
virtual int getPdgID()=0
vector< PhotosParticle * > daughters
Definition: PhotosBranch.h:75
PhotosParticle * particle
Definition: PhotosBranch.h:71
vector< PhotosParticle * > mothers
Definition: PhotosBranch.h:73
int Photospp::PhotosBranch::checkList ( bool  forceOrSuppress)
private

Algorithm used for suppression/forcing check

bool Photospp::PhotosBranch::checkMomentumConservation ( )

Checks momentum conservation of decaying particle. If it does not exist, checks momentum of first mother passed to photos

bool PhotosBranch::checkMomentumConservation ( )

Checks momentum conservation of decaying particle. If it does not exist, checks momentum of first mother passed to photos

Definition at line 85 of file PhotosBranch.cxx.

References Photospp::PhotosParticle::checkMomentumConservation(), mothers, and particle.

Referenced by PhotosBranch(), and process().

86 {
88  if(mothers.size()>0) return mothers.at(0)->checkMomentumConservation();
89  return true;
90 }
PhotosParticle * particle
Definition: PhotosBranch.h:71
vector< PhotosParticle * > mothers
Definition: PhotosBranch.h:73
virtual bool checkMomentumConservation()=0
int Photospp::PhotosBranch::checkSuppressionLevel ( )
inlineprivate

Checks if branching is suppressed by PHOTOS.

Definition at line 58 of file PhotosBranch.h.

References checkList().

Referenced by PhotosBranch().

58 { return checkList(false); }
int checkList(bool forceOrSuppress)
int Photospp::PhotosBranch::checkSuppressionLevel ( )
inlineprivate

Checks if branching is suppressed by PHOTOS.

Definition at line 58 of file 3.52/src/photosCInterfaces/PhotosBranch.h.

References checkList().

58 { return checkList(false); }
int checkList(bool forceOrSuppress)
static vector<PhotosBranch *> Photospp::PhotosBranch::createBranches ( vector< PhotosParticle * >  particles)
static

Create branches from particles list

vector< PhotosBranch * > PhotosBranch::createBranches ( vector< PhotosParticle * >  particles)
static

Create branches from particles list

Definition at line 92 of file PhotosBranch.cxx.

References b, Photospp::Log::Debug(), Photospp::Photos::forceBremList, forcing, Photospp::PhotosParticle::getBarcode(), getDecayingParticle(), Photospp::PhotosParticle::getDecayTree(), getForcingStatus(), getMothers(), Photospp::PhotosParticle::getPdgID(), getSuppressionStatus(), i, Photospp::Photos::isSuppressed, m, mothers, p, particle, PhotosBranch(), suppression, and tree.

Referenced by Photospp::PhotosEvent::process(), and Photospp::Photos::processBranch().

93 {
94  Log::Debug(700)<<"PhotosBranch::createBranches - filtering started"<<endl;
95  list<PhotosParticle *> list(particles.begin(),particles.end());
96  vector<PhotosBranch *> branches;
97 
98  // First - add all forced decays
100  {
101  std::list<PhotosParticle *>::iterator it;
102  for(it=list.begin();it!=list.end();it++)
103  {
104  PhotosBranch *branch = new PhotosBranch(*it);
105  int forcing = branch->getForcingStatus();
106  if(forcing)
107  {
108  Log::Debug(701)<<" Forced: "<<(*it)->getPdgID()<<" (barcode: "<<(*it)->getBarcode()<<") with forcing status= "<<forcing<<endl;
109  branches.push_back(branch);
110  it = list.erase(it);
111  --it;
112  // If forcing consecutive decays
113  if(forcing==2)
114  {
115  PhotosParticle *p = branch->getDecayingParticle();
116  if(!p){
117  if(branch->getMothers().size()>0) p = branch->getMothers().at(0);
118  }else {continue;}
119  vector<PhotosParticle *> tree = p->getDecayTree();
120  //Add branches for all particles from the list - max O(n*m)
121  std::list<PhotosParticle *>::iterator it2;
122  for(it2=list.begin();it2!=list.end();it2++)
123  {
124  for(int i=0;i<(int)tree.size();i++)
125  {
126  if(tree.at(i)->getBarcode()==(*it2)->getBarcode())
127  {
128  PhotosBranch *b = new PhotosBranch(*it2);
129  branches.push_back(b);
130  // If we were to delete our next particle in line
131  if(it==it2) --it;
132  it2 = list.erase(it2);
133  --it2;
134  break;
135  }
136  }
137  }
138  }
139  }
140  else delete branch;
141  }
142  }
143  // Quit if we're suppressing everything
144  if(Photos::isSuppressed) return branches;
145  // Now - check if remaining decays are suppressed
146  while(!list.empty())
147  {
148  PhotosParticle *particle = list.front();
149  list.pop_front();
150  if(!particle) continue;
151 
152  PhotosBranch *branch = new PhotosBranch(particle);
153  int suppression = branch->getSuppressionStatus();
154  if(!suppression) branches.push_back(branch);
155  else
156  {
157  Log::Debug(702)<<" Suppressed: "<<particle->getPdgID()<<" (barcode: "<<particle->getBarcode()<<") with suppression status= "<<suppression<<endl;
158  //If suppressing consecutive decays
159  if(suppression==2)
160  {
161  PhotosParticle *p = branch->getDecayingParticle();
162  if(!p){
163  if(branch->getMothers().size()>0) p = branch->getMothers().at(0);
164  }else {continue;}
165  vector<PhotosParticle *> tree = p->getDecayTree();
166  //Remove all particles from the list - max O(n*m)
167  std::list<PhotosParticle *>::iterator it;
168  for(it=list.begin();it!=list.end();it++)
169  {
170  for(int i=0;i<(int)tree.size();i++)
171  {
172  if(tree.at(i)->getBarcode()==(*it)->getBarcode())
173  {
174  it = list.erase(it);
175  --it;
176  break;
177  }
178  }
179  }
180  }
181  delete branch;
182  continue;
183  }
184 
185  //In case we don't have mid-particle erase rest of the mothers from list
186  if(!branch->getDecayingParticle())
187  {
188  vector<PhotosParticle *> mothers = branch->getMothers();
189  for(int i=0;i<(int)mothers.size();i++)
190  {
191  PhotosParticle *m = mothers.at(i);
192  if(m->getBarcode()==particle->getBarcode()) continue;
193  std::list<PhotosParticle *>::iterator it;
194  for(it=list.begin();it!=list.end();it++)
195  if(m->getBarcode()==(*it)->getBarcode())
196  {
197  it = list.erase(it);
198  break;
199  }
200  }
201  }
202  }
203  return branches;
204 }
Double_t p
Definition: anasim.C:58
Int_t i
Definition: run_full.C:25
__m128 m
Definition: P4_F32vec4.h:28
TTree * b
TTree * tree
Definition: plot_dirc.C:12
static vector< vector< int > * > * forceBremList
Definition: Photos.h:163
static ostream & Debug(unsigned short int code=0, bool count=true)
Definition: Log.cxx:30
static bool isSuppressed
Definition: Photos.h:154
PhotosParticle * particle
Definition: PhotosBranch.h:71
vector< PhotosParticle * > mothers
Definition: PhotosBranch.h:73
Abstract base class for particle in the event. This class also handles boosting.
PhotosBranch(PhotosParticle *p)
Single branching point.
vector<PhotosParticle *> Photospp::PhotosBranch::getDaughters ( )
inline

Get list of daughters

Definition at line 36 of file PhotosBranch.h.

References daughters.

Referenced by Photospp::PH_HEPEVT_Interface::set().

36 { return daughters; }
vector< PhotosParticle * > daughters
Definition: PhotosBranch.h:75
vector<PhotosParticle *> Photospp::PhotosBranch::getDaughters ( )
inline

Get list of daughters

Definition at line 36 of file 3.52/src/photosCInterfaces/PhotosBranch.h.

References daughters.

36 { return daughters; }
vector< PhotosParticle * > daughters
Definition: PhotosBranch.h:75
PhotosParticle* Photospp::PhotosBranch::getDecayingParticle ( )
inline

Return decaying particle. NULL if branching does not have mid-particle

Definition at line 30 of file 3.52/src/photosCInterfaces/PhotosBranch.h.

References particle.

30 { return particle; }
PhotosParticle * particle
Definition: PhotosBranch.h:71
PhotosParticle* Photospp::PhotosBranch::getDecayingParticle ( )
inline

Return decaying particle. NULL if branching does not have mid-particle

Definition at line 30 of file PhotosBranch.h.

References particle.

Referenced by createBranches(), and Photospp::PH_HEPEVT_Interface::set().

30 { return particle; }
PhotosParticle * particle
Definition: PhotosBranch.h:71
int Photospp::PhotosBranch::getForcingStatus ( )
inline

Check if branch is forced

Definition at line 45 of file PhotosBranch.h.

References forcing.

Referenced by createBranches().

45 { return forcing; }
int Photospp::PhotosBranch::getForcingStatus ( )
inline

Check if branch is forced

Definition at line 45 of file 3.52/src/photosCInterfaces/PhotosBranch.h.

References forcing.

45 { return forcing; }
vector<PhotosParticle *> Photospp::PhotosBranch::getMothers ( )
inline

Get list of mothers

Definition at line 33 of file PhotosBranch.h.

References mothers.

Referenced by createBranches(), and Photospp::PH_HEPEVT_Interface::set().

33 { return mothers; }
vector< PhotosParticle * > mothers
Definition: PhotosBranch.h:73
vector<PhotosParticle *> Photospp::PhotosBranch::getMothers ( )
inline

Get list of mothers

Definition at line 33 of file 3.52/src/photosCInterfaces/PhotosBranch.h.

References mothers.

33 { return mothers; }
vector< PhotosParticle * > mothers
Definition: PhotosBranch.h:73
vector<PhotosParticle *> Photospp::PhotosBranch::getParticles ( )

Get list of all particles used by branch

vector< PhotosParticle * > PhotosBranch::getParticles ( )

Get list of all particles used by branch

Definition at line 77 of file PhotosBranch.cxx.

References daughters, mothers, and particle.

78 {
79  vector<PhotosParticle *> ret = mothers;
80  if(particle) ret.push_back(particle);
81  ret.insert(ret.end(),daughters.begin(),daughters.end());
82  return ret;
83 }
vector< PhotosParticle * > daughters
Definition: PhotosBranch.h:75
PhotosParticle * particle
Definition: PhotosBranch.h:71
vector< PhotosParticle * > mothers
Definition: PhotosBranch.h:73
int Photospp::PhotosBranch::getSuppressionStatus ( )
inline

Check if branch is suppressed

Definition at line 42 of file 3.52/src/photosCInterfaces/PhotosBranch.h.

References suppression.

42 { return suppression; }
int Photospp::PhotosBranch::getSuppressionStatus ( )
inline

Check if branch is suppressed

Definition at line 42 of file PhotosBranch.h.

References suppression.

Referenced by createBranches(), and Photospp::Photos::processParticle().

42 { return suppression; }
void PhotosBranch::process ( )

Process single branch

Definition at line 61 of file PhotosBranch.cxx.

References checkMomentumConservation(), Photospp::PH_HEPEVT_Interface::complete(), Photospp::Log::Debug(), Photospp::PH_HEPEVT_Interface::get(), Photospp::PhotosParticle::getBarcode(), mothers, particle, photos_make_c_(), Photospp::PH_HEPEVT_Interface::prepare(), and Photospp::PH_HEPEVT_Interface::set().

Referenced by Photospp::Photos::processParticle().

62 {
63  Log::Debug(703)<<" Processing barcode: "<<( (particle) ? particle->getBarcode() : ( (mothers.size()) ? mothers.at(0)->getBarcode() : -1) )<<endl;
64  /*
65  cout<<"Particles send to photos (with barcodes in brackets):"<<endl;
66  vector<PhotosParticle *> get = getParticles();
67  for(int i=0;i<(int)get.size();i++) cout<<"ID: "<<get.at(i)->getPdgID()<<" ("<<get.at(i)->getBarcode()<<"), "; cout<<endl;
68  */
69  int index = PH_HEPEVT_Interface::set(this);
71  photos_make_c_(&index);
75 }
virtual int getBarcode()=0
static ostream & Debug(unsigned short int code=0, bool count=true)
Definition: Log.cxx:30
void photos_make_c_(int *id)
PhotosParticle * particle
Definition: PhotosBranch.h:71
vector< PhotosParticle * > mothers
Definition: PhotosBranch.h:73
static int set(PhotosBranch *branch)
void Photospp::PhotosBranch::process ( )

Process single branch

Member Data Documentation

vector< PhotosParticle * > PhotosBranch::daughters
private

List of daughters

Definition at line 75 of file PhotosBranch.h.

Referenced by checkList(), getDaughters(), getParticles(), and PhotosBranch().

int PhotosBranch::forcing
private

State of branching forcing

Definition at line 69 of file PhotosBranch.h.

Referenced by createBranches(), getForcingStatus(), and PhotosBranch().

vector< PhotosParticle * > PhotosBranch::mothers
private
PhotosParticle * PhotosBranch::particle
private
int PhotosBranch::suppression
private

State of branching suppression

Definition at line 67 of file PhotosBranch.h.

Referenced by createBranches(), getSuppressionStatus(), and PhotosBranch().


The documentation for this class was generated from the following files: