16#include <FairRootManager.h>
19#include <TClonesArray.h>
22#include <TStopwatch.h>
35using std::setprecision;
37using std::stringstream;
60 fhModXNewEn =
new TH1F(
"hModXNewEn",
"X distr, En", 300, -150., 150.);
63 std::cout << std::endl << std::endl;
64 LOG(info) <<
"======= " << GetName() <<
": Init =====================";
67 FairRootManager* ioman = FairRootManager::Instance();
69 LOG(fatal) <<
"-W- CbmPsdHitProducer::Init: RootManager not instantised!";
74 fEvents =
dynamic_cast<TClonesArray*
>(ioman->GetObject(
"Event"));
76 LOG(info) << GetName() <<
": found Event branch, run event-by-event";
78 fEvents =
dynamic_cast<TClonesArray*
>(ioman->GetObject(
"CbmEvent"));
79 if (
fEvents) LOG(info) << GetName() <<
": found CbmEvent branch, run event-by-event";
82 LOG(info) << GetName() <<
": no event branch found; run in time-based mode";
83 LOG(warn) <<
"*** Note that the current PSD hit producer is not suited for time-based reconstruction!";
84 LOG(warn) <<
"*** Unless you have run the simulation event-by-event, it will not produce sensible results.";
93 LOG(error) << GetName() <<
": No PsdDigi input array present; "
94 <<
"task will be inactive.";
97 LOG(info) << GetName() <<
": found PsdDigi branch";
100 fHitArray =
new TClonesArray(
"CbmPsdHit", 1000);
101 ioman->Register(
"PsdHit",
"PSD",
fHitArray, IsOutputBranchPersistent(
"PsdHit"));
103 LOG(info) << GetName() <<
": registered branch PsdHit";
105 LOG(info) << GetName() <<
": intialisation successfull";
106 LOG(info) <<
"======================================================\n";
124 pair<Int_t, Int_t> result;
134 nDigis = result.first;
135 nHits = result.second;
141 nEvents =
fEvents->GetEntriesFast();
142 for (Int_t iEvent = 0; iEvent < nEvents; iEvent++) {
146 LOG(debug) << GetName() <<
": Event " << iEvent <<
" / " << nEvents <<
", digis " << result.first <<
", hits "
148 nDigis += result.first;
149 nHits += result.second;
156 logOut << setw(20) << left << GetName() <<
" [";
157 logOut << fixed << setw(8) << setprecision(1) << right << timer.RealTime() * 1000. <<
" ms] ";
158 logOut <<
"TS " <<
fNofTs;
159 if (
fEvents) logOut <<
", events " << nEvents;
160 logOut <<
", digis " << nDigis <<
" / " << nDigisAll;
161 logOut <<
", hits " << nHits;
162 LOG(info) << logOut.str();
176 std::cout << std::endl;
177 LOG(info) <<
"=====================================";
178 LOG(info) << GetName() <<
": Run summary";
179 LOG(info) <<
"Time slices : " <<
fNofTs;
180 LOG(info) <<
"Digis / TS : " << fixed << setprecision(2) << Double_t(
fNofDigis) / Double_t(
fNofTs);
181 LOG(info) <<
"Hits / TS : " << fixed << setprecision(2) << Double_t(
fNofHits) / Double_t(
fNofTs);
182 LOG(info) <<
"Time / TS : " << fixed << setprecision(2) << 1000. *
fTimeTot / Double_t(
fNofTs) <<
" ms";
185 LOG(info) <<
"Events / TS : " << fixed << setprecision(2) << Double_t(
fNofEvents) / Double_t(
fNofTs);
186 LOG(info) <<
"Digis / event : " << fixed << setprecision(2) << Double_t(
fNofDigis) / Double_t(
fNofEvents);
187 LOG(info) <<
"Hits / event : " << fixed << setprecision(2) << Double_t(
fNofHits) / Double_t(
fNofEvents);
191 TFile* oldFile = gFile;
192 TDirectory* oldDir = gDirectory;
193 TFile* outfile =
new TFile(
"EdepHistos.root",
"RECREATE");
199 LOG(info) <<
"Histograms written to EdepHistos.root";
200 LOG(info) <<
"=====================================\n";
210 std::map<int, Double_t> edepmap;
216 Int_t digiIndex = -1;
217 for (Int_t iDigi = 0; iDigi < nDigis; iDigi++) {
224 Double_t eDep = (Double_t) digi->
GetEdep();
225 auto insert_result = edepmap.insert(std::make_pair(mod, eDep));
226 if (!insert_result.second) {
227 (*insert_result.first).second += eDep;
233 UInt_t hitIndex = -1;
234 for (
auto edep_entry : edepmap) {
235 int modID = edep_entry.first;
236 Double_t eDep = edep_entry.second;
238 new ((*fHitArray)[hitIndex])
CbmPsdHit(modID, eDep);
243 return std::make_pair(nDigis, nHits);
ClassImp(CbmConverterManager)
@ kPsd
Projectile spectator detector.
static Int_t GetNofDigis(ECbmModuleId systemId)
static Bool_t IsPresent(ECbmModuleId systemId)
Presence of a digi branch.
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,...
Data class for PSD digital information.
double GetEdep() const
Energy deposit.
double GetModuleID() const
Module Identifier.
std::pair< Int_t, Int_t > ProcessData(CbmEvent *event)
Processing of digis.
virtual InitStatus Init()
virtual void Exec(Option_t *opt)
CbmDigiManager * fDigiMan