Coverity fix for uninitialized variables and check for returned null value
[u/mrichter/AliRoot.git] / MUON / AliMUONLocalTrigger.cxx
CommitLineData
a9e2aefa 1/**************************************************************************
2 * Copyright(c) 1998-1999, 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
30178c30 16/* $Id$ */
a9e2aefa 17
8d7dfec2 18
a9e2aefa 19#include "AliMUONLocalTrigger.h"
2be06f1e 20#include "AliLog.h"
8d7dfec2 21#include "AliMUONLocalStruct.h"
00d46f24 22#include "AliMUONRawStreamTriggerHP.h"
8aac6cce 23#include <Riostream.h>
89976fde 24#include <TArrayS.h>
a9e2aefa 25
3d1463c8 26//-----------------------------------------------------------------------------
5398f946 27/// \class AliMUONLocalTrigger
8d7dfec2 28/// Local Trigger algorithm data outputs
5398f946 29/// (contains local trigger decision and bit patterns) \n
30/// Add SetLocalStruct method for rawdata (Ch. Finck)
31/// \author Ph. Crochet
3d1463c8 32//-----------------------------------------------------------------------------
5398f946 33
cdd730d0 34using std::endl;
35using std::cout;
5398f946 36/// \cond CLASSIMP
37ClassImp(AliMUONLocalTrigger)
38/// \endcond
8d7dfec2 39
a9e2aefa 40//----------------------------------------------------------------------
41AliMUONLocalTrigger::AliMUONLocalTrigger()
8d7dfec2 42 : TObject(),
43 fLoCircuit(0),
44 fLoStripX(0),
45 fLoDev(0),
8aac6cce 46 fLoSdev(1),
47 fLoTrigY(1),
48 fLoStripY(15),
8d7dfec2 49 fLoLpt(0),
50 fLoHpt(0),
8d7dfec2 51
52 fX1Pattern(0),
53 fX2Pattern(0),
54 fX3Pattern(0),
55 fX4Pattern(0),
56
57 fY1Pattern(0),
58 fY2Pattern(0),
59 fY3Pattern(0),
00d46f24 60 fY4Pattern(0),
61
62 fHitPatternFromResponse(0xFF),
63 fTriggerWithoutChamber(0)
a9e2aefa 64{
5398f946 65/// Default constructor
a9e2aefa 66}
67//----------------------------------------------------------------------
30178c30 68AliMUONLocalTrigger::AliMUONLocalTrigger(const AliMUONLocalTrigger& theMUONLocalTrig)
1657f946 69 : TObject(theMUONLocalTrig),
70 fLoCircuit(theMUONLocalTrig.fLoCircuit),
71 fLoStripX(theMUONLocalTrig.fLoStripX),
72 fLoDev(theMUONLocalTrig.fLoDev),
8aac6cce 73 fLoSdev(theMUONLocalTrig.fLoSdev),
74 fLoTrigY(theMUONLocalTrig.fLoTrigY),
1657f946 75 fLoStripY(theMUONLocalTrig.fLoStripY),
76 fLoLpt(theMUONLocalTrig.fLoLpt),
77 fLoHpt(theMUONLocalTrig.fLoHpt),
1657f946 78
79 fX1Pattern(theMUONLocalTrig.fX1Pattern),
80 fX2Pattern(theMUONLocalTrig.fX2Pattern),
81 fX3Pattern(theMUONLocalTrig.fX3Pattern),
82 fX4Pattern(theMUONLocalTrig.fX4Pattern),
83
84 fY1Pattern(theMUONLocalTrig.fY1Pattern),
85 fY2Pattern(theMUONLocalTrig.fY2Pattern),
86 fY3Pattern(theMUONLocalTrig.fY3Pattern),
00d46f24 87 fY4Pattern(theMUONLocalTrig.fY4Pattern),
88
89 fHitPatternFromResponse(theMUONLocalTrig.fHitPatternFromResponse),
90 fTriggerWithoutChamber(theMUONLocalTrig.fTriggerWithoutChamber)
e9b63742 91{
5398f946 92/// Copy constructor (useful for TClonesArray)
93
e9b63742 94}
71a2d3aa 95
96//----------------------------------------------------------------------
97AliMUONLocalTrigger::~AliMUONLocalTrigger()
98{
99/// Destructor
100}
101
e9b63742 102//----------------------------------------------------------------------
30178c30 103AliMUONLocalTrigger& AliMUONLocalTrigger::operator=(const AliMUONLocalTrigger& theMUONLocalTrig)
e9b63742 104{
5398f946 105/// Assigment operator;
106/// equal operator (useful for non-pointer member in TClonesArray)
8d7dfec2 107
30178c30 108 if (this == &theMUONLocalTrig)
e9b63742 109 return *this;
110
30178c30 111 // base class assignement
112 TObject::operator=(theMUONLocalTrig);
113
114 fLoCircuit = theMUONLocalTrig.fLoCircuit;
115 fLoStripX = theMUONLocalTrig.fLoStripX;
116 fLoDev = theMUONLocalTrig.fLoDev;
8aac6cce 117 fLoSdev = theMUONLocalTrig.fLoSdev;
118 fLoTrigY = theMUONLocalTrig.fLoTrigY;
30178c30 119 fLoStripY = theMUONLocalTrig.fLoStripY;
120 fLoLpt = theMUONLocalTrig.fLoLpt;
121 fLoHpt = theMUONLocalTrig.fLoHpt;
e9b63742 122
6dc7fcdf 123 fX1Pattern = theMUONLocalTrig.fX1Pattern;
124 fX2Pattern = theMUONLocalTrig.fX2Pattern;
125 fX3Pattern = theMUONLocalTrig.fX3Pattern;
126 fX4Pattern = theMUONLocalTrig.fX4Pattern;
127
128 fY1Pattern = theMUONLocalTrig.fY1Pattern;
129 fY2Pattern = theMUONLocalTrig.fY2Pattern;
130 fY3Pattern = theMUONLocalTrig.fY3Pattern;
131 fY4Pattern = theMUONLocalTrig.fY4Pattern;
132
00d46f24 133 fHitPatternFromResponse = theMUONLocalTrig.fHitPatternFromResponse;
134 fTriggerWithoutChamber = theMUONLocalTrig.fTriggerWithoutChamber;
135
e9b63742 136 return *this;
137}
138
1657f946 139
6dc7fcdf 140//----------------------------------------------------------------------
89976fde 141Char_t AliMUONLocalTrigger::GetLoDecision() const
6dc7fcdf 142{
5398f946 143/// Get local decision
144/// from H(L)pt;
145/// returns local trigger decision
8d7dfec2 146
89976fde 147 Char_t rv = (fLoLpt & 0x3);
148 rv |= (fLoHpt << 2) & 0xC;
402fb06e 149
89976fde 150 return rv;
6dc7fcdf 151}
2be06f1e 152
9016450b 153//___________________________________________
154void AliMUONLocalTrigger::GetXPattern(TArrayS& array) const
155{
156 /// return array of X pattern
157 Short_t vec[4] = {GetX1Pattern(), GetX2Pattern(), GetX3Pattern(), GetX4Pattern()};
158 array.Set(4, vec);
159}
160
161//___________________________________________
162void AliMUONLocalTrigger::GetYPattern(TArrayS& array) const
163{
164 /// return array of Y pattern
165 Short_t vec[4] = {GetY1Pattern(), GetY2Pattern(), GetY3Pattern(), GetY4Pattern()};
166 array.Set(4, vec);
167}
2be06f1e 168
89976fde 169//___________________________________________
170Bool_t
171AliMUONLocalTrigger::IsNull() const
172{
173 /// Whether or not this card has something usefull to say or not
174 return ( fX1Pattern == 0 &&
175 fX2Pattern == 0 &&
176 fX3Pattern == 0 &&
177 fX4Pattern == 0 &&
178 fY1Pattern == 0 &&
179 fY2Pattern == 0 &&
180 fY3Pattern == 0 &&
181 fY4Pattern == 0 );
182}
183
8d7dfec2 184//----------------------------------------------------------------------
185void AliMUONLocalTrigger::SetLocalStruct(Int_t loCircuit, AliMUONLocalStruct& localStruct)
186{
5398f946 187/// Set local trigger info from rawdata localStruct
8d7dfec2 188
189 // set id'
190 SetLoCircuit(loCircuit);
191
8aac6cce 192 // set X, Y, dev, Sdev and TrigY
8d7dfec2 193 SetLoStripX((Int_t)localStruct.GetXPos());
194 SetLoStripY((Int_t)localStruct.GetYPos());
195 SetLoDev((Int_t)localStruct.GetXDev());
8aac6cce 196 SetLoSdev((Int_t)localStruct.GetSXDev());
01b3cffa 197 SetLoTrigY((Int_t)localStruct.GetTrigY());
8d7dfec2 198
199 // set L(H)pt
200 SetLoLpt(localStruct.GetLpt());
a026ce9e 201 SetLoHpt(localStruct.GetHpt());
202
203 // set pattern X
204 SetX1Pattern(localStruct.GetX1());
205 SetX2Pattern(localStruct.GetX2());
206 SetX3Pattern(localStruct.GetX3());
207 SetX4Pattern(localStruct.GetX4());
208
209 // set pattern Y
210 SetY1Pattern(localStruct.GetY1());
211 SetY2Pattern(localStruct.GetY2());
212 SetY3Pattern(localStruct.GetY3());
213 SetY4Pattern(localStruct.GetY4());
214
215}
216
217//----------------------------------------------------------------------
218void AliMUONLocalTrigger::SetLocalStruct(Int_t loCircuit, const AliMUONRawStreamTriggerHP::AliLocalStruct& localStruct)
219{
220/// Set local trigger info from rawdata localStruct (new raw reader)
221
222 // set id'
223 SetLoCircuit(loCircuit);
224
225 // set X, Y, dev, Sdev and TrigY
226 SetLoStripX((Int_t)localStruct.GetXPos());
227 SetLoStripY((Int_t)localStruct.GetYPos());
228 SetLoDev((Int_t)localStruct.GetXDev());
229 SetLoSdev((Int_t)localStruct.GetSXDev());
230 SetLoTrigY((Int_t)localStruct.GetTrigY());
231
232 // set L(H)pt
233 SetLoLpt(localStruct.GetLpt());
8d7dfec2 234 SetLoHpt(localStruct.GetHpt());
235
236 // set pattern X
237 SetX1Pattern(localStruct.GetX1());
238 SetX2Pattern(localStruct.GetX2());
239 SetX3Pattern(localStruct.GetX3());
240 SetX4Pattern(localStruct.GetX4());
241
242 // set pattern Y
243 SetY1Pattern(localStruct.GetY1());
244 SetY2Pattern(localStruct.GetY2());
245 SetY3Pattern(localStruct.GetY3());
246 SetY4Pattern(localStruct.GetY4());
247
248}
eba3379e 249
89976fde 250namespace
251{
252 const char* AsString(Int_t t)
253 {
254 switch (t)
255 {
256 case 0:
257 return "no";
258 break;
259 case 1:
260 return "minus";
261 break;
262 case 2:
263 return "plus";
264 break;
265 case 3:
266 return "undef";
267 break;
268 default:
269 return "";
270 break;
271 }
272 }
273}
274
eba3379e 275//----------------------------------------------------------------------
276void AliMUONLocalTrigger::Print(Option_t* opt) const
277{
71a2d3aa 278/// Printing Local Trigger information
279
eba3379e 280 TString sopt(opt);
281 sopt.ToUpper();
eba3379e 282
89976fde 283 cout << Form("Circuit %3d Decision %2d StripX %2d Dev %2d(%1d) StripY %2d Lpt %6s Hpt %6s",
284 LoCircuit(), GetLoDecision(),
285 LoStripX(), LoDev(), LoSdev(), LoStripY(),
1130977f 286 AsString(LoLpt()),AsString(LoHpt())) << endl;
89976fde 287
288 if ( sopt.Contains("FULL") ) {
eba3379e 289
89976fde 290 cout << Form("Xpatterns = 0x %04x %04x %04x %04x",
291 fX1Pattern,fX2Pattern,fX3Pattern,fX4Pattern) << endl;
292 cout << Form("Ypatterns = 0x %04x %04x %04x %04x",
293 fY1Pattern,fY2Pattern,fY3Pattern,fY4Pattern) << endl;
eba3379e 294 }
295}
296
89976fde 297//----------------------------------------------------------------------
d72d7b9e 298Int_t AliMUONLocalTrigger::GetDeviation() const
299{
5a240757 300 /// return deviation
301
302 Int_t deviation = LoDev();
303 Int_t sign = 0;
304 if ( !LoSdev() && deviation ) sign=-1;
305 if ( !LoSdev() && !deviation ) sign= 0;
306 if ( LoSdev() == 1 ) sign=+1;
307 deviation *= sign;
308 deviation += 15;
309 return deviation;
310}
311
312//----------------------------------------------------------------------
313void AliMUONLocalTrigger::SetDeviation(Int_t deviation)
314{
315 /// set LoDev and LoSDev according to deviation
316
317 deviation -= 15;
318 if (deviation > 0) {
319 SetLoDev(deviation);
320 SetLoSdev(1);
321 } else {
322 SetLoDev(-deviation);
323 SetLoSdev(0);
324 }
d72d7b9e 325}
326
327//----------------------------------------------------------------------
89976fde 328const char*
329AliMUONLocalTrigger::GetName() const
330{
331/// Generate name
332
333 return Form("LocalBoard%3d",LoCircuit());
334}
d72d7b9e 335
336
337//----------------------------------------------------------------------
9ee1d6ff 338Bool_t AliMUONLocalTrigger::IsTrigX() const
d72d7b9e 339{
340/// Trigger response X strips
341 Bool_t xTrig;
342 if ( LoSdev()==1 && LoDev()==0 &&
343 LoStripX()==0) xTrig=kFALSE; // no trigger in X
344 else xTrig = kTRUE; // trigger in X
345 return xTrig;
346}
347
348
349//----------------------------------------------------------------------
9ee1d6ff 350Bool_t AliMUONLocalTrigger::IsTrigY() const
d72d7b9e 351{
352/// Trigger response Y strips
353 Bool_t yTrig;
354 if ( LoTrigY()==1 &&
355 LoStripY()==15 ) yTrig = kFALSE; // no trigger in Y
356 else yTrig = kTRUE; // trigger in Y
357 return yTrig;
358}