9#include <framework/core/HistoModule.h>
10#include <framework/datastore/StoreArray.h>
11#include <framework/datastore/StoreObjPtr.h>
12#include <framework/dataobjects/EventMetaData.h>
13#include <framework/gearbox/Const.h>
14#include <beast/csi/modules/CsiModule.h>
15#include <beast/csi/dataobjects/CsiSimHit.h>
16#include <beast/csi/dataobjects/CsiHit.h>
17#include <beast/csi/dataobjects/CsiDigiHit.h>
18#include <beast/csi/modules/CsIStudyModule.h>
40 h_CrystalSpectrum(NULL),
41 h_CrystalRadDose(NULL),
42 h_CrystalRadDoseSH(NULL),
44 h_LightYieldCrystal(NULL),
54 setDescription(
"Analyze simulations of CsI readings in BEAST. Requires HistoManager module.");
60 string rootfilepath =
"output/waveforms.root";
71 h_CrystalEdep =
new TH1F(
"Crystal_Edep",
"Energy distribution in each crystal;CellID", 16, -0.5, 15.5);
72 h_CrystalSpectrum =
new TH1F(
"Crystal_Edist",
"Photon energy distribution in all crystals;", 100, 0, 0.1);
73 h_NhitCrystal =
new TH1F(
"Crystal_HitRate",
"Number of hit per crystal;CellID; hit/s", 16, -0.5, 15.5);
74 h_CrystalRadDose =
new TH1F(
"Crystal_RadDose",
"Crystal Radiation Dose;CellID;Gy/yr", 16, -0.5, 15.5);
75 h_CrystalRadDoseSH =
new TH1F(
"Crystal_RadDose_SH",
"Crystal Radiation Dose from SimHits;CellID;Gy/yr", 16, -0.5, 15.5);
76 h_LightYieldCrystal =
new TH1F(
"Crystal_g_yield",
"Light yield each crystal;CellID;gamma/sample", 16, -0.5, 15.5);
79 h_Charge =
new TH1F(
"Charge",
"log_{10} of integrated Charge", 200, 0, 10);
80 h_TrueEdep =
new TH1F(
"TrueEdep",
"log_{10} of true deposited energy/GeV", 200, -6, 0);
81 h_Height =
new TH1F(
"Height",
"log10 of pulse height", 200, 0, 6);
82 h_Weight =
new TH1F(
"Weight",
"Distribution of the event weights form the generator", 1000, 0, 10);
111 double eventWeight = eventMetaDataPtr->getGeneratedWeight();
116 if (
m_hits.getEntries() > 0) {
117 int hitNum =
m_hits.getEntries();
123 for (
int i = 0; i < hitNum; i++) {
147 for (
int i = 0; i < hitNum; i++) {
167 for (
int i = 0; i < hitNum; i++) {
172 double charge = (double) aCsIDigiHit->
getCharge();
173 double height = (double) aCsIDigiHit->
getMaxVal();
174 double baseline = (double) aCsIDigiHit->
getBaseline();
176 vector<uint16_t>* waveform = aCsIDigiHit->
getWaveform();
179 h_TrueEdep->Fill(log10(trueEdep), eventWeight);
180 h_Charge->Fill(log10(charge - baseline), eventWeight);
181 h_Height->Fill(log10(height), eventWeight);
188 if (waveform->size()) {
193 sprintf(histoTitle,
"Waveform Hit No. %i, Cell No %i", i, cellID);
197 for (uint iBin = 0; iBin < waveform->size(); iBin++) {
199 h_Gate->Fill(iBin + 1, (
int) statusBits[1]);
200 h_Waveform->Fill(iBin + 1, waveform->at(iBin));
221 bool* bit =
new bool[8];
224 for (
int i = 0; i < 8; i++) {
225 bit[i] = ((data >> i) & 0x01);
static const ParticleType photon
photon particle
const double Sampletime
Sample time in us.
TH1F * h_CrystalEdep
Energy deposited in each crystal.
TH1F * h_Charge
Distribution of the integrated charge from the pulse processing algorithm.
TH1F * h_CrystalSpectrum
Distribution of the energy of each simhit.
TH1F * h_TrueEdep
Distribution of the true total deposited energy in the event.
virtual ~CsIStudyModule()
Empty destructor.
virtual void initialize() override
Initialization: building histograms.
virtual void event() override
Read each event, calculate doses and fill histograms.
bool * readDPPStatusBits(char packedbits)
Reads and unpacks the status bits of the digitizer Unpacks in the appropriate booleans.
StoreArray< CsiHit > m_hits
Array of the crystal hits (1 per event)
double m_paramTemplate
Template of an input parameter.
virtual void endRun() override
To do at the end of each runs.
TH1F * h_Height
Max height of the peak signa(.
virtual void terminate() override
Clean everything up.
StoreArray< CsiSimHit > m_simhits
Array of the simulated hits in the crystals (incl.
int m_nWFSamples
Number of samples in each of the waveforms (in the near future this should be imported from the digi ...
TH1F * h_Weight
Event weight assigned by the generator.
TH1S * h_Waveform
Contains the digitized waveform (if enabled in the digitizer)
const double usInYr
Conversion between us to nominal year.
virtual void beginRun() override
To do at the beginning of each runs.
TH1F * h_LightYieldCrystal
Number of photons hits in each crystal (to validate light yield..)
TH1C * h_Gate
Contains the integration gate (if waveforms are enabled in the digitizer)
TH1F * h_NhitCrystal
Number of hits in each crystal (to get hit rate)
StoreArray< CsiDigiHit > m_digihits
Array of the crystal digitized hits (1 per event per fired crystal)
CsIStudyModule()
Constructor: Sets the description, the properties and the parameters of the module.
TH1F * h_CrystalRadDoseSH
Yearly radiation dose deposited in each crystal (for hit-simhit check)
std::string m_waveformFilename
Path where to save the waveforms (root file)
const double GeVtoJ
Conversion between GeV to Joule.
TFile * fWF
ROOT file to save waveforms.
TH1F * h_CrystalRadDose
Yearly radiation dose deposited in each crystal.
virtual void defineHisto() override
function to define histograms
Class to store Csi digitized hits (output of CsIDigitizer) relation to CsiHit filled in beast/csi/mod...
double getTrueEdep() const
Get true deposited energy.
uint16_t getBaseline() const
Get Baseline.
std::vector< uint16_t > * getWaveform()
Get Waveform array.
uint32_t getCharge() const
Get Integrated Charge.
std::vector< uint8_t > * getStatusBits()
Get Status bits array.
uint8_t getCellId() const
Get Cell ID.
uint16_t getMaxVal() const
Get Maximal Value.
Class to store simulated hits which equate to average of CsiSimHit on crystals Input for digitization...
int getCellId() const
Get Cell ID.
double getEnergyDep() const
Get deposit energy.
ClassCsiSimHit - Geant4 simulated hits in CsI crystals in BEAST.
int getPDGCode() const
Get Particle PDG (can be one of secondaries)
int getCellId() const
Get Cell ID.
double getEnergyDep() const
Get Deposit energy.
HistoModule.h is supposed to be used instead of Module.h for the modules with histogram definitions t...
void setDescription(const std::string &description)
Sets the description of the module.
Type-safe access to single objects in the data store.
void addParam(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.