#include <iostream>
#include "TFile.h"
#include "TTree.h"

void listNoiseEv(string rootfile) {
  //To put a comment in the output file insert a #* before the text:
  //cout << "#*This is the comment." << endl;

  //Open a file
  cout << "#*Opening file:" << rootfile << endl;
  rootfile="rfio:/castor/cern.ch/cms" + rootfile;
  TFile *f =TFile::Open(rootfile.c_str());
  TTree *events = (TTree*)f->Get("Events");

  //Define ailases for nicer printout
  events->SetAlias("Run","EventAuxiliary.id_.run_");
  events->SetAlias("Event","EventAuxiliary.id_.event_");
  events->SetAlias("SiStripCusters","SiStripClusteredmNewDetSetVector_siStripClusters__Rec.obj.@m_ids.size()");
  events->SetAlias("recoTracks","recoTracks_ctfWithMaterialTracksP5__Rec.@obj.size()");
    
  //Define the filter
  string filter="SiStripCusters>40|recoTracks>1";
    //Define field to printout, the first 2 entries must be Run and Event
  cout << "#*" << filter << endl;
  string fields_to_show="Run:Event:SiStripCusters:recoTracks";

  events->SetScanField(0);
  events->Scan(fields_to_show.c_str(), filter.c_str());

  f->Close();
  cout << "File closed" << endl;
}
