]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/TRD/AliHLTTRDCalibrationComponent.cxx
adding new library dependencies for TRD and MUON to configuration and cleaning up...
[u/mrichter/AliRoot.git] / HLT / TRD / AliHLTTRDCalibrationComponent.cxx
1 // $Id$
2
3 /**************************************************************************
4  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
5  *                                                                        *
6  * Authors: Matthias Richter <Matthias.Richter@ift.uib.no>                *
7  *          Timm Steinbeck <timm@kip.uni-heidelberg.de>                   *
8  *          for The ALICE Off-line Project.                               *
9  *                                                                        *
10  * Permission to use, copy, modify and distribute this software and its   *
11  * documentation strictly for non-commercial purposes is hereby granted   *
12  * without fee, provided that the above copyright notice appears in all   *
13  * copies and that both the copyright notice and this permission notice   *
14  * appear in the supporting documentation. The authors make no claims     *
15  * about the suitability of this software for any purpose. It is          *
16  * provided "as is" without express or implied warranty.                  *
17  **************************************************************************/
18
19 /** @file   AliHLTTRDCalibrationComponent.cxx
20     @author Timm Steinbeck, Matthias Richter
21     @date   
22     @brief  A TRDCalibration processing component for the HLT. */
23
24 #if __GNUC__ >= 3
25 using namespace std;
26 #endif
27
28 #include "TTree.h"
29 #include "TFile.h"
30 #include "TBranch.h"
31
32 #include "AliHLTTRDCalibrationComponent.h"
33 #include "AliHLTTRDDefinitions.h"
34
35 #include "AliCDBManager.h"
36 #include "AliTRDclusterizerHLT.h"
37 #include "AliRawReaderMemory.h"
38
39 #include <cstdlib>
40 #include <cerrno>
41 #include <string>
42
43 // this is a global object used for automatic component registration, do not use this
44 AliHLTTRDCalibrationComponent gAliHLTTRDCalibrationComponent;
45
46 ClassImp(AliHLTTRDCalibrationComponent);
47    
48 AliHLTTRDCalibrationComponent::AliHLTTRDCalibrationComponent()
49   : AliHLTCalibrationProcessor()
50   , fOutputPercentage(100) // By default we copy to the output exactly what we got as input  
51   , fStrorageDBpath("local://$ALICE_ROOT")
52   , fCDB(NULL)
53 {
54   // Default constructor
55 }
56
57 AliHLTTRDCalibrationComponent::~AliHLTTRDCalibrationComponent()
58 {
59   // Destructor
60   ;
61 }
62
63 const char* AliHLTTRDCalibrationComponent::GetComponentID()
64 {
65   // Return the component ID const char *
66   return "TRDCalibration"; // The ID of this component
67 }
68
69 void AliHLTTRDCalibrationComponent::GetInputDataTypes( vector<AliHLTComponent_DataType>& list)
70 {
71   // Get the list of input data
72   list.clear(); // We do not have any requirements for our input data type(s).
73   list.push_back( AliHLTTRDDefinitions::fgkTRDSATracksDataType );
74 }
75
76 AliHLTComponent_DataType AliHLTTRDCalibrationComponent::GetOutputDataType()
77 {
78   // Get the output data type
79   return AliHLTTRDDefinitions::fgkCalibrationDataType;
80 }
81
82 void AliHLTTRDCalibrationComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
83 {
84   // Get the output data size
85   constBase = 0;
86   inputMultiplier = ((double)fOutputPercentage)/100.0;
87 }
88
89 AliHLTComponent* AliHLTTRDCalibrationComponent::Spawn()
90 {
91   // Spawn function, return new instance of this class
92   return new AliHLTTRDCalibrationComponent;
93 };
94
95 Int_t AliHLTTRDCalibrationComponent::ScanArgument( int argc, const char** argv )
96 {
97   // perform initialization. We check whether our relative output size is specified in the arguments.
98   fOutputPercentage = 100;
99   int i = 0;
100   char* cpErr;
101   while ( i < argc )
102     {
103       Logging( kHLTLogDebug, "HLT::TRDCalibration::ScanArgument", "Arguments", "argv[%d] == %s", i, argv[i] );
104       if ( !strcmp( argv[i], "output_percentage" ) )
105         {
106           if ( i+1>=argc )
107             {
108               Logging(kHLTLogError, "HLT::TRDCalibration::ScanArgument", "Missing Argument", "Missing output_percentage parameter");
109               return ENOTSUP;
110             }
111           Logging( kHLTLogDebug, "HLT::TRDCalibration::ScanArgument", "Arguments", "argv[%d+1] == %s", i, argv[i+1] );
112           fOutputPercentage = strtoul( argv[i+1], &cpErr, 0 );
113           if ( *cpErr )
114             {
115               Logging(kHLTLogError, "HLT::TRDCalibration::ScanArgument", "Wrong Argument", "Cannot convert output_percentage parameter '%s'", argv[i+1] );
116               return EINVAL;
117             }
118           Logging( kHLTLogInfo, "HLT::TRDCalibration::ScanArgument", "Output percentage set", "Output percentage set to %lu %%", fOutputPercentage );
119           i += 2;
120           continue;
121         }
122
123       if ( strcmp( argv[i], "-cdb" ) == 0)
124         {
125           if ( i+1 >= argc )
126             {
127               Logging(kHLTLogError, "HLT::TRDCalibration::ScanArgument", "Missing Argument", "Missing -cdb argument");
128               return ENOTSUP;         
129             }
130           fStrorageDBpath = argv[i+1];
131           Logging( kHLTLogInfo, "HLT::TRDCalibration::ScanArgument", "DB storage set", "DB storage is %s", fStrorageDBpath.c_str() );     
132           i += 2;
133           continue;
134         }      
135
136       Logging(kHLTLogError, "HLT::TRDCalibration::ScanArgument", "Unknown Option", "Unknown option '%s'", argv[i] );
137       return EINVAL;
138     }
139   return 0;
140 }
141
142 Int_t AliHLTTRDCalibrationComponent::InitCalibration()
143 {
144   //init the calibration
145   fCDB = AliCDBManager::Instance();
146   if (!fCDB)
147     {
148       Logging(kHLTLogError, "HLT::TRDCalibration::InitCalibration", "Could not get CDB instance", "fCDB 0x%x", fCDB);
149     }
150   else
151     {
152       fCDB->SetRun(0); // THIS HAS TO BE RETRIEVED !!!
153       fCDB->SetDefaultStorage(fStrorageDBpath.c_str());
154       Logging(kHLTLogDebug, "HLT::TRDCalibration::InitCalibration", "CDB instance", "fCDB 0x%x", fCDB);
155     }
156   return 0;
157 }
158
159 Int_t AliHLTTRDCalibrationComponent::DeinitCalibration()
160 {
161   // Deinitialization of the component
162   if (fCDB)
163     {
164       Logging( kHLTLogDebug, "HLT::TRDCalibration::DeinitCalibration", "destroy", "fCDB");
165       fCDB->Destroy();
166       fCDB = 0;
167     }
168   return 0;
169 }
170
171 Int_t AliHLTTRDCalibrationComponent::ProcessCalibration( const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData)
172 {
173   // Process an event
174 //   Logging( kHLTLogInfo, "HLT::TRDCalibration::ProcessCalibration", "Output percentage set", "Output percentage set to %lu %%", fOutputPercentage );
175   Logging( kHLTLogDebug, "HLT::TRDCalibration::ProcessCalibration", "BLOCKS", "NofBlocks %lu", evtData.fBlockCnt );
176   // Process an event
177   //unsigned long totalSize = 0;
178
179   //implement a usage of the following
180 //   AliHLTUInt32_t triggerDataStructSize = trigData.fStructSize;
181 //   AliHLTUInt32_t triggerDataSize = trigData.fDataSize;
182 //   void *triggerData = trigData.fData;
183   Logging( kHLTLogDebug, "HLT::TRDCalibration::ProcessCalibration", "Trigger data received", 
184            "Struct size %d Data size %d Data location 0x%x", 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( AliHLTTRDDefinitions::fgkTRDSATracksDataType, "AliTRDtrack", ibForce);
189   Logging( kHLTLogInfo, "HLT::TRDCalibration::ProcessCalibration", "1stBLOCK", "Pointer = 0x%x", tobjin);
190   while (tobjin)
191     {
192       tobjin = (TObject *)GetNextInputObject( ibForce );
193       Logging( kHLTLogInfo, "HLT::TRDCalibration::ProcessCalibration", "nextBLOCK", "Pointer = 0x%x", tobjin);
194     }
195
196   return 0;
197 }
198
199 Int_t AliHLTTRDCalibrationComponent::ShipDataToFXS( const AliHLTComponentEventData& /*evtData*/, AliHLTComponentTriggerData& /*trigData*/)
200 {
201   //Int_t PushToFXS(TObject* pObject, const char* pDetector, const char* pFileID, const char* pDDLNumber = "");
202   //ireturn = PushToFXS(object, "TRD ", "TRDCalib", "1024 ");
203   Logging( kHLTLogDebug, "HLT::TRDCalibration::ProcessCalibration", "Shipping data", 
204            "Nothing serious");
205   Int_t ireturn = 0;
206   return ireturn;
207 }