AliRoot Core  3dc7879 (3dc7879)
AliTOFHeader.cxx
Go to the documentation of this file.
1 /**************************************************************************
2  * Copyright(c) 1998-2003, ALICE Experiment at CERN, All rights reserved. *
3  * *
4  * Author: The ALICE Off-line Project. *
5  * Contributors are mentioned in the code where appropriate. *
6  * *
7  * Permission to use, copy, modify and distribute this software and its *
8  * documentation strictly for non-commercial purposes is hereby granted *
9  * without fee, provided that the above copyright notice appears in all *
10  * copies and that both the copyright notice and this permission notice *
11  * appear in the supporting documentation. The authors make no claims *
12  * about the suitability of this software for any purpose. It is *
13  * provided "as is" without express or implied warranty. *
14  **************************************************************************/
15 
16 //-----------------------------------------------------------------
17 // Implementation of the Event Time class
18 // for the Event Data Summary class
19 // This class contains the Event Time
20 // as estimated by the TOF combinatorial algorithm
21 // Origin: A.De Caro, decaro@sa.infn.it
22 //-----------------------------------------------------------------
23 
24 //---- standard headers ----
25 #include "Riostream.h"
26 //---- Root headers --------
27 #include "TArrayF.h"
28 #include "TArrayI.h"
29 //---- AliRoot headers -----
30 #include "AliTOFHeader.h"
31 
32 
33 ClassImp(AliTOFHeader)
34 
35 //--------------------------------------------------------------------------
37  TObject(),
38  fDefaultEventTimeValue(0.),
39  fDefaultEventTimeRes(0.),
40  fNbins(0),
41  fEventTimeValues(0),
42  fEventTimeRes(0),
43  fNvalues(0),
44  fTOFtimeResolution(0.),
45  fT0spread(0.),
46  fNumberOfTOFclusters(-1),
47  fNumberOfTOFtrgPads(-1),
48  fTrigMask(new AliTOFTriggerMask())
49 {
50  //
51  // Default Constructor
52  //
53 
54 }
55 
56 //--------------------------------------------------------------------------
57 AliTOFHeader::AliTOFHeader(Float_t defEvTime, Float_t defResEvTime,
58  Int_t nDifPbins, Float_t *times, Float_t *res,
59  Int_t *nPbin, Float_t tofTimeRes, Float_t t0spread) :
60  TObject(),
61  fDefaultEventTimeValue(defEvTime),
62  fDefaultEventTimeRes(defResEvTime),
63  fNbins(nDifPbins),
64  fEventTimeValues(0),
65  fEventTimeRes(0),
66  fNvalues(0),
67  fTOFtimeResolution(tofTimeRes),
68  fT0spread(t0spread),
69  fNumberOfTOFclusters(-1),
70  fNumberOfTOFtrgPads(-1),
71  fTrigMask(new AliTOFTriggerMask())
72 {
73  //
74  // Constructor for TOF header
75  //
76 
77  if (fNbins>0) {
78  fEventTimeValues = new TArrayF(fNbins);
79  fEventTimeRes = new TArrayF(fNbins);
80  fNvalues = new TArrayI(fNbins);
81  for (Int_t ii=0; ii<fNbins; ii++) {
82  fEventTimeValues->SetAt(times[ii],ii);
83  fEventTimeRes->SetAt(res[ii],ii);
84  fNvalues->SetAt(nPbin[ii],ii);
85  }
86  }
87 
88 }
89 
90 //--------------------------------------------------------------------------
92  TObject(source),
95  fNbins(source.fNbins),
97  fEventTimeRes(0),
98  fNvalues(0),
100  fT0spread(source.fT0spread),
103  fTrigMask(NULL)
104 {
105  //
106  // Copy constructor
107  //
108 
109  if (fNbins>0) {
110  fEventTimeValues = new TArrayF(fNbins);
111  fEventTimeRes = new TArrayF(fNbins);
112  fNvalues = new TArrayI(fNbins);
113  for(Int_t i=0;i<fNbins;i++) {
114  (*fEventTimeValues)[i]=source.fEventTimeValues->At(i);
115  (*fEventTimeRes)[i]=source.fEventTimeRes->At(i);
116  (*fNvalues)[i]=source.fNvalues->At(i);
117  }
118  }
119 
120  if(source.fTrigMask) fTrigMask = new AliTOFTriggerMask(*(source.fTrigMask));
121  else fTrigMask = new AliTOFTriggerMask();
122 }
123 //--------------------------------------------------------------------------
125  //
126  // assignment operator
127  //
128  if(&source != this){
129  TObject::operator=(source);
130 
133  fNbins=source.fNbins;
135  fT0spread=source.fT0spread;
138 
139  if (fNbins>0) {
140  delete fEventTimeValues;
141  delete fEventTimeRes;
142  delete fNvalues;
143  fEventTimeValues = new TArrayF(fNbins);
144  fEventTimeRes = new TArrayF(fNbins);
145  fNvalues = new TArrayI(fNbins);
146  for(Int_t i=0;i<fNbins;i++) {
147  (*fEventTimeValues)[i]=source.fEventTimeValues->At(i);
148  (*fEventTimeRes)[i]=source.fEventTimeRes->At(i);
149  (*fNvalues)[i]=source.fNvalues->At(i);
150  }
151  } else {
152  fEventTimeValues = 0;
153  fEventTimeRes = 0;
154  fNvalues = 0;
155  }
156 
157  if(source.fTrigMask && fTrigMask) *fTrigMask = *(source.fTrigMask);
158  else if(! fTrigMask) fTrigMask = new AliTOFTriggerMask();
159  }
160  return *this;
161 }
162 //--------------------------------------------------------------------------
163 void AliTOFHeader::Copy(TObject &obj) const {
164 
165  // this overwrites the virtual TOBject::Copy()
166  // to allow run time copying without casting
167  // in AliESDEvent
168 
169  if (this==&obj) return;
170  AliTOFHeader *robj = dynamic_cast<AliTOFHeader*>(&obj);
171  if (!robj) return; // not an AliTOFHeader
172  *robj = *this;
173 
174 }
175 
176 //--------------------------------------------------------------------------
178 {
179 
180  fNbins = 0;
181  if (fEventTimeValues) {
182  delete fEventTimeValues;
184  }
185  if (fEventTimeRes) {
186  delete fEventTimeRes;
187  fEventTimeRes=0;
188  }
189  if (fNvalues) {
190  delete fNvalues;
191  fNvalues=0;
192  }
193  if(fTrigMask){
194  delete fTrigMask;
195  fTrigMask=NULL;
196  }
197 
198 }
199 
200 //--------------------------------------------------------------------------
201 void AliTOFHeader::SetNbins(Int_t nbins)
202 {
203  //
204  //
205  //
206 
207  fNbins=nbins;
208  if (!fEventTimeValues)
209  fEventTimeValues = new TArrayF(nbins);
210  else
211  fEventTimeValues->Set(nbins);
212 
213  if (!fEventTimeRes)
214  fEventTimeRes = new TArrayF(nbins);
215  else
216  fEventTimeRes->Set(nbins);
217 
218  if (!fNvalues)
219  fNvalues = new TArrayI(nbins);
220  else
221  fNvalues->Set(nbins);
222 
223 }
224 //--------------------------------------------------------------------------
226 {
227  //
228  //
229  //
230 
231  fNbins=arr->GetSize();
232 
233  if (!fEventTimeValues)
234  fEventTimeValues = new TArrayF(fNbins);
235  else
236  fEventTimeValues->Set(fNbins);
237 
238  for (Int_t ii=0; ii<fNbins; ii++)
239  fEventTimeValues->SetAt(arr->GetAt(ii),ii);
240 
241 }
242 //--------------------------------------------------------------------------
244 {
245  //
246  //
247  //
248 
249  fNbins=arr->GetSize();
250 
251  if (!fEventTimeRes)
252  fEventTimeRes = new TArrayF(fNbins);
253  else
254  fEventTimeRes->Set(fNbins);
255 
256  for (Int_t ii=0; ii<fNbins; ii++)
257  fEventTimeRes->SetAt(arr->GetAt(ii),ii);
258 
259 }
260 //--------------------------------------------------------------------------
261 void AliTOFHeader::SetNvalues(TArrayI *arr)
262 {
263  //
264  //
265  //
266 
267  fNbins=arr->GetSize();
268 
269  if (!fNvalues)
270  fNvalues = new TArrayI(fNbins);
271  else
272  fNvalues->Set(fNbins);
273 
274  for (Int_t ii=0; ii<fNbins; ii++)
275  fNvalues->SetAt(arr->GetAt(ii),ii);
276 
277 }
AliTOFHeader & operator=(const AliTOFHeader &source)
TArrayF * fEventTimeValues
Definition: AliTOFHeader.h:80
Float_t fDefaultEventTimeValue
Definition: AliTOFHeader.h:75
TArrayI * fNvalues
Definition: AliTOFHeader.h:83
Float_t fTOFtimeResolution
Definition: AliTOFHeader.h:84
Float_t fDefaultEventTimeRes
Definition: AliTOFHeader.h:76
void SetNbins(Int_t nbins)
void SetNvalues(TArrayI *arr)
virtual void Copy(TObject &obj) const
AliTOFTriggerMask * fTrigMask
Definition: AliTOFHeader.h:88
void SetEventTimeRes(TArrayF *arr)
Int_t fNumberOfTOFclusters
Definition: AliTOFHeader.h:86
Float_t fT0spread
Definition: AliTOFHeader.h:85
TArrayF * fEventTimeRes
Definition: AliTOFHeader.h:82
void SetEventTimeValues(TArrayF *arr)
void res(Char_t i)
Definition: Resolution.C:2
Int_t fNumberOfTOFtrgPads
Definition: AliTOFHeader.h:87
virtual ~AliTOFHeader()