6#include "FairRootManager.h"
23 , fUseMCData(useMCdata)
25 , fTestFlnm(
"test.BmnTof1HitProducerIdeal.root")
32 LOG(info) <<
"[BmnTof1HitProducerIdeal::Init] Begin initialization.";
34 FairRootManager* ioman = FairRootManager::Instance();
38 aMcPoints = (TClonesArray*)FairRootManager::Instance()->GetObject(
"TOF400Point");
40 cout <<
"BmnTof1HitProducerIdeal::Init(): branch TOF1Point not found! Task will be deactivated" << endl;
44 aMcTracks = (TClonesArray*)FairRootManager::Instance()->GetObject(
"MCTrack");
46 cout <<
"BmnTof1HitProducerIdeal::Init(): branch MCTrack not found! Task will be deactivated" << endl;
51 aExpDigits = (TClonesArray*)FairRootManager::Instance()->GetObject(
"bmn_tof400");
53 cout <<
"BmnTof1HitProducerIdeal::Init(): branch bmn_tof400 not found! Task will be deactivated" << endl;
60 aTofHits =
new TClonesArray(
"BmnTofHit");
61 ioman->Register(
"TOF400Hit",
"TOF1",
aTofHits, kTRUE);
63 LOG(info) <<
"[BmnTof1HitProducerIdeal::Init] Initialization finished succesfully.";
73 static const TVector3 XYZ_err(0., 0., 0.);
77 Int_t nSingleHits = 0;
82 Int_t nTofPoint =
aMcPoints->GetEntriesFast();
84 for (Int_t pointIndex = 0; pointIndex < nTofPoint; pointIndex++)
87 pPoint->Position(pos);
89 AddHit(pPoint->GetDetectorID(), pos, XYZ_err, pointIndex, pPoint->GetTrackID(), pPoint->GetTime(),
kTOF1);
99 nFinally =
aTofHits->GetEntriesFast();
101 cout <<
" -I- [BmnTof1HitProducerIdeal::Exec] single hits= " << nSingleHits <<
", final hits= " << nFinally
109 typedef map<Int_t, BmnTofHit*> hitsMapType;
111 hitsMapType::iterator it;
114 typedef multiset<Int_t> msUIDsType;
118 for (Int_t hitIndex = 0, nHits =
aTofHits->GetEntriesFast(); hitIndex < nHits; hitIndex++)
121 assert(
nullptr != pHit);
123 Int_t UID = pHit->GetDetectorID();
128 it = fHits.find(UID);
129 if (it != fHits.end())
133 if (pHit->GetTimeStamp() < it->second->GetTimeStamp())
136 slowHit = it->second;
138 fastHit = it->second;
142 fastHit->AddLinks(slowHit->GetLinks());
144 it->second = fastHit;
146 fHits.insert(make_pair(UID, pHit));
154 const TVector3& posHit,
155 const TVector3& posHitErr,
163 FairRootManager::Instance()->SetUseFairLinks(kTRUE);
164 pHit->SetTimeStamp(time);
165 pHit->AddLink(FairLink(0x1, pointIndex));
166 pHit->AddLink(FairLink(0x2, trackIndex));
167 pHit->AddLink(FairLink(0x4, detUID));
173 FairRootManager::Instance()->SetUseFairLinks(kFALSE);
184 out <<
"\n [BmnTof1HitProducerIdeal::Dump] ";
187 out <<
", size= " <<
aTofHits->GetEntriesFast();
191 TVector3 hitPos, pointPos;
193 TIterator* iter =
aTofHits->MakeIterator();
194 while ((pHit = (
BmnTofHit*)iter->Next())) {
195 pHit->Position(hitPos);
196 out <<
"\n hit detUID = " << pHit->GetDetectorID() <<
", hit pos(" << hitPos.X() <<
"," << hitPos.Y() <<
","
197 << hitPos.Z() <<
"), ";
200 point->Position(pointPos);
201 out <<
"\n point detUID = " << point->GetDetectorID() <<
", point pos(" << pointPos.X() <<
","
202 << pointPos.Y() <<
"," << pointPos.Z() <<
"), dev=" << (hitPos - pointPos).Mag();
void SetModule(Int_t mod)
void SetDetId(DetectorId det)
void SetStation(Short_t st)
void Dump(const char *comment=nullptr, std::ostream &out=std::cout) const
void AddHit(Int_t detUID, const TVector3 &posHit, const TVector3 &posHitErr, Int_t pointIndex, Int_t trackIndex, Double_t time, Int_t Idd)
virtual void Exec(Option_t *option)
TClonesArray * aExpDigits
<— MC input
TClonesArray * aTofHits
<— The T0 time is stored in 'BmnTrigInfo.' branch in Run9
BmnTof1HitProducerIdeal(const char *name="TOF1 Ideal HitProducer", Bool_t useMCdata=true, Int_t verbose=1, Bool_t DoTest=false, Bool_t DoMergeHits=false)
virtual InitStatus Init()
virtual ~BmnTof1HitProducerIdeal()
TClonesArray * aMcTracks
<— MC input