7 cout <<
"QA Analysis module for the MVD - Hit resolution check." << endl;
15 Bool_t isSuccessful = kFALSE;
16 Bool_t test1=kTRUE, test2=kTRUE, test3=kTRUE;
30 picture.ReplaceAll(
".root",
".png");
32 TFile*
f =
new TFile(inFile.Data());
33 TTree*
t=(TTree*)f->Get(
"pndsim");
34 t->AddFriend(
"pndsim",recoFile.Data());
35 TFile* dbfile =
new TFile(parFile.Data());
40 dbfile->Get(
"FairBaseParSet");
43 dbfile->Get(
"FairGeoParSet");
45 std::cout<<
"Could not find valid GeoManager. Abort now!"<<std::endl;
51 TClonesArray*
mc_array=
new TClonesArray(
"PndSdsMCPoint");
52 t->SetBranchAddress(
"MVDPoint",&mc_array);
55 t->SetBranchAddress(
"MVDPixelDigis",&digiPixel_array);
58 t->SetBranchAddress(
"MVDStripDigis",&digiStrip_array);
60 TClonesArray* strhit_array=
new TClonesArray(
"PndSdsHit");
61 t->SetBranchAddress(
"MVDHitsStrip",&strhit_array);
63 TClonesArray* pixhit_array=
new TClonesArray(
"PndSdsHit");
64 t->SetBranchAddress(
"MVDHitsPixel",&pixhit_array);
67 std::cout<<
"No MvdGeoHandling existant. Abort now!"<<std::endl;
70 fGeoH->FillSensorMap();
81 TH1D* hisDiff =
new TH1D(
"diff",
"",100,-0.008,0.008);
82 hisDiff->SetTitle(
"MVD Hit Resolution (double gaussian fit);#Deltax / cm;");
85 TH1D* hisDiffTheta =
new TH1D(
"DiffTheta",
"",100,-angmax,angmax);
86 hisDiffTheta->SetTitle(
"#Theta resolution;#Delta#Theta/mrad;");
88 TH1D* hisDiffPhi =
new TH1D(
"DiffPhi",
"",100,-angmax,angmax);
89 hisDiffPhi->SetTitle(
"#Phi resolution;#Delta#Phi/mrad;");
98 cout<<
" -I- Start Loop"<<endl;
99 for (Int_t j=0; j<nEvents && j<t->GetEntriesFast(); j++)
101 if(10==j) verbose=kFALSE;
103 if(verbose) cout<<
"Event No "<<j<<endl;
104 else if (!(j%100)) cout <<
"Event No "<<j<<endl;
105 if(verbose) std::cout<<
"Check sanity of the arrays:"<<std::endl;
107 if(verbose) std::cout<<
"mc_array ok with "<<mc_array->GetEntriesFast()<<
" entries"<<std::endl;
110 std::cout<<
"*** mc_array broken - check your file! ."<<std::endl;
114 if(verbose) std::cout<<
"digiPixel_array ok with "<<digiStrip_array->GetEntriesFast()<<
" entries"<<std::endl;
117 std::cout<<
"*** digiPixel_array broken - check your file! ."<<std::endl;
121 if(verbose) std::cout<<
"digiStrip_array ok with "<<digiStrip_array->GetEntriesFast()<<
" entries"<<std::endl;
124 std::cout<<
"*** digiStrip_array broken - check your file! ."<<std::endl;
128 if(verbose) std::cout<<
"strhit_array ok with "<<strhit_array->GetEntriesFast()<<
" entries"<<std::endl;
131 std::cout<<
"*** strhit_array broken - check your file! ."<<std::endl;
135 if(verbose) std::cout<<
"pixhit_array ok with "<<pixhit_array->GetEntriesFast()<<
" entries"<<std::endl;
138 std::cout<<
"*** pixhit_array broken - check your file! ."<<std::endl;
144 for (Int_t ii=0; ii<pixhit_array->GetEntriesFast(); ii++)
148 if(verbose) cout <<ii<<
".";
152 vecs.SetXYZ(hit->GetX(), hit->GetY(), hit->GetZ());
153 Int_t mcid = hit->GetRefIndex();
154 if(verbose)cout<<mcid<<
" ";
155 if(mcid<0 || mcid >= mc_array->GetEntriesFast())
continue;
159 vecmc.SetXYZ( 0.5 * (point->GetX() + point->
GetXOut()),
160 0.5 * (point->GetY() + point->
GetYOut()),
161 0.5 * (point->GetZ() + point->
GetZOut()));
162 vecdiff = vecmc -
vecs;
163 difftheta = vecmc.Theta() - vecs.Theta();
164 diffphi = vecmc.Phi() - vecs.Phi();
166 difftheta = difftheta*1000.*
TMath::Pi()/180.;
169 hisDiffTheta->Fill(difftheta);
170 hisDiffPhi->Fill(diffphi);
173 tmpMaster[0]=vecs.x();tmpMaster[1]=vecs.y();tmpMaster[2]=vecs.z();
174 currentTransMat->MasterToLocal(tmpMaster,tmpLocal);
175 vecs.SetXYZ(tmpLocal[0],tmpLocal[1],tmpLocal[2]);
176 tmpMaster[0]=vecmc.x();tmpMaster[1]=vecmc.y();tmpMaster[2]=vecmc.z();
177 currentTransMat->MasterToLocal(tmpMaster,tmpLocal);
178 vecmc.SetXYZ(tmpLocal[0],tmpLocal[1],tmpLocal[2]);
179 vecdiff = vecmc -
vecs;
181 hisDiff->Fill(vecdiff.X());
183 if(verbose) cout <<endl;
188 for (Int_t iii=0; iii<strhit_array->GetEntriesFast(); iii++)
195 vecs.SetXYZ(hit->GetX(), hit->GetY(), hit->GetZ());
197 Int_t mcid = hit->GetRefIndex();
198 if(mcid<0 || mcid >= mc_array->GetEntriesFast())
continue;
202 vecmc.SetXYZ( 0.5 * (point->GetX() + point->
GetXOut()),
203 0.5 * (point->GetY() + point->
GetYOut()),
204 0.5 * (point->GetZ() + point->
GetZOut()));
205 vecdiff = vecmc -
vecs;
206 difftheta = vecmc.Theta() - vecs.Theta();
207 diffphi = vecmc.Phi() - vecs.Phi();
209 difftheta = difftheta*1000.*
TMath::Pi()/180.;
212 hisDiffTheta->Fill(difftheta);
213 hisDiffPhi->Fill(diffphi);
216 tmpMaster[0]=vecs.x();tmpMaster[1]=vecs.y();tmpMaster[2]=vecs.z();
217 currentTransMat->MasterToLocal(tmpMaster,tmpLocal);
218 vecs.SetXYZ(tmpLocal[0],tmpLocal[1],tmpLocal[2]);
219 tmpMaster[0]=vecmc.x();tmpMaster[1]=vecmc.y();tmpMaster[2]=vecmc.z();
220 currentTransMat->MasterToLocal(tmpMaster,tmpLocal);
221 vecmc.SetXYZ(tmpLocal[0],tmpLocal[1],tmpLocal[2]);
222 vecdiff = vecmc -
vecs;
224 hisDiff->Fill(vecdiff.X());
234 TCanvas*
can1 =
new TCanvas(
"MvdTestPlot",
"MCHit view in MVD",0,0,a*pix,
b*pix);
237 TCanvas*
can2 =
new TCanvas(
"MvdResPlot",
"MVD point resolution");
243 TF1*
g2 =
new TF1(
"g2",
"gaus",-0.002,0.002);
244 hisDiff->Fit(g2,
"R");
245 g2->GetParameters(&par[0]);
247 TF1*
total =
new TF1(
"total",
"gaus(0)+gaus(3)",-0.008,0.008);
248 total->SetParameters(par);
249 total->SetLineColor(4);
250 total->SetLineWidth(2);
251 total->SetLineStyle(7);
252 hisDiff->Fit(total,
"R");
253 total->GetParameters(&par[0]);
255 hisDiff->SetMarkerStyle(3);
256 hisDiff->SetMarkerSize(0.4);
257 hisDiff->DrawCopy(
"pe");
260 gStyle->SetOptTitle(kFALSE);
261 gStyle->SetOptStat(kFALSE);
264 std::cout<<
" --- Test resolution ---"<<std::endl;
266 Float_t mean1=10000*par[1];
267 Float_t
sigma1=10000*par[2];
268 Float_t mean2=10000*par[4];
269 Float_t sigma2=10000*par[5];
271 cout <<
"<DartMeasurement name=\"mean1\" type=\"numeric/double\">";
273 cout <<
"</DartMeasurement>" << endl;
276 str += (mean1);
for (
int i=0;
i<6;
i++) str.Chop();
278 std::cout<<str.Data()<<
" is ";
279 if(
fabs(mean1) < 2*sigma1 ){
281 test1=test1 && kTRUE;
285 } std::cout<<
" than 2 #sigma away from 0"<<std::endl;
287 cout <<
"<DartMeasurement name=\"mean2\" type=\"numeric/double\">";
289 cout <<
"</DartMeasurement>" << endl;
292 str += (mean2);
for (
int i=0;
i<6;
i++) str.Chop();
294 std::cout<<str.Data()<<
" is ";
295 if(
fabs(mean2) < 2*sigma2 ){
297 test1=test1 && kTRUE;
301 } std::cout<<
" than 2 #sigma away from 0"<<std::endl;
303 cout <<
"<DartMeasurement name=\"sigma1\" type=\"numeric/double\">";
305 cout <<
"</DartMeasurement>" << endl;
307 str =
"#sigma_{1} = ";
308 str += (
sigma1);
for (
int i=0;
i<6;
i++) str.Chop();
311 std::cout<< str.Data();
312 if(
fabs(sigma1) < 10 ){
313 std::cout<<
" Passed a 10um window.";
314 test2=test2 && kTRUE;
316 std::cout<<
" Didn't pass a 10um window.";
318 } std::cout<<std::endl;
320 cout <<
"<DartMeasurement name=\"sigma2\" type=\"numeric/double\">";
322 cout <<
"</DartMeasurement>" << endl;
324 str =
"#sigma_{2} = ";
325 str += (sigma2);
for (
int i=0;
i<6;
i++) str.Chop();
328 std::cout<< str.Data();
330 if(
fabs(sigma2) < 100 ){
331 std::cout<<
" Passed a 100um window.";
332 test2=test2 && kTRUE;
334 std::cout<<
" Didn't pass a 100um window.";
336 } std::cout<<std::endl;
341 can2->Print(picture);
363 printf(
"RealTime=%f seconds, CpuTime=%f seconds\n",rtime,ctime);
364 isSuccessful = test1 && test2 && test3;
366 std::cout <<
" Test passed" << std::endl;
367 std::cout <<
" All ok " << std::endl;
369 std::cout<<
"Something is worong:"<<endl;
370 std::cout<<
"Test of Data Arrays: "<< ((test3) ?
"ok" :
"bad") <<std::endl;
371 std::cout<<
"Test of resolution mean: "<< ((test1) ?
"ok" :
"bad") <<std::endl;
372 std::cout<<
"Test of resolution sigma: "<< ((test2) ?
"ok" :
"bad") <<std::endl;
374 std::cout<<std::endl;
printf("RealTime=%f seconds, CpuTime=%f seconds\n", rtime, ctime)
TGeoManager * gGeoManager
Class to access the naming information of the MVD.
friend F32vec4 fabs(const F32vec4 &a)
TClonesArray * digiPixel_array
int hit(Int_t nEvents=0, TString inFile="sim.root", TString parFile="par.root", TString inDigi="digi.root", TString outFile="hit.root", Int_t timeBased=0)
TGeoHMatrix * currentTransMat
TClonesArray * digiStrip_array
Int_t GetSensorID() const