Line data Source code
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 176 : ClassImp(AliTOFHeader)
34 :
35 : //--------------------------------------------------------------------------
36 : AliTOFHeader::AliTOFHeader() :
37 47 : TObject(),
38 47 : fDefaultEventTimeValue(0.),
39 47 : fDefaultEventTimeRes(0.),
40 47 : fNbins(0),
41 47 : fEventTimeValues(0),
42 47 : fEventTimeRes(0),
43 47 : fNvalues(0),
44 47 : fTOFtimeResolution(0.),
45 47 : fT0spread(0.),
46 47 : fNumberOfTOFclusters(-1),
47 47 : fNumberOfTOFtrgPads(-1),
48 141 : fTrigMask(new AliTOFTriggerMask())
49 235 : {
50 : //
51 : // Default Constructor
52 : //
53 :
54 94 : }
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 8 : TObject(),
61 8 : fDefaultEventTimeValue(defEvTime),
62 8 : fDefaultEventTimeRes(defResEvTime),
63 8 : fNbins(nDifPbins),
64 8 : fEventTimeValues(0),
65 8 : fEventTimeRes(0),
66 8 : fNvalues(0),
67 8 : fTOFtimeResolution(tofTimeRes),
68 8 : fT0spread(t0spread),
69 8 : fNumberOfTOFclusters(-1),
70 8 : fNumberOfTOFtrgPads(-1),
71 24 : fTrigMask(new AliTOFTriggerMask())
72 40 : {
73 : //
74 : // Constructor for TOF header
75 : //
76 :
77 8 : if (fNbins>0) {
78 24 : fEventTimeValues = new TArrayF(fNbins);
79 24 : fEventTimeRes = new TArrayF(fNbins);
80 24 : fNvalues = new TArrayI(fNbins);
81 102 : for (Int_t ii=0; ii<fNbins; ii++) {
82 43 : fEventTimeValues->SetAt(times[ii],ii);
83 43 : fEventTimeRes->SetAt(res[ii],ii);
84 43 : fNvalues->SetAt(nPbin[ii],ii);
85 : }
86 8 : }
87 :
88 16 : }
89 :
90 : //--------------------------------------------------------------------------
91 : AliTOFHeader::AliTOFHeader(const AliTOFHeader &source):
92 0 : TObject(source),
93 0 : fDefaultEventTimeValue(source.fDefaultEventTimeValue),
94 0 : fDefaultEventTimeRes(source.fDefaultEventTimeRes),
95 0 : fNbins(source.fNbins),
96 0 : fEventTimeValues(0),
97 0 : fEventTimeRes(0),
98 0 : fNvalues(0),
99 0 : fTOFtimeResolution(source.fTOFtimeResolution),
100 0 : fT0spread(source.fT0spread),
101 0 : fNumberOfTOFclusters(source.fNumberOfTOFclusters),
102 0 : fNumberOfTOFtrgPads(source.fNumberOfTOFtrgPads),
103 0 : fTrigMask(NULL)
104 0 : {
105 : //
106 : // Copy constructor
107 : //
108 :
109 0 : if (fNbins>0) {
110 0 : fEventTimeValues = new TArrayF(fNbins);
111 0 : fEventTimeRes = new TArrayF(fNbins);
112 0 : fNvalues = new TArrayI(fNbins);
113 0 : for(Int_t i=0;i<fNbins;i++) {
114 0 : (*fEventTimeValues)[i]=source.fEventTimeValues->At(i);
115 0 : (*fEventTimeRes)[i]=source.fEventTimeRes->At(i);
116 0 : (*fNvalues)[i]=source.fNvalues->At(i);
117 : }
118 0 : }
119 :
120 0 : if(source.fTrigMask) fTrigMask = new AliTOFTriggerMask(*(source.fTrigMask));
121 0 : else fTrigMask = new AliTOFTriggerMask();
122 0 : }
123 : //--------------------------------------------------------------------------
124 : AliTOFHeader &AliTOFHeader::operator=(const AliTOFHeader &source){
125 : //
126 : // assignment operator
127 : //
128 32 : if(&source != this){
129 16 : TObject::operator=(source);
130 :
131 16 : fDefaultEventTimeValue=source.fDefaultEventTimeValue;
132 16 : fDefaultEventTimeRes=source.fDefaultEventTimeRes;
133 16 : fNbins=source.fNbins;
134 16 : fTOFtimeResolution=source.fTOFtimeResolution;
135 16 : fT0spread=source.fT0spread;
136 16 : fNumberOfTOFclusters=source.fNumberOfTOFclusters;
137 16 : fNumberOfTOFtrgPads=source.fNumberOfTOFtrgPads;
138 :
139 32 : if (fNbins>0) {
140 38 : delete fEventTimeValues;
141 22 : delete fEventTimeRes;
142 22 : delete fNvalues;
143 32 : fEventTimeValues = new TArrayF(fNbins);
144 32 : fEventTimeRes = new TArrayF(fNbins);
145 32 : fNvalues = new TArrayI(fNbins);
146 204 : for(Int_t i=0;i<fNbins;i++) {
147 86 : (*fEventTimeValues)[i]=source.fEventTimeValues->At(i);
148 86 : (*fEventTimeRes)[i]=source.fEventTimeRes->At(i);
149 86 : (*fNvalues)[i]=source.fNvalues->At(i);
150 : }
151 16 : } else {
152 0 : fEventTimeValues = 0;
153 0 : fEventTimeRes = 0;
154 0 : fNvalues = 0;
155 : }
156 :
157 48 : if(source.fTrigMask && fTrigMask) *fTrigMask = *(source.fTrigMask);
158 0 : else if(! fTrigMask) fTrigMask = new AliTOFTriggerMask();
159 : }
160 16 : return *this;
161 0 : }
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 0 : if (this==&obj) return;
170 0 : AliTOFHeader *robj = dynamic_cast<AliTOFHeader*>(&obj);
171 0 : if (!robj) return; // not an AliTOFHeader
172 0 : *robj = *this;
173 :
174 0 : }
175 :
176 : //--------------------------------------------------------------------------
177 : AliTOFHeader::~AliTOFHeader()
178 204 : {
179 :
180 45 : fNbins = 0;
181 45 : if (fEventTimeValues) {
182 48 : delete fEventTimeValues;
183 24 : fEventTimeValues=0;
184 24 : }
185 45 : if (fEventTimeRes) {
186 48 : delete fEventTimeRes;
187 24 : fEventTimeRes=0;
188 24 : }
189 45 : if (fNvalues) {
190 48 : delete fNvalues;
191 24 : fNvalues=0;
192 24 : }
193 45 : if(fTrigMask){
194 90 : delete fTrigMask;
195 45 : fTrigMask=NULL;
196 45 : }
197 :
198 102 : }
199 :
200 : //--------------------------------------------------------------------------
201 : void AliTOFHeader::SetNbins(Int_t nbins)
202 : {
203 : //
204 : //
205 : //
206 :
207 0 : fNbins=nbins;
208 0 : if (!fEventTimeValues)
209 0 : fEventTimeValues = new TArrayF(nbins);
210 : else
211 0 : fEventTimeValues->Set(nbins);
212 :
213 0 : if (!fEventTimeRes)
214 0 : fEventTimeRes = new TArrayF(nbins);
215 : else
216 0 : fEventTimeRes->Set(nbins);
217 :
218 0 : if (!fNvalues)
219 0 : fNvalues = new TArrayI(nbins);
220 : else
221 0 : fNvalues->Set(nbins);
222 :
223 0 : }
224 : //--------------------------------------------------------------------------
225 : void AliTOFHeader::SetEventTimeValues(TArrayF *arr)
226 : {
227 : //
228 : //
229 : //
230 :
231 0 : fNbins=arr->GetSize();
232 :
233 0 : if (!fEventTimeValues)
234 0 : fEventTimeValues = new TArrayF(fNbins);
235 : else
236 0 : fEventTimeValues->Set(fNbins);
237 :
238 0 : for (Int_t ii=0; ii<fNbins; ii++)
239 0 : fEventTimeValues->SetAt(arr->GetAt(ii),ii);
240 :
241 0 : }
242 : //--------------------------------------------------------------------------
243 : void AliTOFHeader::SetEventTimeRes(TArrayF *arr)
244 : {
245 : //
246 : //
247 : //
248 :
249 0 : fNbins=arr->GetSize();
250 :
251 0 : if (!fEventTimeRes)
252 0 : fEventTimeRes = new TArrayF(fNbins);
253 : else
254 0 : fEventTimeRes->Set(fNbins);
255 :
256 0 : for (Int_t ii=0; ii<fNbins; ii++)
257 0 : fEventTimeRes->SetAt(arr->GetAt(ii),ii);
258 :
259 0 : }
260 : //--------------------------------------------------------------------------
261 : void AliTOFHeader::SetNvalues(TArrayI *arr)
262 : {
263 : //
264 : //
265 : //
266 :
267 0 : fNbins=arr->GetSize();
268 :
269 0 : if (!fNvalues)
270 0 : fNvalues = new TArrayI(fNbins);
271 : else
272 0 : fNvalues->Set(fNbins);
273 :
274 0 : for (Int_t ii=0; ii<fNbins; ii++)
275 0 : fNvalues->SetAt(arr->GetAt(ii),ii);
276 :
277 0 : }
|