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