16 #define MYSQLPP_SSQLS_NO_STATICS
39 TString varname, varvalue;
40 TString modtype, dettype, namech, nameofcombinedchan, keyword;
43 Int_t currentrocread=0;
44 Int_t currentbankread=0;
46 Int_t currentsubbankindex=-1;
51 while (mapstr.ReadNextLine())
53 mapstr.TrimComment(
'!');
54 mapstr.TrimWhitespace();
55 if (mapstr.LineIsEmpty())
continue;
57 if (mapstr.HasVariablePair(
"=",varname,varvalue))
68 else if (varname==
"bank")
70 currentbankread=value;
73 else if (varname==
"sample_size")
82 modtype = mapstr.GetTypedNextToken<TString>();
83 if (modtype ==
"VQWK")
85 modnum = mapstr.GetTypedNextToken<Int_t>();
86 channum = mapstr.GetTypedNextToken<Int_t>();
87 dettype = mapstr.GetTypedNextToken<TString>();
89 namech = mapstr.GetTypedNextToken<TString>();
91 keyword = mapstr.GetTypedNextToken<TString>();
95 if(currentsubbankindex!=
GetSubbankIndex(currentrocread,currentbankread))
117 QwError <<
"QwIntegratedRaster::LoadChannelMap: Unknown module type: "
118 << modtype <<
", the detector "<<namech<<
" will not be decoded "
128 QwVerbose <<
"QwIntegratedRaster::LoadChannelMap: Unknown detector type: "
129 << dettype <<
", the detector "<<namech<<
" will not be decoded "
138 if(detector_id.
fIndex==-1)
149 std::cout<<
"line ok=";
150 if(lineok) std::cout<<
"TRUE"<<std::endl;
152 std::cout<<
"FALSE"<<std::endl;
161 std::cout<<
"QwIntegratedRaster::Done with Load map channel \n";
174 Int_t eventcut_flag = 1;
179 while (mapstr.ReadNextLine()){
181 mapstr.TrimComment(
'!');
182 mapstr.TrimWhitespace();
183 if (mapstr.LineIsEmpty())
continue;
185 TString varname, varvalue;
186 if (mapstr.HasVariablePair(
"=",varname,varvalue)){
187 if (varname ==
"EVENTCUTS") {
194 TString device_type = mapstr.GetTypedNextToken<TString>();
195 device_type.ToLower();
196 TString device_name = mapstr.GetTypedNextToken<TString>();
197 device_name.ToLower();
199 if (device_type !=
"raster") {
200 QwVerbose <<
"QwIntegratedRaster::LoadEventCuts: Skipping detector type: "
201 << device_type <<
", detector name "
207 if (det_index == -1) {
212 Double_t LLX = mapstr.GetTypedNextToken<Double_t>();
213 Double_t ULX = mapstr.GetTypedNextToken<Double_t>();
214 varvalue = mapstr.GetTypedNextToken<TString>();
216 Double_t stabilitycut = mapstr.GetTypedNextToken<Double_t>();
238 Bool_t ldebug=kFALSE;
246 if(ldebug)std::cout<<
"QwIntegratedRaster::LoadInputParameters("<< pedestalfile<<
")\n";
251 while (mapstr.ReadNextLine())
254 if(ldebug)std::cout<<
" line read so far ="<<lineread<<
"\n";
255 mapstr.TrimComment(
'!');
256 mapstr.TrimWhitespace();
257 if (mapstr.LineIsEmpty())
continue;
260 varname = mapstr.GetTypedNextToken<TString>();
262 varname.Remove(TString::kBoth,
' ');
263 varped= mapstr.GetTypedNextToken<Double_t>();
264 varcal= mapstr.GetTypedNextToken<Double_t>();
265 if(ldebug) std::cout<<
"inputs for channel "<<varname
266 <<
": ped="<<varped<<
": cal="<<varcal<<
"\n";
267 Bool_t notfound=kTRUE;
282 if(ldebug) std::cout<<
" line read in the pedestal + cal file ="<<lineread<<
" \n";
315 std::vector<UInt_t> elements;
325 std::vector<UInt_t> subbankheader;
326 std::vector<UInt_t> rocheader;
327 if (elements.size() > 0) {
330 subbankheader.clear();
331 subbankheader.push_back(elements.size() + 1);
332 subbankheader.push_back((
fCurrentBank_ID << 16) | (0x01 << 8) | (1 & 0xff));
337 rocheader.push_back(subbankheader.size() + elements.size() + 1);
338 rocheader.push_back((
fCurrentROC_ID << 16) | (0x10 << 8) | (1 & 0xff));
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());
351 Bool_t lkDEBUG=kFALSE;
355 if (index>=0 && num_words>0){
358 std::cout <<
"QwIntegratedRaster::ProcessEvBuffer: "
359 <<
"Begin processing ROC" << roc_id
360 <<
" and subbank "<<bank_id
361 <<
" number of words="<<num_words<<std::endl;
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;
387 if(!status &&
bDEBUG) std::cout<<
"******* QwIntegratedRaster::SingleEventCuts()->IntegratedRasterChannel[ "<<i<<
" , "<<
fIntegratedRasterChannel[i].GetElementName()<<
" ] ******\n";
465 Bool_t ldebug=kFALSE;
468 std::cout<<
"QwIntegratedRaster::GetDetectorIndex\n";
469 std::cout<<
" name="<<name<<
"\n";
470 std::cout<<
fDetectorIDs.size()<<
" already registered detector\n";
480 std::cout<<
"testing against ("
482 <<
")=>"<<result<<
"\n";
497 if (IntegratedRasterChannel->GetElementName() == name) {
498 return &(*IntegratedRasterChannel);
596 if(
typeid(*value)!=
typeid(*
this))
652 tmp=
"QwIntegratedRasterChannel";
697 std::cout<<
"============================="<<std::endl;
698 std::cout<<
" Detector ID="<<i<<std::endl;
706 std::cout<<std::endl<<
"Detector name= "<<
fdetectorname<<std::endl;
709 std::cout<<
"module type= "<<
fmoduletype<<std::endl;
711 std::cout<<
"Index of this detector in the vector of similar detector= "<<
713 std::cout<<
"Subelement index= "<<
715 std::cout<<
"==========================================\n";
741 Bool_t local_print_flag =
false;
742 if(local_print_flag){
743 QwMessage <<
" --------------------------------------------------------------- " <<
QwLog::endl;
745 QwMessage <<
" --------------------------------------------------------------- " <<
QwLog::endl;
748 std::vector<QwDBInterface> interface;
749 std::vector<QwParitySSQLS::beam> entrylist;
753 TString measurement_type;
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 );
773 if(local_print_flag) {
781 if( entrylist.size() ) {
782 mysqlpp::Query query= db->
Query();
783 query.insert(entrylist.begin(), entrylist.end());
787 QwMessage <<
"QwIntegratedRaster::FillDB :: This is the case when the entrlylist contains nothing in "<< datatype.Data() <<
QwLog::endl;
799 Bool_t local_print_flag =
false;
800 if(local_print_flag){
801 QwMessage <<
" --------------------------------------------------------------- " <<
QwLog::endl;
803 QwMessage <<
" --------------------------------------------------------------- " <<
QwLog::endl;
806 std::vector<QwErrDBInterface> interface;
807 std::vector<QwParitySSQLS::beam_errors> entrylist;
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 );
826 if(local_print_flag) {
834 if( entrylist.size() ) {
835 mysqlpp::Query query= db->
Query();
836 query.insert(entrylist.begin(), entrylist.end());
840 QwMessage <<
"QwIntegratedRaster::FillErrDB :: This is the case when the entrlylist contains nothing in "<< datatype.Data() <<
QwLog::endl;
Int_t GetSubbankIndex() const
#define QwMessage
Predefined log drain for regular messages.
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
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
Bool_t Connect()
Open a connection to the database using the predefined parameters.
void FillHistograms()
Fill the histograms for this subsystem.
static UInt_t GetUInt(const TString &varvalue)
void Difference(VQwSubsystem *value1, VQwSubsystem *value2)
Int_t fQwIntegratedRasterErrorCount
void PrintInfo() const
Print some information about the subsystem.
std::vector< QwIntegratedRasterDetectorID > fDetectorIDs
Bool_t HasDataLoaded() const
#define QwVerbose
Predefined log drain for verbose messages.
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.
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++)
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.
mysqlpp::Query Query(const char *qstr=0)
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.
void AccumulateRunningSum(VQwSubsystem *value)
Update the running sums for devices.
A color changing class for the output stream.
Int_t fCurrentROC_ID
ROC ID that is currently being processed.
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.
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.
void ProcessOptions(QwOptions &options)
Process the command line options.
Int_t fCurrentBank_ID
Bank ID that is currently being processed.
QwParameterFile * ReadUntilNextModule(const bool add_current_line=false)
#define RegisterSubsystemFactory(A)
#define QwError
Predefined log drain for errors.
UInt_t GetGlobalErrorFlag(TString evtype, Int_t evMode, Double_t stabilitycut)
TString GetSubsystemName() const
void SetDataLoaded(Bool_t flag)