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 (DiRICH_Add == 0x7901 || DiRICH_Add == 0x7902)
return;
211 if (data !=
nullptr) {
212 posPoint.SetXYZ(data->
fX, data->
fY, data->
fZ);
215 LOG(info) <<
"CbmRichMCbmHitProducer: No Node for 0x" << std::hex << digi->
GetAddress() << std::dec
216 <<
" found. Using ASCII File! ";
223 posPoint.SetXYZ(dataAscii.
fX, dataAscii.
fY, dataAscii.
fZ);
238 Int_t nofHits =
fRichHits->GetEntriesFast();
241 unsigned int addr = (((DiRICH_Addr >> 24) & 0xF) * 18 * 32) + (((DiRICH_Addr >> 20) & 0xF) * 2 * 32)
242 + (((DiRICH_Addr >> 16) & 0xF) * 32) + ((DiRICH_Addr & 0xFFFF) - 0x1);
272 std::cout << std::endl;
273 LOG(info) <<
"=====================================";
274 LOG(info) << GetName() <<
": Run summary";
275 LOG(info) <<
"Time slices : " <<
fNofTs;
277 LOG(info) <<
"Hits / TS : " << fixed << setprecision(2) <<
fTotalNofHits / Double_t(
fNofTs);
278 LOG(info) <<
"Time / TS : " << fixed << setprecision(2) << 1000. *
fTotalTime / Double_t(
fNofTs) <<
" ms";
281 LOG(info) <<
"Events / TS : " << fixed << setprecision(2) <<
fNofEvents / Double_t(
fNofTs);
285 LOG(info) <<
"Time / ev : " << fixed << setprecision(2) << 1000. *
fTotalTime / Double_t(
fNofEvents)
293 LOG(info) <<
"===== Time by task (real time) ======";
294 LOG(info) <<
"HitProducer / " << eventOrTsStr << fixed << setprecision(2) << setw(9) << right
299 LOG(info) <<
"Denoise NN / " << eventOrTsStr << fixed << setprecision(2) << setw(9) << right
300 << 1000. * fDenoiseCnnTime / eventOrTsValue <<
" ms [" << setw(5) << right
301 << 100 * fDenoiseCnnTime /
fTotalTime <<
" %]";
304 LOG(info) <<
"=====================================\n";
324 Double_t
x =
pos.X();
325 Double_t
y =
pos.Y();
334 if (
x >= -6.25 &&
x <= -1.05) {
336 if (
y >= 8 &&
y <= 15.9) {
340 else if (
x > -1.05 &&
x <= 4.25) {
342 if (
y >= 8 &&
y <= 13.2) {
352 Double_t
x =
pos.X();
353 Double_t
y =
pos.Y();
362 if (
x >= -16.85 &&
x <= 4.25) {
364 if (
y >= -23.8 &&
y <= 23.8) {
374 Double_t
x =
pos.X();
375 Double_t
y =
pos.Y();
385 if (
y > 13.5)
return false;
386 if (
y > 8.0 &&
x < 12.5)
return false;
395 filename += Form(
"_%u.data", iteration);
396 std::ifstream icd_file(filename);
397 unsigned int lineCnt = 0;
398 if (icd_file.is_open()) {
399 while (getline(icd_file, line)) {
400 if (line[0] ==
'#')
continue;
401 std::istringstream iss(line);
402 unsigned int addr = 0;
404 if (!(iss >> addr >> value)) {
405 LOG(info) <<
"A Problem accured in line " << lineCnt;
409 ICD_offsets.at(addr) += value;
412 LOG(info) <<
"Loaded inter channel delay file " << filename <<
" for RICH.";
415 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