BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
CbmStsFindHitsQa.cxx
Go to the documentation of this file.
1// -------------------------------------------------------------------------
2// ----- CbmStsFindHitsQa source file -----
3// ----- Created 01/07/2008 by R. Karabowicz -----
4// -------------------------------------------------------------------------
5
6#include "CbmStsFindHitsQa.h"
7
8#include "CbmGeoStsPar.h"
9#include "CbmMCTrack.h"
10#include "CbmStsCluster.h"
11#include "CbmStsDigi.h"
12#include "CbmStsDigiPar.h"
13#include "CbmStsDigiScheme.h"
14#include "CbmStsHit.h"
15#include "CbmStsPoint.h"
16#include "CbmStsSector.h"
17#include "CbmStsSensor.h"
18#include "CbmStsStation.h"
19#include "FairRootManager.h"
20#include "FairRunAna.h"
21#include "FairRuntimeDb.h"
22#include "TCanvas.h"
23#include "TClonesArray.h"
24#include "TF1.h"
25#include "TFile.h"
26#include "TGeoManager.h"
27#include "TH1F.h"
28#include "TH2F.h"
29#include "TH3F.h"
30#include "TLegend.h"
31#include "TLine.h"
32#include "TList.h"
33#include "TMath.h"
34#include "TPad.h"
35#include "TPaveText.h"
36#include "TVector3.h"
37
38#include <iomanip>
39using namespace std;
40
41// ----- Default constructor ------------------------------------------
43 : FairTask("STS Hit Finder", 1)
44 , fGeoPar(NULL)
45 , fDigiPar(NULL)
46 , fDigiScheme(NULL)
47 , fMCTracks(NULL)
48 , // MCtrack
49 fStsPoints(NULL)
50 , // StsPoints
51 fStsHits(NULL)
52 , // StsHits
53 fMatches(NULL)
54 , // StsTrackMatch
55 fStsDigis(NULL)
56 , // StsDigi
57 fStsClusters(NULL)
58 , // StsCluster
59 fTimer()
61 , fhEffIncAng()
62 , fhEffMom()
63 , fhEffPdgSec()
64 , fhEffPdgPrim()
67 , fHistoList()
68 , fNStations(0)
69 , fNEvents(0)
70 , fTime1(0.)
71 , fNofHits()
74 , fNofRecoPrim()
75 , fNofRecoSec()
79 , recoCanvas()
80{
81 // AZ fDigiScheme = new CbmStsDigiScheme();
83}
84
85// ----- Standard constructor ------------------------------------------
87 : FairTask("STSFindHitsQa", iVerbose)
88 , fGeoPar(NULL)
89 , fDigiPar(NULL)
90 , fDigiScheme(NULL)
91 , fMCTracks(NULL)
92 , // MCtrack
93 fStsPoints(NULL)
94 , // StsPoints
95 fStsHits(NULL)
96 , // StsHits
97 fMatches(NULL)
98 , // StsTrackMatch
99 fStsDigis(NULL)
100 , // StsDigi
101 fStsClusters(NULL)
102 , // StsCluster
103 fTimer()
105 , fhEffIncAng()
106 , fhEffMom()
107 , fhEffPdgSec()
108 , fhEffPdgPrim()
111 , fHistoList()
112 , fNStations(0)
113 , fNEvents(0)
114 , fTime1(0.)
115 , fNofHits()
117 , fNofPointsSec()
118 , fNofRecoPrim()
119 , fNofRecoSec()
122 , fOnlineAnalysis(visualizeBool)
123 , recoCanvas()
124{
125 // AZ fDigiScheme = new CbmStsDigiScheme();
127}
128
130 : FairTask("STSFindHitsQa", iVerbose)
131 , fGeoPar(NULL)
132 , fDigiPar(NULL)
133 , fDigiScheme(NULL)
134 , fMCTracks(NULL)
135 , // MCtrack
136 fStsPoints(NULL)
137 , // StsPoints
138 fStsHits(NULL)
139 , // StsHits
140 fMatches(NULL)
141 , // StsTrackMatch
142 fStsDigis(NULL)
143 , // StsDigi
144 fStsClusters(NULL)
145 , // StsCluster
146 fTimer()
148 , fhEffIncAng()
149 , fhEffMom()
150 , fhEffPdgSec()
151 , fhEffPdgPrim()
154 , fHistoList()
155 , fNStations(0)
156 , fNEvents(0)
157 , fTime1(0.)
158 , fNofHits()
160 , fNofPointsSec()
161 , fNofRecoPrim()
162 , fNofRecoSec()
165 , recoCanvas()
166{
167 // AZ fDigiScheme = new CbmStsDigiScheme();
169}
170
171// ----- Constructor with name -----------------------------------------
172CbmStsFindHitsQa::CbmStsFindHitsQa(const char* name, Int_t iVerbose)
173 : FairTask(name, iVerbose)
174 , fGeoPar(NULL)
175 , fDigiPar(NULL)
176 , fDigiScheme(NULL)
177 , fMCTracks(NULL)
178 , // MCtrack
179 fStsPoints(NULL)
180 , // StsPoints
181 fStsHits(NULL)
182 , // StsHits
183 fMatches(NULL)
184 , // StsTrackMatch
185 fStsDigis(NULL)
186 , // StsDigi
187 fStsClusters(NULL)
188 , // StsCluster
189 fTimer()
191 , fhEffIncAng()
192 , fhEffMom()
193 , fhEffPdgSec()
194 , fhEffPdgPrim()
197 , fHistoList()
198 , fNStations(0)
199 , fNEvents(0)
200 , fTime1(0.)
201 , fNofHits()
203 , fNofPointsSec()
204 , fNofRecoPrim()
205 , fNofRecoSec()
209 , recoCanvas()
210{
211 // AZ fDigiScheme = new CbmStsDigiScheme();
213}
214
215// ----- Destructor ----------------------------------------------------
217{
218 fHistoList->Delete();
219 delete fHistoList;
220 for (Int_t istat = 0; istat < fNStations; istat++) {
221 fHistoListPS[istat]->Delete();
222 }
223 delete[] fHistoList;
224}
225// -------------------------------------------------------------------------
226
227// ----- Public method Exec --------------------------------------------
229{
230
231 fTimer.Start();
232 // Bool_t warn = kFALSE;
233
234 // Check for digi scheme
235 if (!fDigiScheme) {
236 cerr << "-E- " << fName << "::Exec: No digi scheme!" << endl;
237 return;
238 }
239
240 CbmStsStation* station = NULL;
241 CbmStsSector* sector = NULL;
242
243 Int_t nofStsDigis = fStsDigis->GetEntriesFast();
244 for (Int_t idigi = 0; idigi < nofStsDigis; idigi++) {
245 CbmStsDigi* stsDigi = (CbmStsDigi*)fStsDigis->At(idigi);
246 // cout << "digi side = " << stsDigi->GetSide() << endl;
247 // fNofFiredDigis[stsDigi->GetStationNr()-1][stsDigi->GetSectorNr()-1][stsDigi->GetSide()] += 1;
248 fNofDigisPChip[stsDigi->GetStationNr() - 1][stsDigi->GetSectorNr() - 1][stsDigi->GetSide()]
249 [(Int_t)(stsDigi->GetChannelNr() / 128)] += 1;
250 }
251 Int_t nofStsHits = fStsHits->GetEntriesFast();
252 Int_t nofStsPoints = fStsPoints->GetEntriesFast();
253 Int_t hitStationLimits[2][100];
254
255 for (Int_t ist = 0; ist < fNStations; ist++) {
256 hitStationLimits[0][ist] = -1;
257 hitStationLimits[1][ist] = -1;
258 }
259
260 // check for limits of hit indices on different stations...
261
262 for (Int_t ihit = 0; ihit < nofStsHits; ihit++) {
263 CbmStsHit* stsHit = (CbmStsHit*)fStsHits->At(ihit);
264 fNofHits[stsHit->GetStationNr() - 1][stsHit->GetSectorNr() - 1][stsHit->GetSensorNr() - 1] +=
265 1; // count hits per sensor
266 if (hitStationLimits[0][stsHit->GetStationNr() - 1] == -1) {
267 hitStationLimits[0][stsHit->GetStationNr() - 1] = ihit;
268 }
269 CbmStsHit* stsHitBack = (CbmStsHit*)fStsHits->At(nofStsHits - ihit - 1);
270 if (hitStationLimits[1][stsHitBack->GetStationNr() - 1] == -1) {
271 hitStationLimits[1][stsHitBack->GetStationNr() - 1] = nofStsHits - ihit;
272 }
273 }
274 for (Int_t istat = 0; istat < fDigiScheme->GetNStations(); istat++) {
275 station = fDigiScheme->GetStation(istat);
276 for (Int_t isect = 0; isect < station->GetNSectors(); isect++) {
277 sector = station->GetSector(isect);
278
279 CbmStsSensor* sensor = (CbmStsSensor*)sector->GetSensor(0);
280 for (Int_t iside = 0; iside < 2; iside++) {
281 for (Int_t iChip = 0; iChip < 8; iChip++) {
282 if (fNEvents == 999)
283 cout << " St " << istat + 1 << " sect " << isect + 1 << " nofsens " << sector->GetNSensors()
284 << " sectX " << sensor->GetX0() << " sectY " << sensor->GetY0() << " side " << iside
285 << " chip " << iChip + 1 << " fNofDigisPChip "
286 << fNofDigisPChip[istat][isect][iside][iChip] << endl;
287 }
288 }
289
290 for (Int_t isens = 0; isens < sector->GetNSensors(); isens++) {
291 // cout << "filling " << istat << " " << isect << " " << isens << endl;
292 fhNofHits[istat][isect][isens]->Fill(fNofHits[istat][isect][isens]);
293 // cout << "---> done " << isens << endl;
294 }
295 // for ( Int_t iside = 0 ; iside < 2 ; iside++ ) {
296 // fhNofFiredDigis[istat][isect][iside]->Fill(fNofFiredDigis[istat][isect][iside]);
297 // for ( Int_t ichip = 0 ; ichip < 8 ; ichip++ ) {
298 // if ( fhNofDigisPChip[istat][isect][iside][ichip] )
299 // fhNofDigisPChip[istat][isect][iside][ichip]->Fill(fNofDigisPChip[istat][isect][iside][ichip]);
300 // }
301 // }
302 }
303 }
304 for (Int_t ipnt = 0; ipnt < nofStsPoints; ipnt++) {
305 CbmStsPoint* stsPoint = (CbmStsPoint*)fStsPoints->At(ipnt);
306
307 // cout << "point " << ipnt << flush;
308
309 Int_t trackPdg = 0;
310 Int_t motherId = 0;
311 // Int_t motherPdg = 0;
312 TVector3 trackVertex;
313 TVector3 motherVertex;
314 TVector3 momentum;
315
316 Double_t xin = stsPoint->GetXIn();
317 Double_t yin = stsPoint->GetYIn();
318 Double_t zin = stsPoint->GetZIn();
319 // Double_t xout = stsPoint->GetXOut();
320 // Double_t yout = stsPoint->GetYOut();
321 // Double_t zout = stsPoint->GetZOut();
322
323 gGeoManager->FindNode(xin, yin, zin);
324 // TGeoNode* curNode = gGeoManager->GetCurrentNode();
325
326 Int_t trackId = stsPoint->GetTrackID();
327 CbmMCTrack* mcTrack = (CbmMCTrack*)fMCTracks->At(trackId);
328 trackPdg = mcTrack->GetPdgCode();
329 motherId = mcTrack->GetMotherId();
330 mcTrack->GetMomentum(momentum);
331 Double_t mom = momentum.Mag();
332
333 if (motherId >= 0) {
334 CbmMCTrack* motherTrack = (CbmMCTrack*)fMCTracks->At(motherId);
335 // motherPdg = motherTrack->GetPdgCode();
336 mcTrack->GetStartVertex(trackVertex);
337 motherTrack->GetStartVertex(motherVertex);
338 }
339
340 // cout << " in node \"" << curNode->GetName() << "\"" << flush;
341 TString curPath = fDigiScheme->GetCurrentPath();
342 CbmStsSensor* sensor = fDigiScheme->GetSensorByName(curPath);
343 Int_t stationNr = sensor->GetStationNr();
344
345 Int_t startHit = hitStationLimits[0][stationNr - 1];
346 Int_t finalHit = hitStationLimits[1][stationNr - 1];
347
348 // cout << " at station " << stationNr << " ( " << startHit << " - " << finalHit << " )" << endl;
349
350 fhEnergyLoss[stationNr - 1]->Fill(stsPoint->GetXIn(), stsPoint->GetYIn(), stsPoint->GetEnergyLoss());
351
352 fhIncAngle[stationNr - 1]->Fill(stsPoint->GetXIn(), stsPoint->GetYIn(),
353 TMath::Abs(TMath::ATan2((stsPoint->GetZOut() - stsPoint->GetZIn()),
354 (stsPoint->GetXOut() - stsPoint->GetXIn()))
355 * 180. / 3.14));
356 // Float_t zP = stsPoint->GetZ();
357 // Float_t xP = stsPoint->GetX(zP);
358 // Float_t yP = stsPoint->GetY(zP);
359
360 Bool_t foundPnt = kFALSE;
361
362 if (startHit == -1 && finalHit == -1)
363 continue;
364
365 for (Int_t ihit = startHit; ihit < finalHit; ihit++) {
366 CbmStsHit* stsHit = (CbmStsHit*)fStsHits->At(ihit);
367 if ((TMath::Abs(stsHit->GetX() - stsPoint->GetX(stsHit->GetZ())) < .01)
368 && (TMath::Abs(stsHit->GetY() - stsPoint->GetY(stsHit->GetZ())) < .04))
369 {
370 fhHitPointCorrelation[stationNr - 1]->Fill(stsHit->GetX() - stsPoint->GetX(stsHit->GetZ()),
371 stsHit->GetY() - stsPoint->GetY(stsHit->GetZ()));
372 fhHitPointCorr->Fill(stsHit->GetX() - stsPoint->GetX(stsHit->GetZ()),
373 stsHit->GetY() - stsPoint->GetY(stsHit->GetZ()));
374 fhHitPointPull->Fill((stsHit->GetX() - stsPoint->GetX(stsHit->GetZ())) / stsHit->GetDx(),
375 (stsHit->GetY() - stsPoint->GetY(stsHit->GetZ())) / stsHit->GetDy());
376
377 if (stsPoint->GetY(stsHit->GetZ()) > 0.)
378 fhHitPointCorrelationU[stationNr - 1]->Fill(stsHit->GetX() - stsPoint->GetX(stsHit->GetZ()),
379 stsHit->GetY() - stsPoint->GetY(stsHit->GetZ()));
380 if (stsPoint->GetY(stsHit->GetZ()) < 0.)
381 fhHitPointCorrelationB[stationNr - 1]->Fill(stsHit->GetX() - stsPoint->GetX(stsHit->GetZ()),
382 stsHit->GetY() - stsPoint->GetY(stsHit->GetZ()));
383 }
384
385 if ((TMath::Abs(stsHit->GetX() - stsPoint->GetX(stsHit->GetZ())) < .01)
386 && (TMath::Abs(stsHit->GetY() - stsPoint->GetY(stsHit->GetZ())) < .04))
387 {
388 foundPnt = kTRUE;
389 }
390 // cout <<"St "<<stationNr<<" Sens "<<sensor->GetSensorNr()<< " chan
391 // "<<sensor->GetFrontChannel(stsHit->GetX(),stsHit->GetY(),stsHit->GetZ())<<" X "<<stsHit->GetX();
392 }
393 Int_t incAngle =
394 (Int_t)(TMath::ATan2((stsPoint->GetZOut() - stsPoint->GetZIn()), (stsPoint->GetXOut() - stsPoint->GetXIn()))
395 * 180. / 3.14);
396 // Int_t incAngle = (Int_t) (
397 // TMath::ATan((stsPoint->GetXOut()-stsPoint->GetXIn())/(stsPoint->GetZOut()-stsPoint->GetZIn()))*180./3.14);
398 fNofPoints[stationNr - 1][sensor->GetSectorNr() - 1][sensor->GetSensorNr() - 1] += 1;
399 fNofPointsIncAng[TMath::Abs((Int_t)(incAngle))] += 1;
400 if (TMath::Abs((Int_t)(mom)) < 1)
401 fNofPointsMom[TMath::Abs((Int_t)(mom))] += 1;
402 if (TMath::Abs((Int_t)(mom)) < 1)
403 fNofPointsMomSum += 1;
404 // cout << stationNr-1 << " " << sensor->GetSectorNr()-1 << " " << sensor->GetSensorNr()-1 << "/" << flush;
405 fhPoints[stationNr - 1]->Fill(stsPoint->GetX(stsPoint->GetZ()), stsPoint->GetY(stsPoint->GetZ()));
406 fNofPointsSec = 1;
407 if (trackPdg < 10000 && motherId >= 0) {
408 fNofPointsPdgSec[trackPdg] += 1;
409 fNofPointsSec += 1;
410 }
411 fNofPointsPrim = 1;
412 if (trackPdg < 10000 && motherId < 0) {
413 fNofPointsPdgPrim[trackPdg] += 1;
414 fNofPointsPrim += 1;
415 }
416 if (foundPnt) {
417 fNofRecoPoints[stationNr - 1][sensor->GetSectorNr() - 1][sensor->GetSensorNr() - 1] += 1;
418 fNofRecoPointsIncAng[TMath::Abs((Int_t)(incAngle))] += 1;
419 if (TMath::Abs((Int_t)(mom)) < 1)
420 fNofRecoPointsMom[TMath::Abs((Int_t)(mom))] += 1;
421 if (TMath::Abs((Int_t)(mom)) < 1)
423 fhRecoPoints[stationNr - 1]->Fill(stsPoint->GetX(stsPoint->GetZ()), stsPoint->GetY(stsPoint->GetZ()));
424 fNofRecoPrim = 1;
425 if (trackPdg < 10000 && motherId >= 0) {
426 fNofRecoPdgSec[trackPdg] += 1;
427 fNofRecoSec += 1;
428 }
429 fNofRecoPrim = 1;
430 if (trackPdg < 10000 && motherId < 0) {
431 fNofRecoPdgPrim[trackPdg] += 1;
432 fNofRecoPrim += 1;
433 }
434 }
435 }
436 for (Int_t ang = 0; ang < 400; ang++) {
437 // Double_t factor = (Float_t)(fNofRecoPointsIncAng[ang])/(Float_t)(fNofPointsIncAng[ang]);
438 fhEffIncAng->Fill(ang, ((Float_t)(fNofRecoPointsIncAng[ang])) / ((Float_t)(fNofPointsIncAng[ang])));
439 }
440 for (Int_t momentum = 0; momentum < 50; momentum++) {
441 fhEffMom->Fill(momentum, ((Float_t)(fNofRecoPointsMom[momentum])) / ((Float_t)(fNofPointsMom[momentum])));
442 }
443
444 if (fOnlineAnalysis) {
445 recoPad[0]->cd();
446 TLegend* brp = new TLegend(0.1, 0.1, 0.9, 0.9, "STS hit finding");
447 brp->SetTextAlign(22);
448 brp->SetTextSize(0.6);
449 brp->SetTextColor(1);
450 brp->SetBorderSize(0);
451 brp->SetFillColor(0);
452 brp->Draw();
453 recoPad[0]->Update();
454
455 recoPad[1]->cd();
456 fhEffIncAng->SetLineWidth(2);
457 fhEffIncAng->SetLineColor(1);
458 fhEffIncAng->SetMarkerColor(kGreen);
459 fhEffIncAng->SetMarkerStyle(2);
460 fhEffIncAng->SetTitle("Efficiency");
461 fhEffIncAng->Draw();
462 TLine* oneLine = new TLine(0.0, 1.0, 10.0, 1.0);
463 oneLine->SetLineStyle(2);
464 oneLine->Draw();
465 recoPad[1]->Update();
466
467 TH1F* projX[10];
468 TH1F* projY[10];
469 TF1* fitX[10];
470 TF1* fitY[10];
471 Double_t resolution[2][10];
472
473 for (Int_t ist = 0; ist < 8; ist++) {
474 projX[ist] = (TH1F*)fhHitPointCorrelation[ist]->ProjectionX(Form("projX%i", ist + 1));
475 projY[ist] = (TH1F*)fhHitPointCorrelation[ist]->ProjectionY(Form("projY%i", ist + 1));
476 fitX[ist] = new TF1(Form("fitX%i", ist + 1), "gaus", -0.02, 0.02);
477 fitY[ist] = new TF1(Form("fitY%i", ist + 1), "gaus", -0.02, 0.02);
478 projX[ist]->SetAxisRange(-0.02, 0.02, "X");
479 projY[ist]->SetAxisRange(-0.02, 0.02, "X");
480 projX[ist]->Fit(fitX[ist], "QN", "", -0.02, 0.02);
481 projY[ist]->Fit(fitY[ist], "QN", "", -0.02, 0.02);
482 resolution[0][ist] = 10000. * fitX[ist]->GetParameter(2);
483 resolution[1][ist] = 10000. * fitY[ist]->GetParameter(2);
484 }
485
486 TH1F* projXPull;
487 TH1F* projYPull;
488 TF1* fitXPull;
489 TF1* fitYPull;
490 Double_t resolutionPull[2];
491
492 projXPull = (TH1F*)fhHitPointPull->ProjectionX("projXPull");
493 projYPull = (TH1F*)fhHitPointPull->ProjectionY("projYPull");
494 fitXPull = new TF1("fitXPull", "gaus", -2, 2);
495 fitYPull = new TF1("fitYPull", "gaus", -2, 2);
496 projXPull->SetAxisRange(-2, 2, "X");
497 projYPull->SetAxisRange(-2, 2, "X");
498 projXPull->Fit(fitXPull, "QN", "", -2, 2);
499 projYPull->Fit(fitYPull, "QN", "", -2, 2);
500 resolutionPull[0] = fitXPull->GetParameter(2);
501 resolutionPull[1] = fitYPull->GetParameter(2);
502
503 recoPad[3]->cd();
504 fhHitPointCorrelation[0]->Draw("col");
505 recoPad[3]->Update();
506
507 recoPad[4]->cd();
508 fhHitPointPull->Draw("col");
509 recoPad[4]->Update();
510
511 recoPad[5]->cd();
512 projX[0]->SetLineWidth(2);
513 projY[0]->SetLineWidth(2);
514 projX[0]->SetLineColor(2);
515 projY[0]->SetLineColor(3);
516 projY[0]->SetXTitle("#Delta x, y [cm]");
517 projX[0]->Draw();
518 projY[0]->Draw("same");
519 // fitY[fShowStation1]->Draw("same");
520 // fitX[fShowStation1]->Draw("same");
521 TLegend* legend1 = new TLegend(0.55, 0.6, 1.0, 0.94);
522 legend1->SetBorderSize(0);
523 legend1->SetFillColor(0);
524 legend1->AddEntry(projX[0], Form("X,#sigma=%3.2f#mum", resolution[0][0]), "l");
525 legend1->AddEntry(projY[0], Form("Y,#sigma=%3.2f#mum", resolution[1][0]), "l");
526 legend1->Draw();
527 recoPad[5]->Update();
528
529 recoPad[6]->cd();
530 projXPull->SetLineWidth(2);
531 projYPull->SetLineWidth(2);
532 projXPull->SetLineColor(2);
533 projYPull->SetLineColor(3);
534 projXPull->SetXTitle("Pull x, y ");
535 projXPull->Draw();
536 projYPull->Draw("same");
537 // fitY[fShowStation2]->Draw("same");
538 // fitX[fShowStation2]->Draw("same");
539 TLegend* legend2a = new TLegend(0.55, 0.6, 1.0, 0.94);
540 legend2a->SetBorderSize(0);
541 legend2a->SetFillColor(0);
542 legend2a->AddEntry(projXPull, Form("X,#sigma=%3.2f#mum", resolutionPull[0]), "l");
543 legend2a->AddEntry(projYPull, Form("Y,#sigma=%3.2f#mum", resolutionPull[1]), "l");
544 legend2a->Draw();
545 recoPad[6]->Update();
546 recoPad[2]->cd();
547 fhRecoPoints[0]->SetMarkerColor(kCyan);
548 fhRecoPoints[0]->Draw();
549 recoPad[2]->Update();
550
551 recoPad[7]->cd();
552 fhRecoPoints[1]->SetMarkerColor(kMagenta);
553 fhRecoPoints[1]->Draw();
554 recoPad[7]->Update();
555
556 recoPad[8]->cd();
557 fhRecoPoints[2]->SetMarkerColor(kOrange);
558 fhRecoPoints[2]->Draw();
559 recoPad[8]->Update();
560
561 recoPad[9]->cd();
562 fhRecoPoints[4]->SetMarkerColor(kGreen);
563 fhRecoPoints[4]->Draw();
564 recoPad[9]->Update();
565
566 recoPad[10]->cd();
567 fhRecoPoints[5]->SetMarkerColor(kBlue);
568 fhRecoPoints[5]->Draw();
569 recoPad[10]->Update();
570
571 recoPad[11]->cd();
572 fhRecoPoints[7]->SetMarkerColor(kRed);
573 fhRecoPoints[7]->Draw();
574 recoPad[11]->Update();
575
576 recoPad[12]->cd();
577 TPaveText* printoutPave = new TPaveText(0.0, 0.0, 1.0, 1.0);
578 printoutPave->SetTextAlign(20);
579 printoutPave->SetTextSize(0.08);
580 printoutPave->SetTextColor(1);
581 printoutPave->SetBorderSize(0);
582 printoutPave->SetFillColor(0);
583 printoutPave->AddText(Form("%i events", fNEvents + 1));
584 printoutPave->AddText(Form("Hits/Points %3.2f ", Double_t(nofStsHits) / Double_t(nofStsPoints)));
585
586 printoutPave->AddText(Form("%3.0f points prim, %3.0f reco prim",
589 printoutPave->AddText(Form("%3.0f points sec, %3.0f reco sec", Double_t(fNofPointsSec) / Double_t(fNEvents + 1),
591
592 printoutPave->AddText(Form("Hit Finding Efficiency: %3.2f prim, %3.2f sec",
595 // printoutPave->AddText("Tracking efficiencies (p>1.0 GeV/c):");
596 // printoutPave->AddText(Form("all = %2.2f%%(%2.2f%%)",100.*effAll,100.*allEff));
597 // printoutPave->AddText(Form("vertex = %2.2f%%(%2.2f%%)",100.*effPrim,100.*primEff));
598 // printoutPave->AddText(Form("reference = %2.2f%%",100.*effRef));
599 // printoutPave->AddText(Form("non-vertex = %2.2f%%(%2.2f%%)",100.*effSec,100.*secEff));
600 // printoutPave->AddText(Form("Momentum resolution =
601 // %3.2f%%(%3.2f%%)",momentumResolutionAll,momentumResolutionPrim));
602 recoPad[12]->Clear();
603 printoutPave->Draw();
604 recoPad[12]->Update();
605 }
606
607 // Event summary
608 if (fVerbose) {
609 cout << "---------- StsFindHitsQa : Event " << fNEvents + 1 << " summary ------------" << endl;
610 cout << "-----------------------------------------------------------" << endl;
611 cout << endl;
612 } else
613 cout << "\r+ " << setw(15) << left << fName << ": event " << fNEvents + 1 << " " << setprecision(4) << setw(8)
614 << fixed << right << fTimer.RealTime() << "s." << endl;
615
616 // cout << "-------- " << fNofRecoPoints[1][4][0] << " / " << fNofPoints[1][4][0] << endl;
617
618 fNEvents++;
619 fTime1 += fTimer.RealTime();
620}
621// -------------------------------------------------------------------------
622
623// ----- Private method CreateHistos -----------------------------------
625{
626
627 // Histogram list
628 fHistoList = new TList();
629 for (Int_t ist = 0; ist < fNStations; ist++)
630 fHistoListPS[ist] = new TList();
631
632 // Momentum distributions
633 // Double_t minMom = 0.;
634 // Double_t maxMom = 10.;
635 // Int_t nBinsMom = 40;
636
637 CbmStsStation* station = NULL;
638 CbmStsSector* sector = NULL;
639 // CbmStsSensor* sensor = NULL;
640
641 fhHitFindingEfficiency = new TH1F("hHitFindingEfficiency", "Hit finding efficiency", 1000000,
642 (Float_t)(2 << 24) - 0.5, (Float_t)(2 << 24) - 0.5 + 1000000.);
644 new TH2F(Form("hHitPointCorrelation"), Form("Hit vs point correlation "), 500, -.1, .1, 500, -.1, .1);
645 fhEffMom = new TH2F("hEffMom", "hEffMom", 500, 0, 25, 100, 0, 1);
646 fhEffIncAng = new TH2F("hEffIncAng", "hEffIncAng", 100, 0, 100, 100, 0, 1);
647 fhEffPdgSec = new TH2F("hEffPdgSec", "hEffPdgSec", 350, -1000, 2500, 10, 0, 1);
648 fhEffPdgPrim = new TH2F("hEffPdgPrim", "hEffPdgPrim", 350, -1000, 2500, 10, 0, 1);
649 fhHitPointPull = new TH2F("hHitPointPull", "Hit vs sigma at station %i", 500, -3., 3., 500, -3., 3.);
650
656 fHistoList->Add(fhEffMom);
658 for (Int_t ist = 0; ist < fNStations; ist++) {
660 new TH2F(Form("hHitPointCorrelation%i", ist + 1), Form("Hit vs point correlation at station %i", ist + 1),
661 500, -.1, .1, 500, -.1, .1);
662 fhHitPointCorrelation[ist]->SetXTitle("#Delta x [cm]");
663 fhHitPointCorrelation[ist]->SetYTitle("#Delta y [cm]");
664
665 fHistoListPS[ist]->Add(fhHitPointCorrelation[ist]);
666
668 new TH2F(Form("hHitPointCorrelationU%i", ist + 1), Form("Hit vs point correlation at station %i", ist + 1),
669 500, -.1, .1, 500, -.1, .1);
671 new TH2F(Form("hHitPointCorrelationB%i", ist + 1), Form("Hit vs point correlation at station %i", ist + 1),
672 500, -.1, .1, 500, -.1, .1);
673 fHistoListPS[ist]->Add(fhHitPointCorrelationU[ist]);
674 fHistoListPS[ist]->Add(fhHitPointCorrelationB[ist]);
675
676 fhPoints[ist] = new TH2F(Form("hPoints%i", ist + 1), Form("Points on station %i", ist + 1), 100, -100., 100.,
677 100, -100., 100.);
678 fhRecoPoints[ist] =
679 new TH2F(Form("hRecoPoints%i", ist + 1), Form("Reconstructed points on station %i", ist + 1), 100, -100.,
680 100., 100, -100., 100.);
681 fHistoListPS[ist]->Add(fhPoints[ist]);
682 fHistoListPS[ist]->Add(fhRecoPoints[ist]);
683 }
684
685 Double_t binningNofHits[501];
686 binningNofHits[0] = -0.5;
687 for (Int_t itemp = 0; itemp < 100; itemp++) {
688 binningNofHits[itemp + 1] = 0.5 + (Double_t)itemp;
689 binningNofHits[itemp + 101] = 101.5 + 2. * (Double_t)itemp;
690 binningNofHits[itemp + 201] = 302.5 + 3. * (Double_t)itemp;
691 binningNofHits[itemp + 301] = 602.5 + 3. * (Double_t)itemp;
692 binningNofHits[itemp + 401] = 902.5 + 3. * (Double_t)itemp;
693 }
694
695 // Double_t fSectorWidth = 0.;
696 for (Int_t istat = 0; istat < fNStations; istat++) {
697 station = fDigiScheme->GetStation(istat);
698
699 fhEnergyLoss[istat] = new TH3F(Form("hEnergyLossSt%d", istat + 1), Form("Energy loss on station %d", istat + 1),
700 20, -100., 100., 20, -100., 100., 100, 0, 0.01);
701 fhIncAngle[istat] =
702 new TH3F(Form("hIncAngleSt%d", istat + 1), Form("Incident Angle on station %d;X;Y;Angle", istat + 1), 100,
703 -50, 50, 100, -40, 40, 20, 0, 100.);
704 fHistoListPS[istat]->Add(fhEnergyLoss[istat]);
705 fHistoListPS[istat]->Add(fhIncAngle[istat]);
706 for (Int_t isect = 0; isect < station->GetNSectors(); isect++) {
707 sector = station->GetSector(isect);
708 for (Int_t isens = 0; isens < sector->GetNSensors(); isens++) {
709 // sensor = sector->GetSensor(isens);
710 // fSectorWidth = 10.*sensor->GetLx();
711 fhNofHits[istat][isect][isens] = new TH1F(
712 Form("hNofHitsSt%dSect%dSens%d", istat + 1, isect + 1, isens + 1),
713 Form("Number of hits in sector %d, sensor %d of station %d", isect + 1, isens + 1, istat + 1), 500,
714 binningNofHits);
715 // 500,-0.5,500.5);
716 fHistoListPS[istat]->Add(fhNofHits[istat][isect][isens]);
717 }
718 }
719 }
720}
721// -------------------------------------------------------------------------
722
723// ----- Private method Reset ------------------------------------------
725{
726
727 TIter next(fHistoList);
728 while (TH1* histo = ((TH1*)next()))
729 histo->Reset();
730 for (Int_t ist = 0; ist < fNStations; ist++) {
731 TIter next0(fHistoListPS[ist]);
732 while (TH1* histo = ((TH1*)next0()))
733 histo->Reset();
734 }
735}
736// -------------------------------------------------------------------------
737
738// ----- Private method SetParContainers -------------------------------
740{
741
742 // Get run and runtime database
743 FairRunAna* run = FairRunAna::Instance();
744 if (!run)
745 Fatal("SetParContainers", "No analysis run");
746
747 FairRuntimeDb* db = run->GetRuntimeDb();
748 if (!db)
749 Fatal("SetParContainers", "No runtime database");
750
751 // Get STS geometry parameter container
752 fGeoPar = (CbmGeoStsPar*)db->getContainer("CbmGeoStsPar");
753
754 // Get STS digitisation parameter container
755 fDigiPar = (CbmStsDigiPar*)db->getContainer("CbmStsDigiPar");
756}
757// -------------------------------------------------------------------------
758
759// ----- Private method Init -------------------------------------------
761{
762
763 // Get input array
764 FairRootManager* ioman = FairRootManager::Instance();
765 if (!ioman)
766 Fatal("Init", "No FairRootManager");
767
768 // Get MCTrack array
769 fMCTracks = (TClonesArray*)ioman->GetObject("MCTrack");
770 if (!fMCTracks) {
771 cout << "-E- " << GetName() << "::Init: No MCTrack array!" << endl;
772 return kFATAL;
773 }
774 // Get StsPoint array
775 fStsPoints = (TClonesArray*)ioman->GetObject("StsPoint");
776 if (!fStsPoints) {
777 // cout << "-E- " << GetName() << "::Init: No StsPoint array!" << endl;
778 return kFATAL;
779 }
780
781 // Get StsHit array
782 fStsHits = (TClonesArray*)ioman->GetObject("StsHit");
783 if (!fStsHits) {
784 cout << "-E- " << GetName() << "::Init: No StsHit array!" << endl;
785 return kFATAL;
786 }
787
788 // Get StsDigis array
789 fStsDigis = (TClonesArray*)ioman->GetObject("StsDigi");
790 if (!fStsDigis) {
791 cout << "-E- " << GetName() << "::Init: No StsDigi array!" << endl;
792 return kERROR;
793 }
794
795 // Get StsClusters array
796 fStsClusters = (TClonesArray*)ioman->GetObject("StsCluster");
797 if (!fStsClusters) {
798 cout << "-w- " << GetName() << "::Init: No StsCluster array!" << endl;
799 // return kERROR;
800 }
801
802 // Build digitisation scheme
803 Bool_t success = fDigiScheme->Init(fGeoPar, fDigiPar);
804 if (!success)
805 return kERROR;
806
807 fNStations = fDigiScheme->GetNStations();
808
809 CbmStsStation* station = NULL;
810 CbmStsSector* sector = NULL;
811 for (Int_t istat = fNStations; istat > 0;) {
812 station = fDigiScheme->GetStation(--istat);
813 for (Int_t isect = station->GetNSectors(); isect > 0;) {
814 sector = station->GetSector(--isect);
815 for (Int_t isens = sector->GetNSensors(); isens > 0;) {
816 fNofPoints[istat][isect][--isens] = 0;
817 fNofRecoPoints[istat][isect][isens] = 0;
818 }
819 }
820 }
821 for (Int_t iang = 0; iang < 400; iang++) {
822 fNofPointsIncAng[iang] = 0;
823 fNofRecoPointsIncAng[iang] = 0;
824 }
825 for (Int_t ipdg = -10000; ipdg < 10000; ipdg++) {
826 fNofRecoPdgSec[ipdg] = 0;
827 fNofPointsPdgSec[ipdg] = 0;
828 fNofRecoPdgPrim[ipdg] = 0;
829 fNofPointsPdgPrim[ipdg] = 0;
830 }
831
832 CreateHistos();
833 Reset();
834 if (fOnlineAnalysis) {
835 recoCanvas = new TCanvas("StsRecoCanvas", "Sts reconstruction", 10, 10, 600, 900);
836 // TPad* recoPad[10];
837
838 recoPad[0] = new TPad("titlePad", "Title pad", 0.00, 0.90, 1.00, 1.00);
839 recoPad[1] = new TPad("efficiencyPad", "Efficiency pad", 0.00, 0.60, 0.40, 0.90);
840 recoPad[3] = new TPad("hitVspoint1Pad", "Hit vs point on st.1 pad", 0.40, 0.65, 0.70, 0.90);
841 recoPad[4] = new TPad("hitPullst1", "Hit vs sigma on st.1 pad", 0.70, 0.65, 1.00, 0.90);
842 recoPad[5] = new TPad("hitVspntXY1Pad", "Hit vs point XY on st.1 pad", 0.40, 0.40, 0.70, 0.65);
843 recoPad[6] = new TPad("hitVssigmaXY6Pad", "Hit vs sigma XY on st.1 pad", 0.70, 0.40, 1.00, 0.65);
844 recoPad[2] = new TPad("Reco Points st1", "Reco Points st1", 0.00, 0.20, 0.33, 0.40);
845 recoPad[7] = new TPad("Reco Points st2", "Reco Points st2", 0.33, 0.20, 0.66, 0.40);
846 recoPad[8] = new TPad("Reco Points st3", "Reco Points st3", 0.66, 0.20, 1.00, 0.40);
847 recoPad[9] = new TPad("Reco Points st5", "Reco Points st5", 0.00, 0.00, 0.33, 0.20);
848 recoPad[10] = new TPad("Reco Points st6", "Reco Points st6", 0.33, 0.00, 0.66, 0.20);
849 recoPad[11] = new TPad("Reco Points st8", "Reco Points st8", 0.66, 0.00, 1.00, 0.20);
850 recoPad[12] = new TPad("printoutPad", "Print information pad", 0.00, 0.40, 0.40, 0.60);
851 // recoPad[12]->SetLogz();
852 for (Int_t ipad = 0; ipad < 13; ipad++) {
853 recoPad[ipad]->SetFillColor(0);
854 recoPad[ipad]->SetBorderMode(0);
855 recoPad[ipad]->Draw();
856 }
857 }
858 // Control output
859 if (fVerbose == 1 || fVerbose == 2)
860 fDigiScheme->Print(kFALSE);
861 else if (fVerbose > 2)
862 fDigiScheme->Print(kTRUE);
863 cout << "-I- " << fName << "::Init: " << "STS digitisation scheme succesfully initialised" << endl;
864 cout << " Stations: " << fDigiScheme->GetNStations() << ", Sectors: " << fDigiScheme->GetNSectors()
865 << ", Channels: " << fDigiScheme->GetNChannels() << endl;
866
867 return kSUCCESS;
868}
869// -------------------------------------------------------------------------
870
871// ----- Private method ReInit -----------------------------------------
873{
874 // Clear digitisation scheme
875 fDigiScheme->Clear();
876
877 // Build new digitisation scheme
878 Bool_t success = fDigiScheme->Init(fGeoPar, fDigiPar);
879 if (!success)
880 return kERROR;
881
882 // Control output
883 if (fVerbose == 1 || fVerbose == 2)
884 fDigiScheme->Print(kFALSE);
885 else if (fVerbose > 2)
886 fDigiScheme->Print(kTRUE);
887 cout << "-I- " << fName << "::Init: "
888 << "STS digitisation scheme succesfully reinitialised" << endl;
889 cout << " Stations: " << fDigiScheme->GetNStations() << ", Sectors: " << fDigiScheme->GetNSectors()
890 << ", Channels: " << fDigiScheme->GetNChannels() << endl;
891
892 return kSUCCESS;
893}
894// -------------------------------------------------------------------------
895
896// ----- Virtual method Finish -----------------------------------------
898{
899
900 CbmStsStation* station = NULL;
901 CbmStsSector* sector = NULL;
902 // Int_t NofRecoPoints = 0;
903 Int_t HFE_reco = 0;
904 Int_t HFE_point = 0;
905 for (Int_t istat = 0; istat < fDigiScheme->GetNStations(); istat++) {
906 station = fDigiScheme->GetStation(istat);
907 for (Int_t isect = 0; isect < station->GetNSectors(); isect++) {
908 sector = station->GetSector(isect);
909 for (Int_t isens = 0; isens < sector->GetNSensors(); isens++) {
910 HFE_reco = 1;
911 HFE_point = 1;
912 if (fNofPoints[istat][isect][isens]) {
913 fhHitFindingEfficiency->Fill(2 << 24 | (istat + 1) << 16 | (isect + 1) << 4 | (isens + 1) << 1,
914 ((Float_t)(fNofRecoPoints[istat][isect][isens]))
915 / ((Float_t)(fNofPoints[istat][isect][isens])));
916 HFE_reco += (fNofRecoPoints[istat][isect][isens]);
917 HFE_point += (fNofPoints[istat][isect][isens]);
918 }
919 }
920 }
921 }
922 for (Int_t iPdg = -10000; iPdg < 10000; iPdg++) {
923 fhEffPdgSec->Fill(iPdg, ((Float_t)(fNofRecoPdgSec[iPdg])) / ((Float_t)(fNofPointsPdgSec[iPdg])));
924 fhEffPdgPrim->Fill(iPdg, ((Float_t)(fNofRecoPdgPrim[iPdg])) / ((Float_t)(fNofPointsPdgPrim[iPdg])));
925 }
926
927 cout << endl;
928 cout << "============================================================" << endl;
929 cout << "===== " << fName << ": Run summary " << endl;
930 cout << "===== Hit finding efficiency = " << (((Float_t)(HFE_reco)) / ((Float_t)(HFE_point))) * 100. << "%" << endl;
931 cout << "============================================================" << endl;
932
933 gDirectory->mkdir("STSFindHitsQA");
934 gDirectory->cd("STSFindHitsQA");
935 TIter next(fHistoList);
936 while (TH1* histo = ((TH1*)next()))
937 histo->Write();
938
939 for (Int_t istat = 0; istat < fNStations; istat++) {
940 gDirectory->mkdir(Form("Station%d", istat + 1));
941 gDirectory->cd(Form("Station%d", istat + 1));
942 TIter nextO(fHistoListPS[istat]);
943 while (TH1* histo = ((TH1*)nextO()))
944 histo->Write();
945
946 gDirectory->cd("..");
947 }
948 gDirectory->cd("..");
949}
950// -------------------------------------------------------------------------
bool Bool_t
int Int_t
float Float_t
constexpr Bool_t kFALSE
double Double_t
constexpr Bool_t kTRUE
const char Option_t
kRed
kOrange
kGreen
kMagenta
kCyan
kBlue
#define gDirectory
void Fatal(const char *location, const char *msgfmt,...)
R__EXTERN TGeoManager * gGeoManager
char * Form(const char *fmt,...)
CbmMCTrack.h.
Definition CbmMCTrack.h:26
void GetMomentum(TVector3 &momentum) const
Definition CbmMCTrack.h:139
Int_t GetMotherId() const
Definition CbmMCTrack.h:57
void GetStartVertex(TVector3 &vertex) const
Definition CbmMCTrack.h:149
Int_t GetPdgCode() const
Accessors.
Definition CbmMCTrack.h:56
static CbmStsDigiScheme * Instance(int version=1)
CbmStsDigi.h.
Definition CbmStsDigi.h:32
Int_t GetSide() const
Side ( 0 = front, 1 = back ).
Definition CbmStsDigi.h:73
Int_t GetSectorNr() const
Sector number.
Definition CbmStsDigi.h:70
Int_t GetChannelNr() const
Channel number.
Definition CbmStsDigi.h:76
Int_t GetStationNr() const
Station number.
Definition CbmStsDigi.h:67
Int_t fNofDigisPChip[20][300][2][20]
Int_t fNofPointsMom[1000]
Int_t fNofRecoPdgSec[20000]
virtual void SetParContainers()
Get parameter containers.
TH3F * fhEnergyLoss[20]
Double_t fTime1
Number of events with success.
Int_t fNofPoints[20][300][3]
TClonesArray * fStsHits
virtual void Exec(Option_t *opt)
Execution.
TH2F * fhRecoPoints[20]
TClonesArray * fStsClusters
CbmStsFindHitsQa()
Default constructor.
TClonesArray * fMatches
Int_t fNofPointsPdgSec[20000]
Int_t fNofRecoPdgPrim[20000]
Int_t fNofRecoPointsMom[1000]
Int_t fNofRecoPoints[20][300][3]
TH2F * fhHitPointCorrelationU[100]
virtual InitStatus Init()
Intialisation.
virtual InitStatus ReInit()
Reinitialisation.
CbmGeoStsPar * fGeoPar
Pointers to data arrays.
virtual void Finish()
Virtual method Finish.
TClonesArray * fStsDigis
TList * fHistoList
List of histograms.
TClonesArray * fStsPoints
TH2F * fhHitPointCorrelation[100]
TH1F * fhNofHits[20][300][3]
Int_t fNofHits[20][300][3]
Int_t fNofRecoPointsIncAng[1000]
CbmStsDigiScheme * fDigiScheme
Digitisation parameters.
CbmStsDigiPar * fDigiPar
Geometry parameters.
virtual ~CbmStsFindHitsQa()
Destructor.
Int_t fNofPointsPdgPrim[20000]
Int_t fNofPointsIncAng[1000]
TList * fHistoListPS[20]
void Reset()
Reset histograms and counters.
void CreateHistos()
Create histograms.
TClonesArray * fMCTracks
Digitisation scheme.
TH2F * fhHitPointCorrelationB[100]
Int_t GetSensorNr() const
Definition CbmStsHit.h:72
virtual Int_t GetStationNr() const
Definition CbmStsHit.h:67
Int_t GetSectorNr() const
Definition CbmStsHit.h:68
Double_t GetY(Double_t z) const
Double_t GetX(Double_t z) const
Point coordinates at given z from linear extrapolation.
Double_t GetXIn() const
Accessors.
Definition CbmStsPoint.h:64
Double_t GetZOut() const
Definition CbmStsPoint.h:69
Double_t GetZIn() const
Definition CbmStsPoint.h:66
Double_t GetYIn() const
Definition CbmStsPoint.h:65
Double_t GetXOut() const
Definition CbmStsPoint.h:67
CbmStsSensor * GetSensor(Int_t iSensor)
Int_t GetNSensors() const
Double_t GetX0() const
Int_t GetSectorNr() const
Int_t GetStationNr() const
Double_t GetY0() const
Int_t GetSensorNr() const
Int_t GetNSectors() const
CbmStsSector * GetSector(Int_t iSector)
virtual void SetFillColor(Color_t fcolor)
virtual void SetLineStyle(Style_t lstyle)
virtual void SetLineWidth(Width_t lwidth)
virtual void SetLineColor(Color_t lcolor)
virtual void SetTextAlign(Short_t align=11)
virtual void SetTextColor(Color_t tcolor=1)
virtual void SetTextSize(Float_t tsize=1)
virtual Double_t GetParameter(const TString &name) const
virtual void SetXTitle(const char *title)
virtual TFitResultPtr Fit(const char *formula, Option_t *option="", Option_t *goption="", Double_t xmin=0, Double_t xmax=0)
void Draw(Option_t *option="") override
virtual void SetAxisRange(Double_t xmin, Double_t xmax, Option_t *axis="X")
void Draw(Option_t *option="") override
TLegendEntry * AddEntry(const char *name, const char *label="", Option_t *option="lpf")
virtual void Draw(Option_t *option="")
virtual TText * AddText(const char *label)
void Draw(Option_t *option="") override
virtual void SetBorderSize(Int_t bordersize=4)
Double_t Mag() const
Double_t ATan2(Double_t y, Double_t x)
Double_t Abs(Double_t d)
Definition json.hpp:4446