QwAnalysis
QwEventRing.cc
Go to the documentation of this file.
1 
2 #include "QwEventRing.h"
3 
4 
5 
7 : fRollingAvg(event)
8 {
9  fRING_SIZE=ring_size;
10  fEvent_Ring.resize(fRING_SIZE,event);
11 
12  bRING_READY=kFALSE;
13  bEVENT_READY=kTRUE;
15  fNextToBeRead=0;
16 
17  //open the log file
18  if (bDEBUG_Write)
19  out_file = fopen("Ring_log.txt", "wt");
20 }
21 
22 
24 : fRollingAvg(event)
25 {
26  ProcessOptions(options);
27 
28  fEvent_Ring.resize(fRING_SIZE,event);
29 
30  bRING_READY=kFALSE;
31  bEVENT_READY=kTRUE;
33  fNextToBeRead=0;
34 
35  //open the log file
36  if (bDEBUG_Write)
37  out_file = fopen("Ring_log.txt", "wt");
38 }
39 
40 
42 {
43  // Define the execution options
44  options.AddDefaultOptions();
45  options.AddOptions()("ring.size",
46  po::value<int>()->default_value(4800),
47  "QwEventRing: ring/buffer size");
48  options.AddOptions()("ring.stability_cut",
49  po::value<double>()->default_value(1),
50  "QwEventRing: Stability ON/OFF");
51 }
52 
54 {
55  // Reads Event Ring parameters from cmd
56  Double_t stability = 0.0;
57  if (gQwOptions.HasValue("ring.size"))
58  fRING_SIZE=gQwOptions.GetValue<int>("ring.size");
59 
60  if (gQwOptions.HasValue("ring.stability_cut"))
61  stability=gQwOptions.GetValue<double>("ring.stability_cut");
62 
63  if (stability>0.0)
64  bStability=kTRUE;
65  else
66  bStability=kFALSE;
67 
68 }
70 {
71  if (bDEBUG) QwMessage << "QwEventRing::push: BEGIN" <<QwLog::endl;
72 
73 
74 
75  if (bEVENT_READY){
76  fEvent_Ring[fNextToBeFilled]=event;//copy the current good event to the ring
77  if (bStability){
79  }
80 
81 
82  if (bDEBUG) QwMessage<<" Filled at "<<fNextToBeFilled;//<<"Ring count "<<fRing_Count<<QwLog::endl;
83  if (bDEBUG_Write) fprintf(out_file," Filled at %d ",fNextToBeFilled);
84 
85 
86  fNextToBeFilled=(fNextToBeFilled+1)%fRING_SIZE;
87 
88  if(fNextToBeFilled == 0){
89  //then we have RING_SIZE events to process
90  if (bDEBUG) QwMessage<<" RING FILLED "<<fNextToBeFilled+1; //<<QwLog::endl;
91  if (bDEBUG_Write) fprintf(out_file," RING FILLED ");
92  bRING_READY=kTRUE;//ring is filled with good multiplets
93  fNextToBeFilled=0;//next event to be filled
94  fNextToBeRead=0;//first element in the ring
95  //check for current ramps
96  if (bStability){
98  /*
99  //The fRollingAvg dose not contain any regular errorcodes since it only accumulate rolling sum for errorflag==0 event.
100  //The only errorflag it generates is the stability cut faliure error when the rolling avg is computed.
101  //Therefore when fRollingAvg.GetEventcutErrorFlag() is called it will return non-zero error code only if a global stability cut has failed
102  //When fRollingAvg.GetEventcutErrorFlag() is called the fErrorFlag of the subsystemarrayparity object will be updated with any global
103  //stability cut faliures
104  */
105  fRollingAvg.UpdateErrorFlag(); //to update the global error code in the fRollingAvg
106  for(Int_t i=0;i<fRING_SIZE;i++){
107  fEvent_Ring[i].UpdateErrorFlag(fRollingAvg);
108  fEvent_Ring[i].UpdateErrorFlag();
109  }
110 
111  }
112  }
113  //ring processing is done at a separate location
114  }else{
115  }
116 
117 
118 }
119 
120 
122  Int_t tempIndex;
123  tempIndex=fNextToBeRead;
124  if (bDEBUG) QwMessage<<" Read at "<<fNextToBeRead<<QwLog::endl;
125  if (bDEBUG_Write) fprintf(out_file," Read at %d \n",fNextToBeRead);
126 
127  if (fNextToBeRead==(fRING_SIZE-1)){
128  bRING_READY=kFALSE;//setting to false is an extra measure of security to prevent reading a NULL value.
129  }
130  if (bStability){
132  }
134  return fEvent_Ring[tempIndex];
135 }
136 
137 
138 Bool_t QwEventRing::IsReady(){ //Check for readyness to read data from the ring using the pop() routine
139  return bRING_READY;
140 }
141 
#define QwMessage
Predefined log drain for regular messages.
Definition: QwLog.h:50
QwSubsystemArrayParity & pop()
Return the last subsystem in the ring.
Definition: QwEventRing.cc:121
Int_t fRING_SIZE
Definition: QwEventRing.h:47
void DeaccumulateRunningSum(const QwSubsystemArrayParity &value)
Remove the entry value from the running sums for devices.
An options class.
Definition: QwOptions.h:133
bool HasValue(const std::string &key)
Has this key been defined.
Definition: QwOptions.h:233
po::options_description_easy_init AddDefaultOptions()
Add a default option.
Definition: QwOptions.h:159
static const Bool_t bDEBUG
Definition: QwEventRing.h:65
static void DefineOptions(QwOptions &options)
Define options.
Definition: QwEventRing.cc:41
static const Bool_t bDEBUG_Write
Definition: QwEventRing.h:66
Int_t fNextToBeFilled
Definition: QwEventRing.h:50
QwOptions gQwOptions
Definition: QwOptions.cc:27
void CalculateRunningAverage()
Calculate the average for all good events.
po::options_description_easy_init AddOptions(const std::string &blockname="Specialized options")
Add an option to a named block or create new block.
Definition: QwOptions.h:164
void push(QwSubsystemArrayParity &event)
Add the subsystem to the ring.
Definition: QwEventRing.cc:69
T GetValue(const std::string &key)
Get a templated value.
Definition: QwOptions.h:240
Virtual base class for the parity subsystems.
std::vector< QwSubsystemArrayParity > fEvent_Ring
Definition: QwEventRing.h:59
static std::ostream & endl(std::ostream &)
End of the line.
Definition: QwLog.cc:299
Int_t fNextToBeRead
Definition: QwEventRing.h:51
FILE * out_file
Definition: QwEventRing.h:64
Bool_t bStability
Definition: QwEventRing.h:69
Bool_t bRING_READY
Definition: QwEventRing.h:57
void UpdateErrorFlag()
Update the error flag internally from all the subsystems.
Bool_t bEVENT_READY
Definition: QwEventRing.h:54
QwSubsystemArrayParity fRollingAvg
Definition: QwEventRing.h:61
Bool_t IsReady()
Return the read status of the ring.
Definition: QwEventRing.cc:138
void AccumulateAllRunningSum(const QwSubsystemArrayParity &value)
Update the running sums for devices check only the error flags at the channel level. Only used for stability checks.
void ProcessOptions(QwOptions &options)
Process options.
Definition: QwEventRing.cc:53