]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/TPCLib/AliHLTTPCCalibPedestalComponent.cxx
- workaround for copying and merging of ESDs: The HLTOUT contains ESDs for every...
[u/mrichter/AliRoot.git] / HLT / TPCLib / AliHLTTPCCalibPedestalComponent.cxx
index dfdb3b604d7397d9f62764b5fa2f7f00f4fb4c1a..807158aeffe851e1de7383b254e104bf0c7090f3 100755 (executable)
@@ -1,10 +1,9 @@
-
-
 /**************************************************************************
- * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * This file is property of and copyright by the ALICE HLT Project        * 
+ * ALICE Experiment at CERN, All rights reserved.                         *
  *                                                                        *
- * Authors: Jochen Thaeder <thaeder@kip.uni-heidelberg.de>                *
- *          for The ALICE Off-line Project.                               *
+ * Primary Authors: Jochen Thaeder <thaeder@kip.uni-heidelberg.de>        *
+ *                  for The ALICE HLT Project.                            *
  *                                                                        *
  * Permission to use, copy, modify and distribute this software and its   *
  * documentation strictly for non-commercial purposes is hereby granted   *
     @brief  A pedestal calibration component for the TPC.
 */
 
+// see header file for class documentation
+// or
+// refer to README to build package
+// or
+// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt   
+
 #if __GNUC__>= 3
 using namespace std;
 #endif
@@ -40,9 +45,7 @@ using namespace std;
 #include <errno.h>
 #include "TString.h"
 
-// this is a global object used for automatic component registration, do not use this
-AliHLTTPCCalibPedestalComponent gAliHLTTPCCalibPedestalComponent;
-
+/** ROOT macro for the implementation of ROOT specific class methods */
 ClassImp(AliHLTTPCCalibPedestalComponent)
 
 AliHLTTPCCalibPedestalComponent::AliHLTTPCCalibPedestalComponent()
@@ -50,8 +53,11 @@ AliHLTTPCCalibPedestalComponent::AliHLTTPCCalibPedestalComponent()
   fRawReader(NULL),
   fRawStream(NULL),
   fCalibPedestal(NULL),
