3 //**************************************************************************
4 //* This file is property of and copyright by the ALICE HLT Project *
5 //* ALICE Experiment at CERN, All rights reserved. *
7 //* Primary Authors: Kalliopi Kanaki <Kalliopi.Kanaki@ift.uib.no> *
8 //* for The ALICE HLT 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 AliHLTTPCNoiseMapComponent.cxx
20 @author Kalliopi Kanaki
22 @brief The TPC Noise Map component
28 #include "AliHLTTPCNoiseMapComponent.h"
29 #include "AliHLTTPCDigitReaderDecoder.h"
30 #include "AliHLTTPCDigitReaderPacked.h"
31 #include "AliHLTTPCTransform.h"
32 #include "AliHLTTPCDefinitions.h"
33 #include "AliCDBEntry.h"
34 #include "AliCDBManager.h"
35 #include "AliTPCCalPad.h"
40 #include "TObjArray.h"
41 #include "TObjString.h"
46 AliHLTTPCNoiseMapComponent gAliHLTTPCNoiseMapComponent;
48 ClassImp(AliHLTTPCNoiseMapComponent) //ROOT macro for the implementation of ROOT specific class methods
50 AliHLTTPCNoiseMapComponent::AliHLTTPCNoiseMapComponent()
67 // see header file for class documentation
69 // refer to README to build package
71 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
74 AliHLTTPCNoiseMapComponent::~AliHLTTPCNoiseMapComponent() {
75 // see header file for class documentation
79 // Public functions to implement AliHLTComponent's interface.
80 // These functions are required for the registration process
82 const char* AliHLTTPCNoiseMapComponent::GetComponentID() {
83 // see header file for class documentation
88 void AliHLTTPCNoiseMapComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) {
89 // see header file for class documentation
92 list.push_back( kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTPC );
95 AliHLTComponentDataType AliHLTTPCNoiseMapComponent::GetOutputDataType() {
96 // see header file for class documentation
98 return kAliHLTDataTypeHistogram;
101 int AliHLTTPCNoiseMapComponent::GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList) {
102 // see header file for class documentation
105 tgtList.push_back(kAliHLTDataTypeHistogram);
106 return tgtList.size();
109 void AliHLTTPCNoiseMapComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) {
110 // see header file for class documentation
116 AliHLTComponent* AliHLTTPCNoiseMapComponent::Spawn() {
117 // see header file for class documentation
119 return new AliHLTTPCNoiseMapComponent();
122 int AliHLTTPCNoiseMapComponent::DoInit( int argc, const char** argv ) {
123 // see header file for class documentation
130 TString configuration="";
132 for (int i=0; i<argc && iResult>=0; i++) {
135 if (!configuration.IsNull()) configuration+=" ";
136 configuration+=argument;
140 if (!configuration.IsNull()) {
141 iResult=Configure(configuration.Data());
143 iResult=Reconfigure(NULL, NULL);
148 if (!strcmp( argv[i], "-apply-noisemap")) {
149 fApplyNoiseMap = strtoul( argv[i+1], &cpErr ,0);
152 HLTError("Cannot convert apply-noisemap specifier '%s'.", argv[i+1]);
159 if (!strcmp( argv[i], "-plot-side-a")) {
160 fPlotSideA = strtoul( argv[i+1], &cpErr ,0);
162 fHistSideA = new TH2F("fHistSideA","TPC Side A",250,-250,250,250,-250,250);
163 fHistSideA->SetXTitle("global X (cm)"); fHistSideA->SetYTitle("global Y (cm)");
166 HLTError("Cannot convert plot-side-a specifier '%s'.", argv[i+1]);
173 if (!strcmp( argv[i], "-plot-side-c")) {
174 fPlotSideC = strtoul( argv[i+1], &cpErr ,0);
176 fHistSideC = new TH2F("fHistSideC","TPC Side C",250,-250,250,250,-250,250);
177 fHistSideC->SetXTitle("global X (cm)"); fHistSideC->SetYTitle("global Y (cm)");
179 //fSliceA[18], fSliceC[18]
182 HLTError("Cannot convert plot-side-c specifier '%s'.", argv[i+1]);
189 // if (!strcmp( argv[i], "-slice")) {
190 // fSlice = strtoul( argv[i+1], &cpErr ,0);
193 // HLTError("Cannot convert slice specifier '%s'. Must be integer", argv[i+1]);
200 Logging(kHLTLogError, "HLT::TPCNoiseMap::DoInit", "Unknown Option", "Unknown option '%s'", argv[i] );
205 //HLTDebug("using AliHLTTPCDigitReaderDecoder");
206 //pDigitReader = new AliHLTTPCDigitReaderDecoder(); // double-loop
207 //pDigitReader = new AliHLTTPCDigitReaderPacked();
210 // //cout<<"Digit reader decoder is chosen"<<endl;
211 // fDigitReader = new AliHLTTPCDigitReaderDecoder();
213 // else if(fIsUnpacked){
214 // //cout<<"Digit reader unpacked is chosen"<<endl;
215 // fDigitReader = new AliHLTTPCDigitReaderDecoderUnpacked();
218 // HLTFatal("Neither of the two options of digit readers is set no data will be read.");
225 int AliHLTTPCNoiseMapComponent::DoDeinit() {
226 // see header file for class documentation
231 // int AliHLTTPCNoiseMapComponent::DoEvent( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
232 // AliHLTComponentTriggerData&, AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size,
233 // vector<AliHLTComponentBlockData>& outputBlocks ) {
236 int AliHLTTPCNoiseMapComponent::DoEvent(const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData){
237 // see header file for class documentation
239 HLTInfo("--- Entering DoEvent() in TPCNoiseMap ---");
241 if(GetFirstInputBlock( kAliHLTDataTypeSOR ) || GetFirstInputBlock( kAliHLTDataTypeEOR )) return 0;
243 const AliHLTComponentBlockData* iter = NULL;
247 Int_t thissector, thisrow;
249 // reading an existing noise map file
251 TFile *f = TFile::Open("Run3398_4000_v0_s72.root");
252 AliCDBEntry *entry = (AliCDBEntry*)f->Get("AliCDBEntry");
253 AliTPCCalPad *noisePad = (AliTPCCalPad*)entry->GetObject();
254 fHistCDBMap = noisePad->MakeHisto2D(1); //side C
257 for (iter = GetFirstInputBlock(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginTPC); iter != NULL; iter = GetNextInputBlock()){
259 //for ( ndx=0; ndx<evtData.fBlockCnt; ndx++ ) {
260 // iter = blocks+ndx;
262 HLTInfo("Event 0x%08LX (%Lu) received datatype: %s - required datatype: %s",
263 evtData.fEventID, evtData.fEventID,
264 DataType2Text(iter->fDataType).c_str(),
265 DataType2Text(kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTPC).c_str());
267 if (iter->fDataType == AliHLTTPCDefinitions::fgkDDLPackedRawDataType && GetEventCount()<2){
268 HLTWarning("data type %s is depricated, use %s (kAliHLTDataTypeDDLRaw)!",
269 DataType2Text(AliHLTTPCDefinitions::fgkDDLPackedRawDataType).c_str(),
270 DataType2Text(kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTPC).c_str());
273 if (iter->fDataType != (kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTPC)) continue;
275 UInt_t slice = AliHLTTPCDefinitions::GetMinSliceNr(*iter);
276 UInt_t partition = AliHLTTPCDefinitions::GetMinPatchNr(*iter);
278 //if ( partition < fMinPartition ) fMinPartition = partition;
279 //if ( partition > fMaxPartition ) fMaxPartition = partition; // add a warning
281 //fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification( slice, slice, partition, partition );
282 fSpecification = iter->fSpecification;
284 AliHLTTPCDigitReader *pDigitReader = new AliHLTTPCDigitReaderDecoder;
286 pDigitReader->InitBlock(iter->fPtr,iter->fSize,partition,slice);
287 if(!pDigitReader) break; //AliHLTComponent.cxx, altrochannelselector rcu folder
289 while( pDigitReader->Next() ){
290 //while( pDigitReader->NextChannel()) { // pad loop
292 fCurrentRow = pDigitReader->GetRow();
293 fCurrentRow += pDigitReader->GetRowOffset();
295 AliHLTTPCTransform::Slice2Sector(slice,fCurrentRow,thissector,thisrow);
296 AliHLTTPCTransform::Raw2Global(xyz,thissector,thisrow,pDigitReader->GetPad(),0);
298 //use AliTPCPad to fill the data there and use the functions to ask for max charge etc.
301 //while( pDigitReader->NextBunch()) {
303 //in case we want to fill the histograms with the signal value, an additional loop is necessary
304 for(Int_t i=0;i<pDigitReader->GetBunchSize();i++) {
306 const UInt_t *bunchData = pDigitReader->GetSignals();
307 if(bunchData[i]>maxSignal) maxSignal = bunchData[i];
309 //cout<<"Time: "<<pDigitReader->GetTime()+i<<" Signal: "<<bunchData[i]<<endl;
311 //} // end of inner while loop
312 //cout<<slice<<" "<<partition<<" "<<fCurrentRow<<" "<<pDigitReader->GetPad()<<" "<<xyz[0]<<" "<<xyz[1]<<" "<<maxSignal<<endl;
314 if(fPlotSideA || fPlotSideC){
315 if(slice<18) fHistSideA->Fill(xyz[0],xyz[1],maxSignal);
316 else fHistSideC->Fill(xyz[0],xyz[1],maxSignal);
319 } // end of while loop
320 } // end of for loop over data blocks
326 void AliHLTTPCNoiseMapComponent::MakeHistosPublic() {
327 // see header file for class documentation
329 // TFile *outputfile = new TFile("test.root","RECREATE");
330 // fHistSideC->Write();
331 // fHistCDBMap->Write();
332 // fHistSlice[18]->Write();
333 // outputfile->Save();
334 // outputfile->Close();
337 histos.Add(fHistSideA);
338 histos.Add(fHistSideC);
339 PushBack( (TObject*) &histos, kAliHLTDataTypeHistogram, fSpecification);
341 //PushBack( (TObject*) fHistSideC, kAliHLTDataTypeHistogram, fSpecification);
343 //fill it with the right specification for every histogram
344 //make a TObjArray and add all histos
345 //check which pointers are empty and publish only the ones that hold something
352 int AliHLTTPCNoiseMapComponent::Configure(const char* arguments) {
353 // see header file for class documentation
356 if (!arguments) return iResult;
357 HLTInfo("parsing configuration string \'%s\'", arguments);
359 TString allArgs=arguments;
363 TObjArray* pTokens=allArgs.Tokenize(" ");
365 for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) {
366 argument=((TObjString*)pTokens->At(i))->GetString();
367 if (argument.IsNull()) continue;
369 if (argument.CompareTo("-apply-noisemap")==0) {
370 if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
371 HLTInfo("got \'-apply-noisemap\': %s", ((TObjString*)pTokens->At(i))->GetString().Data());
374 else if (argument.CompareTo("-plot-side-c")==0) {
375 if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
376 HLTInfo("got \'-plot-side-c\': %s", ((TObjString*)pTokens->At(i))->GetString().Data());
379 else if (argument.CompareTo("-plot-side-a")==0) {
380 if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
381 HLTInfo("got \'-plot-side-a\': %s", ((TObjString*)pTokens->At(i))->GetString().Data());
385 HLTError("unknown argument %s", argument.Data());
396 HLTError("missing parameter for argument %s", argument.Data());
402 int AliHLTTPCNoiseMapComponent::Reconfigure(const char* cdbEntry, const char* chainId) {
403 // see header file for class documentation
406 const char* path="HLT/ConfigTPC/TPCNoiseMapComponent";
407 const char* defaultNotify="";
410 defaultNotify=" (default)";
414 HLTInfo("reconfigure from entry %s%s, chain id %s", path, defaultNotify,(chainId!=NULL && chainId[0]!=0)?chainId:"<none>");
415 AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/);
417 TObjString* pString=dynamic_cast<TObjString*>(pEntry->GetObject());
419 HLTInfo("received configuration object string: \'%s\'", pString->GetString().Data());
420 iResult=Configure(pString->GetString().Data());
422 HLTError("configuration object \"%s\" has wrong type, required TObjString", path);
425 HLTError("cannot fetch object \"%s\" from CDB", path);