10#include <MicrosliceDescriptor.hpp>
13#include <FairRunOnline.h>
16#include <RtypesCore.h>
23#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);
54 LOG(info) << Class_Name() <<
"::Finish() - ";
60 TFile* oldFile = gFile;
61 TDirectory* oldDir = gDirectory;
76 LOG(info) << Class_Name() <<
"::Finish() nHistos " << nhistos <<
" written to " <<
fOutfilename.data();
87 if (FairRun::Instance()->IsA() == FairRunOnline::Class()) {
88 auto run =
static_cast<FairRunOnline*
>(FairRun::Instance());
96 size_t nchs = std::get<0>((*it).second).size();
104 TFile* oldFile = gFile;
105 TDirectory* oldDir = gDirectory;
120 int ncol(-1), modAddress(-1);
121 std::shared_ptr<TH1> histo =
nullptr;
123 std::vector<int> faspAddress;
124 for (
int idet(0); idet < set->GetNrOfModules(); idet++) {
129 for (
auto address : faspAddress) {
132 if (modAddress != address / 1000) {
133 modAddress = address / 1000;
135 if (modpair.find(modAddress) == modpair.end())
continue;
136 if (!(histo = modpair[modAddress]))
continue;
141 for (
int ich(0); ich <
NFASPCH; ich++) {
143 int pad = fasp->
GetPadAddress(ich), row = pad / ncol, col = pad % ncol;
155 LOG(warning) << Class_Name() <<
"::addParam(CbmTrdParSetAsic*) Module " << madd <<
" not in the list ! Skip.";
160 std::vector<Int_t> add;
162 for (
auto afasp : add) {
165 int faspid(afasp % 1000), ich(faspid * 100);
167 chToFaspMapping[ach] = ich;
171 std::get<0>((*moduleDef).second) = chToFaspMapping;
181 LOG(warning) << Class_Name() <<
"::addParam(CbmTrdParModDigi*) Module " << madd
182 <<
" already loaded ! Replacing pad-plane definition.";
184 std::get<2>((*moduleDef).second) = pp->
GetNofRows();
191 std::string histoname =
"";
192 std::shared_ptr<TH1> newhisto =
nullptr;
195 auto modId = moduleDef.first;
196 auto ncols = std::get<1>(moduleDef.second);
197 auto nrows = std::get<2>(moduleDef.second);
198 auto nchs = nrows * ncols;
203 newhisto = std::make_shared<TH2I>(histoname.data(), Form(
"%s %d", histoname.data(), modId), 2 * ncols, -0.5,
204 (ncols - 0.5), nrows, -0.5, (nrows - 0.5));
205 newhisto->SetXTitle(
"COL (pad)");
206 newhisto->SetYTitle(
"ROW (pad)");
207 newhisto->SetZTitle(
"Yield");
212 newhisto = std::make_shared<TH2I>(histoname.data(), Form(
"%s %d", histoname.data(), modId), 2 * ncols, -0.5,
213 (ncols - 0.5), nrows, -0.5, (nrows - 0.5));
214 newhisto->SetXTitle(
"COL (pad)");
215 newhisto->SetYTitle(
"ROW (pad)");
216 newhisto->SetZTitle(
"Mask");
220 newhisto = std::make_shared<TH2I>(histoname.data(), Form(
"%s %d", histoname.data(), modId), 2 * nchs, -0.5,
221 (nchs - 0.5), 4095, 0.5, 4095.5);
222 newhisto->SetXTitle(
"Pad-Id");
223 newhisto->SetYTitle(
"Sgn [ADU]");
224 newhisto->SetZTitle(
"Yield");
227 newhisto = std::make_shared<TH2I>(histoname.data(), Form(
"%s %d", histoname.data(), modId),
NFASPMOD, -0.5,
229 newhisto->SetXTitle(
"FASP-Id");
230 newhisto->SetYTitle(
"FASP-Ch");
231 newhisto->SetZTitle(
"Yield");
234 const int npointsDecade = 40;
235 const int nb = 6 * npointsDecade;
236 double xa[nb + 1], base = std::pow(10, 1. / npointsDecade);
237 for (
int i(-2 * npointsDecade), j(0); i <= 4 * npointsDecade; i++, j++)
238 xa[j] = std::pow(base, i);
239 newhisto = std::make_shared<TH2I>(histoname.data(), Form(
"%s %d", histoname.data(), modId), 2 * nchs, -0.5,
240 (nchs - 0.5), nb, xa);
241 newhisto->SetXTitle(
"Pad-Id");
242 newhisto->SetYTitle(
"Rate_{SGN} [kHz]");
243 newhisto->SetZTitle(
"Yield");
248 LOG(debug) << Class_Name() <<
"::CreateHisto() HistoDigi " <<
static_cast<size_t>(kHisto) <<
" Module " << modId
249 <<
" initialized as " << histoname.data();
258 std::shared_ptr<TH1> histo)
261 int pad = d->
GetAddressChannel(), ncol = std::get<1>(modDef), row = pad / ncol, col = pad % ncol, dtime,
262 cht = 2 * pad, chr = cht + 1;
266 if (t > 0) histo->Fill(col - 0.25, row);
267 if (r > 0) histo->Fill(col + 0.25, row);
271 if (t > 0) histo->Fill(pad - 0.25, t);
272 if (r > 0) histo->Fill(pad + 0.25, r);
276 int fasp, faspid = -1, faspch = -1;
278 if ((fasp = std::get<0>(modDef).at(cht)) < 0) {
279 LOG(debug) << Class_Name() <<
"::fillHisto() Missing FASP params for pad-T " << pad;
284 histo->Fill(faspid, faspch);
289 if ((fasp = std::get<0>(modDef).at(chr)) < 0) {
290 LOG(debug) << Class_Name() <<
"::fillHisto() Missing FASP params for pad-R " << pad;
295 histo->Fill(faspid, faspch);
315 int ncol = std::get<1>(modDef), nrow = std::get<2>(modDef), nchs = 2 * ncol * nrow;
316 std::vector<size_t> channelsvec(nchs, 0);
318 if (ch > nchs)
return 0;
319 channelsvec.at(ch) = daqt;
320 auto pair = std::make_pair(modid, channelsvec);
325 auto prevtime = modulevecpair->second.at(ch);
326 modulevecpair->second.at(ch) = daqt;
327 auto dt = daqt - prevtime;
ClassImp(CbmConverterManager)
Monitor class for the unpacker algorithms (CbmTrdUnpackFasp) of FASP data.
int32_t GetAddressModule() const
Getter module address in the experiment.
uint64_t GetTimeDAQ() const
Getter for global DAQ time [clk]. Differs for each ASIC. In FASP case DAQ time is already stored in f...
int32_t GetAddressChannel() const
Getter read-out id.
double GetCharge() const
Common purpose charge getter.
virtual std::vector< Int_t > GetChannelAddresses() const
Definition of FASP channel calibration container.
Bool_t HasPairingR() const
Query pad pairing type.
Definition of FASP parameters.
const CbmTrdParFaspChannel * GetChannel(Int_t pad_address, UChar_t pair) const
Query the calibration for one FASP RO channel.
int GetPadAddress(Int_t ich) const
Describe TRD module ASIC settings (electronic gain, delays, etc)
virtual void GetAsicAddresses(std::vector< Int_t > *a) const
Query the ASICs in the module for their DAQ address. It applies to the list of ASICs....
virtual CbmTrdDigi::eCbmTrdAsicType GetAsicType() const
Query the type of ASICs in the list.
virtual const CbmTrdParAsic * GetAsicPar(Int_t address) const
Look for the ASIC parameters of a given DAQ id It applies to the list of ASICs.
Definition of chamber gain conversion for one TRD module.
Int_t GetNofColumns() const
Describe TRD module ASIC settings (electronic gain, delays, etc)
virtual ~CbmTrdUnpackFaspMonitor()
Destroy the Cbm Trd Unpack Task object.
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. Reimplement from CbmTrdUnpackMonitor.
const double fFaspInvClk
save 1/clk for the FASP FEE in kHz
CbmTrdUnpackFaspMonitor()
Create the Cbm Trd Unpack AlgoBase object.
void MapMaskedChannels(const CbmTrdParSetAsic *asics)
Special call for monitoring the masked channel map.
void FillHistos(CbmTrdDigi *digi)
fill the stored digi histograms
std::map< uint32_t, std::tuple< std::vector< int32_t >, uint8_t, uint8_t > > fModuleDef
Map of definitions for each module under monitoring : std::get<0> : pad to FASP channel mapping std::...
void Finish()
Actions at the end of the run, e.g. write histos to file if flag is set.
void createHisto(eDigiHistos kHisto)
Create the actual TH1 shared_ptrs of the Digi histos.
Bool_t Init()
Init all required parameter informations.
virtual std::uint64_t getDeltaT(uint32_t modid, int32_t ch=-1, uint64_t daqt=0)
Paralell implementation of the omonime function from CbmTrdUnpackMonitor for the case of FASP digis....
void addParam(uint32_t madd, const CbmTrdParModAsic *asics)
Init module and link asics properties.
static std::string getTypeName(eDigiHistos kHisto)
Get the Type Name for the given histo.
std::string getHistoName(eDigiHistos kHisto)
Get the Histo Name for the given histo.
eDigiHistos
Enum for the predefined digi histograms.
std::map< std::uint32_t, std::vector< size_t > > fLastDigiTimeMap
Map with the last digi time for each channel of a given module.
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::map< eRawHistos, std::map< std::uint32_t, std::shared_ptr< TH1 > > > fRawHistoMap
Raw histogram pointers stored in a map together with the module id.
bool fDoWriteToFile
Flag whether to write histos to file or not, gets activated if a output filename gets set.
THttpServer * fHistoServer
Pointer to the histogram server, in case we run the online monitoring, the pointer is automatically d...
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::string fOutfilename
File name for the output file.
virtual void createHistos()
Create the actual TH1 shared_ptrs.