30 :
THaFormula(), fNvar(0), fObjSize(0), fEyeOffset(0), fData(0.0),
31 fType(
kUnknown), fDebug(0), fVarPtr(nullptr), fOdata(nullptr),
58 THaFormula(rhs), fNvar(rhs.fNvar), fObjSize(rhs.fObjSize),
59 fEyeOffset(rhs.fEyeOffset), fData(rhs.fData),
60 fType(rhs.fType), fDebug(rhs.fDebug), fAndStr(rhs.fAndStr), fOrStr(rhs.fOrStr),
61 fSumStr(rhs.fSumStr), fVarName(rhs.fVarName), fVarStat(rhs.fVarStat),
62 fSarray(rhs.fSarray), fVectSform(rhs.fVectSform), fStitle(rhs.fStitle),
63 fVarPtr(rhs.fVarPtr), fOdata(nullptr), fPrefix(rhs.fPrefix)
67 for(
const auto* theCut : rhs.
fCut ) {
74 for(
const auto* theForm : rhs.
fFormula ) {
116 for(
const auto* itf : rhs.
fFormula ) {
122 for(
const auto* itc : rhs.
fCut ) {
144 for(
auto& itc :
fCut )
delete itc;
145 for(
auto& itf :
fFormula )
delete itf;
155 cout <<
"Num of variables " <<
fNvar << endl;
156 cout <<
"Object size " <<
fObjSize << endl;
158 cout <<
"Var # " << i <<
" name = " <<
162 cout <<
"Formula full printout --> " << endl;
165 for(
const auto* itc :
fCut ) {
166 cout <<
"Cut full printout --> " << endl;
176 if (
IsVarray()) cout <<
" variable sized array: ";
178 if (
IsCut()) cout <<
" cut: ";
179 if (
IsEye()) cout <<
" [I]-var: ";
189 cout <<
"THaVform::Explanation of error status -->"<<endl;
198 cout <<
"If you make a formula of a variable sized array"<<endl;
199 cout <<
"like L.vdc.v1.wire, then the formula string must"<<endl;
200 cout <<
"ONLY contain that variable, no brackets, NOTHING else."<<endl;
201 cout <<
"Data appears in Tree same as for a variable"<<endl;
202 cout <<
"However, e.g. '2*L.vdc.v1.wire' is undefined."<<endl;
206 cout <<
"Illegal type of THaVform"<<endl;
207 cout <<
"Only options at present are "<<endl;
208 cout <<
"'formula', 'cut', 'eye'"<<endl;
212 cout <<
"There are no global variables defined !!"<<endl;
216 cout <<
"You CANNOT have a formula that mixes"<<endl;
217 cout <<
"variable sized and fixed sized arrays."<<endl;
218 cout <<
"Note: Formula can only defined by fixed sized arrays"<<endl;
219 cout <<
"like L.s1.lt. So e.g. '2*L.s1.lt - 500' is ok."<<endl;
223 cout <<
"Attempting to use a variable with pointer = 0."<<endl;
224 cout <<
"The variables must be defined in the code."<<endl;
225 cout <<
"Try 'gHaVars->Print()' to verify names."<<endl;
229 cout <<
"Your formula uses variables of different sizes."<<endl;
230 cout <<
"This is not meaningful."<<endl;
234 cout <<
"Unknown prefix."<<endl;
235 cout <<
"The presently supported prefixes are "<<endl;
236 cout <<
"'SUM:', 'AND:', and 'OR:' "<<endl;
237 cout <<
"(case insensitive)"<<endl;
241 cout <<
"Illegal usage of prefix."<<endl;
242 cout <<
"'SUM:' can be used with formula and cuts."<<endl;
243 cout <<
"'AND:', and 'OR:' can only be used with cuts."<<endl;
247 cout <<
"Unknown error !!"<<endl;
271 if (
IsEye())
return 0;
306 cout <<
"ERROR:THaVform:: Cannot mix variable arrays with ";
307 cout <<
"other variables or formula."<<endl;
315 if (i ==
fNvar)
continue;
320 if (!pvar1 || !pvar2) {
322 cout <<
"THaVform:ERROR: Trying to use zero pointer."<<endl;
325 if( !(pvar1->HasSameSize(pvar2)) ) {
326 cout <<
"THaVform::ERROR: Var "<<
fVarName[i]<<
" and ";
327 cout <<
fVarName[j]<<
" have different sizes "<<endl;
344 if (status != 0)
return status;
373 for(
auto& itc :
fCut ) itc->Compile();
374 for(
auto& itf :
fFormula ) itf->Compile();
388 if (flo < 0) flo = 0;
389 if (flo >= fhi)
return 0;
393 cout <<
"THaVform::WARNING: Asking for a too-huge";
394 cout <<
" number of formulas !!" << endl;
404 for (
Int_t i = flo; i < fhi; ++i) {
440 cout <<
"THaVform:ERROR:: Unknown prefix"<<endl;
442 if (status != 0)
return status;
444 if (iscut && !
IsCut()) {
446 cout <<
"THaVform:ERROR:: Illegal prefix -- "<<endl;
447 cout <<
"OR:, AND: works only with cuts."<<endl;
448 cout <<
"SUM: works only with both cuts and formulas."<<endl;
453 for (
Int_t i = 0; i < fhi; ++i) {
455 if (i < (
long)
fVectSform.size()-1) sform += soper;
461 if( !
fCut.empty() ) {
462 for(
auto& itc :
fCut )
delete itc;
492 static const vector<Int_t> ipflg{
kAnd,
kOr,
kSum };
495 string stitle = string(expr);
499 for (string::size_type i = 0; i < sprefix.size(); ++i) {
500 auto pos1 = stitle.find(
ToUpper(sprefix[i]),0);
501 auto pos2 = stitle.find(
ToLower(sprefix[i]),0);
502 auto pos = string::npos;
503 if (pos1 != string::npos) pos = pos1;
504 if (pos2 != string::npos) pos = pos2;
505 if (pos != string::npos) {
507 cerr <<
"THaVform:ERROR:: Cannot have >1 prefix."<<endl;
510 pos = pos + sprefix[i].length();
511 result = stitle.substr(pos,pos+stitle.length());
517 const string eye =
"[I]";
521 auto pos = string::npos;
522 if (pos1 != string::npos) pos = pos1;
523 if (pos2 != string::npos) pos = pos2;
524 if (pos != string::npos)
result = stemp.substr(0,pos);
534 auto pos1 = var.find(
'[',0);
535 auto pos2 = var.find(
']',0);
536 if( (pos1 != string::npos) &&
537 (pos2 != string::npos) && pos2 > pos1 ) {
538 result = var.substr(0,pos1);
539 result += var.substr(pos2+1,var.length());
549 if (
IsEye())
return 0;
550 string mydata = string(
GetName());
556 tinfo = mydata +
"/D";
557 tree->Branch(mydata.c_str(), &
fData, tinfo.c_str(), 4000);
578 if ( !theFormula->
IsError() ) {
584 vector<THaFormula*>::size_type i =
fFormula.size();
609 cout <<
"THaVform::ERROR: storing too much";
610 cout <<
" variable sized data: ";
646 vector<THaCut*>::size_type i =
fCut.size();
674 if (
fDebug) cout <<
"THaVform::DefinedGlob for name = " <<
name << endl;
682 const auto* gvar =
static_cast<const THaVar*
>( def.
obj );
690 if( gvar->IsArray() ) {
697 if (gvar->GetLen() == 0) {
705 if (gvar->IsArray()) cout <<
"gvar is array"<<endl;
706 if (gvar->IsBasic()) cout <<
"gvar is basic"<<endl;
707 if (gvar->IsPointerArray()) cout <<
"gvar is pointer array"<<endl;
708 cout <<
"Here is gvar print "<<endl;
710 cout <<
"end of gvar print "<<endl<<endl;
711 cout <<
"length of var "<< gvar->GetLen()<<endl;
724 const string open_brack=
"[";
725 const string close_brack=
"]";
727 for (
int idx = 0; idx <
size; ++idx) {
729 string aline = acopy;
733 for(
const auto& sb :
fSarray ) {
734 vector<string::size_type> ipos;
735 string::size_type pos1 = 0;
736 string::size_type pos = 0;
738 while( pos != string::npos ) {
739 pos = acopy.find(sb, pos1);
740 pos1 = pos + sb.length();
741 auto pos2 = acopy.find(open_brack, pos1);
742 if( pos != string::npos &&
743 (pos2 == string::npos || pos2 > pos1))
744 ipos.push_back(pos1);
746 if( ipos.empty() )
continue;
751 for(
auto ipo : ipos ) {
752 aline.append(acopy.substr(pos, ipo));
753 aline.append(open_brack).append(num).append(close_brack);
756 aline.append(acopy.substr(ipos[ipos.size()-1],acopy.length()));
759 if( aline.length() > 0 )
size_t size(const MatrixT &matrix)
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 result
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 Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char cname
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 Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
TString ToUpper(const TString &s)
TString ToLower(const TString &s)
char * Form(const char *fmt,...)
void Clear(Option_t *="")
void AddBranches(TTree *T, std::string name)
Int_t Fill(Int_t i, Double_t dat)
virtual THaVar * Find(const char *name) const
Double_t GetValue(Int_t i=0) const
virtual void SetTitle(const char *title="")
const char * GetName() const override
const char * GetTitle() const override
virtual void SetName(const char *name)
int CmpNoCase(const string &r, const string &s)