19#include <FairRootManager.h>
22#include <TClonesArray.h>
23#include <TStopwatch.h>
30using std::setprecision;
37 : FairTask(
"CbmRichMCbmHitProducer")
40 , fHitError(0.6 / sqrt(12.))
43 fMappingFile(
"mRICH_Mapping_vert_20190318_elView.geo")
50 FairRootManager* manager = FairRootManager::Instance();
58 FairRootManager* manager = FairRootManager::Instance();
60 fCbmEvents =
dynamic_cast<TClonesArray*
>(manager->GetObject(
"CbmEvent"));
62 LOG(info) << GetName() <<
"::Init() CbmEvent NOT found \n";
65 LOG(info) << GetName() <<
"::Init() CbmEvent found";
72 fRichHits =
new TClonesArray(
"CbmRichHit");
73 manager->Register(
"RichHit",
"RICH",
fRichHits, IsOutputBranchPersistent(
"RichHit"));
83 fDenoiseCnn = std::make_unique<CbmRichMCbmDenoiseCnn>();
85 fDenoiseCnn->SetClassificationThreshold(fDenoiseCnnThreshold);
86 LOG(info) <<
"CbmRichMCbmHitProducer: Initialized CbmRichMCbmDenoiseCnn";
98 if (!file.is_open()) {
99 std::cout <<
"<CbmRichMCbmHitProducer::InitMapping>: Unable to open mapping file:" <<
fMappingFile.c_str()
105 while (getline(file, line)) {
107 istringstream iss(line);
108 vector<std::string> results(istream_iterator<string>{iss}, std::istream_iterator<string>());
109 if (results.size() != 8)
continue;
112 data.
fTrbId = stoi(results[0],
nullptr, 16);
114 data.
fX = stod(results[6]);
115 data.
fY = stod(results[7]);
142 for (Int_t iUnit = 0; iUnit < nUnits; iUnit++) {
149 std::stringstream logOut;
150 logOut << setw(20) << left << GetName() <<
"[";
151 logOut << fixed << setw(8) << setprecision(1) << right << timer.RealTime() * 1000. <<
" ms] ";
152 logOut <<
"TS " <<
fNofTs;
153 if (
fCbmEvents) logOut <<
", events " << nUnits;
155 logOut <<
", hits " <<
fRichHits->GetEntriesFast();
156 LOG(info) << logOut.str();
167 LOG(debug) <<
"CbmRichMCbmHitProducer CbmEvent mode. CbmEvent # " <<
event->GetNumber();
172 for (Int_t iDigi = 0; iDigi < nofDigis; iDigi++) {
176 LOG(debug) <<
"nofDigis: " << nofDigis <<
"\t\t "
194 fDenoiseCnnTime += timer.RealTime();
202 if (digi ==
nullptr)
return;
204 Int_t DiRICH_Add = (digi->
GetAddress() >> 16) & 0xFFFF;
205 if ((0x7901 <= DiRICH_Add && DiRICH_Add <= 0x7905) || (0x9991 <= DiRICH_Add && DiRICH_Add <= 0x9998)) {
215 if (data !=
nullptr) {
216 posPoint.SetXYZ(data->
fX, data->
fY, data->
fZ);
219 LOG(info) <<
"CbmRichMCbmHitProducer: No Node for 0x" << std::hex << digi->
GetAddress() << std::dec
220 <<
" found. Using ASCII File! ";
227 posPoint.SetXYZ(dataAscii.
fX, dataAscii.
fY, dataAscii.
fZ);
242 Int_t nofHits =
fRichHits->GetEntriesFast();
245 unsigned int addr = (((DiRICH_Addr >> 24) & 0xF) * 18 * 32) + (((DiRICH_Addr >> 20) & 0xF) * 2 * 32)
246 + (((DiRICH_Addr >> 16) & 0xF) * 32) + ((DiRICH_Addr & 0xFFFF) - 0x1);
276 std::cout << std::endl;
277 LOG(info) <<
"=====================================";
278 LOG(info) << GetName() <<
": Run summary";
279 LOG(info) <<
"Time slices : " <<
fNofTs;
281 LOG(info) <<
"Hits / TS : " << fixed << setprecision(2) <<
fTotalNofHits / Double_t(
fNofTs);
282 LOG(info) <<
"Time / TS : " << fixed << setprecision(2) << 1000. *
fTotalTime / Double_t(
fNofTs) <<
" ms";
285 LOG(info) <<
"Events / TS : " << fixed << setprecision(2) <<
fNofEvents / Double_t(
fNofTs);
289 LOG(info) <<
"Time / ev : " << fixed << setprecision(2) << 1000. *
fTotalTime / Double_t(
fNofEvents)
297 LOG(info) <<
"===== Time by task (real time) ======";
298 LOG(info) <<
"HitProducer / " << eventOrTsStr << fixed << setprecision(2) << setw(9) << right
303 LOG(info) <<
"Denoise NN / " << eventOrTsStr << fixed << setprecision(2) << setw(9) << right
304 << 1000. * fDenoiseCnnTime / eventOrTsValue <<
" ms [" << setw(5) << right
305 << 100 * fDenoiseCnnTime /
fTotalTime <<
" %]";
308 LOG(info) <<
"=====================================\n";
328 Double_t
x =
pos.X();
329 Double_t
y =
pos.Y();
338 if (
x >= -6.25 &&
x <= -1.05) {
340 if (
y >= 8 &&
y <= 15.9) {
344 else if (
x > -1.05 &&
x <= 4.25) {
346 if (
y >= 8 &&
y <= 13.2) {
356 Double_t
x =
pos.X();
357 Double_t
y =
pos.Y();
366 if (
x >= -16.85 &&
x <= 4.25) {
368 if (
y >= -23.8 &&
y <= 23.8) {
378 Double_t
x =
pos.X();
379 Double_t
y =
pos.Y();
389 if (
y > 13.5)
return false;
390 if (
y > 8.0 &&
x < 12.5)
return false;
399 filename += Form(
"_%u.data", iteration);
400 std::ifstream icd_file(filename);
401 unsigned int lineCnt = 0;
402 if (icd_file.is_open()) {
403 while (getline(icd_file, line)) {
404 if (line[0] ==
'#')
continue;
405 std::istringstream iss(line);
406 unsigned int addr = 0;
408 if (!(iss >> addr >> value)) {
409 LOG(info) <<
"A Problem accured in line " << lineCnt;
413 ICD_offsets.at(addr) += value;
416 LOG(info) <<
"Loaded inter channel delay file " << filename <<
" for RICH.";
419 LOG(info) <<
"Unable to open inter channel delay file " << filename;
ClassImp(CbmConverterManager)
@ kRich
Ring-Imaging Cherenkov Detector.
static Int_t GetNofDigis(ECbmModuleId systemId)
static Bool_t IsPresent(ECbmModuleId systemId)
Presence of a digi branch.
InitStatus Init()
Initialisation.
const Digi * Get(Int_t index) const
Get a digi object.
static CbmDigiManager * Instance()
Static instance.
Class characterising one event by a collection of links (indices) to data objects,...
void SetAddress(int32_t address)
void SetRefId(int32_t refId)
void SetTime(double time)
void SetPosition(const TVector3 &pos)
Sets position of the hit.
static CbmRichDigiMapManager & GetInstance()
Return Instance of CbmRichGeoManager.
CbmRichPixelData * GetPixelDataByAddress(Int_t address)
Return CbmRichDataPixel by digi address.
int32_t GetAddress() const
virtual void SetPmtId(int32_t det)
bool fRestrictToAerogelAccDec2019
virtual ~CbmRichMCbmHitProducer()
Destructor.
std::map< Int_t, CbmRichMCbmMappingData > fRichMapping
bool isInToT(const double ToT)
void read_ICD(std::array< Double_t, 2304 > &offsets, unsigned int iteration)
void ProcessDigi(CbmEvent *event, Int_t digiIndex)
bool RestrictToAcc(TVector3 &pos)
bool RestrictToAerogelAccDec2019(TVector3 &pos)
bool RestrictToFullAcc(TVector3 &pos)
std::string fIcdFilenameBase
void ProcessData(CbmEvent *event)
void AddHit(CbmEvent *event, TVector3 &posHit, const CbmRichDigi *digi, Int_t index, Int_t PmtId)
Add hit to the output array (and) CbmEvent if it is not NULL.
TClonesArray * fCbmEvents
CbmRichMCbmHitProducer()
Default constructor.
virtual void SetParContainers()
Inherited from FairTask.
virtual void Finish()
Inherited from FairTask.
virtual InitStatus Init()
Inherited from FairTask.
std::array< Double_t, 2304 > fICD_offset_read
virtual void Exec(Option_t *option)
Inherited from FairTask.
CbmDigiManager * fDigiMan