[ROOT] How to select events from a chain

From: Milind Purohit (purohit@beauty.physics.sc.edu)
Date: Fri Oct 04 2002 - 17:40:10 MEST


I would like to select events in a tree based on cuts. The events are
being read in a chain. Is there a way to write out selected events? In
the code snippet below "mychoice" is a C++ function which selects events
of interest. How do I write them out to one file? This way I could save
a lot of CP time and not read the events of interest over and over
again. I would like to store the entire event, not just the variables
indicated in the "SetBranchAddress" statements below.

Thanks,

Milind Purohit

      .
      .
      .

  TChain UpsChain("h43");

  FILE * RUNEVT;
  RUNEVT = fopen("UpsRunEvt.txt", "w");

  FILE * CHFILE;
  char line[250];
  CHFILE = fopen("UpsChain.txt", "r");
  while((fgets(line, sizeof(line), CHFILE)) != NULL){
    char root_file_name[250];
    sscanf(line, "%s", root_file_name);
    UpsChain.Add(root_file_name);
  }

//Declaration of leaves types
  Int_t           event;
  Int_t           runnumber;

  Int_t           nchb;
  Float_t         masschb[100];   //[nchb]

  UpsChain.SetBranchAddress("event",&event);
  UpsChain.SetBranchAddress("runnumber",&runnumber);

  UpsChain.SetBranchAddress("nchb",&nchb);
  UpsChain.SetBranchAddress("masschb",&masschb);

  Int_t nevents = (Int_t)UpsChain.GetEntries();

  for(Int_t iev = 0; iev < nevents; iev++){
    UpsChain.GetEvent(iev);

    if(mychoice(myvars)){
      ???????
    }
  }

      .
      .
      .



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:51:12 MET