BRAT 2.4.5
Class index
Full class index
brahmlib
BRAHMS
ROOT page
//$Id: BrVertexModule.cxx,v 1.4 2001/09/06 19:35:59 trine Exp $

// Lynx hacks:  Removed reference to three-argument constructor
// for BrTPMClusterVertexModule

//
// BrVertexModule
//

#ifndef BRAT_BrVertexModule
#include "BrVertexModule.h"
#endif

ClassImp(BrVertexModule)

 BrVertexModule::BrVertexModule():BrModule() // Default Constructor.
{

  fRdoModuleBB = 0;
  fRdoModuleZDC = 0;
  fClusterVertexModule = 0;
  fTrackVertexModule = 0;

  fBBvtx = 0;
  fZDCvtx = 0;
  fTPM1Trackvtx = 0;
  fTPM1Clustervtx = 0;
  fGlobalVertex = 0;

  SetDefaultParameters();

}

 BrVertexModule::BrVertexModule(Char_t *Name,Char_t *Title):BrModule(Name,Title)
{  

  fRdoModuleBB = new BrBbRdoModule("BB","Rdo Module BB");
  fRdoModuleZDC = new BrZdcRdoModule("RdoZDC","Rdo Module ZDC");
  fClusterVertexModule = new BrTPMClusterVertexModule("TPM1","TPM1 Cluster Vertex Module");
  fTrackVertexModule = new BrTPMTrackVertexModule("TPM1","TPM1 Track Vertex Module");
  
  fBBvtx = 0;
  fZDCvtx = 0;
  fTPM1Trackvtx = 0;
  fTPM1Clustervtx = 0;
  fGlobalVertex = 0;
  
  SetDefaultParameters();

}

 void BrVertexModule::SetDefaultParameters() 
{

  kBB = kTRUE;
  kZDC = kTRUE;
  kTPM1c = kTRUE;
  kTPM1t = kTRUE;

  fEstimatedUncertaintyBB = 3.0; // cm
  fEstimatedUncertaintyZDC = 5.0; // cm

  fZOffsetBB = 0.0; // cm
  fZOffsetZDC = 0.0; // cm

  fZDCTdcCount = 100.0e-12; // From BrZdcRdoModule
                            // Should be found in DetectorParameters or DB!!!

  fTPM1ClusterSigmaCut = 1.0;
  fTPM1TrackChisqCut = 5.0;

}


 BrVertexModule::~BrVertexModule() //Destructor
{

  if (fRdoModuleBB) delete fRdoModuleBB;
  if (fRdoModuleZDC) delete fRdoModuleZDC;
  if (fClusterVertexModule) delete fClusterVertexModule;
  if (fTrackVertexModule) delete fTrackVertexModule;

}

 void BrVertexModule::DefineHistograms()
{
  if(fClusterVertexModule)
    fClusterVertexModule->Book();
  if(fTrackVertexModule)
    fTrackVertexModule->Book();
}

 void BrVertexModule::Init(){
  if(fClusterVertexModule)
    fClusterVertexModule->Init();
  if(fTrackVertexModule)
    fTrackVertexModule->Init();
  fRdoModuleBB->Init();
}
 void BrVertexModule::Event(BrEventNode* InputNode, BrEventNode* OutputNode)
{
  fRdoModuleBB->SetDebugLevel(DebugLevel());
  fRdoModuleBB->SetDebugLevel(DebugLevel());
  fClusterVertexModule->SetDebugLevel(DebugLevel());
  fTrackVertexModule->SetDebugLevel(DebugLevel());  

  if (DebugLevel()>0) cout << "Entering BrVertexModule::Event" << endl;

  fRdoNode = new BrEventNode("fRdoNode","Global RDO Node");

  // BB Vertex
  if (kBB) {
    if (DebugLevel()>1) cout << "BrVertexModule: BB" << endl;

    fRdoModuleBB->Event(InputNode, fRdoNode);
    fRdoBB = (BrBbRdo*)fRdoNode->GetObject("BB");
    if (fRdoBB) {
      fBB_z = fRdoBB->GetZ0();
      if (fBB_z<1000) 
	{
	  fBBvtx = new BrVertex("BB VtxData", "BB Vertex Data");
	  fBBvtx->SetZ(fBB_z);
	  fBBvtx->SetVertexMethodUsed(3);
	  fBBvtx->SetVertexFound(1);
	  OutputNode->AddObject(fBBvtx);
	}
    }
  }

  // ZDC Vertex
  if (kZDC) {
    if (DebugLevel()>1) cout << "BrVertexModule: ZDC" << endl;
    fRdoModuleZDC->Event(InputNode, fRdoNode);
    fRdoZDC = (BrZdcRdo*)fRdoNode->GetObject("RdoZDC");
    if (
	fRdoZDC->GetLeftTdc1() > 0 &&
	fRdoZDC->GetLeftTdc1() < 2047 &&
	fRdoZDC->GetRightTdc1() > 0 &&
	fRdoZDC->GetRightTdc1() < 2047
	)
      {
	fZDCvtx = new BrVertex("ZDC VtxData", "ZDC Vertex Data");
	fZDC_z = (((fRdoZDC->GetLeftTdc1()-fRdoZDC->GetRightTdc1())/2)*fZDCTdcCount*3.0e10);
	fZDCvtx->SetZ(fZDC_z);
	fZDCvtx->SetVertexMethodUsed(4);
	fZDCvtx->SetVertexFound(1);
	OutputNode->AddObject(fZDCvtx);      
      }
  }

  // TPM1 Track Vertex
  if (kTPM1t) {
    if (DebugLevel()>1) cout << "BrVertexModule: TPM1 Tracks" << endl;
    if ((fTPM1Tracks = (BrDataTable*)InputNode->GetDataTable("DetectorTrack TPM1"))) {
      //      fTrackVertexModule->SetDetectorTracks(fTPM1Tracks);
      fTrackVertexModule->Event(OutputNode,OutputNode);
      fTPM1Trackvtx = (BrVertex*)OutputNode->GetObject("TPM1 Track VtxData");    
      fTPM1t_y = fTPM1Trackvtx->GetY();
      fTPM1t_z = fTPM1Trackvtx->GetZ();
      fTPM1t_chisq = fTPM1Trackvtx->GetVertexChisq();
    }
  }

  // TPM1 Cluster Vertex
  if (kTPM1c) {
    if (DebugLevel()>1) cout << "BrVertexModule: TPM1 Clusters" << endl;
    if (fTPM1Clusters) {
      //     fClusterVertexModule->SetDetectorHits(fTPM1Clusters);
      fClusterVertexModule->Event(OutputNode,OutputNode);
      fTPM1Clustervtx = (BrVertex*)OutputNode->GetObject("TPM1 Cluster VtxData");
      fTPM1c_y = fTPM1Clustervtx->GetY();
      fTPM1c_z = fTPM1Clustervtx->GetZ();
      fTPM1c_sigma = sqrt(fTPM1Clustervtx->GetVarianceZ());
    }
  }

  // Decide best vtx, fill GlobalVertex
  if (DebugLevel()>1) cout << "BrVertexModule: Global" << endl;
  fGlobalVertex = new BrVertex("VtxData","Vertex Data from best determination");
  OutputNode->AddObject(fGlobalVertex);

  if (fTPM1Clustervtx && fGlobalVertex->VertexFound()==0) {
    if (fTPM1c_sigma<fTPM1ClusterSigmaCut) {
      fGlobalVertex->SetY(fTPM1c_y);
      fGlobalVertex->SetZ(fTPM1c_z);
      fGlobalVertex->SetVertexVarianceY(fTPM1Clustervtx->GetVarianceY());
      fGlobalVertex->SetVertexVarianceZ(fTPM1Clustervtx->GetVarianceZ());
      fGlobalVertex->SetVertexMethodUsed(1);
      fGlobalVertex->SetVertexFound(1);
    }
  }

  if (fTPM1Trackvtx && fGlobalVertex->VertexFound()==0) {
    if (fTPM1t_chisq<fTPM1TrackChisqCut) {
      fGlobalVertex->SetY(fTPM1t_y);
      fGlobalVertex->SetZ(fTPM1t_z);
      fGlobalVertex->SetVertexChisq(fTPM1t_chisq);
      fGlobalVertex->SetVertexMethodUsed(2);
      fGlobalVertex->SetVertexFound(1);
    }
  }

  if (fBBvtx && fBBvtx->VertexFound()!=0 && fGlobalVertex->VertexFound()==0) {
    fGlobalVertex->SetZ(fBB_z);
    fGlobalVertex->SetVertexMethodUsed(3);
    fGlobalVertex->SetVertexFound(1);
  }

  if (fZDCvtx && fZDCvtx->VertexFound()!=0 && fGlobalVertex->VertexFound()==0) {
    fGlobalVertex->SetZ(fZDC_z);
    fGlobalVertex->SetVertexMethodUsed(4);
    fGlobalVertex->SetVertexFound(1);
  }

  delete fRdoNode;

  if (DebugLevel()>0) ListVertices();

}

 void BrVertexModule::ListVertices()
{

  cout << "Vertex information:"<< endl;
  if (fBBvtx) 
    cout << "BB     ---  z: " << fBBvtx->GetZ() << "cm, Estimated error: " << fEstimatedUncertaintyBB << "cm" << endl; 
  if (fZDCvtx) 
    cout << "ZDC    ---  z: " << fZDCvtx->GetZ() << "cm, Estimated error: " << fEstimatedUncertaintyZDC << "cm" << endl; 
  if (fTPM1Clustervtx && fTPM1Clustervtx->VertexFound()!=0) 
    cout << "TPM1 C ---  z: " << fTPM1Clustervtx->GetZ() << "cm, Sigma: " << fTPM1c_sigma << "cm" << endl; 
  if (fTPM1Trackvtx && fTPM1Trackvtx->VertexFound()!=0) 
    cout << "TPM1 T ---  z: " << fTPM1Trackvtx->GetZ() << "cm, Chisq: " << fTPM1t_chisq << "cm" << endl; 
  cout << endl;
}


