]>
Commit | Line | Data |
---|---|---|
4a8f32a0 | 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 | ||
4a8f32a0 | 22 | #include "TTree.h" |
23 | #include "TFile.h" | |
24 | #include "TBranch.h" | |
25 | ||
26 | #include "AliHLTEMCALCalibrationComponent.h" | |
27 | #include "AliHLTEMCALDefinitions.h" | |
28 | ||
29 | #include "AliCDBManager.h" | |
30 | #include "AliRawReaderMemory.h" | |
31 | ||
32 | #include <cstdlib> | |
33 | #include <cerrno> | |
34 | #include <string> | |
35 | ||
008e9402 | 36 | using namespace std; |
37 | ||
4a8f32a0 | 38 | // this is a global object used for automatic component registration, do not use this |
39 | AliHLTEMCALCalibrationComponent gAliHLTEMCALCalibrationComponent; | |
40 | ||
41 | ClassImp(AliHLTEMCALCalibrationComponent); | |
42 | ||
43 | AliHLTEMCALCalibrationComponent::AliHLTEMCALCalibrationComponent() | |
44 | : AliHLTCalibrationProcessor() | |
45 | , fOutputPercentage(100) // By default we copy to the output exactly what we got as input | |
162637e4 | 46 | , fStrorageDBpath("local://$ALICE_ROOT/OCDB") |
4a8f32a0 | 47 | , fCDB(NULL) |
48 | { | |
49 | // Default constructor | |
50 | } | |
51 | ||
52 | AliHLTEMCALCalibrationComponent::~AliHLTEMCALCalibrationComponent() | |
53 | { | |
54 | // Destructor | |
55 | ; | |
56 | } | |
57 | ||
58 | const char* AliHLTEMCALCalibrationComponent::GetComponentID() | |
59 | { | |
60 | // Return the component ID const char * | |
61 | return "EMCALCalibration"; // The ID of this component | |
62 | } | |
63 | ||
64 | void AliHLTEMCALCalibrationComponent::GetInputDataTypes( vector<AliHLTComponent_DataType>& list) | |
65 | { | |
66 | // Get the list of input data | |
67 | list.clear(); // We do not have any requirements for our input data type(s). | |
68 | //list.push_back( AliHLTEMCALDefinitions::fgkDDLRawDataType ); | |
69 | list.push_back( AliHLTEMCALDefinitions::fgkClusterDataType ); | |
70 | //list.push_back( AliHLTEMCALDefinitions::fgkEMCALESDDataType ); | |
71 | } | |
72 | ||
73 | AliHLTComponent_DataType AliHLTEMCALCalibrationComponent::GetOutputDataType() | |
74 | { | |
75 | // Get the output data type | |
76 | return AliHLTEMCALDefinitions::fgkCalibrationDataType; | |
77 | } | |
78 | ||
79 | void AliHLTEMCALCalibrationComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) | |
80 | { | |
81 | // Get the output data size | |
82 | constBase = 0; | |
83 | inputMultiplier = ((double)fOutputPercentage)/100.0; | |
84 | } | |
85 | ||
86 | AliHLTComponent* AliHLTEMCALCalibrationComponent::Spawn() | |
87 | { | |
88 | // Spawn function, return new instance of this class | |
89 | return new AliHLTEMCALCalibrationComponent; | |
90 | }; | |
91 | ||
92 | Int_t AliHLTEMCALCalibrationComponent::ScanArgument( int argc, const char** argv ) | |
93 | { | |
94 | // perform initialization. We check whether our relative output size is specified in the arguments. | |
95 | fOutputPercentage = 100; | |
96 | int i = 0; | |
97 | char* cpErr; | |
98 | while ( i < argc ) | |
99 | { | |
100 | Logging( kHLTLogDebug, "HLT::EMCALCalibration::ScanArgument", "Arguments", "argv[%d] == %s", i, argv[i] ); | |
101 | if ( !strcmp( argv[i], "output_percentage" ) ) | |
102 | { | |
103 | if ( i+1>=argc ) | |
104 | { | |
105 | Logging(kHLTLogError, "HLT::EMCALCalibration::ScanArgument", "Missing Argument", "Missing output_percentage parameter"); | |
106 | return ENOTSUP; | |
107 | } | |
108 | Logging( kHLTLogDebug, "HLT::EMCALCalibration::ScanArgument", "Arguments", "argv[%d+1] == %s", i, argv[i+1] ); | |
109 | fOutputPercentage = strtoul( argv[i+1], &cpErr, 0 ); | |
110 | if ( *cpErr ) | |
111 | { | |
112 | Logging(kHLTLogError, "HLT::EMCALCalibration::ScanArgument", "Wrong Argument", "Cannot convert output_percentage parameter '%s'", argv[i+1] ); | |
113 | return EINVAL; | |
114 | } | |
115 | Logging( kHLTLogInfo, "HLT::EMCALCalibration::ScanArgument", "Output percentage set", "Output percentage set to %lu %%", fOutputPercentage ); | |
116 | i += 2; | |
117 | continue; | |
118 | } | |
119 | ||
120 | if ( strcmp( argv[i], "-cdb" ) == 0) | |
121 | { | |
122 | if ( i+1 >= argc ) | |
123 | { | |
124 | Logging(kHLTLogError, "HLT::EMCALCalibration::ScanArgument", "Missing Argument", "Missing -cdb argument"); | |
125 | return ENOTSUP; | |
126 | } | |
127 | fStrorageDBpath = argv[i+1]; | |
128 | Logging( kHLTLogInfo, "HLT::EMCALCalibration::ScanArgument", "DB storage set", "DB storage is %s", fStrorageDBpath.c_str() ); | |
129 | i += 2; | |
130 | continue; | |
131 | } | |
132 | ||
133 | Logging(kHLTLogError, "HLT::EMCALCalibration::ScanArgument", "Unknown Option", "Unknown option '%s'", argv[i] ); | |
134 | return EINVAL; | |
135 | } | |
136 | return 0; | |
137 | } | |
138 | ||
139 | Int_t AliHLTEMCALCalibrationComponent::InitCalibration() | |
140 | { | |
141 | //init the calibration | |
142 | fCDB = AliCDBManager::Instance(); | |
143 | if (!fCDB) | |
144 | { | |
145 | Logging(kHLTLogError, "HLT::EMCALCalibration::InitCalibration", "Could not get CDB instance", "fCDB 0x%x", fCDB); | |
146 | } | |
147 | else | |
148 | { | |
149 | fCDB->SetRun(0); // THIS HAS TO BE RETRIEVED !!! | |
150 | fCDB->SetDefaultStorage(fStrorageDBpath.c_str()); | |
151 | Logging(kHLTLogDebug, "HLT::EMCALCalibration::InitCalibration", "CDB instance", "fCDB 0x%x", fCDB); | |
152 | } | |
153 | return 0; | |
154 | } | |
155 | ||
156 | Int_t AliHLTEMCALCalibrationComponent::DeinitCalibration() | |
157 | { | |
158 | // Deinitialization of the component | |
159 | if (fCDB) | |
160 | { | |
161 | Logging( kHLTLogDebug, "HLT::EMCALCalibration::DeinitCalibration", "destroy", "fCDB"); | |
162 | fCDB->Destroy(); | |
163 | fCDB = 0; | |
164 | } | |
165 | return 0; | |
166 | } | |
167 | ||
168 | Int_t AliHLTEMCALCalibrationComponent::ProcessCalibration( const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData) | |
169 | { | |
170 | // Process an event | |
171 | // Logging( kHLTLogInfo, "HLT::EMCALCalibration::ProcessCalibration", "Output percentage set", "Output percentage set to %lu %%", fOutputPercentage ); | |
172 | Logging( kHLTLogDebug, "HLT::EMCALCalibration::ProcessCalibration", "BLOCKS", "NofBlocks %lu", evtData.fBlockCnt ); | |
173 | // Process an event | |
174 | // unsigned long totalSize = 0; | |
175 | ||
176 | // implement a usage of the following | |
177 | // AliHLTUInt32_t triggerDataStructSize = trigData.fStructSize; | |
178 | // AliHLTUInt32_t triggerDataSize = trigData.fDataSize; | |
179 | // void *triggerData = trigData.fData; | |
180 | Logging( kHLTLogDebug, "HLT::EMCALCalibration::ProcessCalibration", "Trigger data received", | |
181 | "Struct size %d Data size %d Data location 0x%x", | |
182 | trigData.fStructSize, trigData.fDataSize, (UInt_t*)trigData.fData); | |
183 | ||
184 | // Loop over all input blocks in the event | |
185 | int ibForce = 0; | |
186 | TObject *tobjin = (TObject *)GetFirstInputObject(AliHLTEMCALDefinitions::fgkClusterDataType , "TTree", ibForce); | |
187 | Logging( kHLTLogInfo, "HLT::EMCALCalibration::ProcessCalibration", "1stBLOCK", "Pointer = 0x%x", tobjin); | |
188 | while (tobjin) | |
189 | { | |
190 | tobjin = (TObject *)GetNextInputObject( ibForce ); | |
191 | Logging( kHLTLogInfo, "HLT::EMCALCalibration::ProcessCalibration", "nextBLOCK", "Pointer = 0x%x", tobjin); | |
192 | } | |
193 | ||
194 | return 0; | |
195 | } | |
196 | ||
197 | Int_t AliHLTEMCALCalibrationComponent::ShipDataToFXS( const AliHLTComponentEventData& /*evtData*/, AliHLTComponentTriggerData& /*trigData*/) | |
198 | { | |
199 | //Int_t PushToFXS(TObject* pObject, const char* pDetector, const char* pFileID, const char* pDDLNumber = ""); | |
200 | // what we will actually push depends on the calibration procedure | |
201 | //ireturn = PushToFXS(object, "EMCAL ", "EMCALCalib", "1024 "); | |
202 | Logging( kHLTLogDebug, "HLT::EMCALCalibration::ProcessCalibration", "Shipping data", | |
203 | "Nothing serious"); | |
204 | Int_t ireturn = 0; | |
205 | return ireturn; | |
206 | } |