StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StMcRichHitCollection.cc
1 /***************************************************************************
2  *
3  * $Id: StMcRichHitCollection.cc,v 2.3 2012/03/01 16:48:29 perev Exp $
4  *
5  * Author: Manuel Calderon de la Barca Sanchez, March 2000
6  ***************************************************************************
7  *
8  * Description: Container for StMcRichHit
9  *
10  ***************************************************************************
11  *
12  * $Log: StMcRichHitCollection.cc,v $
13  * Revision 2.3 2012/03/01 16:48:29 perev
14  * method Browse() added
15  *
16  * Revision 2.2 2005/01/27 23:40:47 calderon
17  * Adding persistency to StMcEvent as a step for Virtual MonteCarlo.
18  *
19  * Revision 2.1 2000/03/06 18:05:21 calderon
20  * 1) Modified SVT Hits storage scheme from layer-ladder-wafer to
21  * barrel-ladder-wafer.
22  * 2) Added Rich Hit class and collection, and links to them in other
23  * classes.
24  *
25  *
26  **************************************************************************/
27 #include "TBrowser.h"
28 #include "StMcRichHitCollection.hh"
29 #include "StMcRichHit.hh"
30 
31 static const char rcsid[] = "$Id: StMcRichHitCollection.cc,v 2.3 2012/03/01 16:48:29 perev Exp $";
32 ClassImp(StMcRichHitCollection);
33 //_____________________________________________________________________________
34 StMcRichHitCollection::StMcRichHitCollection()
35 {
36 }
37 
38 //_____________________________________________________________________________
39 StMcRichHitCollection::~StMcRichHitCollection()
40 {
41  // StMcRichHit provides its own new/delete operator, and
42  // mHits is a polymorphic container, so we need to do this.
43  Clear();
44 }
45 
46 //_____________________________________________________________________________
47 bool StMcRichHitCollection::addHit(StMcRichHit* hit)
48 {
49  if (!hit) return false;
50  mHits.push_back(hit);
51  return true;
52 }
53 
54 //_____________________________________________________________________________
55 unsigned long StMcRichHitCollection::numberOfHits() const
56 {
57  return mHits.size();
58 }
59 
60 //_____________________________________________________________________________
61 const StSPtrVecMcRichHit& StMcRichHitCollection::hits() const { return mHits; }
62 
63 StSPtrVecMcRichHit& StMcRichHitCollection::hits() { return mHits; }
64 //_____________________________________________________________________________
65 void StMcRichHitCollection::Clear(const char*)
66 {
67  for (int i=0; i<(int)mHits.size(); i++)
68  {
69  delete mHits[i]; mHits[i] = 0;
70  }
71  mHits.clear();
72 }
73 //_____________________________________________________________________________
74 void StMcRichHitCollection::Browse(TBrowser *b)
75 {
76  // Browse this event (called by TBrowser).
77  for (int i=0; i<(int)mHits.size(); i++) {
78  TObject *obj = mHits[i]; if (!obj) continue;
79  TString ts(obj->GetName()); ts+="#"; ts+=i;
80  b->Add(obj,ts.Data());
81  }
82 }