Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DTACHit_factory.h
Go to the documentation of this file.
1 /*
2  * DTACHit_factory.h
3  *
4  * Created on: Mar 24, 2017
5  * Author: hovanes
6  */
7 
8 #ifndef LIBRARIES_TAC_DTACHIT_FACTORY_H_
9 #define LIBRARIES_TAC_DTACHIT_FACTORY_H_
10 
11 #include <vector>
12 using namespace std;
13 
14 #include <JANA/JFactory.h>
15 #include <JANA/JEventLoop.h>
16 #include <DANA/ReadWriteLock.h>
17 #include <TTAB/DTTabUtilities.h>
18 #include <DAQ/Df250PulseRawData.h>
19 
20 #include "DTACDigiHit.h"
21 #include "DTACTDCDigiHit.h"
22 #include "DTACHit.h"
23 
24 class DTACHit_factory: public jana::JFactory<DTACHit> {
25 protected:
26  double energyScale = 1.0;
27  double timeScaleADC = 0.0625; // ns
28  double timeBaseADC = -130.0; // ns
29  double timeBaseTDC = -130; // ns
30 
31  // calibration constants stored by channel
32  double energyGain = 1.0;
33  double adcPedestal = 100;
34  double adcTimeOffset = 0;
35  double tdcTimeOffsets = 0;
36  vector<double> timeWalkParameters { 9.27503, -0.548155, 20.48000, 328.0000 };
37 
38  static bool checkErrorsOnFADC;
40  static double timeWindowTDC;
41  static double timeDifferencInADCandTDC;
42 
43  static set<int> announcedRuns;
44 
45 public:
47  // TODO Auto-generated constructor stub
48  }
49  virtual ~DTACHit_factory() {
50  // TODO Auto-generated destructor stub
51  }
52 
53  virtual jerror_t init(void) override; ///< Called once at program start
54  virtual jerror_t brun(jana::JEventLoop *eventLoop, int32_t runnumber)
55  override; ///< Called everytime a new run number is detected
56  virtual jerror_t evnt(jana::JEventLoop *eventLoop, uint64_t eventnumber)
57  override; ///< Called every event
58  virtual jerror_t erun(void) override; ///< Called everytime run number changes, if brun has been called
59  virtual jerror_t fini(void) override; ///< Called after last event of last event source has been processed
60 
61  virtual void Reset_Data(void);
62  virtual void AppendData( DTACHit* hit ) { _data.push_back(hit) ;};
63 // virtual std::string SetTag( std::string tag ) ;
64 
65  virtual jerror_t readCCDB( jana::JEventLoop *loop );
66 
67  virtual DTACHit* findMatch(double tdcTime);
68 
69 
70  virtual void makeFADCHits(jana::JEventLoop *loop, uint64_t eventnumber);
71  virtual void makeTDCHits(jana::JEventLoop *loop, uint64_t eventnumber);
72 
73  static bool errorCheckIsNeededForFADC() {
74  return checkErrorsOnFADC;
75  }
76  static bool addRun(int runNumber) {
77  static pthread_mutex_t runListMutex = PTHREAD_MUTEX_INITIALIZER;
78  bool returnValue = false;
79  PlainLock printLock(runListMutex);
80  if (announcedRuns.count(runNumber) == 0) {
81  announcedRuns.insert(runNumber);
82  returnValue = true;
83  }
84  return returnValue;
85  }
86 
87  double getADCPedestal() const {
88  return adcPedestal;
89  }
90 
91  void setADCPedestal(double adcPedestal = 100) {
92  this->adcPedestal = adcPedestal;
93  }
94 
95  double getADCTimeOffset() const {
96  return adcTimeOffset;
97  }
98 
99  void setADCTimeOffset(double adcTimeOffset = 0) {
100  this->adcTimeOffset = adcTimeOffset;
101  }
102 
103  double getEnergyGain() const {
104  return energyGain;
105  }
106 
107  void setEnergyGain(double energyGain = 1.0) {
108  this->energyGain = energyGain;
109  }
110 
111  double getEnergyScale() const {
112  return energyScale;
113  }
114 
115  void setEnergyScale(double energyScale = 1.0) {
116  this->energyScale = energyScale;
117  }
118 
119  double getTDCTimeOffsets() const {
120  return tdcTimeOffsets;
121  }
122 
123  void setTDCTimeOffsets(double tdcTimeOffsets = 0) {
124  this->tdcTimeOffsets = tdcTimeOffsets;
125  }
126 
127  double getTimeBaseADC() const {
128  return timeBaseADC;
129  }
130 
131  void setTimeBaseADC(double timeBaseAdc = -130.0) {
132  timeBaseADC = timeBaseAdc;
133  }
134 
135  double getTimeBaseTDC() const {
136  return timeBaseTDC;
137  }
138 
139  void setTimeBaseTDC(double timeBaseTdc = -130) {
140  timeBaseTDC = timeBaseTdc;
141  }
142 
143  double getTimeScaleADC() const {
144  return timeScaleADC;
145  }
146 
147  void setTimeScaleADC(double timeScaleAdc = 0.0625) {
148  timeScaleADC = timeScaleAdc;
149  }
150 
151  const std::vector<double>& getTimeWalkParameters() const {
152  return timeWalkParameters;
153  }
154 
155  void setTimeWalkParameters(const std::vector<double>& timeWalkParameters) {
156  this->timeWalkParameters = timeWalkParameters;
157  }
158 };
159 
160 #endif /* LIBRARIES_TAC_DTACHIT_FACTORY_H_ */
virtual ~DTACHit_factory()
static set< int > announcedRuns
void setTimeBaseADC(double timeBaseAdc=-130.0)
void setEnergyGain(double energyGain=1.0)
void setTimeWalkParameters(const std::vector< double > &timeWalkParameters)
static bool useTimeWalkCorrections
static bool checkErrorsOnFADC
void setTDCTimeOffsets(double tdcTimeOffsets=0)
double getEnergyGain() const
void setADCTimeOffset(double adcTimeOffset=0)
double getTimeScaleADC() const
void setADCPedestal(double adcPedestal=100)
double getADCTimeOffset() const
double getEnergyScale() const
double getTimeBaseTDC() const
virtual void AppendData(DTACHit *hit)
void setTimeScaleADC(double timeScaleAdc=0.0625)
double getADCPedestal() const
static bool addRun(int runNumber)
static double timeWindowTDC
void setTimeBaseTDC(double timeBaseTdc=-130)
static bool errorCheckIsNeededForFADC()
static double timeDifferencInADCandTDC
double getTimeBaseADC() const
const std::vector< double > & getTimeWalkParameters() const
double getTDCTimeOffsets() const
void setEnergyScale(double energyScale=1.0)