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, uint32_t moduleid);
161 template<
class histotype>
163 std::map<histotype, std::map<uint32_t, std::shared_ptr<TH1>>>* histomap, uint32_t moduleid,
170 auto histopair = std::make_pair(moduleid, histo);
173 auto histomapIt = histomap->find(kHisto);
174 if (histomapIt == histomap->end()) {
176 std::map<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>
196 bool checkIfHistoExists(THistotype etype, std::map<THistotype, std::map<uint32_t, std::shared_ptr<TH1>>>* histomap,
200 auto histotypemapIt = histomap->find(etype);
201 if (histotypemapIt == histomap->end())
return false;
204 auto histopair = histotypemapIt->second.find(moduleid);
205 if (histopair == histotypemapIt->second.end())
return false;
208 if (histopair->second !=
nullptr)
return true;
295 std::pair<uint32_t, uint32_t>
getRowAndCol(uint32_t moduleid, uint32_t channelid);
300 template<
class histotype>
301 size_t writeHistosToFile(std::map<histotype, std::map<uint32_t, std::shared_ptr<TH1>>>* histomap, TFile* file)
308 for (
auto typemappair : *histomap) {
309 for (
auto histopair : typemappair.second) {
312 std::string moduleidname = std::to_string(histopair.first);
313 if (
nullptr == gDirectory->Get(moduleidname.data())) gDirectory->mkdir(moduleidname.data());
314 gDirectory->cd(moduleidname.data());
317 std::string histotypename =
getTypeName(typemappair.first);
319 if (
nullptr == gDirectory->Get(histotypename.data())) gDirectory->mkdir(histotypename.data());
320 gDirectory->cd(histotypename.data());
323 LOG(debug) << Class_Name() <<
"::Finish() Write histo " << histopair.second->GetName() <<
" to file "
324 << file->GetName() <<
" in folder " << moduleidname.data() <<
"/" << histotypename.data();
325 histopair.second->Write();
345 std::map<eDigiHistos, std::map<uint32_t, std::shared_ptr<TH1>>>
fDigiHistoMap = {};
348 std::map<eRawHistos, std::map<uint32_t, std::shared_ptr<TH1>>>
fRawHistoMap = {};
351 std::map<eOtherHistos, std::map<uint32_t, std::shared_ptr<TH1>>>
fOtherHistoMap = {};
391 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...
std::pair< uint32_t, uint32_t > getRowAndCol(uint32_t moduleid, uint32_t channelid)
Get the row and column ids (potentially rotated chambers are adjusted to humand readable rotations)
void Finish()
Actions at the end of the run, e.g. write histos to file if flag is set.
bool checkIfHistoExists(THistotype etype, std::map< THistotype, std::map< uint32_t, std::shared_ptr< TH1 > > > *histomap, uint32_t moduleid)
static std::string getTypeName(eDigiHistos kHisto)
Get the Type Name for the given histo.
virtual ~CbmTrdUnpackMonitor()
Destroy the Cbm Trd Unpack Task object.
void SetCurrentTimesliceStartTime(uint64_t time)
Set the start time of the current timeslice in ns.
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::map< uint32_t, uint8_t > fModuleNrColumns
Map with the number of columns of the modules. Performance helper to not go through the extraction fr...
std::string getHistoName(eDigiHistos kHisto)
Get the Histo Name for the given histo.
void adjustTimeplots(uint64_t newtime)
Adjust the boundaries of all timeplots to contain newtime.
virtual void fillHisto(CbmTrdDigi *digi, eDigiHistos kHisto, uint32_t moduleid, std::shared_ptr< TH1 > histo)
Fill the given histo with the information from the digi.
void fillNtCorrHisto(std::shared_ptr< TH1 > histo, CbmTrdDigi *digi)
Fill the NeighborTrigger Checking Histogram.
eDigiHistos
Enum for the predefined digi histograms.
CbmTrdUnpackMonitor(const CbmTrdUnpackMonitor &)=delete
Copy constructor - not implemented.
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< uint32_t, std::vector< size_t > > fLastDigiTimeMap
Map with the last digi time for each channel of a given module.
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)
std::vector< uint32_t > fModuleIdsVec
Vector with the unique module Ids.
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.
uint64_t fCurrentTimesliceStartTimeNs
Variable which holds the start time in ns of the current timeslice.
static const uint32_t kTimeplotLenghtSeconds
Constant which defines the lenght of the time axis in seconds of plots which display a quantity over ...
static std::string getTypeName(eRawHistos kHisto)
Get the Type Name for the given histo.
std::shared_ptr< CbmTrdSpadic > fSpadic
void SetActiveHistos(std::vector< eDigiHistos > vec)
transfer the enums for the histos to be activated to the member vector
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)
uint64_t fCurrentTimeplotStartNs
Variable which holds the start time in ns of the current time axis of plots which display a quantity ...
std::map< eDigiHistos, std::map< uint32_t, std::shared_ptr< TH1 > > > fDigiHistoMap
Digi histogram pointers stored in a map together with the module id.
void SetActiveHistos(std::vector< eRawHistos > vec)
transfer the enums for the histos to be activated to the member vector
void FillHisto(Spadic::MsInfoType type, uint32_t moduleid)
Fill the given histo with the information on the info type.
std::map< uint32_t, uint8_t > fModuleNrRows
Map with the number of rows of the modules. Performance helper to not go through the extraction from ...
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.
std::map< uint32_t, uint8_t > fModuleOrientation
Map with the orientations of the modules. Performance helper to not go through the extraction from Pa...
void FillHistos(CbmTrdDigi *digi, CbmTrdRawMessageSpadic *raw=nullptr)
fill the stored digi histograms
eOtherHistos
Enum for the predefined other histograms.
std::map< eRawHistos, std::map< uint32_t, std::shared_ptr< TH1 > > > fRawHistoMap
Raw histogram pointers stored in a map together with the module id.
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.
void SetWriteToFile(std::string filename)
Set the output filename, automatically also sets the flag to create an output file.
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.
void addHistoToMap(std::shared_ptr< TH1 > histo, std::map< histotype, std::map< uint32_t, std::shared_ptr< TH1 > > > *histomap, uint32_t moduleid, histotype kHisto)
std::map< eOtherHistos, std::map< uint32_t, std::shared_ptr< TH1 > > > fOtherHistoMap
Other histogram pointers stored in a map together with the module id.
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.
size_t writeHistosToFile(std::map< histotype, std::map< uint32_t, std::shared_ptr< TH1 > > > *histomap, TFile *file)