REST-for-Physics  v2.3
Rare Event Searches ToolKit for Physics
TRestDetectorHitsSmearingProcess.cxx
1 /*************************************************************************
2  * This file is part of the REST software framework. *
3  * *
4  * Copyright (C) 2016 GIFNA/TREX (University of Zaragoza) *
5  * For more information see http://gifna.unizar.es/trex *
6  * *
7  * REST is free software: you can redistribute it and/or modify *
8  * it under the terms of the GNU General Public License as published by *
9  * the Free Software Foundation, either version 3 of the License, or *
10  * (at your option) any later version. *
11  * *
12  * REST is distributed in the hope that it will be useful, *
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15  * GNU General Public License for more details. *
16  * *
17  * You should have a copy of the GNU General Public License along with *
18  * REST in $REST_PATH/LICENSE. *
19  * If not, see http://www.gnu.org/licenses/. *
20  * For the list of contributors see $REST_PATH/CREDITS. *
21  *************************************************************************/
22 
68 #include "TRestDetectorHitsSmearingProcess.h"
69 
70 using namespace std;
71 
73 
78 
83  delete fOutputEvent;
84  // TRestDetectorHitsSmearingProcess destructor
85 }
86 
91  SetSectionName(this->ClassName());
92  SetLibraryVersion(LIBRARY_VERSION);
93 
94  fInputEvent = nullptr;
95  fOutputEvent = new TRestDetectorHitsEvent();
96 }
97 
99  if (fRandom != nullptr) {
100  delete fRandom;
101  }
102  fRandom = new TRandom3(fSeed);
103  fSeed = fRandom->TRandom::GetSeed();
104 }
105 
110  fInputEvent = (TRestDetectorHitsEvent*)inputEvent;
111  fOutputEvent->SetEventInfo(fInputEvent);
112 
113  Double_t eDep = fInputEvent->GetTotalEnergy();
114  Double_t eRes = fResolutionAtERef * TMath::Sqrt(fEnergyRef / eDep) / 2.35 / 100.0;
115 
116  Double_t gain = fRandom->Gaus(1.0, eRes);
117  for (unsigned int hit = 0; hit < fInputEvent->GetNumberOfHits(); hit++)
118  fOutputEvent->AddHit(fInputEvent->GetX(hit), fInputEvent->GetY(hit), fInputEvent->GetZ(hit),
119  fInputEvent->GetEnergy(hit) * gain, fInputEvent->GetTime(hit),
120  fInputEvent->GetType(hit));
121 
122  return fOutputEvent;
123 }
A process to include detector energy resolution in a TRestDetectorHitsEvent.
void Initialize() override
Function to initialize input/output event members and define the section name.
TRestEvent * ProcessEvent(TRestEvent *inputEvent) override
The main processing event function.
void InitProcess() override
To be executed at the beginning of the run (outside event loop)
A base class for any REST event.
Definition: TRestEvent.h:38
void SetEventInfo(TRestEvent *eve)
Definition: TRestEvent.cxx:137