12#include "FairRootManager.h"
13#include "FairRunAna.h"
14#include "FairRuntimeDb.h"
22#include "CbmStsPoint.h"
26#include "FairGeoNode.h"
27#include "FairGeoPassivePar.h"
28#include "FairGeoVector.h"
41using std::setprecision;
127 for (
Int_t iHit = 0; iHit < nHits; iHit++) {
130 cout <<
"-W- " << GetName() <<
"::Exec: Empty hit at index " << iHit << endl;
155 cout <<
"-E- " << GetName() <<
"::Exec: "
156 <<
"No DigiMatchF for hit " << iHit << endl;
157 hit->SetRefIndex(-1);
169 cout <<
"-E- " << GetName() <<
"::Exec: "
170 <<
"No DigiMatchB for hit " << iHit << endl;
171 hit->SetRefIndex(-1);
185 for (
Int_t iMatchF = 0; iMatchF < 3; iMatchF++) {
193 cout <<
"-E- " << GetName() <<
"::Exec: "
194 <<
"No StsPoint (" << iPointF <<
") for pixel hit " << iHit << endl;
207 else if (iType == 2 || iType == 3)
211 for (
Int_t iMatchF = 0; iMatchF < 3; iMatchF++) {
217 for (
Int_t iMatchB = 0; iMatchB < 3; iMatchB++) {
224 if (iPointB != iPointF)
229 cout <<
"-E- " << GetName() <<
"::Exec: "
230 <<
"No StsPoint (" << iPointF <<
") for strip hit " << iHit << endl;
246 cout <<
"-E- " << GetName() <<
"::Exec: Unknwon sensor type " << iType << endl;
247 Fatal(
"Exec",
"Unknwon sensor type");
251 cout <<
"-I- " << GetName() <<
": Hit " << iHit <<
", type " << iType <<
", points " << nPointsF <<
" / "
252 << nPointsB <<
", candidates " <<
fCandMap.size();
258 hit->SetRefIndex(-1);
260 cout <<
", background " << endl;
269 if ((*fIter).first < distMin) {
270 distMin = (*fIter).first;
271 iPoint = (*fIter).second;
275 cout <<
"-E- " << GetName() <<
"::Exec: "
276 <<
"No closest point found in candidate map!" << endl;
277 Fatal(
"Exec",
"No closest point");
281 cout <<
", matched to " << iPoint <<
", distance " << distMin <<
" cm";
290 hit->SetRefIndex(-2);
293 cout <<
", distant" << endl;
294 if (iType == 1 || iType == 2) {
295 cout <<
"-W- " << fName <<
"::Exec: "
296 <<
"Distant hit in pixel / strip MSU station" << endl;
297 cout <<
"Hit " << iHit <<
" coordinates " << xH <<
", " << yH << endl;
298 cout <<
"Matched point " << iPoint <<
", distance " << distMin << endl;
299 cout <<
"Distance y " <<
TMath::Abs(xP - xH) <<
" Error " << dX << endl;
300 cout <<
"Distance y " <<
TMath::Abs(yP - yH) <<
" Error " << dY << endl;
307 hit->SetRefIndex(iPoint);
310 cout <<
", good match" << endl;
314 if (
TMath::Abs(hit->GetZ() - point->GetZ()) > 1.) {
315 cout <<
"-E- " << GetName() <<
"::Exec: Hit " << iHit <<
" is at z = " << hit->GetZ()
316 <<
" cm, but matched point " << iPoint <<
" is at z = " << point->GetZ() <<
"cm " << endl;
317 Fatal(
"Exec",
"Different stations for hit and point");
328 cout << setw(15) << left << fName <<
": " << setprecision(4) << setw(8) << fixed << right <<
fTimer.RealTime()
329 <<
" s, hits " << nHits <<
", matched " << nMatched <<
", distant " << nDistant <<
", background " << setw(6)
364 cout <<
"there are " << nofStsPoints <<
" points and " << nofStsHits <<
" hits." << endl;
365 Int_t hitStationLimits[2][100];
368 hitStationLimits[0][ist] = -1;
369 hitStationLimits[1][ist] = -1;
373 for (
Int_t ihit = 0; ihit < nofStsHits; ihit++) {
375 stsHit->SetRefIndex(-1);
376 if (hitStationLimits[0][stsHit->
GetStationNr() - 1] == -1)
379 if (hitStationLimits[1][stsHitBack->
GetStationNr() - 1] == -1) {
380 hitStationLimits[1][stsHitBack->
GetStationNr() - 1] = nofStsHits - ihit;
387 for (
Int_t ipnt = 0; ipnt < nofStsPoints; ipnt++) {
393 if (startHit == -1 && finalHit == -1)
396 for (
Int_t ihit = startHit; ihit < finalHit; ihit++) {
398 if ((
TMath::Abs(stsHit->GetX() - stsPoint->
GetX(stsHit->GetZ())) < .01)
399 && (
TMath::Abs(stsHit->GetY() - stsPoint->
GetY(stsHit->GetZ())) < .04))
404 stsHit->SetRefIndex(ipnt);
418 cout << setw(15) << left << fName <<
": " << setprecision(4) << setw(8) << fixed << right <<
fTimer.RealTime()
419 <<
" s, hits " << nHits <<
", matched " << nMatched <<
", distant " << nDistant <<
", background " << setw(6)
441 FairRunAna* run = FairRunAna::Instance();
443 Fatal(
"SetParContainers",
"No analysis run");
444 FairRuntimeDb* db = run->GetRuntimeDb();
446 Fatal(
"SetParContainers",
"No runtime database");
464 FairRootManager* ioman = FairRootManager::Instance();
466 Fatal(
"Init",
"No FairRootManager");
474 cout <<
"-E- " << GetName() <<
"::Init: No StsDigi array!" << endl;
479 cout <<
"-E- " << GetName() <<
"::Init: No StsDigiMatch array!" << endl;
484 cout <<
"-E- " << GetName() <<
"::Init: No StsHit array!" << endl;
489 if (geoStatus != kSUCCESS) {
490 cout <<
"-E- " << GetName() <<
"::Init: Error in reading geometry!" << endl;
496 if (fVerbose == 1 || fVerbose == 2)
498 else if (fVerbose > 2)
500 cout <<
"-I- " << fName <<
"::Init: "
501 <<
"STS digitisation scheme succesfully initialised" << endl;
503 <<
", Channels: " <<
fDigiScheme->GetNChannels() << endl;
523 if (geoStatus != kSUCCESS) {
524 cout <<
"-E- " << GetName() <<
"::Init: Error in reading geometry!" << endl;
538 cout <<
"-W- " << GetName() <<
"::GetGeometry: No passive geometry!" << endl;
544 cout <<
"-W- " << GetName() <<
"::GetGeometry: No passive node array" << endl;
564 cout <<
"-W- " << GetName() <<
"::GetGeometry: No passive geometry!" << endl;
570 cout <<
"-E- " << GetName() <<
"::GetGeometry: No STS node array" << endl;
576 cout <<
"There are " << tempNofStations <<
" nodes" << (tempNofStations > 10 ?
"!!!" :
"") << endl;
581 for (
Int_t ist = 0; ist < tempNofStations; ist++) {
582 FairGeoNode* stsNode = (FairGeoNode*)stsNodes->
At(ist);
584 cout <<
"-W- CbmStsDigiScheme::Init: station#" << ist <<
" not found among sensitive nodes " << endl;
587 geoNodeName = stsNode->getName();
593 if (geoNodeName.Contains(stationNames[ikst])) {
595 stationKnown =
kTRUE;
607 geoNodeName.Remove(12, geoNodeName.Length() - 12);
611 cout <<
"station #" <<
fNStations <<
" has MCID = " << stsNode->getMCid() <<
" and name " << stsNode->GetName()
616 cout <<
"There are " <<
fNStations <<
" stations" << endl;
627 cout <<
"============================================================" << endl;
628 cout <<
"===== " << GetName() <<
": Run summary " << endl;
629 cout <<
"===== " << endl;
630 cout <<
"===== Good events : " << setw(6) <<
fNEvents << endl;
631 cout <<
"===== Failed events : " << setw(6) <<
fNEventsFailed << endl;
632 cout <<
"===== Average time : " << setprecision(4) << setw(8) << right <<
fTime /
Double_t(
fNEvents) <<
" s"
634 cout <<
"===== " << endl;
636 cout << setprecision(2);
637 cout <<
"===== Matched hits : " << fixed << setw(6) << right <<
fNMatched /
fNHits * 100. <<
" %" << endl;
638 cout <<
"===== Distant hits : " << fixed << setw(6) << right <<
fNDistant /
fNHits * 100. <<
" %" << endl;
639 cout <<
"===== Background hits : " << fixed << setw(6) << right <<
fNBackgrd /
fNHits * 100. <<
" % " << endl;
640 cout <<
"============================================================" << endl;
vector< Double_t > dist(vector< Double_t > qp, Double_t mu)
void Fatal(const char *location, const char *msgfmt,...)
Int_t GetRefIndex(Int_t i=0) const
Accessor to StsPoint indizes.
virtual Int_t GetStationNr() const
Int_t GetSectorNr() const
Int_t GetDigi(Int_t iSide) const
Double_t GetY(Double_t z) const
Double_t GetX(Double_t z) const
Point coordinates at given z from linear extrapolation.
Double_t fNDistant
Total number of matched hits.
Int_t fStationNrFromMcId[10000]
virtual ~CbmStsRealMatchHits()
Destructor.
CbmStsDigiPar * fDigiPar
Geometry parameter container.
FairGeoPassivePar * fPassGeo
Total number of background hits.
virtual void Exec(Option_t *opt)
Execution.
CbmStsRealMatchHits()
Default constructor.
Double_t fNHits
Total real time used for good events.
map< Double_t, Int_t > fCandMap
Map from candidate point to distance to hit.
Double_t fNMatched
Total number of hits.
TStopwatch fTimer
Array of CbmStsHit.
virtual void SetParContainers()
Get parameter containers.
TClonesArray * fPoints
Digitisation scheme.
virtual InitStatus ReInit()
Reinitialisation.
Int_t fNEventsFailed
Number of events with success.
Double_t fNBackgrd
Total number of displaced hits.
map< Double_t, Int_t >::iterator fIter
virtual void Finish()
Run summary.
Double_t fTime
Number of events with failure.
CbmStsDigiScheme * fDigiScheme
Digitisation parameter container.
TClonesArray * fDigiMatches
Array of CbmStsDigi.
TClonesArray * fDigis
Array of CbmStsPoint.
TClonesArray * fHits
Array of CbmStsDigiMatch.
virtual InitStatus Init()
Intialisation.
virtual void ExecReal(Option_t *opt)
Double_t GetZ(Int_t it=0)
Int_t GetEntries() const override
TObject * At(Int_t idx) const override
const char * Data() const
Double_t Sqrt(Double_t x)