FACT++  1.0
bool DataCalib::Open ( const RUN_HEAD h,
const FAD::RunDescription &  d 
)
virtual

Implements DataProcessorImp.

Definition at line 96 of file DataCalib.cc.

References Error(), fData, RUN_HEAD::NPix, RUN_HEAD::Nroi, RUN_HEAD::NroiTM, and DataWriteFits2::Open().

97 {
98  if (h.NPix != 1440)
99  {
100  Error("Number of pixels in header for run "+to_string(GetRunId())+" not 1440.");
101  return false;
102  }
103 
104  if (fProcessing)
105  {
106  Warn("Previous DRS calibration run not yet finished (current run "+to_string(GetRunId())+")");
107  return false;
108  }
109 
110  if (fData.fStep==3)
111  {
112  Warn("DRS Calibration already finished before current run "+to_string(GetRunId())+"... please restart!");
113  return false;
114  }
115 
116  if (fData.fStep!=2 && h.Nroi != 1024)
117  {
118  ostringstream msg;
119  msg << "Region of interest of run " << GetRunId() << " not 1024, but " << h.Nroi << " in step " << fData.fStep << " ... as it ought to be.";
120  Error(msg);
121  return false;
122  }
123 
124  vector<uint16_t> dac(8);
125 /*
126  // We don't check consistency over several boards because this is done
127  // by the eventCheck routine already
128  for (int i=0; i<h.NBoard; i++)
129  {
130  const PEVNT_HEADER &hh = h.FADhead[i];
131 
132  if (hh.start_package_flag==0)
133  continue;
134 
135  for (int j=0; j<8; j++)
136  dac[j] = hh.dac[j];
137 
138  break;
139  }
140 
141  for (int i=1; i<7; i++)
142  {
143  if (i==3 || dac[i]==dac[i+1])
144  continue;
145 
146  ostringstream msg;
147  msg << "Values of DAC" << i << " (" << dac[i] << ") and DAC" << i+1 <<" (" << dac[i+1] << ") do not match... cannot take DRS calibration!";
148  fMsg.Error(msg);
149  return false;
150  }
151 
152  if (fData.fStep>0)
153  {
154  for (int j=0; j<8; j++)
155  {
156  if (fData.fDAC[j]==dac[j])
157  continue;
158 
159  ostringstream msg;
160  msg << "DAC value from previous run (DAC" << j << "=" << fData.fDAC[j] << ") and current run ";
161  msg << "(DAC" << j << "=" << dac[j] << ") inconsistent... cannot take DRS calibration!";
162  fMsg.Error(msg);
163  return false;
164  }
165  }
166 
167  memcpy(fData.fDAC, dac.data(), 8*sizeof(uint16_t));
168 */
169  fProcessing = true;
170 
171  const bool hastm = h.Nroi<=512 && h.NroiTM>=2*h.Nroi;
172 
173  Reset();
174  InitSize(hastm ? 1600 : 1440, h.Nroi);
175 
177  fData.fNumTm = hastm ? 160 : 0;
178 
179  return DataWriteFits2::Open(h, d);
180 }
uint16_t NroiTM
Definition: FAD.h:102
uint32_t GetRunId() const
uint16_t fRoi
Definition: DrsCalib.h:1318
uint16_t fNumTm
Definition: DrsCalib.h:1319
bool Open(const RUN_HEAD &h, const FAD::RunDescription &d)
size_t fNumSamples
Definition: DrsCalib.h:20
void InitSize(uint16_t channels, uint16_t samples)
Definition: DrsCalib.h:43
int Error(const std::string &str)
Definition: MessageImp.h:49
static DrsCalibration fData
Definition: DataCalib.h:13
uint16_t Nroi
Definition: FAD.h:101
int Warn(const std::string &str)
Definition: MessageImp.h:48
uint32_t fStep
Definition: DrsCalib.h:1317
void Reset()
Definition: DrsCalib.h:33
uint16_t NPix
Definition: FAD.h:99
static bool fProcessing
Storage for mean and rms values.
Definition: DataCalib.h:19

+ Here is the call graph for this function: