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"
39 #include "TObjArray.h"
40 #include "TObjString.h"
45 AliHLTTPCNoiseMapComponent gAliHLTTPCNoiseMapComponent;
47 ClassImp(AliHLTTPCNoiseMapComponent) //ROOT macro for the implementation of ROOT specific class methods
49 AliHLTTPCNoiseMapComponent::AliHLTTPCNoiseMapComponent()
57 // see header file for class documentation
59 // refer to README to build package
61 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
64 AliHLTTPCNoiseMapComponent::~AliHLTTPCNoiseMapComponent() {
65 // see header file for class documentation
69 // Public functions to implement AliHLTComponent's interface.
70 // These functions are required for the registration process
72 const char* AliHLTTPCNoiseMapComponent::GetComponentID() {
73 // see header file for class documentation
78 void AliHLTTPCNoiseMapComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) {
79 // see header file for class documentation
82 list.push_back( kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTPC );
85 AliHLTComponentDataType AliHLTTPCNoiseMapComponent::GetOutputDataType() {
86 // see header file for class documentation
88 return AliHLTTPCDefinitions::fgkNoiseHistoDataType;
91 int AliHLTTPCNoiseMapComponent::GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList) {
92 // see header file for class documentation
95 tgtList.push_back(AliHLTTPCDefinitions::fgkNoiseHistoDataType);
96 return tgtList.size();
99 void AliHLTTPCNoiseMapComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) {
100 // see header file for class documentation
106 AliHLTComponent* AliHLTTPCNoiseMapComponent::Spawn() {
107 // see header file for class documentation
109 return new AliHLTTPCNoiseMapComponent();
112 int AliHLTTPCNoiseMapComponent::DoInit( int argc, const char** argv ) {
113 // see header file for class documentation
120 TString configuration="";
122 for (int i=0; i<argc && iResult>=0; i++) {
125 if (!configuration.IsNull()) configuration+=" ";
126 configuration+=argument;
130 if (!configuration.IsNull()) {
131 iResult=Configure(configuration.Data());
133 iResult=Reconfigure(NULL, NULL);
140 // -- fill noise histograms
141 if (!strcmp( argv[i], "-noisemap")) {
142 fNoiseMap = strtoul( argv[i+1], &cpErr ,0);
146 fHistSideC = new TH2F("fHistSideC","",500,-250,250,500,-250,250);
147 HLTInfo("---- HAVE CREATED HISTOGRAM(S) ----");
148 //fSideA, fSideC, fSliceA[18], fSliceC[18]
152 HLTError("Cannot convert noisemap specifier '%s'.", argv[i+1]);
159 Logging(kHLTLogError, "HLT::TPCNoiseMap::DoInit", "Unknown Option", "Unknown option '%s'", argv[i] );
164 //HLTDebug("using AliHLTTPCDigitReaderDecoder");
165 //pDigitReader = new AliHLTTPCDigitReaderDecoder(); // double-loop
166 //pDigitReader = new AliHLTTPCDigitReaderPacked();
169 // //cout<<"Digit reader decoder is chosen"<<endl;
170 // fDigitReader = new AliHLTTPCDigitReaderDecoder();
172 // else if(fIsUnpacked){
173 // //cout<<"Digit reader unpacked is chosen"<<endl;
174 // fDigitReader = new AliHLTTPCDigitReaderDecoderUnpacked();
177 // HLTFatal("Neither of the two options of digit readers is set no data will be read.");
184 int AliHLTTPCNoiseMapComponent::DoDeinit() {
185 // see header file for class documentation
190 int AliHLTTPCNoiseMapComponent::DoEvent( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
191 AliHLTComponentTriggerData&, AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size,
192 vector<AliHLTComponentBlockData>& outputBlocks ) {
193 // see header file for class documentation
196 HLTInfo("--- Entering DoEvent() in TPCNoiseMap ---");
198 // == init iter (pointer to datablock)
199 const AliHLTComponentBlockData* iter = NULL;
203 Int_t thissector, thisrow;
206 for ( ndx=0; ndx<evtData.fBlockCnt; ndx++ ) {
209 HLTInfo("Event 0x%08LX (%Lu) received datatype: %s - required datatype: %s", evtData.fEventID, evtData.fEventID,
210 DataType2Text( iter->fDataType).c_str(), DataType2Text(kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTPC).c_str());
212 if (iter->fDataType == AliHLTTPCDefinitions::fgkDDLPackedRawDataType && GetEventCount()<2) {
213 HLTWarning("data type %s is depricated, use %s (kAliHLTDataTypeDDLRaw)!", DataType2Text(AliHLTTPCDefinitions::fgkDDLPackedRawDataType).c_str(),
214 DataType2Text(kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTPC).c_str());
217 if (iter->fDataType != (kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTPC)) continue;
220 UInt_t slice = AliHLTTPCDefinitions::GetMinSliceNr( *iter );
221 UInt_t partition = AliHLTTPCDefinitions::GetMinPatchNr( *iter );
223 //if ( partition < fMinPartition ) fMinPartition = partition;
224 //if ( partition > fMaxPartition ) fMaxPartition = partition; // add a warning
226 //fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification( slice, slice, partition, partition );
227 fSpecification = iter->fSpecification;
229 AliHLTTPCDigitReader *pDigitReader = new AliHLTTPCDigitReaderDecoder;
230 pDigitReader->InitBlock(iter->fPtr,iter->fSize,partition,slice);
231 if(!pDigitReader) break; //AliHLTComponent.cxx, altrochannelselector rcu folder
237 rowOffset=AliHLTTPCTransform::GetFirstRow(0);
240 rowOffset=AliHLTTPCTransform::GetFirstRow(1);
243 rowOffset=AliHLTTPCTransform::GetFirstRow(2);
246 rowOffset=AliHLTTPCTransform::GetFirstRow(3);
249 rowOffset=AliHLTTPCTransform::GetFirstRow(4);
252 rowOffset=AliHLTTPCTransform::GetFirstRow(5);
257 //while( pDigitReader->Next() ){
258 while( pDigitReader->NextChannel()) {
260 fCurrentRow = pDigitReader->GetRow();
261 fCurrentRow += rowOffset;
263 if(pDigitReader->GetPad()==1000 || fCurrentRow==1000) continue;
265 AliHLTTPCTransform::Slice2Sector(slice,fCurrentRow,thissector,thisrow);
266 AliHLTTPCTransform::Raw2Global(xyz,thissector,thisrow,pDigitReader->GetPad(),0);
267 //AliHLTTPCTransform::Raw2Local(xyz,thissector,thisrow,pDigitReader->GetPad(),0);
269 //use AliTPCPad to fill the data there and use the functions to ask for max charge etc.
272 while( pDigitReader->NextBunch()) {
274 //in case we want to fill the histograms with the signal value, an additional loop is necessary
275 for(Int_t i=0;i<pDigitReader->GetBunchSize();i++) {
277 const UInt_t *bunchData = pDigitReader->GetSignals();
278 if(bunchData[i]>maxSignal) maxSignal = bunchData[i];
279 //cout<<"Time: "<<pDigitReader->GetTime()+i<<" Signal: "<<bunchData[i]<<endl;
281 } // end of inner while loop
283 cout<<slice<<" "<<partition<<" "<<fCurrentRow<<" "<<pDigitReader->GetPad()<<" "<<xyz[0]<<" "<<xyz[1]<<" "<<maxSignal<<endl;
285 fHistSideC->Fill(xyz[0],xyz[1],maxSignal);
287 } // end of outer while pad loop
288 } // end of data block loop
290 SaveAndResetHistograms();
292 } // end if noisemap==kTRUE
296 void AliHLTTPCNoiseMapComponent::SaveAndResetHistograms() {
297 // see header file for class documentation
299 TFile *outputfile = new TFile("test.root","RECREATE");
304 PushBack( (TObject*) fHistSideC, AliHLTTPCDefinitions::fgkNoiseHistoDataType, fSpecification);
305 //fill it with the right specification for every histogram
306 //make a TObjArray and add all histos
307 //check which pointers are empty and publish only the ones that hold something
312 int AliHLTTPCNoiseMapComponent::Configure(const char* arguments) {
313 // see header file for class documentation
316 if (!arguments) return iResult;
317 HLTInfo("parsing configuration string \'%s\'", arguments);
319 TString allArgs=arguments;
323 TObjArray* pTokens=allArgs.Tokenize(" ");
325 for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) {
326 argument=((TObjString*)pTokens->At(i))->GetString();
327 if (argument.IsNull()) continue;
329 if (argument.CompareTo("-noisemap")==0) {
330 if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
331 HLTInfo("got \'-noisemap\': %s", ((TObjString*)pTokens->At(i))->GetString().Data());
335 HLTError("unknown argument %s", argument.Data());
343 HLTError("missing parameter for argument %s", argument.Data());
350 int AliHLTTPCNoiseMapComponent::Reconfigure(const char* cdbEntry, const char* chainId) {
351 // see header file for class documentation
354 const char* path="HLT/ConfigTPC/TPCNoiseMapComponent";
355 const char* defaultNotify="";
358 defaultNotify=" (default)";
361 HLTInfo("reconfigure from entry %s%s, chain id %s", path, defaultNotify,(chainId!=NULL && chainId[0]!=0)?chainId:"<none>");
362 AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/);
364 TObjString* pString=dynamic_cast<TObjString*>(pEntry->GetObject());
366 HLTInfo("received configuration object string: \'%s\'", pString->GetString().Data());
367 iResult=Configure(pString->GetString().Data());
369 HLTError("configuration object \"%s\" has wrong type, required TObjString", path);
372 HLTError("can not fetch object \"%s\" from CDB", path);