Hello,
could you help me with the following problem, please? I loop over given TTree (whose name is qcd) using the Loop method of the class generated by TTree::MakeClass. I want to use the information stored in this tree to make another one tree called qcd_simple. I use GoodRunsLists to select only some entries of qcd. But when I run the program and look at the generated file that should contain qcd_simple I find that there are two trees qcd_simple instead of one. The two trees has slightly different number of entries. What should that mean? I do not want to have two trees...
Thank you in advance for your help.
Vojtech Pleskot
P.S. I append my code:
void qcd_class::Loop()
{
DQ::SetXMLFile("…/data_GRL.xml");
fChain->SetBranchStatus("*",0); // disable all branches
fChain->SetBranchStatus(“RunNumber”,1); // activate branchname
fChain->SetBranchStatus(“lbn”,1); // activate branchname
fChain->SetBranchStatus(“cl_had_n”,1); // activate branchname
fChain->SetBranchStatus(“cl_had_pt”,1); // activate branchname
fChain->SetBranchStatus(“cl_had_eta”,1); // activate branchname
fChain->SetBranchStatus(“cl_had_phi”,1); // activate branchname
fChain->SetBranchStatus(“cl_had_E_em”,1); // activate branchname
fChain->SetBranchStatus(“cl_had_E_had”,1); // activate branchname
if (fChain == 0) return;
Int_t counter=0;
TH1F *his=new TH1F(“his”,“his”,100,0,2000);
TFile f(“ntup_55.root”,“RECREATE”);
TTree *qcd_simple=new TTree(“qcd_simple”,“qcd tree with only a few branches”);
int n;
UInt_t run=0;
UInt_t lumi=0;
std::vector pt;
std::vector eta;
std::vector phi;
std::vector E;
qcd_simple->Branch(“n”,&n);
qcd_simple->Branch(“pt”,&pt);
qcd_simple->Branch(“eta”,&eta);
qcd_simple->Branch(“phi”,&phi);
qcd_simple->Branch(“E”,&E);
Long64_t nentries = fChain->GetEntriesFast();
Long64_t nbytes = 0, nb = 0;
for (Long64_t jentry=0; jentry<nentries;jentry++) {
Long64_t ientry = LoadTree(jentry);
if (ientry < 0) break;
nb = fChain->GetEntry(jentry); nbytes += nb;
if(run!=RunNumber || lumi!=lbn ) std::cout << "runNo: " << RunNumber << " " << "lumiblock: " << lbn << std::endl;
run=RunNumber;
lumi=lbn;
// if (Cut(ientry) < 0) continue;
//std::cout << "runNo: " << RunNumber << " " << "lumiblock: " << lbn << std::endl;
bool PassGRL = DQ::PassRunLB(RunNumber,lbn);
// if ( jentry == 3 ) PassGRL = false;
if(!PassGRL) {
counter++;
continue;
}
n=cl_had_n;
his->Fill((float)cl_had_n);
for(int i=0;i<cl_had_n;i++){
pt.push_back(cl_had_pt->at(i));
eta.push_back(cl_had_eta->at(i));
phi.push_back(cl_had_phi->at(i));
E.push_back(cl_had_E_em->at(i) + cl_had_E_had->at(i));
}
qcd_simple->Fill();
pt.clear();
eta.clear();
phi.clear();
E.clear();
}
his->Draw();
std::cout << "number of bad events: " << counter << std::endl;
f.Write(“qcd_simple”);
f.Close();
}