#ifndef __TMrbSubevent_h__
#define __TMrbSubevent_h__
namespace std {} using namespace std;
#include <cstdlib>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <fstream>
#include "Rtypes.h"
#include "TSystem.h"
#include "TObject.h"
#include "TNamed.h"
#include "TString.h"
#include "TMrbLofNamedX.h"
#include "TMrbTemplate.h"
#include "TMrbEvent.h"
#include "TMrbModule.h"
#include "TMrbCamacModule.h"
#include "TMrbVMEModule.h"
class TMrbEvent;
class TMrbModule;
class TMrbModuleChannel;
class TMrbSubevent : public TNamed {
public:
TMrbSubevent() {};
TMrbSubevent(const Char_t * SevtName, const Char_t * SevtTitle = "", Int_t Crate = -1);
~TMrbSubevent() {
fLofParams.Delete();
};
TMrbSubevent(const TMrbSubevent &) : TNamed() {};
inline void AddEvent(TMrbEvent * Evt) {
fLofEvents.Add(Evt);
fNofEvents++;
};
inline TMrbEvent * FindEvent(const Char_t * EvtName) const {
return ((TMrbEvent *) fLofEvents.FindObject(EvtName));
};
Bool_t AddParam(TMrbModuleChannel * Param);
inline TMrbModuleChannel * FindParam(const Char_t * ParamName) const {
return((TMrbModuleChannel *) fLofParams.FindObject(ParamName));
};
inline Bool_t AddModule(TMrbModule * Module) {
fLofModules.Add(Module);
fNofModules++;
return(kTRUE);
};
inline TMrbModule * NextModule(TMrbModule * After = NULL) const {
return((After == NULL) ? (TMrbModule *) fLofModules.First() : (TMrbModule *) fLofModules.After((TObject *) After));
};
inline TMrbModule * FindModule(const Char_t * ModuleName) const {
return ((TMrbModule *) fLofModules.FindObject(ModuleName));
};
TMrbModule * FindModuleByID(TMrbConfig::EMrbModuleID ModuleID, TMrbModule * After = NULL) const;
inline TMrbModule * FindModuleByID(TMrbNamedX * ModuleID, TMrbModule * After = NULL) const {
return(this->FindModuleByID((TMrbConfig::EMrbModuleID) ModuleID->GetIndex(), After));
};
TMrbModule * FindModuleByType(UInt_t ModuleType, TMrbModule * After = NULL) const;
inline TMrbModule * FindModuleByType(TMrbNamedX * ModuleType, TMrbModule * After = NULL) const {
return(this->FindModuleByType(ModuleType->GetIndex(), After));
};
TMrbModule * FindModuleBySerial(Int_t ModuleSerial) const;
Bool_t Use(const Char_t * ModuleName, const Char_t * Assignment, Bool_t BookHistos = kTRUE);
inline Bool_t Use(const Char_t * Assignment, Bool_t BookHistos = kTRUE) { return(Use(NULL, Assignment, BookHistos)); };
inline Int_t GetSerial() const { return(fSerial); };
Bool_t Set(const Char_t * ParamName, const Char_t * RegName, Int_t Value);
Bool_t Set(const Char_t * ParamName, Int_t RegIndex, Int_t Value);
Int_t Get(const Char_t * ParamName, const Char_t * RegName) const;
Int_t Get(const Char_t * ParamName, Int_t RegIndex) const;
inline Int_t GetNofEvents() const { return(fNofEvents); };
inline Int_t GetNofModules() const { return(fNofModules); };
inline Int_t GetNofParams() const { return(fNofParams); };
inline Int_t GetNofShorts() const { return(fNofShorts); };
inline UInt_t GetLegalDataTypes() const { return(fLegalDataTypes); };
inline Int_t GetCrate() const { return(fCrate); };
inline UInt_t GetType() const { return(fSevtType); };
inline UInt_t GetSubtype() const { return(fSevtSubtype); };
inline const Char_t * GetDescr() { return(fSevtDescr.Data()); };
virtual Bool_t MakeReadoutCode(ofstream & RdoStrm, TMrbConfig::EMrbReadoutTag TagIndex, TMrbTemplate & Template, const Char_t * Prefix = NULL) { return(kFALSE); };
Bool_t MakeAnalyzeCode(ofstream & AnaStrm, TMrbConfig::EMrbAnalyzeTag TagIndex, const Char_t * Extension);
Bool_t MakeAnalyzeCode(ofstream & AnaStrm, TMrbConfig::EMrbAnalyzeTag TagIndex, TMrbEvent * Event, TMrbTemplate & Template, const Char_t * Prefix = NULL);
virtual Bool_t MakeSpecialAnalyzeCode(ofstream & AnaStrm, TMrbConfig::EMrbAnalyzeTag TagIndex, TMrbTemplate & Template) { return(kFALSE); };
Bool_t MakeConfigCode(ofstream & CfgStrm, TMrbConfig::EMrbConfigTag TagIndex, TMrbTemplate & Template, const Char_t * Prefix = NULL);
virtual Bool_t MakeRcFile(ofstream & RcStrm, TMrbConfig::EMrbRcFileTag TagIndex, const Char_t * ResourceName) { return(kFALSE); };
Bool_t SetReadoutOptions(Option_t * Options = "");
Bool_t SetAnalyzeOptions(Option_t * Options = "byName:Histograms");
Bool_t SetConfigOptions(Option_t * Options = "");
UInt_t GetReadoutOptions(TMrbEvent * Parent = NULL) const;
UInt_t GetAnalyzeOptions(TMrbEvent * Parent = NULL) const;
UInt_t GetConfigOptions(TMrbEvent * Parent = NULL) const;
Bool_t SetParamName(Int_t ParamNo, Char_t * ParamName);
inline void UseExplicitParamNames(Bool_t Flag = kTRUE) { fExplicitParamNames = Flag; };
inline Bool_t ExplicitParamNamesToBeUsed() { return(fExplicitParamNames); };
inline const Char_t * GetPrefix() const { return(fPrefix.Data()); };
inline Bool_t PrefixToBePrepended() const { return(fPrependPrefix); };
void PrependPrefix(const Char_t * Prefix) {
fPrefix = Prefix;
fPrefix.ToLower();
fPrependPrefix = !fPrefix.IsNull();
};
inline void PrependPrefix(Bool_t Flag = kTRUE) { fPrependPrefix = fPrefix.IsNull() ? kFALSE : Flag; };
void Print(Option_t * Option) const { TObject::Print(Option); }
void Print(ostream & OutStrm, const Char_t * Prefix = "") const;
inline virtual void Print() const { Print(cout, ""); };
inline void AllocateHistograms(Bool_t Flag = kTRUE) { fHistosToBeAllocated = Flag; };
inline Bool_t HistosToBeAllocated() const { return(fHistosToBeAllocated); };
inline void FillHistogramsIfTrueHitOnly(Bool_t Flag = kTRUE) { fHistosToBeFilledIfTrueHit = Flag; };
inline Bool_t HistosToBeFilledIfTrueHit() const { return(fHistosToBeFilledIfTrueHit); };
Bool_t SetMbsBranch(Int_t MbsBranchNo, const Char_t * MbsBranchName = NULL);
inline Bool_t SetMbsBranch(TMrbNamedX * MbsBranch) { return(this->SetMbsBranch(MbsBranch->GetIndex(), MbsBranch->GetName())); };
inline TMrbNamedX * GetMbsBranch() { return(&fMbsBranch); };
inline Int_t GetMbsBranchNo() { return(fMbsBranch.GetIndex()); };
virtual inline Bool_t HasFixedLengthFormat() const { return(kTRUE); };
virtual inline Bool_t AllowsMultipleModules() const { return(kTRUE); };
virtual inline Bool_t SerialToBeCreated() const { return(kTRUE); }
virtual inline Bool_t IsRaw() const { return(kFALSE); };
virtual inline Bool_t CheckModuleID(TMrbModule * Module) const { return(kTRUE); };
inline void SetArrayMode(Bool_t ArrayMode = kTRUE) { fArrayMode = ArrayMode; };
inline Bool_t IsInArrayMode() const { return(fArrayMode); };
inline Bool_t HasIndexedParams() const { return(fHasIndexedParams); };
Bool_t UseXhit(const Char_t * HitName, Int_t DataLength = -1);
inline Bool_t UseXhit(Int_t DataLength) { return(this->UseXhit("Xhit", DataLength)); };
inline const Char_t * GetNameOfXhit() { return(fXhit ? fXhit->GetName() : ""); };
inline Int_t GetHitDataLength() { return(fXhit ? fXhit->GetIndex() : 0); };
inline Bool_t HasXhit() { return(fXhit != NULL); };
virtual inline Bool_t NeedsHitBuffer() const { return(kFALSE); };
virtual inline Bool_t NeedsBranchMode() const { return(kFALSE); };
virtual inline Bool_t NeedsModulesToBeAssigned() const { return(kTRUE); };
virtual inline Bool_t HasPrivateCode() const { return(kFALSE); };
virtual inline Bool_t SingleModuleOnly() const { return(kFALSE); };
virtual inline const Char_t * GetPrivateCodeFile() const { return(NULL); };
virtual inline const Char_t * GetCommonCodeFile() { return(NULL); };
inline TObjArray * GetLofEvents() { return(&fLofEvents); };
inline TObjArray * GetLofModules() { return(&fLofModules); };
const Char_t * GetLofModulesAsString(TString & LofModules) const;
inline TObjArray * GetLofParams() { return(&fLofParams); };
const Char_t * GetLofParamsAsString(TString & LofParams) const;
inline void CreateHistoArray(const Char_t * ArrayName = NULL) {
fCreateHistoArray = kTRUE;
fHistoArrayName = ArrayName ? ArrayName : this->GetName();
}
inline Bool_t HistoArrayToBeCreated() { return(fCreateHistoArray); };
inline const Char_t * GetHistoArrayName() { return(fHistoArrayName.Data()); };
void Browse(TBrowser * Browser);
inline void Help() { gSystem->Exec(Form("mrbHelp %s", this->ClassName())); };
protected:
UInt_t fSevtType;
UInt_t fSevtSubtype;
UInt_t fLegalDataTypes;
TString fSevtDescr;
Int_t fSerial;
Int_t fCrate;
Bool_t fHistosToBeAllocated;
Bool_t fHistosToBeFilledIfTrueHit;
TMrbNamedX fMbsBranch;
Bool_t fExplicitParamNames;
Int_t fNofEvents;
TObjArray fLofEvents;
Int_t fNofParams;
Int_t fNofShorts;
TObjArray fLofParams;
Int_t fNofModules;
TObjArray fLofModules;
UInt_t fReadoutOptions;
UInt_t fAnalyzeOptions;
UInt_t fConfigOptions;
Bool_t fHasIndexedParams;
Bool_t fArrayMode;
Bool_t fPrependPrefix;
TString fPrefix;
TMrbNamedX * fXhit;
TString fInheritsFrom;
TString fCommonCodeFile;
Bool_t fCreateHistoArray;
TString fHistoArrayName;
TMrbModule * fSoftModule;
ClassDef(TMrbSubevent, 1)
};
#endif