12#include <MicrosliceDescriptor.hpp>
15#include <FairRunOnline.h>
18#include <RtypesCore.h>
25#include <boost/math/special_functions/math_fwd.hpp>
45 auto modulepair = pair.second.find(moduleid);
46 auto histo = modulepair->second;
47 fillHisto(digi, pair.first, moduleid, histo);
52 auto modulepair = pair.second.find(moduleid);
53 auto histo = modulepair->second;
72 auto histo = pair->second.find(moduleid)->second;
73 histo->Fill(
static_cast<std::uint32_t
>(type));
81 auto histo = pair->second.find(moduleid)->second;
90 auto histo = pair->second.find(moduleid)->second;
102 auto histoBomPerRawRate = pairBomPerRawRate->second.find(moduleid)->second;
103 auto histoBomRate = pairBomRate->second.find(moduleid)->second;
104 auto histoRawRate = pairRawRate->second.find(moduleid)->second;
107 if (histoRawRate->GetBinContent(modifiedBin) != 0)
108 histoBomPerRawRate->SetBinContent(modifiedBin, histoBomRate->GetBinContent(modifiedBin)
109 / histoRawRate->GetBinContent(modifiedBin));
120 auto histo = pair->second.find(moduleid)->second;
122 histo->Fill(
static_cast<std::uint32_t
>(flag));
127 LOG(info) << Class_Name() <<
"::Finish() - ";
133 TFile* oldFile = gFile;
134 TDirectory* oldDir = gDirectory;
150 LOG(info) << Class_Name() <<
"::Finish() nHistos " << nhistos <<
" written to " <<
fOutfilename.data();
158 for (
auto modulepair : modulemap) {
166 fModuleOrientation.emplace(std::pair<std::uint32_t, std::uint8_t>(modulepair.first, parmoddigi->GetOrientation()));
167 fModuleNrRows.emplace(std::pair<std::uint32_t, std::uint8_t>(modulepair.first, parmoddigi->GetNofRows()));
168 fModuleNrColumns.emplace(std::pair<std::uint32_t, std::uint8_t>(modulepair.first, parmoddigi->GetNofColumns()));
174 if (FairRun::Instance()->IsA() == FairRunOnline::Class()) {
175 auto run =
static_cast<FairRunOnline*
>(FairRun::Instance());
181 TFile* oldFile = gFile;
182 TDirectory* oldDir = gDirectory;
197 std::string histoname =
"";
198 std::shared_ptr<TH1> newhisto =
nullptr;
203 auto nchannels = nrows * ncols;
206 histoname =
"ModuleId_" + std::to_string(moduleid) +
"-";
215 if (rotation % 2 == 0) {
216 newhisto = std::make_shared<TH2I>(histoname.data(), histoname.data(), ncols, -0.5, (ncols - 0.5), nrows, -0.5,
218 newhisto->SetXTitle(
"Pad column");
219 newhisto->SetYTitle(
"Pad row");
223 newhisto = std::make_shared<TH2I>(histoname.data(), histoname.data(), nrows, -0.5, (nrows - 0.5), ncols, -0.5,
225 newhisto->SetXTitle(
"Pad row");
226 newhisto->SetYTitle(
"Pad column");
233 newhisto = std::make_shared<TH1I>(histoname.data(), histoname.data(),
fSpadic->GetDynamicRange(), 0 - 0.5,
234 fSpadic->GetDynamicRange() - 0.5);
235 newhisto->SetXTitle(
"MaxAdc [ADC units]");
236 newhisto->SetYTitle(
"Counts");
239 newhisto = std::make_shared<TH1I>(histoname.data(), histoname.data(),
242 newhisto->SetXTitle(
"CbmTrdDigi eTriggerType");
243 newhisto->SetYTitle(
"Counts");
252 newhisto = std::make_shared<TH1I>(histoname.data(), histoname.data(), nchannels, -0.5, (nchannels - 0.5));
253 newhisto->SetXTitle(
"ChannelId");
254 newhisto->SetYTitle(
"Counts");
257 newhisto = std::make_shared<TH2I>(histoname.data(), histoname.data(), nchannels, -0.5, (nchannels - 0.5), 3500,
259 newhisto->SetXTitle(
"ChannelId");
260 newhisto->SetYTitle(
"#DeltaT(Digi(n)-Digi(n-1)) [ns]");
263 newhisto = std::make_shared<TH2I>(histoname.data(), histoname.data(), nchannels, -0.5, (nchannels - 0.5),
264 nchannels, -0.5, (nchannels - 0.5));
265 newhisto->SetXTitle(
"NT AddressChannel");
266 newhisto->SetYTitle(
"ST AddressChannel");
270 LOG(debug) << Class_Name() <<
"::CreateHisto() HistoDigi " <<
static_cast<size_t>(kHisto) <<
" Module " << moduleid
271 <<
" initialized as " << histoname.data();
281 std::string histoname =
"";
282 std::shared_ptr<TH1> newhisto =
nullptr;
287 auto nchannels = nrows * ncols;
289 histoname =
"ModuleId_" + std::to_string(moduleid) +
"-";
296 newhisto = std::make_shared<TH2I>(histoname.data(), histoname.data(), 32, -0.5, 31.5, 520, -260, 260);
297 newhisto->SetXTitle(
"ADC Sample [CC]");
298 newhisto->SetYTitle(
"ADC Value [a.u.]");
303 newhisto = std::make_shared<TH2I>(histoname.data(), histoname.data(), 42, -0.5, 41.5, 16, -0.5, 15.5);
304 newhisto->SetXTitle(
"ElinkId");
305 newhisto->SetYTitle(
"eLink-ChannelId");
308 newhisto = std::make_shared<TH1I>(histoname.data(), histoname.data(), 42, -0.5, 41.5);
309 newhisto->SetXTitle(
"ElinkId");
310 newhisto->SetYTitle(
"Counts");
313 newhisto = std::make_shared<TH1F>(histoname.data(), histoname.data(), 200, 0.0, 100.0);
314 newhisto->SetXTitle(
"ADC signal std. deviation [#sigma]");
315 newhisto->SetYTitle(
"Counts");
318 newhisto = std::make_shared<TH2I>(histoname.data(), histoname.data(), nchannels, -0.5, (nchannels - 0.5), 601,
320 newhisto->SetXTitle(
"ChannelId");
321 newhisto->SetYTitle(
"ADC Value(Sample-0) [a.u.]");
324 newhisto = std::make_shared<TH1I>(histoname.data(), histoname.data(),
327 newhisto->SetXTitle(
"Spadic::eTriggerType");
328 newhisto->SetYTitle(
"Counts");
331 newhisto = std::make_shared<TH1D>(histoname.data(), histoname.data(),
kTimeplotLenghtSeconds * 10 + 1, -0.05,
333 newhisto->SetXTitle(
"Time t [s]");
334 newhisto->SetYTitle(
"Rate [Hz]");
336 default:
return;
break;
338 LOG(debug) << Class_Name() <<
"::CreateHisto() HistoRaw " <<
static_cast<size_t>(kHisto) <<
" Module " << moduleid
339 <<
"initialized as " << histoname.data();
350 std::string histoname =
"";
351 std::shared_ptr<TH1> newhisto =
nullptr;
354 histoname =
"ModuleId_" + std::to_string(moduleid) +
"-";
360 newhisto = std::make_shared<TH1I>(histoname.data(), histoname.data(), nbins, -0.5, nbins - 0.5);
361 newhisto->SetXTitle(
"Info message type");
362 newhisto->SetYTitle(
"Counts");
375 auto nbins =
static_cast<std::uint32_t
>(fles::MicrosliceFlags::DataError) + 1;
376 newhisto = std::make_shared<TH1I>(histoname.data(), histoname.data(), nbins, -0.5, nbins - 0.5);
377 newhisto->SetXTitle(
"#muSlice info/error flags");
378 newhisto->SetYTitle(
"Counts");
379 newhisto->GetXaxis()->SetBinLabel((
static_cast<int>(fles::MicrosliceFlags::CrcValid) + 1),
"CrcValid");
380 newhisto->GetXaxis()->SetBinLabel((
static_cast<int>(fles::MicrosliceFlags::OverflowFlim) + 1),
"OverflowFlim");
381 newhisto->GetXaxis()->SetBinLabel((
static_cast<int>(fles::MicrosliceFlags::OverflowUser) + 1),
"OverflowUser");
382 newhisto->GetXaxis()->SetBinLabel((
static_cast<int>(fles::MicrosliceFlags::DataError) + 1),
"DataError");
388 newhisto = std::make_shared<TH1D>(histoname.data(), histoname.data(),
kTimeplotLenghtSeconds * 10 + 1, -0.05,
390 newhisto->SetXTitle(
"Time t [s]");
391 newhisto->SetYTitle(
"Rate [Hz]");
394 default:
return;
break;
396 LOG(debug) << Class_Name() <<
"::CreateHisto() HistoOther " <<
static_cast<size_t>(kHisto) <<
" Module " << moduleid
397 <<
"initialized as " << histoname.data();
421 std::shared_ptr<TH1> histo)
424 auto triggertype = triggerpair.first;
425 auto isMultihit = triggerpair.second;
433 histo->Fill(addresspair.second, addresspair.first);
443 histo->Fill(addresspair.second, addresspair.first);
449 histo->Fill(addresspair.second, addresspair.first);
483 histo->Fill(
static_cast<int>(triggertype));
489 default:
return;
break;
531 default:
return;
break;
538 for (
size_t isample = 0; isample < raw->
GetSamples()->
size(); isample++) {
539 histo->Fill(isample, raw->
GetSamples()->at(isample));
551 std::vector<size_t> channelsvec(nchannels, 0);
552 if (channelid > nchannels)
return 0;
553 channelsvec.at(channelid) = digi->
GetTime();
554 auto pair = std::make_pair(moduleid, channelsvec);
560 auto prevtime = modulevecpair->second.at(channelid);
561 modulevecpair->second.at(channelid) = digi->
GetTime();
562 auto dt = digi->
GetTime() - prevtime;
570 Double_t newDigiTime = digi->
GetTime();
576 for (
int iDigi = nTrdDigis - 1; iDigi > 0; --iDigi) {
579 Double_t refDigiTime = digiRef.
GetTime();
590 if (refDigiTime < newDigiTime - 500 )
break;
597 std::string histoname =
"";
619 std::string histoname =
"";
640 std::string histoname =
"";
655 std::string histoname = histo->GetName();
657 auto startpos = histoname.find_first_of(
"-");
661 auto length = histoname.find_first_of(
"_", startpos) - startpos;
662 auto histotype = histoname.substr(startpos, length);
669 std::uint32_t channelid)
674 auto nrows =
static_cast<std::uint32_t
>(
fModuleNrRows.find(moduleid)->second);
675 auto ncols =
static_cast<std::uint32_t
>(
fModuleNrColumns.find(moduleid)->second);
678 std::uint32_t rotatedid = doRotate ? (channelid * (-1) + (nrows * ncols) - 1) : channelid;
680 auto row = rotatedid / ncols;
681 auto col = rotatedid % ncols;
685 return std::make_pair(row, col);
688 return std::make_pair(col, row);
698 std::float_t dev = 0;
701 dev += (sample - mean) * (sample - mean);
710 switch (typemappair.first) {
712 for (
auto histopair : typemappair.second) {
713 histopair.second->Reset(
"ICESM");
720 switch (typemappair.first) {
724 for (
auto histopair : typemappair.second) {
725 histopair.second->Reset(
"ICESM");
ClassImp(CbmConverterManager)
Monitor class to monitor the data from the Trd unpacker algorithms.
static constexpr size_t size()
int32_t GetAddressModule() const
Getter module address in the experiment.
static std::pair< eTriggerType, bool > GetTriggerPair(const int32_t triggerValue)
Get the trigger combination, i.e. St or Nt and is multihit or not (true/false)
int32_t GetTriggerType() const
Channel trigger type. SPADIC specific see CbmTrdTriggerType.
int32_t GetAddressChannel() const
Getter read-out id.
double GetTime() const
Getter for physical time [ns]. Accounts for clock representation of each ASIC. In SPADIC case physica...
double GetCharge() const
Common purpose charge getter.
Describe TRD module ASIC settings (electronic gain, delays, etc)
Definition of chamber gain conversion for one TRD module.
Describe TRD module ASIC settings (electronic gain, delays, etc)
virtual const CbmTrdParMod * GetModulePar(Int_t detId) const
std::map< Int_t, CbmTrdParMod * > GetModuleMap()
Base class for storing raw information which comes from the Spadic v2.2 trough flib or from a tsa fil...
const std::vector< std::int16_t > * GetSamples() const
std::uint8_t GetChannelId() const
std::uint8_t GetNrSamples() const
std::uint8_t GetHitType() const
std::uint8_t GetElinkId() const
void Finish()
Actions at the end of the run, e.g. write histos to file if flag is set.
void FillHisto(Spadic::MsInfoType type, std::uint32_t moduleid)
Fill the given histo with the information on the info type.
static std::string getTypeName(eDigiHistos kHisto)
Get the Type Name for the given histo.
virtual ~CbmTrdUnpackMonitor()
Destroy the Cbm Trd Unpack Task object.
std::map< std::uint32_t, std::uint8_t > fModuleNrColumns
Map with the number of columns of the modules. Performance helper to not go through the extraction fr...
CbmTrdUnpackMonitor()
Create the Cbm Trd Unpack AlgoBase object.
void fillSamplesHisto(std::shared_ptr< TH1 > histo, CbmTrdRawMessageSpadic *raw)
Fill the passed histo with the samples as function of time.
std::vector< eDigiHistos > fActiveDigiHistos
Enums of Digi histos to be activated.
std::string getHistoName(eDigiHistos kHisto)
Get the Histo Name for the given histo.
void fillNtCorrHisto(std::shared_ptr< TH1 > histo, CbmTrdDigi *digi)
Fill the NeighborTrigger Checking Histogram.
eDigiHistos
Enum for the predefined digi histograms.
std::uint64_t fCurrentTimeplotStartNs
Variable which holds the start time in ns of the current time axis of plots which display a quantity ...
std::map< std::uint32_t, std::vector< size_t > > fLastDigiTimeMap
Map with the last digi time for each channel of a given module.
virtual void createHisto(eDigiHistos kHisto)
Create the actual TH1 shared_ptrs of the Digi histos.
std::vector< eRawHistos > fActiveRawHistos
Enums of Raw histos to be activated.
std::map< eDigiHistos, std::map< std::uint32_t, std::shared_ptr< TH1 > > > fDigiHistoMap
Digi histogram pointers stored in a map together with the module id.
std::pair< std::uint32_t, std::uint32_t > getRowAndCol(std::uint32_t moduleid, std::uint32_t channelid)
Get the row and column ids (potentially rotated chambers are adjusted to humand readable rotations)
void adjustTimeplots(std::uint64_t newtime)
Adjust the boundaries of all timeplots to contain newtime.
std::string getHistoType(std::shared_ptr< TH1 > histo)
Get the Histo Type, i.e. "Digi/Raw/Other", deduced from the histo name.
Bool_t Init(CbmTrdParSetDigi *digiParSet, CbmTrdParSetAsic *asicParSet=nullptr)
Init all required parameter informations.
std::map< std::uint32_t, std::uint8_t > fModuleOrientation
Map with the orientations of the modules. Performance helper to not go through the extraction from Pa...
std::map< eOtherHistos, std::map< std::uint32_t, std::shared_ptr< TH1 > > > fOtherHistoMap
Other histogram pointers stored in a map together with the module id.
std::map< eRawHistos, std::map< std::uint32_t, std::shared_ptr< TH1 > > > fRawHistoMap
Raw histogram pointers stored in a map together with the module id.
std::shared_ptr< CbmTrdSpadic > fSpadic
static const std::uint32_t kTimeplotLenghtSeconds
Constant which defines the lenght of the time axis in seconds of plots which display a quantity over ...
std::vector< eOtherHistos > fActiveOtherHistos
Enums of Raw histos to be activated.
std::vector< CbmTrdDigi > * fDigiOutputVec
Variable which holds a reference to the TRD digi output vector (for correlations)
virtual void fillHisto(CbmTrdDigi *digi, eDigiHistos kHisto, std::uint32_t moduleid, std::shared_ptr< TH1 > histo)
Fill the given histo with the information from the digi.
std::vector< std::uint32_t > fModuleIdsVec
Vector with the unique module Ids.
bool fDoWriteToFile
Flag whether to write histos to file or not, gets activated if a output filename gets set.
std::double_t getDeltaT(CbmTrdDigi *digi)
Get the time difference between this digi and the previous one from the channel of this digi.
void FillHistos(CbmTrdDigi *digi, CbmTrdRawMessageSpadic *raw=nullptr)
fill the stored digi histograms
eOtherHistos
Enum for the predefined other histograms.
eRawHistos
Enum for the predefined raw histograms.
THttpServer * fHistoServer
Pointer to the histogram server, in case we run the online monitoring, the pointer is automatically d...
std::float_t getSamplesStdDev(CbmTrdRawMessageSpadic *raw)
Extract the std deviation of all samples in the message.
size_t writeHistosToFile(std::map< histotype, std::map< std::uint32_t, std::shared_ptr< TH1 > > > *histomap, TFile *file)
void addHistoToMap(std::shared_ptr< TH1 > histo, std::map< histotype, std::map< std::uint32_t, std::shared_ptr< TH1 > > > *histomap, std::uint32_t moduleid, histotype kHisto)
std::map< std::uint32_t, std::uint8_t > fModuleNrRows
Map with the number of rows of the modules. Performance helper to not go through the extraction from ...
std::uint64_t fLastRawTime
Variable which holds the time in ns of the last processed raw message.
void resetTimeplots()
Reset the contents of all timeplots.
std::string fOutfilename
File name for the output file.
virtual void createHistos()
Create the actual TH1 shared_ptrs.
std::uint64_t fCurrentTimesliceStartTimeNs
Variable which holds the start time in ns of the current timeslice.
@ kUNU
Unused request. 100. .... .... .... cccc.
@ kChannelBufM
Channel buffer full and multihit from kEPO msg.
@ kChannelBuf
Channel buffer full from kEPO msg.
@ kNInfMsgs
Number of different info messages.
@ kBOM
Buffer overflow count. 11nn nnnn nnnn nnnn cccc.
@ kMIS
Missing request. 101. .... .... .... ....
@ kOrdFifoBuf
Multi-hit but ordering buffer full from kEPO msg.
@ kBUF
Buffer full. 011b b... .... .... cccc.
@ kMSB
Message build error. 010. .... .... .... cccc.
@ kNeigh
Neighbor trigger.
@ kSandN
Self and neighbor trigger at the same time.