StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StMcCtbHitCollection.cc
1 /***************************************************************************
2  *
3  * $Id: StMcCtbHitCollection.cc,v 2.3 2012/03/01 16:48:29 perev Exp $
4  * $Log: StMcCtbHitCollection.cc,v $
5  * Revision 2.3 2012/03/01 16:48:29 perev
6  * method Browse() added
7  *
8  * Revision 2.2 2005/01/27 23:40:46 calderon
9  * Adding persistency to StMcEvent as a step for Virtual MonteCarlo.
10  *
11  * Revision 2.1 2003/02/19 03:29:42 calderon
12  * Introduction of CTB classes to repository.
13  *
14  * Revision 1.0 2003/03/18 00:00:00 gans
15  * Introduction of Ctb classes. Modified several classes
16  * accordingly.
17  */
18 #include "TBrowser.h"
19 #include "StMcCtbHitCollection.hh"
20 #include "StMcCtbHit.hh"
21 
22 static const char rcsid[] = "$Id: StMcCtbHitCollection.cc,v 2.3 2012/03/01 16:48:29 perev Exp $";
23 ClassImp(StMcCtbHitCollection)
24 //_____________________________________________________________________________
26 {
27 }
28 
29 //_____________________________________________________________________________
30 StMcCtbHitCollection::~StMcCtbHitCollection()
31 {
32  // StMcCtbHit provides its own new/delete operator, and
33  // mHits is a polymorphic container, so we need to do this.
34  Clear();
35 }
36 
37 //_____________________________________________________________________________
38 unsigned long
39 StMcCtbHitCollection::numberOfHits() const
40 {
41  return mHits.size();
42 }
43 
44 //_____________________________________________________________________________
45 const StSPtrVecMcCtbHit&
46 StMcCtbHitCollection::hits() const { return mHits; }
47 
48 //_____________________________________________________________________________
49 StSPtrVecMcCtbHit& StMcCtbHitCollection::hits() { return mHits; }
50 //_____________________________________________________________________________
51 bool StMcCtbHitCollection::addHit(StMcCtbHit* hit)
52 {
53  assert(hit && "Zero hit pointer added");
54  mHits.push_back(hit);
55  return true;
56 }
57 //_____________________________________________________________________________
58 void StMcCtbHitCollection::Clear(const char*)
59 {
60  for (int i=0; i<(int)mHits.size(); i++)
61  {
62  delete mHits[i]; mHits[i] = 0;
63  }
64  mHits.clear();
65 }
66 //_____________________________________________________________________________
67 void StMcCtbHitCollection::Browse(TBrowser *b)
68 {
69  // Browse this event (called by TBrowser).
70  for (int i=0; i<(int)mHits.size(); i++) {
71  TObject *obj = mHits[i]; if (!obj) continue;
72  TString ts(obj->GetName()); ts+="#"; ts+=i;
73  b->Add(obj,ts.Data());
74  }
75 }