StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
FcsDYBGFilter.cxx
1 #include "FcsDYBGFilter.h"
2 
3 #include "StarGenerator/EVENT/StarGenParticle.h"
4 #include "StarGenerator/EVENT/StarGenEvent.h"
5 #include <string>
6 #include <iostream>
7 #include <fstream>
8 #include <cmath>
9 #include <vector>
10 #include <algorithm>
11 
12 static const float ZFCS = 710.16 + 13.9 + 15.0;
13 static const float XFCSMin = 16.69;
14 static const float XFCSMax = 16.69 + 22.0 * 5.542;
15 static const float YFCS = 34.0/2.0 * 5.542;
16 static const float FVCUT = 0;//2.5; //cm
17 static const float ETCUT = 0.8;
18 static const float DRCUT = 40.0;
19 static const float DYETCUT = 1.0;
20 static const float DYMASSCUT= 2.5;
21 
22 
23 static int ntot=0;
24 static int ngood=0;
25 
26 using namespace std;
27 //_______________________________________________________________
28 FcsDYBGFilter::FcsDYBGFilter():StarFilterMaker("fcsDYBGFilter") {
29  cout<<"FCS DYBG filter is used!!!"<<endl;
30  cout<<"FCS DYBG filter swap particles="<<mSwap<<endl;
31 }
32 
33 FcsDYBGFilter::FcsDYBGFilter(int dy, int check, int swap):StarFilterMaker("fcsDYBGFilter"), mDYmode(dy), mCheckmode(check), mSwap(swap){
34  cout<<"FCS DYBG filter is used!!!"<<endl;
35  cout<<"FCS DYBG filter DYMode="<<mDYmode<<endl;
36  cout<<"FCS DYBG filter Checkmode="<<mCheckmode<<endl;
37  cout<<"FCS DYBG filter swap particles="<<mSwap<<endl;
38 }
39 //_______________________________________________________________
41  ntot++;
42  // Get a reference to the current event
43  StarGenEvent& event = *mEvent;
44 
45  //event.Print();
46  int np=event.GetNumberOfParticles();
47  if(np <= 0) {return kError;}
48 
49  // apply DYBG conditions for events
50  TIter Iterator = event.IterAll();
51  StarGenParticle *p = 0;
52  vector<StarGenParticle*> forwardParticles;
53  while( ( p = (StarGenParticle*)Iterator.Next() ) ){
54  int pid = abs(p->GetId());
55 // if(p->GetStatus()!=1 || pid==111) continue;
56  if(p->GetStatus()!=1) continue;
57  if(p->GetPz()<0.0) continue; // +z direction only
58  if(p->pt()<ETCUT) continue;
59  //simple box cut around FCS (vertex here is in [mm])
60  float x = fabs (p->GetVx()/10.0 + p->GetPx() / p->GetPz() * (ZFCS - p->GetVz()/10.0));
61  if(x<XFCSMin+FVCUT || x>XFCSMax-FVCUT) continue;
62  float y = fabs (p->GetVy()/10.0 + p->GetPy() / p->GetPz() * (ZFCS - p->GetVz()/10.0));
63  if(y>YFCS-FVCUT) continue;
64  forwardParticles.push_back(p);
65  }
66  unsigned int size=forwardParticles.size();
67  if(size<2) return StarGenEvent::kReject;
68  UInt_t res = 0x10;
69  int accept=0;
70  std::vector<int> swap;
71  for(unsigned int i=0; i<size-1; i++){
72  StarGenParticle *p1=forwardParticles.at(i);
73  float x1 = p1->GetVx()/10.0 + p1->GetPx() / p1->GetPz() * (ZFCS - p1->GetVz()/10.0);
74  float y1 = p1->GetVy()/10.0 + p1->GetPy() / p1->GetPz() * (ZFCS - p1->GetVz()/10.0);
75  float pt1= p1->pt();
76  int pid1 = abs(p1->GetId());
77  for(unsigned int j=i + 1; j<size; j++){
78  StarGenParticle *p2=forwardParticles.at(j);
79  float x2 = p2->GetVx()/20.0 + p2->GetPx() / p2->GetPz() * (ZFCS - p2->GetVz()/10.0);
80  float y2 = p2->GetVy()/20.0 + p2->GetPy() / p2->GetPz() * (ZFCS - p2->GetVz()/10.0);
81  float pt2= p2->pt();
82  int pid2 = abs(p2->GetId());
83  TLorentzVector pair = p1->momentum() + p2->momentum();
84  float m=pair.M();
85  float dx=x1-x2;
86  float dy=y1-y2;
87  float dr=sqrt(dx*dx+dy*dy);
88  float xx_ep = x1*x2;
89  if(pid1==11 && pid2==11 && pt1>DYETCUT && pt2>DYETCUT && m>DYMASSCUT) res|=0x08;
90 // if(dr>DRCUT) {
91  if(xx_ep < 0) {
92  res |= 0x20;
93  int idx1 = p1->GetIndex();
94  int idx2 = p2->GetIndex();
95  cout << Form("FcsDYBGFilter : idx=%3d %3d Pid=%5d %5d E=%6.2f %6.2f M=%6.2f DR=%6.2f res=0x%03x, x1=%.3f, x2=%.3f, xx_ep=%.3f",
96  idx1,idx2,pid1,pid2,
97  p1->GetEnergy(),p2->GetEnergy(),m,dr,res,x1,x2,xx_ep) << endl;
98  if(pid1!=111 && pid1!=22 && abs(pid1)!=11) swap.push_back(idx1);
99  if(pid2!=111 && pid2!=22 && abs(pid2)!=11) swap.push_back(idx2);
100  accept++;
101  }
102  }
103  }
104  if(mDYmode && !(res & 0x08)) return StarGenEvent::kReject;
105  if(accept>0) {
106  ngood++;
107  int nswap=0;
108  if(mSwap){
109  //this has to be implemented with middle of GEANT (particle by particle) filter
110  cout << Form("FcsDYBGFilter : found %d accepted pairs, swapped %d particles when implemented",accept,swap.size())<<endl;
111  }else{
112  cout << Form("FcsDYBGFilter : found %d accepted pairs, No swap but could swap %d particles",accept,swap.size())<<endl;
113  }
114  cout << Form("FcsDYBGFilter : N_Genearted=%6d N_Accepted=%6d R=%6.4f",
115  ntot,ngood,float(ngood)/float(ntot)) <<endl;
116  return (StarGenEvent::kAccept | res);
117  }
118  if(mCheckmode) return (StarGenEvent::kReject | res | StarGenEvent::kFlag);
119  return StarGenEvent::kReject;
120 }
Int_t GetIndex()
Get the line number in the event record.
Float_t GetVz()
Get the z-component of the start vertex.
Float_t pt()
Returns the transverse momentum of the particle.
Yet another particle class.
Int_t GetStatus()
Get the status code of the particle according to the HEPEVT standard.
Float_t GetPz()
Get the z-component of the momentum.
Float_t GetEnergy()
Get the energy.
Int_t GetId()
Get the id code of the particle according to the PDG standard.
Main filter class. Goes anywhere in the chain, filters StarGenEvent objects.
Float_t GetPx()
Get the x-component of the momentum.
TLorentzVector momentum()
Return the 4-momentum of the particle.
Float_t GetVy()
Get the y-component of the start vertex.
Float_t GetPy()
Get the y-component of the momentum.
Base class for event records.
Definition: StarGenEvent.h:81
Int_t Filter(StarGenEvent *mEvent)
destructor
Float_t GetVx()
Get the x-component of the start vertex.