StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StMcBTofHitCollection.cc
1 /***************************************************************************
2  *
3  * $Id: StMcBTofHitCollection.cc,v 2.3 2012/03/01 16:48:29 perev Exp $
4  * $Log: StMcBTofHitCollection.cc,v $
5  * Revision 2.3 2012/03/01 16:48:29 perev
6  * method Browse() added
7  *
8  * Revision 2.2 2009/08/25 20:57:54 fine
9  * fix the compilation issues under SL5_64_bits gcc 4.3.2
10  *
11  * Revision 2.1 2009/07/24 19:08:05 perev
12  * Cleanup + Btof added (Geurts)
13  *
14  *
15  */
16 #include "TBrowser.h"
17 #include "StMcBTofHitCollection.hh"
18 #include "StMcBTofHit.hh"
19 #include <cassert>
20 
21 static const char rcsid[] = "$Id: StMcBTofHitCollection.cc,v 2.3 2012/03/01 16:48:29 perev Exp $";
22 
23 //_____________________________________________________________________________
24 ClassImp(StMcBTofHitCollection);
25 //_____________________________________________________________________________
26 StMcBTofHitCollection::StMcBTofHitCollection()
27 {
28 }
29 
30 //_____________________________________________________________________________
31 StMcBTofHitCollection::~StMcBTofHitCollection()
32 {
33  // StMcTofHit provides its own new/delete operator, and
34  // mHits is a polymorphic container, so we need to do this.
35  Clear();
36 }
37 
38 //_____________________________________________________________________________
39 bool StMcBTofHitCollection::addHit(StMcBTofHit* hit)
40 {
41  assert(hit && "Zero hit pointer added");
42  mHits.push_back(hit);
43  return true;
44 }
45 
46 //_____________________________________________________________________________
47 unsigned long StMcBTofHitCollection::numberOfHits() const
48 {
49  return mHits.size();
50 }
51 
52 //_____________________________________________________________________________
53 const StSPtrVecMcBTofHit& StMcBTofHitCollection::hits() const { return mHits; }
54 
55 //_____________________________________________________________________________
56 StSPtrVecMcBTofHit& StMcBTofHitCollection::hits() { return mHits; }
57 //_____________________________________________________________________________
58 void StMcBTofHitCollection::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 StMcBTofHitCollection::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 }