StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
EventMixer.cxx
1 #include <Riostream.h>
2 #include <TMath.h>
3 
4 #include <StEmcPool/StPhotonCommon/MyEvent.h>
5 #include <StEmcPool/StPhotonCommon/MyPoint.h>
6 //#include <StEmcPool/StPhotonCommon/MyMcTrack.h>
7 
8 #include "AnaCuts.h"
9 
10 #include "EventMixer.h"
11 using namespace std;
12 ClassImp(EventMixer)
13 
14 EventMixer::EventMixer(const char *flag)
15 {
16  fNmixed=0;
17 
18  ev_array=new TClonesArray("MyEvent",10);
19  ev_array->SetOwner(kTRUE);
20 
21  cuts=new AnaCuts(flag);
22  cout<<"EventMixer is constructed"<<endl;
23 
24  h_minvMB_mixed=new TH2F("h_minvMB_mixed","invariant mass vs pT MB (mixed events)",cuts->nPtBinsMB,cuts->ptBinsMB.GetArray(),cuts->nMinvBinsMB,cuts->mInvLowMB,cuts->mInvHighMB);
25  h_minvMB_mixed->Sumw2();
26 
27 }
28 EventMixer::~EventMixer()
29 {
30  cout<<"EventMixer is destructed"<<endl;
31 }
32 void EventMixer::addEvent(MyEvent *ev)
33 {
34  if(ev->trigger()&1 && TMath::Abs(ev->vertex().Z())>0. && ev->numberOfPoints()>1){
35  TClonesArray &array=*ev_array;
36  new(array[fNmixed++]) MyEvent(*ev);
37 
38  if(fNmixed==10){
39  mix();
40  ev_array->Clear();
41  fNmixed=0;
42  }
43  }
44 }
45 
46 void EventMixer::mix()
47 {
48 
49  for(int i_ev=0;i_ev<10;i_ev++){
50 
51  MyEvent *e1=(MyEvent*)ev_array->At(i_ev);
52  TClonesArray *clA=e1->getPointArray();
53 
54  for(int j_ev=i_ev+1;j_ev<10;j_ev++){
55 
56  MyEvent *e2=(MyEvent*)ev_array->At(j_ev);
57  TClonesArray *clB=e2->getPointArray();
58 
59  MyPoint *p;
60  MyPoint *pp;
61  for(Int_t j=0;j<clA->GetEntries();j++)
62  {
63  p=(MyPoint*)clA->At(j);
64 
65  TVector3 pPos=p->position();
66  TVector3 pMom=pPos - e1->vertex();
67  pMom.SetMag(p->energy());
68 
69  if(!cuts->isPointOK(p,e1->vertex())) continue;
70 
71 
72  for(Int_t jj=0;jj<clB->GetEntries();jj++)
73  {
74  pp=(MyPoint*)clB->At(jj);
75 
76  TVector3 ppPos=pp->position();
77  TVector3 ppMom=ppPos - e2->vertex();
78  ppMom.SetMag(pp->energy());
79  if(!cuts->isPointOK(pp,e2->vertex())) continue;
80 
81 
82  //two neutrals:
83  TVector3 pi0Mom=pMom+ppMom;
84 
85  Float_t angle=pMom.Angle(ppMom);
86  Float_t minv=TMath::Sqrt(2.*p->energy()*pp->energy()*(1. - TMath::Cos(angle)));
87  Float_t pTpion=pi0Mom.Pt();
88  Float_t etapion=pi0Mom.PseudoRapidity();
89  Float_t asymm=TMath::Abs(p->energy()-pp->energy())/(p->energy()+pp->energy());
90 
91  if(etapion<cuts->rapPionMinCUT||etapion>cuts->rapPionMaxCUT) continue;
92  if(asymm>cuts->asymmetryCUT) continue;
93 
94  h_minvMB_mixed->Fill(pTpion,minv);
95  }
96 
97  }
98 
99  }
100  }
101 
102 
103 }
104 
Definition: MyPoint.h:7