]>
Commit | Line | Data |
---|---|---|
02d01bbf | 1 | /************************************************************************** |
9be2600f | 2 | * This file is property of and copyright by the ALICE HLT Project * |
3 | * ALICE Experiment at CERN, All rights reserved. * | |
02d01bbf | 4 | * * |
9be2600f | 5 | * Primary Authors: Jochen Thaeder <thaeder@kip.uni-heidelberg.de> * |
6 | * for The ALICE HLT Project. * | |
02d01bbf | 7 | * * |
8 | * Permission to use, copy, modify and distribute this software and its * | |
9 | * documentation strictly for non-commercial purposes is hereby granted * | |
10 | * without fee, provided that the above copyright notice appears in all * | |
11 | * copies and that both the copyright notice and this permission notice * | |
12 | * appear in the supporting documentation. The authors make no claims * | |
13 | * about the suitability of this software for any purpose. It is * | |
14 | * provided "as is" without express or implied warranty. * | |
15 | **************************************************************************/ | |
16 | ||
17 | /** @file AliHLTTPCCalibPedestalComponent.cxx | |
18 | @author Jochen Thaeder | |
19 | @date | |
20 | @brief A pedestal calibration component for the TPC. | |
21 | */ | |
22 | ||
23 | #if __GNUC__>= 3 | |
24 | using namespace std; | |
25 | #endif | |
26 | ||
27 | #include "AliHLTTPCLogging.h" | |
28 | #include "AliHLTTPCTransform.h" | |
29 | ||
30 | #include "AliHLTTPCCalibPedestalComponent.h" | |
31 | ||
32 | #include "AliRawDataHeader.h" | |
33 | #include "AliRawReaderMemory.h" | |
34 | #include "AliTPCRawStream.h" | |
35 | ||
36 | #include "AliTPCCalibPedestal.h" | |
37 | ||
38 | #include <stdlib.h> | |
39 | #include <errno.h> | |
40 | #include "TString.h" | |
41 | ||
42 | // this is a global object used for automatic component registration, do not use this | |
43 | AliHLTTPCCalibPedestalComponent gAliHLTTPCCalibPedestalComponent; | |
44 | ||
45 | ClassImp(AliHLTTPCCalibPedestalComponent) | |
46 | ||
47 | AliHLTTPCCalibPedestalComponent::AliHLTTPCCalibPedestalComponent() | |
48 | : | |
49 | fRawReader(NULL), | |
50 | fRawStream(NULL), | |
51 | fCalibPedestal(NULL), | |
9d9ffd37 | 52 | fRCUFormat(kFALSE), |
53 | fMinPatch(5), | |
54 | fMaxPatch(0), | |
55 | fSpecification(0) , | |
56 | fEnableAnalysis(kFALSE) { | |
02d01bbf | 57 | // see header file for class documentation |
58 | // or | |
59 | // refer to README to build package | |
60 | // or | |
61 | // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt | |
62 | } | |
63 | ||
9d9ffd37 | 64 | AliHLTTPCCalibPedestalComponent::~AliHLTTPCCalibPedestalComponent() { |
02d01bbf | 65 | // see header file for class documentation |
66 | } | |
67 | ||
68 | // Public functions to implement AliHLTComponent's interface. | |
69 | // These functions are required for the registration process | |
70 | ||
9d9ffd37 | 71 | const char* AliHLTTPCCalibPedestalComponent::GetComponentID() { |
02d01bbf | 72 | // see header file for class documentation |
9d9ffd37 | 73 | |
02d01bbf | 74 | return "TPCCalibPedestal"; |
75 | } | |
76 | ||
9d9ffd37 | 77 | void AliHLTTPCCalibPedestalComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) { |
02d01bbf | 78 | // see header file for class documentation |
9d9ffd37 | 79 | |
02d01bbf | 80 | list.clear(); |
81 | list.push_back( AliHLTTPCDefinitions::fgkDDLPackedRawDataType ); | |
82 | } | |
83 | ||
9d9ffd37 | 84 | AliHLTComponentDataType AliHLTTPCCalibPedestalComponent::GetOutputDataType() { |
02d01bbf | 85 | // see header file for class documentation |
9d9ffd37 | 86 | |
02d01bbf | 87 | return AliHLTTPCDefinitions::fgkCalibPedestalDataType; |
88 | } | |
89 | ||
9d9ffd37 | 90 | void AliHLTTPCCalibPedestalComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) { |
02d01bbf | 91 | // see header file for class documentation |
9d9ffd37 | 92 | |
02d01bbf | 93 | // XXX TODO: Find more realistic values. |
94 | constBase = 0; | |
95 | inputMultiplier = (2.0); | |
96 | } | |
97 | ||
9d9ffd37 | 98 | AliHLTComponent* AliHLTTPCCalibPedestalComponent::Spawn() { |
02d01bbf | 99 | // see header file for class documentation |
9d9ffd37 | 100 | |
02d01bbf | 101 | return new AliHLTTPCCalibPedestalComponent(); |
102 | } | |
103 | ||
9d9ffd37 | 104 | |
105 | Int_t AliHLTTPCCalibPedestalComponent::ScanArgument( Int_t argc, const char** argv ) { | |
02d01bbf | 106 | // see header file for class documentation |
9d9ffd37 | 107 | |
108 | Int_t iResult = 0; | |
109 | TString argument = ""; | |
110 | TString parameter = ""; | |
111 | ||
112 | if ( !argc ) | |
113 | return -EINVAL; | |
114 | ||
115 | argument = argv[iResult]; | |
02d01bbf | 116 | |
9d9ffd37 | 117 | if ( argument.IsNull() ) |
118 | return -EINVAL; | |
02d01bbf | 119 | |
9d9ffd37 | 120 | // -rcuformat |
121 | if ( argument.CompareTo("-rcuformat") == 0 ) { | |
122 | ||
123 | if ( ++iResult >= argc ) { | |
124 | iResult = -EPROTO; | |
125 | } | |
126 | else { | |
127 | parameter = argv[1]; | |
128 | if ( parameter.CompareTo("old") == 0 ) { | |
02d01bbf | 129 | fRCUFormat = kTRUE; |
9d9ffd37 | 130 | HLTInfo( "RCU Format is set to old." ); |
02d01bbf | 131 | } |
9d9ffd37 | 132 | else if ( parameter.CompareTo("new") == 0 ) { |
02d01bbf | 133 | fRCUFormat = kFALSE; |
9d9ffd37 | 134 | HLTInfo( "RCU Format is set to new." ); |
02d01bbf | 135 | } |
136 | else { | |
9d9ffd37 | 137 | HLTError( "Cannot convert rcu format specifier '%s'.", argv[1] ); |
138 | iResult = -EPROTO; | |
02d01bbf | 139 | } |
9d9ffd37 | 140 | } |
141 | } | |
142 | else if ( argument.CompareTo("-enableanalysis") == 0 ) { | |
143 | HLTInfo( "Analysis before shipping data to FXS enabled." ); | |
144 | fEnableAnalysis = kTRUE; | |
145 | } | |
146 | else { | |
147 | iResult = -EINVAL; | |
148 | } | |
02d01bbf | 149 | |
9d9ffd37 | 150 | return iResult; |
151 | } | |
02d01bbf | 152 | |
9d9ffd37 | 153 | Int_t AliHLTTPCCalibPedestalComponent::InitCalibration() { |
154 | // see header file for class documentation | |
02d01bbf | 155 | |
02d01bbf | 156 | // ** Create pedestal calibration |
157 | if ( fCalibPedestal ) | |
158 | return EINPROGRESS; | |
159 | ||
160 | fCalibPedestal = new AliTPCCalibPedestal(); | |
161 | ||
162 | // ** Create AliRoot Memory Reader | |
163 | if (fRawReader) | |
164 | return EINPROGRESS; | |
165 | ||
166 | #if defined(HAVE_ALIRAWDATA) && defined(HAVE_ALITPCRAWSTREAM_H) | |
167 | fRawReader = new AliRawReaderMemory(); | |
168 | #else | |
169 | HLTFatal("AliRawReader not available - check your build"); | |
170 | return -ENODEV; | |
171 | #endif | |
172 | ||
173 | return 0; | |
174 | } | |
175 | ||
9d9ffd37 | 176 | Int_t AliHLTTPCCalibPedestalComponent::DeinitCalibration() { |
02d01bbf | 177 | // see header file for class documentation |
178 | ||
179 | if ( fRawReader ) | |
180 | delete fRawReader; | |
181 | fRawReader = NULL; | |
182 | ||
183 | if ( fCalibPedestal ) | |
184 | delete fCalibPedestal; | |
185 | fCalibPedestal = NULL; | |
186 | ||
187 | return 0; | |
188 | } | |
189 | ||
190 | /* | |
02d01bbf | 191 | * --- setter for rcuformat need in AliTPCCalibPedestal class |
192 | */ | |
9d9ffd37 | 193 | Int_t AliHLTTPCCalibPedestalComponent::ProcessCalibration( const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData ) { |
02d01bbf | 194 | // see header file for class documentation |
195 | ||
196 | const AliHLTComponentBlockData* iter = NULL; | |
02d01bbf | 197 | |
83fec083 | 198 | AliHLTUInt8_t slice=0, patch=0; |
02d01bbf | 199 | Int_t DDLid = 0; |
200 | ||
201 | // ** Loop over all input blocks and specify which data format should be read - only select Raw Data | |
202 | iter = GetFirstInputBlock( AliHLTTPCDefinitions::fgkDDLPackedRawDataType ); | |
203 | ||
204 | while ( iter != NULL ) { | |
205 | ||
206 | // ** Print Debug output which data format was received | |
207 | char tmp1[14], tmp2[14]; | |
208 | DataType2Text( iter->fDataType, tmp1 ); | |
209 | DataType2Text( AliHLTTPCDefinitions::fgkDDLPackedRawDataType, tmp2 ); | |
210 | ||
9d9ffd37 | 211 | HLTDebug ( "Event received - Event 0x%08LX (%Lu) received datatype: %s - required datatype: %s", |
212 | evtData.fEventID, evtData.fEventID, tmp1, tmp2 ); | |
02d01bbf | 213 | |
214 | // ** Get DDL ID in order to tell the memory reader which slice/patch to use | |
215 | slice = AliHLTTPCDefinitions::GetMinSliceNr( *iter ); | |
216 | patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter ); | |
217 | ||
218 | if (patch < 2) DDLid = 768 + (2 * slice) + patch; | |
219 | else DDLid = 838 + (4*slice) + patch; | |
220 | ||
221 | HLTDebug ( "Input Raw Data - Slice/Patch: %d/%d - EquipmentID : %d.", slice, patch, DDLid ); | |
222 | ||
223 | // ** Get min and max patch, used for output specification | |
9d9ffd37 | 224 | if ( patch < fMinPatch ) fMinPatch = patch; |
225 | if ( patch > fMaxPatch ) fMaxPatch = patch; | |
02d01bbf | 226 | |
227 | // ** Init TPCRawStream | |
228 | fRawReader->SetMemory( reinterpret_cast<UChar_t*>( iter->fPtr ), iter->fSize ); | |
229 | fRawReader->SetEquipmentID(DDLid); | |
230 | ||
231 | fRawStream = new AliTPCRawStream( fRawReader ); | |
232 | fRawStream->SetOldRCUFormat( fRCUFormat ); | |
233 | ||
234 | // ** Process actual Pedestal Calibration - Fill histograms | |
235 | fCalibPedestal->ProcessEvent( fRawStream ); | |
236 | ||
237 | // ** Delete TPCRawStream | |
238 | if ( fRawStream ) | |
239 | delete fRawStream; | |
240 | fRawStream = NULL; | |
241 | ||
242 | // ** Get next input block, with the same specification as defined in GetFirstInputBlock() | |
243 | iter = GetNextInputBlock(); | |
244 | ||
245 | } // while ( iter != NULL ) { | |
9d9ffd37 | 246 | |
247 | // ** Get output specification | |
248 | fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification( slice, slice, fMinPatch, fMaxPatch ); | |
249 | ||
250 | // ** PushBack data to shared memory ... | |
251 | PushBack( (TObject*) fCalibPedestal, AliHLTTPCDefinitions::fgkCalibPedestalDataType, fSpecification); | |
02d01bbf | 252 | |
9d9ffd37 | 253 | return 0; |
254 | } // Int_t AliHLTTPCCalibPedestalComponent::ProcessCalibration( const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData ) { | |
02d01bbf | 255 | |
9d9ffd37 | 256 | |
62fd2539 | 257 | Int_t AliHLTTPCCalibPedestalComponent::ShipDataToFXS( const AliHLTComponentEventData& /*evtData*/, AliHLTComponentTriggerData& /*trigData*/ ) { |
9d9ffd37 | 258 | // see header file for class documentation |
259 | ||
260 | if ( fEnableAnalysis ) | |
261 | fCalibPedestal->Analyse(); | |
02d01bbf | 262 | |
9d9ffd37 | 263 | // ** PushBack data to FXS ... |
264 | PushToFXS( (TObject*) fCalibPedestal, "TPC", "Pedestal" ) ; | |
02d01bbf | 265 | |
266 | return 0; | |
9d9ffd37 | 267 | } // Int_t AliHLTTPCCalibPedestalComponent::ShipDataToFXS( const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData ) { |
268 | ||
269 |