17#include "FairRootManager.h"
18#include "FairRunAna.h"
19#include "FairRuntimeDb.h"
34using std::setprecision;
52 :
FairTask(
"STSRealFindHits", iVerbose)
95 cerr <<
"-E- " << fName <<
"::Exec: No digi scheme!" << endl;
107 Int_t nClustersF = 0;
108 Int_t nClustersB = 0;
112 for (
Int_t iStation = 0; iStation < nStations; iStation++) {
115 Int_t nClustersFInStation = 0;
116 Int_t nClustersBInStation = 0;
117 Int_t nHitsInStation = 0;
119 for (
Int_t iSector = 0; iSector < nSectors; iSector++) {
121 set<Int_t> fSet, bSet;
123 cout <<
"-E- " << fName <<
"::Exec: sector " << sector->
GetSectorNr() <<
" of station "
124 << station->
GetStationNr() <<
"not found in front map!" << endl;
131 cout <<
"-E- " << fName <<
"::Exec: sector " << sector->
GetSectorNr() <<
" of station "
132 << station->
GetStationNr() <<
"not found in back map!" << endl;
138 Int_t nClustersFInSector = fSet.size();
139 Int_t nClustersBInSector = bSet.size();
142 cout <<
"Sector " << sector->
GetSectorNr() <<
", Clusters front " << nClustersFInSector
143 <<
", Clusters Back " << nClustersBInSector <<
", Hits " << nHitsInSector << endl;
144 nHitsInStation += nHitsInSector;
145 nClustersFInStation += nClustersFInSector;
146 nClustersBInStation += nClustersBInSector;
150 cout <<
"Total for station " << station->
GetStationNr() <<
": Clusters front " << nClustersFInStation
151 <<
", clusters back " << nClustersBInStation <<
", hits " << nHitsInStation << endl;
152 nClustersB += nClustersBInStation;
153 nClustersF += nClustersFInStation;
154 nHits += nHitsInStation;
161 cout <<
"-I- " << fName <<
":Event summary" << endl;
162 cout <<
" Clusters front side : " << nClustersF << endl;
163 cout <<
" Clusters back side : " << nClustersB << endl;
164 cout <<
" Hits created : " << nHits << endl;
165 cout <<
" Real time : " <<
fTimer.RealTime() << endl;
171 cout << setw(15) << left << fName <<
": " << setprecision(4) << setw(8) << fixed << right <<
fTimer.RealTime()
172 <<
" s, clusters " << nClustersF <<
" / " << nClustersB <<
", hits: " << nHits << endl;
184 FairRunAna* run = FairRunAna::Instance();
186 Fatal(
"SetParContainers",
"No analysis run");
188 FairRuntimeDb* db = run->GetRuntimeDb();
190 Fatal(
"SetParContainers",
"No runtime database");
205 FairRootManager* ioman = FairRootManager::Instance();
207 Fatal(
"Init",
"No FairRootManager");
212 ioman->Register(
"StsHit",
"Hit in STS",
fHits,
kTRUE);
223 if (fVerbose == 1 || fVerbose == 2)
225 else if (fVerbose > 2)
227 cout <<
"-I- " << fName <<
"::Init: "
228 <<
"STS digitisation scheme succesfully initialised" << endl;
230 <<
", Channels: " <<
fDigiScheme->GetNChannels() << endl;
252 if (fVerbose == 1 || fVerbose == 2)
254 else if (fVerbose > 2)
256 cout <<
"-I- " << fName <<
"::Init: "
257 <<
"STS digitisation scheme succesfully reinitialised" << endl;
259 <<
", Channels: " <<
fDigiScheme->GetNChannels() << endl;
272 for (
Int_t iStation = 0; iStation < nStations; iStation++) {
275 for (
Int_t iSector = 0; iSector < nSectors; iSector++) {
294 cout <<
"-E- " << fName <<
"::SortClusters: No input array!" << endl;
299 map<CbmStsSector*, set<Int_t>>::iterator mapIt;
301 ((*mapIt).second).clear();
303 ((*mapIt).second).clear();
308 Int_t stationNr = -1;
312 for (
Int_t iClus = 0; iClus < nClusters; iClus++) {
317 sector =
fDigiScheme->GetSector(stationNr, sectorNr);
320 cerr <<
"-E- " << fName <<
"::SortClusters:: sector " << sectorNr <<
" of station " << stationNr
321 <<
" not found in digi scheme (F)!" << endl;
325 }
else if (iSide == 1) {
327 cerr <<
"-E- " << fName <<
"::SortClusters:: sector " << sectorNr <<
" of station " << stationNr
328 <<
" not found in digi scheme (B)!" << endl;
368 }
else if (iType == 2 || iType == 3) {
371 vXY = -1. * dx * dx / 12. / tanstr;
373 cerr <<
"-E- " << fName <<
"::FindHits: Illegal sector type " << iType << endl;
378 Double_t wX = vX * vX * cosrot * cosrot - 2. * vXY * cosrot * sinrot + vY * vY * sinrot * sinrot;
379 Double_t wY = vX * vX * sinrot * sinrot + 2. * vXY * cosrot * sinrot + vY * vY * cosrot * cosrot;
380 Double_t wXY = (vX * vX - vY * vY) * cosrot * sinrot + vXY * (cosrot * cosrot - sinrot * sinrot);
385 set<Int_t>::iterator it1;
386 set<Int_t>::iterator it2;
390 Fatal(
"FindHits",
"Sorry, not implemented yet");
397 Fatal(
"FindHits",
"Sorry, not implemented yet");
415 for (it1 = fSet.begin(); it1 != fSet.end(); it1++) {
419 cout <<
"-W- " << GetName() <<
"::FindHits: Invalid cluster index " << iClusF
425 for (it2 = bSet.begin(); it2 != bSet.end(); it2++) {
429 cout <<
"-W- " << GetName() <<
"::FindHits: Invalid cluster index " << iClusB
430 <<
" in back set of sector " << sector->
GetSectorNr() <<
", station "
438 if (sensorDetId == -1)
441 pos.
SetXYZ(xHit, yHit, zHit);
444 Int_t statLayer = -1;
445 for (
Int_t istatL = station->
GetNofZ(); istatL > 0; istatL--)
447 statLayer = istatL - 1;
452 cout <<
"unknown layer for hit at z = " << zHit << endl;
454 new ((*fHits)[nHits++])
455 CbmStsHit(sensorDetId, pos, dpos, wXY, iClusF, iClusB, (
Int_t)chanF, (
Int_t)chanB, statLayer);
459 cout <<
"New StsHit at (" << xHit <<
", " << yHit <<
", " << zHit <<
"), station " << stationNr
460 <<
", sector " << sectorNr <<
", channel " << chanF <<
" / " << chanB << endl;
476 cout <<
"============================================================" << endl;
477 cout <<
"===== " << fName <<
": Run summary " << endl;
478 cout <<
"===== " << endl;
479 cout <<
"===== Number of hits : " << setw(8) << setprecision(2) <<
fNHits << endl;
480 cout <<
"============================================================" << endl;
void Fatal(const char *location, const char *msgfmt,...)
Int_t GetStationNr() const
Int_t GetSectorNr() const
Double_t GetMeanError() const
virtual ~CbmStsRealFindHits()
Destructor.
virtual void Exec(Option_t *opt)
Execution.
void SortClusters()
Sort digis sectorwise.
virtual InitStatus ReInit()
Reinitialisation.
std::map< CbmStsSector *, std::set< Int_t > > fClusterMapF
Output array of CbmStsHit.
Int_t FindHits(CbmStsStation *station, CbmStsSector *sector, std::set< Int_t > &fSet, std::set< Int_t > &bSet)
Find hits in one sector.
std::map< CbmStsSector *, std::set< Int_t > > fClusterMapB
sector clusters (front)
CbmStsDigiScheme * fDigiScheme
Digitisation parameters.
CbmStsDigiPar * fDigiPar
Geometry parameters.
TClonesArray * fClusters
Digitisation scheme.
TStopwatch fTimer
sector clusters (back)
TClonesArray * fHits
Input array of CbmStsCluster.
virtual void Finish()
Virtual method Finish.
virtual InitStatus Init()
Intialisation.
void MakeSets()
Make sectorwise sets for sigis.
CbmStsRealFindHits()
Default constructor.
virtual void SetParContainers()
Get parameter containers.
Int_t GetSectorNr() const
Int_t IntersectClusters(Double_t fChan, Double_t bChan, Double_t &xCross, Double_t &yCross, Double_t &zCross)
Int_t GetDetectorId() const
Double_t GetRotation() const
Double_t GetStereoB() const
Int_t GetNSectors() const
Double_t GetZ(Int_t it=0)
Int_t GetStationNr() const
CbmStsSector * GetSector(Int_t iSector)
void SetXYZ(Double_t x, Double_t y, Double_t z)
Double_t Sqrt(Double_t x)