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.
virtual | ~TQObservable() |
void | TObject::AbstractMethod(const char* method) const |
static bool | addObservable(TQObservable* obs) |
static bool | addObservable(TQObservable* obs, const TString& name) |
static void | allowErrorMessages(bool val) |
virtual void | TObject::AppendPad(Option_t* option = "") |
virtual void | TObject::Browse(TBrowser* b) |
ULong_t | TObject::CheckedHash() |
static TClass* | Class() |
virtual const char* | TObject::ClassName() const |
virtual void | TNamed::Clear(Option_t* option = "") |
static void | clearAll() |
virtual TObject* | TNamed::Clone(const char* newname = "") const |
virtual Int_t | TNamed::Compare(const TObject* obj) const |
static TString | compileExpression(const TString& input, TQTaggable* tags, bool replaceBools = true) |
virtual void | TNamed::Copy(TObject& named) const |
virtual void | TObject::Delete(Option_t* option = "")MENU |
virtual Int_t | TObject::DistancetoPrimitive(Int_t px, Int_t py) |
virtual void | TObject::Draw(Option_t* option = "") |
virtual void | TObject::DrawClass() constMENU |
virtual TObject* | TObject::DrawClone(Option_t* option = "") constMENU |
virtual void | TObject::Dump() constMENU |
virtual void | TObject::Error(const char* method, const char* msgfmt,...) const |
virtual void | TObject::Execute(const char* method, const char* params, Int_t* error = 0) |
virtual void | TObject::Execute(TMethod* method, TObjArray* params, Int_t* error = 0) |
virtual void | TObject::ExecuteEvent(Int_t event, Int_t px, Int_t py) |
virtual void | TObject::Fatal(const char* method, const char* msgfmt,...) const |
virtual void | TNamed::FillBuffer(char*& buffer) |
virtual bool | finalize() |
virtual TObject* | TObject::FindObject(const char* name) const |
virtual TObject* | TObject::FindObject(const TObject* obj) const |
virtual TString | getActiveExpression() const |
virtual TObjArray* | getBranchNames() const |
virtual TQObservable* | getClone() const |
virtual TString | getCompiledExpression(TQTaggable* tags) const |
virtual Long64_t | getCurrentEntry() const |
virtual Option_t* | TObject::GetDrawOption() const |
static Longptr_t | TObject::GetDtorOnly() |
virtual const TString& | getExpression() const |
virtual const char* | TObject::GetIconName() const |
static TQObservable::Manager& | getManager() |
TString | getName() const |
virtual const char* | TNamed::GetName() const |
const TString& | getNameConst() const |
virtual int | getNevaluations() const |
virtual char* | TObject::GetObjectInfo(Int_t px, Int_t py) const |
static Bool_t | TObject::GetObjectStat() |
static TQObservable* | getObservable(const TString& exprname, TQTaggable* tags) |
virtual TQObservable::ObservableType | getObservableType() const |
virtual Option_t* | TObject::GetOption() const |
virtual const char* | TNamed::GetTitle() const |
virtual UInt_t | TObject::GetUniqueID() const |
virtual double | getValue() const |
virtual double | getValueAt(int index) const |
virtual Bool_t | TObject::HandleTimer(TTimer* timer) |
virtual bool | hasExpression() const |
virtual ULong_t | TNamed::Hash() const |
Bool_t | TObject::HasInconsistentHash() const |
virtual void | TObject::Info(const char* method, const char* msgfmt,...) const |
virtual Bool_t | TObject::InheritsFrom(const char* classname) const |
virtual Bool_t | TObject::InheritsFrom(const TClass* cl) const |
virtual bool | initialize(TQSample* sample) |
virtual void | TObject::Inspect() constMENU |
void | TObject::InvertBit(UInt_t f) |
virtual TClass* | IsA() const |
Bool_t | TObject::IsDestructed() const |
virtual Bool_t | TObject::IsEqual(const TObject* obj) const |
virtual Bool_t | TObject::IsFolder() const |
bool | isInitialized() const |
Bool_t | TObject::IsOnHeap() const |
virtual bool | isPrefixRequired() const |
virtual bool | isSetup() const |
virtual Bool_t | TNamed::IsSortable() const |
Bool_t | TObject::IsZombie() const |
virtual void | TNamed::ls(Option_t* option = "") const |
static TString | makeObservableName(const TString& name) |
static bool | matchExpressions(const TString& ex1, const TString& ex2, bool requirePrefix = false) |
void | TObject::MayNotUse(const char* method) const |
virtual Bool_t | TObject::Notify() |
void | TObject::Obsolete(const char* method, const char* asOfVers, const char* removedFromVers) const |
void | TObject::operator delete(void* ptr) |
void | TObject::operator delete(void* ptr, void* vp) |
void | TObject::operator delete[](void* ptr) |
void | TObject::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 void | TObject::Paint(Option_t* option = "") |
virtual void | TObject::Pop() |
virtual void | print() const |
virtual void | TNamed::Print(Option_t* option = "") const |
static void | printObservables(const TString& filter = "*") |
virtual Int_t | TObject::Read(const char* name) |
virtual void | TObject::RecursiveRemove(TObject* obj) |
static TString | replaceBools(TString expression) |
void | TObject::ResetBit(UInt_t f) |
virtual void | TObject::SaveAs(const char* filename = "", Option_t* option = "") constMENU |
virtual void | TObject::SavePrimitive(ostream& out, Option_t* option = "") |
void | TObject::SetBit(UInt_t f) |
void | TObject::SetBit(UInt_t f, Bool_t set) |
virtual void | TObject::SetDrawOption(Option_t* option = "")MENU |
static void | TObject::SetDtorOnly(void* obj) |
virtual void | setExpression(const TString& expr) |
void | setName(const TString& name) |
virtual void | TNamed::SetName(const char* name)MENU |
virtual void | TNamed::SetNameTitle(const char* name, const char* title) |
static void | TObject::SetObjectStat(Bool_t stat) |
virtual void | TNamed::SetTitle(const char* title = "")MENU |
virtual void | TObject::SetUniqueID(UInt_t uid) |
virtual void | ShowMembers(TMemberInspector& insp) const |
virtual Int_t | TNamed::Sizeof() const |
virtual void | Streamer(TBuffer&) |
void | StreamerNVirtual(TBuffer& ClassDef_StreamerNVirtual_b) |
virtual void | TObject::SysError(const char* method, const char* msgfmt,...) const |
Bool_t | TObject::TestBit(UInt_t f) const |
Int_t | TObject::TestBits(UInt_t f) const |
TQObservable() | |
TQObservable(const TString& expression) | |
TQObservable(const TQObservable&) | |
virtual TQObservable* | tryCreateInstanceVirtual(const TString& expr) const |
static TString | unreplaceBools(TString expression) |
virtual void | TObject::UseCurrentStyle() |
virtual void | TObject::Warning(const char* method, const char* msgfmt,...) const |
virtual Int_t | TObject::Write(const char* name = 0, Int_t option = 0, Int_t bufsize = 0) |
virtual Int_t | TObject::Write(const char* name = 0, Int_t option = 0, Int_t bufsize = 0) const |
virtual void | TObject::DoError(int level, const char* location, const char* fmt, va_list va) const |
virtual bool | finalizeSelf() |
virtual bool | hasFactory() const |
virtual bool | initializeSelf() |
void | TObject::MakeZombie() |
virtual Bool_t | CheckTObjectHashConsistency() const |
static TObject::(anonymous) | TObject::kBitMask | |
static TObject::EStatusBits | TObject::kCanDelete | |
static TObject::EStatusBits | TObject::kCannotPick | |
static TObject::EStatusBits | TObject::kHasUUID | |
static TObject::(anonymous) | TObject::kInconsistent | |
static TObject::EStatusBits | TObject::kInvalidObject | |
static TObject::(anonymous) | TObject::kIsOnHeap | |
static TObject::EStatusBits | TObject::kIsReferenced | |
static TObject::EStatusBits | TObject::kMustCleanup | |
static TObject::EStatusBits | TObject::kNoContextMenu | |
static TObject::(anonymous) | TObject::kNotDeleted | |
static TObject::EDeprecatedStatusBits | TObject::kObjInCanvas | |
static TObject::(anonymous) | TObject::kOverwrite | |
static TObject::(anonymous) | TObject::kSingleKey | |
static TObject::(anonymous) | TObject::kWriteDelete | |
static TObject::(anonymous) | TObject::kZombie | |
static TQObservable::Manager | manager | |
static TQObservable::ObservableType | scalar | |
static TQObservable::ObservableType | unknown | |
static TQObservable::ObservableType | vector |
bool | fIsInitialized | |
bool | fIsManaged | |
TString | TNamed::fName | object identifier |
TQSample* | fSample | ! |
TString | TNamed::fTitle | object title |
static bool | gAllowErrorMessages | |
static TObject::(anonymous) | TObject::kOnlyPrepStep |
add an existing tree observable to the pool giving it a new name
retrieve a TQObservable by expression create it if necessary
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
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.
return true if this observable is setup and ready to initialize false otherwise
set the expression to a given string not implemented for the base class
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
{return TQObservable::ObservableType::scalar;}