43 void **tmpCondRef = col->Get(TLoop::kConditionName)->GetObjectRef();
45 Error(
"Init",
"fCondition: tmpCondRef is null");
48 fCondition =
reinterpret_cast<TConditionBit **
>(tmpCondRef);
50 Error(
"Init",
"fCondition is null after reinterpret_cast");
54 TConditionBit *condPtr =
dynamic_cast<TConditionBit *
>(*fCondition);
56 Error(
"Init",
"fCondition: *fCondition is not a TConditionBit!");
60 Warning(
"Init",
"fCondition: *fCondition is null. It might be set later?");
64 auto filelist = gSystem->GetFromPipe(Form(
"ls -tr %s",
fFileName.Data()));
65 auto *allfiles = filelist.Tokenize(
"\n");
67 SetStateError(Form(
"No files matched '%s'",
fFileName.Data()));
69 (*fCondition)->Set(TLoop::kStopLoop);
75 SetStateError(
"MaxEventNum == 0 => No event is processed.");
77 (*fCondition)->Set(TLoop::kStopLoop);
84 for (
int i = 0, n = allfiles->GetEntriesFast(); i < n; ++i) {
85 auto *strObj =
dynamic_cast<TObjString *
>(allfiles->At(i));
88 Info(
"Init",
"Add '%s'", (strObj->GetString()).Data());
89 chain->Add(strObj->GetString());
95 Error(
"Init",
"Failed to create TChain for tree = '%s'",
fTreeName.Data());
97 (*fCondition)->Set(TLoop::kStopLoop);
106 std::vector<TBranch *> useBranch;
107 TIter nextBr(
fTree->GetListOfBranches());
108 while (
auto *br =
dynamic_cast<TBranch *
>(nextBr())) {
109 TClass *cl =
nullptr;
110 EDataType dtype = kNoType_t;
112 if (br->GetExpectedType(cl, dtype)) {
113 Warning(
"Init",
"Unresolved type for branch '%s'", br->GetName());
121 if (
auto *leaf = br->GetLeaf(br->GetName())) {
122 leaf = leaf->GetLeafCounter(arrSize);
127 void *arrPtr =
nullptr;
130 arrPtr =
new Int_t[arrSize];
133 arrPtr =
new Float_t[arrSize];
136 arrPtr =
new Double_t[arrSize];
146 col->Add(
new TEventObject(
149 TString(TDataType::GetTypeName(dtype)),
151 auto **objRef = col->Get(br->GetName())->GetObjectRef();
153 Error(
"Init",
"Branch '%s': tmpRef is null (unexpected)", br->GetName());
156 fTree->SetBranchAddress(br->GetName(), *objRef);
157 useBranch.emplace_back(br);
158 Info(
"Init",
"branch : %s (type=%s, size=%d)",
159 br->GetName(), TDataType::GetTypeName(dtype), arrSize);
164 if (cl == TClonesArray::Class()) {
165 TClonesArray *arr =
nullptr;
167 fTree->SetBranchStatus(
"*", 0);
168 fTree->SetBranchStatus(br->GetName(), 1);
169 fTree->SetBranchAddress(br->GetName(), &arr);
173 TClass *realcls = arr->GetClass();
174 if (!realcls || !realcls->GetNew()) {
185 auto *obj =
static_cast<TObject *
>(cl->New());
186 col->Add(br->GetName(), obj, kTRUE);
188 void **tmpRef = col->Get(br->GetName())->GetObjectRef();
190 Error(
"Init",
"Branch '%s': tmpRef is null (unexpected)", br->GetName());
194 auto **objRef =
reinterpret_cast<TObject **
>(tmpRef);
196 Error(
"Init",
"Branch '%s': objRef is null after cast", br->GetName());
200 TObject *checkObj =
dynamic_cast<TObject *
>(*objRef);
203 "Branch '%s': *objRef is not a TObject. Type mismatch?",
209 fTree->SetBranchAddress(br->GetName(), objRef);
211 useBranch.emplace_back(br);
214 if (cl == TEventHeader::Class()) {
217 Info(
"Init",
"Branch: %s (class=%s)", br->GetName(), cl->GetName());
223 TIter nextInfo(
fTree->GetUserInfo());
224 while (
auto *infoObj = nextInfo()) {
225 col->AddInfo(infoObj->GetName(), infoObj, kTRUE);
229 fTree->SetBranchStatus(
"*", 0);
230 for (
auto *br : useBranch) {
231 fTree->SetBranchStatus(br->GetName(), 1);