]>
Commit | Line | Data |
---|---|---|
95259bbb | 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" | |
9aea5deb | 38 | #include "AliTRDCalibraFillHisto.h" |
95259bbb | 39 | |
40 | #include <cstdlib> | |
41 | #include <cerrno> | |
42 | #include <string> | |
43 | ||
44 | // this is a global object used for automatic component registration, do not use this | |
45 | AliHLTTRDCalibrationComponent gAliHLTTRDCalibrationComponent; | |
46 | ||
47 | ClassImp(AliHLTTRDCalibrationComponent); | |
48 | ||
49 | AliHLTTRDCalibrationComponent::AliHLTTRDCalibrationComponent() | |
50 | : AliHLTCalibrationProcessor() | |
4646c6e3 | 51 | , fTRDCalibraFillHisto(NULL) |
95259bbb | 52 | , fOutputPercentage(100) // By default we copy to the output exactly what we got as input |
53 | , fStrorageDBpath("local://$ALICE_ROOT") | |
54 | , fCDB(NULL) | |
55 | { | |
56 | // Default constructor | |
57 | } | |
58 | ||
59 | AliHLTTRDCalibrationComponent::~AliHLTTRDCalibrationComponent() | |
60 | { | |
61 | // Destructor | |
62 | ; | |
63 | } | |
64 | ||
65 | const char* AliHLTTRDCalibrationComponent::GetComponentID() | |
66 | { | |
67 | // Return the component ID const char * | |
68 | return "TRDCalibration"; // The ID of this component | |
69 | } | |
70 | ||
71 | void AliHLTTRDCalibrationComponent::GetInputDataTypes( vector<AliHLTComponent_DataType>& list) | |
72 | { | |
73 | // Get the list of input data | |
74 | list.clear(); // We do not have any requirements for our input data type(s). | |
75 | list.push_back( AliHLTTRDDefinitions::fgkTRDSATracksDataType ); | |
76 | } | |
77 | ||
78 | AliHLTComponent_DataType AliHLTTRDCalibrationComponent::GetOutputDataType() | |
79 | { | |
80 | // Get the output data type | |
81 | return AliHLTTRDDefinitions::fgkCalibrationDataType; | |
82 | } | |
83 | ||
84 | void AliHLTTRDCalibrationComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) | |
85 | { | |
86 | // Get the output data size | |
87 | constBase = 0; | |
88 | inputMultiplier = ((double)fOutputPercentage)/100.0; | |
89 | } | |
90 | ||
91 | AliHLTComponent* AliHLTTRDCalibrationComponent::Spawn() | |
92 | { | |
93 | // Spawn function, return new instance of this class | |
94 | return new AliHLTTRDCalibrationComponent; | |
95 | }; | |
96 | ||
97 | Int_t AliHLTTRDCalibrationComponent::ScanArgument( int argc, const char** argv ) | |
98 | { | |
99 | // perform initialization. We check whether our relative output size is specified in the arguments. | |
100 | fOutputPercentage = 100; | |
101 | int i = 0; | |
102 | char* cpErr; | |
103 | while ( i < argc ) | |
104 | { | |
105 | Logging( kHLTLogDebug, "HLT::TRDCalibration::ScanArgument", "Arguments", "argv[%d] == %s", i, argv[i] ); | |
106 | if ( !strcmp( argv[i], "output_percentage" ) ) | |
107 | { | |
108 | if ( i+1>=argc ) | |
109 | { | |
110 | Logging(kHLTLogError, "HLT::TRDCalibration::ScanArgument", "Missing Argument", "Missing output_percentage parameter"); | |
111 | return ENOTSUP; | |
112 | } | |
113 | Logging( kHLTLogDebug, "HLT::TRDCalibration::ScanArgument", "Arguments", "argv[%d+1] == %s", i, argv[i+1] ); | |
114 | fOutputPercentage = strtoul( argv[i+1], &cpErr, 0 ); | |
115 | if ( *cpErr ) | |
116 | { | |
117 | Logging(kHLTLogError, "HLT::TRDCalibration::ScanArgument", "Wrong Argument", "Cannot convert output_percentage parameter '%s'", argv[i+1] ); | |
118 | return EINVAL; | |
119 | } | |
120 | Logging( kHLTLogInfo, "HLT::TRDCalibration::ScanArgument", "Output percentage set", "Output percentage set to %lu %%", fOutputPercentage ); | |
121 | i += 2; | |
122 | continue; | |
123 | } | |
124 | ||
125 | if ( strcmp( argv[i], "-cdb" ) == 0) | |
126 | { | |
127 | if ( i+1 >= argc ) | |
128 | { | |
129 | Logging(kHLTLogError, "HLT::TRDCalibration::ScanArgument", "Missing Argument", "Missing -cdb argument"); | |
130 | return ENOTSUP; | |
131 | } | |
132 | fStrorageDBpath = argv[i+1]; | |
133 | Logging( kHLTLogInfo, "HLT::TRDCalibration::ScanArgument", "DB storage set", "DB storage is %s", fStrorageDBpath.c_str() ); | |
134 | i += 2; | |
135 | continue; | |
136 | } | |
137 | ||
138 | Logging(kHLTLogError, "HLT::TRDCalibration::ScanArgument", "Unknown Option", "Unknown option '%s'", argv[i] ); | |
139 | return EINVAL; | |
140 | } | |
141 | return 0; | |
142 | } | |
143 | ||
144 | Int_t AliHLTTRDCalibrationComponent::InitCalibration() | |
145 | { | |
146 | //init the calibration | |
147 | fCDB = AliCDBManager::Instance(); | |
148 | if (!fCDB) | |
149 | { | |
150 | Logging(kHLTLogError, "HLT::TRDCalibration::InitCalibration", "Could not get CDB instance", "fCDB 0x%x", fCDB); | |
151 | } | |
152 | else | |
153 | { | |
154 | fCDB->SetRun(0); // THIS HAS TO BE RETRIEVED !!! | |
155 | fCDB->SetDefaultStorage(fStrorageDBpath.c_str()); | |
156 | Logging(kHLTLogDebug, "HLT::TRDCalibration::InitCalibration", "CDB instance", "fCDB 0x%x", fCDB); | |
157 | } | |
9aea5deb | 158 | fTRDCalibraFillHisto = AliTRDCalibraFillHisto::Instance(); |
159 | fTRDCalibraFillHisto->SetHisto2d(); // choose to use histograms | |
160 | fTRDCalibraFillHisto->SetCH2dOn(); // choose to calibrate the gain | |
161 | fTRDCalibraFillHisto->SetPH2dOn(); // choose to calibrate the drift velocity | |
162 | fTRDCalibraFillHisto->SetPRF2dOn(); // choose to look at the PRF | |
163 | fTRDCalibraFillHisto->Init2Dhistos(); // initialise the histos | |
52be7fb0 | 164 | return 0; |
95259bbb | 165 | } |
166 | ||
167 | Int_t AliHLTTRDCalibrationComponent::DeinitCalibration() | |
168 | { | |
9aea5deb | 169 | HLTDebug("DeinitCalibration"); |
170 | ||
95259bbb | 171 | // Deinitialization of the component |
9aea5deb | 172 | // gain histo |
4646c6e3 | 173 | //TH2I *hCH2d = fTRDCalibraFillHisto->GetCH2d(); |
9aea5deb | 174 | // drift velocity histo |
4646c6e3 | 175 | //TProfile2D *hPH2d = fTRDCalibraFillHisto->GetPH2d(); |
9aea5deb | 176 | // PRF histo |
4646c6e3 | 177 | //TProfile2D *hPRF2d = fTRDCalibraFillHisto->GetPRF2d(); |
9aea5deb | 178 | |
95259bbb | 179 | if (fCDB) |
180 | { | |
181 | Logging( kHLTLogDebug, "HLT::TRDCalibration::DeinitCalibration", "destroy", "fCDB"); | |
182 | fCDB->Destroy(); | |
183 | fCDB = 0; | |
184 | } | |
52be7fb0 | 185 | return 0; |
95259bbb | 186 | } |
187 | ||
188 | Int_t AliHLTTRDCalibrationComponent::ProcessCalibration( const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData) | |
189 | { | |
190 | // Process an event | |
191 | // Logging( kHLTLogInfo, "HLT::TRDCalibration::ProcessCalibration", "Output percentage set", "Output percentage set to %lu %%", fOutputPercentage ); | |
192 | Logging( kHLTLogDebug, "HLT::TRDCalibration::ProcessCalibration", "BLOCKS", "NofBlocks %lu", evtData.fBlockCnt ); | |
193 | // Process an event | |
d76bc02a | 194 | //unsigned long totalSize = 0; |
95259bbb | 195 | |
196 | //implement a usage of the following | |
197 | // AliHLTUInt32_t triggerDataStructSize = trigData.fStructSize; | |
198 | // AliHLTUInt32_t triggerDataSize = trigData.fDataSize; | |
199 | // void *triggerData = trigData.fData; | |
200 | Logging( kHLTLogDebug, "HLT::TRDCalibration::ProcessCalibration", "Trigger data received", | |
201 | "Struct size %d Data size %d Data location 0x%x", trigData.fStructSize, trigData.fDataSize, (UInt_t*)trigData.fData); | |
202 | ||
203 | // Loop over all input blocks in the event | |
204 | int ibForce = 0; | |
205 | TObject *tobjin = (TObject *)GetFirstInputObject( AliHLTTRDDefinitions::fgkTRDSATracksDataType, "AliTRDtrack", ibForce); | |
206 | Logging( kHLTLogInfo, "HLT::TRDCalibration::ProcessCalibration", "1stBLOCK", "Pointer = 0x%x", tobjin); | |
207 | while (tobjin) | |
208 | { | |
209 | tobjin = (TObject *)GetNextInputObject( ibForce ); | |
210 | Logging( kHLTLogInfo, "HLT::TRDCalibration::ProcessCalibration", "nextBLOCK", "Pointer = 0x%x", tobjin); | |
9aea5deb | 211 | TClonesArray* trdTracks = (TClonesArray* )tobjin; |
212 | if (trdTracks) | |
213 | { | |
214 | Int_t nbEntries = trdTracks->GetEntries(); | |
215 | AliTRDtrackV1* trdTrack = 0x0; | |
216 | for (Int_t i = 0; i < nbEntries; i++){ | |
217 | trdTrack = (AliTRDtrackV1*)trdTracks->At(i); | |
218 | fTRDCalibraFillHisto->UpdateHistogramsV1(trdTrack); | |
219 | } | |
220 | ||
221 | } | |
222 | ||
95259bbb | 223 | } |
224 | ||
225 | return 0; | |
226 | } | |
227 | ||
d76bc02a | 228 | Int_t AliHLTTRDCalibrationComponent::ShipDataToFXS( const AliHLTComponentEventData& /*evtData*/, AliHLTComponentTriggerData& /*trigData*/) |
95259bbb | 229 | { |
230 | //Int_t PushToFXS(TObject* pObject, const char* pDetector, const char* pFileID, const char* pDDLNumber = ""); | |
231 | //ireturn = PushToFXS(object, "TRD ", "TRDCalib", "1024 "); | |
232 | Logging( kHLTLogDebug, "HLT::TRDCalibration::ProcessCalibration", "Shipping data", | |
233 | "Nothing serious"); | |
234 | Int_t ireturn = 0; | |
235 | return ireturn; | |
236 | } |