12 #include "MC4Vector.H"
13 #include "HEPParticle.H"
16 #include "TObjArray.h"
18 #define PI 3.141592653
20 inline bool ifSofty(
int Id,
int nparams,
double *params){
21 if (nparams<5 && Id==22)
return true;
22 for (
int i=nparams-1; i>3; i--)
23 if (Id==params[i])
return true;
28 inline void fillUserHisto(
char *name,
double val,
double weight=1.0,
29 double min=Setup::bin_min[0][0],
30 double max=Setup::bin_max[0][0]){
32 TH1D *h=(TH1D*)(Setup::user_histograms->FindObject(name));
34 h=
new TH1D(name,name,Setup::nbins[0][0],min,max);
36 Setup::user_histograms->Add(h);
42 double angle(
double X,
double Y){
46 double R=sqrt(X*X+Y*Y);
48 if(R<pow(10,-20))
return an;
50 if(TMath::Abs(X)/R<0.8)
53 if(Y<0 && an>0) an=-an;
54 if(Y>0 && an<0) an=-an;
59 if(X<0 && an>=0.) an=PI-an;
60 else if(X<0.) an=-PI-an;
66 int ZmumuAnalysis(HEPParticle *mother,HEPParticleList *stableDaughters,
int nparams,
double *params)
90 assert(stableDaughters!=0);
93 double threshold=0.05, leftmax=0.0, selector=0.0, actLost=0.0;
94 if (nparams>0 && params==0)
return -1;
95 if (nparams>0) threshold=params[0];
96 if (nparams>1) leftmax =params[1];
97 if (nparams>2) selector =params[2];
98 if (nparams>3) actLost =params[3];
101 HEPParticleList *lostDaughters=
new HEPParticleList;
102 double pt_limit=threshold*mother->GetM();
104 HEPParticleListIterator daughters (*stableDaughters);
106 double ephot=pow(10,22);
108 for (HEPParticle *part=daughters.first(); part!=0; (redo)? part=part:part=daughters.next() ) {
110 MC4Vector d4(part->GetE(),part->GetPx(),part->GetPy(),part->GetPz(),part->GetM());
112 d4.Boost(mother->GetPx(),mother->GetPy(),mother->GetPz(),mother->GetE(),mother->GetM());
116 double p_t=d4.GetX0();
117 switch ((
int) selector)
119 case 1: p_t=part->GetE();
break;
120 case 2: p_t=d4.Xt();
break;
124 if(ifSofty(part->GetPDGId(),nparams,params)) nphot++;
125 if ( ifSofty(part->GetPDGId(),nparams,params) && p_t < pt_limit) {
128 lostDaughters->push_back(part);
129 stableDaughters->remove(part);
130 part=daughters.first();
134 if( ifSofty(part->GetPDGId(),nparams,params) && ephot>p_t) ephot=p_t;
136 while(nphot>(
int) leftmax)
138 double ephot1=pow(10,22);
140 for (HEPParticle *part=daughters.first(); part!=0; (redo)? part=part:part=daughters.next() ) {
142 MC4Vector d4(part->GetE(),part->GetPx(),part->GetPy(),part->GetPz(),part->GetM());
144 d4.Boost(mother->GetPx(),mother->GetPy(),mother->GetPz(),mother->GetE(),mother->GetM());
147 double p_t=d4.GetX0();
148 switch ((
int) selector)
150 case 1: p_t=part->GetE();
break;
151 case 2: p_t=d4.Xt();
break;
155 if ( ifSofty(part->GetPDGId(),nparams,params) && p_t == ephot) {
158 lostDaughters->push_back(part);
159 stableDaughters->remove(part);
161 part=daughters.first();
165 if( ifSofty(part->GetPDGId(),nparams,params) && ephot1>p_t) ephot1=p_t;
175 HEPParticleListIterator symmetry (*stableDaughters);
176 HEPParticle *phot1 = NULL;
177 HEPParticle *phot2 = NULL;
178 for (HEPParticle *part=symmetry.first(); part!=0; part=symmetry.next() )
180 if(part->GetPDGId()==22)
182 if(!phot1) phot1=part;
192 if(phot1->GetE()<phot2->GetE())
195 double buf_x = phot1->GetPx();
196 double buf_y = phot1->GetPy();
197 double buf_z = phot1->GetPz();
198 double buf_e = phot1->GetE();
200 phot1->SetPx(phot2->GetPx());
201 phot1->SetPy(phot2->GetPy());
202 phot1->SetPz(phot2->GetPz());
203 phot1->SetE (phot2->GetE() );
224 int version=(int) actLost;
230 HEPParticleListIterator lost (*lostDaughters);
231 for (HEPParticle *lostpart=lost.first(); lostpart!=0; lostpart=lost.next() ) {
233 double searchvirt=pow(10.0,22);
235 for( HEPParticle *part=daughters.first(); part!=0; part=daughters.next() ){
236 if(part->GetCharge()==0)
continue;
237 VV=lostpart->GetP4()+part->GetP4();
239 if (VV.GetM()<searchvirt) {searchvirt=VV.GetM(); Best=part;}
242 Best->SetPx(Best->GetPx()+lostpart->GetPx());
243 Best->SetPy(Best->GetPy()+lostpart->GetPy());
244 Best->SetPz(Best->GetPz()+lostpart->GetPz());
245 Best->SetE (Best->GetE ()+lostpart->GetE ());
253 delete lostDaughters;
256 bool activateUserHist=
true;
257 if(!activateUserHist)
return 1;
261 double X=mother->GetPx(), Y=mother->GetPy(), Z=mother->GetPz();
265 double pt=sqrt(X*X+Y*Y);
266 double eta=log((sqrt(pt*pt+Z*Z)+TMath::Abs(Z))/pt);
267 if(Z<0 && eta>0) eta=-eta;
268 if(Z>0 && eta<0) eta=-eta;
269 double phi=angle(X,Y);
270 char hist1[] =
"mother-PT";
271 char hist2[] =
"mother-eta";
272 char hist3[] =
"mother-phi";
273 fillUserHisto(hist1,pt,1.0,0.0,100.0);
274 fillUserHisto(hist2,eta,1.0,-8.0,8.0);
275 fillUserHisto(hist3,phi,1.0,-PI,PI);