CMS 3D CMS Logo

RootChamberReader Class Reference

#include <SimMuon/Neutron/src/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.

00008 : theTree(0),
00009   theHits(0),
00010   thePosition(0),
00011   theSize(0)
00012 {
00013 }

RootChamberReader::RootChamberReader ( TFile *  file,
const std::string &  treeName 
)

Definition at line 16 of file RootChamberReader.cc.

References theHits, theSize, and theTree.

00017 : theTree( (TTree *) file->Get(treeName.c_str()) ),
00018   theHits(new TClonesArray("RootSimHit")),
00019   thePosition(-1),
00020   theSize(0)
00021 {
00022   if(theTree != 0) 
00023   {
00024     theTree->SetBranchAddress("Hits", &theHits);
00025     theSize = theTree->GetEntries();
00026   }
00027 }

RootChamberReader::~RootChamberReader (  ) 

writes the tree, and deletes everything

Definition at line 30 of file RootChamberReader.cc.

00031 {
00032 //  delete theHits;
00033 //  delete theTree;
00034 }


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().

00038 {
00039   // if there's no tree, make no events
00040   if(theTree != 0 && theSize != 0)
00041   {
00042     ++thePosition;
00043     // start again from the beginning, if needed
00044     if(thePosition >= theSize) thePosition = 0;
00045     theTree->GetEntry(thePosition);
00046 
00047     TIter next(theHits);
00048     RootSimHit * rootHit;
00049     while( (rootHit = (RootSimHit *) next()) )
00050     {
00051       hits.push_back(rootHit->get());
00052     }
00053     LogTrace("Neutrons") << "Event " << thePosition << " OF " << theSize 
00054          << " has " << hits.size() << " hits ";
00055   }
00056 }


Member Data Documentation

TClonesArray* RootChamberReader::theHits [private]

Definition at line 21 of file RootChamberReader.h.

Referenced by read(), and RootChamberReader().

int RootChamberReader::thePosition [private]

Definition at line 22 of file RootChamberReader.h.

Referenced by read().

int RootChamberReader::theSize [private]

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().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:30:53 2009 for CMSSW by  doxygen 1.5.4