1 #include "ERDigitizer.h" 6 #include "TGeoMatrix.h" 10 #include "FairRootManager.h" 11 #include "FairRunSim.h" 12 #include "FairRuntimeDb.h" 13 #include "FairLogger.h" 16 #include "ERDecayMCEventHeader.h" 22 #include "ERDetectorList.h" 26 :
ERTask(
"ER common digitization")
61 FairRootManager* ioman = FairRootManager::Instance();
62 if ( ! ioman ) Fatal(
"Init",
"No FairRootManager");
64 TList* allBranchNames = ioman->GetBranchNameList();;
65 TIter nextBranch(allBranchNames);
67 vector<TString> pointBranches;
68 while (bName = (TObjString*)nextBranch()){
69 if (bName->GetString().Contains(fName) && bName->GetString().Contains(
"Point")){
70 pointBranches.push_back(bName->GetString());
74 for (Int_t iBranch = 0; iBranch < pointBranches.size(); iBranch++){
75 TString pBranch = pointBranches[iBranch];
76 fSenVolPoints[pBranch] = (TClonesArray*) ioman->GetObject(pBranch);
77 fSenVolDigis[pBranch] =
new TClonesArray(
"ERDigi");
78 ioman->Register(pBranch(0,pBranch.Length()-5)+
"Digi", fName, fSenVolDigis[pBranch], kTRUE);
90 for(
const auto &itSenVol: fSenVolPoints){
91 TClonesArray* senVolPoints = itSenVol.second;
93 map<Int_t, vector<Int_t>> points;
94 for (Int_t iPoint = 0; iPoint < senVolPoints->GetEntriesFast(); iPoint++){
96 points[point->GetVolNb()].push_back(iPoint);
99 for(
const auto &itVol: points){
101 fTime = numeric_limits<float>::max();
103 for (
const auto itPoint: itVol.second){
105 fEdep += point->GetEnergyLoss();
107 if (point->GetTime() < fTime){
108 fTime = point->GetTime();
113 TString volName = itSenVol.first(fName.Length(),itSenVol.first.Length()-fName.Length()-5);
115 if (fSenVolErrors.find(volName) == fSenVolErrors.end()){
116 cout <<
"Error rule for vol name " << volName <<
" not found!!!" << endl;
120 Float_t sigma = error.a + error.b*TMath::Sqrt(fEdep) + error.c*fEdep;
121 fEdep = gRandom->Gaus(fEdep, sigma);
129 fVolNb = itVol.first;
130 ERDigi *digi = AddDigi(fSenVolDigis[itSenVol.first]);
141 void ERDigitizer::AddTrigger(TString stationSID, Int_t value, Int_t priority)
144 for (
const auto& trigger : fTriggers){
145 if (trigger.first == stationSID)
146 LOG(FATAL) <<
"Trigger with station SID " << stationSID
147 <<
" already exist!" << FairLogger::endl;
148 if (trigger.second.fValue == value)
149 LOG(FATAL) <<
"Trigger with value " << value
150 <<
" already exist!" << FairLogger::endl;
151 if (trigger.second.fPriority == priority)
152 LOG(FATAL) <<
"Trigger with priority " << priority
153 <<
" already exist!" << FairLogger::endl;
156 fTriggers[stationSID] =
ERTrigger(value, priority);
162 void ERDigitizer::ApplyTrigger(TString stationSID, TClonesArray* digiCollection)
168 if (
fRun->ClassName() == TString(
"ERRunSim")){
170 if ((((FairRunSim*)
fRun)->GetMCEventHeader())->ClassName() != TString(
"ERDecayMCEventHeader"))
177 if ( (fTriggers.find(stationSID) != fTriggers.end()) && (digiCollection->GetEntriesFast() > 0) ){
181 if (fTriggers[stationSID].fPriority > header->GetTriggerPriority()){
183 header->SetTrigger(fTriggers[stationSID].fValue);
184 header->SetTriggerPriority(fTriggers[stationSID].fPriority);
197 for(
const auto &itSenVolDigi: fSenVolDigis){
198 itSenVolDigi.second->Clear();
211 ERDigi* ERDigitizer::AddDigi(TClonesArray* digis) {
212 ERDigi *digi =
new((*digis)[digis->GetEntriesFast()])
213 ERDigi(fEdep, fTime, fVolNb);
217 void ERDigitizer::AddError(TString volName,Float_t a, Float_t b, Float_t c) {
virtual void Exec(Option_t *opt)
FairRun * fRun
Pointer to run manager object.
The data class for storing pieces of charged tracks in sensitive volumes in NeuRad.
std::vector< TString > fAvailibleRunManagers
Run managers that are availible for this task.
virtual InitStatus Init()
Base abstract class for all tasks in er.