19#include <FairRootManager.h>
85 QAHit(
double _x,
double _dx,
double _y,
double _dy,
double _t,
double _dt, set<const QAMCPoint*> _points,
86 set<const QAMCTrack*> _tracks,
int _detId)
108static vector<vector<QAHit>>
hits;
124 , fTofDigiPointMatchs(0)
134 FairRootManager* ioman = FairRootManager::Instance();
136 if (0 == ioman) LOG(fatal) <<
"No FairRootManager";
138 fTofHits =
static_cast<TClonesArray*
>(ioman->GetObject(
"TofHit"));
139 fTofDigiMatchs =
static_cast<TClonesArray*
>(ioman->GetObject(
"TofDigiMatch"));
140 fTofDigis =
static_cast<TClonesArray*
>(ioman->GetObject(
"TofDigiExp"));
173 if (0 ==
fTimeSlice) LOG(fatal) <<
"No time slice";
177 if (0 ==
fEventList) LOG(fatal) <<
"No event list";
179 for (
int i = 0; i < 1000; ++i) {
180 vector<QAMCTrack>& evMcTracks =
mcTracks[i];
181 vector<QAMCPoint>& evMcPoints =
mcPoints[i];
185 if (nofmct > 0) evMcTracks.resize(nofmct);
189 if (nofmcp > 0) evMcPoints.resize(nofmcp);
191 for (
int j = 0; j < nofmcp; ++j) {
193 int trackId = tp->GetTrackID();
194 evMcPoints[j] = {tp->GetX(), tp->GetY(), tp->GetTime(), tp->GetDetectorID(), &evMcTracks[trackId],
false};
195 const QAMCPoint* lastPoint = &evMcPoints[j];
196 evMcTracks[trackId].points.push_back(lastPoint);
200 deltaTHisto =
new TH1F(
"deltaTHisto",
"deltaTHisto", 100, -1., 1.);
201 deltaXHisto =
new TH1F(
"deltaXHisto",
"deltaXHisto", 100, -5., 5.);
202 deltaYHisto =
new TH1F(
"deltaYHisto",
"deltaYHisto", 100, -5., 5.);
203 pullTHisto =
new TH1F(
"pullTHisto",
"pullTHisto", 100, -5., 5.);
204 pullXHisto =
new TH1F(
"pullXHisto",
"pullXHisto", 100, -5., 5.);
205 pullYHisto =
new TH1F(
"pullYHisto",
"pullYHisto", 100, -5., 5.);
206 nofHitsHisto =
new TH1F(
"nofHitsHisto",
"nofHitsHisto", 5, 0., 5.);
309 Int_t nofHits =
fTofHits->GetEntriesFast();
310 evHits.resize(nofHits);
312 Int_t nofDigis =
fTofDigis->GetEntriesFast();
315 for (
int i = 0; i < nofHits; ++i) {
325 set<const QAMCPoint*> {},
326 set<const QAMCTrack*> {},
328 QAHit& lastHit = evHits[i];
332 for (
int j = 0; j < nofDigis; ++j) {
340 for (Int_t k = 0; k < nofPoints; ++k) {
342 Int_t evN = pointLnk.
GetEntry() - 1;
343 Int_t pointInd = pointLnk.
GetIndex();
347 if (!
mcPoints[evN][pointInd].isInit) {
349 mcPoints[evN][pointInd].t += eventTime;
350 mcPoints[evN][pointInd].isInit =
true;
357 for (set<const QAMCPoint*>::const_iterator j = lastHit.
points.begin(); j != lastHit.
points.end(); ++j) {
362 for (set<QAMCTrack*>::iterator j =
tracks.begin(); j !=
tracks.end(); ++j) {
364 track->
hits.push_back(&lastHit);
373 TFile* curFile = TFile::CurrentFile();
374 TString histoName = histo->GetName();
375 histoName +=
".root";
376 TFile fh(histoName.Data(),
"RECREATE");
380 TFile::CurrentFile() = curFile;
479 int nofTracksTof = 0;
480 int nofTracksHit = 0;
483 for (vector<vector<QAMCTrack>>::const_iterator i =
mcTracks.begin(); i !=
mcTracks.end(); ++i) {
484 const vector<QAMCTrack>& evTracks = *i;
486 if (!evTracks.empty()) ++nofMCEvents;
488 for (vector<QAMCTrack>::const_iterator j = evTracks.begin(); j != evTracks.end(); ++j) {
491 if (!track.
points.empty()) {
494 if (!track.
hits.empty()) ++nofTracksHit;
497 for (list<const QAHit*>::const_iterator k = track.
hits.begin(); k != track.
hits.end(); ++k) {
498 const QAHit* hit = *k;
500 set<const QAMCPoint*> hitPoints;
518 for (list<const QAMCPoint*>::const_iterator l = track.
points.begin(); l != track.
points.end(); ++l) {
525 if (hitPoints.empty())
continue;
527 for (set<const QAMCPoint*>::const_iterator l = hitPoints.begin(); l != hitPoints.end(); ++l) {
534 int nofPoints = hitPoints.size();
535 double deltaX = hit->
x -
x / nofPoints;
536 double deltaY = hit->
y -
y / nofPoints;
537 double deltaT = hit->
t - t / nofPoints;
548 int nofHitEvents = 0;
550 int nofSingleHits = 0;
552 for (vector<vector<QAHit>>::const_iterator i =
hits.begin(); i !=
hits.end(); ++i) {
553 const vector<QAHit>& evHits = *i;
555 if (!evHits.empty()) ++nofHitEvents;
557 nofHits += evHits.size();
559 for (vector<QAHit>::const_iterator j = evHits.begin(); j != evHits.end(); ++j) {
560 const QAHit& hit = *j;
563 if (hit.
tracks.size() == 1) ++nofSingleHits;
576 double eff = 100 * nofTracksHit;
578 cout <<
"Clustering efficiency: " << eff <<
" % [ " << nofTracksHit <<
" / " << nofTracksTof <<
" ]" << endl;
579 cout <<
"NOF hit events: " << nofHitEvents << endl;
580 cout <<
"NOF hits: " << nofHits << endl;
583 cout <<
"NOF MC Events: " << nofMCEvents << endl;
584 eff = 100 * nofSingleHits;
586 cout <<
"Pure hits: " << eff <<
" % [ " << nofSingleHits <<
" / " << nofHits <<
" ]" << endl;
ClassImp(CbmConverterManager)
static vector< vector< QAMCTrack > > mcTracks
static TH1F * deltaTHisto
static vector< vector< QAMCPoint > > mcPoints
static TH1F * nofTracksDepositedHisto
static TH1F * deltaXHisto
static TH1F * deltaYHisto
static void SaveHisto(TH1 *histo)
static TH1F * nofHitsHisto
static int globalNofDigis
static vector< vector< QAHit > > hits
double GetTimeError() const
int32_t GetAddress() const
TObject * Get(const CbmLink *lnk)
Int_t Size(Int_t fileNumber, Int_t eventNumber)
Task class creating and managing CbmMCDataArray objects.
CbmMCDataArray * InitBranch(const char *name)
Container class for MC events with number, file and start time.
double GetEventTime(uint32_t event, uint32_t file)
Event start time.
const CbmLink & GetLink(int32_t i) const
int32_t GetNofLinks() const
Bookkeeping of time-slice content.
static int32_t GetModFullId(uint32_t address)
CbmMCEventList * fEventList
void Exec(Option_t *option)
CbmMCDataArray * fTofMCPoints
CbmTimeSlice * fTimeSlice
CbmMCDataArray * fMCTracks
TClonesArray * fTofDigiPointMatchs
TClonesArray * fTofDigiMatchs
Geometric intersection of a MC track with a TOFb detector.
set< const QAMCPoint * > points
set< const QAMCTrack * > tracks
QAHit(double _x, double _dx, double _y, double _dy, double _t, double _dt, set< const QAMCPoint * > _points, set< const QAMCTrack * > _tracks, int _detId)
list< const QAHit * > hits
list< const QAMCPoint * > points