Hall A ROOT/C++ Analyzer (podd)
Loading...
Searching...
No Matches
FadcScintillator.cxx
Go to the documentation of this file.
1
2// //
3// FadcScintillator (11202017 Hanjie Liu hanjie@jlab.org) //
4// Generic Scintillator with FADC frontends. //
5// Inherits from THaScintillator with some special FADC variables added. //
6// //
7// Class for a scintillator (hodoscope) consisting of multiple //
8// paddles with phototubes on both ends. //
9// //
11
12#include "FadcScintillator.h"
13#include "FADCData.h"
14#include "THaDetMap.h"
15#include "THaEvData.h"
16#include <cstdlib>
17
18using namespace std;
19
20namespace HallA {
21
22//_____________________________________________________________________________
23FadcScintillator::FadcScintillator( const char* name, const char* description,
24 THaApparatus* apparatus )
25 : THaScintillator(name, description, apparatus),
26 fFADCDataL(nullptr), fFADCDataR(nullptr)
27{
28 // Constructor
29}
30
31//_____________________________________________________________________________
33 : THaScintillator(), fFADCDataL(nullptr), fFADCDataR(nullptr)
34
35{
36 // Default constructor (for ROOT RTTI)
37}
38
39//_____________________________________________________________________________
41{
42 // Destructor. Remove variables from global list.
43
45}
46
47//_____________________________________________________________________________
49{
50 // Read this detector's parameters from the database
51
53 if( err )
54 return err;
55
56 for( int i = kRight; i <= kLeft; ++i ) {
57 auto ret = MakeFADCData(date, this);
58 if( ret.second )
59 return ret.second; // Database error
60 // Keep pointers to the elements around for convenient access
61 FADCData*& fdat = (i == kRight) ? fFADCDataR : fFADCDataL;
62 fdat = ret.first.get();
63 assert(fdat->GetSize() - fNelem == 0);
64 fDetectorData.emplace_back(std::move(ret.first));
65 }
66
67 return kOK;
68}
69
70//_____________________________________________________________________________
72{
73 // Define global analysis variables
74
75 // Add FADC-specific variables for left- and right-side readouts
76 class VarDefInfo {
77 public:
78 FADCData* fadcData;
79 const char* key_prefix;
80 const char* comment_subst;
81 Int_t DefineVariables( EMode mode ) const // Convenience function
82 { return fadcData->DefineVariables(mode, key_prefix, comment_subst); }
83 };
84 const vector<VarDefInfo> sides = {
85 { fFADCDataR, "r", "right side" },
86 { fFADCDataL, "l", "left side" }
87 };
88 for( const auto& side : sides )
89 if( Int_t ret = side.DefineVariables(mode) )
90 return ret;
91
92 // Define standard scintillator variables. This must come last so that our
93 // FADCData objects will be recognized as already initialized.
95}
96
97//_____________________________________________________________________________
99 const DigitizerHitInfo_t& hitinfo )
100{
101 // Callback from Decoder for loading the data for the 'hitinfo' channel.
102 // This routine supports FADC modules and returns the pulse amplitude integral.
103 // Additional info is retrieved from the FADC modules in StoreHit later.
104
106 return FADCData::LoadFADCData(hitinfo);
107
108 // Fallback for legacy modules
109 return THaScintillator::LoadData(evdata, hitinfo);
110}
111
112//_____________________________________________________________________________
113Int_t
115{
116 // Put decoded frontend data into fDetectorData. Called from Decode().
117
118 static_assert(kRight == 0 || kLeft == 0, "kRight or kLeft must be 0");
119 assert(fNviews == abs(kLeft - kRight) + 1);
120
121 auto side = static_cast<ESide>(GetView(hitinfo));
122
123 // Call StoreHit for the FADC modules first to get updated pedestals
124 FADCData* fadcData = (side == kRight) ? fFADCDataR : fFADCDataL;
125 fadcData->StoreHit(hitinfo, data);
126
127 // Retrieve pedestal, if available, and update the PMTData calibrations
128 const auto& FDAT = fadcData->GetData(hitinfo);
129 if( FDAT.fPedq == 0 ) {
130 Podd::PMTData*& pmtData = (side == kRight) ? fRightPMTs : fLeftPMTs;
131 pmtData->GetCalib(hitinfo).ped = FDAT.fPedestal;
132 }
133
134 // Now fill the PMTData in fDetectorData
135 return THaScintillator::StoreHit(hitinfo, data);
136}
137
138} // namespace HallA
139
140//_____________________________________________________________________________
#define kOK
Definition BdataLoc.cxx:40
int Int_t
unsigned int UInt_t
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint TPoint const char mode
char name[80]
Int_t StoreHit(const DigitizerHitInfo_t &hitinfo, UInt_t data) override
Definition FADCData.cxx:138
static OptUInt_t LoadFADCData(const DigitizerHitInfo_t &hitinfo)
Definition FADCData.cxx:125
FADCData_t & GetData(size_t i)
Definition FADCData.h:81
UInt_t GetSize() const override
Definition FADCData.h:76
OptUInt_t LoadData(const THaEvData &evdata, const DigitizerHitInfo_t &hitinfo) override
Int_t StoreHit(const DigitizerHitInfo_t &hitinfo, UInt_t data) override
Int_t ReadDatabase(const TDatime &date) override
Int_t DefineVariables(EMode mode=kDefine) override
Int_t DefineVariables(THaAnalysisObject::EMode mode=THaAnalysisObject::kDefine, const char *key_prefix="", const char *comment_subst="")
PMTCalib_t & GetCalib(size_t i)
Decoder::Module *Decoder::ChannelType type
Definition THaDetMap.h:197
virtual OptUInt_t LoadData(const THaEvData &evdata, const DigitizerHitInfo_t &hitinfo)
VecDetData_t fDetectorData
virtual Int_t GetView(const DigitizerHitInfo_t &hitinfo) const
Podd::PMTData * fRightPMTs
virtual Int_t DefineVariables(EMode mode=kDefine)
virtual Int_t StoreHit(const DigitizerHitInfo_t &hitinfo, UInt_t data)
Podd::PMTData * fLeftPMTs
virtual Int_t ReadDatabase(const TDatime &date)
RVec< PromoteType< T > > abs(const RVec< T > &v)
pair< unique_ptr< FADCData >, Int_t > MakeFADCData(const TDatime &date, THaDetectorBase *det)
Definition FADCData.cxx:27
STL namespace.
ClassImp(TPyArg)