3 #ifndef BSEMCEXTRACTDIGISFROMWAVEFORMS_HH 4 #define BSEMCEXTRACTDIGISFROMWAVEFORMS_HH 12 #include "TClonesArray.h" 13 #include "TStopwatch.h" 15 #include "FairLogger.h" 16 #include "FairRootManager.h" 17 #include "FairRunAna.h" 18 #include "FairRuntimeDb.h" 39 template <
class ParSet>
52 if (
fPSA !=
nullptr) {
71 LOG(debug) <<
"BSEmcExtractDigisFromWaveforms<ParSet>::Init";
80 FairRootManager *ioman = FairRootManager::Instance();
81 if (ioman ==
nullptr) {
82 LOG(error) <<
"BSEmcExtractDigisFromWaveforms<ParSet>::Init: " 83 <<
"RootManager not instantiated!";
88 LOG(debug) <<
"BSEmcExtractDigisFromWaveforms<ParSet>::Init: Registered " <<
fDigiBranchName;
95 LOG(error) <<
"BSEmcExtractDigisFromWaveforms<ParSet>::Init: " 96 <<
"No BSEmcWaveform array containing multi waveforms!";
102 if (
fPSA ==
nullptr) {
103 LOG(error) <<
"No PSA was defined. Aborting!";
109 LOG(debug) <<
"BSEmcExtractDigisFromWaveforms: Intialization successfull";
131 Double_t energy = NAN;
132 Double_t digi_time = NAN;
138 for (Int_t iWaveform = 0; iWaveform < nWaveforms; iWaveform++) {
145 for (Int_t iHit = 0; iHit < nHits; ++iHit) {
149 Double_t timestamp =
GetTimeStamp(theWaveform, digi_time);
153 myDigi->ResetLinks();
154 myDigi->AddLinks(theWaveform->GetLinksWithType(FairRootManager::Instance()->GetBranchId(
fHitBranchName)));
155 FairMultiLinkedData mchitlinks = myDigi->GetLinksWithType(FairRootManager::Instance()->GetBranchId(
fHitBranchName));
156 for (
const FairLink &link : mchitlinks.GetLinks()) {
159 LOG(debug) <<
"BSEmcExtractDigisFromWaveforms for " <<
fDetectorName <<
" created Digi(detId: " << detId <<
", energy: " << energy <<
", timestamp: " << timestamp
160 <<
") and has " << myDigi->GetLinksWithType(FairRootManager::Instance()->GetBranchId(
fHitBranchName)).GetNLinks() <<
" links to EmcMCHits";
166 Double_t rtime = timer.RealTime();
167 Double_t ctime = timer.CpuTime();
168 LOG(debug) <<
"BSEmcExtractDigisFromWaveforms, Real time " << rtime <<
" s, CPU time " << ctime <<
" s";
184 FairRun *run = FairRun::Instance();
185 if (run ==
nullptr) {
186 Fatal(
"SetParContainers",
"No analysis run");
188 FairRuntimeDb *db = run->GetRuntimeDb();
190 Fatal(
"SetParContainers",
"No runtime database");
193 fDigiPar =
dynamic_cast<ParSet *
>(db->getContainer(ParSet::fgParameterName.c_str()));
199 t_digi_time /= sampleRate;
201 return t_waveform->GetTimeStamp() + t_digi_time;
virtual Bool_t Init(const TString &t_branchname) final
Register the data t_branchname in form of TClonesArray * with the FairRootManager.
Baseclass for pulseshapeanalysis ( featureextraction )
const std::string fgMultiWaveformBranchName
virtual void GetHit(Int_t t_i, Double_t &t_energy, Double_t &t_time)=0
Get energy and time of hit.
void SetGainType(eGAIN t_type)
void SetPersistency(Bool_t val=kTRUE)
virtual Int_t Process(const BSEmcWaveform *t_waveform)=0
Find Hits in Waveform.
virtual T * CreateCopy(const T &t_element)
Create a copy of t_element in the TClonesArray and return a pointer to it.
virtual void Reset() final
Delete all elements.
represents the reconstructed hit of one emc crystal
Input and Output Container implementation of PndOutputContainerI using an underlying TClonesArray...
const std::string fgMCHitBranchName
const std::string fgDigiBranchName