6 #include "HEPParticle.H"
11 #define PI 3.141592653
13 inline bool ifSofty(
int Id,
int nparams,
double *params){
14 if (nparams<5 && Id==22)
return true;
15 for (
int i=nparams-1; i>3; i--)
16 if (Id==params[i])
return true;
21 inline void fillUserHisto(
char *name,
double val,
double weight=1.0,
22 double min=Setup::bin_min[0][0],
23 double max=Setup::bin_max[0][0]){
25 TH1D *h=(TH1D*)(Setup::user_histograms->FindObject(name));
27 h=
new TH1D(name,name,Setup::nbins[0][0],min,max);
29 Setup::user_histograms->Add(h);
35 double angle(
double X,
double Y){
39 double R=sqrt(X*X+Y*Y);
41 if(R<pow(10,-20))
return an;
43 if(TMath::Abs(X)/R<0.8)
46 if(Y<0 && an>0) an=-an;
47 if(Y>0 && an<0) an=-an;
52 if(X<0 && an>=0.) an=PI-an;
53 else if(X<0.) an=-PI-an;
61 int ZtautauAnalysis(HEPParticle *mother,HEPParticleList *stableDaughters,
int nparams,
double *params)
85 assert(stableDaughters!=0);
88 double threshold=0.05, leftmax=0.0, selector=0.0, actLost=0.0;
89 if (nparams>0 && params==0)
return -1;
90 if (nparams>0) threshold=params[0];
91 if (nparams>1) leftmax =params[1];
92 if (nparams>2) selector =params[2];
93 if (nparams>3) actLost =params[3];
96 HEPParticleList *lostDaughters=
new HEPParticleList;
97 double pt_limit=threshold*mother->GetM();
99 HEPParticleListIterator daughters (*stableDaughters);
101 double ephot=pow(10,22);
103 for (HEPParticle *part=daughters.first(); part!=0; (redo)? part=part:part=daughters.next() ) {
105 MC4Vector d4(part->GetE(),part->GetPx(),part->GetPy(),part->GetPz(),part->GetM());
107 d4.Boost(mother->GetPx(),mother->GetPy(),mother->GetPz(),mother->GetE(),mother->GetM());
111 double p_t=d4.GetX0();
112 switch ((
int) selector)
114 case 1: p_t=part->GetE();
break;
115 case 2: p_t=d4.Xt();
break;
119 if(ifSofty(part->GetPDGId(),nparams,params)) nphot++;
120 if ( ifSofty(part->GetPDGId(),nparams,params) && p_t < pt_limit) {
123 lostDaughters->push_back(part);
124 stableDaughters->remove(part);
125 part=daughters.first();
129 if( ifSofty(part->GetPDGId(),nparams,params) && ephot>p_t) ephot=p_t;
131 while(nphot>(
int) leftmax)
133 double ephot1=pow(10,22);
135 for (HEPParticle *part=daughters.first(); part!=0; (redo)? part=part:part=daughters.next() ) {
137 MC4Vector d4(part->GetE(),part->GetPx(),part->GetPy(),part->GetPz(),part->GetM());
139 d4.Boost(mother->GetPx(),mother->GetPy(),mother->GetPz(),mother->GetE(),mother->GetM());
142 double p_t=d4.GetX0();
143 switch ((
int) selector)
145 case 1: p_t=part->GetE();
break;
146 case 2: p_t=d4.Xt();
break;
150 if ( ifSofty(part->GetPDGId(),nparams,params) && p_t == ephot) {
153 lostDaughters->push_back(part);
154 stableDaughters->remove(part);
156 part=daughters.first();
160 if( ifSofty(part->GetPDGId(),nparams,params) && ephot1>p_t) ephot1=p_t;
178 int version=(int) actLost;
184 HEPParticleListIterator lost (*lostDaughters);
185 for (HEPParticle *lostpart=lost.first(); lostpart!=0; lostpart=lost.next() ) {
187 double searchvirt=pow(10.0,22);
189 for( HEPParticle *part=daughters.first(); part!=0; part=daughters.next() ){
190 if(part->GetCharge()==0)
continue;
191 VV=lostpart->GetP4()+part->GetP4();
193 if (VV.GetM()<searchvirt) {searchvirt=VV.GetM(); Best=part;}
196 Best->SetPx(Best->GetPx()+lostpart->GetPx());
197 Best->SetPy(Best->GetPy()+lostpart->GetPy());
198 Best->SetPz(Best->GetPz()+lostpart->GetPz());
199 Best->SetE (Best->GetE ()+lostpart->GetE ());
207 delete lostDaughters;
213 double px=0,py=0,pz=0,e=0;
214 double px1=0,py1=0,pz1=0,e1=0;
217 for(HEPParticle *part=daughters.first();part!=0;part=daughters.next())
219 if(abs(part->GetPDGId())==211)
226 if(abs(part->GetPDGId())==211)
continue;
233 double mass=e*e-px*px-py*py-pz*pz;
234 double mass1=(e+e1)*(e+e1)-(px+px1)*(px+px1)-(py+py1)*(py+py1)-(pz+pz1)*(pz+pz1);
236 char mm[] =
"pi-energy";
237 fillUserHisto(mm,mass,1.0,0.0,1.1);
240 bool activateUserHist=
false;
241 if(!activateUserHist)
return 1;
245 double X=mother->GetPx(), Y=mother->GetPy(), Z=mother->GetPz();
249 double pt=sqrt(X*X+Y*Y);
250 double eta=log((sqrt(pt*pt+Z*Z)+TMath::Abs(Z))/pt);
251 if(Z<0 && eta>0) eta=-eta;
252 if(Z>0 && eta<0) eta=-eta;
253 double phi=angle(X,Y);
254 char hist1[] =
"mother-PT";
255 char hist2[] =
"mother-eta";
256 char hist3[] =
"mother-phi";
257 fillUserHisto(hist1,pt,1.0,0.0,100.0);
258 fillUserHisto(hist2,eta,1.0,-8.0,8.0);
259 fillUserHisto(hist3,phi,1.0,-PI,PI);