1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Authors: Matthias Richter <Matthias.Richter@ift.uib.no> *
5 * Timm Steinbeck <timm@kip.uni-heidelberg.de> *
6 * for The ALICE Off-line Project. *
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 **************************************************************************/
17 /** @file AliHLTEMCALCalibrationComponent.cxx
18 @author Mateusz Ploskon
20 @brief A EMCALCalibration processing component for the HLT. */
30 #include "AliHLTEMCALCalibrationComponent.h"
31 #include "AliHLTEMCALDefinitions.h"
33 #include "AliCDBManager.h"
34 #include "AliRawReaderMemory.h"
40 // this is a global object used for automatic component registration, do not use this
41 AliHLTEMCALCalibrationComponent gAliHLTEMCALCalibrationComponent;
43 ClassImp(AliHLTEMCALCalibrationComponent);
45 AliHLTEMCALCalibrationComponent::AliHLTEMCALCalibrationComponent()
46 : AliHLTCalibrationProcessor()
47 , fOutputPercentage(100) // By default we copy to the output exactly what we got as input
48 , fStrorageDBpath("local://$ALICE_ROOT/OCDB")
51 // Default constructor
54 AliHLTEMCALCalibrationComponent::~AliHLTEMCALCalibrationComponent()
60 const char* AliHLTEMCALCalibrationComponent::GetComponentID()
62 // Return the component ID const char *
63 return "EMCALCalibration"; // The ID of this component
66 void AliHLTEMCALCalibrationComponent::GetInputDataTypes( vector<AliHLTComponent_DataType>& list)
68 // Get the list of input data
69 list.clear(); // We do not have any requirements for our input data type(s).
70 //list.push_back( AliHLTEMCALDefinitions::fgkDDLRawDataType );
71 list.push_back( AliHLTEMCALDefinitions::fgkClusterDataType );
72 //list.push_back( AliHLTEMCALDefinitions::fgkEMCALESDDataType );
75 AliHLTComponent_DataType AliHLTEMCALCalibrationComponent::GetOutputDataType()
77 // Get the output data type
78 return AliHLTEMCALDefinitions::fgkCalibrationDataType;
81 void AliHLTEMCALCalibrationComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
83 // Get the output data size
85 inputMultiplier = ((double)fOutputPercentage)/100.0;
88 AliHLTComponent* AliHLTEMCALCalibrationComponent::Spawn()
90 // Spawn function, return new instance of this class
91 return new AliHLTEMCALCalibrationComponent;
94 Int_t AliHLTEMCALCalibrationComponent::ScanArgument( int argc, const char** argv )
96 // perform initialization. We check whether our relative output size is specified in the arguments.
97 fOutputPercentage = 100;
102 Logging( kHLTLogDebug, "HLT::EMCALCalibration::ScanArgument", "Arguments", "argv[%d] == %s", i, argv[i] );
103 if ( !strcmp( argv[i], "output_percentage" ) )
107 Logging(kHLTLogError, "HLT::EMCALCalibration::ScanArgument", "Missing Argument", "Missing output_percentage parameter");
110 Logging( kHLTLogDebug, "HLT::EMCALCalibration::ScanArgument", "Arguments", "argv[%d+1] == %s", i, argv[i+1] );
111 fOutputPercentage = strtoul( argv[i+1], &cpErr, 0 );
114 Logging(kHLTLogError, "HLT::EMCALCalibration::ScanArgument", "Wrong Argument", "Cannot convert output_percentage parameter '%s'", argv[i+1] );
117 Logging( kHLTLogInfo, "HLT::EMCALCalibration::ScanArgument", "Output percentage set", "Output percentage set to %lu %%", fOutputPercentage );
122 if ( strcmp( argv[i], "-cdb" ) == 0)
126 Logging(kHLTLogError, "HLT::EMCALCalibration::ScanArgument", "Missing Argument", "Missing -cdb argument");
129 fStrorageDBpath = argv[i+1];
130 Logging( kHLTLogInfo, "HLT::EMCALCalibration::ScanArgument", "DB storage set", "DB storage is %s", fStrorageDBpath.c_str() );
135 Logging(kHLTLogError, "HLT::EMCALCalibration::ScanArgument", "Unknown Option", "Unknown option '%s'", argv[i] );
141 Int_t AliHLTEMCALCalibrationComponent::InitCalibration()
143 //init the calibration
144 fCDB = AliCDBManager::Instance();
147 Logging(kHLTLogError, "HLT::EMCALCalibration::InitCalibration", "Could not get CDB instance", "fCDB 0x%x", fCDB);
151 fCDB->SetRun(0); // THIS HAS TO BE RETRIEVED !!!
152 fCDB->SetDefaultStorage(fStrorageDBpath.c_str());
153 Logging(kHLTLogDebug, "HLT::EMCALCalibration::InitCalibration", "CDB instance", "fCDB 0x%x", fCDB);
158 Int_t AliHLTEMCALCalibrationComponent::DeinitCalibration()
160 // Deinitialization of the component
163 Logging( kHLTLogDebug, "HLT::EMCALCalibration::DeinitCalibration", "destroy", "fCDB");
170 Int_t AliHLTEMCALCalibrationComponent::ProcessCalibration( const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData)
173 // Logging( kHLTLogInfo, "HLT::EMCALCalibration::ProcessCalibration", "Output percentage set", "Output percentage set to %lu %%", fOutputPercentage );
174 Logging( kHLTLogDebug, "HLT::EMCALCalibration::ProcessCalibration", "BLOCKS", "NofBlocks %lu", evtData.fBlockCnt );
176 // unsigned long totalSize = 0;
178 // implement a usage of the following
179 // AliHLTUInt32_t triggerDataStructSize = trigData.fStructSize;
180 // AliHLTUInt32_t triggerDataSize = trigData.fDataSize;
181 // void *triggerData = trigData.fData;
182 Logging( kHLTLogDebug, "HLT::EMCALCalibration::ProcessCalibration", "Trigger data received",
183 "Struct size %d Data size %d Data location 0x%x",
184 trigData.fStructSize, trigData.fDataSize, (UInt_t*)trigData.fData);
186 // Loop over all input blocks in the event
188 TObject *tobjin = (TObject *)GetFirstInputObject(AliHLTEMCALDefinitions::fgkClusterDataType , "TTree", ibForce);
189 Logging( kHLTLogInfo, "HLT::EMCALCalibration::ProcessCalibration", "1stBLOCK", "Pointer = 0x%x", tobjin);
192 tobjin = (TObject *)GetNextInputObject( ibForce );
193 Logging( kHLTLogInfo, "HLT::EMCALCalibration::ProcessCalibration", "nextBLOCK", "Pointer = 0x%x", tobjin);
199 Int_t AliHLTEMCALCalibrationComponent::ShipDataToFXS( const AliHLTComponentEventData& /*evtData*/, AliHLTComponentTriggerData& /*trigData*/)
201 //Int_t PushToFXS(TObject* pObject, const char* pDetector, const char* pFileID, const char* pDDLNumber = "");
202 // what we will actually push depends on the calibration procedure
203 //ireturn = PushToFXS(object, "EMCAL ", "EMCALCalib", "1024 ");
204 Logging( kHLTLogDebug, "HLT::EMCALCalibration::ProcessCalibration", "Shipping data",