33#if __cplusplus >= 201402L
34# define MKADCDATA(name,title,nelem,chanmap) make_unique<ShowerADCData>((name),(title),(nelem),(chanmap))
36# define MKADCDATA(name,title,nelem,chanmap) unique_ptr<ShowerADCData>(new ShowerADCData((name),(title),(nelem),(chanmap)))
43 fNrows(0), fEmin(0), fAsum_p(
kBig), fAsum_c(
kBig),
44 fNclust(0), fE(
kBig), fX(
kBig), fY(
kBig), fADCData(nullptr)
52 fNrows(0), fEmin(0), fAsum_p(
kBig), fAsum_c(
kBig),
53 fNclust(0), fE(
kBig), fX(
kBig), fY(
kBig), fADCData(nullptr)
64 const char*
const here =
"ReadDatabase";
66 VarType kDataType = std::is_same<Data_t, Float_t>::value ?
kFloat :
kDouble;
67 VarType kDataTypeV = std::is_same<Data_t, Float_t>::value ? kFloatV : kDoubleV;
84 vector<Int_t> detmap, chanmap;
85 vector<Double_t>
xy, dxy;
86 Int_t ncols = 0, nrows = 0;
89 DBRequest config_request[] = {
90 {
"detmap", &detmap, kIntV },
91 {
"chanmap", &chanmap, kIntV, 0,
true },
92 {
"ncols", &ncols,
kInt },
93 {
"nrows", &nrows,
kInt },
94 {
"xy", &
xy, kDoubleV, 2 },
95 {
"dxdy", &dxy, kDoubleV, 2 },
96 {
"emin", &
fEmin, kDataType },
102 if( !err && (nrows <= 0 || ncols <= 0) ) {
103 Error(
Here(
here),
"Illegal number of rows or columns: %d %d. Must be > 0. "
104 "Fix database.", nrows, ncols );
108 Int_t nelem = ncols * nrows;
114 Error(
Here(
here),
"Cannot re-initialize with different number of blocks or "
115 "blocks per cluster (was: %d, now: %d). Detector not re-initialized.",
133 if( tot_nchan != nval ) {
135 "inconsistent with number of blocks (%u)",
141 if( !err && !chanmap.empty() ) {
143 size_t cmapsize = chanmap.size();
144 if( cmapsize != nval ) {
145 Error(
Here(
here),
"Channel map size (%lu) and number of detector "
146 "channels (%u) must be equal. Fix database.",
154 fChanMap.assign(chanmap.begin(), chanmap.end());
173 for(
int c=0;
c<ncols;
c++ ) {
174 for(
int r=0;
r<nrows;
r++ ) {
186 vector<Data_t> ped, gain;
187 DBRequest calib_request[] = {
188 {
"pedestals", &ped, kDataTypeV, nval,
true },
189 {
"gains", &gain, kDataTypeV, nval,
true },
197 for(
UInt_t i = 0; i < nval; ++i ) {
200 calib.gain = gain[i];
210 {
"Detector center", pos,
kDouble, 3 },
212 {
"Channel map", &chanmap, kIntV },
213 {
"Position of block 1", &
xy, kDoubleV },
214 {
"Block x/y spacings", &dxy, kDoubleV },
215 {
"Minimum cluster energy", &
fEmin, kDataType, 1 },
216 {
"ADC pedestals", &ped, kDataTypeV,
N },
217 {
"ADC gains", &gain, kDataTypeV,
N },
238 {
"asum_p",
"Sum of ped-subtracted ADCs",
"fAsum_p" },
239 {
"asum_c",
"Sum of calibrated ADCs",
"fAsum_c" },
240 {
"nclust",
"Number of clusters",
"fNclust" },
241 {
"e",
"Energy (MeV) of largest cluster",
"fE" },
242 {
"x",
"x-position of largest cluster",
"fX" },
243 {
"y",
"y-position of largest cluster",
"fY" },
244 {
"mult",
"Multiplicity of largest cluster",
"GetMainClusterSize()" },
245 {
"nblk",
"Numbers of blocks in main cluster",
"fClBlk.n" },
246 {
"eblk",
"Energies of blocks in main cluster",
"fClBlk.E" },
276 Int_t k = ADCData::GetLogicalChannel(hitinfo);
281 if( !fChanMap.empty() )
285 k = fChanMap.at(k) - 1;
331 for(
int i = 0; i <
fNelem; i++ ) {
333 if( ei > 0.5*
kBig )
continue;
343 fClBlk.push_back( {nmax,emax} );
346 for(
int i = 0; i <
fNelem; i++ ) {
348 if( ei > 0.5*
kBig )
continue;
349 if( ei > 0 && i != nmax ) {
354 if( -2<dr && dr<2 && -2<dc && dc<2 ) {
356 fClBlk.push_back( {i,ei} );
395 <<
" Shower Detector " <<
GetPrefix() << endl;
397 for(
int i = 0; i < ncol; i++ ) {
398 cout <<
" Block ADC ADC_p ";
402 for(
int i = 0; i < (
fNelem + ncol - 1) / ncol; i++ ) {
403 for(
int c = 0;
c < ncol;
c++ ) {
404 int ind =
c *
fNelem / ncol + i;
407 cout <<
" " << setw(3) << ind + 1;
411 WriteValue(ADC.adc_p);
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint xy
Option_t Option_t TPoint TPoint const char mode
#define MKADCDATA(name, title, nelem, chanmap)
static const char *const here
ADCData_t & GetADC(size_t i)
UInt_t GetSize() const override
ADCCalib_t & GetCalib(size_t i)
static Int_t LoadDB(FILE *file, const TDatime &date, const DBRequest *request, const char *prefix, Int_t search=0, const char *here="THaAnalysisObject::LoadDB")
static Int_t DefineVarsFromList(const void *list, EType type, EMode mode, const char *def_prefix, const TObject *obj, const char *prefix, const char *here, const char *comment_subst="")
virtual const char * Here(const char *) const
const char * GetPrefix() const
virtual Int_t ReadDatabase(const TDatime &date)
TString GetPrefixName() const
virtual Int_t DefineVariables(EMode mode=kDefine)
virtual FILE * OpenFile(const TDatime &date)
UInt_t GetTotNumChan() const
Int_t FillDetMap(const std::vector< Int_t > &values, UInt_t flags=0, const char *here="FillDetMap")
virtual Int_t StoreHit(const DigitizerHitInfo_t &hitinfo, UInt_t data)
virtual Int_t ReadGeometry(FILE *file, const TDatime &date, Bool_t required=false)
VecDetData_t fDetectorData
Int_t CalcTrackProj(TClonesArray &tracks)
Int_t GetLogicalChannel(const DigitizerHitInfo_t &hitinfo) const override
virtual void Clear(Option_t *="")
virtual Int_t StoreHit(const DigitizerHitInfo_t &hitinfo, UInt_t data)
std::vector< ClusterBlock > fClBlk
virtual Int_t FineProcess(TClonesArray &tracks)
std::vector< CenterPos > fBlockPos
std::vector< Int_t > fChanMap
virtual Int_t DefineVariables(EMode mode=kDefine)
virtual Int_t CoarseProcess(TClonesArray &tracks)
virtual void PrintDecodedData(const THaEvData &evdata) const
virtual Int_t ReadDatabase(const TDatime &date)
void Clear(Option_t *option="") override
virtual void Error(const char *method, const char *msgfmt,...) const
void GetXYZ(Double_t *carray) const
Double_t Min(Double_t a, Double_t b)