29 "Normalize the detectors by beam current");
39 <<
"Detector yields WILL NOT be normalized."
49 TString varname, varvalue;
50 TString modtype, dettype, namech, nameofcombinedchan, keyword, keyword2;
53 Int_t combinedchans = 0;
54 std::vector<TString> combinedchannelnames;
55 std::vector<Double_t> weight;
56 Int_t currentrocread=0;
57 Int_t currentbankread=0;
59 Int_t currentsubbankindex=-1;
64 while (mapstr.ReadNextLine())
66 mapstr.TrimComment(
'!');
67 mapstr.TrimWhitespace();
68 if (mapstr.LineIsEmpty())
continue;
70 if (mapstr.HasVariablePair(
"=",varname,varvalue))
81 else if (varname==
"bank")
83 currentbankread=value;
86 else if (varname==
"sample_size")
97 modtype = mapstr.GetTypedNextToken<TString>();
98 if (modtype ==
"VQWK" || modtype ==
"SCALER")
100 modnum = mapstr.GetTypedNextToken<Int_t>();
101 channum = mapstr.GetTypedNextToken<Int_t>();
102 dettype = mapstr.GetTypedNextToken<TString>();
104 namech = mapstr.GetTypedNextToken<TString>();
106 keyword = mapstr.GetTypedNextToken<TString>();
107 keyword2 = mapstr.GetTypedNextToken<TString>();
111 else if (modtype ==
"VPMT")
113 channum = mapstr.GetTypedNextToken<Int_t>();
114 combinedchans = mapstr.GetTypedNextToken<Int_t>();
115 dettype = mapstr.GetTypedNextToken<TString>();
117 namech = mapstr.GetTypedNextToken<TString>();
120 combinedchannelnames.clear();
121 for (
int i=0; i<combinedchans; i++)
123 nameofcombinedchan = mapstr.GetTypedNextToken<TString>();
124 nameofcombinedchan.ToLower();
125 combinedchannelnames.push_back(nameofcombinedchan);
128 for (
int i=0; i<combinedchans; i++)
130 weight.push_back( mapstr.GetTypedNextToken<Double_t>());
132 keyword = mapstr.GetTypedNextToken<TString>();
133 keyword2 = mapstr.GetTypedNextToken<TString>();
144 if(currentsubbankindex!=
GetSubbankIndex(currentrocread,currentbankread))
163 else if(modtype==
"SCALER")
165 offset = QwSIS3801D24_Channel::GetBufferOffset(modnum, channum);
168 else if (modtype==
"VPMT")
171 localLumiDetectorID.
fWeight = weight;
177 QwError <<
"QwLumi::LoadChannelMap: Unknown module type: "
178 << modtype <<
", the detector "<<namech<<
" will not be decoded "
188 if(localLumiDetectorID.
fTypeID==-1)
190 QwError <<
"QwLumi::LoadChannelMap: Unknown detector type: "
191 << dettype <<
", the detector "<<namech<<
" will not be decoded "
197 localLumiDetectorID.
fIndex=
201 if(localLumiDetectorID.
fIndex==-1)
212 if (keyword==
"not_normalizable"
213 || keyword2==
"not_normalizable")
230 if (keyword==
"not_normalizable"
231 || keyword2==
"not_normalizable")
253 localcounter.SetNeedsExternalClock(kFALSE);
263 localLumiDetectorID.
Print();
264 std::cout<<
"line ok=";
265 if(lineok) std::cout<<
"TRUE"<<std::endl;
267 std::cout<<
"FALSE"<<std::endl;
290 std::cout<<
"fLumiDetectorID[i].fCombinedChannelNames.size()="
291 <<
fLumiDetectorID[i].fCombinedChannelNames.size()<<std::endl<<
"name list: ";
292 for (
size_t n=0; n<
fLumiDetectorID[i].fCombinedChannelNames.size(); n++)
294 std::cout<<std::endl;
298 for (
size_t j=0; j<
fLumiDetectorID[i].fCombinedChannelNames.size(); j++)
306 std::cout<<
"found a to-be-combined channel candidate"<<std::endl;
313 if ((Int_t)
fLumiDetectorID[i].fCombinedChannelNames.size()==chanmatched)
315 for (
size_t l=0; l<
fLumiDetectorID[i].fCombinedChannelNames.size(); l++)
322 if (ldebug) std::cout<<
"added combined pmt "<<
fLumiDetectorID[i].fWeight[l] <<
" to array"<<std::endl;
326 std::cout<<
"linked a combined channel"<<std::endl;
330 std::cerr<<
"cannot combine void channels for "<<
fLumiDetectorID[i].fdetectorname<<std::endl;
340 std::cout<<
"QwLumi::Done with Load map channel \n";
354 Int_t eventcut_flag = 1;
359 while (mapstr.ReadNextLine()){
361 mapstr.TrimComment(
'!');
362 mapstr.TrimWhitespace();
363 if (mapstr.LineIsEmpty())
continue;
365 TString varname, varvalue;
366 if (mapstr.HasVariablePair(
"=",varname,varvalue)){
367 if (varname ==
"EVENTCUTS"){
374 TString device_type = mapstr.GetTypedNextToken<TString>();
375 device_type.ToLower();
376 TString device_name = mapstr.GetTypedNextToken<TString>();
377 device_name.ToLower();
380 if (det_index == -1) {
386 Double_t LLX = mapstr.GetTypedNextToken<Double_t>();
387 Double_t ULX = mapstr.GetTypedNextToken<Double_t>();
388 varvalue = mapstr.GetTypedNextToken<TString>();
389 Double_t stabilitycut = mapstr.GetTypedNextToken<Double_t>();
400 Double_t LLX = mapstr.GetTypedNextToken<Double_t>();
401 Double_t ULX = mapstr.GetTypedNextToken<Double_t>();
402 varvalue = mapstr.GetTypedNextToken<TString>();
403 Double_t stabilitycut=mapstr.GetTypedNextToken<Double_t>();
431 Bool_t ldebug=kFALSE;
439 if(ldebug)std::cout<<
"QwLumi::LoadInputParameters("<< pedestalfile<<
")\n";
444 while (mapstr.ReadNextLine())
447 if(ldebug)std::cout<<
" line read so far ="<<lineread<<
"\n";
448 mapstr.TrimComment(
'!');
449 mapstr.TrimWhitespace();
450 if (mapstr.LineIsEmpty())
continue;
453 varname = mapstr.GetTypedNextToken<TString>();
455 varname.Remove(TString::kBoth,
' ');
456 varped= mapstr.GetTypedNextToken<Double_t>();
457 varcal= mapstr.GetTypedNextToken<Double_t>();
458 if(ldebug) std::cout<<
"inputs for channel "<<varname
459 <<
": ped="<<varped<<
": cal="<<varcal<<
"\n";
460 Bool_t notfound=kTRUE;
475 if(ldebug) std::cout<<
" line read in the pedestal + cal file ="<<lineread<<
" \n";
507 std::vector<UInt_t> elements;
518 std::vector<UInt_t> subbankheader;
519 std::vector<UInt_t> rocheader;
520 if (elements.size() > 0) {
523 subbankheader.clear();
524 subbankheader.push_back(elements.size() + 1);
525 subbankheader.push_back((
fCurrentBank_ID << 16) | (0x01 << 8) | (1 & 0xff));
530 rocheader.push_back(subbankheader.size() + elements.size() + 1);
531 rocheader.push_back((
fCurrentROC_ID << 16) | (0x10 << 8) | (1 & 0xff));
535 buffer.insert(buffer.end(), rocheader.begin(), rocheader.end());
536 buffer.insert(buffer.end(), subbankheader.begin(), subbankheader.end());
537 buffer.insert(buffer.end(), elements.begin(), elements.end());
544 Bool_t lkDEBUG=kFALSE;
545 Bool_t firsttime=kTRUE;
546 Bool_t issingleevent=kTRUE;
550 if (index>=0 && num_words>0){
553 std::cout <<
"QwLumi::ProcessEvBuffer: "
554 <<
"Begin processing ROC" << roc_id
555 <<
" and subbank "<<bank_id
556 <<
" number of words="<<num_words<<std::endl;
567 std::cout<<
"found IntegrationPMT data for "<<
fLumiDetectorID[i].fdetectorname<<std::endl;
568 std::cout<<
"words left to read in this buffer:"<<num_words-
fLumiDetectorID[i].fWordInSubbank<<std::endl;
579 std::cout<<
"found ScalerPMT data for "<<
fLumiDetectorID[i].fdetectorname<<std::endl;
580 std::cout<<
"word left to read in this buffer:"<<num_words-
fLumiDetectorID[i].fWordInSubbank<<std::endl;
589 issingleevent=kFALSE;
591 std::cout<<
"QwLumi::ProcessEvBuffer: More than one event was found in the buffer. Setting these events to zero."<<std::endl;
595 if (issingleevent==kFALSE)
continue;
620 if(!status &&
bDEBUG) std::cout<<
"******* QwLumi::SingleEventCuts()->IntegrationPMT[ "<<i<<
" , "<<
fIntegrationPMT[i].GetElementName()<<
" ] ******\n";
624 if(!status &&
bDEBUG) std::cout<<
"******* QwLumi::SingleEventCuts()->CombinedPMT[ "<<i<<
" , "<<
fCombinedPMT[i].GetElementName()<<
" ] ******\n";
679 const QwLumi * input =
dynamic_cast<const QwLumi *
> (ev_error);
699 for (
size_t i = 0; i <
fScalerPMT.size(); i++)
738 std::cout<<
"QwLumi::ProcessEvent_2(): processing with exchanged data"<<std::endl;
739 std::cout<<
"pedestal, calfactor, average volts = "<<pedestal<<
", "<<calfactor<<
", "<<volts<<std::endl;
755 Bool_t status = kTRUE;
765 Bool_t status = kFALSE;
767 if(device_name.CompareTo(
fLumiDetectorID[i].fdetectorname)!=0)
continue;
781 QwError <<
"QwLumi::PublishByRequest: Failed to publish channel name: " << device_name <<
QwLog::endl;
820 Bool_t ldebug=kFALSE;
823 std::cout<<
"QwLumi::GetDetectorIndex\n";
824 std::cout<<
"type_id=="<<type_id<<
" name="<<name<<
"\n";
855 for (std::vector<QwIntegrationPMT>::const_iterator IntegrationPMT =
fIntegrationPMT.begin(); IntegrationPMT !=
fIntegrationPMT.end(); ++IntegrationPMT) {
856 if (IntegrationPMT->GetElementName() == name) {
857 return &(*IntegrationPMT);
867 TString tmpname = name;
900 for (
size_t i = 0; i < input->
fScalerPMT.size(); i++)
918 for (
size_t i = 0; i < input->
fScalerPMT.size(); i++)
936 for (
size_t i = 0; i < input->
fScalerPMT.size(); i++)
972 for (
size_t i = 0; i < innumer->
fCombinedPMT.size(); i++)
974 for (
size_t i = 0; i < innumer->
fScalerPMT.size(); i++)
986 for (
size_t i = 0; i <
fScalerPMT.size(); i++)
1008 if(
typeid(*value)!=
typeid(*
this))
1038 for (
size_t i = 0; i <
fScalerPMT.size(); i++)
1052 for (
size_t i = 0; i <
fScalerPMT.size(); i++)
1064 for (
size_t i = 0; i <
fScalerPMT.size(); i++)
1075 for (
size_t i = 0; i <
fScalerPMT.size(); i++)
1085 tmp=
"QwIntegrationPMT";
1098 tmp=
"QwCombinedPMT";
1116 for(
size_t i = 0; i <
fScalerPMT.size(); i++)
1129 for (
size_t i = 0; i <
fScalerPMT.size(); i++)
1146 for (
size_t i = 0; i <
fScalerPMT.size(); i++)
1155 std::cout<<
"============================="<<std::endl;
1156 std::cout<<
" Detector ID="<<i<<std::endl;
1164 std::cout<<std::endl<<
"Detector name= "<<
fdetectorname<<std::endl;
1167 std::cout<<
"module type= "<<
fmoduletype<<std::endl;
1169 std::cout<<
"Index of this detector in the vector of similar detector= "<<
1171 std::cout<<
"Subelement index= "<<
1173 std::cout<<
"==========================================\n";
1222 std::cout<<
"QwLumi::ProcessEvent_2(): processing with exchanged data"<<std::endl;
1223 std::cout<<
"pedestal, calfactor, average volts = "<<pedestal<<
", "<<calfactor<<
", "<<volts<<std::endl;
1229 catch (std::exception&
e)
1231 std::cerr << e.what() << std::endl;
1246 Bool_t local_print_flag =
false;
1247 if(local_print_flag){
1248 QwMessage <<
" --------------------------------------------------------------- " <<
QwLog::endl;
1250 QwMessage <<
" --------------------------------------------------------------- " <<
QwLog::endl;
1253 std::vector<QwDBInterface> interface;
1254 std::vector<QwParitySSQLS::lumi_data> entrylist;
1258 TString measurement_type;
1268 for(j=0; j<interface.size(); j++){
1269 interface.at(j).SetAnalysisID( analysis_id );
1270 interface.at(j).SetLumiDetectorID( db );
1271 interface.at(j).SetMeasurementTypeID( measurement_type );
1272 interface.at(j).PrintStatus( local_print_flag );
1273 interface.at(j).AddThisEntryToList( entrylist );
1282 for(j=0; j<interface.size(); j++) {
1283 interface.at(j).SetAnalysisID( analysis_id );
1284 interface.at(j).SetLumiDetectorID( db );
1285 interface.at(j).SetMeasurementTypeID( measurement_type );
1286 interface.at(j).PrintStatus( local_print_flag );
1287 interface.at(j).AddThisEntryToList( entrylist );
1294 if(local_print_flag) {
1302 if( entrylist.size() ) {
1303 mysqlpp::Query query= db->
Query();
1304 query.insert(entrylist.begin(), entrylist.end());
1308 QwMessage <<
"QwLumi::FillDB :: This is the case when the entrlylist contains nothing in "<< datatype.Data() <<
QwLog::endl;
1322 Bool_t local_print_flag =
false;
1323 if(local_print_flag){
1324 QwMessage <<
" --------------------------------------------------------------- " <<
QwLog::endl;
1326 QwMessage <<
" --------------------------------------------------------------- " <<
QwLog::endl;
1329 std::vector<QwErrDBInterface> interface;
1330 std::vector<QwParitySSQLS::lumi_errors> entrylist;
1341 for(j=0; j<interface.size(); j++){
1342 interface.at(j).SetAnalysisID ( analysis_id );
1343 interface.at(j).SetLumiDetectorID ( db );
1344 interface.at(j).PrintStatus ( local_print_flag );
1345 interface.at(j).AddThisEntryToList( entrylist );
1354 for(j=0; j<interface.size(); j++) {
1355 interface.at(j).SetAnalysisID ( analysis_id );
1356 interface.at(j).SetLumiDetectorID ( db );
1357 interface.at(j).PrintStatus ( local_print_flag );
1358 interface.at(j).AddThisEntryToList( entrylist );
1365 if(local_print_flag) {
1373 if( entrylist.size() ) {
1374 mysqlpp::Query query= db->
Query();
1375 query.insert(entrylist.begin(), entrylist.end());
1379 QwMessage <<
"QwLumi::FillErrDB :: This is the case when the entrlylist contains nothing in "<< datatype.Data() <<
QwLog::endl;
1392 Bool_t local_print_flag =
true;
1393 if(local_print_flag){
1394 QwMessage <<
" --------------------------------------------------------------- " <<
QwLog::endl;
1396 QwMessage <<
" --------------------------------------------------------------- " <<
QwLog::endl;
Int_t GetSubbankIndex() const
#define QwMessage
Predefined log drain for regular messages.
std::map< TString, TString > fDetectorMaps
const QwIntegrationPMT * GetIntegrationPMT(const TString name) const
EQwPMTInstrumentType GetQwPMTInstrumentType(TString name)
#define default_bool_value(b)
void Sum(VQwSubsystem *value1, VQwSubsystem *value2)
void DeaccumulateRunningSum(VQwSubsystem *value)
remove one entry from the running sums for devices
Int_t LoadChannelMap(TString mapfile)
Mandatory map file definition.
Bool_t Connect()
Open a connection to the database using the predefined parameters.
void SetNormalizability(Bool_t isnormalizable)
static UInt_t GetUInt(const TString &varvalue)
void FillTreeVector(std::vector< Double_t > &values) const
Fill the tree vector.
void Normalize(VQwDataElement *denom)
std::vector< Double_t > fWeight
Bool_t bIsExchangedDataValid
void PrintInfo() const
Print some information about the subsystem.
virtual UInt_t UpdateErrorFlag()
Uses the error flags of contained data elements to update Returns the error flag to the top level rou...
void FillErrDB(QwParityDB *db, TString datatype)
void PrintValue() const
Print values of all channels.
Bool_t HasDataLoaded() const
void UpdateErrorFlag(const VQwSubsystem *ev_error)
update the error flag in the subsystem level from the top level routines related to stability checks...
void FillHistograms()
Fill the histograms for this subsystem.
void ConstructBranch(TTree *tree, TString &prefix)
Construct the branch and tree vector.
void DoNormalization(Double_t factor=1.0)
void Difference(VQwSubsystem *value1, VQwSubsystem *value2)
Int_t LoadEventCuts(TString filename)
Load the event cuts file.
const QwIntegrationPMT * GetChannel(const TString name) const
TString GetQwPMTInstrumentTypeName(EQwPMTInstrumentType type)
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...
std::vector< QwCombinedPMT > fCombinedPMT
Bool_t ApplySingleEventCuts()
Apply the single event cuts.
virtual void ConstructHistograms()
Construct the histograms for this subsystem.
Bool_t PublishByRequest(TString device_name)
Try to publish an internal variable matching the submitted name.
po::options_description_easy_init AddOptions(const std::string &blockname="Specialized options")
Add an option to a named block or create new block.
static void PrintErrorCounterHead()
void ProcessOptions(QwOptions &options)
Process the command line options.
T GetValue(const std::string &key)
Get a templated value.
VQwSubsystem & operator+=(VQwSubsystem *value)
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.
static const Bool_t bDEBUG
VQwSubsystem & operator=(VQwSubsystem *value)
Assignment Note: Must be called at the beginning of all subsystems routine call to operator=(VQwSubsy...
void WritePromptSummary(QwPromptSummary *ps, TString type)
static void DefineOptions()
Define options function (note: no virtual static functions in C++)
void PrintErrorCounters() const
Report the number of events failed due to HW and event cut failures.
EQwPMTInstrumentType fTypeID
void RandomizeEventData(int helicity=0, double time=0.0)
TString fSystemName
Name of this subsystem.
mysqlpp::Query Query(const char *qstr=0)
void SetBlindability(Bool_t isblindable)
Int_t ProcessConfigurationBuffer(const UInt_t roc_id, const UInt_t bank_id, UInt_t *buffer, UInt_t num_words)
void CalculateRunningAverage()
Calculate the average for all good events.
void SetBlindability(Bool_t isblindable)
std::vector< QwLumiDetectorID > fLumiDetectorID
The pure virtual base class of all subsystems.
Int_t GetDetectorIndex(EQwPMTInstrumentType TypeID, TString name)
std::vector< QwIntegrationPMT > fIntegrationPMT
void EncodeEventData(std::vector< UInt_t > &buffer)
void ProcessEvent_2()
Process the event data again, including data from other subsystems. Not all derived classes will requ...
A color changing class for the output stream.
class QwScaler_Channel< 0x00ffffff, 0 > QwSIS3801D24_Channel
Int_t fCurrentROC_ID
ROC ID that is currently being processed.
void SetRandomEventParameters(Double_t mean, Double_t sigma)
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.
Bool_t Compare(VQwSubsystem *source)
void SetNormalizability(Bool_t isnormalizable)
static std::ostream & endl(std::ostream &)
End of the line.
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.
void SetRandomEventAsymmetry(Double_t asymmetry)
Bool_t RequestExternalValue(const TString &name, VQwHardwareChannel *value) const
Request a named value which is owned by an external subsystem; the request will be handled by the par...
void Scale(Double_t factor)
static TString DetermineMeasurementTypeID(TString type, TString suffix="", Bool_t forcediffs=kFALSE)
Bool_t PublishInternalValue(const TString &name, const TString &desc, const VQwHardwareChannel *value) const
Publish a variable name to the parent subsystem array.
Bool_t PublishInternalValues() const
Publish all variables of the subsystem.
static void PrintErrorCounterTail()
static Int_t GetBufferOffset(Int_t moduleindex, Int_t channelindex)
void PrintDetectorID() const
std::vector< QwSIS3801D24_Channel > fScalerPMT
QwBeamCharge fTargetCharge
#define QwWarning
Predefined log drain for warnings.
void IncrementErrorCounters()
Increment the error counters.
void FillDB(QwParityDB *db, TString datatype)
Fill the database.
std::vector< TString > fCombinedChannelNames
void ExchangeProcessedData()
Int_t fCurrentBank_ID
Bank ID that is currently being processed.
void Ratio(VQwSubsystem *numer, VQwSubsystem *denom)
UInt_t GetEventcutErrorFlag()
Return the error flag to the top level routines related to stability checks and ErrorFlag updates...
const QwCombinedPMT * GetCombinedPMT(const TString name) const
QwParameterFile * ReadUntilNextModule(const bool add_current_line=false)
void AccumulateRunningSum(VQwSubsystem *value)
Update the running sums for devices.
VQwSubsystem & operator-=(VQwSubsystem *value)
#define RegisterSubsystemFactory(A)
#define QwError
Predefined log drain for errors.
UInt_t GetGlobalErrorFlag(TString evtype, Int_t evMode, Double_t stabilitycut)
EQwPMTInstrumentType GetDetectorTypeID(TString name)
TString GetSubsystemName() const
void SetDataLoaded(Bool_t flag)