FACT++  1.0
int main ( int  argc,
const char *  argv[] 
)

Definition at line 146 of file getevent.cc.

References data, Configuration::DoParse(), Configuration::Get(), Configuration::Has(), i, PrintHelp(), PrintUsage(), run, Configuration::SetPrintUsage(), SetupConfiguration(), and start().

147 {
148  Configuration conf(argv[0]);
149  conf.SetPrintUsage(PrintUsage);
150  SetupConfiguration(conf);
151 
152  if (!conf.DoParse(argc, argv, PrintHelp))
153  return 127;
154 
155  const string name = conf.Get<string>("target");
156 /*
157  if (!conf.Has("event"))
158  {
159  plainListTree(name);
160  return 0;
161  }
162 */
163  const uint32_t event = conf.Has("event") ? conf.Get<uint32_t>("event") : 0;
164 
165  zfits file(name);
166  if (!file)
167  {
168  cerr << name << ": " << strerror(errno) << endl;
169  return 1;
170  }
171 
172  // Php can only read 32bit ints
173  const uint32_t nRows = file.GetNumRows();
174 
175  const uint32_t nRoi = file.GetUInt("NROI");
176  const uint32_t nPix = file.GetUInt("NPIX");
177 
178  const bool isMC = file.HasKey("ISMC") && file.GetStr("ISMC")=="T";
179 
180  // Is drs calibration file?
181  const int8_t step = file.HasKey("STEP") ? file.GetUInt("STEP") : -1;
182 
183  const string strbeg = isMC ? "DATE" : "RUN"+to_string(step)+"-BEG";
184  const string strend = isMC ? "DATE" : "RUN"+to_string(step)+"-END";
185 
186  const double start = step==-1 && !isMC ? file.GetUInt("TSTARTI")+file.GetFloat("TSTARTF") : Time(file.GetStr(strbeg)).UnixDate();
187  const double stop = step==-1 && !isMC ? file.GetUInt("TSTOPI")+file.GetFloat("TSTOPF") : Time(file.GetStr(strend)).UnixDate();
188 
189  const bool isDrsCalib = file.HasKey("DRSCALIB") && file.GetStr("DRSCALIB")=="T";
190  const int16_t drsStep = isDrsCalib ? file.GetUInt("DRSSTEP") : step;
191  const string runType = step==-1 ? file.GetStr("RUNTYPE") : "";
192  const uint16_t scale = file.HasKey("SCALE") ? file.GetUInt("SCALE") : (step==-1?0:10);
193 
194  vector<char> run(80);
195  vector<int16_t> data(nRoi*nPix);
196  vector<float> mean(nRoi*nPix);
197  vector<uint32_t> unixTimeUTC(2);
198 
199  //uint32_t boardTime[40];
200  uint32_t eventNum;
201  //uint32_t numBoards;
202  //uint16_t startCellData[1440];
203  //uint16_t startCellTimeMarker[160];
204  //uint32_t triggerNum;
205  uint16_t triggerType;
206 
207  if (step==-1)
208  {
209  file.SetRefAddress("EventNum", eventNum);
210  //file.SetRefAddress("TriggerNum", triggerNum);
211  file.SetRefAddress("TriggerType", triggerType);
212  if (!isMC)
213  file.SetVecAddress("UnixTimeUTC", unixTimeUTC);
214  }
215 
216  /*
217  float energy, impact, phi, theta;
218  if (isMC)
219  {
220  file.SetRefAddress("MMcEvtBasic.fEnergy", energy);
221  file.SetRefAddress("MMcEvtBasic.fImpact", impact);
222  file.SetRefAddress("MMcEvtBasic.fTelescopeTheta", theta);
223  file.SetRefAddress("MMcEvtBasic.fTelescopePhi", phi);
224  }
225  */
226 
227  switch (step)
228  {
229  case 0: file.SetVecAddress("BaselineMean", mean); strcpy( run.data(), "DRS (pedestal 1024)"); break;
230  case 1: file.SetVecAddress("GainMean", mean); strcpy( run.data(), "DRS (gain)"); break;
231  case 2: file.SetVecAddress("TriggerOffsetMean", mean); strcpy( run.data(), "DRS (pedestal roi)"); break;
232  default: file.SetVecAddress("Data", data); strncpy(run.data(), runType.c_str(), 79); break;
233  }
234 
235  if (!file.GetRow(step==-1 ? event : 0))
236  return 2;
237 
238  if (step!=-1)
239  for (uint32_t i=0; i<nRoi*nPix; i++)
240  data[i] = round(mean[i]*10);
241 
242  cout.write(run.data(), 80);
243  cout.write((char*)&start, sizeof(double));
244  cout.write((char*)&stop, sizeof(double));
245  cout.write((char*)&drsStep, sizeof(drsStep));
246  cout.write((char*)&nRows, sizeof(nRows));
247  cout.write((char*)&scale, sizeof(scale));
248 
249  cout.write((char*)&nRoi, sizeof(nRoi));
250  cout.write((char*)&nPix, sizeof(nPix));
251  cout.write((char*)&eventNum, sizeof(eventNum));
252  //cout.write((char*)&triggerNum, sizeof(triggerNum));
253  cout.write((char*)&triggerType, sizeof(triggerType));
254  cout.write((char*)unixTimeUTC.data(), sizeof(uint32_t)*2);
255  cout.write((char*)data.data(), sizeof(int16_t)*nRoi*nPix);
256 
257  return 0;
258 }
int start(int initState)
Definition: feeserver.c:1740
int i
Definition: db_dim_client.c:21
Adds some functionality to boost::posix_time::ptime for our needs.
Definition: Time.h:30
void PrintHelp()
Definition: getevent.cc:64
void PrintUsage()
Definition: getevent.cc:54
Commandline parsing, resource file parsing and database access.
Definition: Configuration.h:9
static int run
Definition: dim_fork.cxx:9
float data[4 *1440]
Definition: zfits.h:16
void SetupConfiguration(Configuration &conf)
Definition: getevent.cc:29

+ Here is the call graph for this function: