Common Analysis Framework » QFRAMEWORK » TQObservable

class TQObservable: public TNamed


 TQObservable

 The TQObservable class acts on a TQSample with the aim of extracting
 numerical data from a TTree inside the event loop.

 TQObservable itself is an abstract base class that is inherited from by
 different observable variants. The most notable ones are

 - TQTreeFormulaObservable: A wrapper around TTreeFormula, capable of
 evaluating arithmetic expressions on the TTree branches.

 - TQConstObservable: A trivial observable that has the same value for
 all events of a tree. While generally being of limited use, the existence
 of this observable type allows fast and convenient definition of cuts by
 providing an extremely fast way of implementing trivial cut or weight
 expressions.

 - TQMVATreeObservable: A more elaborate observable type that acts as a
 wrapper around a TMVA::Reader object and is capable of evaluating
 multivariate methods on the fly while only requiring a filepath to a
 valid TMVA weights.xml file as input.

 - TQMultiTreeObservable: A wrapper for an expression that consists of only
 constant values and names of other TQObservables, where the latter
 are required to be wrapped in brackets [...]. This observable type is
 required to cut on values provided by TQMVATreeObservable, but can also
 be used to combine outputs from different MVA methods or custom
 observable types.

 While any type of TQObservable may also be instantiated directly, it is
 generally advisable to use the factory functions

 TQObservable::getTreeObservable(name,expression): creates a
 TQObservable with the given name and expression. The type of
 observable created depends on the expression and may be indicated by a
 prefix if necessary (see function documentation of
 TQObservable::createObservable for details). The observable is
 automatically added to the observable database and is only created if
 necessary - if an observable with the same name and expression already
 exists, it is retrieved instead. If an observable with the same name, but
 a different expression exists, an error message is generated.

 TQObservable::getTreeObservable(expression): same as above, but the
 expression is also used as the name.

 The pure getter functions TQObservable::getTreeObservableByName(name)
 and TQObservable::getTreeObservableByExpression(expression) do not
 create observables, but only retrieve them from the central database.

 Defining Custom Observable Classes

 The TQObservable class can and should be used to define custom observable
 classes to implement a more complex behaviour. In order to have your custom
 observable class operate as expected, you need to implement the following
 methods:

 double getValue() const;
 This method returns the value of this observable. When implementing this
 method, please bear in mind that it will be called once for each event
 in all trees, possibly various times at each cut step. Try to implement
 this method as efficient as possible, even if this means spending more
 computation time in the other functions.

 bool initializeSelf();
 This method is supposed to initialize your observable in such a way that
 your getValue can safely be called. When this method is called, the
 values of the fields fSample, and fToken are already set and
 initialized, and you may access them in any way you seem fitting.
 If all went well, this method should return true. If an error occurred,
 you need to undo any changes performed previously and return false.

 bool finalizeSelf();
 This method is supposed to finalize your observable in such a way that
 all changes performed by initialzeSelf are undone and all data members
 allocated by initializeSelf are properly freed. The values of the
 fields fSample and fToken are still set and valid, and you
 may access them in any way you seem fitting. If all went well, this
 method should return true. In the unlikely case of an error, this method
 should return false.

 TObjArray* getBranchNames(TQSample* s) const;
 This method is supposed to return a TObjArray containing TObjStrings,
 each representing the name of a branch of a tree. The argument with
 which this function is called is a pointer to a TQSample object which
 contains the tree and possibly meta-information in the form of tags. A
 typical implementation of this method may look like this:
 TObjArray* getBranchNames(TQSample* s) const {
 return TQUtils::getBranchNames(this->getCompiledExpression(s));
 }
 Here, the called to TQObservable::getCompiledExpression produces the
 final expression string, taking into account all meta-information of the
 sample, and TQUtils::getBranchNames parses the expression to extract all
 literal strings that may represent branch names.

 Depending on the complexity of your observable class, it may be required to
 implement
 void setExpression(const TString&) as well. If you
 re-implement this method, you should call it in your constructor to ensure
 consistent behaviour of your class.

 For examples on how an actual implementation might look like, you may want
 to browse the source code of any of the aforementioned observable types.

 You may also choose to modify TQObservable::createObservable to be
 capable of creating your own observable type. For this purpose, you might
 choose a prefix string to help identifying your observable type.

 When you have implemented and created an instance of your class, you may use
 it as follows:
 - call TQObservable::printObservables() to see if it's in the database
 - add your observable to a cut by either of the following methods:
 - call TQCut::setCutObservableName or TQCut::setWeightObservableName
 with the name of your observable
 - call TQCut::setCutObservableName or TQCut::setWeightObservableName
 with the name of your observable
 - provide the name at construction time when creating via
 TQFolder::importFolder by setting the tags .cutObservableName or
 .weightObservableName of the folder in question
 - choose the name of your observable as CUTNAME_cut or CUTNAME_weight
 in the first place, where CUTNAME is the name of the cut in
 question
 - add your observable to a histogram, eventlist or anything else by
 providing the name or expression of the cut as an argument to the
 associated analysis job

 Of course, if you have modified TQObservable::createObservable to
 support your observable type, you don't have to add the observable yourself
 but can instead rely on automatic creation of your observable at the time it
 is requested by the analysis chain. You may, however, want to check if
 everything works as expected by calling
 TQObservable::printObservables()
 You may be surpised that the number of observables in the database is
 small. This is because most observables are only created when they are first
 requested. Usually, this happens when an analysis job is configured or when
 a cut is assigned to a sample visitor. In the case of the cut, however, you
 may force premature creation of the observables by calling
 TQCut::setupObservables() on the instance in question.


