// Original Author: Rene Brun   05/02/97
// Modified for use in VEGA by D. Buskulic 21/03/03

////////////////////////////////////////////////////////////////////////////
//                                                                        //
// A VSelector object is used by the VFrameChannel::Process to navigate   //
// in a VFrameChannel and make selections.                                //
//                                                                        //
//  The following members functions are called by the VFrameChannel       //
//  functions.                                                            //
//    Init:        Attach a new VFrameChannel during the loop             //
//    Begin:       called everytime a loop on the channel starts.         //
//                 a convenient place to create your histograms / plots.  //
//                                                                        //
//    ProcessCut:  called at the beginning of each entry to return a flag //
//                 true if the entry must be analyzed.                    //
//    ProcessFill: called in the entry loop for all entries accepted      //
//                 by Select.                                             //
//    Terminate:   called at the end of a loop in a VFrameChannel.        //
//                 a convenient place to draw/fit your histograms.        //
//                                                                        //
////////////////////////////////////////////////////////////////////////////

#include "TROOT.h"
#include "TSystem.h"
#include "TError.h"
#include "VSelectorCint.h"
#include "Api.h"

ClassImp(VSelector)

//______________________________________________________________________________
VSelector::VSelector() : TObject()
{
   // Default selector ctor.

   mStatus = 0;
   mObject = 0;
//    mInput  = 0;
//    mOutput = new THashList;
//    mOutput->SetOwner();
}

//______________________________________________________________________________
VSelector::~VSelector()
{
   // Selector destructor.

//   delete mOutput;
}


//______________________________________________________________________________
 VSelector *VSelector::GetSelector(const char *filename)
{
//   The code in filename is loaded (interpreted or compiled , see below)
//   filename must contain a valid class implementation derived from VSelector.
//   where VSelector has the following member functions:
//
//    void VSelector::Begin():       called everytime a loop on the frame channel starts,
//                   a convenient place to create your histograms.
//    Bool_t VSelector::ProcessCut():  called at the beginning of each frame processing to return a flag,
//                   true if the entry must be analyzed.
//    void VSelector::ProcessFrame(): called in the frame loop for all frames accepted
//                   by ProcessCut.
//    void VSelector::ProcessVect(): called in the loop for specific vectors requested
//    void VSelector::Terminate():   called at the end of a loop on the frame channel,
//                   a convenient place to draw/fit your histograms.
//
//   if filename is of the form file.C, the file will be interpreted.
//   if filename is of the form file.C++, the file file.C will be compiled
//      and dynamically loaded. The corresponding binary file and shared library
//      will be deleted at the end of the function.
//   if filename is of the form file.C+, the file file.C will be compiled
//      and dynamically loaded. At next call, if file.C is older than file.o
//      and file.so, the file.C is not compiled, only file.so is loaded.
//
//   The static function returns a pointer to a VSelector object

   //Interpret/compile filename via CINT
   char localname[256];
   int olddispmsg = G__dispmsg;
   G__dispmsg = 0;
   sprintf(localname,".L %s",filename);
   gROOT->ProcessLine(localname);
   G__dispmsg = olddispmsg;

   //loop on all classes known to CINT to find the class on filename
   //that derives from VSelector
   const char *basename = gSystem->BaseName(filename);
   if (basename==0) {
      ::Error("VSelector::GetSelector","Unable to determine the classname for file %s",filename);
      return 0;
   }
   strcpy(localname,basename);
   char *IsCompiled = strchr(localname,'+');
   char *dot        = strchr(localname,'.');
   if (dot) dot[0] = 0;

   G__ClassInfo cl;
   Bool_t OK = kFALSE;
   while (cl.Next()) {
      if (strcmp(cl.Name(),localname)) continue;
      if (cl.IsBase("VSelector")) OK = kTRUE;
      break;
   }
   if (!OK) {
      ::Error("VSelector::GetSelector","file %s does not have a valid class deriving from VSelector",filename);
      return 0;
   }

   // we can now create an instance of the class
   VSelector *selector = (VSelector*)cl.New();
   if (!selector || IsCompiled) return selector;
   //interpreted selector: cannot be used as such
   //create a fake selector
   VSelectorCint *select = new VSelectorCint();
   select->Build(selector,&cl);

   return select;
}



- ROOT page - VEGA page - Class index - 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 , or contact with any questions or problems regarding ROOT or VEGA.