QwAnalysis
QwIntegratedRaster.cc
Go to the documentation of this file.
1 /**********************************************************\
2  * File: QwIntegratedRaster.C *
3  * *
4  * Author: *
5  * Time-stamp: *
6 \**********************************************************/
7 
8 #include "QwIntegratedRaster.h"
9 
10 // System headers
11 #include <stdexcept>
12 #include <iostream>
13 
14 // Qweak headers
15 #include "QwSubsystemArray.h"
16 #define MYSQLPP_SSQLS_NO_STATICS
17 #include "QwParitySSQLS.h"
18 #include "QwParityDB.h"
19 #include "QwVQWK_Channel.h"
20 
21 // Register this subsystem with the factory
23 
25 {
26 }
27 
28 
29 //*****************************************************************
31 {
32 }
33 
34 //*****************************************************************
35 Int_t QwIntegratedRaster::LoadChannelMap(TString mapfile)
36 {
37  Bool_t ldebug=kFALSE;
38 
39  TString varname, varvalue;
40  TString modtype, dettype, namech, nameofcombinedchan, keyword;
41  Int_t modnum = 0;
42  Int_t channum = 0;
43  Int_t currentrocread=0;
44  Int_t currentbankread=0;
45  Int_t offset = -1;
46  Int_t currentsubbankindex=-1;
47  Int_t fSample_size=0;
48 
49  QwParameterFile mapstr(mapfile.Data()); //Open the file
50  fDetectorMaps.insert(mapstr.GetParamFileNameContents());
51  while (mapstr.ReadNextLine())
52  {
53  mapstr.TrimComment('!'); // Remove everything after a '!' character.
54  mapstr.TrimWhitespace(); // Get rid of leading and trailing spaces.
55  if (mapstr.LineIsEmpty()) continue;
56 
57  if (mapstr.HasVariablePair("=",varname,varvalue))
58  {
59  // This is a declaration line. Decode it.
60  varname.ToLower();
61  UInt_t value = QwParameterFile::GetUInt(varvalue);
62 
63  if (varname=="roc")
64  {
65  currentrocread=value;
66  RegisterROCNumber(value,0);
67  }
68  else if (varname=="bank")
69  {
70  currentbankread=value;
71  RegisterSubbank(value);
72  }
73  else if (varname=="sample_size")
74  {
75  fSample_size=value;
76  }
77  }
78  else
79  {
80  Bool_t lineok=kTRUE;
81  // Break this line into tokens to process it.
82  modtype = mapstr.GetTypedNextToken<TString>(); // module type
83  if (modtype == "VQWK")
84  {
85  modnum = mapstr.GetTypedNextToken<Int_t>(); //slot number
86  channum = mapstr.GetTypedNextToken<Int_t>(); //channel number
87  dettype = mapstr.GetTypedNextToken<TString>(); //type-purpose of the detector
88  dettype.ToLower();
89  namech = mapstr.GetTypedNextToken<TString>(); //name of the detector
90  namech.ToLower();
91  keyword = mapstr.GetTypedNextToken<TString>();
92  keyword.ToLower();
93  }
94 
95  if(currentsubbankindex!=GetSubbankIndex(currentrocread,currentbankread))
96  {
97  currentsubbankindex=GetSubbankIndex(currentrocread,currentbankread);
98  }
99 
100 
101 
102  QwIntegratedRasterDetectorID detector_id;
103  detector_id.fdetectorname=namech;
104  detector_id.fmoduletype=modtype;
105  detector_id.fSubbankIndex=currentsubbankindex;
106  detector_id.fdetectortype=dettype;
107 
108 
109  if(modtype=="VQWK")
110  {
111  offset = QwVQWK_Channel::GetBufferOffset(modnum, channum);
112  detector_id.fWordInSubbank = offset;
113  }
114 
115  if(offset<0)
116  {
117  QwError << "QwIntegratedRaster::LoadChannelMap: Unknown module type: "
118  << modtype <<", the detector "<<namech<<" will not be decoded "
119  << QwLog::endl;
120  lineok=kFALSE;
121  continue;
122  }
123 
124 
125  detector_id.fdetectortype.ToLower();
126  if(detector_id.fdetectortype!="raster") {
127  // Silently ignore the line if this isn't a raster element.
128  QwVerbose << "QwIntegratedRaster::LoadChannelMap: Unknown detector type: "
129  << dettype <<", the detector "<<namech<<" will not be decoded "
130  << QwLog::endl;
131  lineok=kFALSE;
132  continue;
133  }
134 
135  detector_id.fIndex=
136  GetDetectorIndex(detector_id.fdetectorname);
137 
138  if(detector_id.fIndex==-1)
139  {
140  QwIntegratedRasterChannel<QwVQWK_Channel> localIntegratedRasterChannel(GetSubsystemName(),detector_id.fdetectorname);
141  fIntegratedRasterChannel.push_back(localIntegratedRasterChannel);
142  fIntegratedRasterChannel[fIntegratedRasterChannel.size()-1].SetDefaultSampleSize(fSample_size);
143  detector_id.fIndex=fIntegratedRasterChannel.size()-1;
144  }
145 
146  if(ldebug)
147  {
148  detector_id.Print();
149  std::cout<<"line ok=";
150  if(lineok) std::cout<<"TRUE"<<std::endl;
151  else
152  std::cout<<"FALSE"<<std::endl;
153  }
154 
155  if(lineok)
156  fDetectorIDs.push_back(detector_id);
157  }
158  }
159 
160  if(ldebug) {
161  std::cout<<"QwIntegratedRaster::Done with Load map channel \n";
162  for(size_t i=0;i<fDetectorIDs.size();i++)
163  fDetectorIDs[i].Print();
164  }
165  ldebug=kFALSE;
166  mapstr.Close(); // Close the file (ifstream)
167  return 0;
168 }
169 
170 
171 //*****************************************************************
172 Int_t QwIntegratedRaster::LoadEventCuts(TString filename)
173 {
174  Int_t eventcut_flag = 1;
175 
176  // Open the file
177  QwParameterFile mapstr(filename.Data());
178  fDetectorMaps.insert(mapstr.GetParamFileNameContents());
179  while (mapstr.ReadNextLine()){
180  //std::cout<<"********* In the loop *************"<<std::endl;
181  mapstr.TrimComment('!'); // Remove everything after a '!' character.
182  mapstr.TrimWhitespace(); // Get rid of leading and trailing spaces.
183  if (mapstr.LineIsEmpty()) continue;
184 
185  TString varname, varvalue;
186  if (mapstr.HasVariablePair("=",varname,varvalue)){
187  if (varname == "EVENTCUTS") {
188  //varname="";
189  eventcut_flag = QwParameterFile::GetUInt(varvalue);
190  //std::cout<<"EVENT CUT FLAG "<<eventcut_flag<<std::endl;
191  }
192  }
193  else{
194  TString device_type = mapstr.GetTypedNextToken<TString>();
195  device_type.ToLower();
196  TString device_name = mapstr.GetTypedNextToken<TString>();
197  device_name.ToLower();
198 
199  if (device_type != "raster") {
200  QwVerbose << "QwIntegratedRaster::LoadEventCuts: Skipping detector type: "
201  << device_type << ", detector name "
202  << device_name << QwLog::endl;
203  continue;
204  }
205 
206  Int_t det_index = GetDetectorIndex(device_name);
207  if (det_index == -1) {
208  QwWarning << " Device not found " << device_name << " of type " << device_type << QwLog::endl;
209  continue;
210  }
211 
212  Double_t LLX = mapstr.GetTypedNextToken<Double_t>(); //lower limit for IntegratedRasterChannel value
213  Double_t ULX = mapstr.GetTypedNextToken<Double_t>(); //upper limit for IntegratedRasterChannel value
214  varvalue = mapstr.GetTypedNextToken<TString>();//global/local
215  varvalue.ToLower();
216  Double_t stabilitycut = mapstr.GetTypedNextToken<Double_t>();
217  QwMessage << "QwIntegratedRaster Error Code passing to QwIntegratedRasterChannel " << GetGlobalErrorFlag(varvalue,eventcut_flag,stabilitycut) << QwLog::endl;
218 
219  //std::cout<<"*****************************"<<std::endl;
220  //std::cout<<" Type "<<device_type<<" Name "<<device_name<<" Index ["<<det_index <<"] "<<" device flag "<<check_flag<<std::endl;
221 
222  fIntegratedRasterChannel[det_index].SetSingleEventCuts(GetGlobalErrorFlag(varvalue,eventcut_flag,stabilitycut),LLX,ULX,stabilitycut);
223  //std::cout<<"*****************************"<<std::endl;
224  }
225 
226  }
227  for (size_t i = 0; i < fIntegratedRasterChannel.size(); i++)
228  fIntegratedRasterChannel[i].SetEventCutMode(eventcut_flag);
229 
230  fQwIntegratedRasterErrorCount = 0; //set the error counter to zero
231 
232  return 0;
233 }
234 
235 //*****************************************************************
236 Int_t QwIntegratedRaster::LoadInputParameters(TString pedestalfile)
237 {
238  Bool_t ldebug=kFALSE;
239  TString varname;
240  Double_t varped;
241  Double_t varcal;
242  TString localname;
243 
244  Int_t lineread=0;
245 
246  if(ldebug)std::cout<<"QwIntegratedRaster::LoadInputParameters("<< pedestalfile<<")\n";
247 
248  QwParameterFile mapstr(pedestalfile.Data()); //Open the file
249  fDetectorMaps.insert(mapstr.GetParamFileNameContents());
250 
251  while (mapstr.ReadNextLine())
252  {
253  lineread+=1;
254  if(ldebug)std::cout<<" line read so far ="<<lineread<<"\n";
255  mapstr.TrimComment('!'); // Remove everything after a '!' character.
256  mapstr.TrimWhitespace(); // Get rid of leading and trailing spaces.
257  if (mapstr.LineIsEmpty()) continue;
258  else
259  {
260  varname = mapstr.GetTypedNextToken<TString>(); //name of the channel
261  varname.ToLower();
262  varname.Remove(TString::kBoth,' ');
263  varped= mapstr.GetTypedNextToken<Double_t>(); // value of the pedestal
264  varcal= mapstr.GetTypedNextToken<Double_t>(); // value of the calibration factor
265  if(ldebug) std::cout<<"inputs for channel "<<varname
266  <<": ped="<<varped<<": cal="<<varcal<<"\n";
267  Bool_t notfound=kTRUE;
268 
269  if(notfound)
270  for(size_t i=0;i<fIntegratedRasterChannel.size();i++)
271  if(fIntegratedRasterChannel[i].GetElementName()==varname)
272  {
273  fIntegratedRasterChannel[i].SetPedestal(varped);
274  fIntegratedRasterChannel[i].SetCalibrationFactor(varcal);
275  i=fIntegratedRasterChannel.size()+1;
276  notfound=kFALSE;
277  i=fIntegratedRasterChannel.size()+1;
278  }
279  }
280 
281  }
282  if(ldebug) std::cout<<" line read in the pedestal + cal file ="<<lineread<<" \n";
283 
284  ldebug=kFALSE;
285  mapstr.Close(); // Close the file (ifstream)
286 
287  return 0;
288 }
289 
290 //*****************************************************************
291 void QwIntegratedRaster::SetRandomEventParameters(Double_t mean, Double_t sigma)
292 {
293  for (size_t i = 0; i < fIntegratedRasterChannel.size(); i++)
295 }
296 
297 //*****************************************************************
299 {
300  for (size_t i = 0; i < fIntegratedRasterChannel.size(); i++)
302 }
303 
304 //*****************************************************************
305 void QwIntegratedRaster::RandomizeEventData(int helicity, double time)
306 {
307  // Randomize all QwIntegratedRasterChannel buffers
308  for (size_t i = 0; i < fIntegratedRasterChannel.size(); i++)
309  fIntegratedRasterChannel[i].RandomizeEventData(helicity, time);
310 }
311 
312 //*****************************************************************
313 void QwIntegratedRaster::EncodeEventData(std::vector<UInt_t> &buffer)
314 {
315  std::vector<UInt_t> elements;
316  elements.clear();
317 
318  // Get all buffers in the order they are defined in the map file
319  for (size_t i = 0; i < fDetectorIDs.size(); i++) {
320  // This is a QwIntegratedRasterChannel
321  fIntegratedRasterChannel[fDetectorIDs.at(i).fIndex].EncodeEventData(elements);
322  }
323 
324  // If there is element data, generate the subbank header
325  std::vector<UInt_t> subbankheader;
326  std::vector<UInt_t> rocheader;
327  if (elements.size() > 0) {
328 
329  // Form CODA subbank header
330  subbankheader.clear();
331  subbankheader.push_back(elements.size() + 1); // subbank size
332  subbankheader.push_back((fCurrentBank_ID << 16) | (0x01 << 8) | (1 & 0xff));
333  // subbank tag | subbank type | event number
334 
335  // Form CODA bank/roc header
336  rocheader.clear();
337  rocheader.push_back(subbankheader.size() + elements.size() + 1); // bank/roc size
338  rocheader.push_back((fCurrentROC_ID << 16) | (0x10 << 8) | (1 & 0xff));
339  // bank tag == ROC | bank type | event number
340 
341  // Add bank header, subbank header and element data to output buffer
342  buffer.insert(buffer.end(), rocheader.begin(), rocheader.end());
343  buffer.insert(buffer.end(), subbankheader.begin(), subbankheader.end());
344  buffer.insert(buffer.end(), elements.begin(), elements.end());
345  }
346 }
347 
348 //*****************************************************************
349 Int_t QwIntegratedRaster::ProcessEvBuffer(const UInt_t roc_id, const UInt_t bank_id, UInt_t* buffer, UInt_t num_words)
350 {
351  Bool_t lkDEBUG=kFALSE;
352 
353  Int_t index = GetSubbankIndex(roc_id,bank_id);
354 
355  if (index>=0 && num_words>0){
356  // We want to process this ROC. Begin looping through the data.
357  if (lkDEBUG)
358  std::cout << "QwIntegratedRaster::ProcessEvBuffer: "
359  << "Begin processing ROC" << roc_id
360  << " and subbank "<<bank_id
361  << " number of words="<<num_words<<std::endl;
362 
363  for(size_t i=0;i<fDetectorIDs.size();i++) {
364  if(fDetectorIDs[i].fSubbankIndex==index) {
365  if (lkDEBUG) {
366  std::cout<<"found IntegratedRasterChannel data for "<<fDetectorIDs[i].fdetectorname<<std::endl;
367  std::cout<<"words left to read in this buffer:"<<num_words-fDetectorIDs[i].fWordInSubbank<<std::endl;
368  }
369 
371  ProcessEvBuffer(&(buffer[fDetectorIDs[i].fWordInSubbank]),
372  num_words-fDetectorIDs[i].fWordInSubbank);
373  }
374 
375  }
376  SetDataLoaded(kTRUE);
377  }
378  return 0;
379 }
380 
381 //*****************************************************************
383 
384  Bool_t status=kTRUE;
385  for(size_t i=0;i<fIntegratedRasterChannel.size();i++){
386  status &= fIntegratedRasterChannel[i].ApplySingleEventCuts();
387  if(!status && bDEBUG) std::cout<<"******* QwIntegratedRaster::SingleEventCuts()->IntegratedRasterChannel[ "<<i<<" , "<<fIntegratedRasterChannel[i].GetElementName()<<" ] ******\n";
388  }
389 
390  if (!status)
391  fQwIntegratedRasterErrorCount++;//failed event counter for QwIntegratedRaster
392 
393  return status;
394 }
395 
396 
397 //*****************************************************************
399 {
400  for (size_t i = 0; i < fIntegratedRasterChannel.size(); i++)
402 }
403 
404 //*****************************************************************
406 {
407  //inherited from the VQwSubsystemParity; this will display the error summary
408  QwMessage<<"*********QwIntegratedRaster Error Summary****************"<<QwLog::endl;
410  for(size_t i=0;i<fIntegratedRasterChannel.size();i++){
411  //std::cout<<" IntegratedRasterChannel ["<<i<<"] "<<std::endl;
412  fIntegratedRasterChannel[i].PrintErrorCounters();
413  }
415 }
416 
417 
418 //*****************************************************************
419 UInt_t QwIntegratedRaster::GetEventcutErrorFlag(){//return the error flag
420  UInt_t ErrorFlag;
421  ErrorFlag=0;
422  for(size_t i=0;i<fIntegratedRasterChannel.size();i++){
423  ErrorFlag |= fIntegratedRasterChannel[i].GetEventcutErrorFlag();
424  }
425  return ErrorFlag;
426 }
427 
428 //*****************************************************************
430 {
431  if (! HasDataLoaded()) return;
432 
433  for (size_t i = 0; i < fIntegratedRasterChannel.size(); i++)
435 }
436 
437 
438 //*****************************************************************
439 Int_t QwIntegratedRaster::ProcessConfigurationBuffer(const UInt_t roc_id, const UInt_t bank_id, UInt_t* buffer, UInt_t num_words)
440 {
441  return 0;
442 }
443 
444 //*****************************************************************
446 {
447  Bool_t test=kTRUE;
448 
449  return test;
450 }
451 
452 
453 //*****************************************************************
455 {
456  SetDataLoaded(kFALSE);
457  for(size_t i=0;i<fIntegratedRasterChannel.size();i++)
459 }
460 
461 
462 //*****************************************************************
464 {
465  Bool_t ldebug=kFALSE;
466  if(ldebug)
467  {
468  std::cout<<"QwIntegratedRaster::GetDetectorIndex\n";
469  std::cout<<" name="<<name<<"\n";
470  std::cout<<fDetectorIDs.size()<<" already registered detector\n";
471  }
472 
473  Int_t result=-1;
474  for(size_t i=0;i<fDetectorIDs.size();i++)
475  {
476  if(fDetectorIDs[i].fdetectorname==name)
477  result=fDetectorIDs[i].fIndex;
478  if(ldebug)
479  {
480  std::cout<<"testing against ("
481  <<fDetectorIDs[i].fdetectorname
482  <<")=>"<<result<<"\n";
483  }
484  }
485 
486  return result;
487 }
488 
489 
490 //*****************************************************************
491 const VQwDataElement* QwIntegratedRaster::GetChannel(const TString name) const
492 {
493  if (! fIntegratedRasterChannel.empty()) {
494  for (std::vector<QwIntegratedRasterChannel<QwVQWK_Channel> >::const_iterator
495  IntegratedRasterChannel = fIntegratedRasterChannel.begin();
496  IntegratedRasterChannel != fIntegratedRasterChannel.end(); ++IntegratedRasterChannel) {
497  if (IntegratedRasterChannel->GetElementName() == name) {
498  return &(*IntegratedRasterChannel);
499  }
500  }
501  }
502  return 0;
503 }
504 
505 
506 //*****************************************************************
508 {
509  // std::cout<<" here in QwIntegratedRaster::operator= \n";
510  if (Compare(value))
511  {
513  QwIntegratedRaster* input = dynamic_cast<QwIntegratedRaster*> (value);
514 
515  for (size_t i = 0; i < input->fIntegratedRasterChannel.size(); i++)
517  }
518  return *this;
519 }
520 
521 //*****************************************************************
523 {
524  if (Compare(value))
525  {
526  QwIntegratedRaster* input= dynamic_cast<QwIntegratedRaster*>(value);
527 
528  for (size_t i = 0; i < input->fIntegratedRasterChannel.size(); i++)
530  }
531  return *this;
532 }
533 
534 //*****************************************************************
536 {
537 
538  if (Compare(value))
539  {
540  QwIntegratedRaster* input= dynamic_cast<QwIntegratedRaster*>(value);
541 
542  for (size_t i = 0; i < input->fIntegratedRasterChannel.size(); i++)
544  }
545  return *this;
546 }
547 
548 //*****************************************************************
550 {
551  if (Compare(value1) && Compare(value2))
552  {
553  *this = value1;
554  *this += value2;
555  }
556 }
557 
558 //*****************************************************************
560 {
561  if (Compare(value1) && Compare(value2))
562  {
563  *this = value1;
564  *this -= value2;
565  }
566 }
567 
568 //*****************************************************************
570 {
571  if (Compare(numer) && Compare(denom))
572  {
573  QwIntegratedRaster* innumer = dynamic_cast<QwIntegratedRaster*>(numer);
574  QwIntegratedRaster* indenom = dynamic_cast<QwIntegratedRaster*>(denom);
575 
576  for (size_t i = 0; i < innumer->fIntegratedRasterChannel.size(); i++)
578  }
579 }
580 
581 //*****************************************************************
582 void QwIntegratedRaster::Scale(Double_t factor)
583 {
584  for (size_t i = 0; i < fIntegratedRasterChannel.size(); i++)
585  fIntegratedRasterChannel[i].Scale(factor);
586 }
587 
588 
589 
590 //*****************************************************************
592 {
593  // std::cout<<" Here in QwIntegratedRaster::Compare \n";
594 
595  Bool_t res=kTRUE;
596  if(typeid(*value)!=typeid(*this))
597  {
598  res=kFALSE;
599  // std::cout<<" types are not ok \n";
600  // std::cout<<" this is bypassed just for now but should be fixed eventually \n";
601  }
602  else
603  {
604  QwIntegratedRaster* input= dynamic_cast<QwIntegratedRaster*>(value);
605  if(input->fIntegratedRasterChannel.size() !=fIntegratedRasterChannel.size() )
606  {
607  res=kFALSE;
608  }
609  }
610  return res;
611 }
612 
613 
614 //*****************************************************************
615 void QwIntegratedRaster::ConstructHistograms(TDirectory *folder, TString &prefix)
616 {
617  for (size_t i = 0; i < fIntegratedRasterChannel.size(); i++)
619 }
620 
621 
622 //*****************************************************************
624 {
625  if (! HasDataLoaded()) return;
626 
627  for (size_t i = 0; i < fIntegratedRasterChannel.size(); i++)
629 }
630 
631 
632 //*****************************************************************
633 void QwIntegratedRaster::ConstructBranchAndVector(TTree *tree, TString & prefix, std::vector <Double_t> &values)
634 {
635  for (size_t i = 0; i < fIntegratedRasterChannel.size(); i++)
636  fIntegratedRasterChannel[i].ConstructBranchAndVector(tree, prefix, values);
637 }
638 
639 //*****************************************************************
640 void QwIntegratedRaster::ConstructBranch(TTree *tree, TString & prefix)
641 {
642  for (size_t i = 0; i < fIntegratedRasterChannel.size(); i++)
643  fIntegratedRasterChannel[i].ConstructBranch(tree, prefix);
644 }
645 
646 //*****************************************************************
647 void QwIntegratedRaster::ConstructBranch(TTree *tree, TString & prefix, QwParameterFile& trim_file)
648 {
649  TString tmp;
650  QwParameterFile* nextmodule;
651 
652  tmp="QwIntegratedRasterChannel";
653  trim_file.RewindToFileStart();
654  if (trim_file.FileHasModuleHeader(tmp)){
655  nextmodule=trim_file.ReadUntilNextModule();
656  //This section contains sub modules and or channels to be included in the tree
657 
658  for(size_t i = 0; i < fIntegratedRasterChannel.size(); i++)
659  fIntegratedRasterChannel[i].ConstructBranch(tree, prefix,*nextmodule);
660  }
661 }
662 
663 //*****************************************************************
664 void QwIntegratedRaster::FillTreeVector(std::vector<Double_t> &values) const
665 {
666  if (! HasDataLoaded()) return;
667 
668  for(size_t i = 0; i < fIntegratedRasterChannel.size(); i++)
670 }
671 
672 
673 //*****************************************************************
675 {
676  QwMessage << "=== QwIntegratedRaster: " << GetSubsystemName() << " ===" << QwLog::endl;
677  for (size_t i = 0; i < fIntegratedRasterChannel.size(); i++)
679 }
680 
681 //*****************************************************************
683 {
684  QwMessage << "Name of the subsystem = " << fSystemName << QwLog::endl;
685  QwMessage << "There are " << fIntegratedRasterChannel.size() << " IntegratedRasterChannel" << QwLog::endl;
686 
687  QwMessage << " Printing Running AVG and other channel info" << QwLog::endl;
688  for (size_t i = 0; i < fIntegratedRasterChannel.size(); i++)
690 }
691 
692 //*****************************************************************
694 {
695  for (size_t i=0;i<fDetectorIDs.size();i++)
696  {
697  std::cout<<"============================="<<std::endl;
698  std::cout<<" Detector ID="<<i<<std::endl;
699  fDetectorIDs[i].Print();
700  }
701 }
702 
703 //*****************************************************************
705 {
706  std::cout<<std::endl<<"Detector name= "<<fdetectorname<<std::endl;
707  std::cout<<"SubbankkIndex= "<<fSubbankIndex<<std::endl;
708  std::cout<<"word index in subbank= "<<fWordInSubbank<<std::endl;
709  std::cout<<"module type= "<<fmoduletype<<std::endl;
710  std::cout<<"detector type= "<<fdetectortype<<std::endl;
711  std::cout<<"Index of this detector in the vector of similar detector= "<<
712  fIndex<<std::endl;
713  std::cout<<"Subelement index= "<<
714  fSubelement<<std::endl;
715  std::cout<<"==========================================\n";
716 }
717 
718 //*****************************************************************
720 {
721  for (size_t i = 0; i < fIntegratedRasterChannel.size(); i++)
723 }
724 
725 //*****************************************************************
727 {
728  if (Compare(value1)) {
729  QwIntegratedRaster* value = dynamic_cast<QwIntegratedRaster*>(value1);
730 
731  for (size_t i = 0; i < fIntegratedRasterChannel.size(); i++)
733  }
734 }
735 
736 
737 //*****************************************************************
738 void QwIntegratedRaster::FillDB(QwParityDB *db, TString datatype)
739 {
740 
741  Bool_t local_print_flag = false;
742  if(local_print_flag){
743  QwMessage << " --------------------------------------------------------------- " << QwLog::endl;
744  QwMessage << " QwIntegratedRaster::FillDB " << QwLog::endl;
745  QwMessage << " --------------------------------------------------------------- " << QwLog::endl;
746  }
747 
748  std::vector<QwDBInterface> interface;
749  std::vector<QwParitySSQLS::beam> entrylist;
750 
751  UInt_t analysis_id = db->GetAnalysisID();
752 
753  TString measurement_type;
754  measurement_type =
756 
757  UInt_t i,j;
758  i = j = 0;
759  if(local_print_flag) QwMessage << QwColor(Qw::kGreen) << "IntegratedRasterChannel" <<QwLog::endl;
760 
761  for(i=0; i< fIntegratedRasterChannel.size(); i++) {
762  interface.clear();
763  interface = fIntegratedRasterChannel[i].GetDBEntry();
764  for(j=0; j<interface.size(); j++){
765  interface.at(j).SetAnalysisID( analysis_id );
766  interface.at(j).SetMonitorID( db );
767  interface.at(j).SetMeasurementTypeID( measurement_type );
768  interface.at(j).PrintStatus( local_print_flag );
769  interface.at(j).AddThisEntryToList( entrylist );
770  }
771  }
772 
773  if(local_print_flag) {
774  QwMessage << QwColor(Qw::kGreen) << "Entrylist Size : "
775  << QwColor(Qw::kBoldRed) << entrylist.size()
777  }
778 
779  db->Connect();
780  // Check the entrylist size, if it isn't zero, start to query..
781  if( entrylist.size() ) {
782  mysqlpp::Query query= db->Query();
783  query.insert(entrylist.begin(), entrylist.end());
784  query.execute();
785  }
786  else {
787  QwMessage << "QwIntegratedRaster::FillDB :: This is the case when the entrlylist contains nothing in "<< datatype.Data() << QwLog::endl;
788  }
789 
790  db->Disconnect();
791 
792  return;
793 }
794 
795 
796 void QwIntegratedRaster::FillErrDB(QwParityDB *db, TString datatype)
797 {
798 
799  Bool_t local_print_flag = false;
800  if(local_print_flag){
801  QwMessage << " --------------------------------------------------------------- " << QwLog::endl;
802  QwMessage << " QwIntegratedRaster::FillErrDB " << QwLog::endl;
803  QwMessage << " --------------------------------------------------------------- " << QwLog::endl;
804  }
805 
806  std::vector<QwErrDBInterface> interface;
807  std::vector<QwParitySSQLS::beam_errors> entrylist;
808 
809  UInt_t analysis_id = db->GetAnalysisID();
810 
811  UInt_t i,j;
812  i = j = 0;
813  if(local_print_flag) QwMessage << QwColor(Qw::kGreen) << "IntegratedRasterChannel" <<QwLog::endl;
814 
815  for(i=0; i< fIntegratedRasterChannel.size(); i++) {
816  interface.clear();
817  interface = fIntegratedRasterChannel[i].GetErrDBEntry();
818  for(j=0; j<interface.size(); j++){
819  interface.at(j).SetAnalysisID ( analysis_id );
820  interface.at(j).SetMonitorID ( db );
821  interface.at(j).PrintStatus ( local_print_flag );
822  interface.at(j).AddThisEntryToList( entrylist );
823  }
824  }
825 
826  if(local_print_flag) {
827  QwMessage << QwColor(Qw::kGreen) << "Entrylist Size : "
828  << QwColor(Qw::kBoldRed) << entrylist.size()
830  }
831 
832  db->Connect();
833  // Check the entrylist size, if it isn't zero, start to query..
834  if( entrylist.size() ) {
835  mysqlpp::Query query= db->Query();
836  query.insert(entrylist.begin(), entrylist.end());
837  query.execute();
838  }
839  else {
840  QwMessage << "QwIntegratedRaster::FillErrDB :: This is the case when the entrlylist contains nothing in "<< datatype.Data() << QwLog::endl;
841  }
842 
843  db->Disconnect();
844 
845  return;
846 };
847 
849 {
850  QwMessage << "QwIntegratedRaster::WritePromptSummary()" << QwLog::endl;
851  return;
852 };
853 
Int_t GetSubbankIndex() const
Definition: VQwSubsystem.h:303
#define QwMessage
Predefined log drain for regular messages.
Definition: QwLog.h:50
void SetRandomEventParameters(Double_t mean, Double_t sigma)
const VQwDataElement * GetChannel(const TString name) const
void PrintValue() const
Print values of all channels.
std::map< TString, TString > fDetectorMaps
Definition: VQwSubsystem.h:322
Bool_t ApplySingleEventCuts()
Apply the single event cuts.
void Scale(Double_t factor)
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...
void PrintErrorCounters() const
Report the number of events failed due to HW and event cut failures.
void ConstructBranchAndVector(TTree *tree, TString &prefix, std::vector< Double_t > &values)
Construct the branch and tree vector.
Int_t LoadInputParameters(TString pedestalfile)
Mandatory parameter file definition.
static const Bool_t bDEBUG
void Disconnect()
Definition: QwDatabase.h:59
Bool_t Connect()
Open a connection to the database using the predefined parameters.
Definition: QwDatabase.cc:175
void FillHistograms()
Fill the histograms for this subsystem.
An options class.
Definition: QwOptions.h:133
static UInt_t GetUInt(const TString &varvalue)
void Difference(VQwSubsystem *value1, VQwSubsystem *value2)
void PrintInfo() const
Print some information about the subsystem.
std::vector< QwIntegratedRasterDetectorID > fDetectorIDs
Bool_t HasDataLoaded() const
Definition: VQwSubsystem.h:94
#define QwVerbose
Predefined log drain for verbose messages.
Definition: QwLog.h:55
UInt_t GetAnalysisID()
Definition: QwParityDB.h:71
void FillDB(QwParityDB *db, TString datatype)
Fill the database.
VQwSubsystem & operator+=(VQwSubsystem *value)
void RandomizeEventData(int helicity=0, double time=0.0)
void Ratio(VQwSubsystem *numer, VQwSubsystem *denom)
virtual void ConstructHistograms()
Construct the histograms for this subsystem.
Definition: VQwSubsystem.h:209
static void PrintErrorCounterHead()
void FillTreeVector(std::vector< Double_t > &values) const
Fill the tree vector.
void FillErrDB(QwParityDB *db, TString datatype)
virtual VQwSubsystem & operator=(VQwSubsystem *value)
Assignment Note: Must be called at the beginning of all subsystems routine call to operator=(VQwSubsy...
Bool_t FileHasModuleHeader(const std::string &secname)
The pure virtual base class of all data elements.
Int_t LoadEventCuts(TString filename)
Load the event cuts file.
void SetRandomEventAsymmetry(Double_t asymmetry)
static void DefineOptions()
Define options function (note: no virtual static functions in C++)
Definition: VQwSubsystem.h:88
void EncodeEventData(std::vector< UInt_t > &buffer)
VQwSubsystem & operator=(VQwSubsystem *value)
Assignment Note: Must be called at the beginning of all subsystems routine call to operator=(VQwSubsy...
TString fSystemName
Name of this subsystem.
Definition: VQwSubsystem.h:315
mysqlpp::Query Query(const char *qstr=0)
Definition: QwDatabase.h:66
UInt_t GetEventcutErrorFlag()
Return the error flag to the top level routines related to stability checks and ErrorFlag updates...
Int_t LoadChannelMap(TString mapfile)
Mandatory map file definition.
Int_t GetDetectorIndex(TString name)
std::vector< QwIntegratedRasterChannel< QwVQWK_Channel > > fIntegratedRasterChannel
void IncrementErrorCounters()
Increment the error counters.
void PrintDetectorID() const
The pure virtual base class of all subsystems.
Definition: VQwSubsystem.h:59
void AccumulateRunningSum(VQwSubsystem *value)
Update the running sums for devices.
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.
static std::ostream & endl(std::ostream &)
End of the line.
Definition: QwLog.cc:299
Bool_t Compare(VQwSubsystem *source)
void WritePromptSummary(QwPromptSummary *ps, TString type)
Int_t ProcessConfigurationBuffer(const UInt_t roc_id, const UInt_t bank_id, UInt_t *buffer, UInt_t num_words)
void Sum(VQwSubsystem *value1, VQwSubsystem *value2)
static TString DetermineMeasurementTypeID(TString type, TString suffix="", Bool_t forcediffs=kFALSE)
static void PrintErrorCounterTail()
static Int_t GetBufferOffset(Int_t moduleindex, Int_t channelindex)
void CalculateRunningAverage()
Calculate the average for all good events.
void ConstructBranch(TTree *tree, TString &prefix)
Construct the branch and tree vector.
VQwSubsystem & operator-=(VQwSubsystem *value)
#define QwWarning
Predefined log drain for warnings.
Definition: QwLog.h:45
void ProcessOptions(QwOptions &options)
Process the command line options.
Int_t fCurrentBank_ID
Bank ID that is currently being processed.
Definition: VQwSubsystem.h:326
QwParameterFile * ReadUntilNextModule(const bool add_current_line=false)
#define RegisterSubsystemFactory(A)
Definition: QwFactory.h:230
#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
TString GetSubsystemName() const
Definition: VQwSubsystem.h:93
void SetDataLoaded(Bool_t flag)
Definition: VQwSubsystem.h:305