//$Log: BrVertexModule.cxx,v $
//Revision 1.4  2001/09/06 19:35:59  trine
//Small change to compile with the newest BrTPMClusterModule
//(removed references to three-argument constructor)
//Class version changed to 0 as proper for a module.
//
//Revision 1.3  2001/08/03 21:46:30  zdc
//The functions names for getting times from ZDC have been re-named in BrVertexModule.cxx file, accordingly to changes in BrZdcRdoModule class
//
//Revision 1.2  2001/06/22 17:51:07  cholm
//Changes to to data class renaming.
//
//Revision 1.1.1.1  2001/06/21 14:55:14  hagel
//Initial revision of brat2
//
//Revision 1.3  2001/01/12 16:45:51  zdc
//The functions calls to ZDC's BrZdcRdo object has been changed
//
//Revision 1.2  2000/11/22 21:21:26  videbaek
//Changes due to better handling of Init().
//
//Revision 1.1  2000/11/07 16:40:24  bjornhs
//Added BrVertexModule to CVS - superclass for vertex-finding.
//Major change in TPC-vertex-modules:
//BrTPMTrackVertexModule adds BrVertex-object "TPM1 Track VtxData" to outputnode.
//BrTPMClusterVertexModule has been thorougly cleaned up to work better and faster. Adds BrVertex-object "TPM1 Cluster VtxData" to outputnode.
//BrVertex is slightly edited to reflect these changes.
//

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