QwAnalysis
QwBeamLine.cc
Go to the documentation of this file.
1 /**********************************************************\
2 * File: QwBeamLine.C *
3 * *
4 * Author: *
5 * Time-stamp: *
6 \**********************************************************/
7 
8 #include "QwBeamLine.h"
9 
10 // System headers
11 #include <iostream>
12 #include <stdexcept>
13 
14 // Qweak headers
15 #include "QwLog.h"
16 #define MYSQLPP_SSQLS_NO_STATICS
17 #include "QwParitySSQLS.h"
18 #include "QwParityDB.h"
19 
20 #include "QwPromptSummary.h"
21 
22 // Forward declarations
23 class QwParityDB;
24 //class QwDBInterface;
25 
26 // Register this subsystem with the factory
28 
29 //*****************************************************************//
31  //Handle command line options
32 }
33 
34 //*****************************************************************//
35 template <>
36 Int_t QwBeamLine::AddToElementList<VQwClock_ptr>(std::vector<VQwClock_ptr> &elementlist,
37  QwBeamDetectorID &detector_id)
38 {
39  if (detector_id.fTypeID == kQwClock){
40  VQwClock_ptr element(
41  VQwClock::Create(GetSubsystemName(),
42  detector_id.fdetectorname,
43  detector_id.fmoduletype) );
44  elementlist.push_back(element);
45  }
46  detector_id.fIndex = elementlist.size()-1;
47  return detector_id.fIndex;
48 }
49 //*****************************************************************//
50 template <>
51 Int_t QwBeamLine::AddToElementList<VQwBCM_ptr>(std::vector<VQwBCM_ptr> &elementlist,
52  QwBeamDetectorID &detector_id)
53 {
54  if (detector_id.fTypeID == kQwBCM){
55  VQwBCM_ptr element(
56  VQwBCM::Create(GetSubsystemName(),
57  detector_id.fdetectorname,
58  detector_id.fmoduletype) );
59  elementlist.push_back(element);
60  }
61  detector_id.fIndex = elementlist.size()-1;
62  return detector_id.fIndex;
63 }
64 //*****************************************************************//
65 template <>
66 Int_t QwBeamLine::AddToElementList<VQwBPM_ptr>(std::vector<VQwBPM_ptr> &elementlist,
67  QwBeamDetectorID &detector_id)
68 {
69  if (detector_id.fTypeID == kQwBPMStripline){
70  VQwBPM_ptr element(
71  VQwBPM::CreateStripline(GetSubsystemName(),
72  detector_id.fdetectorname,
73  detector_id.fmoduletype) );
74  elementlist.push_back(element);
75  }
76  detector_id.fIndex = elementlist.size()-1;
77  return detector_id.fIndex;
78 }
79 
80 //*****************************************************************//
81 template <typename TT>
82 Int_t QwBeamLine::AddToElementList(std::vector<TT> &elementlist,
83  QwBeamDetectorID &detector_id)
84 {
85  TT element(GetSubsystemName(), detector_id.fdetectorname);
86  elementlist.push_back(element);
87  detector_id.fIndex = elementlist.size()-1;
88  return detector_id.fIndex;
89 }
90 
91 
92 
93 //*****************************************************************//
94 Int_t QwBeamLine::LoadChannelMap(TString mapfile)
95 {
96  Bool_t ldebug=kFALSE;
97 
98  TString varname, varvalue;
99 
100  TString combotype, comboname, dev_name;
101 
102  Int_t index = 0;
103  Bool_t combolistdecoded;
104  Bool_t deviceok;
105 
106  std::vector<TString> fDeviceName;
107  std::vector<TString> fProperty;
108  std::vector<TString> fType;
109  std::vector<Double_t> fQWeight;
110  std::vector<Double_t> fXWeight;
111  std::vector<Double_t> fYWeight;
112  Double_t sumQweights = 0.0;
113 
114  std::vector<QwBeamDetectorID> clock_needed_list;
115 
116  QwParameterFile mapstr(mapfile.Data()); //Open the file
117  fDetectorMaps.insert(mapstr.GetParamFileNameContents());
118  mapstr.EnableGreediness();
119  mapstr.SetCommentChars("!");
120  mapstr.AddBreakpointKeyword("begin");
121  mapstr.AddBreakpointKeyword("end");
122 
123  while (mapstr.ReadNextLine()
124  && mapstr.SkipSection("PUBLISH") ){
125  UInt_t value = 0;
126  if (mapstr.PopValue("roc",value)){
127  // currentrocread=value;
128  RegisterROCNumber(value,0);
129  }
130  if (mapstr.PopValue("bank",value)){
131  // currentbankread=value;
132  RegisterSubbank(value);
133  }
134 
135  if (mapstr.HasVariablePair("=",varname,varvalue)){ // This is a declaration line. Decode it.
136  varname.ToLower();
137 
138  if (varname=="begin"){
139 
140  // Start to decode derived beamline devices combined+energy
141  deviceok = kTRUE;
142  combotype = varvalue;
143  combolistdecoded = kFALSE;
144 
145  TString dettype;
146 
147  while(mapstr.ReadNextLine()&&!combolistdecoded){
148  if (mapstr.HasVariablePair("=",varname,varvalue)){
149  varname.ToLower();
150  if (varname=="end"){
151  // calculate the total weights of the charge
152  sumQweights = 0.0;
153  for(size_t i=0;i<fDeviceName.size();i++)
154  sumQweights+=fQWeight[i];
155  combolistdecoded = kTRUE;
156  break;
157  }
158  }
159 
160  if (mapstr.PopValue("name",varvalue)){
161  comboname = varvalue;
162  }
163 
164  dev_name = mapstr.GetTypedNextToken<TString>();
165  dev_name.ToLower();
166  dettype = mapstr.GetTypedNextToken<TString>();
167  dettype.ToLower();
168 
169  // Check to see if the device being read is a valid physical device.
170  // If not, discard the combination.
171  index=GetDetectorIndex(GetQwBeamInstrumentType(dettype),dev_name);
172 
173  if (index == -1) {
174  QwError << "QwBeamLine::LoadChannelMap: Unknown device: "
175  << dev_name <<" used in "<< comboname
176  <<". This combination will not be decoded!"
177  << QwLog::endl;
178  deviceok = kFALSE;
179  combolistdecoded = kTRUE;
180  }else{
181  // Found the device
182  // Add to the array of names
183  fDeviceName.push_back(dev_name);
184 
185  // Read in the weights.
186  // For combined bpms and combined bcms these are charge weights.
187  // For the energy calculator these are the ratios of the transport matrix elements.
188  fQWeight.push_back(mapstr.GetTypedNextToken<Double_t>());
189 
190  // For combined BPMs,in addition, there are weights for the X & Y positions.
191  if(combotype == "combinedbpm"){
192  fXWeight.push_back(mapstr.GetTypedNextToken<Double_t>());
193  fYWeight.push_back(mapstr.GetTypedNextToken<Double_t>());
194  }
195 
196  // For the enrgy calculator there are device type and the specified beam parameters.
197  if(combotype == "energycalculator"){
198  fType.push_back(dettype);
199  fProperty.push_back(mapstr.GetTypedNextToken<TString>());
200  }
201  }
202  }
203 
204  // Now create the combined device
205  QwBeamDetectorID localComboID(-1, -1, comboname, combotype,
206  fBeamDetectorID.at(index).fmoduletype );
207 
208  localComboID.fdetectorname=comboname(0,comboname.Sizeof()-1);
209  localComboID.fIndex = GetDetectorIndex(localComboID.fTypeID,localComboID.fdetectorname);
210 
211  if(localComboID.fTypeID==kQwUnknownDeviceType){
212  QwError << "QwBeamLine::LoadChannelMap: Unknown detector type: "
213  << combotype <<", the detector "<<comboname<<" will not be decoded "
214  << QwLog::endl;
215  deviceok = kFALSE;
216  continue;
217  }
218 
219  if((localComboID.fIndex==-1) && deviceok) {
220 
221  // Decoding combined BCM array
222  if (localComboID.fTypeID == kQwCombinedBCM){
223 
224  VQwBCM_ptr localbcmcombo(
226  localComboID.fdetectorname,localComboID.fmoduletype));
227  fBCMCombo.push_back(localbcmcombo);
228 
229  for(size_t i=0;i<fDeviceName.size();i++){
230  index=GetDetectorIndex(GetQwBeamInstrumentType(dettype),fDeviceName[i]);
231  fBCMCombo[fBCMCombo.size()-1].get()->SetBCMForCombo(fBCM.at(index).get(),
232  fQWeight[i],sumQweights );
233  }
234  fDeviceName.clear();
235  fQWeight.clear();
236  localComboID.fIndex=fBCMCombo.size()-1;
237  }
238 
239  // Decoding combined BPM array.
240  if(localComboID.fTypeID== kQwCombinedBPM){
241  VQwBPM_ptr localbpmcombo(
243  localComboID.fdetectorname,localComboID.fmoduletype));
244  fBPMCombo.push_back(localbpmcombo);
245 
246  for(size_t i=0;i<fDeviceName.size();i++){
247  index=GetDetectorIndex(GetQwBeamInstrumentType(dettype),fDeviceName[i]);
248  fBPMCombo[fBPMCombo.size()-1].get()->SetBPMForCombo(
249  fStripline.at(index).get(), fQWeight[i],fXWeight[i],
250  fYWeight[i],sumQweights );
251 
252  }
253  fDeviceName.clear();
254  fQWeight.clear();
255  fXWeight.clear();
256  fYWeight.clear();
257  localComboID.fIndex=fBPMCombo.size()-1;
258  }
259 
260  // Decoding energy calculator.
261  if(localComboID.fTypeID== kQwEnergyCalculator){
262 
263  QwEnergyCalculator localecalculator(GetSubsystemName(), localComboID.fdetectorname);
264  fECalculator.push_back(localecalculator);
265 
266  for(size_t i=0;i<fDeviceName.size();i++){
267  index=GetDetectorIndex(GetQwBeamInstrumentType(fType[i]),fDeviceName[i]);
268 
269  if ( GetQwBeamInstrumentType(fType[i]) == kQwBPMStripline)
270  fECalculator[fECalculator.size()-1].Set(fStripline.at(index).get(),fType[i],fProperty[i],fQWeight[i]);
271 
272  if ( GetQwBeamInstrumentType(fType[i]) == kQwCombinedBPM)
273  fECalculator[fECalculator.size()-1].Set(fBPMCombo.at(index).get(),fType[i],fProperty[i],fQWeight[i]);
274 
275  }
276 
277  fDeviceName.clear();
278  fQWeight.clear();
279 
280  fProperty.clear();
281  fType.clear();
282  localComboID.fIndex=fECalculator.size()-1;
283  }
284  }
285  // Use only the combinations that are of known type and has known physical devices.
286  if(deviceok)
287  fBeamDetectorID.push_back(localComboID);
288  }
289 
290  QwError << "At end of processing the combined device " << QwLog::endl;
291 
292  } else{
293  // Start to decode the physical beamline devices
294  QwBeamDetectorID localBeamDetectorID(GetSubbankIndex(), mapstr);
295  Bool_t lineok = localBeamDetectorID.ReportInitErrors();
296  if (! lineok) continue;
297 
298  localBeamDetectorID.fIndex=
299  GetDetectorIndex(localBeamDetectorID.fTypeID,
300  localBeamDetectorID.fdetectorname);
301 
302  if(localBeamDetectorID.fIndex==-1){
303  Int_t index;
304  VQwDataElement* local_element = NULL;
305 
306  if(localBeamDetectorID.fTypeID == kQwHaloMonitor){
307  index = AddToElementList(fHaloMonitor, localBeamDetectorID);
308  local_element = &(fHaloMonitor.at(index));
309  }
310  if(localBeamDetectorID.fTypeID==kQwBPMCavity){
311  index = AddToElementList(fCavity, localBeamDetectorID);
312  local_element = &(fCavity.at(index));
313  }
314  if(localBeamDetectorID.fTypeID== kQwBPMStripline){
315  index = AddToElementList(fStripline, localBeamDetectorID);
316  local_element = fStripline.at(index).get();
317  }
318  if(localBeamDetectorID.fTypeID== kQwBCM){
319  index = AddToElementList(fBCM, localBeamDetectorID);
320  local_element = fBCM.at(index).get();
321  }
322  if(localBeamDetectorID.fTypeID== kQwClock ) {
323  index = AddToElementList(fClock, localBeamDetectorID);
324  local_element = fClock.at(index).get();
325  }
326  if(localBeamDetectorID.fTypeID== kQwQPD){
327  index = AddToElementList(fQPD, localBeamDetectorID);
328  local_element = &(fQPD.at(index));
329  }
330  if(localBeamDetectorID.fTypeID== kQwLinearArray){
331  index = AddToElementList(fLinearArray, localBeamDetectorID);
332  local_element = &(fLinearArray.at(index));
333  }
334 
335  local_element->LoadChannelParameters(mapstr);
336  if (local_element->NeedsExternalClock()){
337  QwDebug << "Try to push device "
338  << local_element->GetElementName()
339  << " (address=" << std::hex << local_element
340  << ") onto the clock_needed_list"
341  << QwLog::endl;
342  clock_needed_list.push_back(localBeamDetectorID);
343  }
344  }
345 
346 
347 
348  fBeamDetectorID.push_back(localBeamDetectorID);
349  }
350  }
351 
352  // Now load the variables to publish
353  mapstr.RewindToFileStart();
354  QwParameterFile *section;
355  std::vector<TString> publishinfo;
356  while ((section=mapstr.ReadNextSection(varvalue))) {
357  if (varvalue == "PUBLISH") {
358  fPublishList.clear();
359  while (section->ReadNextLine()) {
360  section->TrimComment(); // Remove everything after a comment character
361  section->TrimWhitespace(); // Get rid of leading and trailing spaces
362  for (int ii = 0; ii < 4; ii++) {
363  varvalue = section->GetTypedNextToken<TString>();
364  if (varvalue.Length()) {
365  publishinfo.push_back(varvalue);
366  }
367  }
368  if (publishinfo.size() == 4)
369  fPublishList.push_back(publishinfo);
370  publishinfo.clear();
371  }
372  }
373  delete section;
374  }
375  // Print list of variables to publish
376  QwMessage << "Variables to publish:" << QwLog::endl;
377  for (size_t jj = 0; jj < fPublishList.size(); jj++)
378  QwMessage << fPublishList.at(jj).at(0) << " " << fPublishList.at(jj).at(1) << " "
379  << fPublishList.at(jj).at(2) << " " << fPublishList.at(jj).at(3) << QwLog::endl;
380 
381 
382  if(ldebug){
383  std::cout<<"QwBeamLine::Done with Load map channel \n";
384  for(size_t i=0;i<fBeamDetectorID.size();i++)
385  fBeamDetectorID[i].Print();
386  }
387 
388  // Now propagate clock pointers to those channels that need it
389  index = 0;
390  VQwDataElement* local_element;
391  std::string clockname;
392  for (size_t i=0; i<clock_needed_list.size();i++ ) {
393  local_element = GetElement(clock_needed_list[i]);
394  clockname = local_element->GetExternalClockName();
395  if (clockname.empty()){
396  QwWarning << "QwBeamLine::LoadChannelMap "
397  << "Device, " << local_element->GetElementName()
398  << " needs a reference clock, but the reference clock name is empty"
399  << QwLog::endl;
400  } else {
401  index = GetDetectorIndex(kQwClock,clockname);
402  if( index >= 0 ){
403  QwMessage << "QwBeamLine::LoadChannelMap "
404  << "Setting " << fClock.at(index).get()->GetElementName()
405  << " as the reference clock for channel "
406  << local_element->GetElementName()
407  << QwLog::endl;
408  local_element->SetExternalClockPtr(fClock.at(index).get()->GetTime());
409  } else {
410  QwWarning << "QwBeamLine::LoadChannelMap "
411  << "Cannot find clock, " << local_element->GetExternalClockName()
412  << ", needed by device, " << local_element->GetElementName()
413  << QwLog::endl;
414  }
415  }
416  }
417  ldebug=kFALSE;
418 
419  mapstr.Close(); // Close the file (ifstream)
420  return 0;
421 }
422 
423 
424 //*****************************************************************//
425 Int_t QwBeamLine::LoadEventCuts(TString filename)
426 {
427  Int_t eventcut_flag = 1;
428 
429  // Open the file
430  QwParameterFile mapstr(filename.Data());
431  fDetectorMaps.insert(mapstr.GetParamFileNameContents());
432  while (mapstr.ReadNextLine()){
433  mapstr.TrimComment('!'); // Remove everything after a '!' character.
434  mapstr.TrimWhitespace(); // Get rid of leading and trailing spaces.
435  if (mapstr.LineIsEmpty()) continue;
436 
437  TString varname, varvalue;
438  if (mapstr.HasVariablePair("=",varname,varvalue)){
439  if (varname == "EVENTCUTS"){
440  eventcut_flag = QwParameterFile::GetUInt(varvalue);
441  }
442  }
443  else{
444  TString device_type = mapstr.GetTypedNextToken<TString>();
445  device_type.ToLower();
446  TString device_name = mapstr.GetTypedNextToken<TString>();
447  device_name.ToLower();
448 
449  Int_t det_index = GetDetectorIndex(GetQwBeamInstrumentType(device_type),device_name);
450  if (det_index == -1) {
451  QwWarning << " Device not found " << device_name << " of type " << device_type << QwLog::endl;
452  continue;
453  }
454 
455  if (device_type == GetQwBeamInstrumentTypeName(kQwBCM)){
456  Double_t LLX = mapstr.GetTypedNextToken<Double_t>(); //lower limit for BCM value
457  Double_t ULX = mapstr.GetTypedNextToken<Double_t>(); //upper limit for BCM value
458  varvalue = mapstr.GetTypedNextToken<TString>();//global/loacal
459  Double_t stabilitycut = mapstr.GetTypedNextToken<Double_t>();
460  varvalue.ToLower();
461  QwMessage<<"QwBeamLine Error Code passing to QwBCM "<<GetGlobalErrorFlag(varvalue,eventcut_flag,stabilitycut)<<QwLog::endl;
462  fBCM[det_index].get()->SetSingleEventCuts(GetGlobalErrorFlag(varvalue,eventcut_flag,stabilitycut),LLX,ULX,stabilitycut);//(fBCMEventCuts);
463  }
464  else if (device_type == GetQwBeamInstrumentTypeName(kQwHaloMonitor)){
465  Double_t LLX = mapstr.GetTypedNextToken<Double_t>(); //lower limit for HaloMonitor value
466  Double_t ULX = mapstr.GetTypedNextToken<Double_t>(); //upper limit for HaloMonitor value
467  varvalue = mapstr.GetTypedNextToken<TString>();//global/loacal
468  Double_t stabilitycut = mapstr.GetTypedNextToken<Double_t>();
469  varvalue.ToLower();
470  QwMessage<<"QwBeamLine Error Code passing to QwHaloMonitor "<<GetGlobalErrorFlag(varvalue,eventcut_flag,stabilitycut)<<QwLog::endl;
471  fHaloMonitor[det_index].SetSingleEventCuts(GetGlobalErrorFlag(varvalue,eventcut_flag,stabilitycut),LLX,ULX,stabilitycut);//(fBCMEventCuts);
472  }
473  else if (device_type ==GetQwBeamInstrumentTypeName(kQwEnergyCalculator)){
474  Double_t LLX = mapstr.GetTypedNextToken<Double_t>(); //lower limit for energy
475  Double_t ULX = mapstr.GetTypedNextToken<Double_t>(); //upper limit for energy
476  varvalue = mapstr.GetTypedNextToken<TString>();//global/loacal
477  Double_t stabilitycut = mapstr.GetTypedNextToken<Double_t>();
478  varvalue.ToLower();
479  QwMessage<<"QwBeamLine Error Code passing to QwEnergyCalculator "<<GetGlobalErrorFlag(varvalue,eventcut_flag,stabilitycut)<<QwLog::endl;
480  fECalculator[det_index].SetSingleEventCuts(GetGlobalErrorFlag(varvalue,eventcut_flag,stabilitycut),LLX,ULX,stabilitycut);//(fEnergyEventCuts);
481  }
482  else if (device_type == GetQwBeamInstrumentTypeName(kQwBPMStripline)){
483  TString channel_name = mapstr.GetTypedNextToken<TString>();
484  channel_name.ToLower();
485  Double_t LLX = mapstr.GetTypedNextToken<Double_t>(); //lower limit for BPMStripline X
486  Double_t ULX = mapstr.GetTypedNextToken<Double_t>(); //upper limit for BPMStripline X
487  varvalue = mapstr.GetTypedNextToken<TString>();//global/loacal
488  Double_t stabilitycut = mapstr.GetTypedNextToken<Double_t>();
489  varvalue.ToLower();
490  //QwMessage<<"QwBeamLine:QwBPMStripline "<<channel_name<<" "<<varvalue<<" "<<stabilitycut<<QwLog::endl;
491  QwMessage<<"QwBeamLine Error Code passing to QwBPMStripline "<<GetGlobalErrorFlag(varvalue,eventcut_flag,stabilitycut)<<" stability "<<stabilitycut <<QwLog::endl;
492  fStripline[det_index].get()->SetSingleEventCuts(channel_name, GetGlobalErrorFlag(varvalue,eventcut_flag,stabilitycut), LLX, ULX, stabilitycut);
493  }
494  else if (device_type == GetQwBeamInstrumentTypeName(kQwQPD)){
495  TString channel_name = mapstr.GetTypedNextToken<TString>();
496  channel_name.ToLower();
497  Double_t LLX = mapstr.GetTypedNextToken<Double_t>(); //lower limit for QPD X
498  Double_t ULX = mapstr.GetTypedNextToken<Double_t>(); //upper limit for QPD X
499  varvalue = mapstr.GetTypedNextToken<TString>();//global/loacal
500  Double_t stabilitycut = mapstr.GetTypedNextToken<Double_t>();
501  varvalue.ToLower();
502  QwMessage<<"QwBeamLine Error Code passing to QwQPD "<<GetGlobalErrorFlag(varvalue,eventcut_flag,stabilitycut)<<QwLog::endl;
503  fQPD[det_index].SetSingleEventCuts(channel_name, GetGlobalErrorFlag(varvalue,eventcut_flag,stabilitycut), LLX, ULX, stabilitycut);
504  }
505  else if (device_type == GetQwBeamInstrumentTypeName(kQwLinearArray)){
506  TString channel_name = mapstr.GetTypedNextToken<TString>();
507  channel_name.ToLower();
508  Double_t LLX = mapstr.GetTypedNextToken<Double_t>(); //lower limit for LinearArray X
509  Double_t ULX = mapstr.GetTypedNextToken<Double_t>(); //upper limit for LinearArray X
510  varvalue = mapstr.GetTypedNextToken<TString>();//global/loacal
511  Double_t stabilitycut = mapstr.GetTypedNextToken<Double_t>();
512  varvalue.ToLower();
513  QwMessage<<"QwBeamLine Error Code passing to QwLinearArray "<<GetGlobalErrorFlag(varvalue,eventcut_flag,stabilitycut)<<QwLog::endl;
514  fLinearArray[det_index].SetSingleEventCuts(channel_name, GetGlobalErrorFlag(varvalue,eventcut_flag,stabilitycut), LLX, ULX, stabilitycut);
515  }
516  else if (device_type == GetQwBeamInstrumentTypeName(kQwBPMCavity)){
517  TString channel_name = mapstr.GetTypedNextToken<TString>();
518  channel_name.ToLower();
519  Double_t LLX = mapstr.GetTypedNextToken<Double_t>(); //lower limit for cavity bpm X
520  Double_t ULX = mapstr.GetTypedNextToken<Double_t>(); //upper limit for cavity bpm X
521  varvalue = mapstr.GetTypedNextToken<TString>();//global/loacal
522  Double_t stabilitycut = mapstr.GetTypedNextToken<Double_t>();
523  varvalue.ToLower();
524  QwMessage<<"QwBeamLine Error Code passing to QwBPMCavity "<<GetGlobalErrorFlag(varvalue,eventcut_flag,stabilitycut)<<" "<<det_index<<QwLog::endl;
525  fCavity[det_index].SetSingleEventCuts(channel_name, GetGlobalErrorFlag(varvalue,eventcut_flag,stabilitycut), LLX, ULX, stabilitycut);
526  }
527  else if (device_type == GetQwBeamInstrumentTypeName(kQwCombinedBCM)){
528  Double_t LLX = mapstr.GetTypedNextToken<Double_t>(); //lower limit for BCM value
529  Double_t ULX = mapstr.GetTypedNextToken<Double_t>(); //upper limit for BCM value
530  varvalue = mapstr.GetTypedNextToken<TString>();//global/loacal
531  Double_t stabilitycut = mapstr.GetTypedNextToken<Double_t>();
532  varvalue.ToLower();
533  QwMessage<<"QwBeamLine Error Code passing to QwCombinedBCM "<<GetGlobalErrorFlag(varvalue,eventcut_flag,stabilitycut)<<QwLog::endl;
534  fBCMCombo[det_index].get()->PrintInfo();
535  fBCMCombo[det_index].get()->SetSingleEventCuts(GetGlobalErrorFlag(varvalue,eventcut_flag,stabilitycut), LLX, ULX, stabilitycut);
536 
537  }
538  else if (device_type == GetQwBeamInstrumentTypeName(kQwCombinedBPM)){
539  TString channel_name = mapstr.GetTypedNextToken<TString>();
540  channel_name.ToLower();
541 
542  Double_t LLX = mapstr.GetTypedNextToken<Double_t>(); //lower limit for combined bpm X
543  Double_t ULX = mapstr.GetTypedNextToken<Double_t>(); //upper limit for combined bpm X
544  varvalue = mapstr.GetTypedNextToken<TString>();//global/loacal
545  Double_t stabilitycut = mapstr.GetTypedNextToken<Double_t>();
546  varvalue.ToLower();
547  QwMessage<<"QwBeamLine Error Code passing to QwCombinedBPM "<<GetGlobalErrorFlag(varvalue,eventcut_flag,stabilitycut)<<QwLog::endl;
548  fBPMCombo[det_index].get()->SetSingleEventCuts(channel_name, GetGlobalErrorFlag(varvalue,eventcut_flag,stabilitycut), LLX, ULX, stabilitycut);
549  }
550 
551  }
552 
553  }
554 
555 
556  //update the event cut ON/OFF for all the devices
557  //std::cout<<"EVENT CUT FLAG"<<eventcut_flag<<std::endl;
558  for (size_t i=0;i<fStripline.size();i++)
559  fStripline[i].get()->SetEventCutMode(eventcut_flag);
560 
561  for (size_t i=0;i<fQPD.size();i++)
562  fQPD[i].SetEventCutMode(eventcut_flag);
563 
564  for (size_t i=0;i<fLinearArray.size();i++)
565  fLinearArray[i].SetEventCutMode(eventcut_flag);
566 
567  for (size_t i=0;i<fCavity.size();i++)
568  fCavity[i].SetEventCutMode(eventcut_flag);
569 
570  for (size_t i=0;i<fBCM.size();i++)
571  fBCM[i].get()->SetEventCutMode(eventcut_flag);
572 
573  for (size_t i=0;i<fClock.size();i++)
574  fClock[i].get()->SetEventCutMode(eventcut_flag);
575 
576  for (size_t i=0;i<fHaloMonitor.size();i++){
577  fHaloMonitor[i].SetEventCutMode(eventcut_flag);
578  }
579 
580  for (size_t i=0;i<fBCMCombo.size();i++)
581  fBCMCombo[i].get()->SetEventCutMode(eventcut_flag);
582 
583  for (size_t i=0;i<fBPMCombo.size();i++)
584  fBPMCombo[i].get()->SetEventCutMode(eventcut_flag);
585 
586  for (size_t i=0;i<fECalculator.size();i++)
587  fECalculator[i].SetEventCutMode(eventcut_flag);
588 
589  fQwBeamLineErrorCount=0; //set the error counter to zero
590 
591  mapstr.Close(); // Close the file (ifstream)
592  return 0;
593 }
594 
595 
596 //*****************************************************************//
597 Int_t QwBeamLine::LoadGeometryDefinition(TString mapfile){
598  Bool_t ldebug=kFALSE;
599  TString varname, varvalue;
600  Int_t lineread=1;
601  Int_t index = 0;
602  TString devname,devtype;
603  TString melement;
604  Double_t devOffsetX = 0,devOffsetY = 0, devOffsetZ = 0;
605  Double_t devSENfactor = 0, devAlphaX = 0, devAlphaY = 0;
606  TString rotation_stat;
607  VQwBPM * bpm = NULL;
608 
609  if(ldebug)std::cout<<"QwBeamLine::LoadGeometryParameters("<< mapfile<<")\n";
610 
611  QwParameterFile mapstr(mapfile.Data()); //Open the file
612  fDetectorMaps.insert(mapstr.GetParamFileNameContents());
613  while (mapstr.ReadNextLine()){
614  lineread+=1;
615  if(ldebug)std::cout<<" line read so far ="<<lineread<<"\n";
616  mapstr.TrimComment('!');
617  mapstr.TrimWhitespace();
618 
619  if (mapstr.LineIsEmpty()) continue;
620 
621  Bool_t notfound=kTRUE;
622 
623  devtype = mapstr.GetTypedNextToken<TString>();
624  devtype.ToLower();
625  devtype.Remove(TString::kBoth,' ');
626  devname = mapstr.GetTypedNextToken<TString>();
627  devname.ToLower();
628  devname.Remove(TString::kBoth,' ');
629 
631  QwError << "Error! Unknown detector type '"<<devtype
632  << "' in Geometry file!"<<QwLog::endl;
633  /*If the device type is unknown there is no point in going through the rest of the specs for that device*/
634  continue;
635  }
636 
637  index=GetDetectorIndex(GetQwBeamInstrumentType(devtype),devname);
638  if( index<0 ) {
639  /*Detector name isn't recognized. Ignore it!*/
640  QwWarning << "Unrecognized detector name '" << devname
641  << "' in Geometry file. This may not be a problem, "
642  << "if we're using a reduced channel map."
643  << QwLog::endl;
644  }
645  else {
646  devOffsetX = mapstr.GetTypedNextToken<Double_t>(); // X offset
647  devOffsetY = mapstr.GetTypedNextToken<Double_t>(); // Y offset
648  devOffsetZ = mapstr.GetTypedNextToken<Double_t>(); // Z offset
649  devSENfactor = mapstr.GetTypedNextToken<Double_t>(); // sensivity scaling factor
650  devAlphaX = mapstr.GetTypedNextToken<Double_t>(); // alpha X
651  devAlphaY = mapstr.GetTypedNextToken<Double_t>(); // alpha Y
652 
653 
654  /*If the device is a bpm stripline, assign the rotations and gains*/
656  bpm = fStripline.at(index).get();
657  AssignGeometry(&mapstr,bpm);
658  }
659 
660 
661  if(ldebug==1){
662  std::cout<<"####################\n";
663  std::cout<<"! device type, device_name, Xoffset, Yoffset, Zoffset, BSEN scaling factor, AlpaX, AlpaY\n"<<std::endl;
664  std::cout<<GetQwBeamInstrumentType(devtype)<<" / "
665  <<devname <<" / "
666  <<devOffsetX <<" / "
667  <<devOffsetY <<" / "
668  <<devOffsetZ <<" / "
669  <<devSENfactor <<" / "
670  <<devAlphaX <<" / "
671  <<devAlphaY <<" / "
672  <<std::endl;
673  }
674 
675 
676  while(notfound){
678  //Load bpm offsets
679  if(index == -1){
680  QwWarning << "QwBeamLine::LoadGeometryDefinition: Unknown bpm in qweak_beamline_geometry.map: "
681  <<devname
682  <<QwLog::endl;
683  notfound=kFALSE;
684  continue;
685  }
686 
687  TString localname = fStripline.at(index).get()->GetElementName();
688  localname.ToLower();
689  if(ldebug) std::cout<<"element name =="<<localname
690  <<"== to be compared to =="<<devname<<"== \n";
691 
692  if(localname==devname){
693  if(ldebug) std::cout<<" I found the bpm !\n";
694  bpm->GetSurveyOffsets(devOffsetX,devOffsetY,devOffsetZ);
695  bpm->GetElectronicFactors(devSENfactor,devAlphaX, devAlphaY);
696 
697  // If nothing is specified, a default rotation of 45 degrees is implied.
698  notfound=kFALSE;
699  }
700  }
701  else if (GetQwBeamInstrumentType(devtype)==kQwCombinedBPM){
702  //Load combined bpm offsets which are, ofcourse, target position in the beamline
703  if(index == -1){
704  QwError << "QwBeamLine::LoadGeometryDefinition: Unknown combined bpm in qweak_beamline_geometry.map: "
705  <<devname<<" Check the combined bpm names!\n "
706  << QwLog::endl;
707  notfound=kFALSE;
708  continue;
709  }
710 
711  TString localname = fBPMCombo.at(index).get()->GetElementName();
712  localname.ToLower();
713  if(ldebug)
714  std::cout<<"element name =="<<localname<<"== to be compared to =="<<devname<<"== \n";
715 
716  if(localname==devname){
717  if(ldebug) std::cout<<" I found the combinedbpm !\n";
718  fBPMCombo.at(index).get()->GetSurveyOffsets(devOffsetX,devOffsetY,devOffsetZ);
719  notfound=kFALSE;
720  }
721  }
722  else if(GetQwBeamInstrumentType(devtype)==kQwBPMCavity){
723  //Load cavity bpm offsets
724  if(index == -1){
725  QwError << "QwBeamLine::LoadGeometryDefinition: Unknown bpm : "
726  <<devname<<" will not be asigned with geometry parameters. \n"
727  <<QwLog::endl;
728  notfound=kFALSE;
729  continue;
730  }
731  TString localname = fCavity.at(index).GetElementName();
732  localname.ToLower();
733  if(ldebug) std::cout<<"element name =="<<localname
734  <<"== to be compared to =="<<devname<<"== \n";
735 
736  if(localname==devname){
737  if(ldebug) std::cout<<" I found the cavity bpm !\n";
738  fCavity.at(index).GetSurveyOffsets(devOffsetX,devOffsetY,devOffsetZ);
739  notfound=kFALSE;
740  }
741  }
742  else if(GetQwBeamInstrumentType(devtype)==kQwQPD){
743  //Load QPD calibration factors
744  if(index == -1){
745  QwError << "QwBeamLine::LoadGeometryDefinition: Unknown QPD : "
746  <<devname<<" will not be asigned with calibration factors. \n"
747  <<QwLog::endl;
748  notfound=kFALSE;
749  continue;
750  }
751  TString localname = fQPD.at(index).GetElementName();
752  localname.ToLower();
753  if(ldebug) std::cout<<"element name =="<<localname
754  <<"== to be compared to =="<<devname<<"== \n";
755 
756  if(localname==devname){
757  if(ldebug) std::cout<<" I found the QPD !\n";
758  fQPD.at(index).GetCalibrationFactors(devAlphaX, devAlphaY);
759  notfound=kFALSE;
760  }
761  }
762  else QwError<<" QwBeamLine::LoadGeometryDefinition: Unknown device type :"<<devtype<<". Are you sure we have this in the beamline? I am skipping this."<<QwLog::endl;
763  }
764  }
765  }
766 
767  if(ldebug) std::cout<<" line read in the geometry file ="<<lineread<<" \n";
768 
769  ldebug=kFALSE;
770  mapstr.Close(); // Close the file (ifstream)
771  return 0;
772 
773 }
774 
775 
777 {
778 
779  Bool_t ldebug = kFALSE;
780 
781  TString token = "0";
782  TString angle,xgain,ygain;
783  Double_t rotation_angle = 0;
784 
785  while(token!=""){
786  token= mapstr->GetTypedNextToken<TString>();
787  token.Remove(TString::kBoth,'\0');
788 
789  if(token.Contains("unrotated")){
790  if(ldebug) std::cout<<" unrotated "<<std::endl;
791  bpm->SetRotationOff();
792  }
793  else if(token.Contains("rotation")){
794  // If the status is 'rotated'
795 
796  // If a specific rotation angle is given read that
797  if(token.Contains("=")){
798  angle = token.Remove(0,9);
799  rotation_angle = atof(angle);
800  if(ldebug) std::cout<<"Rotation angle = "<<rotation_angle<<std::endl;
801  bpm->SetRotation(rotation_angle);
802  }
803  }
804  // If nothing is specified for rotation, a default rotation of 45 degrees is implied.
805 
806  if(token.Contains("xgain")){
807  xgain = token.Remove(0,6);
808  if(ldebug) std::cout<<" xgain ="<<xgain<<std::endl;
809  bpm->SetGains("X", atof(xgain));
810  }
811 
812  if(token.Contains("ygain")){
813  ygain = token.Remove(0,6);
814  if(ldebug) std::cout<<" ygain ="<<ygain<<std::endl;
815  bpm->SetGains("Y", atof(ygain));
816  }
817  }
818 }
819 
820 //*****************************************************************//
821 Int_t QwBeamLine::LoadInputParameters(TString pedestalfile)
822 {
823  Bool_t ldebug=kFALSE;
824 
825  Int_t lineread=1;
826 
827  if(ldebug)std::cout<<"QwBeamLine::LoadInputParameters("<< pedestalfile<<")\n";
828 
829  QwParameterFile mapstr(pedestalfile.Data()); //Open the file
830  fDetectorMaps.insert(mapstr.GetParamFileNameContents());
831 
832  while (mapstr.ReadNextLine())
833  {
834  lineread+=1;
835  if(ldebug)std::cout<<" line read so far ="<<lineread<<"\n";
836  mapstr.TrimComment('!'); // Remove everything after a '!' character.
837  mapstr.TrimWhitespace(); // Get rid of leading and trailing spaces.
838  if (mapstr.LineIsEmpty()) continue;
839  else
840  {
841  TString varname = mapstr.GetTypedNextToken<TString>(); //name of the channel
842  varname.ToLower();
843  varname.Remove(TString::kBoth,' ');
844  Double_t varped = mapstr.GetTypedNextToken<Double_t>(); // value of the pedestal
845  Double_t varcal = mapstr.GetTypedNextToken<Double_t>(); // value of the calibration factor
846  /*Double_t varweight = */ mapstr.GetTypedNextToken<Double_t>(); // value of the statistical weight
847 
848  //if(ldebug) std::cout<<"inputs for channel "<<varname
849  // <<": ped="<<varped<<": cal="<<varcal<<": weight="<<varweight<<"\n";
850  Bool_t notfound=kTRUE;
851 
852  if(notfound) {
853 
854  for(size_t i=0;i<fStripline.size();i++)
855  {
856  for(int j=0;j<4;j++)
857  {
858  TString localname = fStripline[i].get()->GetSubElementName(j);
859  localname.ToLower();
860  if(ldebug) std::cout<<"Stripline element name =="<<localname
861  <<"== to be compared to =="<<varname<<"== \n";
862  if(localname==varname)
863  {
864  if(ldebug) std::cout<<" I found it !\n";
865  fStripline[i].get()->SetSubElementPedestal(j,varped);
866  fStripline[i].get()->SetSubElementCalibrationFactor(j,varcal);
867  notfound=kFALSE;
868  j=5;
869  i=fStripline.size()+1;
870  }
871  }
872  }
873 
874  for(size_t i=0;i<fQPD.size();i++)
875  {
876  for(int j=0;j<4;j++)
877  {
878  TString localname = fQPD[i].GetSubElementName(j);
879  localname.ToLower();
880  if(ldebug) std::cout<<"QPD element name =="<<localname
881  <<"== to be compared to =="<<varname<<"== \n";
882  if(localname==varname)
883  {
884  if(ldebug) std::cout<<" I found it !\n";
885  fQPD[i].SetSubElementPedestal(j,varped);
886  fQPD[i].SetSubElementCalibrationFactor(j,varcal);
887  notfound=kFALSE;
888  j=5;
889  i=fQPD.size()+1;
890  }
891  }
892  }
893 
894  for(size_t i=0;i<fLinearArray.size();i++)
895  {
896  for(int j=0;j<8;j++)
897  {
898  TString localname = fLinearArray[i].GetSubElementName(j);
899  localname.ToLower();
900  if(ldebug) std::cout<<"LinearArray element name =="<<localname
901  <<"== to be compared to =="<<varname<<"== \n";
902  if(localname==varname)
903  {
904  if(ldebug) std::cout<<" I found it !\n";
905  fLinearArray[i].SetSubElementPedestal(j,varped);
906  fLinearArray[i].SetSubElementCalibrationFactor(j,varcal);
907  notfound=kFALSE;
908  j=9;
909  i=fLinearArray.size()+1;
910  }
911  }
912  }
913 
914  for(size_t i=0;i<fCavity.size();i++)
915  {
916  for(int j=0;j<2;j++)
917  {
918  TString localname = fCavity[i].GetSubElementName(j);
919  localname.ToLower();
920  if(ldebug) std::cout<<"Cavity element name =="<<localname
921  <<"== to be compared to =="<<varname<<"== \n";
922  if(localname==varname)
923  {
924  if(ldebug) std::cout<<" I found it !\n";
925  fCavity[i].SetSubElementPedestal(j,varped);
926  fCavity[i].SetSubElementCalibrationFactor(j,varcal);
927  notfound=kFALSE;
928  j=3;
929  i=fCavity.size()+1;
930  }
931  }
932  }
933 
934  for(size_t i=0;i<fBCM.size();i++) {
935  if(fBCM[i].get()->GetElementName()==varname)
936  {
937  fBCM[i].get()->SetPedestal(varped);
938  fBCM[i].get()->SetCalibrationFactor(varcal);
939  i=fBCM.size()+1;
940  notfound=kFALSE;
941  i=fBCM.size()+1;
942  }
943  }
944  for(size_t i=0;i<fClock.size();i++) {
945  if(fClock[i].get()->GetElementName()==varname)
946  {
947  fClock[i].get()->SetPedestal(varped);
948  fClock[i].get()->SetCalibrationFactor(varcal);
949  i=fClock.size()+1;
950  notfound=kFALSE;
951  i=fClock.size()+1;
952  }
953  }
954 
955 
956 
957  for(size_t i=0;i<fHaloMonitor.size();i++) {
958  if(fHaloMonitor[i].GetElementName()==varname)
959  {
960  std::cout<<varname<<" I found it ! "<<varcal<<" ped. "<<varped<<"\n";
961  fHaloMonitor[i].SetPedestal(varped);
962  fHaloMonitor[i].SetCalibrationFactor(varcal);
963  i=fHaloMonitor.size()+1;
964  notfound=kFALSE;
965  i=fHaloMonitor.size()+1;
966  }
967  }
968 
969 
970 
971  }
972 
973 
974  }
975 
976  }
977  if(ldebug) std::cout<<" line read in the pedestal + cal file ="<<lineread<<" \n";
978 
979  ldebug=kFALSE;
980  mapstr.Close(); // Close the file (ifstream)
981  return 0;
982 }
983 
984 
985 //*****************************************************************//
986 void QwBeamLine::RandomizeEventData(int helicity, double time)
987 {
988  // Randomize all QwBPMStripline buffers
989  for (size_t i = 0; i < fStripline.size(); i++)
990  fStripline[i].get()->RandomizeEventData(helicity, time);
991 
992  for (size_t i = 0; i < fCavity.size(); i++)
993  fCavity[i].RandomizeEventData(helicity, time);
994 
995  // Randomize all QwBCM buffers
996  for (size_t i = 0; i < fBCM.size(); i++)
997  fBCM[i].get()->RandomizeEventData(helicity, time);
998 
999  // Randomize all QwHaloMonitor buffers
1000  //for (size_t i = 0; i < fHaloMonitor.size(); i++)
1001  //fHaloMonitor[i].RandomizeEventData(helicity, time);
1002 }
1003 
1004 
1005 //*****************************************************************//
1006 void QwBeamLine::EncodeEventData(std::vector<UInt_t> &buffer)
1007 {
1008  std::vector<UInt_t> elements;
1009  elements.clear();
1010 
1011  // Get all buffers in the order they are defined in the map file
1012  for (size_t i = 0; i < fBeamDetectorID.size(); i++) {
1013  // This is a QwBCM
1014  if (fBeamDetectorID.at(i).fTypeID == kQwBCM)
1015  fBCM[fBeamDetectorID.at(i).fIndex].get()->EncodeEventData(elements);
1016  // This is a QwBPMStripline (which has 4 entries, only process the first one)
1017  if (fBeamDetectorID.at(i).fTypeID == kQwBPMStripline
1018  && fBeamDetectorID.at(i).fSubelement == 0)
1019  fStripline[fBeamDetectorID.at(i).fIndex].get()->EncodeEventData(elements);
1020  }
1021 
1022  // If there is element data, generate the subbank header
1023  std::vector<UInt_t> subbankheader;
1024  std::vector<UInt_t> rocheader;
1025  if (elements.size() > 0) {
1026 
1027  // Form CODA subbank header
1028  subbankheader.clear();
1029  subbankheader.push_back(elements.size() + 1); // subbank size
1030  subbankheader.push_back((fCurrentBank_ID << 16) | (0x01 << 8) | (1 & 0xff));
1031  // subbank tag | subbank type | event number
1032 
1033  // Form CODA bank/roc header
1034  rocheader.clear();
1035  rocheader.push_back(subbankheader.size() + elements.size() + 1); // bank/roc size
1036  rocheader.push_back((fCurrentROC_ID << 16) | (0x10 << 8) | (1 & 0xff));
1037  // bank tag == ROC | bank type | event number
1038 
1039  // Add bank header, subbank header and element data to output buffer
1040  buffer.insert(buffer.end(), rocheader.begin(), rocheader.end());
1041  buffer.insert(buffer.end(), subbankheader.begin(), subbankheader.end());
1042  buffer.insert(buffer.end(), elements.begin(), elements.end());
1043  }
1044 }
1045 
1046 
1047 //*****************************************************************//
1048 Int_t QwBeamLine::ProcessEvBuffer(const UInt_t roc_id, const UInt_t bank_id, UInt_t* buffer, UInt_t num_words)
1049 {
1050  Bool_t lkDEBUG=kFALSE;
1051 
1052  Int_t index = GetSubbankIndex(roc_id,bank_id);
1053  if (index>=0 && num_words>0){
1054  // We want to process this ROC. Begin looping through the data.
1055  if (lkDEBUG)
1056  std::cout << "QwBeamLine::ProcessEvBuffer: "
1057  << "Begin processing ROC" << roc_id
1058  << " and subbank "<<bank_id
1059  << " number of words="<<num_words<<std::endl;
1060  if (buffer[0]==0xf0f0f0f0 && num_words%2==1){
1061  buffer++;
1062  if (lkDEBUG)
1063  std::cout << "QwBeamLine::ProcessEvBuffer: "
1064  << "Skipped padding word 0xf0f0f0f0 at beginning of buffer."
1065  << std::endl;
1066  }
1067 
1068  for(size_t i=0;i<fBeamDetectorID.size();i++)
1069  {
1070  if(fBeamDetectorID[i].fSubbankIndex==index)
1071  {
1072 
1073  if(fBeamDetectorID[i].fTypeID==kQwBPMStripline)
1074  {
1075  if (lkDEBUG)
1076  {
1077  std::cout<<"found stripline data for "<<fBeamDetectorID[i].fdetectorname<<std::endl;
1078  std::cout<<"word left to read in this buffer:"<<num_words-fBeamDetectorID[i].fWordInSubbank<<std::endl;
1079  }
1080  fStripline[fBeamDetectorID[i].fIndex].get()->
1081  ProcessEvBuffer(&(buffer[fBeamDetectorID[i].fWordInSubbank]),
1082  num_words-fBeamDetectorID[i].fWordInSubbank,
1083  fBeamDetectorID[i].fSubelement);
1084  }
1085 
1086  if(fBeamDetectorID[i].fTypeID==kQwQPD)
1087  {
1088  if (lkDEBUG)
1089  {
1090  std::cout<<"found qpd data for "<<fBeamDetectorID[i].fdetectorname<<std::endl;
1091  std::cout<<"word left to read in this buffer:"<<num_words-fBeamDetectorID[i].fWordInSubbank<<std::endl;
1092  }
1093  fQPD[fBeamDetectorID[i].fIndex].
1094  ProcessEvBuffer(&(buffer[fBeamDetectorID[i].fWordInSubbank]),
1095  num_words-fBeamDetectorID[i].fWordInSubbank,
1096  fBeamDetectorID[i].fSubelement);
1097  }
1098 
1099  if(fBeamDetectorID[i].fTypeID==kQwLinearArray)
1100  {
1101  if (lkDEBUG)
1102  {
1103  std::cout<<"found linear array data for "<<fBeamDetectorID[i].fdetectorname<<fBeamDetectorID[i].fIndex<<std::endl;
1104  std::cout<<"word left to read in this buffer:"<<num_words-fBeamDetectorID[i].fWordInSubbank<<std::endl;
1105  }
1106  fLinearArray[fBeamDetectorID[i].fIndex].
1107  ProcessEvBuffer(&(buffer[fBeamDetectorID[i].fWordInSubbank]),
1108  num_words-fBeamDetectorID[i].fWordInSubbank,
1109  fBeamDetectorID[i].fSubelement);
1110 
1111  }
1112 
1113  if(fBeamDetectorID[i].fTypeID==kQwBPMCavity)
1114  {
1115  if (lkDEBUG)
1116  {
1117  std::cout<<"found stripline data for "<<fBeamDetectorID[i].fdetectorname<<std::endl;
1118  std::cout<<"word left to read in this buffer:"<<num_words-fBeamDetectorID[i].fWordInSubbank<<std::endl;
1119  }
1120  fCavity[fBeamDetectorID[i].fIndex].
1121  ProcessEvBuffer(&(buffer[fBeamDetectorID[i].fWordInSubbank]),
1122  num_words-fBeamDetectorID[i].fWordInSubbank,
1123  fBeamDetectorID[i].fSubelement);
1124  }
1125 
1126  if(fBeamDetectorID[i].fTypeID==kQwBCM)
1127  {
1128  if (lkDEBUG)
1129  {
1130  std::cout<<"found bcm data for "<<fBeamDetectorID[i].fdetectorname<<std::endl;
1131  std::cout<<"word left to read in this buffer:"<<num_words-fBeamDetectorID[i].fWordInSubbank<<std::endl;
1132  }
1133  fBCM[fBeamDetectorID[i].fIndex].get()->
1134  ProcessEvBuffer(&(buffer[fBeamDetectorID[i].fWordInSubbank]),
1135  num_words-fBeamDetectorID[i].fWordInSubbank);
1136  }
1137 
1138  if(fBeamDetectorID[i].fTypeID==kQwClock)
1139  {
1140  if (lkDEBUG)
1141  {
1142  std::cout<<"found clock data for "<<fBeamDetectorID[i].fdetectorname<<std::endl;
1143  std::cout<<"word left to read in this buffer:"<<num_words-fBeamDetectorID[i].fWordInSubbank<<std::endl;
1144  }
1145  fClock[fBeamDetectorID[i].fIndex].get()->
1146  ProcessEvBuffer(&(buffer[fBeamDetectorID[i].fWordInSubbank]),
1147  num_words-fBeamDetectorID[i].fWordInSubbank);
1148  }
1149 
1150  if(fBeamDetectorID[i].fTypeID==kQwHaloMonitor)
1151  {
1152  if (lkDEBUG)
1153  {
1154  std::cout<<"found halo monitor data for "<<fBeamDetectorID[i].fdetectorname<<std::endl;
1155  std::cout<<"word left to read in this buffer:"<<num_words-fBeamDetectorID[i].fWordInSubbank<<std::endl;
1156  }
1157  fHaloMonitor[fBeamDetectorID[i].fIndex].
1158  ProcessEvBuffer(&(buffer[fBeamDetectorID[i].fWordInSubbank]),
1159  num_words-fBeamDetectorID[i].fWordInSubbank);
1160  }
1161 
1162  }
1163  }
1164  }
1165 
1166  return 0;
1167 }
1168 
1169 
1170 
1171 //*****************************************************************//
1173 
1174  Bool_t status=kTRUE;
1175 
1176  for(size_t i=0;i<fBCM.size();i++){
1177  status &= fBCM[i].get()->ApplySingleEventCuts();
1178  if(!status && bDEBUG) std::cout<<"******* QwBeamLine::SingleEventCuts()->BCM[ "<<i
1179  <<" , "<<fBCM[i].get()->GetElementName()<<" ] ******\n";
1180  }
1181 
1182  for(size_t i=0;i<fClock.size();i++){
1183  status &= fClock[i].get()->ApplySingleEventCuts();
1184  if(!status && bDEBUG) std::cout<<"******* QwBeamLine::SingleEventCuts()->Clock[ "<<i
1185  <<" , "<<fClock[i].get()->GetElementName()<<" ] ******\n";
1186  }
1187 
1188  for(size_t i=0;i<fHaloMonitor.size();i++){
1189  status &= fHaloMonitor[i].ApplySingleEventCuts();
1190  if(!status && bDEBUG) std::cout<<"******* QwBeamLine::SingleEventCuts()->HaloMonitor[ "<<i
1191  <<" , "<<fHaloMonitor[i].GetElementName()<<" ] ******\n";
1192  }
1193 
1194  for(size_t i=0;i<fStripline.size();i++){
1195  status &= fStripline[i].get()->ApplySingleEventCuts();
1196  if(!status && bDEBUG) std::cout<<"******** QwBeamLine::SingleEventCuts()->BPMStripline[ "<<i
1197  <<" , "<<fStripline[i].get()->GetElementName()<<" ] *****\n";
1198 
1199  }
1200 
1201  for(size_t i=0;i<fQPD.size();i++){
1202  status &= fQPD[i].ApplySingleEventCuts();
1203  if(!status && bDEBUG) std::cout<<"******** QwBeamLine::SingleEventCuts()->QPD[ "<<i
1204  <<" , "<<fQPD[i].GetElementName()<<" ] *****\n";
1205  }
1206  for(size_t i=0;i<fLinearArray.size();i++){
1207  status &= fLinearArray[i].ApplySingleEventCuts();
1208  if(!status && bDEBUG) std::cout<<"******** QwBeamLine::SingleEventCuts()->LinearArray[ "<<i
1209  <<" , "<<fLinearArray[i].GetElementName()<<" ] *****\n";
1210  }
1211 
1212  for(size_t i=0;i<fCavity.size();i++){
1213  status &= fCavity[i].ApplySingleEventCuts();
1214  if(!status && bDEBUG) std::cout<<"******** QwBeamLine::SingleEventCuts()->BPMCavity[ "<<i
1215  <<" , "<<fCavity[i].GetElementName()<<" ] *****\n";
1216  }
1217 
1218  for(size_t i=0;i<fBCMCombo.size();i++){
1219  status &= fBCMCombo[i].get()->ApplySingleEventCuts();
1220  if(!status && bDEBUG) std::cout<<"******* QwBeamLine::SingleEventCuts()->CombinedBCM[ "<<i
1221  <<" , "<<fBCMCombo[i].get()->GetElementName()<<" ] ******\n";
1222  }
1223 
1224  for(size_t i=0;i<fBPMCombo.size();i++){
1225  status &= fBPMCombo[i].get()->ApplySingleEventCuts();
1226  if(!status && bDEBUG) std::cout<<"******* QwBeamLine::SingleEventCuts()->CombinedBPM[ "<<i
1227  <<" , "<<fBPMCombo[i].get()->GetElementName()<<" ] ******\n";
1228 
1229  }
1230  for(size_t i=0;i<fECalculator.size();i++){
1231  status &= fECalculator[i].ApplySingleEventCuts();
1232  if(!status && bDEBUG) std::cout<<"******* QwBeamLine::SingleEventCuts()->EnergyCalculator[ "<<i
1233  <<" , "<<fECalculator[i].GetElementName()<<" ] ******\n";
1234 
1235  }
1236 
1237 
1238  //If at least one of the devices failed event cuts, increment error counter for QwBeamLine
1239  if (!status)
1241 
1242 
1243  return status;
1244 
1245 }
1246 
1247 
1248 //*****************************************************************//
1249 void QwBeamLine::PrintErrorCounters() const{//inherited from the VQwSubsystemParity; this will display the error summary
1250 
1251  QwMessage<<"*********QwBeamLine Error Summary****************"<<QwLog::endl;
1253 
1254  for(size_t i=0;i<fClock.size();i++){
1255  fClock[i].get()->PrintErrorCounters();
1256  }
1257  printf("\n");
1258  for(size_t i=0;i<fBCM.size();i++){
1259  fBCM[i].get()->PrintErrorCounters();
1260  }
1261  printf("\n");
1262  for(size_t i=0;i<fHaloMonitor.size();i++){
1263  fHaloMonitor[i].PrintErrorCounters();
1264  }
1265  printf("\n");
1266  for(size_t i=0;i<fStripline.size();i++){
1267  fStripline[i].get()->PrintErrorCounters();
1268  printf("\n");
1269  }
1270  for(size_t i=0;i<fQPD.size();i++){
1271  fQPD[i].PrintErrorCounters();
1272  }
1273  printf("\n");
1274  for(size_t i=0;i<fLinearArray.size();i++){
1275  fLinearArray[i].PrintErrorCounters();
1276  }
1277  printf("\n");
1278  for(size_t i=0;i<fCavity.size();i++){
1279  fCavity[i].PrintErrorCounters();
1280  }
1281  printf("\n");
1282  for(size_t i=0;i<fBCMCombo.size();i++){
1283  fBCMCombo[i].get()->PrintErrorCounters();
1284  }
1285  printf("\n");
1286  for(size_t i=0;i<fBPMCombo.size();i++){
1287  fBPMCombo[i].get()->PrintErrorCounters();
1288  }
1289  printf("\n");
1290  for(size_t i=0;i<fECalculator.size();i++){
1291  fECalculator[i].PrintErrorCounters();
1292  }
1294 }
1295 
1296 //*****************************************************************//
1298 {
1299  for(size_t i=0;i<fClock.size();i++){
1300  fClock[i].get()->IncrementErrorCounters();
1301  }
1302  for(size_t i=0;i<fBCM.size();i++){
1303  fBCM[i].get()->IncrementErrorCounters();
1304  }
1305  for(size_t i=0;i<fHaloMonitor.size();i++){
1306  fHaloMonitor[i].IncrementErrorCounters();
1307  }
1308  for(size_t i=0;i<fStripline.size();i++){
1309  fStripline[i].get()->IncrementErrorCounters();
1310  }
1311  for(size_t i=0;i<fQPD.size();i++){
1312  fQPD[i].IncrementErrorCounters();
1313  }
1314  for(size_t i=0;i<fLinearArray.size();i++){
1315  fLinearArray[i].IncrementErrorCounters();
1316  }
1317  for(size_t i=0;i<fCavity.size();i++){
1318  fCavity[i].IncrementErrorCounters();
1319  }
1320  for(size_t i=0;i<fBCMCombo.size();i++){
1321  fBCMCombo[i].get()->IncrementErrorCounters();
1322  }
1323  for(size_t i=0;i<fBPMCombo.size();i++){
1324  fBPMCombo[i].get()->IncrementErrorCounters();
1325  }
1326  for(size_t i=0;i<fECalculator.size();i++){
1327  fECalculator[i].IncrementErrorCounters();
1328  }
1329 }
1330 
1331 //*****************************************************************//
1332 UInt_t QwBeamLine::GetEventcutErrorFlag(){//return the error flag
1333  UInt_t ErrorFlag;
1334  UInt_t ErrorFlagtmp;
1335  ErrorFlag=0;
1336  for(size_t i=0;i<fBCM.size();i++){
1337  ErrorFlagtmp = fBCM[i].get()->GetEventcutErrorFlag();
1338  ErrorFlag |=ErrorFlagtmp;
1339  }
1340  for(size_t i=0;i<fStripline.size();i++){
1341  ErrorFlag |= fStripline[i].get()->GetEventcutErrorFlag();
1342  }
1343  for(size_t i=0;i<fQPD.size();i++){
1344  ErrorFlag |= fQPD[i].GetEventcutErrorFlag();
1345  }
1346  for(size_t i=0;i<fLinearArray.size();i++){
1347  ErrorFlag |= fLinearArray[i].GetEventcutErrorFlag();
1348  }
1349  for(size_t i=0;i<fCavity.size();i++){
1350  ErrorFlag |= fCavity[i].GetEventcutErrorFlag();
1351  }
1352  for(size_t i=0;i<fBCMCombo.size();i++){
1353  ErrorFlag |= fBCMCombo[i].get()->GetEventcutErrorFlag();
1354  }
1355  for(size_t i=0;i<fBPMCombo.size();i++){
1356  ErrorFlag |= fBPMCombo[i].get()->GetEventcutErrorFlag();
1357  }
1358  for(size_t i=0;i<fECalculator.size();i++){
1359  ErrorFlag |= fECalculator[i].GetEventcutErrorFlag();
1360  }
1361 
1362  return ErrorFlag;
1363 
1364 }
1365 
1366 //*****************************************************************//
1367 UInt_t QwBeamLine::UpdateErrorFlag(){//return the error flag
1368  UInt_t ErrorFlag;
1369  UInt_t ErrorFlagtmp;
1370  ErrorFlag=0;
1371  for(size_t i=0;i<fBCM.size();i++){
1372  ErrorFlagtmp = fBCM[i].get()->UpdateErrorFlag();
1373  ErrorFlag |=ErrorFlagtmp;
1374  }
1375  for(size_t i=0;i<fStripline.size();i++){
1376  ErrorFlag |= fStripline[i].get()->UpdateErrorFlag();
1377  }
1378  for(size_t i=0;i<fQPD.size();i++){
1379  ErrorFlag |= fQPD[i].UpdateErrorFlag();
1380  }
1381  for(size_t i=0;i<fLinearArray.size();i++){
1382  ErrorFlag |= fLinearArray[i].UpdateErrorFlag();
1383  }
1384  for(size_t i=0;i<fCavity.size();i++){
1385  ErrorFlag |= fCavity[i].UpdateErrorFlag();
1386  }
1387  for(size_t i=0;i<fBCMCombo.size();i++){
1388  ErrorFlag |= fBCMCombo[i].get()->UpdateErrorFlag();
1389  }
1390  for(size_t i=0;i<fBPMCombo.size();i++){
1391  ErrorFlag |= fBPMCombo[i].get()->UpdateErrorFlag();
1392  }
1393  for(size_t i=0;i<fECalculator.size();i++){
1394  ErrorFlag |= fECalculator[i].UpdateErrorFlag();
1395  }
1396 
1397  return ErrorFlag;
1398 
1399 }
1400 
1401 //*****************************************************************//
1403  VQwSubsystem* tmp = const_cast<VQwSubsystem*>(ev_error);
1404  if(Compare(tmp))
1405  {
1406 
1407  const QwBeamLine* input = dynamic_cast<const QwBeamLine*>(ev_error);
1408 
1409  /*
1410  for(size_t i=0;i<input->fClock.size();i++)
1411  *(this->fClock[i].get())=*(input->fClock[i].get());
1412  */
1413  for(size_t i=0;i<input->fStripline.size();i++)
1414  (this->fStripline[i].get())->UpdateErrorFlag(input->fStripline[i].get());
1415  for(size_t i=0;i<input->fQPD.size();i++)
1416  (this->fQPD[i]).UpdateErrorFlag(&(input->fQPD[i]));
1417  for(size_t i=0;i<input->fLinearArray.size();i++)
1418  (this->fLinearArray[i]).UpdateErrorFlag(&(input->fLinearArray[i]));
1419  for(size_t i=0;i<input->fCavity.size();i++)
1420  (this->fCavity[i]).UpdateErrorFlag(&(input->fCavity[i]));
1421  for(size_t i=0;i<input->fBCM.size();i++){
1422  (this->fBCM[i].get())->UpdateErrorFlag(input->fBCM[i].get());
1423  }
1424  for(size_t i=0;i<input->fBCMCombo.size();i++)
1425  (this->fBCMCombo[i].get())->UpdateErrorFlag(input->fBCMCombo[i].get()); //*(this->fBCMCombo[i].get())=*(input->fBCMCombo[i].get());
1426  for(size_t i=0;i<input->fBPMCombo.size();i++)
1427  (this->fBPMCombo[i].get())->UpdateErrorFlag(input->fBPMCombo[i].get()); //=*(input->fBPMCombo[i].get());
1428  for(size_t i=0;i<input->fECalculator.size();i++)
1429  (this->fECalculator[i]).UpdateErrorFlag(&(input->fECalculator[i]));
1430  for(size_t i=0;i<input->fHaloMonitor.size();i++)
1431  (this->fHaloMonitor[i]).UpdateErrorFlag(&(input->fHaloMonitor[i]));
1432 
1433 
1434 
1435  }
1436 }
1437 
1438 
1439 //*****************************************************************//
1441 {
1442  // Make sure this one comes first! The clocks are needed by
1443  // other elements.
1444  for(size_t i=0;i<fClock.size();i++)
1445  fClock[i].get()->ProcessEvent();
1446 
1447  for(size_t i=0;i<fStripline.size();i++)
1448  fStripline[i].get()->ProcessEvent();
1449 
1450  for(size_t i=0;i<fCavity.size();i++)
1451  fCavity[i].ProcessEvent();
1452 
1453  for(size_t i=0;i<fBCM.size();i++)
1454  fBCM[i].get()->ProcessEvent();
1455 
1456  for(size_t i=0;i<fQPD.size();i++)
1457  fQPD[i].ProcessEvent();
1458 
1459  for(size_t i=0;i<fLinearArray.size();i++)
1461 
1462  for(size_t i=0;i<fHaloMonitor.size();i++){
1463  fHaloMonitor[i].ProcessEvent();
1464  }
1465 
1466  for(size_t i=0;i<fBCMCombo.size();i++)
1467  fBCMCombo[i].get()->ProcessEvent();
1468 
1469  for(size_t i=0;i<fBPMCombo.size();i++)
1470  fBPMCombo[i].get()->ProcessEvent();
1471 
1472  for(size_t i=0;i<fECalculator.size();i++)
1474 
1475  return;
1476 }
1477 
1478 
1479 //*****************************************************************//
1480 Int_t QwBeamLine::ProcessConfigurationBuffer(const UInt_t roc_id, const UInt_t bank_id, UInt_t* buffer, UInt_t num_words)
1481 {
1482 
1483  return 0;
1484 }
1485 
1486 //*****************************************************************//
1488 {
1489  // Publish variables
1490  Bool_t status = kTRUE;
1491 
1492  // Publish variables through map file
1493  // This should work with bcm, bpmstripline, bpmcavity, combo bpm and combo bcm
1494  for (size_t pp = 0; pp < fPublishList.size(); pp++) {
1495  TString publish_name = fPublishList.at(pp).at(0);
1496  TString device_type = fPublishList.at(pp).at(1);
1497  TString device_name = fPublishList.at(pp).at(2);
1498  TString device_prop = fPublishList.at(pp).at(3);
1499  device_type.ToLower();
1500  device_prop.ToLower();
1501 
1502  const VQwHardwareChannel* tmp_channel = 0;
1503 
1504  EQwBeamInstrumentType type_id;
1505  if (device_type == "combobpm")
1506  type_id = kQwCombinedBPM;
1507  else if (device_type == "combobcm")
1508  type_id = kQwCombinedBCM;
1509  else if (device_type == "comboenergy")
1510  type_id = kQwEnergyCalculator;
1511  else if (device_type == "scaler")
1512  type_id = kQwHaloMonitor;
1513  else
1514  type_id = GetQwBeamInstrumentType(device_type);
1515 
1516  Int_t index = GetDetectorIndex(type_id,device_name);
1517 
1518  if (type_id != kQwUnknownDeviceType
1519  && index != -1){
1520  tmp_channel = GetChannel(type_id,index,device_prop);
1521  } else
1522  QwError << "QwBeamLine::PublishInternalValues() error "<< QwLog::endl;
1523 
1524  if (tmp_channel == NULL) {
1525  QwError << "QwBeamLine::PublishInternalValues(): " << publish_name << " not found" << QwLog::endl;
1526  status = kFALSE;
1527  } else {
1528  QwDebug << "QwBeamLine::PublishInternalValues(): " << publish_name << " found" << QwLog::endl;
1529 
1530  status = PublishInternalValue(publish_name, "published-value", tmp_channel);
1531  }
1532  }
1533 
1534  return status;
1535 }
1536 
1537 //*****************************************************************//
1538 Bool_t QwBeamLine::PublishByRequest(TString device_name)
1539 {
1540  Bool_t status = kFALSE;
1541  const VQwHardwareChannel* tmp_channel = 0;
1542 
1543  std::vector<TString> publishinfo(4,TString(""));
1544  publishinfo.at(0) = device_name;
1545 
1546  EQwBeamInstrumentType type_id;
1547  Int_t index=-1;
1548 
1549  TString name = device_name;
1550  TString device_prop = "value";
1551  if (device_name.EndsWith("_EffectiveCharge")){
1552  name = device_name(0,device_name.Length()-16);
1553  device_prop = "ef";
1554  } else if (device_name.EndsWith("XSlope")){
1555  name = device_name(0,device_name.Length()-6);
1556  device_prop = "xp";
1557  } else if (device_name.EndsWith("YSlope")){
1558  name = device_name(0,device_name.Length()-6);
1559  device_prop = "yp";
1560  } else if (device_name.EndsWith("X")){
1561  name = device_name(0,device_name.Length()-1);
1562  device_prop = "x";
1563  } else if (device_name.EndsWith("Y")){
1564  name = device_name(0,device_name.Length()-1);
1565  device_prop = "y";
1566  }
1567 
1568  for(size_t i=0;i<fBeamDetectorID.size();i++) {
1569  if(fBeamDetectorID[i].fdetectorname==name
1570  || fBeamDetectorID[i].fdetectorname==device_name){
1571  index = fBeamDetectorID[i].fIndex;
1572  type_id = fBeamDetectorID[i].fTypeID;
1573 
1574  publishinfo.at(1) = GetQwBeamInstrumentTypeName(type_id);
1575  publishinfo.at(2) = fBeamDetectorID[i].fdetectorname;
1576  publishinfo.at(3) = device_prop;
1577  break;
1578  }
1579  }
1580 
1581  if (index != -1){
1582  tmp_channel = GetChannel(type_id,index,publishinfo.at(3));
1583  fPublishList.push_back(publishinfo);
1584  status = PublishInternalValue(publishinfo.at(0), "published-by-request",
1585  tmp_channel);
1586  }
1587 
1588  return status;
1589 }
1590 
1591 
1592 //*****************************************************************//
1594 {
1595  for(size_t i=0;i<fClock.size();i++)
1596  fClock[i].get()->ClearEventData();
1597  for(size_t i=0;i<fStripline.size();i++)
1598  fStripline[i].get()->ClearEventData();
1599  for(size_t i=0;i<fCavity.size();i++)
1600  fCavity[i].ClearEventData();
1601  for(size_t i=0;i<fBCM.size();i++)
1602  fBCM[i]->ClearEventData();
1603  for(size_t i=0;i<fQPD.size();i++)
1604  fQPD[i].ClearEventData();
1605  for(size_t i=0;i<fLinearArray.size();i++)
1607  for(size_t i=0;i<fHaloMonitor.size();i++)
1609 
1610  for(size_t i=0;i<fBCMCombo.size();i++)
1611  fBCMCombo[i].get()->ClearEventData();
1612  for(size_t i=0;i<fBPMCombo.size();i++)
1613  fBPMCombo[i].get()->ClearEventData();
1614  for(size_t i=0;i<fECalculator.size();i++)
1616  return;
1617 }
1618 
1619 //*****************************************************************//
1620 Int_t QwBeamLine::GetDetectorIndex( EQwBeamInstrumentType type_id, TString name) const
1621 {
1622  Bool_t ldebug=kFALSE;
1623  Int_t result=-1;
1624  if(ldebug) {
1625  std::cout<<"QwBeamLine::GetDetectorIndex\n";
1626  std::cout<<"type_id=="<<type_id<<" name="<<name<<"\n";
1627  std::cout<<fBeamDetectorID.size()<<" already registered detector\n";
1628  }
1629  for(size_t i=0;i<fBeamDetectorID.size();i++) {
1630  if(ldebug){
1631  std::cout<<"testing against ("<<fBeamDetectorID[i].fTypeID
1632  <<","<<fBeamDetectorID[i].fdetectorname<<")=>"<<result<<"\n";
1633  }
1634  if(fBeamDetectorID[i].fTypeID==type_id
1635  && fBeamDetectorID[i].fdetectorname==name){
1636  result=fBeamDetectorID[i].fIndex;
1637  break;
1638  }
1639  }
1640  return result;
1641 }
1642 
1644 {
1645  return GetElement(det_id.fTypeID, det_id.fIndex);
1646 };
1647 
1649 {
1650  Int_t index = GetDetectorIndex(TypeID,name);
1651  return GetElement(TypeID,index);
1652 };
1653 
1655 {
1656  VQwDataElement* tmp_ptr;
1657  switch (TypeID){
1658  case kQwBPMStripline:
1659  tmp_ptr = fStripline.at(index).get();
1660  break;
1661  case kQwQPD:
1662  tmp_ptr = &(fQPD.at(index));
1663  break;
1664  case kQwLinearArray:
1665  tmp_ptr = &(fLinearArray.at(index));
1666  break;
1667  case kQwBCM:
1668  tmp_ptr = fBCM.at(index).get();
1669  break;
1670  case kQwCombinedBCM:
1671  tmp_ptr = fBCMCombo.at(index).get();
1672  break;
1673  case kQwCombinedBPM:
1674  tmp_ptr = fBPMCombo.at(index).get();
1675  break;
1676  case kQwEnergyCalculator:
1677  tmp_ptr = &(fECalculator.at(index));
1678  break;
1679  case kQwHaloMonitor:
1680  tmp_ptr = &(fHaloMonitor.at(index));
1681  break;
1682  case kQwBPMCavity:
1683  tmp_ptr = &(fCavity.at(index));
1684  break;
1685  case kQwClock:
1686  tmp_ptr = fClock.at(index).get();
1687  break;
1688  default:
1689  TString loc="QwBeamLine::GetElement called by "
1690  +this->GetSubsystemName()+" with invalid arguements: "
1691  +GetQwBeamInstrumentTypeName(TypeID)+" "
1692  +Form("%d",index);
1693  throw std::invalid_argument(loc.Data());
1694  }
1695  return tmp_ptr;
1696 };
1697 
1699 {
1700  return const_cast<QwBeamLine*>(this)->GetElement(TypeID,index);
1701 }
1702 
1703 const VQwHardwareChannel* QwBeamLine::GetChannel(EQwBeamInstrumentType TypeID, Int_t index, TString device_prop) const
1704 {
1705  const VQwHardwareChannel* tmp_channel = 0;
1706 
1707  if (TypeID==kQwBPMStripline || TypeID==kQwBPMCavity || TypeID==kQwQPD){
1708  const VQwBPM* tmp_ptr = dynamic_cast<const VQwBPM*>(GetElement(TypeID, index));
1709  if (device_prop == "x")
1710  tmp_channel = tmp_ptr->GetPosition(VQwBPM::kXAxis);
1711  else if (device_prop == "y")
1712  tmp_channel = tmp_ptr->GetPosition(VQwBPM::kYAxis);
1713  else if (device_prop == "ef")
1714  tmp_channel = tmp_ptr->GetEffectiveCharge();
1715  } else if (TypeID==kQwCombinedBPM){
1716  if (device_prop == "x")
1717  tmp_channel = fBPMCombo.at(index)->GetPosition(VQwBPM::kXAxis);
1718  else if (device_prop == "y")
1719  tmp_channel = fBPMCombo.at(index)->GetPosition(VQwBPM::kYAxis);
1720  else if (device_prop == "ef")
1721  tmp_channel = fBPMCombo.at(index)->GetEffectiveCharge();
1722  else if (device_prop == "xp")
1723  tmp_channel = fBPMCombo.at(index)->GetAngleX();
1724  else if (device_prop == "yp")
1725  tmp_channel = fBPMCombo.at(index)->GetAngleY();
1726  } else if (TypeID==kQwLinearArray){
1727  /// TODO: QwBeamLine::GetChannel
1728  /// How do we access linear array channel outputs?
1729  } else if (TypeID==kQwBCM || TypeID==kQwCombinedBCM){
1730  tmp_channel = dynamic_cast<const VQwBCM*>(GetElement(TypeID,index))->GetCharge();
1731  } else if (TypeID==kQwEnergyCalculator){
1732  tmp_channel = fECalculator.at(index).GetEnergy();
1733  } else if (TypeID==kQwHaloMonitor){
1734  tmp_channel = fHaloMonitor.at(index).GetScaler();
1735  } else if (TypeID==kQwClock){
1736  tmp_channel = fClock.at(index)->GetTime();
1737  } else {
1738  TString loc="QwBeamLine::GetChannel called by "
1739  +this->GetSubsystemName()+" with invalid arguements: "
1740  +GetQwBeamInstrumentTypeName(TypeID)+" "
1741  +Form("%d",index);
1742  throw std::invalid_argument(loc.Data());
1743  }
1744  return tmp_channel;
1745 }
1746 
1747 //*****************************************************************//
1749 {
1750  if (! fStripline.empty()) {
1751  for (std::vector<VQwBPM_ptr >::iterator stripline = fStripline.begin(); stripline != fStripline.end(); ++stripline) {
1752  if ((*stripline).get()->GetElementName() == name) {
1753  return (*stripline).get();
1754  }
1755  }
1756  }
1757  return 0;
1758 }
1759 
1760 //*****************************************************************//
1761 
1763 {
1764  if (! fCavity.empty()) {
1765  for (std::vector<QwBPMCavity>::iterator cavity = fCavity.begin(); cavity != fCavity.end(); ++cavity) {
1766  if (cavity->GetElementName() == name) {
1767  return &(*cavity);
1768  }
1769  }
1770  }
1771  return 0;
1772 }
1773 
1774 
1775 //*****************************************************************//
1776 VQwBCM* QwBeamLine::GetBCM(const TString name)
1777 {
1778  //QwWarning << "QwBeamLine::GetBCM" << QwLog::endl;
1779  if (! fBCM.empty()) {
1780  for (std::vector<VQwBCM_ptr >::iterator bcm = fBCM.begin(); bcm != fBCM.end(); ++bcm) {
1781  if ((*bcm).get()->GetElementName() == name) {
1782  return (*bcm).get();
1783  }
1784  }
1785 
1786  //QwWarning << "BCM Found" << QwLog::endl;
1787  return 0;
1788  }
1789  return 0;
1790 }
1791 
1792 
1793 //*****************************************************************//
1794 VQwClock* QwBeamLine::GetClock(const TString name)
1795 {
1796  //QwWarning << "QwBeamLine::GetClock" << QwLog::endl;
1797  if (! fClock.empty()) {
1798  for (std::vector<VQwClock_ptr >::iterator clock = fClock.begin(); clock != fClock.end(); ++clock) {
1799  if ((*clock).get()->GetElementName() == name) {
1800  return (*clock).get();
1801  }
1802  }
1803 
1804  //QwWarning << "Clock Found" << QwLog::endl;
1805  return 0;
1806  }
1807  return 0;
1808 }
1809 
1810 //*****************************************************************//
1812 {
1813  //QwWarning << "QwBeamLine::GetCombinedBCM" << QwLog::endl;
1814  if (! fBCMCombo.empty()) {
1815 
1816  for (std::vector<VQwBCM_ptr>::iterator cbcm = fBCMCombo.begin(); cbcm != fBCMCombo.end(); ++cbcm) {
1817  if ((*cbcm).get()->GetElementName() == name) {
1818  return (*cbcm).get();
1819  }
1820  }
1821 
1822 
1823  }
1824  return 0;
1825 }
1826 
1827 //*****************************************************************//
1829 {
1830  //QwWarning << "QwBeamLine::GetCombinedBPM" << QwLog::endl;
1831  if (! fBPMCombo.empty()) {
1832 
1833  for (std::vector<VQwBPM_ptr>::iterator cbpm = fBPMCombo.begin(); cbpm != fBPMCombo.end(); ++cbpm) {
1834  if ((*cbpm).get()->GetElementName() == name) {
1835  return (*cbpm).get();
1836  }
1837  }
1838 
1839 
1840  }
1841  return 0;
1842 }
1843 
1844 //*****************************************************************//
1846  if (! fECalculator.empty()) {
1847 
1848  for (std::vector<QwEnergyCalculator>::iterator ecal = fECalculator.begin(); ecal != fECalculator.end(); ++ecal) {
1849  if (ecal->GetElementName() == name) {
1850  return &(*ecal);
1851  }
1852  }
1853 
1854 
1855  }
1856  return 0;
1857 }
1858 
1859 //*****************************************************************//
1860 const VQwBPM* QwBeamLine::GetBPMStripline(const TString name) const
1861 {
1862  return const_cast<QwBeamLine*>(this)->GetBPMStripline(name);
1863 }
1864 
1866  if (! fHaloMonitor.empty()) {
1867 
1868  for (std::vector<QwHaloMonitor>::iterator halo = fHaloMonitor.begin(); halo != fHaloMonitor.end(); ++halo) {
1869  if (halo->GetElementName() == name) {
1870  return &(*halo);
1871  }
1872  }
1873 
1874 
1875  }
1876  return 0;
1877 };
1878 
1879 //*****************************************************************//
1880 const QwBPMCavity* QwBeamLine::GetBPMCavity(const TString name) const
1881 {
1882  return const_cast<QwBeamLine*>(this)->GetBPMCavity(name);
1883 }
1884 
1885 //*****************************************************************//
1886 const VQwBCM* QwBeamLine::GetBCM(const TString name) const
1887 {
1888  return const_cast<QwBeamLine*>(this)->GetBCM(name);
1889 }
1890 
1891 //*****************************************************************//
1892 const VQwClock* QwBeamLine::GetClock(const TString name) const
1893 {
1894  return const_cast<QwBeamLine*>(this)->GetClock(name);
1895 }
1896 
1897 //*****************************************************************//
1898 const VQwBCM* QwBeamLine::GetCombinedBCM(const TString name) const{
1899  return const_cast<QwBeamLine*>(this)->GetCombinedBCM(name);
1900 }
1901 
1902 //*****************************************************************//
1903 const VQwBPM* QwBeamLine::GetCombinedBPM(const TString name) const{
1904  return const_cast<QwBeamLine*>(this)->GetCombinedBPM(name);
1905 }
1906 
1907 //*****************************************************************//
1908 const QwEnergyCalculator* QwBeamLine::GetEnergyCalculator(const TString name) const{
1909  return const_cast<QwBeamLine*>(this)->GetEnergyCalculator(name);
1910 }
1911 
1912  //*****************************************************************//
1913 const QwHaloMonitor* QwBeamLine::GetScalerChannel(const TString name)const {
1914  return const_cast<QwBeamLine*>(this)->GetScalerChannel(name);
1915 };
1916 
1917 
1918 //*****************************************************************//
1920 {
1921  // std::cout<<" here in QwBeamLine::operator= \n";
1922  if(Compare(value))
1923  {
1924 
1925  QwBeamLine* input = dynamic_cast<QwBeamLine*>(value);
1926 
1927  for(size_t i=0;i<input->fClock.size();i++)
1928  *(this->fClock[i].get())=*(input->fClock[i].get());
1929  for(size_t i=0;i<input->fStripline.size();i++)
1930  *(this->fStripline[i].get())=*(input->fStripline[i].get());
1931  for(size_t i=0;i<input->fQPD.size();i++)
1932  this->fQPD[i]=input->fQPD[i];
1933  for(size_t i=0;i<input->fLinearArray.size();i++)
1934  this->fLinearArray[i]=input->fLinearArray[i];
1935  for(size_t i=0;i<input->fCavity.size();i++)
1936  this->fCavity[i]=input->fCavity[i];
1937  for(size_t i=0;i<input->fBCM.size();i++)
1938  *(this->fBCM[i].get())=*(input->fBCM[i].get());
1939  for(size_t i=0;i<input->fHaloMonitor.size();i++)
1940  this->fHaloMonitor[i]=input->fHaloMonitor[i];
1941  for(size_t i=0;i<input->fBCMCombo.size();i++)
1942  *(this->fBCMCombo[i].get())=*(input->fBCMCombo[i].get());
1943  for(size_t i=0;i<input->fBPMCombo.size();i++)
1944  *(this->fBPMCombo[i].get())=*(input->fBPMCombo[i].get());
1945  for(size_t i=0;i<input->fECalculator.size();i++)
1946  this->fECalculator[i]=input->fECalculator[i];
1947 
1948  if (input->fPublishList.size()>0){
1949  this->fPublishList.resize(input->fPublishList.size());
1950  for(size_t i=0;i<input->fPublishList.size();i++){
1951  this->fPublishList.at(i).resize(input->fPublishList.at(i).size());
1952  for(size_t j=0;j<input->fPublishList.at(i).size();j++){
1953  this->fPublishList.at(i).at(j)=input->fPublishList.at(i).at(j);
1954  }
1955  }
1956  }
1957 
1958  }
1959  return *this;
1960 }
1961 
1962 
1963 //*****************************************************************//
1965 {
1966  if(Compare(value))
1967  {
1968  //QwBeamLine* input= (QwBeamLine*)value ;
1969  QwBeamLine* input = dynamic_cast<QwBeamLine*>(value);
1970 
1971  for(size_t i=0;i<input->fClock.size();i++)
1972  *(this->fClock[i].get())+=*(input->fClock[i].get());
1973  for(size_t i=0;i<input->fStripline.size();i++)
1974  *(this->fStripline[i].get())+=*(input->fStripline[i].get());
1975  for(size_t i=0;i<input->fCavity.size();i++)
1976  this->fCavity[i]+=input->fCavity[i];
1977  for(size_t i=0;i<input->fQPD.size();i++)
1978  this->fQPD[i]+=input->fQPD[i];
1979  for(size_t i=0;i<input->fLinearArray.size();i++)
1980  this->fLinearArray[i]+=input->fLinearArray[i];
1981  for(size_t i=0;i<input->fBCM.size();i++)
1982  *(this->fBCM[i].get())+=*(input->fBCM[i].get());
1983  for(size_t i=0;i<input->fHaloMonitor.size();i++)
1984  this->fHaloMonitor[i]+=input->fHaloMonitor[i];
1985  for(size_t i=0;i<input->fBCMCombo.size();i++)
1986  *(this->fBCMCombo[i].get())+=*(input->fBCMCombo[i].get());
1987  for(size_t i=0;i<input->fBPMCombo.size();i++)
1988  *(this->fBPMCombo[i].get())+=*(input->fBPMCombo[i].get());
1989  for(size_t i=0;i<input->fECalculator.size();i++)
1990  this->fECalculator[i]+=input->fECalculator[i];
1991 
1992  if (input->fPublishList.size()>0){
1993  this->fPublishList.resize(input->fPublishList.size());
1994  for(size_t i=0;i<input->fPublishList.size();i++){
1995  this->fPublishList.at(i).resize(input->fPublishList.at(i).size());
1996  for(size_t j=0;j<input->fPublishList.at(i).size();j++){
1997  this->fPublishList.at(i).at(j)=input->fPublishList.at(i).at(j);
1998  }
1999  }
2000  }
2001 
2002  }
2003  return *this;
2004 }
2005 
2006 //*****************************************************************//
2008 {
2009 
2010  if(Compare(value))
2011  {
2012  QwBeamLine* input = dynamic_cast<QwBeamLine*>(value);
2013 
2014  for(size_t i=0;i<input->fClock.size();i++)
2015  *(this->fClock[i].get())-=*(input->fClock[i].get());
2016  for(size_t i=0;i<input->fStripline.size();i++)
2017  *(this->fStripline[i].get())-=*(input->fStripline[i].get());
2018  for(size_t i=0;i<input->fCavity.size();i++)
2019  this->fCavity[i]-=input->fCavity[i];
2020  for(size_t i=0;i<input->fQPD.size();i++)
2021  this->fQPD[i]-=input->fQPD[i];
2022  for(size_t i=0;i<input->fLinearArray.size();i++)
2023  this->fLinearArray[i]-=input->fLinearArray[i];
2024  for(size_t i=0;i<input->fBCM.size();i++)
2025  *(this->fBCM[i].get())-=*(input->fBCM[i].get());
2026  for(size_t i=0;i<input->fHaloMonitor.size();i++)
2027  this->fHaloMonitor[i]-=input->fHaloMonitor[i];
2028  for(size_t i=0;i<input->fBCMCombo.size();i++)
2029  *(this->fBCMCombo[i].get())-=*(input->fBCMCombo[i].get());
2030  for(size_t i=0;i<input->fBPMCombo.size();i++)
2031  *(this->fBPMCombo[i].get())-=*(input->fBPMCombo[i].get());
2032  for(size_t i=0;i<input->fECalculator.size();i++)
2033  this->fECalculator[i]-=input->fECalculator[i];
2034 
2035  if (input->fPublishList.size()>0){
2036  this->fPublishList.resize(input->fPublishList.size());
2037  for(size_t i=0;i<input->fPublishList.size();i++){
2038  this->fPublishList.at(i).resize(input->fPublishList.at(i).size());
2039  for(size_t j=0;j<input->fPublishList.at(i).size();j++){
2040  this->fPublishList.at(i).at(j)=input->fPublishList.at(i).at(j);
2041  }
2042  }
2043  }
2044 
2045  }
2046  return *this;
2047 }
2048 
2049 
2050 //*****************************************************************//
2052 {
2053  if(Compare(value1)&&Compare(value2))
2054  {
2055  *this = value1;
2056  *this += value2;
2057  }
2058 }
2059 
2060 
2061 //*****************************************************************//
2063 {
2064  if(Compare(value1)&&Compare(value2))
2065  {
2066  *this = value1;
2067  *this -= value2;
2068  }
2069 }
2070 
2071 
2072 //*****************************************************************//
2074 {
2075  if(Compare(numer)&&Compare(denom))
2076  {
2077  QwBeamLine* innumer = dynamic_cast<QwBeamLine*>(numer);
2078  QwBeamLine* indenom = dynamic_cast<QwBeamLine*>(denom);
2079 
2080  for(size_t i=0;i<innumer->fClock.size();i++)
2081  this->fClock[i].get()->Ratio(*(innumer->fClock[i].get()),
2082  *(indenom->fClock[i].get()));
2083  for(size_t i=0;i<innumer->fStripline.size();i++)
2084  this->fStripline[i].get()->Ratio(*(innumer->fStripline[i].get()),
2085  *(indenom->fStripline[i].get()));
2086  for(size_t i=0;i<innumer->fCavity.size();i++)
2087  this->fCavity[i].Ratio(innumer->fCavity[i],indenom->fCavity[i]);
2088  for(size_t i=0;i<innumer->fQPD.size();i++)
2089  this->fQPD[i].Ratio(innumer->fQPD[i],indenom->fQPD[i]);
2090  for(size_t i=0;i<innumer->fLinearArray.size();i++)
2091  this->fLinearArray[i].Ratio(innumer->fLinearArray[i],indenom->fLinearArray[i]);
2092  for(size_t i=0;i<innumer->fBCM.size();i++)
2093  this->fBCM[i].get()->Ratio(*(innumer->fBCM[i].get()),
2094  *(indenom->fBCM[i].get()));
2095  for(size_t i=0;i<innumer->fHaloMonitor.size();i++)
2096  this->fHaloMonitor[i].Ratio(innumer->fHaloMonitor[i],indenom->fHaloMonitor[i]);
2097  for(size_t i=0;i<innumer->fBCMCombo.size();i++)
2098  this->fBCMCombo[i].get()->Ratio(*(innumer->fBCMCombo[i].get()),
2099  *(indenom->fBCMCombo[i]));
2100  for(size_t i=0;i<innumer->fBPMCombo.size();i++)
2101  this->fBPMCombo[i].get()->Ratio(*(innumer->fBPMCombo[i].get()),
2102  *(indenom->fBPMCombo[i].get()));
2103  for(size_t i=0;i<innumer->fECalculator.size();i++)
2104  this->fECalculator[i].Ratio(innumer->fECalculator[i],indenom->fECalculator[i]);
2105 
2106  // For the combined bcm, maybe we might want to think about getting
2107  // the asymmetry using the asymmetries of the individual bcms with a
2108  // weight. But right now it is unclear if really need to have that
2109  // option.
2110  }
2111  return;
2112 }
2113 
2114 //*****************************************************************//
2115 void QwBeamLine::Scale(Double_t factor)
2116 {
2117  for(size_t i=0;i<fClock.size();i++) fClock[i].get()->Scale(factor);
2118  for(size_t i=0;i<fStripline.size();i++) fStripline[i].get()->Scale(factor);
2119  for(size_t i=0;i<fCavity.size();i++) fCavity[i].Scale(factor);
2120  for(size_t i=0;i<fQPD.size();i++) fQPD[i].Scale(factor);
2121  for(size_t i=0;i<fLinearArray.size();i++) fLinearArray[i].Scale(factor);
2122  for(size_t i=0;i<fBCM.size();i++) fBCM[i].get()->Scale(factor);
2123  for(size_t i=0;i<fHaloMonitor.size();i++) fHaloMonitor[i].Scale(factor);
2124  for(size_t i=0;i<fBCMCombo.size();i++) fBCMCombo[i].get()->Scale(factor);
2125  for(size_t i=0;i<fBPMCombo.size();i++) fBPMCombo[i].get()->Scale(factor);
2126  for(size_t i=0;i<fECalculator.size();i++) fECalculator[i].Scale(factor);
2127  return;
2128 }
2129 
2130 //*****************************************************************//
2132 {
2133  for (size_t i = 0; i < fClock.size(); i++) fClock[i].get()->CalculateRunningAverage();
2134  for (size_t i = 0; i < fStripline.size(); i++) fStripline[i].get()->CalculateRunningAverage();
2135  for (size_t i = 0; i < fCavity.size(); i++) fCavity[i].CalculateRunningAverage();
2136  for (size_t i = 0; i < fQPD.size(); i++) fQPD[i].CalculateRunningAverage();
2137  for (size_t i = 0; i < fLinearArray.size(); i++) fLinearArray[i].CalculateRunningAverage();
2138  for (size_t i = 0; i < fBCM.size(); i++) fBCM[i].get()->CalculateRunningAverage();
2139  for (size_t i = 0; i < fHaloMonitor.size(); i++) fHaloMonitor[i].CalculateRunningAverage();
2140  for (size_t i = 0; i < fBCMCombo.size(); i++) fBCMCombo[i].get()->CalculateRunningAverage();
2141  for (size_t i = 0; i < fBPMCombo.size(); i++) fBPMCombo[i].get()->CalculateRunningAverage();
2142  for (size_t i = 0; i < fECalculator.size(); i++) fECalculator[i].CalculateRunningAverage();
2143 }
2144 
2145 //*****************************************************************//
2147 {
2148  QwMessage << "=== QwBeamLine: " << GetSubsystemName() << " ===" << QwLog::endl;
2149  QwMessage << "Clock" << QwLog::endl;
2150  for (size_t i = 0; i < fClock.size(); i++) fClock[i].get()->PrintValue();
2151  QwMessage << "BPM stripline" << QwLog::endl;
2152  for (size_t i = 0; i < fStripline.size(); i++) fStripline[i].get()->PrintValue();
2153  QwMessage << "QPD" << QwLog::endl;
2154  for (size_t i = 0; i < fQPD.size(); i++) fQPD[i].PrintValue();
2155  QwMessage << "LinearArray" << QwLog::endl;
2156  for (size_t i = 0; i < fLinearArray.size(); i++) fLinearArray[i].PrintValue();
2157  QwMessage << "BPM cavity" << QwLog::endl;
2158  for (size_t i = 0; i < fCavity.size(); i++) fCavity[i].PrintValue();
2159  QwMessage << "BCM" << QwLog::endl;
2160  for (size_t i = 0; i < fBCM.size(); i++) fBCM[i].get()->PrintValue();
2161  QwMessage << "HaloMonitor" << QwLog::endl;
2162  for (size_t i = 0; i < fHaloMonitor.size(); i++) fHaloMonitor[i].PrintValue();
2163  QwMessage << "BPM combo" << QwLog::endl;
2164  for (size_t i = 0; i < fBCMCombo.size(); i++) fBCMCombo[i].get()->PrintValue();
2165  QwMessage << "BPM combo" << QwLog::endl;
2166  for (size_t i = 0; i < fBPMCombo.size(); i++) fBPMCombo[i].get()->PrintValue();
2167  QwMessage << "Energy " << QwLog::endl;
2168  for (size_t i = 0; i < fECalculator.size(); i++) fECalculator[i].PrintValue();
2169 
2170 }
2171 
2172 //*****************************************************************//
2174 {
2175  if (Compare(value1)) {
2176  QwBeamLine* value = dynamic_cast<QwBeamLine*>(value1);
2177 
2178  for (size_t i = 0; i < fClock.size(); i++)
2179  fClock[i].get()->AccumulateRunningSum(*(value->fClock[i].get()));
2180  for (size_t i = 0; i < fStripline.size(); i++)
2181  fStripline[i].get()->AccumulateRunningSum(*(value->fStripline[i].get()));
2182  for (size_t i = 0; i < fCavity.size(); i++)
2183  fCavity[i].AccumulateRunningSum(value->fCavity[i]);
2184  for (size_t i = 0; i < fBCM.size(); i++)
2185  fBCM[i].get()->AccumulateRunningSum(*(value->fBCM[i].get()));
2186  for (size_t i = 0; i < fBCMCombo.size(); i++)
2187  fBCMCombo[i].get()->AccumulateRunningSum(*(value->fBCMCombo[i].get()));
2188  for (size_t i = 0; i < fBPMCombo.size(); i++)
2189  fBPMCombo[i].get()->AccumulateRunningSum(*(value->fBPMCombo[i].get()));
2190  for (size_t i = 0; i < fECalculator.size(); i++)
2192  for (size_t i = 0; i < fQPD.size(); i++)
2193  fQPD[i].AccumulateRunningSum(value->fQPD[i]);
2194  for (size_t i = 0; i < fLinearArray.size(); i++)
2196  for (size_t i = 0; i <fHaloMonitor.size(); i++)
2198 
2199  }
2200 }
2201 
2202 //*****************************************************************//
2204  if (Compare(value1)) {
2205  QwBeamLine* value = dynamic_cast<QwBeamLine*>(value1);
2206  /*
2207  for (size_t i = 0; i < fClock.size(); i++)
2208  fClock[i].get()->DeaccumulateRunningSum(*(value->fClock[i].get()));
2209  */
2210  for (size_t i = 0; i < fStripline.size(); i++)
2211  fStripline[i].get()->DeaccumulateRunningSum(*(value->fStripline[i].get()));
2212  for (size_t i = 0; i < fCavity.size(); i++)
2213  fCavity[i].DeaccumulateRunningSum(value->fCavity[i]);
2214  for (size_t i = 0; i < fBCM.size(); i++)
2215  fBCM[i].get()->DeaccumulateRunningSum(*(value->fBCM[i].get()));
2216  for (size_t i = 0; i < fBCMCombo.size(); i++)
2217  fBCMCombo[i].get()->DeaccumulateRunningSum(*(value->fBCMCombo[i].get()));
2218  for (size_t i = 0; i < fBPMCombo.size(); i++)
2219  fBPMCombo[i].get()->DeaccumulateRunningSum(*(value->fBPMCombo[i].get()));
2220  for (size_t i = 0; i < fQPD.size(); i++)
2221  fQPD[i].DeaccumulateRunningSum(value->fQPD[i]);
2222  for (size_t i = 0; i < fLinearArray.size(); i++)
2224  for (size_t i = 0; i < fECalculator.size(); i++)
2226  for (size_t i = 0; i <fHaloMonitor.size(); i++)
2228 
2229  }
2230 };
2231 
2232 //*****************************************************************//
2234 {
2235  // std::cout<<" Here in QwBeamLine::Compare \n";
2236 
2237  Bool_t res=kTRUE;
2238  if(typeid(*value)!=typeid(*this))
2239  {
2240  res=kFALSE;
2241  // std::cout<<" types are not ok \n";
2242  // std::cout<<" this is bypassed just for now but should be fixed eventually \n";
2243  }
2244  else
2245  {
2246  QwBeamLine* input = dynamic_cast<QwBeamLine*>(value);
2247  if(input->fStripline.size()!=fStripline.size())
2248  {
2249  // std::cout<<" not the same number of striplines \n";
2250  res=kFALSE;
2251  }
2252  else if(input->fBCM.size()!=fBCM.size())
2253  {
2254  res=kFALSE;
2255  // std::cout<<" not the same number of bcms \n";
2256  }
2257  else if(input->fHaloMonitor.size()!=fHaloMonitor.size())
2258  {
2259  res=kFALSE;
2260  // std::cout<<" not the same number of halomonitors \n";
2261  }
2262  else if(input->fClock.size()!=fClock.size()){
2263  res=kFALSE;
2264  // std::cout<<" not the same number of halomonitors \n";
2265  }else if(input->fBCMCombo.size()!=fBCMCombo.size()){
2266  res=kFALSE;
2267  }else if(input->fBPMCombo.size()!=fBPMCombo.size()){
2268  res=kFALSE;
2269  }else if(input->fLinearArray.size()!=fLinearArray.size()){
2270  res=kFALSE;
2271  }else if(input->fECalculator.size()!=fECalculator.size()){
2272  res=kFALSE;
2273  }else if(input->fCavity.size()!=fCavity.size()){
2274  res=kFALSE;
2275  }else if(input->fQPD.size()!=fQPD.size()){
2276  res=kFALSE;
2277  }
2278 
2279  }
2280  return res;
2281 }
2282 
2283 
2284 //*****************************************************************//
2285 void QwBeamLine::ConstructHistograms(TDirectory *folder, TString &prefix)
2286 {
2287 
2288  // std::cout<<" here is QwBeamLine::ConstructHistogram with prefix ="<<prefix<<"\n";
2289  for(size_t i=0;i<fClock.size();i++)
2290  fClock[i].get()->ConstructHistograms(folder,prefix);
2291 
2292  for(size_t i=0;i<fStripline.size();i++)
2293  fStripline[i].get()->ConstructHistograms(folder,prefix);
2294 
2295  for(size_t i=0;i<fQPD.size();i++)
2296  fQPD[i].ConstructHistograms(folder,prefix);
2297 
2298  for(size_t i=0;i<fLinearArray.size();i++)
2299  fLinearArray[i].ConstructHistograms(folder,prefix);
2300 
2301  for(size_t i=0;i<fCavity.size();i++)
2302  fCavity[i].ConstructHistograms(folder,prefix);
2303 
2304  for(size_t i=0;i<fBCM.size();i++)
2305  fBCM[i].get()->ConstructHistograms(folder,prefix);
2306 
2307  for(size_t i=0;i<fHaloMonitor.size();i++)
2308  fHaloMonitor[i].ConstructHistograms(folder,prefix);
2309 
2310  for(size_t i=0;i<fBCMCombo.size();i++)
2311  fBCMCombo[i].get()->ConstructHistograms(folder,prefix);
2312 
2313  for(size_t i=0;i<fBPMCombo.size();i++)
2314  fBPMCombo[i].get()->ConstructHistograms(folder,prefix);
2315 
2316  for(size_t i=0;i<fECalculator.size();i++)
2317  fECalculator[i].ConstructHistograms(folder,prefix);
2318  return;
2319 }
2320 
2321 //*****************************************************************//
2323 {
2324  for(size_t i=0;i<fClock.size();i++)
2325  fClock[i].get()->FillHistograms();
2326  for(size_t i=0;i<fStripline.size();i++)
2327  fStripline[i].get()->FillHistograms();
2328  for(size_t i=0;i<fQPD.size();i++)
2329  fQPD[i].FillHistograms();
2330  for(size_t i=0;i<fLinearArray.size();i++)
2332  for(size_t i=0;i<fCavity.size();i++)
2333  fCavity[i].FillHistograms();
2334  for(size_t i=0;i<fBCM.size();i++)
2335  fBCM[i].get()->FillHistograms();
2336  for(size_t i=0;i<fHaloMonitor.size();i++)
2338  for(size_t i=0;i<fBCMCombo.size();i++)
2339  fBCMCombo[i].get()->FillHistograms();
2340  for(size_t i=0;i<fBPMCombo.size();i++)
2341  fBPMCombo[i].get()->FillHistograms();
2342  for(size_t i=0;i<fECalculator.size();i++)
2344 
2345  return;
2346 }
2347 
2348 
2349 //*****************************************************************//
2350 void QwBeamLine::ConstructBranchAndVector(TTree *tree, TString & prefix, std::vector <Double_t> &values)
2351 {
2352 
2353  for(size_t i = 0; i < fClock.size(); i++)
2354  fClock[i].get()->ConstructBranchAndVector(tree, prefix, values);
2355  for(size_t i = 0; i < fStripline.size(); i++)
2356  fStripline[i].get()->ConstructBranchAndVector(tree, prefix, values);
2357  for(size_t i = 0; i < fQPD.size(); i++)
2358  fQPD[i].ConstructBranchAndVector(tree, prefix, values);
2359  for(size_t i = 0; i < fLinearArray.size(); i++)
2360  fLinearArray[i].ConstructBranchAndVector(tree, prefix, values);
2361  for(size_t i = 0; i < fCavity.size(); i++)
2362  fCavity[i].ConstructBranchAndVector(tree, prefix, values);
2363  for(size_t i = 0; i < fBCM.size(); i++)
2364  fBCM[i].get()->ConstructBranchAndVector(tree, prefix, values);
2365  for(size_t i = 0; i < fHaloMonitor.size(); i++)
2366  fHaloMonitor[i].ConstructBranchAndVector(tree, prefix, values);
2367  for(size_t i = 0; i <fBCMCombo.size();i++)
2368  fBCMCombo[i].get()->ConstructBranchAndVector(tree, prefix, values);
2369  for(size_t i = 0; i <fBPMCombo.size();i++)
2370  fBPMCombo[i].get()->ConstructBranchAndVector(tree, prefix, values);
2371  for(size_t i = 0; i <fECalculator.size();i++)
2372  fECalculator[i].ConstructBranchAndVector(tree, prefix, values);
2373 
2374  return;
2375 }
2376 
2377 //*****************************************************************//
2378 void QwBeamLine::ConstructBranch(TTree *tree, TString & prefix)
2379 {
2380  for(size_t i = 0; i < fClock.size(); i++)
2381  fClock[i].get()->ConstructBranch(tree, prefix);
2382  for(size_t i = 0; i < fStripline.size(); i++)
2383  fStripline[i].get()->ConstructBranch(tree, prefix);
2384  for(size_t i = 0; i < fQPD.size(); i++)
2385  fQPD[i].ConstructBranch(tree, prefix);
2386  for(size_t i = 0; i < fLinearArray.size(); i++)
2387  fLinearArray[i].ConstructBranch(tree, prefix);
2388  for(size_t i = 0; i < fBCM.size(); i++)
2389  fBCM[i].get()->ConstructBranch(tree, prefix);
2390  for(size_t i = 0; i <fCavity.size(); i++)
2391  fStripline[i].get()->ConstructBranch(tree, prefix);
2392  for(size_t i = 0; i < fHaloMonitor.size(); i++)
2393  fHaloMonitor[i].ConstructBranch(tree, prefix);
2394  for(size_t i = 0; i <fBCMCombo.size();i++)
2395  fBCMCombo[i].get()->ConstructBranch(tree, prefix);
2396  for(size_t i = 0; i <fBPMCombo.size();i++)
2397  fBPMCombo[i].get()->ConstructBranch(tree, prefix);
2398  for(size_t i = 0; i <fECalculator.size();i++)
2399  fECalculator[i].ConstructBranch(tree, prefix);
2400 
2401 
2402  return;
2403 }
2404 
2405 //*****************************************************************//
2406 void QwBeamLine::ConstructBranch(TTree *tree, TString & prefix, QwParameterFile& trim_file)
2407 {
2408  TString tmp,varname,varvalue;
2409  tmp="QwBCM";
2410  QwParameterFile* nextmodule;
2411  trim_file.RewindToFileStart();
2412 
2413 
2414  tmp="QwBPMStripline";
2415  trim_file.RewindToFileStart();
2416  if (trim_file.FileHasModuleHeader(tmp)){
2417  nextmodule=trim_file.ReadUntilNextModule();//This section contains sub modules and or channels to be included in the tree
2418  for(size_t i = 0; i < fStripline.size(); i++)
2419  fStripline[i].get()->ConstructBranch(tree, prefix,*nextmodule);
2420 
2421  }
2422 
2423  tmp="QwQPD";
2424  trim_file.RewindToFileStart();
2425  if (trim_file.FileHasModuleHeader(tmp)){
2426  nextmodule=trim_file.ReadUntilNextModule();//This section contains sub modules and or channels to be included in the tree
2427  for(size_t i = 0; i < fQPD.size(); i++)
2428  fQPD[i].ConstructBranch(tree, prefix,*nextmodule);
2429  }
2430 
2431  tmp="QwLinearDiodeArray";
2432  trim_file.RewindToFileStart();
2433  if (trim_file.FileHasModuleHeader(tmp)){
2434  nextmodule=trim_file.ReadUntilNextModule();//This section contains sub modules and or channels to be included in the tree
2435  for(size_t i = 0; i < fLinearArray.size(); i++)
2436  fLinearArray[i].ConstructBranch(tree, prefix,*nextmodule);
2437  }
2438 
2439  tmp="QwBPMCavity";
2440  trim_file.RewindToFileStart();
2441  if (trim_file.FileHasModuleHeader(tmp)){
2442  nextmodule=trim_file.ReadUntilNextModule();//This section contains sub modules and or channels to be included in the tree
2443  for(size_t i = 0; i < fCavity.size(); i++)
2444  fCavity[i].ConstructBranch(tree, prefix,*nextmodule);
2445 
2446  }
2447 
2448  tmp="QwBCM";
2449  trim_file.RewindToFileStart();
2450  if (trim_file.FileHasModuleHeader(tmp)){
2451  nextmodule=trim_file.ReadUntilNextModule();//This section contains sub modules and or channels to be included in the tree
2452  for(size_t i = 0; i < fBCM.size(); i++)
2453  fBCM[i].get()->ConstructBranch(tree, prefix,*nextmodule);
2454  }
2455 
2456  tmp="QwClock";
2457  trim_file.RewindToFileStart();
2458  if (trim_file.FileHasModuleHeader(tmp)){
2459  nextmodule=trim_file.ReadUntilNextModule();//This section contains sub modules and or channels to be included in the tree
2460  for(size_t i = 0; i < fClock.size(); i++)
2461  fClock[i].get()->ConstructBranch(tree, prefix,*nextmodule);
2462  }
2463 
2464  tmp="QwHaloMonitor";
2465  trim_file.RewindToFileStart();
2466  if (trim_file.FileHasModuleHeader(tmp)){
2467  nextmodule=trim_file.ReadUntilNextModule();//This section contains sub modules and or channels to be included in the tree
2468  for(size_t i = 0; i < fHaloMonitor.size(); i++)
2469  fHaloMonitor[i].ConstructBranch(tree, prefix,*nextmodule);
2470  }
2471 
2472 
2473  tmp="QwCombinedBCM";
2474  trim_file.RewindToFileStart();
2475  if (trim_file.FileHasModuleHeader(tmp)){
2476  nextmodule=trim_file.ReadUntilNextModule();//This section contains sub modules and or channels to be included in the tree
2477  for(size_t i = 0; i <fBCMCombo.size();i++)
2478  fBCMCombo[i].get()->ConstructBranch(tree, prefix,*nextmodule);
2479  }
2480 
2481 
2482  tmp="QwCombinedBPM";
2483  trim_file.RewindToFileStart();
2484  if (trim_file.FileHasModuleHeader(tmp)){
2485  nextmodule=trim_file.ReadUntilNextModule();//This section contains sub modules and or channels to be included in the tree
2486  for(size_t i = 0; i <fBPMCombo.size();i++)
2487  fBPMCombo[i].get()->ConstructBranch(tree, prefix,*nextmodule);
2488  }
2489 
2490  tmp="QwEnergyCalculator";
2491  trim_file.RewindToFileStart();
2492  if (trim_file.FileHasModuleHeader(tmp)){
2493  nextmodule=trim_file.ReadUntilNextModule();//This section contains sub modules and or channels to be included in the tree
2494  for(size_t i = 0; i <fECalculator.size();i++)
2495  fECalculator[i].ConstructBranch(tree, prefix,*nextmodule);
2496  }
2497 
2498  return;
2499 }
2500 
2501 //*****************************************************************//
2502 void QwBeamLine::FillTreeVector(std::vector<Double_t> &values) const
2503 {
2504  for(size_t i = 0; i < fClock.size(); i++)
2505  fClock[i].get()->FillTreeVector(values);
2506  for(size_t i = 0; i < fStripline.size(); i++)
2507  fStripline[i].get()->FillTreeVector(values);
2508  for(size_t i = 0; i < fQPD.size(); i++)
2509  fQPD[i].FillTreeVector(values);
2510  for(size_t i = 0; i < fLinearArray.size(); i++)
2511  fLinearArray[i].FillTreeVector(values);
2512  for(size_t i = 0; i < fCavity.size(); i++)
2513  fCavity[i].FillTreeVector(values);
2514  for(size_t i = 0; i < fBCM.size(); i++)
2515  fBCM[i].get()->FillTreeVector(values);
2516  for(size_t i = 0; i < fHaloMonitor.size(); i++)
2517  fHaloMonitor[i].FillTreeVector(values);
2518  for(size_t i = 0; i < fBCMCombo.size(); i++)
2519  fBCMCombo[i].get()->FillTreeVector(values);
2520  for(size_t i = 0; i < fBPMCombo.size(); i++)
2521  fBPMCombo[i].get()->FillTreeVector(values);
2522  for(size_t i = 0; i < fECalculator.size(); i++){
2523  fECalculator[i].FillTreeVector(values);}
2524  return;
2525 }
2526 
2527 
2528 //*****************************************************************//
2530 {
2531  std::cout<<"Name of the subsystem ="<<fSystemName<<"\n";
2532  std::cout<<"there are "<<fClock.size()<<" clock \n";
2533  std::cout<<"there are "<<fStripline.size()<<" striplines \n";
2534  std::cout<<"there are "<<fQPD.size()<<" QPDs \n";
2535  std::cout<<"there are "<<fLinearArray.size()<<" LinearArrays \n";
2536  std::cout<<"there are "<<fCavity.size()<<" cavities \n";
2537  std::cout<<"there are "<<fBCM.size()<<" bcm \n";
2538  std::cout<<"there are "<<fHaloMonitor.size()<<" halomonitors \n";
2539  std::cout<<"there are "<<fBCMCombo.size()<<" combined bcms \n";
2540  std::cout<<"there are "<<fBPMCombo.size()<<" combined bpms \n";
2541  std::cout<<"there are "<<fECalculator.size()<<" energy calculators \n";
2542  std::cout<<" Printing Running AVG and other channel info for BCMs"<<std::endl;
2543  for(size_t i=0;i<fBCM.size();i++)
2544  fBCM[i].get()->PrintInfo();
2545  for(size_t i=0;i<fHaloMonitor.size();i++)
2546  fHaloMonitor[i].PrintInfo();
2547  return;
2548 }
2549 
2550 
2551 //*****************************************************************//
2553 {
2554  for (size_t i=0;i<fBeamDetectorID.size();i++)
2555  {
2556  std::cout<<"============================="<<std::endl;
2557  std::cout<<" Detector ID="<<i<<std::endl;
2558  fBeamDetectorID[i].Print();
2559  }
2560  return;
2561 }
2562 
2563 
2564 
2565 //*****************************************************************//
2567 {
2568  const QwBeamLine* input = dynamic_cast<const QwBeamLine*>(source);
2569 
2570  this->fClock.reserve(input->fClock.size());
2571  for(size_t i=0;i<input->fClock.size();i++) {
2572  this->fClock.push_back(VQwClock_ptr(VQwClock::Create(*(input->fClock[i].get()))));
2573  }
2574 
2575  this->fStripline.reserve(input->fStripline.size());
2576  for(size_t i=0;i<input->fStripline.size();i++) {
2577  this->fStripline.push_back(VQwBPM_ptr(
2578  VQwBPM::CreateStripline(*(input->fStripline[i].get()))));
2579  }
2580 
2581  this->fBCM.reserve(input->fBCM.size());
2582  for(size_t i=0;i<input->fBCM.size();i++) {
2583  this->fBCM.push_back(VQwBCM_ptr(
2584  VQwBCM::Create(*(input->fBCM[i].get()))));
2585  }
2586 
2587  this->fBCMCombo.reserve(input->fBCMCombo.size());
2588  for(size_t i=0;i<input->fBCMCombo.size();i++) {
2589  this->fBCMCombo.push_back(VQwBCM_ptr(
2591  input->fBCMCombo[i].get()))));
2592  }
2593 
2594  this->fBPMCombo.reserve(input->fBPMCombo.size());
2595  for(size_t i=0;i<input->fBPMCombo.size();i++){
2596  this->fBPMCombo.push_back(VQwBPM_ptr(
2597  VQwBPM::CreateCombo(*(input->fBPMCombo[i].get()))));
2598  }
2599 }
2600 
2601 //*****************************************************************//
2602 void QwBeamLine::FillDB(QwParityDB *db, TString datatype)
2603 {
2604 
2605  Bool_t local_print_flag = false;
2606 
2607  if(local_print_flag) {
2608  QwMessage << " --------------------------------------------------------------- " << QwLog::endl;
2609  QwMessage << " QwBeamLine::FillDB " << QwLog::endl;
2610  QwMessage << " --------------------------------------------------------------- " << QwLog::endl;
2611  }
2612 
2613  std::vector<QwDBInterface> interface;
2614  std::vector<QwParitySSQLS::beam> entrylist;
2615 
2616  UInt_t analysis_id = db->GetAnalysisID();
2617 
2618  TString measurement_type_bcm;
2619  TString measurement_type_bpm;
2620  TString measurement_type_halo;
2621 
2622  measurement_type_bcm =
2624  measurement_type_bpm =
2625  QwDBInterface::DetermineMeasurementTypeID(datatype,"p",kTRUE);
2626  measurement_type_halo =
2628 
2629  UInt_t i,j;
2630  i = j = 0;
2631  // try to access BCM mean and its error
2632  // there are 2 different types BCM data we have at the moment
2633  // Yield and Asymmetry
2634  if(local_print_flag) QwMessage << QwColor(Qw::kGreen) << "Beam Current Monitors" <<QwLog::endl;
2635 
2636  for(i=0; i< fBCM.size(); i++) {
2637  interface.clear();
2638  interface = fBCM[i].get()->GetDBEntry();
2639  for (j=0; j<interface.size(); j++){
2640  interface.at(j).SetAnalysisID( analysis_id );
2641  interface.at(j).SetMonitorID( db );
2642  interface.at(j).SetMeasurementTypeID( measurement_type_bcm );
2643  interface.at(j).PrintStatus( local_print_flag );
2644  interface.at(j).AddThisEntryToList( entrylist );
2645  }
2646  }
2647 
2648  /// try to access BPM mean and its error
2649  if(local_print_flag) QwMessage << QwColor(Qw::kGreen) << "Beam Position Monitors" <<QwLog::endl;
2650  for(i=0; i< fStripline.size(); i++) {
2651  // fStripline[i].MakeBPMList();
2652  interface.clear();
2653  interface = fStripline[i].get()->GetDBEntry();
2654  for (j=0; j<interface.size()-5; j++){
2655  interface.at(j).SetAnalysisID( analysis_id ) ;
2656  interface.at(j).SetMonitorID( db );
2657  interface.at(j).SetMeasurementTypeID( measurement_type_bpm );
2658  interface.at(j).PrintStatus( local_print_flag);
2659  interface.at(j).AddThisEntryToList( entrylist );
2660  }
2661  // effective charge (last 4 elements) need to be saved as measurement_type_bcm
2662  for (j=interface.size()-5; j<interface.size(); j++){
2663  interface.at(j).SetAnalysisID( analysis_id ) ;
2664  interface.at(j).SetMonitorID( db );
2665  interface.at(j).SetMeasurementTypeID( measurement_type_bcm );
2666  interface.at(j).PrintStatus( local_print_flag);
2667  interface.at(j).AddThisEntryToList( entrylist );
2668  }
2669  }
2670 
2671 
2672  /// try to access CombinedBPM means and errors
2673  if(local_print_flag) QwMessage << QwColor(Qw::kGreen) << "Combined Beam Position Monitors" <<QwLog::endl;
2674  for(i=0; i< fBPMCombo.size(); i++) {
2675  // fBPMCombo[i].MakeBPMComboList();
2676  interface.clear();
2677  interface = fBPMCombo[i].get()->GetDBEntry();
2678  for (j=0; j<interface.size()-5; j++){
2679  interface.at(j).SetAnalysisID( analysis_id ) ;
2680  interface.at(j).SetMonitorID( db );
2681  interface.at(j).SetMeasurementTypeID( measurement_type_bpm );
2682  interface.at(j).PrintStatus( local_print_flag);
2683  interface.at(j).AddThisEntryToList( entrylist );
2684  }
2685  // effective charge (last element) need to be saved as measurement_type_bcm
2686  for (j=interface.size()-5; j<interface.size(); j++){
2687  interface.at(j).SetAnalysisID( analysis_id ) ;
2688  interface.at(j).SetMonitorID( db );
2689  interface.at(j).SetMeasurementTypeID( measurement_type_bcm );
2690  interface.at(j).PrintStatus( local_print_flag);
2691  interface.at(j).AddThisEntryToList( entrylist );
2692  }
2693  }
2694 
2695  /// try to access CombinedBCM means and errors
2696  if(local_print_flag) QwMessage << QwColor(Qw::kGreen) << "Combined Beam Current Monitors" <<QwLog::endl;
2697 
2698  for(i=0; i< fBCMCombo.size(); i++) {
2699  interface.clear();
2700  interface = fBCMCombo[i].get()->GetDBEntry();
2701  for (j=0; j<interface.size(); j++){
2702  interface.at(j).SetAnalysisID( analysis_id );
2703  interface.at(j).SetMonitorID( db );
2704  interface.at(j).SetMeasurementTypeID( measurement_type_bcm );
2705  interface.at(j).PrintStatus( local_print_flag );
2706  interface.at(j).AddThisEntryToList( entrylist );
2707  }
2708  }
2709 
2710  /// try to access Energy Calculator mean and its error
2711  if(local_print_flag) QwMessage << QwColor(Qw::kGreen) << "Energy Calculator" <<QwLog::endl;
2712 
2713  for(i=0; i< fECalculator.size(); i++) {
2714  interface.clear();
2715  interface = fECalculator[i].GetDBEntry();
2716  for (j=0; j<interface.size(); j++){
2717  interface.at(j).SetAnalysisID( analysis_id );
2718  interface.at(j).SetMonitorID( db );
2719  interface.at(j).SetMeasurementTypeID( measurement_type_bpm );
2720  interface.at(j).PrintStatus( local_print_flag );
2721  interface.at(j).AddThisEntryToList( entrylist );
2722  }
2723  }
2724 
2725 
2726  /// try to access QPD mean and its error
2727  if(local_print_flag) QwMessage << QwColor(Qw::kGreen) << "Quadrant PhotoDiodes" <<QwLog::endl;
2728  for(i=0; i< fQPD.size(); i++) {
2729  // fQPD[i].MakeQPDList();
2730  interface.clear();
2731  interface = fQPD[i].GetDBEntry();
2732  for (j=0; j<interface.size()-5; j++){
2733  interface.at(j).SetAnalysisID( analysis_id ) ;
2734  interface.at(j).SetMonitorID( db );
2735  interface.at(j).SetMeasurementTypeID( measurement_type_bpm );
2736  interface.at(j).PrintStatus( local_print_flag);
2737  interface.at(j).AddThisEntryToList( entrylist );
2738  }
2739  // effective charge need (last element) to be saved as measurement_type_bcm
2740  for (j=interface.size()-5; j<interface.size(); j++){
2741  interface.at(j).SetAnalysisID( analysis_id ) ;
2742  interface.at(j).SetMonitorID( db );
2743  interface.at(j).SetMeasurementTypeID( measurement_type_bcm );
2744  interface.at(j).PrintStatus( local_print_flag);
2745  interface.at(j).AddThisEntryToList( entrylist );
2746  }
2747  }
2748 
2749  /// try to access LinearArray mean and its error
2750  if(local_print_flag) QwMessage << QwColor(Qw::kGreen) << "Linear PhotoDiode Array" <<QwLog::endl;
2751  for(i=0; i< fLinearArray.size(); i++) {
2752  // fLinearArray[i].MakeLinearArrayList();
2753  interface.clear();
2754  interface = fLinearArray[i].GetDBEntry();
2755  for (j=0; j<interface.size()-5; j++){
2756  interface.at(j).SetAnalysisID( analysis_id ) ;
2757  interface.at(j).SetMonitorID( db );
2758  interface.at(j).SetMeasurementTypeID( measurement_type_bpm );
2759  interface.at(j).PrintStatus( local_print_flag);
2760  interface.at(j).AddThisEntryToList( entrylist );
2761  }
2762  for (j=interface.size()-5; j<interface.size(); j++){
2763  interface.at(j).SetAnalysisID( analysis_id ) ;
2764  interface.at(j).SetMonitorID( db );
2765  interface.at(j).SetMeasurementTypeID( measurement_type_bcm );
2766  interface.at(j).PrintStatus( local_print_flag);
2767  interface.at(j).AddThisEntryToList( entrylist );
2768  }
2769  }
2770 
2771  /// try to access cavity bpm mean and its error
2772  if(local_print_flag) QwMessage << QwColor(Qw::kGreen) << "Cavity Monitors" <<QwLog::endl;
2773  for(i=0; i< fCavity.size(); i++) {
2774  // fCavity[i].MakeBPMCavityList();
2775  interface.clear();
2776  interface = fCavity[i].GetDBEntry();
2777  for (j=0; j<interface.size()-5; j++){
2778  interface.at(j).SetAnalysisID( analysis_id ) ;
2779  interface.at(j).SetMonitorID( db );
2780  interface.at(j).SetMeasurementTypeID( measurement_type_bpm );
2781  interface.at(j).PrintStatus( local_print_flag);
2782  interface.at(j).AddThisEntryToList( entrylist );
2783  }
2784  for (j=interface.size()-5; j<interface.size(); j++){
2785  interface.at(j).SetAnalysisID( analysis_id ) ;
2786  interface.at(j).SetMonitorID( db );
2787  interface.at(j).SetMeasurementTypeID( measurement_type_bcm );
2788  interface.at(j).PrintStatus( local_print_flag);
2789  interface.at(j).AddThisEntryToList( entrylist );
2790  }
2791  }
2792 
2793  // try to access halo mean and its error
2794  if(local_print_flag) QwMessage << QwColor(Qw::kGreen) << "Halo Monitors" <<QwLog::endl;
2795 
2796  for(i=0; i< fHaloMonitor.size(); i++) {
2797  interface.clear();
2798  interface = fHaloMonitor[i].GetDBEntry();
2799  for (j=0; j<interface.size(); j++){
2800  interface.at(j).SetAnalysisID( analysis_id );
2801  interface.at(j).SetMonitorID( db );
2802  interface.at(j).SetMeasurementTypeID( measurement_type_halo );
2803  interface.at(j).PrintStatus( local_print_flag );
2804  interface.at(j).AddThisEntryToList( entrylist );
2805  }
2806  }
2807 
2808  if(local_print_flag){
2809  QwMessage << QwColor(Qw::kGreen) << "Entrylist Size : "
2810  << QwColor(Qw::kBoldRed) << entrylist.size()
2812  }
2813 
2814  db->Connect();
2815  // Check the entrylist size, if it isn't zero, start to query..
2816  if( entrylist.size() ) {
2817  mysqlpp::Query query= db->Query();
2818  query.insert(entrylist.begin(), entrylist.end());
2819  query.execute();
2820  }
2821  else {
2822  QwMessage << "QwBeamLine::FillDB :: This is the case when the entrlylist contains nothing in "<< datatype.Data() << QwLog::endl;
2823  }
2824  db->Disconnect();
2825 
2826  return;
2827 }
2828 
2829 
2830 void QwBeamLine::FillErrDB(QwParityDB *db, TString datatype)
2831 {
2832 
2833  Bool_t local_print_flag = false;
2834 
2835  if(local_print_flag) {
2836  QwMessage << " --------------------------------------------------------------- " << QwLog::endl;
2837  QwMessage << " QwBeamLine::FillErrDB " << QwLog::endl;
2838  QwMessage << " --------------------------------------------------------------- " << QwLog::endl;
2839  }
2840 
2841  std::vector<QwErrDBInterface> interface;
2842  std::vector<QwParitySSQLS::beam_errors> entrylist;
2843 
2844  UInt_t analysis_id = db->GetAnalysisID();
2845 
2846  UInt_t i,j;
2847  i = j = 0;
2848 
2849  if(local_print_flag) QwMessage << QwColor(Qw::kGreen) << "Beam Current Monitors" <<QwLog::endl;
2850  for(i=0; i< fBCM.size(); i++) {
2851  interface.clear();
2852  interface = fBCM[i].get()->GetErrDBEntry();
2853  for (j=0; j<interface.size(); j++){
2854  interface.at(j).SetAnalysisID( analysis_id );
2855  interface.at(j).SetMonitorID( db );
2856  interface.at(j).PrintStatus( local_print_flag );
2857  interface.at(j).AddThisEntryToList( entrylist );
2858  }
2859  if(local_print_flag) printf("\n");
2860  }
2861 
2862  /// try to access BPM mean and its error
2863  if(local_print_flag) QwMessage << QwColor(Qw::kGreen) << "Beam Position Monitors" <<QwLog::endl;
2864  for(i=0; i< fStripline.size(); i++) {
2865  interface.clear();
2866  interface = fStripline[i].get()->GetErrDBEntry();
2867  for (j=0; j<interface.size(); j++){
2868  interface.at(j).SetAnalysisID( analysis_id ) ;
2869  interface.at(j).SetMonitorID( db );
2870  interface.at(j).PrintStatus( local_print_flag );
2871  interface.at(j).AddThisEntryToList( entrylist );
2872  }
2873  if(local_print_flag) printf("\n");
2874  }
2875 
2876  if(local_print_flag) QwMessage << QwColor(Qw::kGreen) << "Combined Beam Position Monitors" <<QwLog::endl;
2877  for(i=0; i< fBPMCombo.size(); i++) {
2878  interface.clear();
2879  interface = fBPMCombo[i].get()->GetErrDBEntry();
2880  for (j=0; j<interface.size(); j++){
2881  interface.at(j).SetAnalysisID( analysis_id ) ;
2882  interface.at(j).SetMonitorID( db );
2883  interface.at(j).PrintStatus( local_print_flag );
2884  interface.at(j).AddThisEntryToList( entrylist );
2885  }
2886  if(local_print_flag) printf("\n");
2887  }
2888 
2889  /// try to access CombinedBCM means and errors
2890  if(local_print_flag) QwMessage << QwColor(Qw::kGreen) << "Combined Beam Current Monitors" <<QwLog::endl;
2891  for(i=0; i< fBCMCombo.size(); i++) {
2892  interface.clear();
2893  interface = fBCMCombo[i].get()->GetErrDBEntry();
2894  for (j=0; j<interface.size(); j++){
2895  interface.at(j).SetAnalysisID( analysis_id ) ;
2896  interface.at(j).SetMonitorID( db );
2897  interface.at(j).PrintStatus( local_print_flag );
2898  interface.at(j).AddThisEntryToList( entrylist );
2899  }
2900  if(local_print_flag) printf("\n");
2901  }
2902 
2903  /// try to access Energy Calculator mean and its error
2904  if(local_print_flag) QwMessage << QwColor(Qw::kGreen) << "Energy Calculator" <<QwLog::endl;
2905  for(i=0; i< fECalculator.size(); i++) {
2906  interface.clear();
2907  interface = fECalculator[i].GetErrDBEntry();
2908  for (j=0; j<interface.size(); j++){
2909  interface.at(j).SetAnalysisID( analysis_id ) ;
2910  interface.at(j).SetMonitorID( db );
2911  interface.at(j).PrintStatus( local_print_flag );
2912  interface.at(j).AddThisEntryToList( entrylist );
2913  }
2914  if(local_print_flag) printf("\n");
2915  }
2916 
2917  /// try to access QPD mean and its error
2918  if(local_print_flag) QwMessage << QwColor(Qw::kGreen) << "Quadrant PhotoDiodes" <<QwLog::endl;
2919  for(i=0; i< fQPD.size(); i++) {
2920  interface.clear();
2921  interface = fQPD[i].GetErrDBEntry();
2922  for (j=0; j<interface.size(); j++){
2923  interface.at(j).SetAnalysisID( analysis_id ) ;
2924  interface.at(j).SetMonitorID( db );
2925  interface.at(j).PrintStatus( local_print_flag );
2926  interface.at(j).AddThisEntryToList( entrylist );
2927  }
2928  if(local_print_flag) printf("\n");
2929  }
2930 
2931  /// try to access LinearArray mean and its error
2932  if(local_print_flag) QwMessage << QwColor(Qw::kGreen) << "Linear PhotoDiode Array" <<QwLog::endl;
2933  for(i=0; i< fLinearArray.size(); i++) {
2934  interface.clear();
2935  interface = fLinearArray[i].GetErrDBEntry();
2936  for (j=0; j<interface.size(); j++){
2937  interface.at(j).SetAnalysisID( analysis_id ) ;
2938  interface.at(j).SetMonitorID( db );
2939  interface.at(j).PrintStatus( local_print_flag );
2940  interface.at(j).AddThisEntryToList( entrylist );
2941  }
2942  if(local_print_flag) printf("\n");
2943  }
2944 
2945  /// try to access cavity bpm mean and its error
2946  if(local_print_flag) QwMessage << QwColor(Qw::kGreen) << "Cavity Monitors" <<QwLog::endl;
2947  for(i=0; i< fCavity.size(); i++) {
2948  interface.clear();
2949  interface = fCavity[i].GetErrDBEntry();
2950  for (j=0; j<interface.size(); j++){
2951  interface.at(j).SetAnalysisID( analysis_id ) ;
2952  interface.at(j).SetMonitorID( db );
2953  interface.at(j).PrintStatus( local_print_flag );
2954  interface.at(j).AddThisEntryToList( entrylist );
2955  }
2956  if(local_print_flag) printf("\n");
2957  }
2958 
2959  // try to access halo mean and its error
2960  if(local_print_flag) QwMessage << QwColor(Qw::kGreen) << "Halo Monitors" <<QwLog::endl;
2961  for(i=0; i< fHaloMonitor.size(); i++) {
2962  interface.clear();
2963  interface = fHaloMonitor[i].GetErrDBEntry();
2964  for (j=0; j<interface.size(); j++){
2965  interface.at(j).SetAnalysisID( analysis_id ) ;
2966  interface.at(j).SetMonitorID( db );
2967  interface.at(j).PrintStatus( local_print_flag );
2968  interface.at(j).AddThisEntryToList( entrylist );
2969  }
2970  if(local_print_flag) printf("\n");
2971  }
2972 
2973 
2974  if(local_print_flag){
2975  QwMessage << QwColor(Qw::kGreen) << "Entrylist Size : "
2976  << QwColor(Qw::kBoldRed) << entrylist.size()
2978  }
2979 
2980  db->Connect();
2981  // Check the entrylist size, if it isn't zero, start to query..
2982  if( entrylist.size() ) {
2983  mysqlpp::Query query= db->Query();
2984  query.insert(entrylist.begin(), entrylist.end());
2985  query.execute();
2986  }
2987  else {
2988  QwMessage << "QwBeamLine::FillErrDB :: This is the case when the entrlylist contains nothing in "<< datatype.Data() << QwLog::endl;
2989  }
2990  db->Disconnect();
2991  return;
2992 }
2993 
2994 
2996 {
2997  Bool_t local_print_flag = true;
2998 
2999  if(local_print_flag) {
3000  printf("---------------------------------------------------------------\n");
3001  printf("QwBeamLine::WritePromptSummary() Type : %12s\n", type.Data());
3002  printf("---------------------------------------------------------------\n");
3003  }
3004 
3005  TString element_name = "";
3006  Double_t element_value = 0.0;
3007  Double_t element_value_err = 0.0;
3008  Double_t element_value_width = 0.0;
3009 
3010  PromptSummaryElement *local_ps_element = NULL;
3011 
3012  // Double_t asymmetry_ppm = 1e-6;
3013 
3014  for (size_t i = 0; i < fBCM.size(); i++)
3015  {
3016  element_name = fBCM[i].get()->GetElementName();
3017  element_value = 0.0;
3018  element_value_err = 0.0;
3019  element_value_width = 0.0;
3020 
3021  if (element_name.Contains("qwk_bcm1")) {
3022  local_ps_element = ps-> GetElementByName("bcm1");
3023  } else if (element_name.Contains("qwk_bcm2")) {
3024  local_ps_element = ps-> GetElementByName("bcm2");
3025  } else if (element_name.Contains("qwk_bcm5")) {
3026  local_ps_element = ps-> GetElementByName("bcm5");
3027  } else if (element_name.Contains("qwk_bcm6")) {
3028  local_ps_element = ps-> GetElementByName("bcm6");
3029  } else if (element_name.Contains("qwk_bcm7")) {
3030  local_ps_element = ps-> GetElementByName("bcm7");
3031  } else if (element_name.Contains("qwk_bcm8")) {
3032  local_ps_element = ps-> GetElementByName("bcm8");
3033  } else {
3034  local_ps_element = NULL;
3035  }
3036 
3037  if(local_ps_element) {
3038  element_value = fBCM[i].get()->GetValue();
3039  element_value_err = fBCM[i].get()->GetValueError();
3040  element_value_width = fBCM[i].get()->GetValueWidth();
3041 
3042  local_ps_element->Set(type, element_value, element_value_err, element_value_width);
3043  }
3044 
3045  if( local_print_flag && local_ps_element) {
3046  printf("Type %12s, Element %32s, value %12.4e error %8.4e width %12.4e\n",
3047  type.Data(), element_name.Data(), element_value, element_value_err, element_value_width);
3048  }
3049  }
3050 
3051  ps->FillDoubleDifference(type, "bcm1", "bcm2");
3052  ps->FillDoubleDifference(type, "bcm1", "bcm5");
3053  ps->FillDoubleDifference(type, "bcm1", "bcm6");
3054  ps->FillDoubleDifference(type, "bcm2", "bcm5");
3055  ps->FillDoubleDifference(type, "bcm2", "bcm6");
3056  ps->FillDoubleDifference(type, "bcm5", "bcm6");
3057 
3058  ps->FillDoubleDifference(type, "bcm1", "bcm7");
3059  ps->FillDoubleDifference(type, "bcm1", "bcm8");
3060 
3061  ps->FillDoubleDifference(type, "bcm5", "bcm7");
3062  ps->FillDoubleDifference(type, "bcm7", "bcm8");
3063 
3064 
3065 
3066  // for(size_t i=0; i< fStripline.size(); i++)
3067  // {
3068  // element_name = fStripline[i].get()->GetElementName();
3069  // element_value = 0.0;
3070  // element_value_err = 0.0;
3071  // element_value_width = 0.0;
3072 
3073 
3074  // printf("Strip BPM %d, name %s\n", (Int_t) i, element_name.Data());
3075  // // if (element_name.Contains("qwk_bcm1")) {
3076  // // local_ps_element = ps-> GetElementByName("bcm1");
3077  // // } else if (element_name.Contains("qwk_bcm2")) {
3078  // // local_ps_element = ps-> GetElementByName("bcm2");
3079  // // } else if (element_name.Contains("qwk_bcm5")) {
3080  // // local_ps_element = ps-> GetElementByName("bcm5");
3081  // // } else if (element_name.Contains("qwk_bcm6")) {
3082  // // local_ps_element = ps-> GetElementByName("bcm6");
3083  // // } else if (element_name.Contains("qwk_bcm7")) {
3084  // // local_ps_element = ps-> GetElementByName("bcm7");
3085  // // } else if (element_name.Contains("qwk_bcm8")) {
3086  // // local_ps_element = ps-> GetElementByName("bcm8");
3087  // // } else {
3088  // // local_ps_element = NULL;
3089  // // }
3090 
3091  // }
3092 
3093  // for(size_t i=0; i< fBPMCombo.size(); i++)
3094  // {
3095  // element_name = fBPMCombo[i].get()->GetElementName();
3096  // element_value = 0.0;
3097  // element_value_err = 0.0;
3098  // element_value_width = 0.0;
3099  // printf("Combo BPM %d, name %s\n", (Int_t) i, element_name.Data());
3100  // }
3101 
3102  return;
3103 };
Int_t GetSubbankIndex() const
Definition: VQwSubsystem.h:303
void AssignGeometry(QwParameterFile *mapstr, VQwBPM *bpm)
Definition: QwBeamLine.cc:776
#define QwMessage
Predefined log drain for regular messages.
Definition: QwLog.h:50
std::vector< VQwBPM_ptr > fBPMCombo
Definition: QwBeamLine.h:170
boost::shared_ptr< VQwBCM > VQwBCM_ptr
Definition: VQwBCM.h:122
std::map< TString, TString > fDetectorMaps
Definition: VQwSubsystem.h:322
void PrintDetectorID() const
Definition: QwBeamLine.cc:2552
void Scale(Double_t factor)
Definition: QwBeamLine.cc:2115
virtual Bool_t NeedsExternalClock()
Int_t fQwBeamLineErrorCount
Definition: QwBeamLine.h:189
QwBPMCavity * GetBPMCavity(const TString name)
Definition: QwBeamLine.cc:1762
static VQwBCM * Create(TString subsystemname, TString type, TString name, TString clock="")
A fast way of creating a BCM of specified type.
Definition: VQwBCM.cc:27
UInt_t GetEventcutErrorFlag()
Return the error flag to the top level routines related to stability checks and ErrorFlag updates...
Definition: QwBeamLine.cc:1332
Definition: VQwBCM.h:32
EQwBeamInstrumentType GetQwBeamInstrumentType(TString name)
Definition: QwTypes.cc:29
void FillDoubleDifference(TString type, TString name1, TString name2)
Bool_t PublishInternalValues() const
Publish all variables of the subsystem.
Definition: QwBeamLine.cc:1487
void Difference(VQwSubsystem *value1, VQwSubsystem *value2)
Definition: QwBeamLine.cc:2062
void Disconnect()
Definition: QwDatabase.h:59
Bool_t ApplySingleEventCuts()
Apply the single event cuts.
Definition: QwBeamLine.cc:1172
static const Bool_t bDEBUG
Definition: QwBeamLine.h:192
Bool_t Connect()
Open a connection to the database using the predefined parameters.
Definition: QwDatabase.cc:175
An options class.
Definition: QwOptions.h:133
static UInt_t GetUInt(const TString &varvalue)
std::vector< QwBPMCavity > fCavity
Definition: QwBeamLine.h:179
QwEnergyCalculator * GetEnergyCalculator(const TString name)
Definition: QwBeamLine.cc:1845
static VQwClock * Create(TString subsystemname, TString type, TString name)
A fast way of creating a Clock of specified type.
Definition: VQwClock.cc:26
boost::shared_ptr< VQwClock > VQwClock_ptr
Definition: VQwClock.h:94
UInt_t UpdateErrorFlag()
Uses the error flags of contained data elements to update Returns the error flag to the top level rou...
Definition: QwBeamLine.cc:1367
std::vector< QwEnergyCalculator > fECalculator
Definition: QwBeamLine.h:183
void PrintValue() const
Print values of all channels.
Definition: QwBeamLine.cc:2146
void TrimComment(const char commentchar)
Int_t LoadChannelMap(TString mapfile)
Mandatory map file definition.
Definition: QwBeamLine.cc:94
void CalculateRunningAverage()
Calculate the average for all good events.
Definition: QwBeamLine.cc:2131
void Ratio(VQwSubsystem *numer, VQwSubsystem *denom)
Definition: QwBeamLine.cc:2073
VQwBCM * GetCombinedBCM(const TString name)
Definition: QwBeamLine.cc:1811
virtual const VQwHardwareChannel * GetEffectiveCharge() const =0
Bool_t ReportInitErrors() const
void GetSurveyOffsets(Double_t Xoffset, Double_t Yoffset, Double_t Zoffset)
Definition: VQwBPM.cc:36
UInt_t GetAnalysisID()
Definition: QwParityDB.h:71
TString GetQwBeamInstrumentTypeName(EQwBeamInstrumentType type)
Definition: QwTypes.cc:95
Int_t LoadInputParameters(TString pedestalfile)
Mandatory parameter file definition.
Definition: QwBeamLine.cc:821
virtual void LoadChannelParameters(QwParameterFile &paramfile)
const VQwHardwareChannel * GetChannel(EQwBeamInstrumentType TypeID, Int_t index, TString device_prop) const
Definition: QwBeamLine.cc:1703
virtual void ConstructHistograms()
Construct the histograms for this subsystem.
Definition: VQwSubsystem.h:209
static void PrintErrorCounterHead()
QwParameterFile * ReadNextSection(std::string &secname, const bool keep_header=false)
void SetRotationOff()
Definition: VQwBPM.cc:85
std::vector< VQwClock_ptr > fClock
Definition: QwBeamLine.h:175
virtual const VQwHardwareChannel * GetPosition(EBeamPositionMonitorAxis axis) const =0
Int_t ProcessConfigurationBuffer(const UInt_t roc_id, const UInt_t bank_id, UInt_t *buffer, UInt_t num_words)
Definition: QwBeamLine.cc:1480
VQwClock * GetClock(const TString name)
Definition: QwBeamLine.cc:1794
void PrintErrorCounters() const
Report the number of events failed due to HW and event cut failures.
Definition: QwBeamLine.cc:1249
Int_t AddToElementList(std::vector< TT > &elementlist, QwBeamDetectorID &detector_id)
Adds a new element to a vector of data elements, and returns the index of that element within the arr...
Definition: QwBeamLine.cc:82
std::vector< VQwBCM_ptr > fBCM
Definition: QwBeamLine.h:172
std::vector< VQwBPM_ptr > fStripline
Definition: QwBeamLine.h:169
void FillDB(QwParityDB *db, TString datatype)
Fill the database.
Definition: QwBeamLine.cc:2602
VQwSubsystem & operator=(VQwSubsystem *value)
Assignment Note: Must be called at the beginning of all subsystems routine call to operator=(VQwSubsy...
Definition: QwBeamLine.cc:1919
void ProcessEvent()
Definition: QwBeamLine.cc:1440
Bool_t FileHasModuleHeader(const std::string &secname)
The pure virtual base class of all data elements.
Int_t GetDetectorIndex(EQwBeamInstrumentType TypeID, TString name) const
Definition: QwBeamLine.cc:1620
VQwBCM * GetBCM(const TString name)
Definition: QwBeamLine.cc:1776
#define QwDebug
Predefined log drain for debugging output.
Definition: QwLog.h:60
void EncodeEventData(std::vector< UInt_t > &buffer)
Definition: QwBeamLine.cc:1006
A logfile class, based on an identical class in the Hermes analyzer.
std::vector< QwHaloMonitor > fHaloMonitor
Definition: QwBeamLine.h:180
void ConstructBranchAndVector(TTree *tree, TString &prefix, std::vector< Double_t > &values)
Construct the branch and tree vector.
Definition: QwBeamLine.cc:2350
EQwBeamInstrumentType fTypeID
void PrintInfo() const
Print some information about the subsystem.
Definition: QwBeamLine.cc:2529
TString fSystemName
Name of this subsystem.
Definition: VQwSubsystem.h:315
void SetRotation(Double_t)
Definition: VQwBPM.cc:68
void AccumulateRunningSum(VQwSubsystem *value)
Update the running sums for devices.
Definition: QwBeamLine.cc:2173
mysqlpp::Query Query(const char *qstr=0)
Definition: QwDatabase.h:66
void FillErrDB(QwParityDB *db, TString datatype)
Definition: QwBeamLine.cc:2830
Bool_t ReadNextLine()
QwHaloMonitor * GetScalerChannel(const TString name)
Definition: QwBeamLine.cc:1865
void FillTreeVector(std::vector< Double_t > &values) const
Fill the tree vector.
Definition: QwBeamLine.cc:2502
Int_t LoadEventCuts(TString filename)
Load the event cuts file.
Definition: QwBeamLine.cc:425
Bool_t PublishByRequest(TString device_name)
Try to publish an internal variable matching the submitted name.
Definition: QwBeamLine.cc:1538
void WritePromptSummary(QwPromptSummary *ps, TString type)
Definition: QwBeamLine.cc:2995
void Set(TString type, const Double_t a, const Double_t a_err, const Double_t a_width)
std::vector< std::vector< TString > > fPublishList
List of parameters to be published (loaded at the channel map)
Definition: VQwSubsystem.h:144
The pure virtual base class of all subsystems.
Definition: VQwSubsystem.h:59
virtual std::string GetExternalClockName()
void IncrementErrorCounters()
Increment the error counters.
Definition: QwBeamLine.cc:1297
virtual void SetExternalClockPtr(const VQwHardwareChannel *clock)
A color changing class for the output stream.
Definition: QwColor.h:98
Int_t fCurrentROC_ID
ROC ID that is currently being processed.
Definition: VQwSubsystem.h:325
Int_t RegisterSubbank(const UInt_t bank_id)
Tell the object that it will decode data from this sub-bank in the ROC currently open for registratio...
virtual Int_t RegisterROCNumber(const UInt_t roc_id, const UInt_t bank_id=0)
Tell the object that it will decode data from this ROC and sub-bank.
std::vector< VQwBCM_ptr > fBCMCombo
Definition: QwBeamLine.h:173
Bool_t Compare(VQwSubsystem *source)
Definition: QwBeamLine.cc:2233
std::vector< QwBeamDetectorID > fBeamDetectorID
Definition: QwBeamLine.h:184
static std::ostream & endl(std::ostream &)
End of the line.
Definition: QwLog.cc:299
std::vector< QwLinearDiodeArray > fLinearArray
Definition: QwBeamLine.h:178
Definition: VQwBPM.h:34
Int_t ProcessEvBuffer(const UInt_t roc_id, const UInt_t bank_id, UInt_t *buffer, UInt_t num_words)
TODO: The non-event-type-aware ProcessEvBuffer routine should be replaced with the event-type-aware v...
Definition: QwBeamLine.cc:1048
virtual const TString & GetElementName() const
Get the name of this element.
VQwDataElement * GetElement(QwBeamDetectorID det_id)
Definition: QwBeamLine.cc:1643
static VQwBPM * CreateCombo(TString subsystemname, TString type, TString name)
A fast way of creating a BPM stripline of specified type.
Definition: VQwBPM.cc:268
void ClearEventData()
Definition: QwBeamLine.cc:1593
void RandomizeEventData(int helicity=0, double time=0.0)
Definition: QwBeamLine.cc:986
T GetTypedNextToken()
Get next token into specific type.
void ConstructBranch(TTree *tree, TString &prefix)
Construct the branch and tree vector.
Definition: QwBeamLine.cc:2378
void TrimWhitespace(TString::EStripType head_tail=TString::kBoth)
VQwSubsystem & operator-=(VQwSubsystem *value)
Definition: QwBeamLine.cc:2007
static TString DetermineMeasurementTypeID(TString type, TString suffix="", Bool_t forcediffs=kFALSE)
void SetGains(TString pos, Double_t value)
Definition: VQwBPM.cc:92
EQwBeamInstrumentType
Definition: QwTypes.h:132
void FillHistograms()
Fill the histograms for this subsystem.
Definition: QwBeamLine.cc:2322
static VQwBPM * CreateStripline(TString subsystemname, TString type, TString name)
A fast way of creating a BPM stripline of specified type.
Definition: VQwBPM.cc:225
Bool_t PublishInternalValue(const TString &name, const TString &desc, const VQwHardwareChannel *value) const
Publish a variable name to the parent subsystem array.
static void PrintErrorCounterTail()
void DeaccumulateRunningSum(VQwSubsystem *value)
remove one entry from the running sums for devices
Definition: QwBeamLine.cc:2203
#define QwWarning
Predefined log drain for warnings.
Definition: QwLog.h:45
void ProcessOptions(QwOptions &options)
Process the command line options.
Definition: QwBeamLine.cc:30
boost::shared_ptr< VQwBPM > VQwBPM_ptr
Definition: VQwBPM.h:279
void CopyTemplatedDataElements(const VQwSubsystem *source)
Definition: QwBeamLine.cc:2566
VQwSubsystem & operator+=(VQwSubsystem *value)
Definition: QwBeamLine.cc:1964
void GetElectronicFactors(Double_t BSENfactor, Double_t AlphaX, Double_t AlphaY)
Definition: VQwBPM.cc:47
std::vector< QwQPD > fQPD
Definition: QwBeamLine.h:177
VQwBPM * GetBPMStripline(const TString name)
Definition: QwBeamLine.cc:1748
Int_t fCurrentBank_ID
Bank ID that is currently being processed.
Definition: VQwSubsystem.h:326
static VQwBCM * CreateCombo(TString subsystemname, TString type, TString name)
A fast way of creating a combo BCM of specified type.
Definition: VQwBCM.cc:70
QwParameterFile * ReadUntilNextModule(const bool add_current_line=false)
VQwBPM * GetCombinedBPM(const TString name)
Definition: QwBeamLine.cc:1828
#define RegisterSubsystemFactory(A)
Definition: QwFactory.h:230
void Sum(VQwSubsystem *value1, VQwSubsystem *value2)
Definition: QwBeamLine.cc:2051
#define QwError
Predefined log drain for errors.
Definition: QwLog.h:40
UInt_t GetGlobalErrorFlag(TString evtype, Int_t evMode, Double_t stabilitycut)
Definition: QwTypes.cc:127
Int_t LoadGeometryDefinition(TString mapfile)
Optional geometry definition.
Definition: QwBeamLine.cc:597
TString GetSubsystemName() const
Definition: VQwSubsystem.h:93