21#ifndef CbmTrdUnpackMonitor_H
22#define CbmTrdUnpackMonitor_H
30#include <MicrosliceDescriptor.hpp>
31#include <Timeslice.hpp>
33#include <FairRunOnline.h>
38#include <RtypesCore.h>
41#include <THttpServer.h>
125 void FillHisto(fles::MicrosliceFlags flag, std::uint32_t moduleid);
161 template<
class histotype>
163 std::map<histotype, std::map<std::uint32_t, std::shared_ptr<TH1>>>* histomap,
164 std::uint32_t moduleid, histotype kHisto)
170 auto histopair = std::make_pair(moduleid, histo);
173 auto histomapIt = histomap->find(kHisto);
174 if (histomapIt == histomap->end()) {
176 std::map<std::uint32_t, std::shared_ptr<TH1>> newmap = {};
177 newmap.emplace(histopair);
179 auto pair = std::make_pair(kHisto, newmap);
181 histomap->emplace(pair);
185 histomapIt->second.emplace(histopair);
190 std::string directory = std::to_string(moduleid) +
"/" +
getHistoType(histo) +
"/";
195 template<
typename THistotype>
197 std::map<THistotype, std::map<std::uint32_t, std::shared_ptr<TH1>>>* histomap,
198 std::uint32_t moduleid)
201 auto histotypemapIt = histomap->find(etype);
202 if (histotypemapIt == histomap->end())
return false;
205 auto histopair = histotypemapIt->second.find(moduleid);
206 if (histopair == histotypemapIt->second.end())
return false;
209 if (histopair->second !=
nullptr)
return true;
296 std::pair<std::uint32_t, std::uint32_t>
getRowAndCol(std::uint32_t moduleid, std::uint32_t channelid);
301 template<
class histotype>
302 size_t writeHistosToFile(std::map<histotype, std::map<std::uint32_t, std::shared_ptr<TH1>>>* histomap, TFile* file)
309 for (
auto typemappair : *histomap) {
310 for (
auto histopair : typemappair.second) {
313 std::string moduleidname = std::to_string(histopair.first);
314 if (
nullptr == gDirectory->Get(moduleidname.data())) gDirectory->mkdir(moduleidname.data());
315 gDirectory->cd(moduleidname.data());
318 std::string histotypename =
getTypeName(typemappair.first);
320 if (
nullptr == gDirectory->Get(histotypename.data())) gDirectory->mkdir(histotypename.data());
321 gDirectory->cd(histotypename.data());
324 LOG(debug) << Class_Name() <<
"::Finish() Write histo " << histopair.second->GetName() <<
" to file "
325 << file->GetName() <<
" in folder " << moduleidname.data() <<
"/" << histotypename.data();
326 histopair.second->Write();
346 std::map<eDigiHistos, std::map<std::uint32_t, std::shared_ptr<TH1>>>
fDigiHistoMap = {};
349 std::map<eRawHistos, std::map<std::uint32_t, std::shared_ptr<TH1>>>
fRawHistoMap = {};
352 std::map<eOtherHistos, std::map<std::uint32_t, std::shared_ptr<TH1>>>
fOtherHistoMap = {};
392 std::shared_ptr<CbmTrdSpadic>
fSpadic =
nullptr;
Software representation of the SPADIC v2.2+.
Describe TRD module ASIC settings (electronic gain, delays, etc)
Base class for storing raw information which comes from the Spadic v2.2 trough flib or from a tsa fil...
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 ...
CbmTrdUnpackMonitor(const CbmTrdUnpackMonitor &)=delete
Copy constructor - not implemented.
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.
void SetDigiOutputVec(std::vector< CbmTrdDigi > *digiOutputVec)
Set digi outpout vector (to make it usable for correlations)
static std::string getTypeName(eOtherHistos kHisto)
Get the Type Name for the given histo.
void SetActiveHistos(std::vector< eOtherHistos > vec)
transfer the enums for the histos to be activated to the member vector
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.
static std::string getTypeName(eRawHistos kHisto)
Get the Type Name for the given histo.
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
void SetActiveHistos(std::vector< eDigiHistos > vec)
transfer the enums for the histos to be activated to the member vector
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.
void SetActiveHistos(std::vector< eRawHistos > vec)
transfer the enums for the histos to be activated to the member vector
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.
bool checkIfHistoExists(THistotype etype, std::map< THistotype, std::map< std::uint32_t, std::shared_ptr< TH1 > > > *histomap, std::uint32_t moduleid)
size_t writeHistosToFile(std::map< histotype, std::map< std::uint32_t, std::shared_ptr< TH1 > > > *histomap, TFile *file)
void SetWriteToFile(std::string filename)
Set the output filename, automatically also sets the flag to create an output 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 ...
void SetCurrentTimesliceStartTime(std::uint64_t time)
Set the start time of the current timeslice in ns.
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.
CbmTrdUnpackMonitor & operator=(const CbmTrdUnpackMonitor &)=delete
Assignment operator - not implemented.
void SetSpadicObject(std::shared_ptr< CbmTrdSpadic > value)
Set the Spadic Object.
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.