00001 #include <Riostream.h>
00002 #include <TMath.h>
00003
00004 #include <StEmcPool/StPhotonCommon/MyEvent.h>
00005 #include <StEmcPool/StPhotonCommon/MyPoint.h>
00006
00007
00008 #include "AnaCuts.h"
00009
00010 #include "EventMixer.h"
00011
00012 ClassImp(EventMixer)
00013
00014 EventMixer::EventMixer(const char *flag)
00015 {
00016 fNmixed=0;
00017
00018 ev_array=new TClonesArray("MyEvent",10);
00019 ev_array->SetOwner(kTRUE);
00020
00021 cuts=new AnaCuts(flag);
00022 cout<<"EventMixer is constructed"<<endl;
00023
00024 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);
00025 h_minvMB_mixed->Sumw2();
00026
00027 }
00028 EventMixer::~EventMixer()
00029 {
00030 cout<<"EventMixer is destructed"<<endl;
00031 }
00032 void EventMixer::addEvent(MyEvent *ev)
00033 {
00034 if(ev->trigger()&1 && TMath::Abs(ev->vertex().Z())>0. && ev->numberOfPoints()>1){
00035 TClonesArray &array=*ev_array;
00036 new(array[fNmixed++]) MyEvent(*ev);
00037
00038 if(fNmixed==10){
00039 mix();
00040 ev_array->Clear();
00041 fNmixed=0;
00042 }
00043 }
00044 }
00045
00046 void EventMixer::mix()
00047 {
00048
00049 for(int i_ev=0;i_ev<10;i_ev++){
00050
00051 MyEvent *e1=(MyEvent*)ev_array->At(i_ev);
00052 TClonesArray *clA=e1->getPointArray();
00053
00054 for(int j_ev=i_ev+1;j_ev<10;j_ev++){
00055
00056 MyEvent *e2=(MyEvent*)ev_array->At(j_ev);
00057 TClonesArray *clB=e2->getPointArray();
00058
00059 MyPoint *p;
00060 MyPoint *pp;
00061 for(Int_t j=0;j<clA->GetEntries();j++)
00062 {
00063 p=(MyPoint*)clA->At(j);
00064
00065 TVector3 pPos=p->position();
00066 TVector3 pMom=pPos - e1->vertex();
00067 pMom.SetMag(p->energy());
00068
00069 if(!cuts->isPointOK(p,e1->vertex())) continue;
00070
00071
00072 for(Int_t jj=0;jj<clB->GetEntries();jj++)
00073 {
00074 pp=(MyPoint*)clB->At(jj);
00075
00076 TVector3 ppPos=pp->position();
00077 TVector3 ppMom=ppPos - e2->vertex();
00078 ppMom.SetMag(pp->energy());
00079 if(!cuts->isPointOK(pp,e2->vertex())) continue;
00080
00081
00082
00083 TVector3 pi0Mom=pMom+ppMom;
00084
00085 Float_t angle=pMom.Angle(ppMom);
00086 Float_t minv=TMath::Sqrt(2.*p->energy()*pp->energy()*(1. - TMath::Cos(angle)));
00087 Float_t pTpion=pi0Mom.Pt();
00088 Float_t etapion=pi0Mom.PseudoRapidity();
00089 Float_t asymm=TMath::Abs(p->energy()-pp->energy())/(p->energy()+pp->energy());
00090
00091 if(etapion<cuts->rapPionMinCUT||etapion>cuts->rapPionMaxCUT) continue;
00092 if(asymm>cuts->asymmetryCUT) continue;
00093
00094 h_minvMB_mixed->Fill(pTpion,minv);
00095 }
00096
00097 }
00098
00099 }
00100 }
00101
00102
00103 }
00104