SToGS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
SToGS_BaseROOTEvents.C
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 //
27 
28 #include "SToGS_BaseROOTEvents.h"
29 #include "TClass.h"
30 
36 
37 SBRHit::SBRHit() : TObject(),
38  fE(0.0),
39  fPDG(-1),
40  fX(0.0),
41  fY(0.0),
42  fZ(0.0),
43  fT(0.0),
44  fFlag(0),
45  fUID(-1)
46 {
47  SBRHit::Class()->IgnoreTObjectStreamer();
48  Clear("");
49 
50  // printf("Const \n");
51 }
52 
53 SBRHit::SBRHit(const SBRHit &sbrhit) : TObject((TObject &)sbrhit)
54 {
55  fE = sbrhit.fE;
56  fPDG = sbrhit.fPDG;
57  fX = sbrhit.fX;
58  fY = sbrhit.fY;
59  fZ = sbrhit.fZ;
60  fT = sbrhit.fT;
61  fFlag = sbrhit.fFlag;
62  fUID = sbrhit.fUID;
63 }
64 
66 {
67  // printf("Des \n");
68 }
69 
70 SBRPHit::SBRPHit(const SBRPHit &sbrphit) : SBRHit((SBRPHit &)sbrphit)
71 {
72  fPX = sbrphit.fPX;
73  fPY = sbrphit.fPY;
74  fPZ = sbrphit.fPZ;
75 }
76 
78  fX(0.0),
79  fY(0.0),
80  fZ(0.0),
81  fTA(0.0),
82  fTL(0.0),
83  fLength(0.0),
84  fPrimaryID(0.0),
85  fSecondaryID(0.0),
86  fNbSteps(0.0)
87 {
88  SBROpticalHit::Class()->IgnoreTObjectStreamer();
89  Clear("");
90 
91  // printf("Const \n");
92 }
93 
94 SBROpticalHit::SBROpticalHit(const SBROpticalHit &SBRHit) : TObject((TObject &)SBRHit)
95 {
96  fX = SBRHit.fX;
97  fY = SBRHit.fY;
98  fZ = SBRHit.fZ;
99  fTA = SBRHit.fTA;
100  fTL = SBRHit.fTL;
101  fLength = SBRHit.fLength;
102 
103  fPrimaryID = SBRHit.fPrimaryID;
104  fSecondaryID = SBRHit.fSecondaryID;
105  fNbSteps = SBRHit.fNbSteps;
106 }
107 
108 void SBROpticalHit::Clear(Option_t * /*opt*/)
109 {
110  fX = 0.0;
111  fY = 0.0;
112  fZ = 0.0;
113  fTA = 0.0;
114  fTL = 0.0;
115  fLength = 0.0;
116 
117  fPrimaryID = -1;
118  fSecondaryID = -1;
119  fNbSteps = 0;
120 }
121 
123 {
124  // printf("Des \n");
125 }
126 
127 SBREvent::SBREvent() : TObject(),
128  fHits(0x0),
129  fETot(0.0),
130  fMultTot(0)
131 {
132  fHits = new TClonesArray("SBRHit",10000);
133 
134  SBREvent::Class()->IgnoreTObjectStreamer();
135 }
136 
138 {
139  delete fHits;
140 }
141 
142 void SBREvent::Clear(Option_t *opt)
143 {
144  fHits->Clear(opt);
145 
146  fMultTot = 0;
147  fETot = 0.0;
148 }
149 
151 {
152  // printf("entries IN %d \n",fHits->GetEntries());
153 
154  TClonesArray &ar = *fHits;
155  SBRHit *p = new( ar[fHits->GetEntries()] ) SBRHit();
156 
157  // printf("entries OU %d \n",fHits->GetEntries());
158 
159  return p;
160 }
161 
163 {
164  TClonesArray &ar = *fHits;
165 
166  if ( which < fHits->GetEntries() )
167  return (SBRHit *)ar[which];
168  return 0x0;
169 }
170 
171 SBRPEvent::SBRPEvent() : TObject(),
172  fHits(0x0),
173  fETot(0.0),
174  fMultTot(0)
175 {
176  fHits = new TClonesArray("SBRPHit",10000);
177 
178  SBRPEvent::Class()->IgnoreTObjectStreamer();
179 }
180 
182 {
183  delete fHits;
184 }
185 
186 void SBRPEvent::Clear(Option_t *opt)
187 {
188  fHits->Clear(opt);
189 
190  fMultTot = 0;
191  fETot = 0.0;
192 }
193 
195 {
196  // printf("entries IN %d \n",fHits->GetEntries());
197 
198  TClonesArray &ar = *fHits;
199  SBRPHit *p = new( ar[fHits->GetEntries()] ) SBRPHit();
200 
201  // printf("entries OU %d \n",fHits->GetEntries());
202 
203  return p;
204 }
205 
207 {
208  TClonesArray &ar = *fHits;
209 
210  if ( which < fHits->GetEntries() )
211  return (SBRPHit *)ar[which];
212  return 0x0;
213 }
214 
215 
217  fHits(0x0)
218 {
219  fHits = new TClonesArray("SBROpticalHit",100000);
220  //
221  SBROpticalEvent::Class()->IgnoreTObjectStreamer();
222 }
223 
225 {
226  delete fHits;
227 }
228 
229 void SBROpticalEvent::Clear(Option_t *opt)
230 {
231  fHits->Clear(opt);
232 }
233 
235 {
236  // printf("entries IN %d \n",fHits->GetEntries());
237 
238  TClonesArray &ar = *fHits;
239  SBROpticalHit *p = new( ar[fHits->GetEntries()] ) SBROpticalHit();
240 
241  // printf("entries OU %d \n",fHits->GetEntries());
242 
243  return p;
244 }
245 
247 {
248  TClonesArray &ar = *fHits;
249 
250  if ( which < fHits->GetEntries() )
251  return (SBROpticalHit *)ar[which];
252  return 0x0;
253 }
254 
255 #include <algorithm>
256 
257 // function to have hit sorted with increasing energy
258 bool CompE_ASCENDING(SBRHit *hit1, SBRHit *hit2)
259 {
260  if ( hit2->fE > hit1->fE )
261  return true;
262 
263  return false;
264 }
265 // function to have hit sorted with decreasing energy
266 bool CompE_DESCENDING(SBRHit *hit1, SBRHit *hit2)
267 {
268  if ( hit2->fE < hit1->fE )
269  return true;
270 
271  return false;
272 }
273 
274 /*
275 void SBREvent::CopyTo(std::vector <SBRHit *> &ordlist, Option_t *opt)
276 {
277  TString o = opt; TClonesArray &ar = *fHits;
278 
279  for( Int_t i = 0; i < ar.GetEntries(); i++ ) {
280  ordlist.push_back( (SBRHit *)ar[i] );
281  }
282  if ( o == "e>" ) {
283  std::sort( ordlist.begin(), ordlist.end(), CompE_ASCENDING );
284  }
285  if ( o == "e<" ) {
286  std::sort( ordlist.begin(), ordlist.end(), CompE_DESCENDING );
287  }
288 }
289 
290 void SBRPEvent::CopyTo(std::vector <SBRPHit *> &ordlist, Option_t *opt)
291 {
292  TString o = opt; TClonesArray &ar = *fHits;
293 
294  for( Int_t i = 0; i < ar.GetEntries(); i++ ) {
295  ordlist.push_back( (SBRPHit *)ar[i] );
296  }
297  if ( o == "e>" ) {
298  std::sort( ordlist.begin(), ordlist.end(), CompE_ASCENDING );
299  }
300  if ( o == "e<" ) {
301  std::sort( ordlist.begin(), ordlist.end(), CompE_DESCENDING );
302  }
303 }
304  */
305 
306 
307 
308 
309 
virtual void Clear(Option_t *opt)
clear the collection of hits, set H, K to 0
SBROpticalHit * AddHit()
add a hit to the current event
SToGS Base Root Polarized Hit.
SBRHit * GetHit(Int_t)
to get a Hit
Double32_t fPY
bool CompE_DESCENDING(SBRHit *hit1, SBRHit *hit2)
SBRPHit * AddHit()
add a hit to the current event
Double32_t fPZ
ClassImp(SBRHit)
Double32_t fX
Double32_t fT
virtual ~SBRPEvent()
bool CompE_ASCENDING(SBRHit *hit1, SBRHit *hit2)
SBRHit * AddHit()
add a hit to the current event
virtual void Clear(Option_t *opt)
clear the collection of hits, set H, K to 0
virtual ~SBREvent()
Double32_t fZ
SBROpticalHit * GetHit(Int_t)
to get a Hit
Double32_t fY
Double32_t fPX
SBRPHit * GetHit(Int_t)
to get a Hit
void Clear(Option_t *opt)
virtual ~SBRHit()
Double32_t fE