11 #include <TEntryList.h>
12 #include <TFriendElement.h>
17 using namespace Diana;
35 std::vector<std::string>::iterator iter;
38 for(iter = fFileList.begin(); iter!= fFileList.end(); iter++) {
39 Debug(
"Adding to chain %s", iter->c_str());
40 err = fChain->Add(iter->c_str(),0);
42 if(
err == 0) Panic(
"Cannot open file %s", iter->c_str());
45 fChain->SetCacheSize(100000000);
46 fChain->AddBranchToCache(
"*",kTRUE);
47 fEvents = fChain->GetEntries();
48 fChain->SetEstimate(fEvents);
49 Info(
"Number of events: %d", fEvents);
57 snprintf(buf,128,
"Total events: %llu; event requested: %llu", fEvents, event);
58 fErr.SetDescription(buf);
69 std::string owner = label.
GetOwner();
70 std::string name = label.
GetName();
72 Debug(
"Adding \"%s\" of owned by \"%s\"", name.c_str(), owner.c_str());
73 eva.
Add(owner.c_str(),name.c_str(), evData);
81 Int_t nbranches = branches->GetEntriesFast();
82 std::vector<TBranch*> myBranches;
83 std::stringstream msg;
84 bool firstCall =
false;
88 for (Int_t br = 0; br < nbranches; br++) {
89 TBranch* branch = (TBranch*) branches->UncheckedAt(br);
90 const char* brname = branch->GetName();
91 std::string brnamecut = brname;
92 brnamecut = brnamecut.substr(0,brnamecut.size()-1);
95 QObject** oldobj = eva.
Get(label.
owner.c_str(),label.
name.c_str());
96 bool addBranch = firstCall || (oldobj && *oldobj &&
97 (*oldobj)->IsRequired());
100 myBranches.push_back(branch);
102 if(!firstCall) (*oldobj)->SetIsRequired();
106 Debug(
"Active branches: %s",msg.str().c_str());
111 std::vector<TBranch*> branches = GetBranches(fChain,eva);
112 Int_t nbranches = branches.size();
113 fChain->SetBranchStatus(
"*",0);
115 for (Int_t br = 0; br < nbranches; br++) {
116 TBranch* branch = branches[br];
118 const char* brname = branch->GetName();
119 TLeaf* leaf = branch->GetLeaf(brname);
120 const char* leafType = leaf->GetTypeName();
121 Debug(
"Found branch \"%s\" of type \"%s\"", brname, leafType);
122 TClass* thisClass = TClass::GetClass(leafType,
false,
false);
123 if(thisClass && thisClass->InheritsFrom(
"Diana::QObject")) {
124 std::string brnamecut = brname;
125 brnamecut = brnamecut.substr(0,brnamecut.size()-1);
126 std::string brnamed = brnamecut +
"*";
127 fChain->SetBranchStatus(brnamed.c_str(),1);
128 if(fObjectList.find(brname) == fObjectList.end()) {
129 QObject** evData =
new QObject*(0);
132 branch->SetAddress(evData);
133 AddToEvent(brnamecut.c_str(),evData,eva);
134 fObjectList[brname] = evData;
135 (*evData)->SetIsRequired(GetBool(brnamecut,fInclusive,
false ));
137 branch->SetAddress(fObjectList[brname]);
140 Error(
"Type \"%s\" (in branch \"%s\") does not inherit from "
141 "Diana::QObject: skipped",leafType,brname);
TObjArray * GetListOfAllBranches()
error class with error type and description
Visitor class of QEvent that provides full handling of QEvent.
std::vector< QEventLabel > GetLabels() const
Get the list of all QObject labels in the event.
void Get(const char *owner, WriteHandle< Q > &handle)
Get QObject from the event in write mode. This method has to be called in the event loop,...
void Add(const char *owner, WriteHandle< Q > &handle)
Add QObject to the event. This method has to be called before the event loop, e.g....
label for QObject in the QEvent
const std::string & GetOwner() const
get owner
const std::string & GetName() const
get name
std::string owner
owner of the QObject
std::string name
name of the QObject
virtual void SetBranches(Diana::QEventAssembler &eva)
Set the branch caches.
virtual std::vector< TBranch * > GetBranches(QChain *chain, Diana::QEventAssembler &eva)
Get a list of the branches needed by the event.
virtual void AddToEvent(const char *brname, Diana::QObject **evData, Diana::QEventAssembler &eva)
Add an object from a branch to the event.
virtual void LoadQChain()
Build a QChain.
virtual ~QRootFileReaderBase()
virtual const QError & JumpToEvent(Long64_t event)
Jump to a particular event in the chain.
the Diana namespace is needed because sometimes we use Qt libraries, that use same class names of our...