BRAT 2.4.5
Class index
Full class index
brahmlib
BRAHMS
ROOT page
//____________________________________________________________________
//
// Rdo (after first analysis pass) structure common to both TMA and
// SMA. 
//

//____________________________________________________________________
// $Id: BrMultRdo.cxx,v 1.4 2001/11/24 15:45:19 sanders Exp $
// $Author: sanders $
// $Date: 2001/11/24 15:45:19 $
// $Copyright: 2001 BRAHMS Collaboration <brahmlib@rhic.bnl.gov>
//
#ifndef BRAT_BrMultRdo
#include "BrMultRdo.h"
#endif
#ifndef ROOT_TDirectory
#include "TDirectory.h"
#endif
#ifndef __WIN32
#include <iostream>
#include <iomanip>
#else 
#include <iostream.h>
#include <iomanip.h>
#endif
//____________________________________________________________________
ClassImp(BrMultRdo);

//____________________________________________________________________
BrMultRdo::BrMultRdo()
  : BrDataObject(),
    fSingle("BrMultRdo::BrSingle", 0), 
    fRing("BrMultRdo::BrRing",0), 
    fArrayCalibratedAdc(0),
    fArrayEnergy(0), 
    fArrayMultiplicity(0),
    fArrayHits(0)
{
  // Default constructor, do not use 
  // Fix to allow objects of this class to be extracted an put as a
  // split branch on a new TTree. 
  fSingle.BypassStreamer(kFALSE);
  fRing.BypassStreamer(kFALSE);
}

//____________________________________________________________________
BrMultRdo::BrMultRdo(const char* name, const char* title)
  : BrDataObject(name, title),
  fSingle("BrMultRdo::BrSingle", 0), 
  fRing("BrMultRdo::BrRing",0), 
  fArrayCalibratedAdc(0),
  fArrayEnergy(0), 
  fArrayMultiplicity(0),
  fArrayHits(0)
{
  // Named constructor
  // Fix to allow objects of this class to be extracted an put as a
  // split branch on a new TTree. 
  fSingle.BypassStreamer(kFALSE);
  fRing.BypassStreamer(kFALSE);
}

//____________________________________________________________________
BrMultRdo::~BrMultRdo() 
{
  fSingle.Delete();
  fRing.Delete();
}

//____________________________________________________________________
void BrMultRdo::Clear(Option_t* option) 
{
  fSingle.Clear();
  fRing.Clear();
  fArrayCalibratedAdc = 0;
  fArrayEnergy        = 0;
  fArrayMultiplicity  = 0;
  fArrayHits          = 0; 
}

//____________________________________________________________________
void BrMultRdo::Print(Option_t* option)  const
{
  // Print this data object
  // 
  // Options: 
  //    A          Array data 
  //    I          Single data 
  //    R          Ring data  
  // 
  // other options are passed on. 
  // 
  cout << "BrMultRdo: " << GetName() 
       << "(" << GetTitle() << ")" << endl;
  
  TString opt(option);
  opt.ToLower();

  if (opt.Contains("a"))
    cout << " CalAdc: " << setw(7) << fArrayCalibratedAdc
	 << " Energy: " << setw(7) << fArrayEnergy
	 << " Mult: "   << setw(7) << fArrayMultiplicity
	 << " Hits: "   << setw(7) << fArrayHits 
	 << endl;

  if (opt.Contains("i")) {
    TIter nextI(&fSingle);
    BrSingle* o = 0;
    while((o = (BrSingle*)nextI())) 
      o->Print(option);
  }
  
  if (opt.Contains("r")) {
    TIter nextR(&fRing);
    BrRing* o = 0;
    while((o = (BrRing*)nextR())) 
      o->Print(option);
  }
}

//____________________________________________________________________
BrMultRdo::BrSingle* BrMultRdo::FindSingle(int id) const
{
  // Find the data object for single detector element with ID
  // number id.  Return 0, if not found
  TIter next(&fSingle);
  BrSingle* o = 0;
  while((o = (BrSingle*)next())) {
    if (o->GetId() == id)
      return o;
  }
  return 0;
}

//____________________________________________________________________
BrMultRdo::BrRing* BrMultRdo::FindRing(int id) const
{
  // Find the data object for ring detector element with ID
  // number id.  Return 0, if not found
  TIter next(&fRing);
  BrRing* o = 0;
  while((o = (BrRing*)next())) {
    if (o->GetId() == id)
      return o;
  }
  return 0;
}