Function Members (Methods)

 
    This is an abstract class, constructors will not be documented.
    Look at the header to check for available constructors.

public:
virtual~TQObservable()
voidTObject::AbstractMethod(const char* method) const
static booladdObservable(TQObservable* obs)
static booladdObservable(TQObservable* obs, const TString& name)
static voidallowErrorMessages(bool val)
virtual voidTObject::AppendPad(Option_t* option = "")
virtual voidTObject::Browse(TBrowser* b)
ULong_tTObject::CheckedHash()
static TClass*Class()
virtual const char*TObject::ClassName() const
virtual voidTNamed::Clear(Option_t* option = "")
static voidclearAll()
virtual TObject*TNamed::Clone(const char* newname = "") const
virtual Int_tTNamed::Compare(const TObject* obj) const
static TStringcompileExpression(const TString& input, TQTaggable* tags, bool replaceBools = true)
virtual voidTNamed::Copy(TObject& named) const
virtual voidTObject::Delete(Option_t* option = "")MENU
virtual Int_tTObject::DistancetoPrimitive(Int_t px, Int_t py)
virtual voidTObject::Draw(Option_t* option = "")
virtual voidTObject::DrawClass() constMENU
virtual TObject*TObject::DrawClone(Option_t* option = "") constMENU
virtual voidTObject::Dump() constMENU
virtual voidTObject::Error(const char* method, const char* msgfmt,...) const
virtual voidTObject::Execute(const char* method, const char* params, Int_t* error = 0)
virtual voidTObject::Execute(TMethod* method, TObjArray* params, Int_t* error = 0)
virtual voidTObject::ExecuteEvent(Int_t event, Int_t px, Int_t py)
virtual voidTObject::Fatal(const char* method, const char* msgfmt,...) const
virtual voidTNamed::FillBuffer(char*& buffer)
virtual boolfinalize()
virtual TObject*TObject::FindObject(const char* name) const
virtual TObject*TObject::FindObject(const TObject* obj) const
virtual TStringgetActiveExpression() const
virtual TObjArray*getBranchNames() const
virtual TQObservable*getClone() const
virtual TStringgetCompiledExpression(TQTaggable* tags) const
virtual Long64_tgetCurrentEntry() const
virtual Option_t*TObject::GetDrawOption() const
static Longptr_tTObject::GetDtorOnly()
virtual const TString&getExpression() const
virtual const char*TObject::GetIconName() const
static TQObservable::Manager&getManager()
TStringgetName() const
virtual const char*TNamed::GetName() const
const TString&getNameConst() const
virtual intgetNevaluations() const
virtual char*TObject::GetObjectInfo(Int_t px, Int_t py) const
static Bool_tTObject::GetObjectStat()
static TQObservable*getObservable(const TString& exprname, TQTaggable* tags)
virtual TQObservable::ObservableTypegetObservableType() const
virtual Option_t*TObject::GetOption() const
virtual const char*TNamed::GetTitle() const
virtual UInt_tTObject::GetUniqueID() const
virtual doublegetValue() const
virtual doublegetValueAt(int index) const
virtual Bool_tTObject::HandleTimer(TTimer* timer)
virtual boolhasExpression() const
virtual ULong_tTNamed::Hash() const
Bool_tTObject::HasInconsistentHash() const
virtual voidTObject::Info(const char* method, const char* msgfmt,...) const
virtual Bool_tTObject::InheritsFrom(const char* classname) const
virtual Bool_tTObject::InheritsFrom(const TClass* cl) const
virtual boolinitialize(TQSample* sample)
virtual voidTObject::Inspect() constMENU
voidTObject::InvertBit(UInt_t f)
virtual TClass*IsA() const
Bool_tTObject::IsDestructed() const
virtual Bool_tTObject::IsEqual(const TObject* obj) const
virtual Bool_tTObject::IsFolder() const
boolisInitialized() const
Bool_tTObject::IsOnHeap() const
virtual boolisPrefixRequired() const
virtual boolisSetup() const
virtual Bool_tTNamed::IsSortable() const
Bool_tTObject::IsZombie() const
virtual voidTNamed::ls(Option_t* option = "") const
static TStringmakeObservableName(const TString& name)
static boolmatchExpressions(const TString& ex1, const TString& ex2, bool requirePrefix = false)
voidTObject::MayNotUse(const char* method) const
virtual Bool_tTObject::Notify()
voidTObject::Obsolete(const char* method, const char* asOfVers, const char* removedFromVers) const
voidTObject::operator delete(void* ptr)
voidTObject::operator delete(void* ptr, void* vp)
voidTObject::operator delete[](void* ptr)
voidTObject::operator delete[](void* ptr, void* vp)
void*TObject::operator new(size_t sz)
void*TObject::operator new(size_t sz, void* vp)
void*TObject::operator new[](size_t sz)
void*TObject::operator new[](size_t sz, void* vp)
TQObservable&operator=(const TQObservable&)
virtual voidTObject::Paint(Option_t* option = "")
virtual voidTObject::Pop()
virtual voidprint() const
virtual voidTNamed::Print(Option_t* option = "") const
static voidprintObservables(const TString& filter = "*")
virtual Int_tTObject::Read(const char* name)
virtual voidTObject::RecursiveRemove(TObject* obj)
static TStringreplaceBools(TString expression)
voidTObject::ResetBit(UInt_t f)
virtual voidTObject::SaveAs(const char* filename = "", Option_t* option = "") constMENU
virtual voidTObject::SavePrimitive(ostream& out, Option_t* option = "")
voidTObject::SetBit(UInt_t f)
voidTObject::SetBit(UInt_t f, Bool_t set)
virtual voidTObject::SetDrawOption(Option_t* option = "")MENU
static voidTObject::SetDtorOnly(void* obj)
virtual voidsetExpression(const TString& expr)
voidsetName(const TString& name)
virtual voidTNamed::SetName(const char* name)MENU
virtual voidTNamed::SetNameTitle(const char* name, const char* title)
static voidTObject::SetObjectStat(Bool_t stat)
virtual voidTNamed::SetTitle(const char* title = "")MENU
virtual voidTObject::SetUniqueID(UInt_t uid)
virtual voidShowMembers(TMemberInspector& insp) const
virtual Int_tTNamed::Sizeof() const
virtual voidStreamer(TBuffer&)
voidStreamerNVirtual(TBuffer& ClassDef_StreamerNVirtual_b)
virtual voidTObject::SysError(const char* method, const char* msgfmt,...) const
Bool_tTObject::TestBit(UInt_t f) const
Int_tTObject::TestBits(UInt_t f) const
TQObservable()
TQObservable(const TString& expression)
TQObservable(const TQObservable&)
virtual TQObservable*tryCreateInstanceVirtual(const TString& expr) const
static TStringunreplaceBools(TString expression)
virtual voidTObject::UseCurrentStyle()
virtual voidTObject::Warning(const char* method, const char* msgfmt,...) const
virtual Int_tTObject::Write(const char* name = 0, Int_t option = 0, Int_t bufsize = 0)
virtual Int_tTObject::Write(const char* name = 0, Int_t option = 0, Int_t bufsize = 0) const
protected:
virtual voidTObject::DoError(int level, const char* location, const char* fmt, va_list va) const
virtual boolfinalizeSelf()
virtual boolhasFactory() const
virtual boolinitializeSelf()
voidTObject::MakeZombie()
private:
virtual Bool_tCheckTObjectHashConsistency() const

Data Members

public:
static TObject::(anonymous)TObject::kBitMask
static TObject::EStatusBitsTObject::kCanDelete
static TObject::EStatusBitsTObject::kCannotPick
static TObject::EStatusBitsTObject::kHasUUID
static TObject::(anonymous)TObject::kInconsistent
static TObject::EStatusBitsTObject::kInvalidObject
static TObject::(anonymous)TObject::kIsOnHeap
static TObject::EStatusBitsTObject::kIsReferenced
static TObject::EStatusBitsTObject::kMustCleanup
static TObject::EStatusBitsTObject::kNoContextMenu
static TObject::(anonymous)TObject::kNotDeleted
static TObject::EDeprecatedStatusBitsTObject::kObjInCanvas
static TObject::(anonymous)TObject::kOverwrite
static TObject::(anonymous)TObject::kSingleKey
static TObject::(anonymous)TObject::kWriteDelete
static TObject::(anonymous)TObject::kZombie
static TQObservable::Managermanager
static TQObservable::ObservableTypescalar
static TQObservable::ObservableTypeunknown
static TQObservable::ObservableTypevector
protected:
boolfIsInitialized
boolfIsManaged
TStringTNamed::fNameobject identifier
TQSample*fSample!
TStringTNamed::fTitleobject title
static boolgAllowErrorMessages
static TObject::(anonymous)TObject::kOnlyPrepStep
private:
static boolgIgnoreExpressionMismatch

Class Charts

Inheritance Chart:
TObject
TNamed
TQObservable
TQConstObservable
TQFilterObservable
TQHistogramObservable<TH1>
TQHistogramObservable<TH2>
TQHistogramObservable<TH3>
TQMVAObservable
TQMultiObservable
TQSampleNormalizationObservable
TQTreeObservable
TQEventIndexObservable
 [more...]

Function documentation

void clearAll()
TQObservable()
TQObservable(const TString& expression)
 constructor setting the name and expression
bool addObservable(TQObservable* obs)
 add an existing tree observable to the pool
bool addObservable(TQObservable* obs, const TString& name)
 add an existing tree observable to the pool
 giving it a new name
void printObservables(const TString& filter = "*")
 retrieve a TQObservable by expression
 create it if necessary
bool matchExpressions(const TString& ex1, const TString& ex2, bool requirePrefix = false)
TQObservable* getObservable(const TString& exprname, TQTaggable* tags)
 retrieve an incarnation of a TQObservable
 the observable is identified by its name 'expression'
 also, the incarnation of this observable needs to match the compiled expression
 retrieved by compiling expression using the tags provided
bool hasFactory() const
TString makeObservableName(const TString& name)
 convert a string into a valid observable name
bool initialize(TQSample* sample)
 initialize this observable
bool isInitialized() const
 return true if this observable is initialized, false otherwise
bool finalize()
 finalize this observable, return the tree token
~TQObservable()
 standard destructor
void print() const
 print the contents of this observable and its associated branches
TString getCompiledExpression(TQTaggable* tags) const
 retrieve the expression string
TString replaceBools(TString expression)
TString unreplaceBools(TString expression)
TString compileExpression(const TString& input, TQTaggable* tags, bool replaceBools = true)
 compile an expression, evaluating all evaluable expressions beforehand
 the following examples document the behaviour of this function:

 - newlines and tabs, and double spaces are removed, e.g.
 "Mjj > 600."
 becomes
 "Mjj > 600."

 - placeholders are replaced by their respective values based on the
 instance of TQTaggable provided as second argument and all its base
 objects, e.g.
 "$(bTagWeightName)"
 becomes
 "bTagEventWeight"
 if the TQTaggable object or any of its parent objects carries the tag
 bTagWeightName = bTagEventWeight

 - boolean strings are replaced by their numerical equivalents, i.e.
 "true" is replaced by "1."
 "false" is replaced by "0."

 - inline conditionals in curly braces are evaluated if possible, e.g.
 "{ $(channel) == 'ee' ? true : false }"
 becomes "1." if the tag "channel" has the value "ee", false otherwise.
 if evaluation is not possible because the conditional contains
 unresolved strings, the curly braces are replaced by round ones.

 - single quotes are replaced by double quotes, e.g.
 "{ $(channel) == "ee" ? true : false }"
 is identical to
 "{ $(channel) == 'ee' ? true : false }"

 if the compilation fails and the result still contains unresolved
 variables (or any dollar signs, to that extend) an error is thrown.

TString getName() const
 retrieve the name of this object
void setName(const TString& name)
 set the name of this object
const TString& getNameConst() const
 retrieve a const reference to the name of this object
bool isSetup() const
 return true if this observable is setup and ready to initialize
 false otherwise
void allowErrorMessages(bool val)
const TString& getExpression() const
 retrieve the expression associated with this observable
bool hasExpression() const
 check if this observable type knows expressions (default false)
TQObservable* getClone() const
 retrieve a clone of this observable
void setExpression(const TString& expr)
 set the expression to a given string
 not implemented for the base class
TQObservable* tryCreateInstanceVirtual(const TString& expr) const
 this is the factory function for each observable type
 in the default implementation, this always returns NULL
 because there is no fully general observable factory
TString getActiveExpression() const
 retrieve the expression string
double getValueAt(int index) const
 retrieve the value at the given index
bool initializeSelf()
bool finalizeSelf()
Manager& getManager()
Long64_t getCurrentEntry() const
bool isPrefixRequired() const
{return false;}
TQObservable()
double getValue() const
int getNevaluations() const
{return 1;}
TQObservable::ObservableType getObservableType() const
{return TQObservable::ObservableType::scalar;}
TObjArray* getBranchNames() const