]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/EMCAL/AliHLTEMCALCalibrationComponent.cxx
Fixed warnings
[u/mrichter/AliRoot.git] / HLT / EMCAL / AliHLTEMCALCalibrationComponent.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Authors: Matthias Richter <Matthias.Richter@ift.uib.no>                *
5  *          Timm Steinbeck <timm@kip.uni-heidelberg.de>                   *
6  *          for The ALICE Off-line 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   AliHLTEMCALCalibrationComponent.cxx
18     @author Mateusz Ploskon
19     @date   
20     @brief  A EMCALCalibration processing component for the HLT. */
21
22 #if __GNUC__ >= 3
23 using namespace std;
24 #endif
25
26 #include "TTree.h"
27 #include "TFile.h"
28 #include "TBranch.h"
29
30 #include "AliHLTEMCALCalibrationComponent.h"
31 #include "AliHLTEMCALDefinitions.h"
32
33 #include "AliCDBManager.h"
34 #include "AliRawReaderMemory.h"
35
36 #include <cstdlib>
37 #include <cerrno>
38 #include <string>
39
40 // this is a global object used for automatic component registration, do not use this
41 AliHLTEMCALCalibrationComponent gAliHLTEMCALCalibrationComponent;
42
43 ClassImp(AliHLTEMCALCalibrationComponent);
44    
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")
49   , fCDB(NULL)
50 {
51   // Default constructor
52 }
53
54 AliHLTEMCALCalibrationComponent::~AliHLTEMCALCalibrationComponent()
55 {
56   // Destructor
57   ;
58 }
59
60 const char* AliHLTEMCALCalibrationComponent::GetComponentID()
61 {
62   // Return the component ID const char *
63   return "EMCALCalibration"; // The ID of this component
64 }
65
66 void AliHLTEMCALCalibrationComponent::GetInputDataTypes( vector<AliHLTComponent_DataType>& list)
67 {
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 );
73 }
74
75 AliHLTComponent_DataType AliHLTEMCALCalibrationComponent::GetOutputDataType()
76 {
77   // Get the output data type
78   return AliHLTEMCALDefinitions::fgkCalibrationDataType;
79 }
80
81 void AliHLTEMCALCalibrationComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
82 {
83   // Get the output data size
84   constBase = 0;
85   inputMultiplier = ((double)fOutputPercentage)/100.0;
86 }
87
88 AliHLTComponent* AliHLTEMCALCalibrationComponent::Spawn()
89 {
90   // Spawn function, return new instance of this class
91   return new AliHLTEMCALCalibrationComponent;
92 };
93
94 Int_t AliHLTEMCALCalibrationComponent::ScanArgument( int argc, const char** argv )
95 {
96   // perform initialization. We check whether our relative output size is specified in the arguments.
97   fOutputPercentage = 100;
98   int i = 0;
99   char* cpErr;
100   while ( i < argc )
101     {
102       Logging( kHLTLogDebug, "HLT::EMCALCalibration::ScanArgument", "Arguments", "argv[%d] == %s", i, argv[i] );
103       if ( !strcmp( argv[i], "output_percentage" ) )
104         {
105           if ( i+1>=argc )
106             {
107               Logging(kHLTLogError, "HLT::EMCALCalibration::ScanArgument", "Missing Argument", "Missing output_percentage parameter");
108               return ENOTSUP;
109             }
110           Logging( kHLTLogDebug, "HLT::EMCALCalibration::ScanArgument", "Arguments", "argv[%d+1] == %s", i, argv[i+1] );
111           fOutputPercentage = strtoul( argv[i+1], &cpErr, 0 );
112           if ( *cpErr )
113             {
114               Logging(kHLTLogError, "HLT::EMCALCalibration::ScanArgument", "Wrong Argument", "Cannot convert output_percentage parameter '%s'", argv[i+1] );
115               return EINVAL;
116             }
117           Logging( kHLTLogInfo, "HLT::EMCALCalibration::ScanArgument", "Output percentage set", "Output percentage set to %lu %%", fOutputPercentage );
118           i += 2;
119           continue;
120         }
121
122       if ( strcmp( argv[i], "-cdb" ) == 0)
123         {
124           if ( i+1 >= argc )
125             {
126               Logging(kHLTLogError, "HLT::EMCALCalibration::ScanArgument", "Missing Argument", "Missing -cdb argument");
127               return ENOTSUP;         
128             }
129           fStrorageDBpath = argv[i+1];
130           Logging( kHLTLogInfo, "HLT::EMCALCalibration::ScanArgument", "DB storage set", "DB storage is %s", fStrorageDBpath.c_str() );   
131           i += 2;
132           continue;
133         }      
134
135       Logging(kHLTLogError, "HLT::EMCALCalibration::ScanArgument", "Unknown Option", "Unknown option '%s'", argv[i] );
136       return EINVAL;
137     }
138   return 0;
139 }
140
141 Int_t AliHLTEMCALCalibrationComponent::InitCalibration()
142 {
143   //init the calibration
144   fCDB = AliCDBManager::Instance();
145   if (!fCDB)
146     {
147       Logging(kHLTLogError, "HLT::EMCALCalibration::InitCalibration", "Could not get CDB instance", "fCDB 0x%x", fCDB);
148     }
149   else
150     {
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);
154     }
155   return 0;
156 }
157
158 Int_t AliHLTEMCALCalibrationComponent::DeinitCalibration()
159 {
160   // Deinitialization of the component
161   if (fCDB)
162     {
163       Logging( kHLTLogDebug, "HLT::EMCALCalibration::DeinitCalibration", "destroy", "fCDB");
164       fCDB->Destroy();
165       fCDB = 0;
166     }
167   return 0;
168 }
169
170 Int_t AliHLTEMCALCalibrationComponent::ProcessCalibration( const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData)
171 {
172   // Process an event
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 );
175   // Process an event
176   // unsigned long totalSize = 0;
177
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);
185
186   // Loop over all input blocks in the event
187   int ibForce = 0;
188   TObject *tobjin = (TObject *)GetFirstInputObject(AliHLTEMCALDefinitions::fgkClusterDataType , "TTree", ibForce);
189   Logging( kHLTLogInfo, "HLT::EMCALCalibration::ProcessCalibration", "1stBLOCK", "Pointer = 0x%x", tobjin);
190   while (tobjin)
191     {
192       tobjin = (TObject *)GetNextInputObject( ibForce );
193       Logging( kHLTLogInfo, "HLT::EMCALCalibration::ProcessCalibration", "nextBLOCK", "Pointer = 0x%x", tobjin);
194     }
195
196   return 0;
197 }
198
199 Int_t AliHLTEMCALCalibrationComponent::ShipDataToFXS( const AliHLTComponentEventData& /*evtData*/, AliHLTComponentTriggerData& /*trigData*/)
200 {
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", 
205            "Nothing serious");
206   Int_t ireturn = 0;
207   return ireturn;
208 }