10 #include "FairRootManager.h"
11 #include "TClonesArray.h"
18 #include "TGeoTrack.h"
19 #include "TGeoManager.h"
20 #include "TLorentzVector.h"
31 #include <TVirtualFitter.h>
32 #include <TPolyLine3D.h>
33 #include <Math/Vector3D.h>
34 #include <TGraphErrors.h>
39 using namespace ROOT::Math;
43 : FairTask(
"Alignment") ,
45 fTCandBranchName(
"MVDHitsStrip"),
59 for (Int_t gg = 0 ; gg < 4 ; gg++)
71 : FairTask(
"3D-Straight-Line-Fit"),
73 fTCandBranchName(
"MVDHitsStrip"),
76 fExclBox(ExcludedBox),
87 if (fExclBox < 1 || fExclBox > 6)
89 std::cout <<
"Excluded box: Wrong value, setting as default 2!" << std::endl;
93 for (Int_t gg = 0 ; gg < 6 ; gg++)
113 FairRootManager* ioman= FairRootManager::Instance();
117 Error(
"TtAliTask::Init",
"RootManager not instantiated!");
127 Error(
"TtAliTask::Init",
"trackcand-array not found!");
131 std::cout <<
"-I- TtAliTask: Initialisation successfull" << std::endl;
135 hx =
new TH1F(
"hx",
"hx",50000,-5.,+5.);
136 hy =
new TH1F(
"hy",
"hy",50000,-5.,+5.);
155 std::map<Double_t,Int_t> SensorsPos;
160 if(
fTCandArray==0) Fatal(
"TtAliTask::Exec",
"No Points");
173 for(Int_t itr=0;itr<ntcand;++itr){
180 if (SensorsPos.size() < 6) SensorsPos[theHit->GetZ()] =
name;
188 const Int_t sizeMap = SensorsPos.size();
190 Int_t DetNames[sizeMap];
194 if (SensorsPos.size()>=6)
197 for (std::map<Double_t,Int_t>::iterator it=SensorsPos.begin();it!=SensorsPos.end();++it)
199 if (
fEvent < 5) std::cout <<
"position: " << it->first <<
" name: " << (it->second) << std::endl;
201 DetNames[
jj] = it->second;
224 if (SensorsPos.size()==6)
276 for (Int_t it1 = 0 ; it1 < ntcand ; it1++)
284 x[0] = theHit->GetX();
285 y[0] = theHit->GetY();
286 z[0] = theHit->GetZ();
287 Erx[0] = theHit->GetDx();
288 Ery[0] = theHit->GetDy();
289 Erz[0] = theHit->GetDz();
294 x[1] = theHit->GetX();
295 y[1] = theHit->GetY();
296 z[1] = theHit->GetZ();
297 Erx[1] = theHit->GetDx();
298 Ery[1] = theHit->GetDy();
299 Erz[1] = theHit->GetDz();
303 x[2] = theHit->GetX();
304 y[2] = theHit->GetY();
305 z[2] = theHit->GetZ();
306 Erx[2] = theHit->GetDx();
307 Ery[2] = theHit->GetDy();
308 Erz[2] = theHit->GetDz();
313 x[3] = theHit->GetX();
314 y[3] = theHit->GetY();
315 z[3] = theHit->GetZ();
316 Erx[3] = theHit->GetDx();
317 Ery[3] = theHit->GetDy();
318 Erz[3] = theHit->GetDz();
322 x[4] = theHit->GetX();
323 y[4] = theHit->GetY();
324 z[4] = theHit->GetZ();
325 Erx[4] = theHit->GetDx();
326 Ery[4] = theHit->GetDy();
327 Erz[4] = theHit->GetDz();
332 x[5] = theHit->GetX();
333 y[5] = theHit->GetY();
334 z[5] = theHit->GetZ();
335 Erx[5] = theHit->GetDx();
336 Ery[5] = theHit->GetDy();
337 Erz[5] = theHit->GetDz();
355 for (Int_t ww = 0 ; ww < 6 ; ww++)
368 for (Int_t ww = 0 ; ww < 6 ; ww++)
372 if (
TMath::Abs(Erx[ww]) > 0.5) Erx[ww] = 1000000;
373 if (
TMath::Abs(Ery[ww]) > 0.5) Ery[ww] = 1000000;
385 MyFit(x,y,z,Erx,Ery,Erz,x[
fExclBox-1],y[
fExclBox-1],z[
fExclBox-1],DX,DY);
403 void TtAliTask::MyFit(
Double_t *
x,
Double_t *
y,
Double_t *
z,
Double_t *Erx,
Double_t *Ery,
Double_t *,
Double_t realX,
Double_t realY,
Double_t realZ,
Double_t &DELTAX,
Double_t &DELTAY)
411 for (Int_t j = 0 ; j < 6 ; j++)
419 grX.SetPoint(ix,z[j],x[j]);
425 grY.SetPoint(iy,z[j],y[j]);
449 buffX = mx * realZ + nx;
450 buffY = my * realZ + ny;
452 DELTAX = buffX - realX;
453 DELTAY = buffY - realY;
468 TF1 *fun =
new TF1(
"fun",
"gaus");
470 hx->Fit(fun,
"Q",
"",(
hx->GetMean() - 2*(
hx->GetRMS())),(
hx->GetMean() + 2*(
hx->GetRMS())));
474 mX = fun->GetParameter(1);
475 siX = fun->GetParameter(2);
477 cout <<
"RMS: " <<
hx->GetRMS() <<
" sigma " << siX << endl;
479 hy->Fit(fun,
"Q",
"",(
hy->GetMean() - 2*(
hy->GetRMS())),(
hy->GetMean() + 2*(
hy->GetRMS())));
483 mY = fun->GetParameter(1);
484 siY = fun->GetParameter(2);
486 cout <<
"X, mean: " << mX <<
", sig: " << siX << endl;
487 cout <<
"Y, mean: " << mY <<
", sig: " << siY << endl;
578 cout <<
"SHIFTS" << endl;
579 for (Int_t k = 0 ; k < 6 ; k++)
581 cout <<
"X: " <<
sX[k] <<
" Y: " <<
sY[k] << endl;
591 cout <<
"RESIDUALS" << endl;
592 for (Int_t k = 0 ; k < 6 ; k++)
594 cout <<
"X: " <<
m_X[k] <<
" Y: " <<
m_Y[k] << endl;
601 cout <<
"SIGMA-RESIDUALS" << endl;
602 for (Int_t k = 0 ; k < 6 ; k++)
604 cout <<
"sigX: " <<
sigX[k] <<
" sigY: " <<
sigY[k] << endl;
614 return TVector2(resx,resy);
621 TCanvas *can =
new TCanvas();
627 hx->GetXaxis()->SetRangeUser((
hx->GetMean())-8*(
hx->GetRMS()),(
hx->GetMean())+8*(
hx->GetRMS()));
629 std::string nameX = Form(
"HistResidualsX_%d.png",
fExclBox);
631 can->Print(nameX.c_str(),
"png");
636 hy->GetXaxis()->SetRangeUser((
hy->GetMean())-8*(
hy->GetRMS()),(
hy->GetMean())+8*(
hy->GetRMS()));
638 std::string nameY = Form(
"HistResidualsY_%d.png",
fExclBox);
640 can->Print(nameY.c_str(),
"png");
virtual void Exec(Option_t *opt)
virtual InitStatus Init()
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)<< "
virtual void FinishTask()
TClonesArray * fTCandArray
void PrintSigmaResiduals()
void MyFit(Double_t *x, Double_t *y, Double_t *z, Double_t *Erx, Double_t *Ery, Double_t *Erz, Double_t realX, Double_t realY, Double_t realZ, Double_t &DELTAX, Double_t &DELTAY)
Int_t GetSensorID() const
void PrintMeanResiduals()