er  dev
cls_RootEvent.cxx
1 #include "cls_RootEvent.h"
2 
3 #include <TClonesArray.h>
4 
5 #include "cls_RootHit.h"
6 
7 ClassImp(cls_RootEvent)
8 
10  fNumOfHits(0),
11  fEventID(0)
12 {
13  fHits = new TClonesArray("cls_RootHit", 5);
14 }
15 
16 cls_RootEvent::~cls_RootEvent()
17 {
18  Clear();
19 }
20 
21 void cls_RootEvent::Clear(Option_t * /*option*/)
22 {
23  fHits->Clear("C");
24  fNumOfHits = 0; // Hakuna Matata
25 }
26 
27 /* https://root.cern.ch/root/htmldoc/guides/users-guide/Trees.html#example-4-a-tree-with-an-event-class
28  * Section 14.17
29  */
30 cls_RootHit* cls_RootEvent::AddHit(cls_RootHit* p_sourceHit)
31 {
32  TClonesArray &hits = *fHits;
33  cls_RootHit *hit = new(hits[fNumOfHits++]) cls_RootHit(p_sourceHit);
34  return hit;
35 }
36 
37 cls_RootHit* cls_RootEvent::AddHit(ULong64_t p_ts, UChar_t p_ch, UShort_t p_rawAdc, Int_t p_adc, Float_t p_adcCalib)
38 {
39  TClonesArray &hits = *fHits;
40  cls_RootHit *hit = new(hits[fNumOfHits++]) cls_RootHit(p_ts, p_ch, p_rawAdc, p_adc, p_adcCalib);
41  return hit;
42 }