StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StMcMtdHitCollection.cc
1 /***************************************************************************
2  *
3  * $Id: StMcMtdHitCollection.cc,v 2.2 2012/03/01 16:48:29 perev Exp $
4  * $Log: StMcMtdHitCollection.cc,v $
5  * Revision 2.2 2012/03/01 16:48:29 perev
6  * method Browse() added
7  *
8  * Revision 2.1 2011/10/11 16:22:39 perev
9  * Add Mtd
10  *
11  *
12  *
13  */
14 #include "TBrowser.h"
15 #include "StMcMtdHitCollection.hh"
16 #include "StMcMtdHit.hh"
17 #include <cassert>
18 
19 static const char rcsid[] = "$Id: StMcMtdHitCollection.cc,v 2.2 2012/03/01 16:48:29 perev Exp $";
20 
21 ClassImp(StMcMtdHitCollection);
22 //_____________________________________________________________________________
23 StMcMtdHitCollection::StMcMtdHitCollection()
24 {
25 }
26 
27 //_____________________________________________________________________________
28 StMcMtdHitCollection::~StMcMtdHitCollection()
29 {
30  Clear();
31 }
32 
33 
34 //_____________________________________________________________________________
35 bool StMcMtdHitCollection::addHit(StMcMtdHit* hit)
36 {
37  assert(hit && "Zero hit pointer added");
38  mHits.push_back(hit);
39  return true;
40 }
41 //_____________________________________________________________________________
42 void StMcMtdHitCollection::Clear(const char*)
43 {
44  for (int i=0; i<(int)mHits.size(); i++)
45  {
46  delete mHits[i]; mHits[i] = 0;
47  }
48  mHits.clear();
49 }
50 //_____________________________________________________________________________
51 void StMcMtdHitCollection::Browse(TBrowser *b)
52 {
53  // Browse this event (called by TBrowser).
54  for (int i=0; i<(int)mHits.size(); i++) {
55  TObject *obj = mHits[i]; if (!obj) continue;
56  TString ts(obj->GetName()); ts+="#"; ts+=i;
57  b->Add(obj,ts.Data());
58  }
59 }
60 //_____________________________________________________________________________
61 unsigned long StMcMtdHitCollection::numberOfHits() const
62 {
63  return mHits.size();
64 }
65 
66 //_____________________________________________________________________________
67 const StSPtrVecMcMtdHit& StMcMtdHitCollection::hits() const { return mHits; }
68 
69 //_____________________________________________________________________________
70 StSPtrVecMcMtdHit& StMcMtdHitCollection::hits() { return mHits; }
71 
72 //______________________________________________________________________________
73 //______________________________________________________________________________