25#include <FairRootManager.h>
26#include <FairRunAna.h>
27#include <FairRuntimeDb.h>
30#include <RtypesCore.h>
32#include <TClonesArray.h>
33#include <TGeoPhysicalNode.h>
34#include <TStopwatch.h>
45using std::setprecision;
47using std::stringstream;
86 const int NDIGICHUNK = 1000;
89 if (ndigis == 0)
return 0;
92 for (
size_t idigi(0); idigi < ndigis; idigi++) {
109 if (ndigis == 0)
return 0;
110 for (
size_t idigi = 0; idigi < ndigis; idigi++) {
127 std::map<Int_t, CbmTrdModuleRec*>::iterator imod =
fModules.find(moduleAddress);
140 Int_t digiCounter(0), clsCounter(0);
141 for (std::map<Int_t, CbmTrdModuleRec*>::iterator imod =
fModules.begin(); imod !=
fModules.end(); imod++) {
149 for (std::map<Int_t, CbmTrdModuleRec*>::iterator imod =
fModules.begin(); imod !=
fModules.end(); imod++)
150 imod->second->Clear(
"cls");
156 LOG(info) << GetName() <<
"::Exec : Digis : " << ndigis <<
" / " << digiCounter <<
" above threshold ("
158 LOG(info) << GetName() <<
"::Exec : Clusters : " << clsCounter;
168 module = fModules[address] = new CbmTrdModuleRec2D(address);
170 module = fModules[address] = new CbmTrdModuleRecR(address);
171 LOG(debug) << GetName() <<
"::AddModule : " <<
module->GetName();
176 LOG(fatal) << GetName() <<
"::AddModule : No Geo params for module " << address <<
". Using default.";
179 module->SetGeoPar(pGeo);
184 LOG(warn) << GetName() <<
"::AddModule : No Read-Out params for modAddress " << address <<
". Using default.";
187 module->SetDigiPar(pDigi);
192 LOG(warn) << GetName() <<
"::AddModule : No ASIC params for modAddress " << address <<
". Using default.";
196 module->SetAsicPar(pAsic);
201 LOG(warn) << GetName() <<
"::AddModule : No Gas params for modAddress " << address <<
". Using default.";
204 module->SetChmbPar(pChmb);
213 module->SetGainPar(pGain);
221 FairRuntimeDb* rtdb = FairRunAna::Instance()->GetRuntimeDb();
236 FairRootManager* ioman = FairRootManager::Instance();
238 fClusters =
new TClonesArray(
"CbmTrdCluster", 100);
239 ioman->Register(
"TrdCluster",
"TRD",
fClusters, IsOutputBranchPersistent(
"TrdCluster"));
245 fEvents =
dynamic_cast<TClonesArray*
>(ioman->GetObject(
"CbmEvent"));
246 bool digiEvent(
false);
251 LOG(info) << GetName() <<
": Event trigger " << (
fEvents ?
"found" :
"miss") <<
"; digi organized "
252 << (digiEvent ?
"EbyE" :
"Timebased") <<
".";
257 LOG(warn) << GetName()
258 <<
": Event mode selected but no CbmEvent branch found ! Processing all digi from the list.";
264 LOG(warn) << GetName()
265 <<
": CbmEvent branch found but full digi stream asked by user ! Processing all digi from the list.";
271 LOG(warn) << GetName() <<
": Timebased mode selected but digi EbyE ! Processing digi from event (simulation EbyE).";
295 LOG(info) <<
"================ TRD Cluster Finder ===============";
296 LOG(info) <<
" Free streaming : " << (
IsTimeBased() ?
"yes" :
"no");
297 LOG(info) <<
" Multi hit detect : " << (
HasMultiHit() ?
"yes" :
"no");
298 LOG(info) <<
" Row merger : " << (
HasRowMerger() ?
"yes" :
"no");
299 LOG(info) <<
" c-Neighbour enable : " << (
HasNeighbourCol() ?
"yes" :
"no");
300 LOG(info) <<
" r-Neighbour enable : " << (
HasNeighbourRow() ?
"yes" :
"no");
301 LOG(info) <<
" Write clusters : " << (
HasDumpClusters() ?
"yes" :
"no");
329 Long64_t nDigisUsed = 0;
334 for (
auto eventobj : *
fEvents) {
336 auto event =
static_cast<CbmEvent*
>(eventobj);
341 nDigisUsed += nDigis;
344 LOG(info) << GetName() <<
"::Exec : Event Nr: " <<
fNrEvents;
345 LOG(info) << GetName() <<
"::Exec : real time=" << timer.RealTime() <<
" CPU time=" << timer.CpuTime();
360 LOG(info) << GetName() <<
"::Exec : Event Nr: " <<
fNrEvents;
361 LOG(info) << GetName() <<
"::Exec : real time=" << timer.RealTime() <<
" CPU time=" << timer.CpuTime();
369 logOut << setw(20) << left << GetName() <<
" [";
370 logOut << fixed << setw(8) << setprecision(1) << right << timerTs.RealTime() * 1000. <<
" ms] ";
371 logOut <<
"TS " <<
fNrTs;
373 logOut <<
", digis " << nDigisUsed <<
" / " << nDigisAll <<
" clusters "
375 LOG(info) << logOut.str();
382 if (!clusters)
return 0;
387 Int_t ncl(
fClusters->GetEntriesFast()), mcl(0), ncols(0);
389 for (Int_t ic(0); ic < clusters->GetEntriesFast(); ic++) {
392 if (!cls->HasFaspDigis()) {
396 LOG(error) <<
"CbmTrdClusterFinder::AddClusters : Can't find "
397 "ParModDigi for address"
398 << cls->GetAddress();
405 for (Int_t
id = 0;
id < cls->GetNofDigis();
id++) {
408 Int_t colId = digiChannel % ncols;
409 Int_t globalRow = digiChannel / ncols;
411 Int_t combiId = globalRow * ncols + colId;
412 cols.SetBitNumber(combiId);
413 rows.SetBitNumber(globalRow);
416 cls->SetNCols(cols.CountBits());
417 cls->SetNRows(rows.CountBits());
424 if (cls->GetMatch() != NULL)
435 std::cout << std::endl;
436 LOG(info) <<
"=====================================";
437 LOG(info) << GetName() <<
": Finish run";
438 LOG(info) << GetName() <<
": Run summary ";
439 LOG(info) << GetName() <<
": Processing time : " << std::fixed << std::setprecision(3) <<
fProcessTime;
440 LOG(info) << GetName() <<
": Nr of events : " <<
fNrEvents;
441 LOG(info) << GetName() <<
": Nr of input digis : " <<
fNrDigis;
442 LOG(info) << GetName() <<
": Nr of produced clusters : " <<
fNrClusters;
443 LOG(info) << GetName() <<
": Nr of clusters / event : " << std::fixed << std::setprecision(2)
445 LOG(info) << GetName() <<
": Nr of digis / cluster : " << std::fixed << std::setprecision(2)
447 LOG(info) <<
"=====================================";
448 std::cout << std::endl;
ClassImp(CbmConverterManager)
@ kTrd
Transition Radiation Detector.
FairTask to produce TrdCluster objects from TrdHit objects.
Data Container for TRD clusters.
Helper class to extract information from the GeoManager.
static Int_t GetNofDigis(ECbmModuleId systemId)
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,...
Bookkeeping of time-slice content.
static void SetUseOnlyEventDigis(Bool_t set=kTRUE)
Set the Use Only Event Digis Per default this is activated on construction, such that the user can tu...
static void SetTimeBased(Bool_t set=kTRUE)
TClonesArray * fEvents
Array connected to the CbmEvent branch.
std::map< Int_t, CbmTrdModuleRec * > fModules
list of modules being processed
CbmTrdParSetGas * fGasPar
parameter list for HV status
static Bool_t HasDumpClusters()
static Int_t fgConfig
Configuration map for the clusterizer. See CbmTrdRecDef for details.
UInt_t fNrDigis
Number of digis as input for the hit production.
virtual void SetParContainers()
virtual InitStatus Init()
static Bool_t HasNeighbourCol()
Bool_t AddCluster(CbmTrdCluster *c)
Save one finished cluster to the output.
CbmTrdParSetDigi * fDigiPar
parameter list for read-out geometry
CbmTrdClusterFinder()
Default constructor.
static Bool_t HasRowMerger()
UInt_t fNrTs
Number of processed time slices.
~CbmTrdClusterFinder()
Default destructor.
CbmTrdModuleRec * AddModule(const CbmTrdDigi *digi)
Adds the module corresponding to the address of the passed digi to the ModuleMap (fModules)
virtual void Exec(Option_t *option)
Executed task.
UInt_t fNrClusters
Number of produced clusters.
CbmTrdParSetGeo * fGeoPar
parameter list for modules geometry
static Bool_t HasNeighbourRow()
static Bool_t UseOnlyEventDigis()
If true only digis connected ro a CbmEvent are processed Per default this is activated on constructio...
CbmTrdParSetGain * fGainPar
parameter list for keV->ADC gain conversion
void processDigisInModules(UInt_t ndigis, CbmEvent *event=nullptr, bool clr=true)
Call the clusterizer function of each module.
static Bool_t HasMultiHit()
static Bool_t IsTimeBased()
UInt_t addDigisToModules()
Add all digis available from CbmDigiManager to the corresponding modules.
static Float_t fgMinimumChargeTH
Int_t AddClusters(TClonesArray *clusters, CbmEvent *event, Bool_t moveOwner=kTRUE)
void addDigiToModule(UInt_t digiIdx)
Add the digi in the TrdDigi branch at the passed digiIdx to its corresponding module.
CbmTrdParSetAsic * fAsicPar
parameter list for ASIC characterization
UInt_t fNrEvents
Number of processed events (without CbmEvent corresponds to nr of exec calls)
Float_t fProcessTime
Total processing time [RealTime].
static Bool_t DoDebugPrintouts()
Data Container for TRD clusters.
void SetFaspDigis(bool set=true)
int32_t GetAddressModule() const
Getter module address in the experiment.
int32_t GetAddressChannel() const
Getter read-out id.
eCbmTrdAsicType GetType() const
Channel FEE SPADIC/FASP according to CbmTrdAsicType.
Abstract class for module wise cluster finding and hit reconstruction.
virtual Int_t GetOverThreshold() const
virtual TClonesArray * GetClusters()
virtual Bool_t AddDigi(const CbmTrdDigi *, Int_t)
Add digi to local module.
virtual Int_t FindClusters(bool clr=true)=0
Steering routine for finding digits clusters.
Describe TRD module ASIC settings (electronic gain, delays, etc)
Definition of chamber gain conversion for one TRD module.
Int_t GetNofColumns() const
Definition of gain parameters for one TRD module.
Definition of gas parameters for one TRD module.
Definition of geometry for one TRD module.
Describe TRD module ASIC settings (electronic gain, delays, etc)
Describe TRD module working settings (HV, etc)
virtual const CbmTrdParMod * GetModulePar(Int_t detId) const