78 fBCM_Gain(0), fBCM_Offset(0), fBCM_SatOffset(0), fBCM_SatQuadratic(0), fBCM_delta_charge(0),
79 evcount(0), evcountR(0.0), ifound(0), fNormIdx(-1),
81 dvars(0),dvars_prev_read(0), dvarsFirst(0), fScalerTree(0), fUseFirstEvent(
kTRUE),
82 fOnlySyncEvents(
kFALSE), fOnlyBanks(
kFALSE), fDelayedType(-1),
83 fClockChan(-1), fLastClock(0), fClockOverflows(0)
111 delete[] fDelayedEvent;
119 cout <<
"THcScalerEvtHandler::End Analyzing " <<
fDelayedEvents.size() <<
" delayed scaler events" << endl;
129 delete[] fDelayedEvent;
162 {
"BCM_Names", &bcm_namelist, kString},
174 vector<string> bcm_names = Podd::vsplit(bcm_namelist);
176 fBCM_Name.push_back(bcm_names[i]+
".scal");
210 *
fDebugFile << endl <<
"---------------------------------- "<<endl<<endl;
211 *
fDebugFile <<
"\nEnter THcScalerEvtHandler for fName = "<<
fName<<endl;
242 for (
size_t i = 0; i <
scalerloc.size(); i++) {
255 auto *datacopy =
new UInt_t[evlen];
257 memcpy(datacopy,rdata,evlen*
sizeof(
UInt_t));
283 *
fDebugFile <<
"Bank: " << hex << *
p << dec <<
" len: " << *(
p-1) << endl;
285 if((*
p & 0xff00) == 0x1000) {
287 }
else if (((*
p & 0xff00) == 0x100) && (*
p != 0xC0000100)) {
295 UInt_t tag = (*
p>>16) & 0xffff;
304 if(onlysync && num==0) {
328 *
fDebugFile <<
"Scaler Header: " << hex << *
p << dec;
330 for(
size_t j=0; j<
scalers.size(); j++) {
332 nskip =
scalers[j]->GetNumChan() + 1;
335 *
fDebugFile <<
" found (" << j <<
") skip " << nskip << endl;
358 *
fDebugFile <<
"Finished with decoding. "<<endl;
378 cout <<
" ******************* Severe Warning ****************************" << endl;
379 cout <<
" In THcScalerEvtHandler have found fDeltaTime is zero !! " << endl;
380 cout <<
" ******************* Alert DAQ experts ****************************" << endl;
384 for (
size_t i = 0; i <
scalerloc.size(); i++) {
396 dvars[ivar] = scaldata;
416 if (match!=string::npos)
462 if (match!=string::npos)
488 cout <<
"THcScalerEvtHandler:: ERROR:: incorrect index "<<ivar<<
" "<<idx<<
" "<<ichan<<endl;
525 if (match!=string::npos)
545 dvars[ivar]=cur_temp;
572 cout <<
"THcScalerEvtHandler:: ERROR:: incorrect index "<<ivar<<
" "<<idx<<
" "<<ichan<<endl;
579 size_t ivar = i->ivar;
580 size_t idx = i->index;
581 size_t ichan = i->ichan;
600 if (match!=string::npos)
621 for(
auto& scaler:
scalers ) scaler->Clear(
"");
638 delete [] fDelayedEvent;
641 cout <<
"Howdy ! We are initializing THcScalerEvtHandler !! name = "
649 dfile =
fName +
"scaler.txt";
655 sname =
fName+sname0;
657 FILE *fi = Podd::OpenDBFile(sname.
Data(), date);
659 cout <<
"Cannot find db file for "<<
fName<<
" scaler event handler"<<endl;
665 string scomment =
"#";
666 string svariable =
"variable";
668 vector<string> dbline;
670 while( fgets(cbuf, LEN, fi) ) {
671 std::string
sin(cbuf);
672 std::string sinput(
sin.substr(0,
sin.find_first_of(
'#')));
674 dbline = Podd::vsplit(sinput);
675 if (!dbline.empty()) {
676 pos1 = FindNoCase(dbline[0],scomment);
677 if (pos1 != minus1)
continue;
678 pos1 = FindNoCase(dbline[0],svariable);
679 if (pos1 != minus1 && dbline.size()>4) {
681 for (
size_t j=5; j<dbline.size(); j++) sdesc = sdesc+
" "+dbline[j];
682 UInt_t islot = atoi(dbline[1].c_str());
683 UInt_t ichan = atoi(dbline[2].c_str());
684 UInt_t ikind = atoi(dbline[3].c_str());
686 *
fDebugFile <<
"add var "<<dbline[1]<<
" desc = "<<sdesc<<
" islot= "<<islot<<
" "<<ichan<<
" "<<ikind<<endl;
687 TString tsname(dbline[4].c_str());
689 AddVars(tsname,tsdesc,islot,ichan,ikind);
696 pos1 = FindNoCase(dbline[0],smap);
697 if (
fDebugFile) *
fDebugFile <<
"map ? "<<dbline[0]<<
" "<<smap<<
" "<<pos1<<
" "<<dbline.size()<<endl;
698 if (pos1 != minus1 && dbline.size()>6) {
699 Int_t imodel, icrate, islot, inorm;
702 sscanf(sinput.c_str(),
"%s %d %d %d %x %x %d \n",cdum,&imodel,&icrate,&islot, &header, &
mask, &inorm);
703 if ((
fNormSlot >= 0) && (
fNormSlot != inorm)) cout <<
"THcScalerEvtHandler::WARN: contradictory norm slot "<<
fNormSlot<<
" "<<inorm<<endl;
707 if (dbline.size()>8) {
708 clkchan = atoi(dbline[7].c_str());
709 clkfreq = 1.0*atoi(dbline[8].c_str());
714 *
fDebugFile <<
"map line "<<dec<<imodel<<
" "<<icrate<<
" "<<islot<<endl;
715 *
fDebugFile <<
" header 0x"<<hex<<header<<
" 0x"<<
mask<<dec<<
" "<<inorm<<
" "<<clkchan<<
" "<<clkfreq<<endl;
761 cout <<
"Setting scaler clock ... channel = "<<clkchan<<
" ... freq = "<<clkfreq<<endl;
762 if (
fDebugFile) *
fDebugFile <<
"Setting scaler clock ... channel = "<<clkchan<<
" ... freq = "<<clkfreq<<endl;
764 if (islot !=
fNormSlot) cout <<
"THcScalerEvtHandler:: WARN: contradictory norm slot ! "<<islot<<endl;
785 if (
fName ==
"Left") {
803 if (
fName ==
"Left") {
808 scalers[0]->SetHeader(0xabc00000, 0xffff0000);
809 scalers[1]->SetHeader(0xabc10000, 0xffff0000);
810 scalers[2]->SetHeader(0xabc20000, 0xffff0000);
811 scalers[3]->SetHeader(0xabc30000, 0xffff0000);
813 scalers[1]->SetClock(4, 7, 1024);
821 scalers[0]->SetHeader(0xceb00000, 0xffff0000);
822 scalers[1]->SetHeader(0xceb10000, 0xffff0000);
823 scalers[2]->SetHeader(0xceb20000, 0xffff0000);
824 scalers[3]->SetHeader(0xceb30000, 0xffff0000);
825 scalers[0]->SetClock(4, 7, 1024);
836 cout <<
"THcScalerEvtHandler:: WARN: same slot defined twice"<<endl;
848 for (
size_t i=0; i<
scalers.size(); i++) {
877 if (
Nvars == 0)
return;
887 cout <<
"No gHaVars ?! Well, that's a problem !!"<<endl;
891 const Int_t* count =
nullptr;
892 for (
size_t i = 0; i <
scalerloc.size(); i++) {
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t mask
R__EXTERN class THaVarList * gHaVars
ClassImp(VDC::AnalyticTTDConv) using namespace std
R__EXTERN class THcParmList * gHcParms
static const UInt_t ICURRENT
static const UInt_t IRATE
static const UInt_t defaultDT
static const UInt_t ICOUNT
static const UInt_t ITIME
static const UInt_t MAXCHAN
static const UInt_t ICHARGE
const UInt_t * GetRawDataBuffer() const
UInt_t GetEvLength() const
std::vector< UInt_t > eventtypes
virtual Bool_t IsMyEvent(UInt_t type) const
virtual void EvDump(THaEvData *evdata) const
std::ofstream * fDebugFile
virtual THaVar * DefineByType(const char *name, const char *desc, const void *loc, VarType type, const Int_t *count, const char *errloc="DefineByType")
Int_t LoadParmValues(const DBRequest *list, const char *prefix="")
Retrieve parameter values from the parameter cache.
Event handler for Hall C scalers.
Int_t Analyze(THaEvData *evdata)
std::set< UInt_t > fModuleSet
Double_t * fBCM_SatQuadratic
std::vector< HCScalerLoc * > scalerloc
std::vector< UInt_t > scal_prev_read
std::vector< Decoder::GenScaler * > scalers
std::vector< UInt_t * > fDelayedEvents
Double_t fbcm_Current_Threshold
virtual Int_t ReadDatabase(const TDatime &date)
std::vector< UInt_t > scal_present_read
std::vector< std::string > fBCM_Name
virtual void SetDelayedType(int evtype)
Double_t * fBCM_delta_charge
std::set< UInt_t > fRocSet
void AddVars(const TString &name, const TString &desc, UInt_t iscal, UInt_t ichan, UInt_t ikind)
Double_t * fBCM_SatOffset
virtual Int_t End(THaRunBase *r=nullptr)
Int_t fbcm_Current_Threshold_Index
virtual ~THcScalerEvtHandler()
Int_t AnalyzeBuffer(UInt_t *rdata, Bool_t onlysync)
std::vector< UInt_t > scal_overflows
THcScalerEvtHandler(const char *, const char *)
static Bool_t Initialized()
const char * Data() const
virtual void SetAutoSave(Long64_t autos=-300000000)
Int_t Write(const char *name=nullptr, Int_t option=0, Int_t bufsize=0) const override
virtual Int_t Branch(const char *folder, Int_t bufsize=32000, Int_t splitlevel=99)
RVec< PromoteType< T > > sin(const RVec< T > &v)
string::size_type FindNoCase(string data, string chunk)
Double_t Power(Double_t x, Double_t y)
Double_t Max(Double_t a, Double_t b)