HYDRA_development_version
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
hrichcalsim.cc
Go to the documentation of this file.
1 //////////////////////////////////////////////////////////////////////////////
2 //
3 // $Id: $
4 //
5 //*-- Author : RICH team member
6 //*-- Revised : Martin Jurkovic <martin.jurkovic@ph.tum.de> 2010
7 //
8 //_HADES_CLASS_DESCRIPTION
9 //////////////////////////////////////////////////////////////////////////////
10 //
11 // HRichCalSim
12 //
13 // cal class for simulated data.
14 // contains OLD RICH :
15 // fTrackIds[0]+fTrackIds[1] : index1-index2 range in HRichTrack category (indexes of the first and last track numbers)
16 // fNofTracks = 2;
17 // fEnergy = average energy of the photon hit per track
18 //
19 // RICH700:
20 // fTrackIds[10] : Geant track IDS
21 // fNofTracks = number of trackIDs
22 // fEnergy = 0;
23 //
24 // isNewRich() returns kTRUE when filled by HRich700Digitizer
25 //
26 //////////////////////////////////////////////////////////////////////////////
27 
28 
29 #include "hrichcalsim.h"
30 
31 #include "TBuffer.h"
32 
34 
36  HRichCal(),
37  fNofTracks(0),
38  fEnergy(0),
39  fCt(0)
40 {
41  initTrackIds();
42 }
43 
45 HRichCal(ch),
46 fNofTracks(0),
47 fEnergy(0),
48 fCt(0)
49 {
50  initTrackIds();
51 }
52 
53 HRichCalSim::HRichCalSim(Int_t s, Int_t r, Int_t c):
54 HRichCal(s, c, r),
55 fNofTracks(0),
56 fEnergy(0),
57 fCt(0)
58 {
59  initTrackIds();
60 }
61 
63 {
64  for (Int_t i = 0; i < NMAXTRACKS; i++) {
65  fTrackIds[i] = -1;
66  }
67 }
68 
69 Bool_t HRichCalSim::checkTrackId(Int_t trackId)
70 {
71  // check that trackId is not added
72  // kTRUE : track is already in the list of tracks
73  // kFALSE : track is not in the list of tracks
74  for (Int_t i = 0; i < fNofTracks; i++) {
75  if (fTrackIds[i] == trackId) return kTRUE;
76  }
77  return kFALSE;
78 }
79 
80 void HRichCalSim::addTrackId(Int_t trackId)
81 {
82  // store trackId for one richCal
83  // use checkTrackId(Int_t trackId) to cekc if the
84  // track is in the list of tracks already
85  for (Int_t i = 0; i < fNofTracks; i++) {
86  if (fTrackIds[i] == trackId) return;
87  }
88  if (fNofTracks >= NMAXTRACKS) return;
89  fTrackIds[fNofTracks] = trackId;
90  fNofTracks++;
91 }
92 
93 
94 Int_t HRichCalSim::getTrackId(Int_t index)
95 {
96  if (index >= fNofTracks || index < 0 ) return -1;
97  return fTrackIds[index];
98 }
99 
100 
101 void HRichCalSim::Streamer(TBuffer &R__b)
102 {
103  // Stream an object of class HRichCalSim.
104 
105  UInt_t R__s, R__c;
106  if (R__b.IsReading()) {
107  Version_t R__v = R__b.ReadVersion(&R__s, &R__c); if (R__v) { }
108  HRichCal::Streamer(R__b);
109 
110  if(R__v > 1){ // RICH700 format
111  R__b.ReadStaticArray((int*)fTrackIds);
112  R__b >> fNofTracks;
113  } else {
114  initTrackIds() ;
115  fNofTracks = 0;
116  }
117  if(R__v == 1){ // RICH format
118  Int_t fTrack1;
119  Int_t fTrack2;
120 
121  R__b >> fTrack1;
122  R__b >> fTrack2;
123 
124  fTrackIds[0] = fTrack1;
125  fTrackIds[1] = fTrack2;
126  fNofTracks = 2;
127  }
128  R__b >> fEnergy;
129 
130 
131  R__b.CheckByteCount(R__s, R__c, HRichCalSim::IsA());
132  } else {
133  R__c = R__b.WriteVersion(HRichCalSim::IsA(), kTRUE);
134  HRichCal::Streamer(R__b);
135  R__b.WriteArray(fTrackIds, NMAXTRACKS);
136  R__b << fNofTracks;
137  R__b << fEnergy;
138  R__b.SetByteCount(R__c, kTRUE);
139  }
140 }
141 
142 
143 
ClassImp(HRichCalSim) HRichCalSim
Definition: hrichcalsim.cc:33
Float_t fEnergy
Definition: hrichcalsim.h:30
Int_t getTrackId(Int_t index)
Definition: hrichcalsim.cc:94
#define NMAXTRACKS
Definition: hrichcalsim.h:23
void addTrackId(Int_t trackId)
Definition: hrichcalsim.cc:80
Int_t fTrackIds[NMAXTRACKS]
Definition: hrichcalsim.h:28
Int_t fNofTracks
Definition: hrichcalsim.h:29
Bool_t checkTrackId(Int_t trackId)
Definition: hrichcalsim.cc:69
void initTrackIds()
tmp counter for HRichDigitizer
Definition: hrichcalsim.cc:62