QwAnalysis
QwHitRootContainer.cc
Go to the documentation of this file.
1 #include "QwHitRootContainer.h"
3 
4 // Initialize the static list of QwHits
5 TClonesArray *QwHitRootContainer::gQwHits = 0;
6 
7 // Constructor
9 {
10  // Create the static TClonesArray if not existing yet
11  if (! gQwHits) gQwHits = new TClonesArray("QwHit", 100000);
12  // Set local TClonesArray to static TClonesArray and zero hits
13  fQwHits = gQwHits;
14  fQwHits->Clear();
15 }
16 
17 // Destructor
19 {
20  // Delete the static TClonesArray
21  Reset();
22  // Set local TClonesArray to null
23  fQwHits = 0;
24 }
25 
26 // Clear the local TClonesArray
27 void QwHitRootContainer::Clear(Option_t *option)
28 {
29  fQwHits->Clear(option);
30  fNQwHits = 0;
31 }
32 
33 void QwHitRootContainer::Delete(Option_t *option)
34 {
35  fQwHits->Delete(option);
36  fNQwHits = 0;
37 }
38 
39 // Delete the static TClonesArray
40 void QwHitRootContainer::Reset(Option_t *option)
41 {
42  delete gQwHits;
43  gQwHits = 0;
44 }
45 
46 // Add an existing QwHit
48 {
49  TClonesArray &hits = *fQwHits;
50  QwHit *newhit = new (hits[fNQwHits++]) QwHit();
51  *newhit = *hit;
52 }
53 
55 {
56  TClonesArray &hits = *fQwHits;
57  new (hits[fNQwHits++]) QwHit(in);
58  return;
59 }
60 
61 // Convert from a QwHitContainer hitlist to the TOrdCollection
63 {
64  Clear();
65  for (QwHitContainer::iterator hit = hitlist->begin(); hit != hitlist->end(); hit++)
66  {
67  QwHit* p = &(*hit);
68  AddHit(p);
69  }
70 }
71 
73 {
74  // Save current Object count
75  // Int_t ObjectNumber = TProcessID::GetObjectCount();
76  Clear();
77  QwHitContainer::iterator hititerator;
78  for (hititerator = hitcontainer.begin(); hititerator != hitcontainer.end(); hititerator++)
79  {
80  AddQwHit(*hititerator);
81  }
82  // TProcessID::SetObjectCount(ObjectNumber);
83  return;
84 }
85 
86 // Convert from this TOrdCollection to a QwHitContainer hitlist
88 {
89  QwHitContainer* hitlist = new QwHitContainer();
90  TIterator* iterator = fQwHits->MakeIterator();
91  QwHit* hit = 0;
92  while ((hit = dynamic_cast<QwHit*>(iterator->Next())))
93  hitlist->push_back(*hit);
94  return hitlist;
95 }
96 
97 // Print the TOrdCollection hitlist
98 void QwHitRootContainer::Print(Option_t* option) const
99 {
100  TIterator* iterator = fQwHits->MakeIterator();
101  QwHit* hit = 0;
102  while ((hit = dynamic_cast<QwHit*>(iterator->Next())))
103  std::cout << *hit << std::endl;
104 }
105 
107 {
108  return dynamic_cast<QwHit*>(fQwHits->At(hit));
109 }
QwHit * GetHit(Int_t hitID) const
void Clear(Option_t *option="")
void Print(Option_t *option="") const
static const double in
Definition: QwUnits.h:66
static TClonesArray * gQwHits
void Build(QwHitContainer &hitcontainer)
void Delete(Option_t *option="")
void Reset(Option_t *option="")
Int_t fNQwHits
Number of QwHits in the array.
QwHitContainer * Convert() const
QwHitRootContainer()
///&lt; Static array of QwHits
TClonesArray * fQwHits
Array of QwHits.
ClassImp(QwF1TDC)
Hit structure uniquely defining each hit.
Definition: QwHit.h:43
void AddQwHit(QwHit &in)