CMS 3D CMS Logo

Public Member Functions | Private Attributes

RootChamberReader Class Reference

#include <RootChamberReader.h>

List of all members.

Public Member Functions

void read (edm::PSimHitContainer &hits)
 RootChamberReader (TFile *file, const std::string &treeName)
 RootChamberReader ()
 default ctor, for STL
 ~RootChamberReader ()
 writes the tree, and deletes everything

Private Attributes

TClonesArray * theHits
int thePosition
int theSize
TTree * theTree

Detailed Description

Definition at line 8 of file RootChamberReader.h.


Constructor & Destructor Documentation

RootChamberReader::RootChamberReader ( )

default ctor, for STL

Definition at line 7 of file RootChamberReader.cc.

: theTree(0),
  theHits(0),
  thePosition(0),
  theSize(0)
{
}
RootChamberReader::RootChamberReader ( TFile *  file,
const std::string &  treeName 
)

Definition at line 16 of file RootChamberReader.cc.

References theHits, theSize, and theTree.

: theTree( (TTree *) file->Get(treeName.c_str()) ),
  theHits(new TClonesArray("RootSimHit")),
  thePosition(-1),
  theSize(0)
{
  if(theTree != 0) 
  {
    theTree->SetBranchAddress("Hits", &theHits);
    theSize = theTree->GetEntries();
  }
}
RootChamberReader::~RootChamberReader ( )

writes the tree, and deletes everything

Definition at line 30 of file RootChamberReader.cc.

{
//  delete theHits;
//  delete theTree;
}

Member Function Documentation

void RootChamberReader::read ( edm::PSimHitContainer hits)

Definition at line 37 of file RootChamberReader.cc.

References RootSimHit::get(), LogTrace, theHits, thePosition, theSize, and theTree.

Referenced by RootNeutronReader::readNextEvent().

{
  // if there's no tree, make no events
  if(theTree != 0 && theSize != 0)
  {
    ++thePosition;
    // start again from the beginning, if needed
    if(thePosition >= theSize) thePosition = 0;
    theTree->GetEntry(thePosition);

    TIter next(theHits);
    RootSimHit * rootHit;
    while( (rootHit = (RootSimHit *) next()) )
    {
      hits.push_back(rootHit->get());
    }
    LogTrace("Neutrons") << "Event " << thePosition << " OF " << theSize 
         << " has " << hits.size() << " hits ";
  }
}

Member Data Documentation

TClonesArray* RootChamberReader::theHits [private]

Definition at line 21 of file RootChamberReader.h.

Referenced by read(), and RootChamberReader().

Definition at line 22 of file RootChamberReader.h.

Referenced by read().

Definition at line 23 of file RootChamberReader.h.

Referenced by read(), and RootChamberReader().

TTree* RootChamberReader::theTree [private]

Definition at line 20 of file RootChamberReader.h.

Referenced by read(), and RootChamberReader().