本文整理汇总了C++中TBranch::GetEvent方法的典型用法代码示例。如果您正苦于以下问题:C++ TBranch::GetEvent方法的具体用法?C++ TBranch::GetEvent怎么用?C++ TBranch::GetEvent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TBranch
的用法示例。
在下文中一共展示了TBranch::GetEvent方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fillhist
void fillhist(const char* filename, const char* treename, int process, double scale, TH1* hist) {
TFile* file = new TFile(filename);
TTree* tree = (TTree*)file->Get(treename);
TBranch *bmet = tree->GetBranch("mumet");
TBranch *bweight = tree->GetBranch("weight");
TBranch *bnjets = tree->GetBranch("njets");
TBranch *bjjdphi = tree->GetBranch("jetjetdphi");
double vmet = 0.0;
double vweight = 0.0;
unsigned vnjets = 0;
double vjjdphi = 0.0;
bmet ->SetAddress(&vmet);
bweight->SetAddress(&vweight);
bnjets ->SetAddress(&vnjets);
bjjdphi->SetAddress(&vjjdphi);
for (int i = 0; i < tree->GetEntries(); i++) {
bmet ->GetEvent(i);
bweight->GetEvent(i);
bnjets ->GetEvent(i);
bjjdphi->GetEvent(i);
if (process == 0) vweight *= scale;
if (process == 1) vweight *= scale * (5.942 * 1.023) / (0.79*(1.0-exp(-0.00910276*(vmet-36.1669))));
if (process == 2) vweight *= scale * 38.7823/pow(-85.7023 + vmet, 0.667232);
hist->Fill(vmet, vweight);
}
}
示例2: dumpDDG4
int dumpDDG4(const char* fname, int event_num) {
TFile* data = TFile::Open(fname);
if ( !data || data->IsZombie() ) {
printf("+ File seems to not exist. Exiting\n");
usage();
return -1;
}
TTree* tree = (TTree*)data->Get("EVENT");
for(int event=0, num=tree->GetEntries(); event<num; ++event) {
TObjArray* arr = tree->GetListOfBranches();
if ( event_num>= 0 ) event = event_num;
for(int j=0, nj=arr->GetEntries(); j<nj; ++j) {
TBranch* b = (TBranch*)arr->At(j);
typedef vector<void*> _E;
_E* e = 0;
b->SetAddress(&e);
int nbytes = b->GetEvent(event);
if ( nbytes > 0 ) {
if ( e->empty() ) {
continue;
}
string br_name = b->GetName();
string cl_name = b->GetClassName();
if ( cl_name.find("dd4hep::sim::Geant4Tracker::Hit") != string::npos ) {
typedef vector<Geant4Tracker::Hit*> _H;
printHits(br_name,(_H*)e);
}
else if ( cl_name.find("dd4hep::sim::Geant4Calorimeter::Hit") != string::npos ) {
typedef vector<Geant4Calorimeter::Hit*> _H;
printHits(br_name,(_H*)e);
}
else if ( cl_name.find("dd4hep::sim::Geant4Particle") != string::npos ) {
typedef vector<Geant4Particle*> _H;
::printf("%s\n+ Particle Dump of event %8d [%8d bytes] +\n%s\n",
line,event,nbytes,line);
printParticles(br_name,(_H*)e);
}
}
}
if ( event_num >= 0 ) break;
}
delete data;
return 0;
}