//____________________________________________________________________
BrMultRdo::BrSingle* BrMultRdo::AddSingle(Short_t id,
					  Int_t   calAdc,
					  Float_t energy,
					  Float_t multiplicity,
					  Bool_t  isSaturated)
{
  Int_t idx = fSingle.GetLast()+1;
  return new(fSingle[idx]) BrSingle(id, calAdc, energy,
				    multiplicity, isSaturated);
}

//____________________________________________________________________
BrMultRdo::BrRing* BrMultRdo::AddRing(Short_t  id, 
				      Int_t    calAdc,
				      Float_t  energy,
				      Float_t  multiplicity,
				      Short_t  hits,
				      Float_t  eta)
{
  Int_t idx = fRing.GetLast()+1;
  return new(fRing[idx]) BrRing(id, calAdc, energy,
				multiplicity, hits, eta);
}


//____________________________________________________________________
Int_t BrMultRdo::GetSingleCalibratedAdc(Int_t i) const
{
  // Get calibrated ADC from single element i. Returns -1 if no
  // such element
  BrSingle* o = FindSingle(i);
  if (!o) 
    return -1;
  return o->GetCalibratedAdc();
}
//____________________________________________________________________
Float_t BrMultRdo::GetSingleEnergy(Int_t i)  const
{
  // Get energy from single element i. Returns -1 if no
  // such element
  BrSingle* o = FindSingle(i);
  if (!o) 
    return -1;
  return o->GetEnergy();
}
//____________________________________________________________________
Float_t BrMultRdo::GetSingleMultiplicity(Int_t i)  const
{
  // Get multiplicity from single element i. Returns -1 if no
  // such element
  BrSingle* o = FindSingle(i);
  if (!o) 
    return -1;
  return o->GetMultiplicity();
}
//____________________________________________________________________
Bool_t BrMultRdo::IsSingleSaturated(Int_t i)  const
{
  // Get saturation flag from single element i. Returns kFALSE if
  // no such element
  BrSingle* o = FindSingle(i);
  if (!o) 
    return kFALSE;
  return o->IsSaturated();
}
//____________________________________________________________________
Int_t BrMultRdo::GetRingCalibratedAdc(Int_t i) const
{
  // Get calibrated ADC from ring element i. Returns -1 if no
  // such element
  BrRing* o = FindRing(i);
  if (!o) 
    return -1;
  return o->GetCalibratedAdc();
}
//____________________________________________________________________
Float_t BrMultRdo::GetRingEnergy(Int_t i)  const
{
  // Get energy from ring element i. Returns -1 if no
  // such element
  BrRing* o = FindRing(i);
  if (!o) 
    return -1;
  return o->GetEnergy();
}
//____________________________________________________________________
Float_t BrMultRdo::GetRingMultiplicity(Int_t i)  const
{
  // Get multiplicity from ring element i. Returns -1 if no
  // such element
  BrRing* o = FindRing(i);
  if (!o) 
    return -1;
  return o->GetMultiplicity();
}
//____________________________________________________________________
Short_t BrMultRdo::GetRingHits(Int_t i)  const
{
  // Get no of hits from ring element i. Returns -1 if no
  // such element
  BrRing* o = FindRing(i);
  if (!o) 
    return -1;
  return o->GetHits();
}
//____________________________________________________________________
Float_t BrMultRdo::GetRingEta(Int_t i)  const
{
  // Get psuedo-rapidity from ring element i. Returns -1 if no
  // such element
  BrRing* o = FindRing(i);
  if (!o) 
    return -1;
  return o->GetEta();
}
//____________________________________________________________________
Float_t BrMultRdo::GetRingAvgEta(Int_t i)  const
{
  // Get Hijing weighted psuedo-rapidity from ring element i. Returns -1 if no
  // such element
  BrRing* o = FindRing(i);
  if (!o) 
    return -1;
  return o->GetAvgEta();
}
//____________________________________________________________________
Float_t BrMultRdo::GetRingdNdEta(Int_t i)  const
{
  // Get charged particle density for ring.  Returns -1 if no
  // such element
  BrRing* o = FindRing(i);
  if (!o) 
    return -1;
  return o->GetdNdEta();
}

