]>
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 | |
dc2e6604 | 21 | @date |
95259bbb | 22 | @brief A TRDCalibration processing component for the HLT. */ |
23 | ||
24 | #if __GNUC__ >= 3 | |
775f67d7 | 25 | using namespace std; |
95259bbb | 26 | #endif |
27 | ||
28 | #include "TTree.h" | |
29 | #include "TFile.h" | |
30 | #include "TBranch.h" | |
31 | ||
32 | #include "AliHLTTRDCalibrationComponent.h" | |
33 | #include "AliHLTTRDDefinitions.h" | |
dc2e6604 | 34 | #include "AliHLTTRDUtils.h" |
95259bbb | 35 | |
36 | #include "AliCDBManager.h" | |
775f67d7 | 37 | #include "AliCDBStorage.h" |
95259bbb | 38 | #include "AliRawReaderMemory.h" |
9aea5deb | 39 | #include "AliTRDCalibraFillHisto.h" |
dc2e6604 | 40 | #include "AliTRDtrackV1.h" |
95259bbb | 41 | |
42 | #include <cstdlib> | |
43 | #include <cerrno> | |
44 | #include <string> | |
45 | ||
95259bbb | 46 | ClassImp(AliHLTTRDCalibrationComponent); |
dc2e6604 | 47 | |
93ce7d1b | 48 | AliHLTTRDCalibrationComponent::AliHLTTRDCalibrationComponent() |
49 | : AliHLTCalibrationProcessor(), | |
775f67d7 | 50 | fTRDCalibraFillHisto(NULL), |
93ce7d1b | 51 | fOutputSize(50000), |
52 | fTracksArray(NULL), | |
53 | fOutArray(NULL), | |
54 | fNevent(0), | |
55 | feveryNevent(20), | |
56 | fRecievedTimeBins(kFALSE) | |
95259bbb | 57 | { |
775f67d7 | 58 | // Default constructor |
95259bbb | 59 | } |
60 | ||
61 | AliHLTTRDCalibrationComponent::~AliHLTTRDCalibrationComponent() | |
62 | { | |
775f67d7 | 63 | // Destructor |
95259bbb | 64 | } |
65 | ||
66 | const char* AliHLTTRDCalibrationComponent::GetComponentID() | |
67 | { | |
775f67d7 | 68 | // Return the component ID const char * |
69 | return "TRDCalibration"; // The ID of this component | |
95259bbb | 70 | } |
71 | ||
93ce7d1b | 72 | void AliHLTTRDCalibrationComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) |
95259bbb | 73 | { |
775f67d7 | 74 | // Get the list of input data |
75 | list.clear(); // We do not have any requirements for our input data type(s). | |
93ce7d1b | 76 | list.push_back(AliHLTTRDDefinitions::fgkTRDSATracksDataType); |
95259bbb | 77 | } |
78 | ||
93ce7d1b | 79 | AliHLTComponentDataType AliHLTTRDCalibrationComponent::GetOutputDataType() |
95259bbb | 80 | { |
775f67d7 | 81 | // Get the output data type |
82 | return AliHLTTRDDefinitions::fgkCalibrationDataType; | |
95259bbb | 83 | } |
84 | ||
85 | void AliHLTTRDCalibrationComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) | |
86 | { | |
775f67d7 | 87 | // Get the output data size |
93ce7d1b | 88 | constBase = fOutputSize; |
89 | inputMultiplier = 0; | |
95259bbb | 90 | } |
91 | ||
92 | AliHLTComponent* AliHLTTRDCalibrationComponent::Spawn() | |
93 | { | |
775f67d7 | 94 | // Spawn function, return new instance of this class |
95 | return new AliHLTTRDCalibrationComponent; | |
95259bbb | 96 | }; |
97 | ||
98 | Int_t AliHLTTRDCalibrationComponent::ScanArgument( int argc, const char** argv ) | |
99 | { | |
775f67d7 | 100 | // perform initialization. We check whether our relative output size is specified in the arguments. |
101 | int i = 0; | |
102 | char* cpErr; | |
103 | while ( i < argc ) | |
104 | { | |
105 | HLTDebug("argv[%d] == %s", i, argv[i] ); | |
93ce7d1b | 106 | if ( !strcmp( argv[i], "output_size" ) ) |
dc2e6604 | 107 | { |
775f67d7 | 108 | if ( i+1>=argc ) |
109 | { | |
93ce7d1b | 110 | HLTError("Missing output_size parameter"); |
775f67d7 | 111 | return ENOTSUP; |
dc2e6604 | 112 | } |
775f67d7 | 113 | HLTDebug("argv[%d+1] == %s", i, argv[i+1] ); |
93ce7d1b | 114 | fOutputSize = strtoul( argv[i+1], &cpErr, 0 ); |
775f67d7 | 115 | if ( *cpErr ) |
116 | { | |
93ce7d1b | 117 | HLTError("Cannot convert output_size parameter '%s'", argv[i+1] ); |
775f67d7 | 118 | return EINVAL; |
119 | } | |
93ce7d1b | 120 | HLTInfo("Output size set to %lu %%", fOutputSize ); |
775f67d7 | 121 | i += 2; |
122 | continue; | |
dc2e6604 | 123 | } |
93ce7d1b | 124 | if ( !strcmp( argv[i], "-everyNevent" ) ) |
125 | { | |
126 | if ( i+1>=argc ) | |
127 | { | |
128 | HLTError("Missing everyNevent parameter"); | |
129 | return ENOTSUP; | |
130 | } | |
131 | HLTDebug("argv[%d+1] == %s", i, argv[i+1] ); | |
132 | fOutputSize = strtoul( argv[i+1], &cpErr, 0 ); | |
133 | if ( *cpErr ) | |
134 | { | |
135 | HLTError("Cannot convert everyNevent parameter '%s'", argv[i+1] ); | |
136 | return EINVAL; | |
137 | } | |
138 | HLTInfo("Pushing back every %d event", feveryNevent); | |
139 | i += 2; | |
140 | continue; | |
141 | } | |
142 | ||
775f67d7 | 143 | else { |
144 | HLTError("Unknown option '%s'", argv[i] ); | |
145 | return EINVAL; | |
146 | } | |
147 | } | |
148 | return 0; | |
95259bbb | 149 | } |
150 | ||
151 | Int_t AliHLTTRDCalibrationComponent::InitCalibration() | |
152 | { | |
775f67d7 | 153 | if(!AliCDBManager::Instance()->IsDefaultStorageSet()){ |
93ce7d1b | 154 | HLTError("DefaultStorage is not set in CDBManager"); |
155 | return -EINVAL; | |
775f67d7 | 156 | } |
157 | if(AliCDBManager::Instance()->GetRun()<0){ | |
93ce7d1b | 158 | HLTError("Run Number is not set in CDBManager"); |
159 | return -EINVAL; | |
775f67d7 | 160 | } |
161 | HLTInfo("CDB default storage: %s; RunNo: %i", (AliCDBManager::Instance()->GetDefaultStorage()->GetBaseFolder()).Data(), AliCDBManager::Instance()->GetRun()); | |
775f67d7 | 162 | |
163 | fTRDCalibraFillHisto = AliTRDCalibraFillHisto::Instance(); | |
164 | fTRDCalibraFillHisto->SetHisto2d(); // choose to use histograms | |
165 | fTRDCalibraFillHisto->SetCH2dOn(); // choose to calibrate the gain | |
166 | fTRDCalibraFillHisto->SetPH2dOn(); // choose to calibrate the drift velocity | |
167 | fTRDCalibraFillHisto->SetPRF2dOn(); // choose to look at the PRF | |
93ce7d1b | 168 | fTRDCalibraFillHisto->SetIsHLT(); // per detector |
169 | //fTRDCalibraFillHisto->SetDebugLevel(1);// debug | |
170 | fTRDCalibraFillHisto->SetFillWithZero(kTRUE); | |
171 | ||
172 | fTracksArray = new TClonesArray("AliTRDtrackV1"); | |
173 | fOutArray = new TObjArray(3); | |
174 | ||
775f67d7 | 175 | return 0; |
95259bbb | 176 | } |
177 | ||
178 | Int_t AliHLTTRDCalibrationComponent::DeinitCalibration() | |
179 | { | |
93ce7d1b | 180 | |
775f67d7 | 181 | // Deinitialization of the component |
93ce7d1b | 182 | |
183 | HLTDebug("DeinitCalibration"); | |
184 | fTracksArray->Delete(); | |
185 | delete fTracksArray; | |
186 | fTRDCalibraFillHisto->Destroy(); | |
187 | //fOutArray->Delete(); | |
188 | delete fOutArray; | |
dc2e6604 | 189 | |
775f67d7 | 190 | return 0; |
95259bbb | 191 | } |
192 | ||
d679dd6c | 193 | Int_t AliHLTTRDCalibrationComponent::ProcessCalibration(const AliHLTComponent_EventData& evtData, |
dc2e6604 | 194 | const AliHLTComponent_BlockData* blocks, |
195 | AliHLTComponent_TriggerData& /*trigData*/, | |
196 | AliHLTUInt8_t* /*outputPtr*/, | |
197 | AliHLTUInt32_t& /*size*/, | |
198 | vector<AliHLTComponent_BlockData>& /*outputBlocks*/) | |
95259bbb | 199 | { |
775f67d7 | 200 | HLTDebug("NofBlocks %lu", evtData.fBlockCnt ); |
201 | // Process an event | |
202 | ||
203 | // Loop over all input blocks in the event | |
204 | vector<AliHLTComponent_DataType> expectedDataTypes; | |
205 | GetInputDataTypes(expectedDataTypes); | |
206 | for ( unsigned long iBlock = 0; iBlock < evtData.fBlockCnt; iBlock++ ) | |
207 | { | |
208 | const AliHLTComponentBlockData &block = blocks[iBlock]; | |
209 | AliHLTComponentDataType inputDataType = block.fDataType; | |
210 | Bool_t correctDataType = kFALSE; | |
211 | ||
212 | for(UInt_t i = 0; i < expectedDataTypes.size(); i++) | |
213 | if( expectedDataTypes.at(i) == inputDataType) | |
214 | correctDataType = kTRUE; | |
215 | if (!correctDataType) { | |
216 | HLTDebug( "Block # %i/%i; Event 0x%08LX (%Lu) Wrong received datatype: %s - Skipping", | |
217 | iBlock, evtData.fBlockCnt, | |
218 | evtData.fEventID, evtData.fEventID, | |
219 | DataType2Text(inputDataType).c_str()); | |
220 | continue; | |
221 | } | |
222 | else { | |
93ce7d1b | 223 | HLTDebug("We get the right data type: Block # %i/%i; Event 0x%08LX (%Lu) Received datatype: %s; Block Size: %i", |
775f67d7 | 224 | iBlock, evtData.fBlockCnt-1, |
225 | evtData.fEventID, evtData.fEventID, | |
93ce7d1b | 226 | DataType2Text(inputDataType).c_str(), |
227 | block.fSize); | |
775f67d7 | 228 | } |
229 | ||
93ce7d1b | 230 | Int_t nTimeBins; |
231 | AliHLTTRDUtils::ReadTracks(fTracksArray, block.fPtr, block.fSize, &nTimeBins); | |
232 | ||
233 | if(!fRecievedTimeBins){ | |
234 | HLTDebug("Reading number of time bins from input block. Value is: %d", nTimeBins); | |
235 | fTRDCalibraFillHisto->Init2Dhistos(); // initialise the histos | |
236 | fTRDCalibraFillHisto->SetNumberClusters(0); // At least 1 clusters | |
237 | fTRDCalibraFillHisto->SetNumberClustersf(nTimeBins); // Not more than %d clusters | |
238 | fRecievedTimeBins=kTRUE; | |
775f67d7 | 239 | } |
dc2e6604 | 240 | |
93ce7d1b | 241 | Int_t nbEntries = fTracksArray->GetEntries(); |
242 | HLTDebug(" %i TRDtracks in tracksArray", nbEntries); | |
243 | AliTRDtrackV1* trdTrack = 0x0; | |
244 | for (Int_t i = 0; i < nbEntries; i++){ | |
245 | HLTDebug("%i/%i: ", i+1, nbEntries); | |
246 | trdTrack = (AliTRDtrackV1*)fTracksArray->At(i); | |
247 | trdTrack->Print(); | |
248 | fTRDCalibraFillHisto->UpdateHistogramsV1(trdTrack); | |
249 | } | |
250 | ||
251 | if(!fOutArray->At(0))FormOutput(); | |
252 | if (fNevent%feveryNevent==0 && fOutArray) { | |
253 | PushBack(fOutArray, AliHLTTRDDefinitions::fgkCalibrationDataType); | |
775f67d7 | 254 | } |
dc2e6604 | 255 | |
93ce7d1b | 256 | fTracksArray->Delete(); |
257 | fNevent++; | |
258 | ||
775f67d7 | 259 | } |
260 | return 0; | |
dc2e6604 | 261 | |
95259bbb | 262 | } |
263 | ||
d679dd6c | 264 | /** |
dc2e6604 | 265 | * Form output array of histrograms |
d679dd6c | 266 | */ |
267 | //============================================================================ | |
93ce7d1b | 268 | void AliHLTTRDCalibrationComponent::FormOutput() |
d679dd6c | 269 | { |
775f67d7 | 270 | // gain histo |
271 | TH2I *hCH2d = fTRDCalibraFillHisto->GetCH2d(); | |
93ce7d1b | 272 | fOutArray->Add(hCH2d); |
d679dd6c | 273 | |
775f67d7 | 274 | // drift velocity histo |
275 | TProfile2D *hPH2d = fTRDCalibraFillHisto->GetPH2d(); | |
93ce7d1b | 276 | fOutArray->Add(hPH2d); |
d679dd6c | 277 | |
775f67d7 | 278 | // PRF histo |
279 | TProfile2D *hPRF2d = fTRDCalibraFillHisto->GetPRF2d(); | |
93ce7d1b | 280 | fOutArray->Add(hPRF2d); |
dc2e6604 | 281 | |
775f67d7 | 282 | HLTDebug("GetCH2d = 0x%x; NEntries = %i; size = %i", hCH2d, hCH2d->GetEntries(), sizeof(hCH2d)); |
283 | hCH2d->Print(); | |
284 | HLTDebug("GetPH2d = 0x%x; NEntries = %i; size = %i", hPH2d, hPH2d->GetEntries(), sizeof(hPH2d)); | |
285 | hPH2d->Print(); | |
286 | HLTDebug("GetPRF2d = 0x%x; NEntries = %i; size = %i", hPRF2d, hPRF2d->GetEntries(), sizeof(hPRF2d)); | |
287 | hPRF2d->Print(); | |
93ce7d1b | 288 | HLTDebug("output Array: pointer = 0x%x; NEntries = %i; size = %i", fOutArray, fOutArray->GetEntries(), sizeof(fOutArray)); |
d679dd6c | 289 | } |
290 | ||
93ce7d1b | 291 | Int_t AliHLTTRDCalibrationComponent::ShipDataToFXS(const AliHLTComponentEventData& /*evtData*/, AliHLTComponentTriggerData& /*trigData*/) |
292 | { | |
293 | //fTRDCalibraFillHisto->DestroyDebugStreamer(); | |
294 | PushToFXS((TObject*)fOutArray, "TRD", "GAINDRIFTPRF"); | |
e03c1166 | 295 | return 0; |
93ce7d1b | 296 | } |