GRUTinizer
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
TS800Hit.h
Go to the documentation of this file.
1 #ifndef TSEIGHTHUNDRADHIT_H
2 #define TSEIGHTHUNDRADHIT_H
3 
4 #include <TObject.h>
5 #include <TClass.h>
6 #include <iostream>
7 
8 #include <TDetectorHit.h>
9 #include <TMath.h>
10 #include "TRandom.h"
11 
12 #define MAXCRDC 513
13 //#define CRDC_XSlope 2.54
14 //#define CRDC_XOffset -281.94
15 //#define CRDC_YSlope 2.54
16 //#define CRDC_YOffset -281.94
17 //#define CRDC_XSlope 1
18 //#define CRDC_YSlope 1
19 //#define CRDC_XOffset 0
20 //#define CRDC_YOffset 0
21 
22 
23 class TS800Channel : public TDetectorHit {
24  public:
26  TS800Channel(short value) { Set(value); }
27  TS800Channel(unsigned short value) { Set(value); }
29 
30  void Set(short value) { fValue = (unsigned short)value; }
31  void Set(unsigned short value) { fValue = value; }
32 
33  virtual short GetId() const { return (((fValue)&0xf000)>>12); }
34  short GetValue() const { return fValue&0x0fff; }
35 
36  virtual void Clear(Option_t *opt="") { TDetectorHit::Clear(opt); fValue = 0; }
37  virtual void Print(Option_t *opt="") const { printf("[%i] = %i\n",GetId(),GetValue());}
38  virtual void Copy(TObject &obj) const { TDetectorHit::Copy(obj); ((TS800Channel&)obj).fValue = fValue; }
39 
40  virtual int Charge() const { return GetValue(); }
41 
42  private:
43  //void Init() { Class()->IgnoreTObjectStreamer(true); }
44  short fValue;
45 
47 };
48 
49 class TTrigger : public TDetectorHit {
50  public:
51  TTrigger();
52  ~TTrigger();
53 
54  void SetRegistr(unsigned short reg) { fregistr=reg; }
55  void SetS800Source(short sou) { fs800source=sou; }
56  void SetExternalSource1(short sou) { fexternalsource1=sou; }
57  void SetExternalSource2(short sou) { fexternalsource2=sou; }
58  void SetSecondarySource(short sou) { fsecondarysource=sou; }
59 
60  unsigned short GetRegistr() { return fregistr; }
61  short GetS800Source() { return fs800source; }
65 
66  virtual void Copy(TObject &) const;
67  virtual void Print(Option_t *opt="") const;
68  virtual void Clear(Option_t *opt="");
69 
70  private:
71  virtual int Charge() const { return 0; }
72 
73  unsigned short fregistr;
74  short fs800source;
78 
80 };
81 
82 
83 class TTof : public TDetectorHit { // S800 Time of Flight
84  public:
85  TTof();
86  ~TTof();
87 
88  void SetRF(short rf) { frf=rf; }
89  void SetOBJ(short obj) { fobj=obj; }
90  void SetXFP(short xfp) { fxfp=xfp; }
91  void SetSI(short si) { fsi=si; }
92  void SetTacOBJ(short obj) { ftac_obj=obj; }
93  void SetTacXFP(short xfp) { ftac_xfp=xfp; }
94 
95  short GetRF() { return frf; }
96  short GetOBJ() { return fobj; } // tdc!
97  short GetXFP() { return fxfp; } // tdc!
98  short GetSI() { return fsi; }
99  short GetTacOBJ() { return ftac_obj;} // tac!
100  short GetTacXFP() { return ftac_xfp;} // tac!
101 
102 
103  virtual void Copy(TObject &) const;
104  virtual void Print(Option_t *opt="") const;
105  virtual void Clear(Option_t *opt="");
106 
107  private:
108  virtual int Charge() const { return 0; }
109 
110  short frf;
111  short fobj;
112  short fxfp;
113  short fsi;
114  short ftac_obj;
115  short ftac_xfp;
116 
117  ClassDef(TTof,1);
118 };
119 
120 class TCrdc : public TDetectorHit {
121  public:
122  TCrdc();
123  ~TCrdc();
124 
125  short GetId() { return fId; }
126  short GetAnode() { return anode; }
127  short GetTime() { return time; }
128  float GetTimeRand() { return ((float)(time)+gRandom->Uniform()); }
129 
130  int Size() const { return sample.size(); }
131  int GetNSamples() const { return sample.size(); }
132 
133  void SetId(short id) { fId = id; }
134  void SetAnode(short an) {anode = an; }
135  void SetTime(short ti) {time = ti; }
136 
137  void SetXslope (float xm) { fCRDCXslope = xm; }
138  void SetYslope (float ym) { fCRDCYslope = ym; }
139  void SetXoffset (float xo) { fCRDCXoff = xo; }
140  void SetYoffset (float yo) { fCRDCYoff = yo; }
141 
142 
143  void AddPoint(int chan,int samp,int dat) { channel.push_back(chan);
144  sample.push_back(samp);
145  data.push_back(dat); }
146  int GetChannel(int i) { if(i>=Size()) return -1; return channel.at(i); }
147  int GetSample(int i) { if(i>=Size()) return -1; return sample.at(i); }
148  int GetData(int i) { if(i>=Size()) return -1; return data.at(i); }
149 
150  int GetWidth();
151 
152  float GetDispersiveX() { if(GetPad()==-1) return sqrt(-1); return (GetPad()*fCRDCXslope+fCRDCXoff); }
153  float GetNonDispersiveY() { if(GetPad()==-1) return sqrt(-1); return (GetTimeRand()*fCRDCYslope+fCRDCYoff); }
154  float GetXslope () { return fCRDCXslope; }
155  float GetYslope () { return fCRDCYslope; }
156  float GetXoffset () { return fCRDCXoff; }
157  float GetYoffset () { return fCRDCYoff; }
158 
159 
160 
161  float GetPad();
162 
163  virtual void Copy(TObject&) const;
164  virtual void Print(Option_t *opt="") const;
165  virtual void Clear(Option_t *opt="");
166 
167  virtual void DrawChannels(Option_t *opt="") const;
168  virtual void DrawHit(Option_t *opt="") const;
169 
170  private:
171  virtual int Charge() const { return 0; }
172  short fId;
173  std::vector<int> channel;
174  std::vector<int> sample;
175  std::vector<int> data;
176 
177  float fCRDCXslope;
178  float fCRDCYslope;
179  float fCRDCXoff;
180  float fCRDCYoff;
181 
182  unsigned short anode;
183  unsigned short time;
184 
185  ClassDef(TCrdc,1)
186 };
187 
188 
189 class TScintillator : public TDetectorHit {
190  public:
191  TScintillator();
192  ~TScintillator();
193 
194  void SetID(int id) { fID=id; }
195  void SetdE_Up(float de) { fdE_up = de; }
196  void SetdE_Down(float de) { fdE_down = de; }
197  void SetTime_Up(float t) { fTime_up = t; } // tdc
198  void SetTime_Down(float t) { fTime_down = t; } // tdc
199 
200  int GetID() { return fID; }
201  float GetEUp() { return fdE_up; }
202  float GetEDown() { return fdE_down; }
203  float GetTimeUp() { return fTime_up; }
204  float GetTimeDown() { return fTime_down; }
205 
206  virtual void Copy(TObject&) const;
207  virtual void Print(Option_t *opt="") const;
208  virtual void Clear(Option_t *opt="");
209 
210  private:
211  virtual int Charge() const { return 0; }
212  int fID;
213  float fdE_up;
214  float fdE_down;
215  float fTime_up;
216  float fTime_down;
217 
219 };
220 
221 class TIonChamber : public TDetectorHit {
222  public:
223  TIonChamber();
224  ~TIonChamber();
225 
226  void Set(int ch, int data); // { fChan.push_back(ch); fData.push_back(data); }
227 
228  int GetChannel(int i) const { if(i>=Size()) return sqrt(-1); return fChan.at(i); }
229  int GetData(int i) const { if(i>=Size()) return sqrt(-1); return fData.at(i); }
230  int Size() const { return fChan.size(); }
231  float GetdE();
232 
233 
234  virtual void Copy(TObject&) const;
235  virtual void Print(Option_t *opt="") const;
236  virtual void Clear(Option_t *opt="");
237  int Charge() const { int sum=0;for(int i=0;i<Size();i++)sum+=GetData(i);return sum;}
238  //int GetSum() const { int sum=0;for(int i=0;i<Size();i++)sum+=GetData(i);return sum;}
239  private:
240 
241 
242  std::vector<int> fChan;
243  std::vector<int> fData;
244  //float fdE; //! Average of all fData.
246 };
247 
248 
249 
250 
251 
252 
253 // ----------- ?? OLD ?? -----------
254 
255 
256 class TTOFHit : public TS800Channel {
257  public:
258  TTOFHit() { }
259  TTOFHit(const TTOFHit &tof) { tof.Copy(*this); }
260  TTOFHit(short value) : TS800Channel(value) { }
261  TTOFHit(unsigned short value) : TS800Channel(value) { }
262  //TTOFHit(char *data,int size);
263  ~TTOFHit() { }
264 
265  bool IsRF_tdc( ) {return GetId() == 0x000c;}
266  bool IsOBJ_tdc() {return GetId() == 0x000d;}
267  bool IsOBJ_tac() {return GetId() == 0x0005;}
268  bool IsXFP_tac() {return GetId() == 0x000e;}
269  bool IsXFP_tdc() {return GetId() == 0x0004;}
270  bool IsSI_tdc() {return GetId() == 0x000f;}
271 
272  virtual void Clear(Option_t *opt="") { TS800Channel::Clear(opt); }
273  virtual void Print(Option_t *opt="") const { printf("TOF");TS800Channel::Print(opt);}
274  virtual void Copy(TObject &obj) const { TS800Channel::Copy(obj); }
275 
276  ClassDef(TTOFHit,1);
277 };
278 
279 
280 class THodoHit : public TS800Channel {
281  public:
282  THodoHit() { Clear(); }
283  THodoHit(short chan,short value) { SetChannel(chan); Set(value); }
284  ~THodoHit() { };
285 
286  virtual void Clear(Option_t *opt="") { TS800Channel::Clear(opt); fChannel=-1; }
287  virtual void Print(Option_t *opt="") const { printf("HODO"); }
288  virtual void Copy(TObject &obj) const { TS800Channel::Copy(obj); ((THodoHit&)obj).fChannel = fChannel; }
289 
290  void SetChannel(short chan) { fChannel = chan; }
291  short GetId() const { return GetChannel(); }
292  short GetChannel() const { return fChannel; }
293 
294  private:
295  short fChannel;
296 
297 
298  ClassDef(THodoHit,1)
299 };
300 
301 
302 class TFPScint : public TS800Channel {
303  public:
304  TFPScint() { }
305  TFPScint(const TFPScint &fpscint) { fpscint.Copy(*this); }
306  TFPScint(short charge,short time):TS800Channel(charge),fTime((unsigned short)time) { }
307  TFPScint(unsigned short charge,unsigned short time):TS800Channel(charge),fTime(time) { }
308  //TFPScint(char *data,int size);
309  ~TFPScint() { }
310 
311  void SetCharge(short chg) { Set(chg); }
312  void SetTime(short time) { fTime = time; }
313 
314 
315 
316  bool IsE1up() {return GetId() == 0x0000;}
317  bool IsE1down() {return GetId() == 0x0001;}
318  bool IsE2up() {return GetId() == 0x0002;}
319  bool IsE2down() {return GetId() == 0x0003;}
320  bool IsE3up() {return GetId() == 0x0004;}
321  bool IsE3down() {return GetId() == 0x0005;}
322 
323  short GetTime() const { return fTime&0x0fff; }
324 
325  virtual void Clear(Option_t *opt="") { TS800Channel::Clear(opt); fTime = 0; }
326  virtual void Print(Option_t *opt="") const { printf("FPScint");TS800Channel::Print(opt);}
327  virtual void Copy(TObject &obj) const { TS800Channel::Copy(obj); }
328  private:
329 
330  unsigned short fTime;
331  ClassDef(TFPScint,1);
332 };
333 
334 /*
335 class TIonChamber : public TS800Channel {
336  public:
337  TIonChamber() { }
338  TIonChamber(const TIonChamber &ion) { ion.Copy(*this); }
339  TIonChamber(short value):TS800Channel(value) { }
340 
341  virtual void Clear(Option_t *opt="") { TS800Channel::Clear(opt); }
342  virtual void Print(Option_t *opt="") const { printf("Ion Chamber");TS800Channel::Print(opt);}
343  virtual void Copy(TObject &obj) const { TS800Channel::Copy(obj); }
344  private:
345  ClassDef(TIonChamber,1)
346 
347 };
348 */
349 
350 class TMTof : public TDetectorHit {
351  public:
352  TMTof();
353  ~TMTof();
354  TMTof(const TMTof&);
355 
356  virtual void Copy(TObject&) const;
357  virtual void Print(Option_t *opt="") const;
358  virtual void Clear(Option_t *opt="");
359 
360  int E1UpSize() const { return fE1Up.size(); }
361  int E1DownSize() const { return fE1Down.size(); }
362  int XfpSize() const { return fXfp.size(); }
363  int ObjSize() const { return fObj.size(); }
364  int RfSize() const { return fRf.size(); }
365  int Crdc1AnodeSize() const { return fCrdc1Anode.size();}
366  int Crdc2AnodeSize() const { return fCrdc2Anode.size();}
367  int HodoSize() const { return fHodoscope.size(); }
368  int RefSize() const { return fRef.size(); }
369 
370 
371 
372 
373  //private:
374 
375  std::vector<unsigned short> fE1Up; // Channel 0
376  std::vector<unsigned short> fE1Down; // Channel 1
377  std::vector<unsigned short> fXfp; // Channel 2
378  std::vector<unsigned short> fObj; // Channel 3
379  std::vector<unsigned short> fRf; // Channel 5
380  std::vector<unsigned short> fCrdc1Anode; // Channel 6
381  std::vector<unsigned short> fCrdc2Anode; // Channel 7
382  std::vector<unsigned short> fHodoscope; // Channel 12
383  std::vector<unsigned short> fRef; // Channel 15, same as E1Up (different cable.)
384 
385  //std::vector<int> fGalotte;
386  //
387  //
388  virtual Int_t Charge() const {return 0;}
389  //
390  //
391  ClassDef(TMTof,1)
392 };
393 
394 
395 class TCrdcPad : public TDetectorHit {
396 
397  public:
398  TCrdcPad();
399  TCrdcPad(int chan);
400  ~TCrdcPad();
401 
402  virtual Int_t Charge() const;
403 
404 
405  void SetChannel(short chan) { fChannel = chan; }
406  void SetPoint(short sample,short value) {
407  if(fNumSamples >= MAXCRDC){
408  printf("fNumSamples = %i\n",fNumSamples); fflush(stdout);
409  }
410  fSample[fNumSamples] = sample;
412  fNumSamples++;
413 
414  }
415  //int GetPoint(int sample) { if(fTrace.count(sample)) return fTrace.at(sample); else return 0; }
416  short GetChannel() { return fChannel; }
417 
418  virtual void Clear(Option_t *opt="");
419  virtual void Print(Option_t *opt="") const;
420  virtual void Copy(TObject &obj) const;
421 
422  private:
423  short fChannel;
424  short fNumSamples;
425  short fSample[MAXCRDC];
426  short fValue[MAXCRDC];
427  //std::map <int,int> fTrace;
428 
429 
430 
431  ClassDef(TCrdcPad,1)
432 };
433 
434 
435 class TS800Hit : public TDetectorHit {
436  public:
437  TS800Hit() { }
438  ~TS800Hit() { }
439  virtual Int_t Charge() const { return 0; }
440 
441  virtual void Clear(Option_t *opt ="") { TDetectorHit::Clear(opt); }
442  virtual void Print(Option_t *opt ="") const { }
443  virtual void Copy(TObject &obj) const { TDetectorHit::Copy(obj); }
444 
445  private:
446 
447  ClassDef(TS800Hit,1);
448 };
449 
450 
451 
452 
453 
454 
455 
456 
457 
458 
459 #endif