9 #include "FairRootManager.h"
10 #include "TClonesArray.h"
11 #include "TGraph2DErrors.h"
18 #include "TGeoTrack.h"
19 #include "TGeoManager.h"
20 #include "TLorentzVector.h"
30 #include <TVirtualFitter.h>
31 #include <TPolyLine3D.h>
32 #include <Math/Vector3D.h>
33 #include <TGraphErrors.h>
45 fTCandBranchName(
"MVDHitsStrip"),
65 FairRootManager* ioman= FairRootManager::Instance();
69 Error(
"TtCracowTask::Init",
"RootManager not instantiated!");
79 Error(
"TtCracowTask::Init",
"trackcand-array not found!");
83 std::cout <<
"Input: " <<
fTCandArray->GetClass()->GetName() << std::endl;
87 ioman->Register(
"TTFit",
"PndMvd",
fTrackArray, kTRUE);
89 std::cout <<
"-I- TtCracowTask: Initialisation successfull" << std::endl;
106 TVector3
x0(par[0],par[2],0);
107 TVector3 x1(par[0]+par[1],par[2]+par[3],1);
108 TVector3 u = (x1-
x0).Unit();
109 double d2 = ((xp-
x0).Cross(u)) .Mag2();
125 ddd.SetXYZ(x-(par[1]*z +par[0]),0.,0.);
131 ddd.SetXYZ(0.,y-(par[3]*z +par[2]),0.);
142 TGraph2D * gr =
dynamic_cast<TGraph2D*
>( (TVirtualFitter::GetFitter())->GetObjectFit() );
144 double *
x = gr->GetX();
145 double *
y = gr->GetY();
146 double *
z = gr->GetZ();
147 double * Ex = gr->GetEX();
148 double * Ey = gr->GetEY();
149 double * Ez = gr->GetEZ();
158 if ((Ex[
i] < 10000.) && (Ey[
i] < 10000.))
164 if ((Ex[
i] > 10000.) && (Ey[
i] > 10000.))
170 if ((Ex[
i] > 10000.) || (Ey[
i] > 10000.))
200 for (Int_t qq = 0 ; qq < 6 ; qq++)
214 std::map<Double_t,Int_t> SensorsPos;
216 std::cout <<
"Event: " <<
fEvent << std::endl;
217 std::cout <<
"Initial map size: " << SensorsPos.size() << std::endl;
221 if(
fTrackArray==0) Fatal(
"TtCracowTask::Exec",
"No TrackArray");
226 for(Int_t itr=0;itr<ntcand;++itr){
232 if (SensorsPos.size() < 6) SensorsPos[theHit->GetZ()] =
name;
236 const Int_t sizeMap = (Int_t) SensorsPos.size();
238 Int_t DetNames[sizeMap];
244 if (SensorsPos.size()>=6)
247 std::cout <<
"Map size after looping: " << SensorsPos.size() << std::endl;
249 for (std::map<Double_t,Int_t>::iterator it=SensorsPos.begin();it!=SensorsPos.end();++it)
252 std::cout <<
"position: " << it->first <<
" name: " << (it->second) << std::endl;
254 DetNames[
jj] = it->second;
267 for (Int_t l = 0 ; l < sizeMap ; l++)
273 if (SensorsPos.size()==6)
296 TGraph2DErrors * gr =
new TGraph2DErrors();
298 for (Int_t it1 = 0 ; it1 < ntcand ; it1++)
305 x[0] = theHit->GetX();
306 y[0] = theHit->GetY();
307 z[0] = theHit->GetZ();
308 Erx[0] = theHit->GetDx();
309 Ery[0] = theHit->GetDy();
317 x[1] = theHit->GetX();
318 y[1] = theHit->GetY();
319 z[1] = theHit->GetZ();
320 Erx[1] = theHit->GetDx();
321 Ery[1] = theHit->GetDy();
328 x[2] = theHit->GetX();
329 y[2] = theHit->GetY();
330 z[2] = theHit->GetZ();
331 Erx[2] = theHit->GetDx();
332 Ery[2] = theHit->GetDy();
340 x[3] = theHit->GetX();
341 y[3] = theHit->GetY();
342 z[3] = theHit->GetZ();
343 Erx[3] = theHit->GetDx();
344 Ery[3] = theHit->GetDy();
351 x[4] = theHit->GetX();
352 y[4] = theHit->GetY();
353 z[4] = theHit->GetZ();
354 Erx[4] = theHit->GetDx();
355 Ery[4] = theHit->GetDy();
363 x[5] = theHit->GetX();
364 y[5] = theHit->GetY();
365 z[5] = theHit->GetZ();
366 Erx[5] = theHit->GetDx();
367 Ery[5] = theHit->GetDy();
382 for (Int_t ww = 0 ; ww < 6 ; ww++)
385 if (
TMath::Abs(Erx[ww]) > 0.5) Erx[ww] = 10000.;
386 if (
TMath::Abs(Ery[ww]) > 0.5) Ery[ww] = 10000.;
397 if (s0 && s1 && s2 && s3 && s4 && s5)
399 for (Int_t ss = 0 ; ss < 6 ; ss++)
401 gr->SetPoint(ss,x[ss],y[ss],z[ss]);
402 gr->SetPointError(ss,x[ss],y[ss],z[ss]);
406 Int_t Npoint = gr->GetN();
413 dir.SetXYZ(xx[Npoint-1]-xx[0],yy[Npoint-1]-yy[0],zz[Npoint-1]-zz[0]);
415 TVirtualFitter::SetDefaultFitter(
"Minuit");
416 TVirtualFitter *
min = TVirtualFitter::Fitter(0,4);
417 min->SetObjectFit(gr);
423 min->ExecuteCommand(
"SET NOWarnings",arglist,1);
425 min->ExecuteCommand(
"SET PRINT",arglist,1);
435 min->SetParameter(0,
"y0",0,1,0,0);
436 min->SetParameter(1,
"A",0,1,0,0);
437 min->SetParameter(2,
"z0",0,1,0,0);
438 min->SetParameter(3,
"B",0,1,0,0);
442 min->ExecuteCommand(
"MIGRAD", arglist ,2);
445 double amin,edm, errdef;
446 min->GetStats(amin,edm,errdef,nvpar,nparx);
447 if(
fVerbose>1) min->PrintResults(1,amin);
456 for (Int_t gg = 0 ; gg < 6 ; gg++) SumEn +=
fEloss[gg];
458 std::cout <<
"Scrivo" << endl;
459 new ((*fTrackArray)[0])
TtFitRes(min->GetParameter(0), min->GetParameter(1), min->GetParameter(2), min->GetParameter(3), SumEn, chi2, chi2, Npoint) ;
486 for (Int_t j = 0 ; j < 6 ; j++)
492 grX.SetPoint(ix,z[j],x[j]);
500 grY.SetPoint(iy,z[j],y[j]);
530 chiX = (grX.GetFunction(
"pol1"))->GetChisquare();
532 chiY = (grY.GetFunction(
"pol1"))->GetChisquare();
cout<< "ifile "<< ifile<< endl;cout<< " momentum sampled over "<< nsteps<< " with step width "<< 1.5/nsteps<< endl;cout<< endl;cout<< "MEAN DEDX PARAMETRIZATION"<< endl;cout<< "mom limits "<< mean_inf<< " "<< mean_sup<< endl;cout<< "mu: ";for(int param=0;param< npardedx;param++) cout<< fdedx-> GetParameter(param)<< "
Double_t GetEloss() const
void MyFit(Double_t *x, Double_t *y, Double_t *z, Double_t *Erx, Double_t *Ery, Double_t *Erz, Double_t *par, Double_t &chiX, Double_t &chiY)
TClonesArray * fTrackArray
friend F32vec4 min(const F32vec4 &a, const F32vec4 &b)
static double distance2(double x, double y, double z, double *p)
static void SumDistance2(int &, double *, double &sum, double *par, int)
TClonesArray * fTCandArray
Int_t GetSensorID() const
virtual void Exec(Option_t *opt)
virtual void FinishEvent()
static double distance2Single(double x, double y, double z, double ex, double ey, double ez, double *p)
virtual InitStatus Init()