BRAT 2.4.5
Class index
Full class index
brahmlib
BRAHMS
ROOT page
// 
// Module to "fix" BrFsTracks.  The problem arises when BrFsTracks are
// written out and the user needs their constituent BrFfsTracks and
// BrBfsTracks.  The ids are written, but not the pointers.  The pointers
// are very useful for just getting the data out and using it without
// doing searches.  So this module does the searches and sets the ffs amd bfs
// pointers of the BrFsTrack that was read to the correct pointers.
//
// The way to use it is:
//    BrFsTrackRegeneratorModule* fsmod = new BrFsTrackRegeneratorModule("name", "title"); 
// The only time it is needed is if BrFsTrack objects have been written
// to disk and the constituent BrFfsTrack and BrBfsTrack pointers are needed
// in a subsequent module


//____________________________________________________________________
//
// $Id: BrFsTrackRegeneratorModule.cxx,v 1.2 2002/08/12 21:41:56 hagel Exp $
// $Author: hagel $
// $Date: 2002/08/12 21:41:56 $
// $Copyright: (C) 2002 BRAHMS Collaboration <brahmlib@rhic.bnl.gov>
//
#ifndef BRAT_BrFsTrackRegeneratorModule
#include "BrFsTrackRegeneratorModule.h"
#endif

#ifndef BRAT_BrSpectrometerTracks
#include "BrSpectrometerTracks.h"
#endif

#ifndef WIN32
#include <iostream>
#else
#include <iostream.h>
#endif

//____________________________________________________________________
ClassImp(BrFsTrackRegeneratorModule);

//____________________________________________________________________
 BrFsTrackRegeneratorModule::BrFsTrackRegeneratorModule()
{
  // Default constructor. DO NOT USE
  SetState(kSetup);

}

//____________________________________________________________________
 BrFsTrackRegeneratorModule::BrFsTrackRegeneratorModule(const Char_t* name, 
				       const Char_t* title)
  : BrModule(name, title)
{
  // Named Constructor
  SetState(kSetup);

}

//____________________________________________________________________
 void BrFsTrackRegeneratorModule::Init() 
{
  SetState(kInit);

}

//____________________________________________________________________
 void BrFsTrackRegeneratorModule::DefineHistograms() 
{

}

//____________________________________________________________________
 void BrFsTrackRegeneratorModule::Begin() 
{
  SetState(kBegin);
  
}


//____________________________________________________________________
 void BrFsTrackRegeneratorModule::Event(BrEventNode* inNode, BrEventNode* outNode)
{
  // Per event method
  SetState(kEvent);


  // ---- get track tables:

  BrDataTable *ffsTab, *bfsTab;
  BrDataTable* fsTab = inNode->GetDataTable("FsTracks");
  if(fsTab) {
     ffsTab = inNode->GetDataTable("FfsTracks");
     bfsTab = inNode->GetDataTable("BfsTracks");
     if(!ffsTab || !bfsTab) {
        Error("Event","There was a FsTracks in inNode, but FfsTracks = %d, BfsTracks = %d; something is wrong",Int_t(ffsTab),Int_t(bfsTab));
        return;
     }
     }
  if(!fsTab) {
     fsTab = outNode->GetDataTable("FsTracks");
     if(fsTab) {
        ffsTab = outNode->GetDataTable("FfsTracks");
        bfsTab = outNode->GetDataTable("BfsTracks");
        if(!ffsTab || !bfsTab) {
           Error("Event","There was a FsTracks in outNode, but FfsTracks = %d, BfsTracks = %d; something is wrong",Int_t(ffsTab),Int_t(bfsTab));
           return;
           }
        }
     }
  if(!fsTab) {
     Info(5,"Event","No FsTracks in inNode or outNode");
     return;  //This can happen, so return quietly (unless user wants info)
     }

  Int_t nFsTracks = fsTab->GetEntries();
  Int_t nFfsTracks = ffsTab->GetEntries();
  Int_t nBfsTracks = bfsTab->GetEntries();
  for(Int_t iFsTrack=0;iFsTrack<nFsTracks;iFsTrack++) {
     BrFsTrack *fsTrack = (BrFsTrack*)fsTab->At(iFsTrack);
     if(!fsTrack->GetFfsTrack() && !fsTrack->GetBfsTrack()) {
        //Do this only if we need to.  If one of those two is not NULL,
        //assume it is already set.  Ie, user is calling this when not needed.
        Int_t ffsTrackId = fsTrack->GetFfsTrackId();
        Int_t bfsTrackId = fsTrack->GetBfsTrackId();
        Bool_t ffsTrackFound = kFALSE;
        Bool_t bfsTrackFound = kFALSE;
        for(Int_t iFfsTrack=0;iFfsTrack<nFfsTracks;iFfsTrack++) {
           BrFfsTrack *ffsTrack = (BrFfsTrack*)ffsTab->At(iFfsTrack);
           if(ffsTrack) {
              if(ffsTrackId == ffsTrack->GetTrackId()) {
                 ffsTrackFound = kTRUE;
                 fsTrack->SetFfsTrack(ffsTrack);
                 }
              }
           }
        for(Int_t iBfsTrack=0;iBfsTrack<nFfsTracks;iBfsTrack++) {
           BrBfsTrack *bfsTrack = (BrBfsTrack*)bfsTab->At(iBfsTrack);
           if(bfsTrack) {
              if(bfsTrackId == bfsTrack->GetTrackId()) {
                 bfsTrackFound = kTRUE;
                 fsTrack->SetBfsTrack(bfsTrack);
                 }
              }
           }
        if(!ffsTrackFound) Info(5,"Event","No FFS track found for Fs track");
        if(!bfsTrackFound) Info(5,"Event","No BFS track found for Fs track");
        }
     else return; //We have no business in here at all.
     }
    
}

//____________________________________________________________________
 void BrFsTrackRegeneratorModule::Finish() 
{
  SetState(kFinish);
}

//____________________________________________________________________
 void BrFsTrackRegeneratorModule::Print(Option_t* option) const
{
  // Print module information
  // See BrModule::Print for options.
  // In addition this module defines the Option:
  // <fill in here>
  
  TString opt(option);
  opt.ToLower(); 
  
  BrModule::Print(option); 
  if (opt.Contains("d")) { 
    cout << endl 
         << "  Original author: K. Hagel" << endl
         << "  Last Modifications: " << endl 
         << "    $Author: hagel $" << endl  
         << "    $Date: 2002/08/12 21:41:56 $"   << endl 
         << "    $Revision: 1.2 $ " << endl  
         << endl 
         << "-------------------------------------------------" << endl;
  }
}

//____________________________________________________________________
//
// $Log: BrFsTrackRegeneratorModule.cxx,v $
// Revision 1.2  2002/08/12 21:41:56  hagel
// Put check of pointer to avoid seg violation
//
// Revision 1.1  2002/08/12 21:27:35  hagel
// Initial revision (after testing; should work)
//

This page automatically generated by script docBrat by Christian Holm

Copyright ; 2002 BRAHMS Collaboration <brahmlib@rcf.rhic.bnl.gov>
Last Update on by

Validate HTML
Validate CSS