GammaWare  Head Version for release 0.9
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 #include <iostream>
31 
37 
38 SBRHit::SBRHit() : TObject(),
39  fE(0.0),
40  fPDG(-1),
41  fX(0.0),
42  fY(0.0),
43  fZ(0.0),
44  fT(0.0),
45  fFlag(0),
46  fUID(-1)
47 {
48  SBRHit::Class()->IgnoreTObjectStreamer();
49  Clear("");
50 
51  // printf("Const \n");
52 }
53 
54 SBRHit::SBRHit(const SBRHit &sbrhit) : TObject((TObject &)sbrhit)
55 {
56  fE = sbrhit.fE;
57  fPDG = sbrhit.fPDG;
58  fX = sbrhit.fX;
59  fY = sbrhit.fY;
60  fZ = sbrhit.fZ;
61  fT = sbrhit.fT;
62  fFlag = sbrhit.fFlag;
63  fUID = sbrhit.fUID;
64 }
65 
67 {
68  // printf("Des \n");
69 }
70 
71 SBRPHit::SBRPHit(const SBRPHit &sbrphit) : SBRHit((SBRPHit &)sbrphit)
72 {
73  fPX = sbrphit.fPX;
74  fPY = sbrphit.fPY;
75  fPZ = sbrphit.fPZ;
76 }
77 
79  fX(0.0),
80  fY(0.0),
81  fZ(0.0),
82  fTA(0.0),
83  fTL(0.0),
84  fLength(0.0),
85  fPrimaryID(0.0),
86  fSecondaryID(0.0),
87  fNbSteps(0.0)
88 {
89  SBROpticalHit::Class()->IgnoreTObjectStreamer();
90  Clear("");
91 
92  // printf("Const \n");
93 }
94 
95 SBROpticalHit::SBROpticalHit(const SBROpticalHit &SBRHit) : TObject((TObject &)SBRHit)
96 {
97  fX = SBRHit.fX;
98  fY = SBRHit.fY;
99  fZ = SBRHit.fZ;
100  fTA = SBRHit.fTA;
101  fTL = SBRHit.fTL;
102  fLength = SBRHit.fLength;
103 
104  fPrimaryID = SBRHit.fPrimaryID;
105  fSecondaryID = SBRHit.fSecondaryID;
106  fNbSteps = SBRHit.fNbSteps;
107 }
108 
109 void SBROpticalHit::Clear(Option_t * /*opt*/)
110 {
111  fX = 0.0;
112  fY = 0.0;
113  fZ = 0.0;
114  fTA = 0.0;
115  fTL = 0.0;
116  fLength = 0.0;
117 
118  fPrimaryID = -1;
119  fSecondaryID = -1;
120  fNbSteps = 0;
121 }
122 
124 {
125  // printf("Des \n");
126 }
127 
128 SBREvent::SBREvent() : TObject(),
129  fHits(0x0),
130  fETot(0.0),
131  fMultTot(0)
132 {
133  fHits = new TClonesArray("SBRHit",10000);
134 
135  SBREvent::Class()->IgnoreTObjectStreamer();
136 }
137 
139 {
140  delete fHits;
141 }
142 
143 void SBREvent::Clear(Option_t *opt)
144 {
145  fHits->Clear(opt);
146 
147  fMultTot = 0;
148  fETot = 0.0;
149 }
150 
152 {
153  // printf("entries IN %d \n",fHits->GetEntries());
154 
155  TClonesArray &ar = *fHits;
156  SBRHit *p = new( ar[fHits->GetEntries()] ) SBRHit();
157 
158  // printf("entries OU %d \n",fHits->GetEntries());
159 
160  return p;
161 }
162 
163 void SBREvent::AddHit(const SBRHit *hit)
164 {
165  SBRHit *a_hit = AddHit();
166 
167  (*a_hit) = (*hit);
168  fETot += hit->fE;
169  fMultTot++;
170 }
171 
173 {
174  TClonesArray &ar = *fHits;
175 
176  if ( which < fHits->GetEntries() )
177  return (SBRHit *)ar[which];
178  return 0x0;
179 }
180 
181 SBRPEvent::SBRPEvent() : TObject(),
182  fHits(0x0),
183  fETot(0.0),
184  fMultTot(0)
185 {
186  fHits = new TClonesArray("SBRPHit",10000);
187 
188  SBRPEvent::Class()->IgnoreTObjectStreamer();
189 }
190 
192 {
193  delete fHits;
194 }
195 
196 void SBRPEvent::Clear(Option_t *opt)
197 {
198  fHits->Clear(opt);
199 
200  fMultTot = 0;
201  fETot = 0.0;
202 }
203 
205 {
206  // printf("entries IN %d \n",fHits->GetEntries());
207 
208  TClonesArray &ar = *fHits;
209  SBRPHit *p = new( ar[fHits->GetEntries()] ) SBRPHit();
210 
211  // printf("entries OU %d \n",fHits->GetEntries());
212 
213  return p;
214 }
215 
217 {
218  TClonesArray &ar = *fHits;
219 
220  if ( which < fHits->GetEntries() )
221  return (SBRPHit *)ar[which];
222  return 0x0;
223 }
224 
225 
227  fHits(0x0)
228 {
229  fHits = new TClonesArray("SBROpticalHit",100000);
230  //
231  SBROpticalEvent::Class()->IgnoreTObjectStreamer();
232 }
233 
235 {
236  delete fHits;
237 }
238 
239 void SBROpticalEvent::Clear(Option_t *opt)
240 {
241  fHits->Clear(opt);
242 }
243 
245 {
246  // printf("entries IN %d \n",fHits->GetEntries());
247 
248  TClonesArray &ar = *fHits;
249  SBROpticalHit *p = new( ar[fHits->GetEntries()] ) SBROpticalHit();
250 
251  // printf("entries OU %d \n",fHits->GetEntries());
252 
253  return p;
254 }
255 
257 {
258  TClonesArray &ar = *fHits;
259 
260  if ( which < fHits->GetEntries() )
261  return (SBROpticalHit *)ar[which];
262  return 0x0;
263 }
264 
265 #include <algorithm>
266 
267 // function to have hit sorted with increasing energy
268 bool CompE_ASCENDING(SBRHit *hit1, SBRHit *hit2)
269 {
270  if ( hit2->fE > hit1->fE )
271  return true;
272 
273  return false;
274 }
275 // function to have hit sorted with decreasing energy
276 bool CompE_DESCENDING(SBRHit *hit1, SBRHit *hit2)
277 {
278  if ( hit2->fE < hit1->fE )
279  return true;
280 
281  return false;
282 }
283 
284 /*
285 void SBREvent::CopyTo(std::vector <SBRHit *> &ordlist, Option_t *opt)
286 {
287  TString o = opt; TClonesArray &ar = *fHits;
288 
289  for( Int_t i = 0; i < ar.GetEntries(); i++ ) {
290  ordlist.push_back( (SBRHit *)ar[i] );
291  }
292  if ( o == "e>" ) {
293  std::sort( ordlist.begin(), ordlist.end(), CompE_ASCENDING );
294  }
295  if ( o == "e<" ) {
296  std::sort( ordlist.begin(), ordlist.end(), CompE_DESCENDING );
297  }
298 }
299 
300 void SBRPEvent::CopyTo(std::vector <SBRPHit *> &ordlist, Option_t *opt)
301 {
302  TString o = opt; TClonesArray &ar = *fHits;
303 
304  for( Int_t i = 0; i < ar.GetEntries(); i++ ) {
305  ordlist.push_back( (SBRPHit *)ar[i] );
306  }
307  if ( o == "e>" ) {
308  std::sort( ordlist.begin(), ordlist.end(), CompE_ASCENDING );
309  }
310  if ( o == "e<" ) {
311  std::sort( ordlist.begin(), ordlist.end(), CompE_DESCENDING );
312  }
313 }
314  */
315 
316 
317 
318 
319 
SBROpticalHit * GetHit(Int_t)
to get a Hit
SToGS Base Root Polarized Hit.
virtual ~SBRPEvent()
Double32_t fZ
bool CompE_ASCENDING(SBRHit *hit1, SBRHit *hit2)
SBROpticalHit * AddHit()
add a hit to the current event
Double32_t fE
Double32_t fPZ
SBRPHit * AddHit()
add a hit to the current event
virtual ~SBRHit()
Double32_t fX
Double32_t fPX
bool CompE_DESCENDING(SBRHit *hit1, SBRHit *hit2)
Double32_t fT
SBRHit * AddHit()
add a hit to the current event
ClassImp(SBRHit)
SBRPHit * GetHit(Int_t)
to get a Hit
Double32_t fPY
SBRHit * GetHit(Int_t)
to get a Hit
virtual void Clear(Option_t *opt)
clear the collection of hits, set H, K to 0
virtual void Clear(Option_t *opt)
clear the collection of hits, set H, K to 0
void Clear(Option_t *opt)
virtual ~SBREvent()
Double32_t fY