-  fRCUFormat(kFALSE)
-{
+  fRCUFormat(kFALSE),
+  fMinPatch(5),
+  fMaxPatch(0),
+  fSpecification(0) ,
+  fEnableAnalysis(kFALSE) {
   // see header file for class documentation
   // or
   // refer to README to build package
@@ -59,102 +65,98 @@ AliHLTTPCCalibPedestalComponent::AliHLTTPCCalibPedestalComponent()
   // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
 }
 
-AliHLTTPCCalibPedestalComponent::AliHLTTPCCalibPedestalComponent(const AliHLTTPCCalibPedestalComponent&)
-  :
-  fRawReader(NULL),
-  fRawStream(NULL),
-  fCalibPedestal(NULL),
-  fRCUFormat(kFALSE)
-{
-  // see header file for class documentation
-  HLTFatal("copy constructor untested");
-}
-
-AliHLTTPCCalibPedestalComponent& AliHLTTPCCalibPedestalComponent::operator=(const AliHLTTPCCalibPedestalComponent&)
-{ 
-  // see header file for class documentation
-  HLTFatal("assignment operator untested");
-  return *this;
-}      
-
-AliHLTTPCCalibPedestalComponent::~AliHLTTPCCalibPedestalComponent()
-{
+AliHLTTPCCalibPedestalComponent::~AliHLTTPCCalibPedestalComponent() {
   // see header file for class documentation
 }
 
 // Public functions to implement AliHLTComponent's interface.
 // These functions are required for the registration process
 
-const char* AliHLTTPCCalibPedestalComponent::GetComponentID()
-{
+const char* AliHLTTPCCalibPedestalComponent::GetComponentID() {
   // see header file for class documentation
+
   return "TPCCalibPedestal";
 }
 
-void AliHLTTPCCalibPedestalComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
-{
+void AliHLTTPCCalibPedestalComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) {
   // see header file for class documentation
+
   list.clear(); 
   list.push_back( AliHLTTPCDefinitions::fgkDDLPackedRawDataType );
 }
 
-AliHLTComponentDataType AliHLTTPCCalibPedestalComponent::GetOutputDataType()
-{
+AliHLTComponentDataType AliHLTTPCCalibPedestalComponent::GetOutputDataType() {
   // see header file for class documentation
+
   return AliHLTTPCDefinitions::fgkCalibPedestalDataType;
 }
 
-void AliHLTTPCCalibPedestalComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
-{
+void AliHLTTPCCalibPedestalComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) {
   // see header file for class documentation
+
   // XXX TODO: Find more realistic values.  
   constBase = 0;
   inputMultiplier = (2.0);
 }
 
-AliHLTComponent* AliHLTTPCCalibPedestalComponent::Spawn()
-{
+AliHLTComponent* AliHLTTPCCalibPedestalComponent::Spawn() {
   // see header file for class documentation
+
   return new AliHLTTPCCalibPedestalComponent();
 }  
 
-Int_t AliHLTTPCCalibPedestalComponent::DoInit( int argc, const char** argv ) {
+
+Int_t AliHLTTPCCalibPedestalComponent::ScanArgument( Int_t argc, const char** argv ) {
   // see header file for class documentation
+
+  Int_t iResult = 0;
+  TString argument = "";
+  TString parameter = "";
+
+  if ( !argc ) 
+    return -EINVAL;
+
+  argument = argv[iResult];
   
-  // ** Interprete commandline arguments
-  Int_t i = 0;
-  Char_t* cpErr;
+  if ( argument.IsNull() ) 
+    return -EINVAL;
 
-  while ( i < argc ) {      
-    
-    // -- rcu format option -- default in constructor: kFALSE => use new data format
-    if ( !strcmp( argv[i], "rcuformat" ) ) {
-      if ( argc <= i+1 ) {
-       HLTError( "Missing RCU format - RCU format not specified" );
-       return ENOTSUP;
-      }
-      
-      // Decodes the rcu format --  options: "old" or "new"
-      if ( !strcmp( argv[i+1], "old" ) ) {
+  // -rcuformat
+  if ( argument.CompareTo("-rcuformat") == 0 ) {
+
+    if ( ++iResult >= argc  ) {
+      iResult = -EPROTO;
+    }
+    else {
+      parameter = argv[1];
+      if ( parameter.CompareTo("old") == 0 ) {
        fRCUFormat = kTRUE;
+        HLTInfo( "RCU Format is set to old." );
       }
-      else if ( !strcmp( argv[i+1], "new" ) ) {
+      else if ( parameter.CompareTo("new") == 0 ) {
        fRCUFormat = kFALSE;
+        HLTInfo( "RCU Format is set to new." );
       }
       else {
-       HLTError( "Missing RCU format - Cannot convert rcu format  specifier '%s'.", argv[i+1] );
-       return EINVAL;
+       HLTError( "Cannot convert rcu format specifier '%s'.", argv[1] );
+       iResult = -EPROTO;
       }
+    } 
+  }
+  else if ( argument.CompareTo("-enableanalysis") == 0 ) {
+    HLTInfo( "Analysis before shipping data to FXS enabled." );
+    fEnableAnalysis = kTRUE;
+  }
+  else {
+    iResult = -EINVAL;
+  }
       
-      i += 2;
-      continue;
-    }
+  return iResult;
+}
 
-    HLTError( "Unknown Option - Unknown option '%s'", argv[i] );
-    return EINVAL;
+Int_t AliHLTTPCCalibPedestalComponent::InitCalibration() {
+  // see header file for class documentation
     
-  }
-  
   // ** Create pedestal calibration
   if ( fCalibPedestal )
     return EINPROGRESS;
@@ -165,18 +167,12 @@ Int_t AliHLTTPCCalibPedestalComponent::DoInit( int argc, const char** argv ) {
   if (fRawReader)
     return EINPROGRESS;
 
-#if defined(HAVE_ALIRAWDATA) && defined(HAVE_ALITPCRAWSTREAM_H) 
   fRawReader = new AliRawReaderMemory();
-#else
-  HLTFatal("AliRawReader  not available - check your build");
-  return -ENODEV;
-#endif
 
   return 0;
 }
 
-Int_t AliHLTTPCCalibPedestalComponent::DoDeinit()
-{
+Int_t AliHLTTPCCalibPedestalComponent::DeinitCalibration() {
   // see header file for class documentation
 
   if ( fRawReader )
@@ -191,50 +187,45 @@ Int_t AliHLTTPCCalibPedestalComponent::DoDeinit()
 }
 
 /*
- * --- will be changing with the Calibration Processor, -> Split DoEvent into 2 functions:
- *    --- > Process event
- *    --- > Ship Data to FXS
  * --- setter for rcuformat need in AliTPCCalibPedestal class
  */
-Int_t AliHLTTPCCalibPedestalComponent::DoEvent( const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData ) {
+Int_t AliHLTTPCCalibPedestalComponent::ProcessCalibration( const AliHLTComponentEventData& /*evtData*/, 
+                                                          AliHLTComponentTriggerData& /*trigData*/ ) {
   // see header file for class documentation
   
   const AliHLTComponentBlockData* iter = NULL;
-  AliHLTUInt32_t spec = 0;
 
-  Int_t slice, patch;
-  Int_t minPatch = 5;
-  Int_t maxPatch = 0;
-  Int_t DDLid = 0;
+  AliHLTUInt8_t slice=0, patch=0;
+  Int_t ddlId = 0;
     
   // ** Loop over all input blocks and specify which data format should be read - only select Raw Data
-  iter = GetFirstInputBlock( AliHLTTPCDefinitions::fgkDDLPackedRawDataType );
+  iter = GetFirstInputBlock( kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTPC);
   
   while ( iter != NULL ) {
     
     // ** Print Debug output which data format was received
-    char tmp1[14], tmp2[14];
-    DataType2Text( iter->fDataType, tmp1 );
-    DataType2Text( AliHLTTPCDefinitions::fgkDDLPackedRawDataType, tmp2 );
-
-    HLTDebug ( "Event received - Event 0x%08LX (%Lu) received datatype: %s - required datatype: %s", evtData.fEventID, evtData.fEventID, tmp1, tmp2 );
+    //    char tmp1[14], tmp2[14];
+    //    DataType2Text( iter->fDataType, tmp1 );
+    //    DataType2Text( AliHLTTPCDefinitions::fgkDDLPackedRawDataType, tmp2 );
+    //    HLTDebug ( "Event received - Event 0x%08LX (%Lu) received datatype: %s - required datatype: %s", 
+    //    evtData.fEventID, evtData.fEventID, tmp1, tmp2 );
 
     // ** Get DDL ID in order to tell the memory reader which slice/patch to use
     slice = AliHLTTPCDefinitions::GetMinSliceNr( *iter );
     patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter );
 
-    if (patch < 2) DDLid = 768 + (2 * slice) + patch;
-    else DDLid = 838 + (4*slice) + patch;
+    if (patch < 2) ddlId = 768 + (2 * slice) + patch;
+    else ddlId = 838 + (4*slice) + patch;
 
-    HLTDebug ( "Input Raw Data - Slice/Patch: %d/%d - EquipmentID : %d.", slice, patch, DDLid );
+    HLTDebug ( "Input Raw Data - Slice/Patch: %d/%d - EquipmentID : %d.", slice, patch, ddlId );
 
     // ** Get min and max patch, used for output specification
-    if ( patch < minPatch ) minPatch =  patch;
-    if ( patch > maxPatch ) maxPatch =  patch;
+    if ( patch < fMinPatch ) fMinPatch =  patch;
+    if ( patch > fMaxPatch ) fMaxPatch =  patch;
 
     // ** Init TPCRawStream
     fRawReader->SetMemory( reinterpret_cast<UChar_t*>( iter->fPtr ), iter->fSize );
-    fRawReader->SetEquipmentID(DDLid);
+    fRawReader->SetEquipmentID(ddlId);
 
     fRawStream = new AliTPCRawStream( fRawReader );
     fRawStream->SetOldRCUFormat( fRCUFormat );
@@ -251,17 +242,28 @@ Int_t AliHLTTPCCalibPedestalComponent::DoEvent( const AliHLTComponentEventData&
     iter = GetNextInputBlock();
 
   } //  while ( iter != NULL ) {
+    
+  // ** Get output specification
+  fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification( slice, slice, fMinPatch, fMaxPatch );
+
+  // ** PushBack data to shared memory ... 
+  PushBack( (TObject*) fCalibPedestal, AliHLTTPCDefinitions::fgkCalibPedestalDataType, fSpecification);
   
-  // !!! HIGHLY DEBUG !!!
-  //  fCalibPedestal->DumpToFile("Pedestal.root");
-  // !!! HIGHLY DEBUG !!!
+  return 0;
+} // Int_t AliHLTTPCCalibPedestalComponent::ProcessCalibration( const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData ) {
+
 
-  // ** Call only at "END OF RUN" event
-  //  fCalibPedestal->Analyse();
+Int_t AliHLTTPCCalibPedestalComponent::ShipDataToFXS( const AliHLTComponentEventData& /*evtData*/, 
+                                                     AliHLTComponentTriggerData& /*trigData*/ ) {
+  // see header file for class documentation
+    
+  if ( fEnableAnalysis )
+    fCalibPedestal->Analyse();
   
-  // ** PushBack data to shared memory ... 
-  spec = AliHLTTPCDefinitions::EncodeDataSpecification( slice, slice, minPatch, maxPatch );
-  PushBack( (TObject*) fCalibPedestal, AliHLTTPCDefinitions::fgkCalibPedestalDataType, spec);
+  // ** PushBack data to FXS ...
+  PushToFXS( (TObject*) fCalibPedestal, "TPC", "Pedestal" ) ;
   
   return 0;
-} // Int_t AliHLTTPCCalibPedestalComponent::DoEvent( const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData ) {
+} // Int_t AliHLTTPCCalibPedestalComponent::ShipDataToFXS( const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData ) {
+
+