SLAC PEP-II
BABAR
SLAC<->RAL
Babar logo
HEPIC E,S & H Databases PDG HEP preprints
Organization Detector Computing Physics Documentation
Personnel Glossary Sitemap Search Hypernews
Unwrap page!
Comp. Search
Who's who?
Meetings
FAQ Homepage
Archive
Environment
Administration
New User Info.
Web Info/Tools
Monitoring
Training
Tools & Utils
Programming
C++ Standard
SRT, AFS, CVS
QA and QC
Remedy
Histogramming
Operations
PromptReco
Simulation Production
Online SW
Dataflow
Detector Control
Evt Processing
Run Control
Calibration
Databases
Offline
Workbook
Coding Standards
Simulation
Reconstruction
Prompt Reco.
BaBar Grid
Data Distribution
Beta & BetaTools
Kanga & Root
Analysis Tools
RooFit Toolkit
Data Management
Data Quality
Event display
Event Browser
Code releases
Databases
Check this page for HTML 4.01 Transitional compliance with the
W3C Validator
(More checks...)

Simple Macro to count the Number of Candidates

TH1* nCand( KanEventSource& input, const char* listName, UInt_t nEvt = 0) {
  // This is a simple macro to fill a 1D the # of candidate on a given list
  // The input is a KanEventSource.
  // The return value is the filled histogram
  //
  // To Build a KanEventSource you need to do:
  // root[0] KanEventSource* input = KanEventSource::mini("in");
  // root[1] input->Add("/A/Collection/Name")
  //
  // To invoke this macro you could do (for example)
  // root[2] .L ../KanExample/nCand.C
  // root[3] TH1F* hist = nCand(*input,"ChargedTracks");
  // root[4] hist->Draw();
  //
  // Note that this macro is the equivalent of doing:
  // root[5] input->getComponent(3)->Draw("Cnd_<list>__n");
  //
  

  // Setup the input data 
  TString theName("Cnd_");
  theName += listName;

  BtaCandHandleList cands(KanCompMap::cnd,theName.Data());
  input.setBranchToRead(cands);

  // Build the output histogram
  TH1F* hist = new TH1F("nCand","A plot of number of candidates on a list",31,-0.5,30.5);
  
  // Setup the Event Loop
  UInt_t n = (UInt_t)input.GetEntries();
  if ( nEvt > 0 ) {
    n = n > nEvt ? nEvt : n;
  }
  cout << "Will run on " << n << " events." << endl;
  
  // Event Loop
  for ( UInt_t i(0); i < n; ++i ) {

    // Load the event
    input.LoadTree(i);
    
    // Read the data
    if ( !cands(input) ) {
      cerr << "Failed to read branch object for event " << i << endl;
      break;
    }
    
    // Fill the output histogram
    hist->Fill((Float_t)(cands.size()));
  }
  
  // Return the histogram
  return hist;
}  


ROOT page - Class index - Class Hierarchy - Top of the page

This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.