// Author: Andrew M. Rogers, NSCL 07/01/2006
//* Copyright (C) 2006-2008 Andrew M. Rogers

#include <stdio.h>
#include <iostream>
#include <fstream>

#include <TTree.h>

#include "TCsI.h"


ClassImp(TCsI);

//////////////////////////////////////////////////////////////////////////
//                                                                      //
// TCsI                                                                 //
//                                                                      //
// A TCsI class derives from TObject.  This Class provides the          //
// structure for the CsI crystal in the HiRA device.  Raw event data is //
// filled as branches on the THiRA tree.                                //
//                                                                      //
//////////////////////////////////////////////////////////////////////////


//______________________________________________________________________________
TCsI::TCsI(const TCsI &CsI) : TObject(CsI)
{
  // -- Copy constructor.
  
  ((TCsI&)CsI).Copy(*this);
//   this->fName  = p.fName;
//   this->fTitle = p.fTitle;
  
//   for(Int_t i=0; i<THIRA_CSI_CHANNELS; i++) this->fPos[i] = p.fPos[i];
    
}


//______________________________________________________________________________
void TCsI::Copy(TObject &CsI) const
{
  // -- Copy this method.
  
  TObject::Copy((TObject&)CsI);
  ((TCsI&)CsI).fName    = fName;
  ((TCsI&)CsI).fTitle   = fTitle;
  ((TCsI&)CsI).fAddRndm = fAddRndm;
  for(Int_t i=0; i<THIRA_CSI_CHANNELS; i++){
    ((TCsI&)CsI).fPos[i]    = fPos[i];
    ((TCsI&)CsI).fSegVec[i] = fSegVec[i];}

  ((TCsI&)CsI).Clear();
}


//______________________________________________________________________________
void TCsI::Calculate()
{
  // --

}


//______________________________________________________________________________
void TCsI::Calibrate()
{
  // --

}


//______________________________________________________________________________
void TCsI::Clear(Option_t *)
{
  // -- Clear data members.
  //

  memset(ERaw,'\0',sizeof(ERaw));
  memset(E,'\0',sizeof(E));

  Emax    = 0;
  Emaxch  = 99;
  E2max   = 0;
  E2maxch = 99;
  rawMult = 0;

}


//______________________________________________________________________________
Int_t TCsI::GetEntry(Long64_t entry,Int_t getall)
{ 
  // -- Read all branches in this class of entry and return total number of bytes read.
  //
  //     getall = 0 : get only active branches
  //     getall = 1 : get all branches
  //

  Int_t getBytes=0;
  
  getBytes += b_ERaw->GetEntry(entry,getall);
  getBytes += b_E->GetEntry(entry,getall);
  getBytes += b_Emax->GetEntry(entry,getall);
  getBytes += b_Emaxch->GetEntry(entry,getall);
  getBytes += b_E2max->GetEntry(entry,getall);
  getBytes += b_E2maxch->GetEntry(entry,getall);
  getBytes += b_rawMult->GetEntry(entry,getall);

  return getBytes;
}


//______________________________________________________________________________
void TCsI::InitClass(TString name)
{
  // --
  //

  SetName(name);

  fAddRndm = kFALSE;

  for(int i=0; i<THIRA_CSI_CHANNELS; i++){
    ERaw[i] = 0;
    E[i]    = 0;
    E2[i]   = 0;
    fPos[i] = i;
  }

  Emax    = 0;
  Emaxch  = 99;
  E2max   = 0;
  E2maxch = 99;
  rawMult = 0;
}


//______________________________________________________________________________
void TCsI::InitTree(TTree *tree)
{
  // --

  TString bName(fName);
  fChain   = tree;
  fCurrent = -1;
  #ifdef TESTING
  // Set the trees into compatiblity mode so that we can read individual branches.
  fChain->SetMakeClass(1);
  #endif
//   if(strstr(fChain->GetName(),"Cal")!=0){
//     bName = "E02023."+bName;
//     fChain->GetTree()->GetFriend("E02023")->SetMakeClass(1);
//     cout << "Calibrated Tree " << bName << endl;
//   }

  b_ERaw = fChain->GetBranch(fName + ".ERaw[4]");
  b_E    = fChain->GetBranch(fName + ".E[4]");
  b_E2   = fChain->GetBranch(fName + ".E2[4]");
  
  b_Emax    = fChain->GetBranch(fName + ".Emax");
  b_Emaxch  = fChain->GetBranch(fName + ".Emaxch");
  b_E2max   = fChain->GetBranch(fName + ".E2max");
  b_E2maxch = fChain->GetBranch(fName + ".E2maxch");
  b_rawMult = fChain->GetBranch(fName + ".rawMult");

//   fChain->SetBranchAddress(bName + ".ERaw[4]",&ERaw,&b_ERaw);
//   fChain->SetBranchAddress(fName + ".E[4]",&E,&b_E);

//   fChain->SetBranchAddress(bName + ".Emax",&Emax,&b_Emax);
//   fChain->SetBranchAddress(bName + ".Emaxch",&Emaxch,&b_Emaxch);
//   fChain->SetBranchAddress(bName + ".rawMult",&rawMult,&b_rawMult);
}


//______________________________________________________________________________
Bool_t TCsI::IsBad(Int_t segment)
{
  // -- Check if the segment is marked as "bad".
  //

  if(fBadSegs[segment]==1) return kTRUE;
  return kFALSE;
}


//______________________________________________________________________________
void TCsI::SetBad(Int_t segment, Int_t bitValue)
{
  // --
  //

  if((bitValue==0 || bitValue==1) && (segment>=0 && segment<THIRA_SI_CHANNELS)) fBadSegs.set(segment,bitValue);
  else if(segment==99) ; // Do nothing
  else if(segment<0 || segment>=THIRA_SI_CHANNELS) printf("* ERROR:  Invalid segment!!!\n");
  else printf("* ERROR:  Invalid bitValue!!!\n");
}


//______________________________________________________________________________
void TCsI::SetName(const Char_t *name)
{
  // -- Change (i.e. set) the name of the TCsI.
  //

  fName = name;
}

//______________________________________________________________________________
void TCsI::SetNameTitle(const Char_t *name, const Char_t *title)
{
  // -- Change (i.e. set) all the TCsI parameters (name and title).
  //

  fName  = name;
  fTitle = title;
}

//______________________________________________________________________________
void TCsI::SetTitle(const Char_t *title)
{
  // -- Change (i.e. set) the title of the TCsI.
  //

  fTitle = title;
}


Last change: Sun Dec 21 12:38:45 2008
Last generated: 2008-12-21 12:38

This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.