27#include <FairRootManager.h>
28#include <FairRunAna.h>
29#include <FairRuntimeDb.h>
32#include <TGeoManager.h>
33#include <TGeoPhysicalNode.h>
34#include <TStopwatch.h>
44using std::setprecision;
46using std::stringstream;
73 std::uint32_t numModuleHits =
hits->GetEntriesFast();
74 if (!numModuleHits)
return 0;
78 if (nHitsEv > 0) nHitsTs += nHitsEv;
79 for (std::uint32_t iHit = 0; iHit < numModuleHits; ++iHit)
93 if (moduleAddress != address) {
94 LOG(error) <<
"CbmTrdHitProducer::AddModule: Module ID " << address <<
" does not match geometry definition "
95 << moduleAddress <<
". Module init failed!";
101 LOG(error) << GetName() <<
"::AddModule : No Read-Out params for module " << address <<
" @ " << pg->GetTitle()
102 <<
". Module init failed!";
111 trd2d = (moduleType >= 9);
112 LOG(info) << GetName() <<
"::AddModule(" << pg->GetName() <<
" " << (trd2d ?
'2' :
'1') <<
"D] mod[" << moduleAddress
113 <<
"] ly[" << lyId <<
"] det[" << moduleAddress <<
"]";
117 module = fModules[address] = new CbmTrdModuleRec2D(address);
122 module = fModules[address] = new CbmTrdModuleRecR(address);
126 module->SetGeoPar(pg);
127 module->SetDigiPar(pDigi);
132 LOG(warn) << GetName() <<
"::AddModule : No ASIC params for modAddress " << address <<
". Using default.";
136 module->SetAsicPar(pAsic);
141 LOG(warn) << GetName() <<
"::AddModule : No Gas params for modAddress " << address <<
". Using default.";
144 module->SetChmbPar(pChmb);
153 module->SetGainPar(pGain);
162 Int_t nclusters =
fClusters->GetEntriesFast();
164 for (Int_t icluster = 0; icluster < nclusters; icluster++) {
169 LOG(info) << GetName() <<
"::processClusters: "
170 <<
" Clusters : " << nclusters;
171 LOG(info) << GetName() <<
"::processClusters: "
172 <<
" Hits : " << nhits;
182 for (Int_t icluster = 0; icluster < nclusters; icluster++) {
189 LOG(info) << GetName() <<
"::processClusters: "
190 <<
" Clusters : " << nclusters;
191 LOG(info) << GetName() <<
"::processClusters: "
192 <<
" Hits : " << nhits;
202 if (!cluster)
return;
205 auto imod =
fModules.find(cluster->GetAddress());
206 auto mod = imod->second;
208 std::vector<const CbmTrdDigi*> digivec = {};
211 for (Int_t iDigi = 0; iDigi < cluster->GetNofDigis(); iDigi++) {
215 digivec.emplace_back(digi);
217 mod->MakeHit(clusterIdx, cluster, &digivec);
226 for (std::map<Int_t, CbmTrdModuleRec*>::iterator imod =
fModules.begin(); imod !=
fModules.end(); imod++) {
227 auto mod = imod->second;
228 mod->PreProcessHits();
229 mod->PostProcessHits();
241 FairRootManager* ioman = FairRootManager::Instance();
243 LOG(error) << GetName() <<
"::Init: "
244 <<
"ROOT manager is not instantiated!";
251 fClusters = (TClonesArray*) ioman->GetObject(
"TrdCluster");
253 LOG(error) << GetName() <<
"::Init: "
254 <<
"no TrdCluster array!";
258 fHits =
new TClonesArray(
"CbmTrdHit", 100);
259 ioman->Register(
"TrdHit",
"TRD",
fHits, IsOutputBranchPersistent(
"TrdHit"));
263 fEvents =
dynamic_cast<TClonesArray*
>(ioman->GetObject(
"CbmEvent"));
273 LOG(error) << GetName() <<
"::Init: "
274 <<
"GEO info for modules unavailable !";
280 if (nrModules != nrNodes)
281 LOG(fatal) <<
"CbmTrdHitProducer::Init() - Geometry(" << nrNodes <<
") and parameter files(" << nrModules
282 <<
") have different number of modules.";
283 for (Int_t loop = 0; loop < nrModules; ++loop) {
300 Long64_t nClusters =
fClusters->GetEntriesFast();
305 for (
auto eventobj : *
fEvents) {
307 auto event =
static_cast<CbmEvent*
>(eventobj);
308 if (!event)
continue;
314 LOG(info) << GetName() <<
"::Exec : Event Nr: " <<
fNrEvents;
315 LOG(info) << GetName() <<
"::Exec : real time=" << timer.RealTime() <<
" CPU time=" << timer.CpuTime();
328 LOG(info) << GetName() <<
"::Exec : Event Nr: " <<
fNrEvents;
329 LOG(info) << GetName() <<
"::Exec : real time=" << timer.RealTime() <<
" CPU time=" << timer.CpuTime();
339 LOG(info) << GetName() <<
"::Exec: real time=" << timer.RealTime() <<
" CPU time=" << timer.CpuTime();
343 logOut << setw(20) << left << GetName() <<
" [";
344 logOut << fixed << setw(8) << setprecision(1) << right << timerTs.RealTime() * 1000. <<
" ms] ";
345 logOut <<
"TS " <<
fNrTs;
347 logOut <<
", clusters " << nClusters <<
", hits " <<
fNrHitsCall <<
", time/1k-hit " << setprecision(4)
348 << timerTs.RealTime() * 1e6 /
fNrHitsCall <<
" [ms]";
349 LOG(info) << logOut.str();
356 std::cout << std::endl;
357 LOG(info) <<
"=====================================";
358 LOG(info) << GetName() <<
": Finish run";
359 LOG(info) << GetName() <<
": Run summary ";
360 LOG(info) << GetName() <<
": Processing time : " << std::fixed << std::setprecision(3) <<
fProcessTime;
361 LOG(info) << GetName() <<
": Nr of events : " <<
fNrEvents;
362 LOG(info) << GetName() <<
": Nr of input clusters : " <<
fNrClusters;
363 LOG(info) << GetName() <<
": Nr of produced hits : " <<
fNrHits;
364 LOG(info) << GetName() <<
": Nr of hits / event : " << std::fixed << std::setprecision(2)
366 LOG(info) << GetName() <<
": Nr of hits / clusters: " << std::fixed << std::setprecision(2)
368 LOG(info) <<
"=====================================";
369 std::cout << std::endl;
375 FairRuntimeDb* rtdb = FairRunAna::Instance()->GetRuntimeDb();
@ kTrd
Transition Radiation Detector.
static vector< vector< QAHit > > hits
Helper class to convert unique channel ID back and forth.
FairTask to produce TrdCluster objects from TrdHit objects.
Helper class to extract information from the GeoManager.
ClassImp(CbmTrdHitProducer)
FairTask to produce TrdHit objects from TrdCluster objects.
Class for hits in TRD detector.
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,...
void AddData(ECbmDataType type, uint32_t index)
static uint32_t GetLayerId(uint32_t address)
Return layer ID from address.
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 Bool_t UseRecoHelpers()
static Bool_t UseOnlyEventDigis()
If true only digis connected ro a CbmEvent are processed Per default this is activated on constructio...
static Bool_t DoDebugPrintouts()
Data Container for TRD clusters.
eCbmTrdAsicType GetType() const
Channel FEE SPADIC/FASP according to CbmTrdAsicType.
double GetCharge() const
Common purpose charge getter.
Int_t GetModuleType(const TString &path)
Int_t GetModuleAddress()
Return module address calculated based on the current node in the TGeoManager.
UInt_t fNrClusters
Number of clusters as input for the hit production.
CbmTrdParSetGain * fGainPar
parameter list for keV->ADC gain conversion
UInt_t addModuleHits(CbmTrdModuleRec *mod, CbmEvent *event)
Pass all hits produced by the given module to the TrdHit branch. In case of event not nullptr only th...
UInt_t fNrHits
Number of produced hits.
CbmTrdParSetGeo * fGeoPar
parameter list for modules geometry
UInt_t processClusters()
Process all clusters found in the TrdClusters branch.
UInt_t fNrTs
Number of processed time slices.
void processCluster(const Int_t clusterIdx)
Produce a hit from the cluster found at clusterIdx in fClusters.
std::map< Int_t, CbmTrdModuleRec * > fModules
list of modules being processed
CbmTrdHitProducer()
Constructor.
virtual void SetParContainers()
UInt_t fNrHitsCall
Number of produced hits per call of Exec, i.e. Event(EbyE) or TimeSlice(TB).
CbmTrdParSetAsic * fAsicPar
parameter list for ASIC characterization
virtual void Exec(Option_t *option="")
Inherited from FairTask.
CbmTrdParSetDigi * fDigiPar
parameter list for read-out geometry
virtual ~CbmTrdHitProducer()
Destructor.
int fHitTimeOffset
hit time correction for synchronization
CbmTrdParSetGas * fGasPar
parameter list for HV status
virtual InitStatus Init()
Inherited form FairTask.
TClonesArray * fClusters
Input array of CbmTrdCluster.
Int_t addHits(CbmEvent *event=nullptr)
Loop over all modules in the given geometry and call addModuleHits(imodule)
UInt_t fNrEvents
Number of processed events (without CbmEvent corresponds to nr of exec calls)
virtual void Finish()
Inherited from FairTask.
CbmTrdModuleRec * AddModule(Int_t address, const CbmTrdParModGeo *pg)
Float_t fProcessTime
Total processing time [RealTime].
TClonesArray * fEvents
Array connected to the CbmEvent branch.
TClonesArray * fHits
Output array of CbmTrdHit.
Cluster finding and hit reconstruction algorithms for the TRD(2D) module.
Abstract class for module wise cluster finding and hit reconstruction.
virtual TClonesArray * GetHits()
Describe TRD module ASIC settings (electronic gain, delays, etc)
Definition of chamber gain conversion for one TRD module.
int GetPadPlaneType() const
Access the basic type of pad plane topology. For convenience also specific accessors are added for ea...
bool IsPadPlane2D() 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)
bool LoadAlignVolumes()
Trigger loading alignment information for all nodes registered.
virtual Int_t GetNrOfModules() const
virtual Int_t GetModuleId(Int_t i) const
virtual const CbmTrdParMod * GetModulePar(Int_t detId) const