From deeb9f12e27920393ae3b0da62cebf5f8e4cd983 Mon Sep 17 00:00:00 2001 From: richterm Date: Wed, 2 Apr 2008 12:05:28 +0000 Subject: [PATCH] TPCNoiseMapComponent included into build (Kelly) --- HLT/TPCLib/AliHLTTPCNoiseMapComponent.cxx | 293 +++++++++++++--------- HLT/TPCLib/AliHLTTPCNoiseMapComponent.h | 46 ++-- HLT/libAliHLTTPC.pkg | 1 + 3 files changed, 199 insertions(+), 141 deletions(-) diff --git a/HLT/TPCLib/AliHLTTPCNoiseMapComponent.cxx b/HLT/TPCLib/AliHLTTPCNoiseMapComponent.cxx index 49024db9e3d..fa04e911a2f 100644 --- a/HLT/TPCLib/AliHLTTPCNoiseMapComponent.cxx +++ b/HLT/TPCLib/AliHLTTPCNoiseMapComponent.cxx @@ -32,6 +32,7 @@ using namespace std; #include "AliHLTTPCDefinitions.h" #include "AliCDBEntry.h" #include "AliCDBManager.h" +#include "AliTPCCalPad.h" #include #include #include "TString.h" @@ -48,11 +49,20 @@ ClassImp(AliHLTTPCNoiseMapComponent) //ROOT macro for the implementation of ROOT AliHLTTPCNoiseMapComponent::AliHLTTPCNoiseMapComponent() : - fNoiseMap(0), - fIsPacked(1), + fSpecification(0), + //pDigitReader(0), + fPlotSideA(0), + fPlotSideC(0), + fApplyNoiseMap(0), + fIsPacked(0), fIsUnpacked(0), + fSlice(-99), fCurrentPartition(0), - fCurrentRow(0) + fCurrentRow(0), + fHistSideA(NULL), + fHistSideC(NULL), + fHistCDBMap(NULL) + //fHistSlice(NULL) { // see header file for class documentation // or @@ -85,14 +95,14 @@ void AliHLTTPCNoiseMapComponent::GetInputDataTypes( vectorSetXTitle("global X (cm)"); fHistSideA->SetYTitle("global Y (cm)"); - //} if ( *cpErr ) { - HLTError("Cannot convert noisemap specifier '%s'.", argv[i+1]); + HLTError("Cannot convert plot-side-a specifier '%s'.", argv[i+1]); return EINVAL; } i+=2; continue; } + + if (!strcmp( argv[i], "-plot-side-c")) { + fPlotSideC = strtoul( argv[i+1], &cpErr ,0); + fHistSideC = new TH2F("fHistSideC","TPC Side C",250,-250,250,250,-250,250); + fHistSideC->SetXTitle("global X (cm)"); fHistSideC->SetYTitle("global Y (cm)"); + + //fSliceA[18], fSliceC[18] + + if ( *cpErr ) { + HLTError("Cannot convert plot-side-c specifier '%s'.", argv[i+1]); + return EINVAL; + } + i+=2; + continue; + } + +// if (!strcmp( argv[i], "-slice")) { +// fSlice = strtoul( argv[i+1], &cpErr ,0); +// +// if ( *cpErr ) { +// HLTError("Cannot convert slice specifier '%s'. Must be integer", argv[i+1]); +// return EINVAL; +// } +// i+=2; +// continue; +// } + Logging(kHLTLogError, "HLT::TPCNoiseMap::DoInit", "Unknown Option", "Unknown option '%s'", argv[i] ); return EINVAL; - } + } // end while //HLTDebug("using AliHLTTPCDigitReaderDecoder"); //pDigitReader = new AliHLTTPCDigitReaderDecoder(); // double-loop @@ -187,125 +228,124 @@ int AliHLTTPCNoiseMapComponent::DoDeinit() { return 0; } -int AliHLTTPCNoiseMapComponent::DoEvent( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks, - AliHLTComponentTriggerData&, AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size, - vector& outputBlocks ) { +// int AliHLTTPCNoiseMapComponent::DoEvent( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks, +// AliHLTComponentTriggerData&, AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size, +// vector& outputBlocks ) { + + +int AliHLTTPCNoiseMapComponent::DoEvent(const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData){ // see header file for class documentation - if(fNoiseMap) { HLTInfo("--- Entering DoEvent() in TPCNoiseMap ---"); - - // == init iter (pointer to datablock) + + if(GetFirstInputBlock( kAliHLTDataTypeSOR ) || GetFirstInputBlock( kAliHLTDataTypeEOR )) return 0; + const AliHLTComponentBlockData* iter = NULL; - unsigned long ndx; + //unsigned long ndx; Float_t xyz[3]; Int_t thissector, thisrow; + // reading an existing noise map file + if(fApplyNoiseMap){ + TFile *f = TFile::Open("Run3398_4000_v0_s72.root"); + AliCDBEntry *entry = (AliCDBEntry*)f->Get("AliCDBEntry"); + AliTPCCalPad *noisePad = (AliTPCCalPad*)entry->GetObject(); + fHistCDBMap = noisePad->MakeHisto2D(1); //side C + } - for ( ndx=0; ndxfDataType).c_str(), DataType2Text(kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTPC).c_str()); - - if (iter->fDataType == AliHLTTPCDefinitions::fgkDDLPackedRawDataType && GetEventCount()<2) { - HLTWarning("data type %s is depricated, use %s (kAliHLTDataTypeDDLRaw)!", DataType2Text(AliHLTTPCDefinitions::fgkDDLPackedRawDataType).c_str(), - DataType2Text(kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTPC).c_str()); - } //endif - - if (iter->fDataType != (kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTPC)) continue; + for (iter = GetFirstInputBlock(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginTPC); iter != NULL; iter = GetNextInputBlock()){ + //for ( ndx=0; ndx fMaxPartition ) fMaxPartition = partition; // add a warning - - //fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification( slice, slice, partition, partition ); - fSpecification = iter->fSpecification; - - AliHLTTPCDigitReader *pDigitReader = new AliHLTTPCDigitReaderDecoder; - pDigitReader->InitBlock(iter->fPtr,iter->fSize,partition,slice); - if(!pDigitReader) break; //AliHLTComponent.cxx, altrochannelselector rcu folder - - rowOffset = 0; + HLTInfo("Event 0x%08LX (%Lu) received datatype: %s - required datatype: %s", + evtData.fEventID, evtData.fEventID, + DataType2Text(iter->fDataType).c_str(), + DataType2Text(kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTPC).c_str()); + + if (iter->fDataType == AliHLTTPCDefinitions::fgkDDLPackedRawDataType && GetEventCount()<2){ + HLTWarning("data type %s is depricated, use %s (kAliHLTDataTypeDDLRaw)!", + DataType2Text(AliHLTTPCDefinitions::fgkDDLPackedRawDataType).c_str(), + DataType2Text(kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTPC).c_str()); + } + + if (iter->fDataType != (kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTPC)) continue; - switch(partition){ - case 0: - rowOffset=AliHLTTPCTransform::GetFirstRow(0); - break; - case 1: - rowOffset=AliHLTTPCTransform::GetFirstRow(1); - break; - case 2: - rowOffset=AliHLTTPCTransform::GetFirstRow(2); - break; - case 3: - rowOffset=AliHLTTPCTransform::GetFirstRow(3); - break; - case 4: - rowOffset=AliHLTTPCTransform::GetFirstRow(4); - break; - case 5: - rowOffset=AliHLTTPCTransform::GetFirstRow(5); - break; - } - + UInt_t slice = AliHLTTPCDefinitions::GetMinSliceNr(*iter); + UInt_t partition = AliHLTTPCDefinitions::GetMinPatchNr(*iter); + + //if ( partition < fMinPartition ) fMinPartition = partition; + //if ( partition > fMaxPartition ) fMaxPartition = partition; // add a warning + + //fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification( slice, slice, partition, partition ); + fSpecification = iter->fSpecification; + + AliHLTTPCDigitReader *pDigitReader = new AliHLTTPCDigitReaderDecoder; + + pDigitReader->InitBlock(iter->fPtr,iter->fSize,partition,slice); + if(!pDigitReader) break; //AliHLTComponent.cxx, altrochannelselector rcu folder + + while( pDigitReader->Next() ){ + //while( pDigitReader->NextChannel()) { // pad loop - //while( pDigitReader->Next() ){ - while( pDigitReader->NextChannel()) { - - fCurrentRow = pDigitReader->GetRow(); - fCurrentRow += rowOffset; - - if(pDigitReader->GetPad()==1000 || fCurrentRow==1000) continue; + fCurrentRow = pDigitReader->GetRow(); + fCurrentRow += pDigitReader->GetRowOffset(); - AliHLTTPCTransform::Slice2Sector(slice,fCurrentRow,thissector,thisrow); - AliHLTTPCTransform::Raw2Global(xyz,thissector,thisrow,pDigitReader->GetPad(),0); - //AliHLTTPCTransform::Raw2Local(xyz,thissector,thisrow,pDigitReader->GetPad(),0); - - //use AliTPCPad to fill the data there and use the functions to ask for max charge etc. + AliHLTTPCTransform::Slice2Sector(slice,fCurrentRow,thissector,thisrow); + AliHLTTPCTransform::Raw2Global(xyz,thissector,thisrow,pDigitReader->GetPad(),0); + + //use AliTPCPad to fill the data there and use the functions to ask for max charge etc. - Int_t maxSignal = 0; - while( pDigitReader->NextBunch()) { - - //in case we want to fill the histograms with the signal value, an additional loop is necessary - for(Int_t i=0;iGetBunchSize();i++) { - - const UInt_t *bunchData = pDigitReader->GetSignals(); - if(bunchData[i]>maxSignal) maxSignal = bunchData[i]; - //cout<<"Time: "<GetTime()+i<<" Signal: "<GetPad()<<" "<NextBunch()) { + + //in case we want to fill the histograms with the signal value, an additional loop is necessary + for(Int_t i=0;iGetBunchSize();i++) { + + const UInt_t *bunchData = pDigitReader->GetSignals(); + if(bunchData[i]>maxSignal) maxSignal = bunchData[i]; - fHistSideC->Fill(xyz[0],xyz[1],maxSignal); - - } // end of outer while pad loop - } // end of data block loop - - SaveAndResetHistograms(); + //cout<<"Time: "<GetTime()+i<<" Signal: "<GetPad()<<" "<Fill(xyz[0],xyz[1],maxSignal); + else fHistSideC->Fill(xyz[0],xyz[1],maxSignal); + } + + } // end of while loop + } // end of for loop over data blocks - } // end if noisemap==kTRUE - return 0; + MakeHistosPublic(); + return 0; } // end DoEvent() -void AliHLTTPCNoiseMapComponent::SaveAndResetHistograms() { +void AliHLTTPCNoiseMapComponent::MakeHistosPublic() { // see header file for class documentation - TFile *outputfile = new TFile("test.root","RECREATE"); - fHistSideC->Write(); - outputfile->Save(); - outputfile->Close(); +// TFile *outputfile = new TFile("test.root","RECREATE"); +// fHistSideC->Write(); +// fHistCDBMap->Write(); +// fHistSlice[18]->Write(); +// outputfile->Save(); +// outputfile->Close(); + + TObjArray histos; + histos.Add(fHistSideA); + histos.Add(fHistSideC); + PushBack( (TObject*) &histos, kAliHLTDataTypeHistogram, fSpecification); - PushBack( (TObject*) fHistSideC, AliHLTTPCDefinitions::fgkNoiseHistoDataType, fSpecification); + //PushBack( (TObject*) fHistSideC, kAliHLTDataTypeHistogram, fSpecification); + //fill it with the right specification for every histogram //make a TObjArray and add all histos //check which pointers are empty and publish only the ones that hold something - + + //delete histos; + delete fHistSideA; delete fHistSideC; } @@ -326,9 +366,19 @@ int AliHLTTPCNoiseMapComponent::Configure(const char* arguments) { argument=((TObjString*)pTokens->At(i))->GetString(); if (argument.IsNull()) continue; - if (argument.CompareTo("-noisemap")==0) { + if (argument.CompareTo("-apply-noisemap")==0) { if ((bMissingParam=(++i>=pTokens->GetEntries()))) break; - HLTInfo("got \'-noisemap\': %s", ((TObjString*)pTokens->At(i))->GetString().Data()); + HLTInfo("got \'-apply-noisemap\': %s", ((TObjString*)pTokens->At(i))->GetString().Data()); + + } + else if (argument.CompareTo("-plot-side-c")==0) { + if ((bMissingParam=(++i>=pTokens->GetEntries()))) break; + HLTInfo("got \'-plot-side-c\': %s", ((TObjString*)pTokens->At(i))->GetString().Data()); + + } + else if (argument.CompareTo("-plot-side-a")==0) { + if ((bMissingParam=(++i>=pTokens->GetEntries()))) break; + HLTInfo("got \'-plot-side-a\': %s", ((TObjString*)pTokens->At(i))->GetString().Data()); } else { @@ -336,15 +386,17 @@ int AliHLTTPCNoiseMapComponent::Configure(const char* arguments) { iResult=-EINVAL; break; } - } // endfor + } // end for + delete pTokens; - } + + } // end if pTokens + if (bMissingParam) { HLTError("missing parameter for argument %s", argument.Data()); iResult=-EINVAL; } return iResult; - } int AliHLTTPCNoiseMapComponent::Reconfigure(const char* cdbEntry, const char* chainId) { @@ -354,9 +406,10 @@ int AliHLTTPCNoiseMapComponent::Reconfigure(const char* cdbEntry, const char* ch const char* path="HLT/ConfigTPC/TPCNoiseMapComponent"; const char* defaultNotify=""; if (cdbEntry) { - path=cdbEntry; - defaultNotify=" (default)"; + path=cdbEntry; + defaultNotify=" (default)"; } + if (path) { HLTInfo("reconfigure from entry %s%s, chain id %s", path, defaultNotify,(chainId!=NULL && chainId[0]!=0)?chainId:""); AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/); @@ -369,7 +422,7 @@ int AliHLTTPCNoiseMapComponent::Reconfigure(const char* cdbEntry, const char* ch HLTError("configuration object \"%s\" has wrong type, required TObjString", path); } } else { - HLTError("can not fetch object \"%s\" from CDB", path); + HLTError("cannot fetch object \"%s\" from CDB", path); } } diff --git a/HLT/TPCLib/AliHLTTPCNoiseMapComponent.h b/HLT/TPCLib/AliHLTTPCNoiseMapComponent.h index d3b0ba37f9a..936ff66f2ba 100644 --- a/HLT/TPCLib/AliHLTTPCNoiseMapComponent.h +++ b/HLT/TPCLib/AliHLTTPCNoiseMapComponent.h @@ -28,23 +28,20 @@ class TH2; /** * @class AliHLTTPCNoiseMapComponent - * Implementation of the component to fill histograms with TPC noise by request. + * Implementation of the component to fill histograms with TPC noise and read + * the noise map from OCDB by request. * The component implements the interface methods of the @ref AliHLTProcessor. * It reads the data pad by pad and fills histograms. The output is unpacked and * sent to the clulsterfinder. * * The component has the following component arguments: - * - adc-threshold ADC count threshold for zero suppression. + * - apply-noise-map Read the noise map from OCDB and apply it on the online data * - * - rms-threshold RMS threshold for zero suppression. + * -plot-side-a Histograms the TPC side A * - * - first-timebin The first timebin for zero suppression + * -plot-side-c Histograms the TPC side C * - * - last-timebin The last timebin for zero suppression - * - * - occupancy-limit Minimum number of timebins with signal - * - * - sort-pads Flag to switch on pad sorting(needed by the SORTED clusterfinder) + * -apply-noisemap Reads a noise map from a file and subtracts the value contained in every pad from the data * * @ingroup alihlt_tpc */ @@ -57,7 +54,6 @@ class AliHLTTPCNoiseMapComponent : public AliHLTProcessor { /** destructor */ virtual ~AliHLTTPCNoiseMapComponent(); - // Public functions to implement AliHLTComponent's interface. // These functions are required for the registration process @@ -74,7 +70,7 @@ class AliHLTTPCNoiseMapComponent : public AliHLTProcessor { /** interface function, see @ref AliHLTComponent for description */ AliHLTComponent* Spawn(); /** function for acting on the saving and cleaning histograms, after they are filled */ - void SaveAndResetHistograms(); + void MakeHistosPublic(); protected: @@ -83,9 +79,10 @@ class AliHLTTPCNoiseMapComponent : public AliHLTProcessor { int DoInit( int argc, const char** argv ); int DoDeinit(); - int DoEvent( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks, - AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr, - AliHLTUInt32_t& size, vector& outputBlocks ); +// int DoEvent( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks, +// AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr, +// AliHLTUInt32_t& size, vector& outputBlocks ); + int DoEvent( const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData ); int Reconfigure(const char* cdbEntry, const char* chainId); using AliHLTProcessor::DoEvent; @@ -104,18 +101,25 @@ class AliHLTTPCNoiseMapComponent : public AliHLTProcessor { AliHLTUInt32_t fSpecification; //!transient //AliHLTUInt8_t fMinPartition; //!transient //AliHLTUInt8_t fMaxPartition; //!transient + + //AliHLTTPCDigitReader *pDigitReader; - Bool_t fNoiseMap; //!transient - Bool_t fIsPacked; //!transient - Bool_t fIsUnpacked; //!transient + Bool_t fPlotSideA; //!transient + Bool_t fPlotSideC; //!transient + Bool_t fApplyNoiseMap; //!transient + Bool_t fIsPacked; //!transient + Bool_t fIsUnpacked; //!transient + + Int_t fSlice; //!transient Int_t fCurrentPartition; //!transient Int_t fCurrentRow; //!transient - Int_t rowOffset; //!transient - TH2 *fHistSideC; //!transient - - ClassDef(AliHLTTPCNoiseMapComponent, 0) + TH2 *fHistSideA; //!transient + TH2 *fHistSideC; //!transient + TH2 *fHistCDBMap; //!transient + + ClassDef(AliHLTTPCNoiseMapComponent, 1) }; #endif diff --git a/HLT/libAliHLTTPC.pkg b/HLT/libAliHLTTPC.pkg index 7b65615f9e5..2f5fa820893 100644 --- a/HLT/libAliHLTTPC.pkg +++ b/HLT/libAliHLTTPC.pkg @@ -19,6 +19,7 @@ CLASS_HDRS:= AliHLTTPCTransform.h \ AliHLTTPCDigitReaderDecoder.h \ AliHLTTPCDigitDumpComponent.h \ AliHLTTPCZeroSuppressionComponent.h \ + AliHLTTPCNoiseMapComponent.h \ AliHLTTPCVertex.h \ AliHLTTPCVertexArray.h \ AliHLTTPCVertexFinder.h \ -- 2.43.0