FairRoot/PandaRoot
NEW/ReadLines.C
Go to the documentation of this file.
2 
3  // load libs
4 
5  gROOT->Macro("$VMCWORKDIR/gconfig/rootlogon.C");
6 
7 // TString LinFile = "/hiskp1/bianco/Cracow/Fit_5.000000_11_9000.root";
8 // TString MCFile = "/hiskp1/bianco/Cracow/Sim_5.000000_11_9000.root";
9 
10  TFile *f = new TFile(LinFile);
11 
12  TTree *t=(TTree *) f->Get("pndsim") ;
13 
14  TClonesArray* tr_array=new TClonesArray("TtFitRes");
15  t->SetBranchAddress("TTFit",&tr_array);//Branch names
16 
17  TFile *fMC = new TFile(MCFile);
18 
19  TTree *tMC=(TTree *) fMC->Get("pndsim") ;
20 
21  TClonesArray* mc_array=new TClonesArray("PndSdsMCPoint");
22  tMC->SetBranchAddress("LMDPoint",&mc_array);//Branch names
23 
24  if (t->GetEntries() != tMC->GetEntries()) break;
25 
26  cout << "Events: " << t->GetEntries() << endl;
27 
28  Double_t Sx=0.,Sy=0.,Ox=0.,Oy=0.;
29 
30  TH2F *offsets = new TH2F("Residuals","Residuals",5000,-1.,+1.,5000,-1.,+1.);
31 
32  TVector3 DevPoint, FitPoint;
33 
34  TCanvas *can = new TCanvas("2D","2D",0,0,1200,600);
35  TCanvas *can2 = new TCanvas("1D","1D",0,0,1200,400);
36 
37  can->Divide(2,1);
38  can2->Divide(2,1);
39 
40  for (Int_t j = 0 ; j < t->GetEntries() ; j++) // loop on events
41  {
42 
43  t->GetEvent(j);
44  tMC->GetEvent(j);
45 
46  cout << "Event " << j << " Entries " << tr_array->GetEntries() << endl;
47 
48  if ( (mc_array->GetEntries()!=1) || (tr_array->GetEntries()!=1) ) continue;
49 
50  PndSdsMCPoint *point = (PndSdsMCPoint*) mc_array->At(0);
51  TtFitRes* line = (TtFitRes*)tr_array->At(0);
52 
53  DevPoint = 0.5*(point->GetPosition() + point->GetPositionOut());
54 
55  Sx = (line->GetDirectionVec()).X(); // par[1]
56  Sy = (line->GetDirectionVec()).Y(); // par[3]
57 
58  Ox = (line->GetFirstPoint()).X(); // par[0]
59  Oy = (line->GetFirstPoint()).Y(); // par[2]
60 
61  FitPoint.SetXYZ((Ox+Sx*(DevPoint.Z())),(Oy+Sy*(DevPoint.Z())),DevPoint.Z());
62 
63  offsets->Fill( (FitPoint.X()-DevPoint.X()) , (FitPoint.Y()-DevPoint.Y()) );
64 
65  } // end loop on events
66 
67  offsets->GetXaxis()->SetRangeUser(-10*offsets->GetRMS(1),+10*offsets->GetRMS(1));
68  offsets->GetYaxis()->SetRangeUser(-10*offsets->GetRMS(2),+10*offsets->GetRMS(2));
69 
70  offsets->GetXaxis()->SetTitle("#DeltaX [cm]");
71  offsets->GetXaxis()->SetTitle("#DeltaY [cm]");
72 
73  TString Res2D = LinFile;
74  Res2D.Remove(Res2D.Sizeof()-6);
75  Res2D = Res2D+"_2DResiduals.png";
76 
77  TString Res1D = LinFile;
78  Res1D.Remove(Res1D.Sizeof()-6);
79  Res1D = Res1D+"_1DResiduals.png";
80 
81  gStyle->SetPalette(1.);
82 
83  can->cd(1);
84 
85  offsets->Draw("COLZ");
86 
87  can->cd(2);
88 
89  offsets->Draw("LEGO2");
90 
91  can->SaveAs(Res2D.Data(),"png");
92 
93 
94 
95  TH1D *resX = offsets->ProjectionX("_Xproj");
96  resX->SetTitle("X Redisuals");
97  resX->GetXaxis()->SetTitle("#DeltaX [cm]");
98 
99 
100  TH1D *resY = offsets->ProjectionY("_Yproj");
101  resY->SetTitle("Y Redisuals");
102  resY->GetXaxis()->SetTitle("#DeltaY [cm]");
103 
104  gStyle->SetOptFit(1);
105 
106  can2->cd(1);
107 
108  resX->Draw();
109  resX->Fit("gaus");
110 
111  can2->cd(2);
112 
113  resY->Draw();
114  resY->Fit("gaus");
115 
116  can2->SaveAs(Res1D.Data(),"png");
117  return 0;
118 }
119 
int ReadLines(TString LinFile, TString MCFile)
Definition: NEW/ReadLines.C:1
TClonesArray * mc_array
Definition: anaLmdCluster.C:25
TVector3 GetPositionOut() const
Definition: PndSdsMCPoint.h:91
double Y
Definition: anaLmdDigi.C:68
TVector2 GetFirstPoint() const
Definition: TtFitRes.h:29
Double_t
TClonesArray * point
Definition: anaLmdDigi.C:29
TFile * f
Definition: bump_analys.C:12
TVector3 GetPosition() const
Definition: PndSdsMCPoint.h:90
double X
Definition: anaLmdDigi.C:68
TCanvas * can2
TString MCFile
TTree * t
Definition: bump_analys.C:13
TVector2 GetDirectionVec() const
Definition: TtFitRes.h:30