Enable leaf with PDGid and fill histogram

Hello,

I have an Event branch that stores parton info (PDG id) for qqbar annihilation and gluon fusion.
I need to fill histograms associated with each of those initial states.

How do you retrieve the info from the qqbar leaf and then tell a root to fill a histogram for pt?
I’ve tried if I could enable a certain leaf while filling but it doesn’t work.

Hope you could help!

Thanks!

Uzziel

 58    Long64_t nentries = fChain->GetEntriesFast();
 59   //==== Loop over the events
 60    Long64_t nbytes = 0, nb = 0;
 61    for (Long64_t jentry=0; jentry<nentries;jentry++) {
 62       Long64_t ientry = LoadTree(jentry);
 63       if (ientry < 0) break;
 64       nb = fChain->GetEntry(jentry);   nbytes += nb;
 65       // if (Cut(ientry) < 0) continue;
 66      
..................
 73 
 74    // if (Event_interactingParton2PdgId){
 75     //  fChain->SetBranchStatus("Event_interactingParton1PdgId", kTRUE);
 76      // fChain->SetBranchStatus("Event_interactingParton2PdgId", kFALSE);
 77      //interacting_parton gluglu{
 78        //Event_interactingParton1PdgId, 
 79      //}
 80     //  cout << Event_interactingParton1PdgId << endl;
 81       gg->Fill(Photon_pt, Event_weight);
 82       N_gluglu++;
 83    // }
 84     //if (Event_interactingParton2PdgId){
 85       //fChain->SetBranchStatus("Event_interactingParton1PdgId",kTRUE);
 86       //fChain->SetBranchStatus("Event_interactingParton2PdgId", kFALSE);
 87       //cout << Event_interactingParton2PdgId << endl;
 88       qq->Fill(Photon_pt, Event_weight);
 89       N_qqbar++;
 90    // } 
 91 
 92 
 93    }//end of event loop 
 

I think, the best for you would be to try an “analysis skeleton”. See, for example, links in: How are multiple TTree->Draw()s done?