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
29 #include "AliHLTTPCNoiseMapComponent.h"
30 #include "AliHLTTPCDigitReaderDecoder.h"
31 #include "AliHLTTPCDigitReaderPacked.h"
32 #include "AliHLTTPCTransform.h"
33 #include "AliHLTTPCDefinitions.h"
35 #include "AliCDBEntry.h"
36 #include "AliCDBManager.h"
38 #include "AliTPCCalPad.h"
39 #include "AliTPCROC.h"
40 #include "AliTPCCalROC.h"
46 #include "TObjArray.h"
47 #include "TObjString.h"
52 AliHLTTPCNoiseMapComponent gAliHLTTPCNoiseMapComponent;
54 ClassImp(AliHLTTPCNoiseMapComponent) //ROOT macro for the implementation of ROOT specific class methods
56 AliHLTTPCNoiseMapComponent::AliHLTTPCNoiseMapComponent()
68 fCurrentPartition(-99),
75 // see header file for class documentation
77 // refer to README to build package
79 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
82 AliHLTTPCNoiseMapComponent::~AliHLTTPCNoiseMapComponent() {
83 // see header file for class documentation
87 // Public functions to implement AliHLTComponent's interface.
88 // These functions are required for the registration process
90 const char* AliHLTTPCNoiseMapComponent::GetComponentID() {
91 // see header file for class documentation
96 void AliHLTTPCNoiseMapComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) {
97 // see header file for class documentation
100 list.push_back( kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTPC );
103 AliHLTComponentDataType AliHLTTPCNoiseMapComponent::GetOutputDataType() {
104 // see header file for class documentation
106 return kAliHLTDataTypeHistogram;
109 int AliHLTTPCNoiseMapComponent::GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList) {
110 // see header file for class documentation
113 tgtList.push_back(kAliHLTDataTypeHistogram);
114 return tgtList.size();
117 void AliHLTTPCNoiseMapComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) {
118 // see header file for class documentation
124 AliHLTComponent* AliHLTTPCNoiseMapComponent::Spawn() {
125 // see header file for class documentation
127 return new AliHLTTPCNoiseMapComponent();
130 int AliHLTTPCNoiseMapComponent::DoInit( int argc, const char** argv ) {
131 // see header file for class documentation
138 TString configuration="";
140 for (int j=0; j<argc && iResult>=0; j++) {
143 if (!configuration.IsNull()) configuration+=" ";
144 configuration+=argument;
147 if (!configuration.IsNull()) {
148 iResult=Configure(configuration.Data());
150 iResult=Reconfigure(NULL, NULL);
155 if (!strcmp( argv[i], "-apply-noisemap")) {
156 fApplyNoiseMap = strtoul( argv[i+1], &cpErr ,0);
159 HLTError("Cannot convert apply-noisemap specifier '%s'.", argv[i+1]);
166 if (!strcmp( argv[i], "-plot-side-a")) {
167 fPlotSideA = strtoul( argv[i+1], &cpErr ,0);
170 HLTError("Cannot convert plot-side-a specifier '%s'.", argv[i+1]);
177 if (!strcmp( argv[i], "-plot-side-c")) {
178 fPlotSideC = strtoul( argv[i+1], &cpErr ,0);
181 HLTError("Cannot convert plot-side-c specifier '%s'.", argv[i+1]);
188 if (!strcmp( argv[i], "-reset-histograms")) {
189 fResetHistograms = strtoul( argv[i+1], &cpErr ,0);
192 HLTError("Cannot convert reset-histograms specifier '%s'.", argv[i+1]);
199 Logging(kHLTLogError, "HLT::TPCNoiseMap::DoInit", "Unknown Option", "Unknown option '%s'", argv[i] );
205 // if(fApplyNoiseMap){
206 // //TFile *f = TFile::Open("/scratch/noiseComp/Run3398_4000_v0_s72.root");
207 // TFile *f = TFile::Open("/home/kanaki/noiseComp/Run3398_4000_v0_s72.root");
208 // AliCDBEntry *pEntry = (AliCDBEntry*)f->Get("AliCDBEntry");
209 // noisePad = (AliTPCCalPad*)pEntry->GetObject();
210 // //fHistCDBMap = noisePad->MakeHisto2D(1); //side C
214 // HLTDebug("using AliHLTTPCDigitReaderDecoder");
215 // pDigitReader = new AliHLTTPCDigitReaderDecoder(); // double-loop
216 // pDigitReader = new AliHLTTPCDigitReaderPacked();
222 int AliHLTTPCNoiseMapComponent::DoDeinit() {
223 // see header file for class documentation
228 int AliHLTTPCNoiseMapComponent::DoEvent(const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& /*trigData*/){
229 // see header file for class documentation
231 HLTInfo("--- Entering DoEvent() in TPCNoiseMap ---");
233 if(GetFirstInputBlock( kAliHLTDataTypeSOR ) || GetFirstInputBlock( kAliHLTDataTypeEOR )) return 0;
236 fHistSideA = new TH2F("fHistSideA","TPC Side A",250,-250,250,250,-250,250);
237 fHistSideA->SetXTitle("global X (cm)"); fHistSideA->SetYTitle("global Y (cm)");
241 fHistSideC = new TH2F("fHistSideC","TPC Side C",250,-250,250,250,-250,250);
242 fHistSideC->SetXTitle("global X (cm)"); fHistSideC->SetYTitle("global Y (cm)");
245 const AliHLTComponentBlockData *iter = NULL;
248 Int_t thissector, thisrow;
250 fHistPartition = new TH2F("fHistPartition","fHistPartition",250,-250,250,250,-250,250);
252 for(iter = GetFirstInputBlock(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginTPC); iter != NULL; iter = GetNextInputBlock()){
254 HLTInfo("Event 0x%08LX (%Lu) received datatype: %s - required datatype: %s",
255 evtData.fEventID, evtData.fEventID,
256 DataType2Text(iter->fDataType).c_str(),
257 DataType2Text(kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTPC).c_str());
259 if (iter->fDataType == AliHLTTPCDefinitions::fgkDDLPackedRawDataType && GetEventCount()<2){
260 HLTWarning("data type %s is depricated, use %s (kAliHLTDataTypeDDLRaw)!",
261 DataType2Text(AliHLTTPCDefinitions::fgkDDLPackedRawDataType).c_str(),
262 DataType2Text(kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTPC).c_str());
265 if (iter->fDataType != (kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTPC)) continue;
267 UInt_t slice = AliHLTTPCDefinitions::GetMinSliceNr(*iter);
268 UInt_t partition = AliHLTTPCDefinitions::GetMinPatchNr(*iter);
270 fSpecification = iter->fSpecification;
272 AliHLTTPCDigitReader *pDigitReader = new AliHLTTPCDigitReaderDecoder;
274 pDigitReader->InitBlock(iter->fPtr,iter->fSize,partition,slice);
275 if(!pDigitReader) break;
277 //sprintf(name,"hMaxSignal_slice%d_partition%d", slice, partition);
278 //fHistPartition = new TH2F(name,name,250,-250,250,250,-250,250);
280 while( pDigitReader->Next() ){
281 //while( pDigitReader->NextChannel()) { // pad loop
283 fCurrentRow = pDigitReader->GetRow();
284 fCurrentRow += pDigitReader->GetRowOffset();
286 AliHLTTPCTransform::Slice2Sector(slice,fCurrentRow,thissector,thisrow);
287 //AliHLTTPCTransform::Raw2Global(xyz,thissector,thisrow,pDigitReader->GetPad(),0);
289 // AliTPCCalROC *calRoc = noisePad->GetCalROC(thissector);
290 // calRoc->GetValue(thisrow,pDigitReader->GetPad());
292 Float_t maxSignal = 0.;
293 //while( pDigitReader->NextBunch()) {
295 const UInt_t *bunchData = pDigitReader->GetSignals();
296 for(Int_t i=0;i<pDigitReader->GetBunchSize();i++) {
298 if((Float_t)(bunchData[i])>maxSignal){
299 maxSignal = (Float_t)(bunchData[i]);
302 // if((Float_t)(bunchData[i])>maxSignal){
303 // if(fApplyNoiseMap) { //still in local coordinates
305 // if(calRoc->GetValue(thisrow,pDigitReader->GetPad())>0.) maxSignal = 0.;
306 // else maxSignal = bunchData[i];
308 // } else maxSignal = bunchData[i];
311 //} // end of inner while loop
313 AliHLTTPCTransform::Raw2Global(xyz,thissector,thisrow,pDigitReader->GetPad(),0);
314 // transformation from pad-row coordinates to global ones
315 // time info is not taken into account
317 fHistPartition->Fill(xyz[0],xyz[1],maxSignal);
319 if(fPlotSideA || fPlotSideC){
320 if(slice<18) fHistSideA->Fill(xyz[0],xyz[1],maxSignal);
321 else fHistSideC->Fill(xyz[0],xyz[1],maxSignal);
322 } // end if plotting sides
323 } // end of while loop
325 } // end of for loop over data blocks
327 if(fResetHistograms) ResetHistograms();
333 void AliHLTTPCNoiseMapComponent::MakeHistosPublic() {
334 // see header file for class documentation
336 // TFile *outputfile = new TFile("test.root","RECREATE");
337 // fHistSideC->Write();
338 // fHistPartition->Write();
339 // fHistCDBMap->Write();
340 // outputfile->Save();
341 // outputfile->Close();
344 histos.Add(fHistPartition);
345 if(fPlotSideA) histos.Add(fHistSideA);
346 if(fPlotSideC) histos.Add(fHistSideC);
347 //histos.Add(fHistCDBMap);
349 TIter iterator(&histos);
350 while(TObject *pObj=iterator.Next()){
352 PushBack(pObj, kAliHLTDataTypeHistogram|kAliHLTDataOriginTPC, fSpecification);
355 //PushBack( (TObject*) &histos, kAliHLTDataTypeHistogram, fSpecification);
357 delete fHistPartition;
358 if(fHistSideA) delete fHistSideA; fHistSideA=NULL;
359 if(fHistSideC) delete fHistSideC; fHistSideC=NULL;
362 void AliHLTTPCNoiseMapComponent::ResetHistograms(){
363 // see header file for class documentation
365 fHistPartition->Reset();
366 if(fHistSideA) fHistSideA->Reset();
367 if(fHistSideC) fHistSideC->Reset();
370 int AliHLTTPCNoiseMapComponent::Configure(const char* arguments) {
371 // see header file for class documentation
374 if (!arguments) return iResult;
375 HLTInfo("parsing configuration string \'%s\'", arguments);
377 TString allArgs=arguments;
381 TObjArray* pTokens=allArgs.Tokenize(" ");
383 for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) {
384 argument=((TObjString*)pTokens->At(i))->GetString();
385 if (argument.IsNull()) continue;
387 if (argument.CompareTo("-apply-noisemap")==0) {
388 if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
389 HLTInfo("got \'-apply-noisemap\': %s", ((TObjString*)pTokens->At(i))->GetString().Data());
392 else if (argument.CompareTo("-plot-side-c")==0) {
393 if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
394 HLTInfo("got \'-plot-side-c\': %s", ((TObjString*)pTokens->At(i))->GetString().Data());
397 else if (argument.CompareTo("-plot-side-a")==0) {
398 if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
399 HLTInfo("got \'-plot-side-a\': %s", ((TObjString*)pTokens->At(i))->GetString().Data());
403 HLTError("unknown argument %s", argument.Data());
414 HLTError("missing parameter for argument %s", argument.Data());
420 int AliHLTTPCNoiseMapComponent::Reconfigure(const char* cdbEntry, const char* chainId) {
421 // see header file for class documentation
423 const char* path="HLT/ConfigTPC/TPCNoiseMapComponent";
424 const char* defaultNotify="";
427 defaultNotify=" (default)";
431 HLTInfo("reconfigure from entry %s%s, chain id %s", path, defaultNotify,(chainId!=NULL && chainId[0]!=0)?chainId:"<none>");
432 AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/);
434 TObjString* pString=dynamic_cast<TObjString*>(pEntry->GetObject());
436 HLTInfo("received configuration object string: \'%s\'", pString->GetString().Data());
437 iResult=Configure(pString->GetString().Data());
439 HLTError("configuration object \"%s\" has wrong type, required TObjString", path);
442 HLTError("cannot fetch object \"%s\" from CDB", path);
446 const char* pathNoiseMap="TPC/Config/NoiseMap";
449 HLTInfo("reconfigure noise map from entry %s, chain id %s", path,(chainId!=NULL && chainId[0]!=0)?chainId:"<none>");
450 AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(pathNoiseMap/*,GetRunNo()*/);
452 TObjString* pString=dynamic_cast<TObjString*>(pEntry->GetObject());
454 HLTInfo("received configuration object string: \'%s\'", pString->GetString().Data());
455 iResult=Configure(pString->GetString().Data());
457 HLTError("configuration object \"%s\" has wrong type, required TObjString", path);
460 HLTError("cannot fetch object \"%s\" from CDB", path);