10#include <ecl/modules/eclDigitizer/ECLDigitizerPureCsIModule.h>
13#include <ecl/dataobjects/ECLDigit.h>
14#include <ecl/dataobjects/ECLDsp.h>
15#include <ecl/dataobjects/ECLHit.h>
16#include <ecl/dataobjects/ECLPureCsIInfo.h>
17#include <ecl/dbobjects/ECLWaveformData.h>
18#include <ecl/digitization/ECLDspFitterPure.h>
19#include <ecl/geometry/ECLGeometryPar.h>
22#include <framework/gearbox/Unit.h>
23#include <framework/logging/Logger.h>
24#include <framework/utilities/FileSystem.h>
52 addParam(
"Background",
m_background,
"Flag to use the DigitizerPureCsI configuration with backgrounds; Default is no background",
55 "Flag to use the DigitizerPureCsI for Waveform fit Covariance Matrix calibration; Default is false",
57 addParam(
"adcTickFactor",
m_tickFactor,
"multiplication factor to get adc tick from trigger tick", 8);
65 addParam(
"debugtrgtime",
m_testtrg,
"set fixed trigger time for testing purposes", 0);
66 addParam(
"debugsigtimeshift",
m_testsig,
"shift signal arrival time for testing purposes (in microsec)", 0.);
67 addParam(
"debugenergydeposit",
m_testenedep,
"energy deposit in all crystals for testing purposes", 0.);
118 int j = eclHit.getCellId() - 1;
121 double hitE = eclHit.getEnergyDep() /
Unit::GeV;
122 double hitTime = eclHit.getTimeAve() /
Unit::us;
125 int nphotavg = round((hitE / 0.001) * nphotavg1MeV);
126 int nphot = gRandom->Poisson(nphotavg);
127 hitE = (nphot / nphotavg1MeV) / 1000;
150 memset(adcNoise, 0,
sizeof(adcNoise));
154 z[i] = gRandom->Gaus(0, 1);
155 m_noise[0].generateCorrelatedNoise(z, adcNoise);
160 FitA[i] = 20 * (1000 * a.c[i] + adcNoise[i]) + 3000;
178 DSPFitterPure(
m_fitparams[
m_tbl[j].idn], FitA, 0, energyFit, tFit, fitChi2, qualityFit);
191 eclDsp->setCellId(CellId);
192 eclDsp->setDspA(FitA);
195 eclDigit->setCellId(CellId);
196 eclDigit->setAmp(energyFit);
197 eclDigit->setTimeFit(
int(tFit * 10));
198 eclDigit->setQuality(qualityFit);
201 eclDigit->addRelationTo(AeclPureCsIInfo);
202 AeclPureCsIInfo->setPureCsI(1);
203 AeclPureCsIInfo->setCellId(CellId);
205 eclDigit->addRelationTo(eclDsp);
206 for (
const auto& hit : hitmap[j])
207 eclDigit->addRelationTo(hit);
216 int cellid = eclDigit.getCellId();
219 eclDigitClone->setCellId(cellid);
220 eclDigitClone->setAmp(eclDigit.getAmp());
221 eclDigitClone->setTimeFit(eclDigit.getTimeFit());
222 eclDigitClone->setQuality(eclDigit.getQuality());
225 eclDigitClone->addRelationTo(AeclPureCsIInfo);
226 AeclPureCsIInfo->setPureCsI(0);
227 AeclPureCsIInfo->setCellId(cellid);
245 string dataFileName, dataFileName2;
250 B2INFO(
"ECLDigitizerPureCsI: Reading configuration data with background from: " << dataFileName);
251 B2INFO(
"ECLDigitizerPureCsI: Reading configuration data with background from: " << dataFileName2);
257 B2INFO(
"ECLDigitizerPureCsI: Reading configuration data without background from: " << dataFileName);
258 B2INFO(
"ECLDigitizerPureCsI: Reading configuration data without background from: " << dataFileName2);
260 assert(! dataFileName.empty());
262 TFile rootfile(dataFileName.c_str());
263 const TH1F* sampledWF =
dynamic_cast<TH1F*
>(rootfile.Get(
"sampleddsp"));
264 assert(sampledWF !=
nullptr);
265 const TH1F* sampledWF1 =
dynamic_cast<TH1F*
>(rootfile.Get(
"sampleddsp1"));
266 assert(sampledWF1 !=
nullptr);
273 m_ss[0].InitSample(sampledWF, sampledWF1);
276 B2INFO(
"ECLDigitizerPureCsI: " <<
m_ss.size() <<
" sampled signal templates were created.");
281 TFile rootfile2(dataFileName2.c_str());
282 TTree* tree = (TTree*) rootfile2.Get(
"EclWF");
284 const int maxncellid = 512;
286 vector<int> cellId(maxncellid);
288 tree->SetBranchAddress(
"ncellId", &ncellId);
289 tree->SetBranchAddress(
"cellId", cellId.data());
290 tree->SetBranchAddress(
"CovarianceM", &eclWFData);
291 for (Long64_t j = 0, jmax = tree->GetEntries(); j < jmax; j++) {
293 assert(ncellId <= maxncellid);
294 for (
int i = 0; i < ncellId; ++i)
301 B2INFO(
"ECLDigitizerPureCsI: parameters vector size : " <<
m_fitparams.size());
307 for (
int i = 0; i < 16; i++)
308 for (
int j = 0; j < 16; j++)
314 initParams(param,
m_ss[0]);
322 for (
int j = 0; j <= i; j++)
324 else m_noise[0].setMatrixElement(index++, 0.);
StoreArray< ECLDigit > m_BaselineDigits
ECL digits (baseline, i.e.
StoreArray< ECLDigit > m_ecldigits
StoreArray ECLDigit.
bool m_NoCovMatrix
Flag to use a diagonal (neutral) Covariance matrix.
ECLDigitizerPureCsIModule()
Constructor.
static constexpr const char * eclPureCsIInfoArrayName()
Pure CsI Info array name.
virtual void initialize() override
Initialize variables
int m_thetaIdMax
Ring ID of last pure CsI ring in FWD.
std::vector< signalsample_type > m_ss
Tabulated shape line.
virtual void event() override
Actual digitization of all pure CsI hits in the ECL.
void mapGeometry()
Returns ring ID for a certain crystal.
double m_elecNoise
Electronic Noise energy equivalente in MeV.
virtual void endRun() override
Nothing so far.
StoreArray< ECLHit > m_hitLists
StoreArray ECLHit.
virtual void terminate() override
Free memory.
bool m_debug
Flag for debug mode.
bool m_background
Flag to set covariance matrix for WF with beam-bkg.
int m_testtrg
Fixed trigger time for testing purposes.
bool isPureCsI(int cellId)
Returns 1 if corresponding crystal is set as pure CsI crystal.
std::vector< adccounts_type > m_adc
Storage for adc hits from entire calorimeter (8736 crystals).
static constexpr const char * eclDigitArrayName()
Pure CsI digit array name.
double m_testenedep
Fixed energy deposition in all crystals, for testing purposes.
int m_nEvent
Event number.
virtual void beginRun() override
Nothing so far.
int m_thetaIdMin
Module parameters.
StoreArray< ECLPureCsIInfo > m_eclpurecsiinfo
StoreArray ECLPureCsIInfo.
double m_photostatresolution
Resolution for a 1 MeV energy deposit.
std::vector< fitparams_type > m_fitparams
Fitting parameters.
std::vector< crystallinks_t > m_tbl
Lookup table for ECL channels.
int m_tickFactor
multiplication factor to get adc tick from trigger tick.
StoreArray< ECLDsp > m_ecldsps
StoreArray ECLDsp.
double m_testsig
Shift in signal arrival time, for testing purposes.
bool m_calibration
Flag to use the DigitizerPureCsI for Waveform fit Covariance Matrix calibration.
static constexpr const char * eclDspArrayName()
Pure CsI DSP array name.
std::vector< ECLNoiseData > m_noise
Parameters for correlated noise stimation.
double m_sigmaTrigger
Trigger resolution.
int m_thetaID[ECL::EclConfigurationPure::m_nch]
ECL ring ID.
~ECLDigitizerPureCsIModule()
Destructor.
void readDSPDB()
read Shaper-DSP data from root file.
The Class for ECL Geometry Parameters.
static ECLGeometryPar * Instance()
Static method to get a reference to the ECLGeometryPar instance.
void Mapping(int cid)
Mapping theta, phi Id.
int GetThetaID()
Get Theta Id.
static void setTickPure(double newval)
Setter for m_tickPure.
static constexpr int m_nch
total number of electronic channels (crystals) in fwd endcap calorimeter
static constexpr int m_nsmp
number of ADC measurements for signal fitting
static double getTick()
See m_tick.
static constexpr int m_ntrg
number of trigger counts per ADC clock tick
static std::string findFile(const std::string &path, bool silent=false)
Search for given file or directory in local or central release directory, and return absolute path if...
void setDescription(const std::string &description)
Sets the description of the module.
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
static const double us
[microsecond]
static const double GeV
Standard of [energy, momentum, mass].
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.
a struct for the fit parameters for the pure CsI calorimeter
A struct for the fit parameters for a single channel of the pure CsI calorimeter (in the simulation,...