3 /**************************************************************************
4 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
6 * Authors: Matthias Richter <Matthias.Richter@ift.uib.no> *
7 * Timm Steinbeck <timm@kip.uni-heidelberg.de> *
8 * for The ALICE Off-line Project. *
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 **************************************************************************/
19 /** @file AliHLTTRDCalibrationComponent.cxx
20 @author Timm Steinbeck, Matthias Richter
22 @brief A TRDCalibration processing component for the HLT. */
32 #include "AliHLTTRDCalibrationComponent.h"
33 #include "AliHLTTRDDefinitions.h"
34 #include "AliHLTTRDUtils.h"
36 #include "AliCDBManager.h"
37 #include "AliRawReaderMemory.h"
38 #include "AliTRDCalibraFillHisto.h"
39 #include "AliTRDtrackV1.h"
45 // this is a global object used for automatic component registration, do not use this
46 AliHLTTRDCalibrationComponent gAliHLTTRDCalibrationComponent;
48 ClassImp(AliHLTTRDCalibrationComponent);
50 AliHLTTRDCalibrationComponent::AliHLTTRDCalibrationComponent():
51 AliHLTCalibrationProcessor(),
52 fTRDCalibraFillHisto(NULL),
53 fOutputPercentage(100), // By default we copy to the output exactly what we got as input
54 fStrorageDBpath("local://$ALICE_ROOT/OCDB"),
57 // Default constructor
60 AliHLTTRDCalibrationComponent::~AliHLTTRDCalibrationComponent()
66 const char* AliHLTTRDCalibrationComponent::GetComponentID()
68 // Return the component ID const char *
69 return "TRDCalibration"; // The ID of this component
72 void AliHLTTRDCalibrationComponent::GetInputDataTypes( vector<AliHLTComponent_DataType>& list)
74 // Get the list of input data
75 list.clear(); // We do not have any requirements for our input data type(s).
76 list.push_back( AliHLTTRDDefinitions::fgkTRDSATracksDataType );
79 AliHLTComponent_DataType AliHLTTRDCalibrationComponent::GetOutputDataType()
81 // Get the output data type
82 return AliHLTTRDDefinitions::fgkCalibrationDataType;
85 void AliHLTTRDCalibrationComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
87 // Get the output data size
89 inputMultiplier = ((double)fOutputPercentage)/100.0;
92 AliHLTComponent* AliHLTTRDCalibrationComponent::Spawn()
94 // Spawn function, return new instance of this class
95 return new AliHLTTRDCalibrationComponent;
98 Int_t AliHLTTRDCalibrationComponent::ScanArgument( int argc, const char** argv )
100 // perform initialization. We check whether our relative output size is specified in the arguments.
105 HLTDebug("argv[%d] == %s", i, argv[i] );
106 if ( !strcmp( argv[i], "output_percentage" ) )
110 HLTError("Missing output_percentage parameter");
113 HLTDebug("argv[%d+1] == %s", i, argv[i+1] );
114 fOutputPercentage = strtoul( argv[i+1], &cpErr, 0 );
117 HLTError("Cannot convert output_percentage parameter '%s'", argv[i+1] );
120 HLTInfo("Output percentage set to %lu %%", fOutputPercentage );
124 else if ( strcmp( argv[i], "-cdb" ) == 0)
128 HLTError("Missing -cdb argument");
131 fStrorageDBpath = argv[i+1];
132 HLTInfo("DB storage is %s", fStrorageDBpath.c_str() );
137 HLTError("Unknown option '%s'", argv[i] );
144 Int_t AliHLTTRDCalibrationComponent::InitCalibration()
146 //init the calibration
147 fCDB = AliCDBManager::Instance();
150 HLTError("Could not get CDB instance, fCDB 0x%x", fCDB);
154 fCDB->SetRun(0); // THIS HAS TO BE RETRIEVED !!!
155 fCDB->SetDefaultStorage(fStrorageDBpath.c_str());
156 HLTDebug("fCDB 0x%x", fCDB);
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
167 Int_t AliHLTTRDCalibrationComponent::DeinitCalibration()
169 HLTDebug("DeinitCalibration");
171 // Deinitialization of the component
175 HLTDebug("destroy fCDB");
182 Int_t AliHLTTRDCalibrationComponent::ProcessCalibration(const AliHLTComponent_EventData& evtData,
183 const AliHLTComponent_BlockData* blocks,
184 AliHLTComponent_TriggerData& /*trigData*/,
185 AliHLTUInt8_t* /*outputPtr*/,
186 AliHLTUInt32_t& /*size*/,
187 vector<AliHLTComponent_BlockData>& /*outputBlocks*/)
189 HLTDebug("NofBlocks %lu", evtData.fBlockCnt );
192 // Loop over all input blocks in the event
193 vector<AliHLTComponent_DataType> expectedDataTypes;
194 GetInputDataTypes(expectedDataTypes);
195 for ( unsigned long iBlock = 0; iBlock < evtData.fBlockCnt; iBlock++ )
197 const AliHLTComponentBlockData &block = blocks[iBlock];
198 AliHLTComponentDataType inputDataType = block.fDataType;
199 Bool_t correctDataType = kFALSE;
201 for(UInt_t i = 0; i < expectedDataTypes.size(); i++)
202 if( expectedDataTypes.at(i) == inputDataType)
203 correctDataType = kTRUE;
204 if (!correctDataType) {
205 HLTDebug( "Block # %i/%i; Event 0x%08LX (%Lu) Wrong received datatype: %s - Skipping",
206 iBlock, evtData.fBlockCnt,
207 evtData.fEventID, evtData.fEventID,
208 DataType2Text(inputDataType).c_str());
212 HLTDebug("We get the right data type: Block # %i/%i; Event 0x%08LX (%Lu) Received datatype: %s",
213 iBlock, evtData.fBlockCnt-1,
214 evtData.fEventID, evtData.fEventID,
215 DataType2Text(inputDataType).c_str());
217 TClonesArray* tracksArray = NULL;
218 tracksArray = new TClonesArray("AliTRDtrackV1");
219 HLTDebug("BLOCK fPtr 0x%x, fOffset %i, fSize %i, fSpec 0x%x, fDataType %s", block.fPtr, block.fOffset, block.fSize, block.fSpecification, DataType2Text(block.fDataType).c_str());
220 AliHLTTRDUtils::ReadTracks(tracksArray, block.fPtr, block.fSize);
223 Int_t nbEntries = tracksArray->GetEntries();
224 HLTDebug(" %i TRDtracks in tracksArray", nbEntries);
225 AliTRDtrackV1* trdTrack = 0x0;
226 for (Int_t i = 0; i < nbEntries; i++){
227 HLTDebug("%i/%i: ", i+1, nbEntries);
228 trdTrack = (AliTRDtrackV1*)tracksArray->At(i);
230 fTRDCalibraFillHisto->UpdateHistogramsV1(trdTrack);
235 TObjArray *outArray = FormOutput();
237 PushBack(outArray, AliHLTTRDDefinitions::fgkCalibrationDataType);
248 * Form output array of histrograms
250 //============================================================================
251 TObjArray* AliHLTTRDCalibrationComponent::FormOutput()
253 TObjArray *outArray=new TObjArray(3);
256 TH2I *hCH2d = fTRDCalibraFillHisto->GetCH2d();
257 outArray->Add(hCH2d);
259 // drift velocity histo
260 TProfile2D *hPH2d = fTRDCalibraFillHisto->GetPH2d();
261 outArray->Add(hPH2d);
264 TProfile2D *hPRF2d = fTRDCalibraFillHisto->GetPRF2d();
265 outArray->Add(hPRF2d);
267 HLTDebug("GetCH2d = 0x%x; NEntries = %i; size = %i", hCH2d, hCH2d->GetEntries(), sizeof(hCH2d));
269 HLTDebug("GetPH2d = 0x%x; NEntries = %i; size = %i", hPH2d, hPH2d->GetEntries(), sizeof(hPH2d));
271 HLTDebug("GetPRF2d = 0x%x; NEntries = %i; size = %i", hPRF2d, hPRF2d->GetEntries(), sizeof(hPRF2d));
273 HLTDebug("output Array: pointer = 0x%x; NEntries = %i; size = %i", outArray, outArray->GetEntries(), sizeof(outArray));