]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/TPCLib/AliHLTTPCCalibPulserComponent.cxx
bugfix: compilation error after arturs changes
[u/mrichter/AliRoot.git] / HLT / TPCLib / AliHLTTPCCalibPulserComponent.cxx
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
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
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
42 #ifndef HAVE_NOT_ALITPCCALIBPULSER
43 #include "AliTPCCalibPulser.h"
44 #endif // HAVE_NOT_ALITPCCALIBPULSER
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
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     
164 #ifndef HAVE_NOT_ALITPCCALIBPULSER
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;
183 #else // HAVE_NOT_ALITPCCALIBPULSER
184 #warning AliTPCCalibPulser not available in this AliRoot version - AliHLTTPCCalibPulserComponent not functional
185   HLTFatal("AliTPCCalibPulser  not available - check your build");
186   return -ENODEV;
187 #endif //HAVE_NOT_ALITPCCALIBPULSER
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
197 #ifndef HAVE_NOT_ALITPCCALIBPULSER
198   if ( fCalibPulser ) {
199     delete fCalibPulser;
200   }
201 #endif
202   fCalibPulser = NULL;
203
204   return 0;
205 }
206
207 /*
208  * --- setter for rcuformat need in AliTPCCalibPulser class
209  */
210 Int_t AliHLTTPCCalibPulserComponent::ProcessCalibration( const AliHLTComponentEventData& /*evtData*/, AliHLTComponentTriggerData& /*trigData*/ ) {
211   // see header file for class documentation
212   
213   const AliHLTComponentBlockData* iter = NULL;
214
215   AliHLTUInt8_t slice=0, patch=0;
216   Int_t ddlId = 0;
217     
218   // ** Loop over all input blocks and specify which data format should be read - only select Raw Data
219   iter = GetFirstInputBlock( AliHLTTPCDefinitions::fgkDDLPackedRawDataType );
220   
221   while ( iter != NULL ) {
222     
223     // ** Print Debug output which data format was received
224     char tmp1[14], tmp2[14];
225     DataType2Text( iter->fDataType, tmp1 );
226     DataType2Text( AliHLTTPCDefinitions::fgkDDLPackedRawDataType, tmp2 );
227
228 //     HLTDebug ( "Event received - Event 0x%08LX (%Lu) received datatype: %s - required datatype: %s", 
229 //             evtData.fEventID, evtData.fEventID, tmp1, tmp2 );
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
235     if (patch < 2) ddlId = 768 + (2 * slice) + patch;
236     else ddlId = 838 + (4*slice) + patch;
237
238     HLTDebug ( "Input Raw Data - Slice/Patch: %d/%d - EquipmentID : %d.", slice, patch, ddlId );
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 );
246     fRawReader->SetEquipmentID(ddlId);
247
248     fRawStream = new AliTPCRawStream( fRawReader );
249     fRawStream->SetOldRCUFormat( fRCUFormat );
250
251 #ifndef HAVE_NOT_ALITPCCALIBPULSER
252     // ** Process actual Pulser Calibration - Fill histograms
253     fCalibPulser->ProcessEvent( fRawStream );
254 #else //!HAVE_NOT_ALITPCCALIBPULSER
255     HLTFatal("AliTPCCalibPulser  not available - check your build");
256     return -ENODEV;
257 #endif //HAVE_NOT_ALITPCCALIBPULSER
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
279 Int_t AliHLTTPCCalibPulserComponent::ShipDataToFXS( const AliHLTComponentEventData& /*evtData*/, AliHLTComponentTriggerData& /*trigData*/ ) {
280   // see header file for class documentation
281     
282 #ifndef HAVE_NOT_ALITPCCALIBPULSER
283   if ( fEnableAnalysis )
284     fCalibPulser->Analyse();
285 #else //!HAVE_NOT_ALITPCCALIBPULSER
286   HLTFatal("AliTPCCalibPulser  not available - check your build");
287   return -ENODEV;
288 #endif //HAVE_NOT_ALITPCCALIBPULSER
289   
290   // ** PushBack data to FXS ...
291   PushToFXS( (TObject*) fCalibPulser, "TPC", "Pulser" ) ;
292   
293   return 0;
294 } // Int_t AliHLTTPCCalibPulserComponent::ShipDataToFXS( const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData ) {