1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 #include "AliMUONSubEventTracker.h"
23 /// Bus patch structure for tracker raw data
24 /// each Dsp contains at most 5 bus patch structure
25 /// Beside the total length and length of the below data
26 /// the header of the block contains the bus patch id, trigger words
27 /// and data structure itself (11bits for manu id, 6 bits for channel id and
28 /// 12 bits for charge)
32 const Int_t AliMUONSubEventTracker::fgkHeaderLength = 4;
34 ClassImp(AliMUONSubEventTracker)
36 //___________________________________________
37 AliMUONSubEventTracker::AliMUONSubEventTracker()
48 fData = new UInt_t[fBufSize];
50 //___________________________________________
51 AliMUONSubEventTracker::~AliMUONSubEventTracker()
59 //___________________________________________
60 void AliMUONSubEventTracker::SetAlloc(Int_t size)
63 // Allocate size per default 1024;
64 // return if size < 1024
71 //___________________________________________
72 void AliMUONSubEventTracker::AddData(UInt_t data)
74 // could have used class from ROOT
75 // but the structure must be as simple as possible
76 // to be written on disc blockwise, not so sure ?
77 if (fLength == fBufSize)
79 fData[fLength++] = data;
80 fTotalLength = fLength + 4;
83 //___________________________________________
84 void AliMUONSubEventTracker::ResizeData(Int_t size)
86 // In case of resizing the vector
87 // the most simplest way to do it
93 UInt_t* newData = new UInt_t[fBufSize];
94 for (Int_t i = 0; i < fLength; i++)
95 newData[i] = fData[i];
99 //___________________________________________
100 AliMUONSubEventTracker::
101 AliMUONSubEventTracker(const AliMUONSubEventTracker& event): TObject(event)
106 fTotalLength = event.fTotalLength;
107 fLength = event.fLength;
108 fBusPatchId = event.fBusPatchId;
109 fTriggerWord = event.fTriggerWord;
110 fBufSize = event.fBufSize;
112 fData = new UInt_t[event.fBufSize];
113 for (int i = 0; i < event.fBufSize; i++)
114 fData[i] = event.fData[i];
116 //___________________________________________
117 AliMUONSubEventTracker&
118 AliMUONSubEventTracker::operator=(const AliMUONSubEventTracker& event)
121 // assignment operator
123 if (this == &event) return *this;
124 fTotalLength = event.fTotalLength;
125 fLength = event.fLength;
126 fBusPatchId = event.fBusPatchId;
127 fTriggerWord = event.fTriggerWord;
128 fBufSize = event.fBufSize;
131 fData = new UInt_t[event.fBufSize];
132 for (int i = 0; i < event.fBufSize; i++)
133 fData[i] = event.fData[i];
137 //___________________________________________
138 Int_t AliMUONSubEventTracker::Compare(const TObject *obj) const
141 // sort bus patch by bus patch number
142 // important for AliMUONRawWriter
144 AliMUONSubEventTracker* event = (AliMUONSubEventTracker*) obj;
145 return (fBusPatchId > event->GetBusPatchId()) ? 1 : -1;
148 //___________________________________________
149 UInt_t AliMUONSubEventTracker::GetData(Int_t n) const
154 if ( n>=0 && n<fLength ) return fData[n];
156 AliError("Index outside limits.");
160 //___________________________________________
161 Char_t AliMUONSubEventTracker::GetParity(Int_t n) const
166 if ( n>=0 && n<fLength ) return (Char_t)(fData[n] >> 29) & 0x7;
168 AliError("Index outside limits.");
172 //___________________________________________
173 UShort_t AliMUONSubEventTracker::GetManuId(Int_t n) const
178 if ( n>=0 && n<fLength ) return (UShort_t)(fData[n] >> 18) & 0x7FF;
180 AliError("Index outside limits.");
184 //___________________________________________
185 Char_t AliMUONSubEventTracker::GetChannelId(Int_t n) const
190 if ( n>=0 && n<fLength ) return (Char_t)(fData[n] >> 12) & 0x3F;
192 AliError("Index outside limits.");
196 //___________________________________________
197 UShort_t AliMUONSubEventTracker::GetCharge(Int_t n) const
200 // get charge (in ADC)
202 if ( n>=0 && n<fLength ) return (UShort_t)(fData[n] & 0xFFF);
204 AliError("Index outside limits.");