Hall A ROOT/C++ Analyzer (podd)
Loading...
Searching...
No Matches
THaFormula.cxx
Go to the documentation of this file.
1//*-- Author : Ole Hansen 20/04/2000
2
4//
5// THaFormula
6//
7// A formula that is aware of the analyzer's global variables, similar
8// to TFormula;s parameters. Unlike TFormula, an arbitrary number of
9// global variables may be referenced in a THaFormula.
10//
11// THaFormulas containing arrays are arrays themselves. Each element
12// (instance) of such an array formula may be evaluated separately.
13//
15
16#include "THaFormula.h"
17#include "THaArrayString.h"
18#include "THaVarList.h"
19#include "THaCutList.h"
20#include "THaCut.h"
21#include "TROOT.h"
22#include "TError.h"
23#include "TVirtualMutex.h"
24#include "TMath.h"
25#include "DataType.h"
26#include "Helper.h"
27
28#include <cstring>
29#include <cassert>
30#include <algorithm>
31#include <numeric>
32#include <vector>
33
34using namespace std;
35
36const Option_t* const THaFormula::kPRINTFULL = "FULL";
37const Option_t* const THaFormula::kPRINTBRIEF = "BRIEF";
38
41
42//_____________________________________________________________________________
43static inline Int_t NumberOfSetBits( UInt_t v )
44{
45 // Count number of bits set in 32-bit integer. From
46 // http://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetParallel
47
48 v = v - ((v >> 1) & 0x55555555);
49 v = (v & 0x33333333) + ((v >> 2) & 0x33333333);
50 return (((v + (v >> 4)) & 0x0F0F0F0F) * 0x01010101) >> 24;
51}
52
53//_____________________________________________________________________________
55{
56 // Count number of bits in 64-bit integer
57
58 const ULong64_t mask32 = (1LL<<32)-1;
59 return NumberOfSetBits( static_cast<UInt_t>(mask32 & v) ) +
60 NumberOfSetBits( static_cast<UInt_t>(mask32 & (v>>32)) );
61}
62
63//_____________________________________________________________________________
65 TFormula(), fVarList(nullptr), fCutList(nullptr), fInstance(0)
66{
67 // Default constructor
68
69 Init( nullptr, nullptr );
70}
71
72//_____________________________________________________________________________
73THaFormula::THaFormula( const char* name, const char* expression,
74 Bool_t do_register,
75 const THaVarList* vlst, const THaCutList* clst )
76 : TFormula(), fVarList(vlst), fCutList(clst), fInstance(0)
77{
78 // Create a formula 'expression' with name 'name' and symbolic variables
79 // from the list 'lst'.
80
81 // We have to duplicate the TFormula constructor code here because of
82 // the call to Compile(). Not only do we have our own Compile(), but
83 // also out own DefinedVariable() etc. virtual functions. A disturbing
84 // design error of the ROOT base class indeed.
85
86 if( Init( name, expression ) != 0 ) {
87 RegisterFormula(false);
88 return;
89 }
90
91 SetBit(kNotGlobal,!do_register);
92
93 Compile(); // This calls our own Compile()
94
95 if( do_register )
97}
98
99//_____________________________________________________________________________
100Int_t THaFormula::Init( const char* name, const char* expression )
101{
102 // Common initialization called from the constructors
103
104 const char* const here = "THaFormula";
105
112
113 if( !name )
114 return -1;
115 SetName(name);
116
117 if( fName.IsWhitespace() ) {
118 Error(here, "name may not be empty");
119 SetBit(kError);
120 }
121
122 // Eliminate blanks in expression and convert "**" to "^"
123 TString chaine(expression);
124 chaine.ReplaceAll(" ","");
125 if( chaine.Length() == 0 ) {
126 Error(here, "expression may not be empty");
127 SetBit(kError);
128 return -1;
129 }
130 chaine.ReplaceAll("**","^");
131
132 Bool_t gausNorm = false, landauNorm = false, linear = false;
133
134 //special case for functions for linear fitting
135 if (chaine.Contains("++"))
136 linear = true;
137 // special case for normalized gaus
138 if (chaine.Contains("gausn")) {
139 gausNorm = true;
140 chaine.ReplaceAll("gausn","gaus");
141 }
142 // special case for normalized landau
143 if (chaine.Contains("landaun")) {
144 landauNorm = true;
145 chaine.ReplaceAll("landaun","landau");
146 }
147 SetTitle(chaine.Data());
148
149 if( linear )
151
152 if( gausNorm || landauNorm )
154
155 return 0;
156}
157
158//_____________________________________________________________________________
160 TFormula(rhs), fVarDef(rhs.fVarDef),
161 fVarList(rhs.fVarList), fCutList(rhs.fCutList), fInstance(0)
162{
163 // Copy ctor
164}
165
166//_____________________________________________________________________________
167THaFormula::~THaFormula() = default;
168
169//_____________________________________________________________________________
171{
172 if( this != &rhs ) {
174 fVarDef = rhs.fVarDef;
175 fVarList = rhs.fVarList;
176 fCutList = rhs.fCutList;
177 fInstance = 0;
178 }
179 return *this;
180}
181
182//_____________________________________________________________________________
184 : type(rhs.type), obj(rhs.obj), index(rhs.index)
185{
186 if( (type == kFormula || type == kVarFormula) && rhs.obj != nullptr )
187 obj = new THaFormula(*static_cast<THaFormula*>(rhs.obj));
188}
189
190//_____________________________________________________________________________
192{
193 if( this != &rhs ) {
194 if( type == kFormula || type == kVarFormula )
195 delete static_cast<THaFormula*>(obj);
196 type = rhs.type;
197 if( (type == kFormula || type == kVarFormula) && rhs.obj != nullptr )
198 obj = new THaFormula(*static_cast<THaFormula*>(rhs.obj));
199 else
200 obj = rhs.obj;
201 index = rhs.index;
202 }
203 return *this;
204}
205
206//_____________________________________________________________________________
208 : type(rhs.type), obj(rhs.obj), index(rhs.index)
209{
210 rhs.obj = nullptr;
211}
212
213//_____________________________________________________________________________
215{
216 if( this != &rhs ) {
217 if( type == kFormula || type == kVarFormula )
218 delete static_cast<THaFormula*>(obj);
219 type = rhs.type;
220 obj = rhs.obj;
221 index = rhs.index;
222 rhs.obj = nullptr;
223 }
224 return *this;
225}
226
227//_____________________________________________________________________________
229{
230 if( type == kFormula || type == kVarFormula )
231 delete static_cast<THaFormula*>(obj);
232}
233
234//_____________________________________________________________________________
235Int_t THaFormula::Compile( const char* expression )
236{
237 // Parse the given expression, or, if empty, parse the title.
238 // Return 0 on success, 1 if error in expression.
239
240 fNval = 0;
241 fAlreadyFound.ResetAllBits(); // Seems to be missing in ROOT
242 fVarDef.clear();
244
245 Int_t status = TFormula::Compile( expression );
246
247
248 SetBit(kError, (status != 0));
249 if( !IsError() ) {
250 assert( fNval+fNstring - fVarDef.size() == 0 );
251 assert( fNstring >= 0 && fNval >= 0 );
252 // If the formula is good, then fix the variable counters that TFormula
253 // may have messed with when reverting lone kDefinedString variables to
254 // kDefinedVariable. If there is a mix of strings and values, we force
255 // the variable counters to the full number of defined variables, so
256 // that the loops in EvalPar calculate all the values. This is inefficient,
257 // but the best we can do with the implementation of TFormula.
258 if( fNstring > 0 && fNval > 0 )
259 fNval = fNstring = static_cast<Int_t>(fVarDef.size());
260 }
261 return status;
262}
263
264//_____________________________________________________________________________
266{
267 // Get pointer to the i-th string variable. If the variable is not
268 // a string, return pointer to an empty string.
269
270 assert( i>=0 && i<(Int_t)fVarDef.size() );
271 const FVarDef_t& def = fVarDef[i];
272 if( def.type == kString ) {
273 const auto* pvar = static_cast<const THaVar*>( def.obj );
274 char** ppc = (char**)pvar->GetValuePointer(); //truly gruesome cast
275 return *ppc;
276 }
277 return (char*)"";
278}
279
280//_____________________________________________________________________________
282{
283 Int_t action = GetAction(oper);
284 return ( action == kStringConst || action == kDefinedString );
285}
286
287//_____________________________________________________________________________
289{
290 // Get value of i-th variable in the formula
291 // If the i-th variable is a cut, return its last result
292 // (calculated at the last evaluation).
293 // If the variable is a string, return value of its character value
294 // kCutScaler and kCutNCalled give # times a cut passed and # times
295 // a cut has been evaluated. These types can only exist if hcana's
296 // THcFormula is used.
297 //
298
299 assert( i>=0 && i<(Int_t)fVarDef.size() );
300
301 if( IsInvalid() )
302 return 1.0;
303
304 const FVarDef_t& def = fVarDef[i];
305 switch( def.type ) {
306 case kVariable:
307 case kString:
308 case kArray:
309 {
310 const auto* var = static_cast<const THaVar*>(def.obj);
311 assert(var);
312 Int_t index = (def.type == kArray) ? fInstance : def.index;
313 assert(index >= 0);
314 if( index >= var->GetLen() ) {
316 return 1.0; // safer than kBig to prevent overflow
317 }
318 return var->GetValue( index );
319 }
320 break;
321 case kCut:
322 {
323 const auto* cut = static_cast<const THaCut*>(def.obj);
324 assert(cut);
325 return cut->GetResult();
326 }
327 break;
328 case kFunction:
329 {
330 auto code = static_cast<EFuncCode>(def.index);
331 if( code == kIteration )
332 return fInstance;
333 else {
334 assert(false); // not reached
335 }
336 }
337 break;
338 case kFormula:
339 case kVarFormula:
340 {
341 auto code = static_cast<EFuncCode>(def.index);
342 auto* func = static_cast<THaFormula*>(def.obj);
343 assert(func);
344
345 Int_t ndata = func->GetNdata();
346 if( code == kLength )
347 return ndata;
348
349 if( ndata == 0 ) {
350 //FIXME: needs thought
352 return 1.0;
353 }
354 Double_t y = kBig;
355 if( code == kNumSetBits ) {
356 // Number of set bits is intended for unsigned int-type expressions
357 y = func->EvalInstance(fInstance);
358 if( y > static_cast<double>(kMaxULong64>>11) || y < 0.0 ) {
359 return 0;
360 }
361 return NumberOfSetBits( static_cast<ULong64_t>(y) );
362 }
363
364 vector<Double_t> values;
365 values.reserve(ndata);
366 for( Int_t instance = 0; instance < ndata; ++instance ) {
367 values.push_back( func->EvalInstance(instance) );
368 }
369 if( func->IsInvalid() ) {
371 return 1.0;
372 }
373 switch( code ) {
374 case kSum:
375 y = accumulate( ALL(values), static_cast<Double_t>(0.0) );
376 break;
377 case kMean:
378 y = TMath::Mean( ndata, &values[0] );
379 break;
380 case kStdDev:
381 y = TMath::RMS( ndata, &values[0] );
382 break;
383 case kMax:
384 y = *max_element( ALL(values) );
385 break;
386 case kMin:
387 y = *min_element( ALL(values) );
388 break;
389 case kGeoMean:
390 y = TMath::GeomMean( ndata, &values[0] );
391 break;
392 case kMedian:
393 y = TMath::Median( ndata, &values[0] );
394 break;
395 default:
396 assert(false); // not reached
397 break;
398 }
399 return y;
400 }
401 break;
402 case kCutScaler:
403 {
404 const auto* cut = static_cast<const THaCut*>(def.obj);
405 assert(cut);
406 return cut->GetNPassed();
407 }
408 break;
409 case kCutNCalled:
410 {
411 const auto* cut = static_cast<const THaCut*>(def.obj);
412 assert(cut);
413 return cut->GetNCalled();
414 }
415 break;
416 }
417 assert(false); // not reached
418 return kBig;
419}
420
421//_____________________________________________________________________________
423{
424 // Check for function name not supported by THaFormula
425
426 const char* const numbers = "0123456789";
427
428 Ssiz_t len = name.Length();
429
430 // gaus, xgaus, pol0 etc.
431 const char* blacklist[] = { "expo", "gaus", "landau", "pol", nullptr };
432 const char** item = blacklist;
433 while( *item ) {
434 TString func( *(item++) );
435 Ssiz_t pos = name.Index(func);
436 if( pos == kNPOS ) continue;
437 Ssiz_t n = func.Length();
438 if( func != "pol" ) {
439 if( (pos == 0 || (pos == 1 && strchr("xyzt",name[0])) ||
440 (pos == 2 && name(0,2) == "xy")) && len == pos+n )
441 return 1;
442 } else {
443 if( (pos == 0 || (pos == 1 && strchr("xyzt",name[0]))) &&
444 len > pos+n && strchr(numbers,name[pos+n]) )
445 return 1;
446 }
447 }
448
449 // Plain parameters "[0]" etc. Reject any bare square brackets expression
450 if( len > 1 && name[0] == '[' && name[len-1] == ']' ) {
451 return 1;
452 }
453 return 0;
454}
455
456//_____________________________________________________________________________
458{
459 // Check if name is in the list of global objects
460
461 // This member function redefines the function in TFormula.
462 // A THaFormula may contain more than one variable.
463 // For each variable referenced, a pointer to the corresponding
464 // global object is stored
465 //
466 // Return codes:
467 // >=0 serial number of variable or cut found
468 // -1 variable not found
469 // -2 error parsing variable name
470 // -3 error parsing variable name, error already printed
471
472 action = kDefinedVariable;
473 fNpar = 0;
474
476 if( k != -1 )
477 return k;
478
480 if( k>=0 ) {
481 FVarDef_t& def = fVarDef[k];
482 const auto* pvar = static_cast<const THaVar*>( def.obj );
483 assert(pvar);
484 // Interpret Char_t* variables as strings
485 if( pvar->GetType() == kCharP ) {
486 action = kDefinedString;
487 // String definitions must be in the same array as variable definitions
488 // because TFormula may revert a kDefinedString to a kDefinedVariable.
489 def.type = kString;
490 // TFormula::Analyze will increment fNstring even if the string
491 // was already found. Fix this here.
492 if( k < kMAXFOUND && !fAlreadyFound.TestBitNumber(k) )
494 else
495 --fNstring;
496 }
497 return k;
498 }
499 if( k != -1 )
500 return k;
501
502 k = DefinedCut( name );
503 if( k != -1 )
504 return k;
505
506 // Filter out TFormula's parameterized functions and parameter expressions.
507 // THaFormula does not support parameters (fNpar>0) or dimensions (fNdim>0).
508 if( CheckBlacklistedNames(name) != 0 ) {
509 Error("Compile", " Unknown name : %s", name.Data());
510 return -3;
511 }
512
513 return k;
514}
515
516//_____________________________________________________________________________
518{
519 // Check if 'name' is a known cut. If so, enter it in the local list of
520 // variables used in this formula.
521
522 return DefinedCutWithType (name, kCut);
523}
524//_____________________________________________________________________________
526{
527 // Check if 'name' is a known cut. If so, enter it in the local list of
528 // variables used in this formula.
529
530 // Cut names are obviously only valid if there is a list of existing cuts
531 if( fCutList ) {
532 THaCut* pcut = fCutList->FindCut( name );
533 if( pcut ) {
534 // See if this cut already used earlier in the expression
535 for( vector<FVarDef_t>::size_type i=0; i<fVarDef.size(); ++i ) {
536 const FVarDef_t& def = fVarDef[i];
537 if( def.type == type && pcut == def.obj )
538 return i;
539 }
540 fVarDef.emplace_back(type, pcut, 0);
541 return fVarDef.size()-1;
542 }
543 }
544 return -1;
545}
546
547//_____________________________________________________________________________
552//_____________________________________________________________________________
554 const THaVarList* extralist)
555{
556 // Check if 'name' is a known global variable. If so, enter it in the
557 // local list of variables used in this formula.
558
559 // No global variable list?
560 if( !fVarList && !extralist)
561 return -1;
562
563 // Parse name for array syntax
564 THaArrayString parsed_name(name);
565 if( parsed_name.IsError() ) return -1;
566
567 // Find the variable with this name in the extralist (Hall C Parameter)
568 THaVar* var = nullptr;
569 if( extralist ) {
570 var = extralist->Find( parsed_name.GetName() );
571 }
572 if( !var && fVarList ) {
573 var = fVarList->Find( parsed_name.GetName() );
574 }
575 if(!var) {
576 return -1;
577 }
578
580 Int_t index = 0;
581 if( parsed_name.IsArray() ) {
582 // Requesting an array element
583 if( !var->IsArray() )
584 // Element requested but the corresponding variable is not an array
585 return -2;
586 if( var->IsVarArray() ) {
587 // Variable-size arrays are always 1-d
588 assert( var->GetNdim() == 1 );
589 if( parsed_name.GetNdim() != 1 )
590 return -2;
591 // For variable-size arrays, we allow requests for any element and
592 // check at evaluation time whether the element actually exists
593 index = parsed_name[0];
594 } else {
595 // Fixed-size arrays: check if subscript(s) within bounds?
596 //TODO: allow fixing some dimensions
597 index = var->Index( parsed_name );
598 if( index < 0 )
599 return -2;
600 }
601 } else if( var->IsArray() ) {
602 // Asking for an entire array
603 type = kArray;
605 if( var->IsVarArray() )
607 }
608
609 // Check if this variable already used in this formula
610 for( vector<FVarDef_t>::size_type i=0; i<fVarDef.size(); ++i ) {
611 const FVarDef_t& def = fVarDef[i];
612 if( var == def.obj && index == def.index ) {
613 assert( type == def.type );
614 return i;
615 }
616 }
617 // If this is a new variable, add it to the list
618 fVarDef.emplace_back(type, var, index);
619
620 return fVarDef.size()-1;
621}
622
623
624//_____________________________________________________________________________
626{
627 // Check if 'name' is a predefined special function
628
629 class FuncDef_t {
630 public:
631 const char* func;
632 const char* form;
634 EFuncCode code;
635 };
636 static const vector<FuncDef_t> func_defs = {
637 { "Length$(", "length$Form", kFormula, kLength },
638 { "Sum$(", "sum$Form", kFormula, kSum },
639 { "Mean$(", "mean$Form", kFormula, kMean },
640 { "StdDev$(", "stddev$Form", kFormula, kStdDev },
641 { "Max$(", "max$Form", kFormula, kMax },
642 { "Min$(", "min$Form", kFormula, kMin },
643 { "GeoMean$(", "geoMean$Form", kFormula, kGeoMean },
644 { "Median$(", "median$Form", kFormula, kMedian },
645 { "Iteration$", nullptr, kFunction, kIteration },
646 { "NumSetBits$(", "numbits$Form", kVarFormula, kNumSetBits }
647 };
648 for( const auto& def : func_defs ) {
649 if( def.form && name.BeginsWith(def.func) && name.EndsWith(")") ) {
650 // Make a subformula for the argument, but don't register it with ROOT
651 TString subform = name( strlen(def.func), name.Length() );
652 subform.Chop();
653 auto* func = new THaFormula(def.form, subform, false,
655 if( func->IsError() ) {
656 delete func;
657 return -3;
658 }
659 if( func->IsArray() ) {
660 if( func->IsVarArray() ) {
661 // Make a note that the argument may be empty at evaluation time,
662 // even if the formula is not an array per se
664 } else if( func->GetNdata() == 0 ) {
665 // Empty fixed-size array is an invalid argument
666 return -2;
667 }
668 }
669 fVarDef.emplace_back(def.type, func, def.code);
670 // Expand the function argument in case it is a recursive definition
671 name = def.func; name += func->GetExpFormula(); name += ")";
672 // Treat the kFormula-type functions as scalars, even though they might
673 // cause this formula to have GetNdata() == 0 if they operate on an
674 // empty array. kVarFormula however passes the array type right through.
675 if( def.type == kVarFormula ) {
676 SetBit( kArrayFormula, func->IsArray() );
677 SetBit( kVarArray, func->IsVarArray() );
678 }
679 return fVarDef.size()-1;
680 }
681 else if( !def.form && name == def.func ) {
682 fVarDef.emplace_back(def.type, nullptr, def.code);
683 return fVarDef.size()-1;
684 }
685 }
686 return -1;
687}
688
689
690//_____________________________________________________________________________
692{
693 // Evaluate this formula
694
695 return EvalInstance(0);
696}
697
698//_____________________________________________________________________________
700{
701 // Evaluate this formula
702
703 if( IsError() )
704 return kBig;
705 if( instance < 0 || (!IsArray() && instance != 0) ) {
707 return kBig;
708 }
709
711 Double_t y = EvalInstanceUnchecked( instance );
712
713 if( IsInvalid() )
714 return kBig;
715
716 return y;
717}
718
719//_____________________________________________________________________________
721{
722 // Return minimum of sizes of all referenced arrays
723
724 Int_t ndata = TestBit(kArrayFormula) ? kMaxInt : 1; // 1 = kFuncOfVarArray
725 for( vector<FVarDef_t>::size_type i = 0; ndata > 0 && i < fVarDef.size();
726 ++i ) {
727 const FVarDef_t& def = fVarDef[i];
728 switch( def.type ) {
729 case kArray:
730 {
731 const auto* pvar = static_cast<const THaVar*>(def.obj);
732 assert( pvar );
733 assert( pvar->IsArray() );
734 assert( pvar->GetNdim() > 0 );
735 ndata = TMath::Min( ndata, pvar->GetLen() );
736 }
737 break;
738 case kFormula:
739 case kVarFormula:
740 {
741 const auto* func = static_cast<THaFormula*>(def.obj);
742 assert( func );
743 Int_t nfunc = func->GetNdata();
744 if( def.type == kFormula && nfunc == 0 )
745 ndata = 0;
746 else if( def.type == kVarFormula )
747 ndata = TMath::Min( ndata, nfunc );
748 }
749 break;
750 default:
751 break;
752 }
753 }
754 return ndata;
755}
756
757//_____________________________________________________________________________
759{
760 // Get number of available instances of this formula
761
762 if( !IsArray() && !TestBit(kFuncOfVarArray) )
763 return 1;
764
765 return GetNdataUnchecked();
766}
767
768//_____________________________________________________________________________
769void THaFormula::Print( Option_t* option ) const
770{
771 // Print this formula to stdout
772 // Options:
773 // "BRIEF" -- short, one line
774 // "FULL" -- full, multiple lines
775
776 if( !strcmp( option, kPRINTFULL ))
778 else
780}
781
782//_____________________________________________________________________________
784{
785 // Store/remove this formula in/from ROOT's list of functions
786
787 if( gROOT ) {
789 const char* name = GetName();
790 TCollection* flist = gROOT->GetListOfFunctions();
791 TObject* old = flist->FindObject(name);
792 if( !add || IsError() ) {
793 if( old == this )
794 flist->Remove(old);
795 } else {
796 if( old )
797 flist->Remove(old);
798 if( !TestBit(kNotGlobal) ) {
799 flist->Add(this);
800 }
801 }
802 }
803}
804
805//_____________________________________________________________________________
806
int Int_t
unsigned int UInt_t
const Data_t kBig
Definition DataType.h:15
bool Bool_t
const Ssiz_t kNPOS
const Int_t kMaxInt
int Ssiz_t
const ULong64_t kMaxULong64
double Double_t
const char Option_t
Option_t Option_t option
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
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 UChar_t len
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
char name[80]
static Int_t NumberOfSetBits(UInt_t v)
EFuncCode
@ kMax
@ kSum
@ kMedian
@ kIteration
@ kStdDev
@ kNumSetBits
@ kMin
@ kGeoMean
@ kMean
@ kLength
static Int_t CheckBlacklistedNames(const TString &name)
static const char *const here
Definition THaVar.cxx:64
R__EXTERN TVirtualMutex * gROOTMutex
#define gROOT
#define R__LOCKGUARD2(mutex)
Short_t GetAction(Int_t code) const
void ResetAllBits(Bool_t value=kFALSE)
Bool_t TestBitNumber(UInt_t bitnumber) const
void SetBitNumber(UInt_t bitnumber, Bool_t value=kTRUE)
virtual TObject * Remove(TObject *obj)=0
virtual void Add(TObject *obj)=0
TObject * FindObject(const char *name) const override
void Print(Option_t *option="") const override
TFormula & operator=(const TFormula &rhs)
Int_t Compile(const char *expression="")
Bool_t IsArray() const
Bool_t IsError() const
Int_t GetNdim() const
const char * GetName() const
THaCut * FindCut(const char *name) const
Definition THaCutList.h:57
EVariableType type
Definition THaFormula.h:76
FVarDef_t(EVariableType t, void *p, Int_t i)
Definition THaFormula.h:79
FVarDef_t & operator=(const FVarDef_t &rhs)
virtual Int_t GetNdata() const
virtual void Print(Option_t *option="") const
Int_t Init(const char *name, const char *expression)
Int_t GetNdataUnchecked() const
virtual Int_t DefinedVariable(TString &variable, Int_t &action)
static const Option_t *const kPRINTBRIEF
Definition THaFormula.h:25
virtual Int_t Compile(const char *expression="")
virtual Bool_t IsString(Int_t oper) const
virtual void RegisterFormula(Bool_t add=true)
Bool_t IsInvalid() const
Definition THaFormula.h:54
virtual Int_t DefinedCutWithType(TString &variable, EVariableType type)
virtual Double_t Eval()
virtual Int_t DefinedCut(TString &variable)
virtual Double_t EvalInstance(Int_t instance)
std::vector< FVarDef_t > fVarDef
Definition THaFormula.h:86
Bool_t IsError() const
Definition THaFormula.h:53
virtual Double_t DefinedValue(Int_t i)
virtual Bool_t IsArray() const
Definition THaFormula.h:51
Double_t EvalInstanceUnchecked(Int_t instance)
Definition THaFormula.h:102
@ kFuncOfVarArray
Definition THaFormula.h:66
const THaVarList * fVarList
Definition THaFormula.h:87
const THaCutList * fCutList
Definition THaFormula.h:88
Int_t fInstance
Definition THaFormula.h:89
virtual ~THaFormula()
virtual Int_t DefinedSpecialFunction(TString &name)
virtual Int_t DefinedGlobalVariable(TString &variable)
virtual Int_t DefinedGlobalVariableExtraList(TString &variable, const THaVarList *extralist)
THaFormula & operator=(const THaFormula &rhs)
static const Option_t *const kPRINTFULL
Definition THaFormula.h:24
virtual char * DefinedString(Int_t i)
virtual THaVar * Find(const char *name) const
Bool_t IsArray() const
Definition THaVar.h:62
Int_t Index(const char *subscripts) const
Definition THaVar.cxx:193
Bool_t IsVarArray() const
Definition THaVar.h:69
Int_t GetNdim() const
Definition THaVar.h:40
const void * GetValuePointer() const
Definition THaVar.h:51
virtual void SetTitle(const char *title="")
const char * GetName() const override
void Print(Option_t *option="") const override
TString fName
virtual void SetName(const char *name)
void SetBit(UInt_t f)
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
virtual void Error(const char *method, const char *msgfmt,...) const
void ResetBit(UInt_t f)
Ssiz_t Length() const
const char * Data() const
TString & Chop()
Bool_t IsWhitespace() const
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
TString & ReplaceAll(const char *s1, const char *s2)
unsigned long long ULong64_t
Double_t y[n]
const Int_t n
Double_t Min(Double_t a, Double_t b)
Double_t RMS(Iterator first, Iterator last)
Double_t Median(Long64_t n, const T *a, const Double_t *w=nullptr, Long64_t *work=nullptr)
Double_t GeomMean(Iterator first, Iterator last)
Double_t Mean(Iterator first, Iterator last)
STL namespace.
v
ClassImp(TPyArg)
const Int_t kMAXFOUND