]>
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 | ||
9d9ffd37 | 175 | fRawReader = new AliRawReaderMemory(); |
9d9ffd37 | 176 | |
177 | return 0; | |
591fc7c3 | 178 | #else // HAVE_NOT_ALITPCCALIBPULSER |
9d9ffd37 | 179 | #warning AliTPCCalibPulser not available in this AliRoot version - AliHLTTPCCalibPulserComponent not functional |
180 | HLTFatal("AliTPCCalibPulser not available - check your build"); | |
181 | return -ENODEV; | |
591fc7c3 | 182 | #endif //HAVE_NOT_ALITPCCALIBPULSER |
9d9ffd37 | 183 | } |
184 | ||
185 | Int_t AliHLTTPCCalibPulserComponent::DeinitCalibration() { | |
186 | // see header file for class documentation | |
187 | ||
188 | if ( fRawReader ) | |
189 | delete fRawReader; | |
190 | fRawReader = NULL; | |
191 | ||
591fc7c3 | 192 | #ifndef HAVE_NOT_ALITPCCALIBPULSER |
193 | if ( fCalibPulser ) { | |
9d9ffd37 | 194 | delete fCalibPulser; |
591fc7c3 | 195 | } |
196 | #endif | |
9d9ffd37 | 197 | fCalibPulser = NULL; |
198 | ||
199 | return 0; | |
200 | } | |
201 | ||
202 | /* | |
203 | * --- setter for rcuformat need in AliTPCCalibPulser class | |
204 | */ | |
ed504011 | 205 | Int_t AliHLTTPCCalibPulserComponent::ProcessCalibration( const AliHLTComponentEventData& /*evtData*/, |
206 | AliHLTComponentTriggerData& /*trigData*/ ) { | |
9d9ffd37 | 207 | // see header file for class documentation |
208 | ||
209 | const AliHLTComponentBlockData* iter = NULL; | |
210 | ||
83fec083 | 211 | AliHLTUInt8_t slice=0, patch=0; |
6a8e0bb4 | 212 | Int_t ddlId = 0; |
9d9ffd37 | 213 | |
214 | // ** Loop over all input blocks and specify which data format should be read - only select Raw Data | |
ed504011 | 215 | iter = GetFirstInputBlock( kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTPC); |
9d9ffd37 | 216 | |
217 | while ( iter != NULL ) { | |
218 | ||
219 | // ** Print Debug output which data format was received | |
ed504011 | 220 | // char tmp1[14], tmp2[14]; |
221 | // DataType2Text( iter->fDataType, tmp1 ); | |
222 | // DataType2Text( AliHLTTPCDefinitions::fgkDDLPackedRawDataType, tmp2 ); | |
223 | // HLTDebug ( "Event received - Event 0x%08LX (%Lu) received datatype: %s - required datatype: %s", | |
224 | // evtData.fEventID, evtData.fEventID, tmp1, tmp2 ); | |
9d9ffd37 | 225 | |
226 | // ** Get DDL ID in order to tell the memory reader which slice/patch to use | |
227 | slice = AliHLTTPCDefinitions::GetMinSliceNr( *iter ); | |
228 | patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter ); | |
229 | ||
6a8e0bb4 | 230 | if (patch < 2) ddlId = 768 + (2 * slice) + patch; |
231 | else ddlId = 838 + (4*slice) + patch; | |
9d9ffd37 | 232 | |
6a8e0bb4 | 233 | HLTDebug ( "Input Raw Data - Slice/Patch: %d/%d - EquipmentID : %d.", slice, patch, ddlId ); |
9d9ffd37 | 234 | |
235 | // ** Get min and max patch, used for output specification | |
236 | if ( patch < fMinPatch ) fMinPatch = patch; | |
237 | if ( patch > fMaxPatch ) fMaxPatch = patch; | |
238 | ||
239 | // ** Init TPCRawStream | |
240 | fRawReader->SetMemory( reinterpret_cast<UChar_t*>( iter->fPtr ), iter->fSize ); | |
6a8e0bb4 | 241 | fRawReader->SetEquipmentID(ddlId); |
9d9ffd37 | 242 | |
243 | fRawStream = new AliTPCRawStream( fRawReader ); | |
244 | fRawStream->SetOldRCUFormat( fRCUFormat ); | |
245 | ||
591fc7c3 | 246 | #ifndef HAVE_NOT_ALITPCCALIBPULSER |
9d9ffd37 | 247 | // ** Process actual Pulser Calibration - Fill histograms |
248 | fCalibPulser->ProcessEvent( fRawStream ); | |
591fc7c3 | 249 | #else //!HAVE_NOT_ALITPCCALIBPULSER |
9d9ffd37 | 250 | HLTFatal("AliTPCCalibPulser not available - check your build"); |
251 | return -ENODEV; | |
591fc7c3 | 252 | #endif //HAVE_NOT_ALITPCCALIBPULSER |
9d9ffd37 | 253 | |
254 | // ** Delete TPCRawStream | |
255 | if ( fRawStream ) | |
256 | delete fRawStream; | |
257 | fRawStream = NULL; | |
258 | ||
259 | // ** Get next input block, with the same specification as defined in GetFirstInputBlock() | |
260 | iter = GetNextInputBlock(); | |
261 | ||
262 | } // while ( iter != NULL ) { | |
263 | ||
264 | // ** Get output specification | |
265 | fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification( slice, slice, fMinPatch, fMaxPatch ); | |
266 | ||
267 | // ** PushBack data to shared memory ... | |
268 | PushBack( (TObject*) fCalibPulser, AliHLTTPCDefinitions::fgkCalibPulserDataType, fSpecification); | |
269 | ||
270 | return 0; | |
271 | } // Int_t AliHLTTPCCalibPulserComponent::ProcessCalibration( const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData ) { | |
272 | ||
273 | ||
ed504011 | 274 | Int_t AliHLTTPCCalibPulserComponent::ShipDataToFXS( const AliHLTComponentEventData& /*evtData*/, |
275 | AliHLTComponentTriggerData& /*trigData*/ ) { | |
9d9ffd37 | 276 | // see header file for class documentation |
277 | ||
591fc7c3 | 278 | #ifndef HAVE_NOT_ALITPCCALIBPULSER |
9d9ffd37 | 279 | if ( fEnableAnalysis ) |
280 | fCalibPulser->Analyse(); | |
591fc7c3 | 281 | #else //!HAVE_NOT_ALITPCCALIBPULSER |
9d9ffd37 | 282 | HLTFatal("AliTPCCalibPulser not available - check your build"); |
283 | return -ENODEV; | |
591fc7c3 | 284 | #endif //HAVE_NOT_ALITPCCALIBPULSER |
9d9ffd37 | 285 | |
286 | // ** PushBack data to FXS ... | |
287 | PushToFXS( (TObject*) fCalibPulser, "TPC", "Pulser" ) ; | |
288 | ||
289 | return 0; | |
290 | } // Int_t AliHLTTPCCalibPulserComponent::ShipDataToFXS( const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData ) { |