//____________________________________________________________________
void BrMultRdo::SetSingleCalibratedAdc(Int_t i, Int_t x)
{
  // Set the calibrated ADC for single detector element i to x. 
  // Please notice, that this will create a new object in the array if
  // one does not exits already. 
  BrSingle* o = FindSingle(i);
  if (!o) 
    o = AddSingle(i, x);
  o->SetCalibratedAdc(x > 0 ? x : 0);
}   
//____________________________________________________________________
void BrMultRdo::SetSingleEnergy(Int_t i, Float_t x)
{
  // Set the energy for single detector element i to x. 
  // If no such element in the array exists, this method does
  // nothing. 
  BrSingle* o = FindSingle(i);
  if (!o) 
    return;
  o->SetEnergy(x > 0 ? x : 0);
}   
//____________________________________________________________________
void BrMultRdo::SetSingleMultiplicity(Int_t i, Float_t x)
{
  // Set the multiplicity for single detector element i to x. 
  // If no such element in the array exists, this method does
  // nothing. 
  BrSingle* o = FindSingle(i);
  if (!o) 
    return;
  o->SetMultiplicity(x > 0 ? x : 0);
}   
//____________________________________________________________________
void BrMultRdo::SetIsSingleSaturated(Int_t i, Bool_t x)
{
  // Set the saturation flag for single detector element i to x. 
  // If no such element in the array exists, this method does
  // nothing. 
  BrSingle* o = FindSingle(i);
  if (!o) 
    return;
  o->SetSaturated(x);
}   
//____________________________________________________________________
void BrMultRdo::SetRingCalibratedAdc(Int_t i, Int_t x)
{
  // Set the calibrated ADC for ring detector element i to x. 
  // Please notice, that this will create a new object in the array if
  // one does not exits already. 
  BrRing* o = FindRing(i);
  if (!o) 
    o = AddRing(i, x);
  o->SetCalibratedAdc(x > 0 ? x : 0);
}   
//____________________________________________________________________
void BrMultRdo::SetRingEnergy(Int_t i, Float_t x)
{
  // Set the energy for ring detector element i to x. 
  // If no such element in the array exists, this method does
  // nothing. 
  BrRing* o = FindRing(i);
  if (!o) 
    return;
  o->SetEnergy(x > 0 ? x : 0);
}   
//____________________________________________________________________
void BrMultRdo::SetRingMultiplicity(Int_t i, Float_t x)
{
  // Set the multiplicity for ring detector element i to x. 
  // If no such element in the array exists, this method does
  // nothing. 
  BrRing* o = FindRing(i);
  if (!o) 
    return;
  o->SetMultiplicity(x > 0 ? x : 0);
}   
//____________________________________________________________________
void BrMultRdo::SetRingHits(Int_t i, Int_t x)
{
  // Set the # hits for ring detector element i to x. 
  // If no such element in the array exists, this method does
  // nothing. 
  BrRing* o = FindRing(i);
  if (!o) 
    return;
  o->SetHits(x > 0 ? x : 0);
}   
//____________________________________________________________________
void BrMultRdo::SetRingEta(Int_t i, Float_t x)
{
  // Set the pseudo-rapidity for ring detector element i to x. 
  // If no such element in the array exists, this method does
  // nothing. 
  BrRing* o = FindRing(i);
  if (!o) 
    return;
  o->SetEta(x);
}   
//____________________________________________________________________
void BrMultRdo::SetRingAvgEta(Int_t i, Float_t x)
{
  // Set the hijing weighted pseudo-rapidity for ring detector 
  //  element i to x. 
  // If no such element in the array exists, this method does
  // nothing. 
  BrRing* o = FindRing(i);
  if (!o) 
    return;
  o->SetAvgEta(x);
}   
//____________________________________________________________________
void BrMultRdo::SetRingdNdEta(Int_t i, Float_t x)
{
  // Set calculated charged particle density for ring 
  //  
  // If no such element in the array exists, this method does
  // nothing. 
  BrRing* o = FindRing(i);
  if (!o) 
    return;
  o->SetdNdEta(x);
}   

//____________________________________________________________________
ClassImp(BrMultRdo::BrSingle);

//____________________________________________________________________
 BrMultRdo::BrSingle::BrSingle() 
{
  fId            = -1;
  fIsSaturated   = kFALSE;
  fCalibratedAdc = 0;
  fEnergy        = 0;
  fMultiplicity  = 0;
}

//____________________________________________________________________
 BrMultRdo::BrSingle::BrSingle(Short_t   id, 
			      Int_t   calAdc,
			      Float_t energy,
			      Float_t multiplicity,
			      Bool_t  isSaturated) 
{
  // Default constructor
  fId = id;
  fIsSaturated = isSaturated;
  SetCalibratedAdc(calAdc > 0 ? calAdc : 0);
  SetEnergy(energy > 0 ? energy : 0);
  SetMultiplicity(multiplicity > 0 ? multiplicity : 0);
}

//____________________________________________________________________
 void BrMultRdo::BrSingle::Clear() 
{
  // Clear this object 
  fId            = -1;
  fCalibratedAdc = 0;
  fEnergy        = 0;
  fMultiplicity  = 0;
  fIsSaturated   = kFALSE; 
}

//____________________________________________________________________
 void BrMultRdo::BrSingle::Print(Option_t* option) const
{
  // Print the data
  cout << " " << GetName() << " Single ID: " << setw(3) << fId 
       << " CalAdc: " << setw(7) << fCalibratedAdc
       << (fIsSaturated ? "(saturated)" : " ") 
       << " Energy: " << setw(8) << fEnergy
       << " Mult: "   << setw(8) << fMultiplicity << endl;
}

//____________________________________________________________________
 Int_t BrMultRdo::BrSingle::Compare(const TObject* o) const 
{
  // Compare by ID. 
  if (((BrMultRdo::BrSingle*)o)->GetId() > fId) 
    return -1;
  else if (((BrMultRdo::BrSingle*)o)->GetId() < fId) 
    return 1;
  return 0;
}


//____________________________________________________________________
ClassImp(BrMultRdo::BrRing);

//____________________________________________________________________
BrMultRdo::BrRing::BrRing() 
{
  fId                     = -1;
  fCalibratedAdc          = 0;
  fEnergy                 = 0;
  fMultiplicity           = 0;
  fHits                   = 0;
  fEta                    = 0;
}

//____________________________________________________________________
BrMultRdo::BrRing::BrRing(Short_t id, 
			  Int_t   calAdc,
			  Float_t energy,
			  Float_t multiplicity,
			  Short_t hits,
			  Float_t eta) 
{
  // Default constructor
  fId = id; 
  fEta = eta;
  SetCalibratedAdc(calAdc > 0 ? calAdc : 0);
  SetEnergy(energy > 0 ? energy : 0);
  SetMultiplicity(multiplicity > 0 ? multiplicity : 0);
  SetHits(hits > 0 ? hits : 0);
}

//____________________________________________________________________
void BrMultRdo::BrRing::Clear() 
{
  // Clear this object 
  fId            = -1;
  fCalibratedAdc = 0;
  fEnergy        = 0;
  fMultiplicity  = 0;
  fEta           = 0;
  fHits          = 0;
}

//____________________________________________________________________
void BrMultRdo::BrRing::Print(Option_t* option) const
{
  // Print the data
  cout << " " << GetName() << "   Ring ID: " << setw(3) << fId 
       << " CalAdc: " << setw(7) << fCalibratedAdc
       << " Energy: " << setw(8) << fEnergy
       << " Mult: "   << setw(8) << fMultiplicity 
       << " Eta:  "   << setw(8) << fEta 
       << " Hits: "   << setw(2) << fHits 
       << endl;
}

//____________________________________________________________________
Int_t BrMultRdo::BrRing::Compare(const TObject* o) const 
{
  // Compare by ID. 
  if (((BrMultRdo::BrRing*)o)->GetId() > fId) 
    return -1;
  else if (((BrMultRdo::BrRing*)o)->GetId() < fId) 
    return 1;
  return 0;
}
//____________________________________________________________________
//
// $Log: BrMultRdo.cxx,v $
// Revision 1.4  2001/11/24 15:45:19  sanders
// Added ring dNdEta and HIJING weighted eta values to data structure.
// Bumped ClassDef to 2.
//
// Revision 1.3  2001/08/10 14:06:49  cholm
// Fix to allow putting theses on branch in a new TTree - thanks Rene
//
// Revision 1.2  2001/06/25 14:31:11  cholm
// Made Print conform to TObject
//
// Revision 1.1.1.1  2001/06/21 14:55:02  hagel
// Initial revision of brat2
//
// Revision 1.4  2001/06/01 15:49:13  cholm
// Fix of some default values from -1 to zero (gave bad results)
// BrSiCalibration had a bug in returning the correction function.
// Tile|Rdo modules had some minor bugs, and I did some improvments
// Mult Rdo module had some serious bugs, but should be ok now.
// BrMultRdo is fixed a lot too.
//
// Revision 1.3  2001/05/31 01:46:06  cholm
// Second rewamp of this directory.  All RDO modules use the common
// BrMultRdoModule, and they both write BrMultRdo Objects.  Also introduced
// ABC for Br[Tile|Si][Parameters|Calibration] since they have a lot in common,
// and the code can be made more efficient this way.
//
// A possible further thing to do, is to make an ABC for the CentModules, and
// the corresponding calibration modules, since they are very VERY similar.
// However, the current module BrMultCentModule is in the way.  Need to talk
// to Steve about that.
//
// Revision 1.2  2001/05/23 12:31:28  cholm
// Now compiles, and is almost done. Not used yet
//
// Revision 1.1  2001/05/17 11:18:36  cholm
// Added class BrMultRdo for data storage from Br[Tile|Si]RdoModule. Still developing
//
//

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