From e419c1ae1433662dd9f378942c91168d45587d42 Mon Sep 17 00:00:00 2001 From: sgorbuno Date: Mon, 7 Dec 2009 03:15:43 +0000 Subject: [PATCH] GlobalHistoCollector component added. It merges histograms with the same name which were produced by different components. The collector is needed when a histo component runs with the multiplicity > 1 --- HLT/global/AliHLTGlobalAgent.cxx | 2 + HLT/global/AliHLTGlobalHistoCollector.cxx | 298 ++++++++++++++++++ HLT/global/AliHLTGlobalHistoCollector.h | 123 ++++++++ .../AliHLTGlobalVertexerHistoComponent.cxx | 32 +- .../AliHLTGlobalVertexerHistoComponent.h | 2 + HLT/global/physics/AliHLTV0HistoComponent.cxx | 26 +- HLT/global/physics/AliHLTV0HistoComponent.h | 4 +- HLT/libAliHLTGlobal.pkg | 1 + 8 files changed, 468 insertions(+), 20 deletions(-) create mode 100644 HLT/global/AliHLTGlobalHistoCollector.cxx create mode 100644 HLT/global/AliHLTGlobalHistoCollector.h diff --git a/HLT/global/AliHLTGlobalAgent.cxx b/HLT/global/AliHLTGlobalAgent.cxx index 4fd51249818..c83a0866be0 100644 --- a/HLT/global/AliHLTGlobalAgent.cxx +++ b/HLT/global/AliHLTGlobalAgent.cxx @@ -34,6 +34,7 @@ #include "AliHLTGlobalVertexerComponent.h" #include "AliHLTV0HistoComponent.h" #include "AliHLTGlobalVertexerHistoComponent.h" +#include "AliHLTGlobalHistoCollector.h" /** global instance for agent registration */ AliHLTGlobalAgent gAliHLTGlobalAgent; @@ -67,6 +68,7 @@ int AliHLTGlobalAgent::RegisterComponents(AliHLTComponentHandler* pHandler) cons pHandler->AddComponent(new AliHLTGlobalVertexerComponent); pHandler->AddComponent(new AliHLTGlobalVertexerHistoComponent); pHandler->AddComponent(new AliHLTV0HistoComponent ); + pHandler->AddComponent(new AliHLTGlobalHistoCollector ); return 0; } diff --git a/HLT/global/AliHLTGlobalHistoCollector.cxx b/HLT/global/AliHLTGlobalHistoCollector.cxx new file mode 100644 index 00000000000..c1909994b2e --- /dev/null +++ b/HLT/global/AliHLTGlobalHistoCollector.cxx @@ -0,0 +1,298 @@ + +//************************************************************************** +//* This file is property of and copyright by the ALICE HLT Project * +//* ALICE Experiment at CERN, All rights reserved. * +//* * +//* Primary Authors: Kalliopi Kanaki * +//* for The ALICE HLT Project. * +//* * +//* Permission to use, copy, modify and distribute this software and its * +//* documentation strictly for non-commercial purposes is hereby granted * +//* without fee, provided that the above copyright notice appears in all * +//* copies and that both the copyright notice and this permission notice * +//* appear in the supporting documentation. The authors make no claims * +//* about the suitability of this software for any purpose. It is * +//* provided "as is" without express or implied warranty. * +//************************************************************************** + +/** @file AliHLTGlobalHistoCollector.cxx + @author Kalliopi Kanaki + @date + @brief The Histogram Handler component +*/ + +#if __GNUC__>= 3 +using namespace std; +#endif +#include "AliHLTGlobalHistoCollector.h" +#include "AliCDBEntry.h" +#include "AliCDBManager.h" +#include "TString.h" +#include "TObjArray.h" +#include "TObjString.h" +#include "TH1.h" +#include "TTimeStamp.h" +#include "TSystem.h" + +ClassImp(AliHLTGlobalHistoCollector) //ROOT macro for the implementation of ROOT specific class methods + + AliHLTGlobalHistoCollector::AliHLTGlobalHistoCollector() + : + fUID(0), + fStore() +{ + // see header file for class documentation + // or + // refer to README to build package + // or + // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt +} + +AliHLTGlobalHistoCollector::~AliHLTGlobalHistoCollector() { + // see header file for class documentation + Clear(); +} + + + +// Public functions to implement AliHLTComponent's interface. +// These functions are required for the registration process + +const char* AliHLTGlobalHistoCollector::GetComponentID() +{ + // see header file for class documentation + return "GlobalHistoCollector"; +} + +void AliHLTGlobalHistoCollector::GetInputDataTypes( vector& list) +{ + // see header file for class documentation + + list.clear(); + list.push_back( kAliHLTDataTypeHistogram ); +} + +AliHLTComponentDataType AliHLTGlobalHistoCollector::GetOutputDataType() +{ + // see header file for class documentation + return kAliHLTDataTypeHistogram; +} + + +void AliHLTGlobalHistoCollector::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) +{ + // see header file for class documentation + constBase=0; + inputMultiplier=1.0; +} + +AliHLTComponent* AliHLTGlobalHistoCollector::Spawn() +{ + // see header file for class documentation + return new AliHLTGlobalHistoCollector(); +} + +int AliHLTGlobalHistoCollector::DoInit( int argc, const char** argv ) +{ + // see header file for class documentation + + Clear(); + + int iResult=0; + + TString configuration=""; + TString argument=""; + for (int j=0; j=0; j++) { + + argument=argv[j]; + if (!configuration.IsNull()) configuration+=" "; + configuration+=argument; + } + + if (!configuration.IsNull()) { + iResult=Configure(configuration.Data()); + } else { + iResult=Reconfigure(NULL, NULL); + } + fUID = 0; + return iResult; +} + + +int AliHLTGlobalHistoCollector::DoDeinit() +{ + // see header file for class documentation + + Clear(); + fUID = 0; + return 0; +} + +int AliHLTGlobalHistoCollector::Configure(const char* arguments) +{ + // see header file for class documentation + + int iResult=0; + if (!arguments) return iResult; + HLTInfo("parsing configuration string \'%s\'", arguments); + + TString allArgs=arguments; + TString argument; + int bMissingParam=0; + + TObjArray* pTokens=allArgs.Tokenize(" "); + if (pTokens) { + for (int i=0; iGetEntries() && iResult>=0; i++) { + argument=((TObjString*)pTokens->At(i))->GetString(); + if (argument.IsNull()) continue; + + //if (argument.CompareTo("-sum-noise-histograms")==0) { + //fNoiseHistograms = kTRUE; + //HLTInfo("got \'-sum-noise-histograms\': %s", ((TObjString*)pTokens->At(i))->GetString().Data()); + //else + { + HLTError("unknown argument %s", argument.Data()); + iResult=-EINVAL; + break; + } + } // end for + + delete pTokens; + + } // end if pTokens + + if (bMissingParam) { + HLTError("missing parameter for argument %s", argument.Data()); + iResult=-EINVAL; + } + return iResult; +} + + +int AliHLTGlobalHistoCollector::Reconfigure(const char* cdbEntry, const char* chainId) { + // see header file for class documentation + + return 0; // no CDB entry exist + + int iResult=0; + const char* path="HLT/ConfigGlobal/GlobalHistoCollector"; + const char* defaultNotify=""; + if (cdbEntry) { + 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()*/); + if (pEntry) { + TObjString* pString=dynamic_cast(pEntry->GetObject()); + if (pString) { + HLTInfo("received configuration object string: \'%s\'", pString->GetString().Data()); + iResult=Configure(pString->GetString().Data()); + } else { + HLTError("configuration object \"%s\" has wrong type, required TObjString", path); + } + } else { + HLTError("cannot fetch object \"%s\" from CDB", path); + } + } + return iResult; +} + + +void AliHLTGlobalHistoCollector::Clear() +{ + // reset the store + + for( unsigned int i=0; iGetPid() + t.GetNanoSec())*10 + evtData.fEventID; + } + + + const TObject *iter = NULL; + for(iter = GetFirstInputObject(kAliHLTDataTypeHistogram); iter != NULL; iter = GetNextInputObject()){ + + if( !( GetDataType(iter) == kAliHLTDataTypeHistogram )) continue; + + const TH1 *h = dynamic_cast(const_cast( iter ) ); + if( !h ) continue; + //cout<<"received histo "<GetName()<<" with id="<GetName()).CompareTo(h->GetName())==0){ + iBase = i; + break; + } + } + + if( iBase<0 ){ + AliHLTHistoBaseData b; + b.fDataType = GetDataType(iter); + b.fMergedHisto = (TH1*) iter->Clone(); + fStore.push_back(b); + iBase = fStore.size()-1; + } + + // search for the specific entry, if not exist then create a new one + + AliHLTHistoBaseData &b = fStore[iBase]; + + int iSpec=-1; + for( unsigned int i=0; iClone(); + b.fHistos.push_back(d); + iSpec = b.fHistos.size()-1; + } + b.fHistos[iSpec].fHisto->Reset(); + b.fHistos[iSpec].fHisto->Add( (TH1*)iter, 1); + //cout<<"index = "< + +class TH1; +class TH2; + +/** + * @class AliHLTGlobalHistoCollector + * Implementation of the component to read histograms from other + * components and add, divide etc. + * The component implements the interface methods of the @ref AliHLTProcessor. + * + * The component has the following component arguments: + * + * -sum-noise-histograms Loops over the output of TPCNoiseMap and sums the partition histograms + * They are sorted per TPC side. + * + * -sum-krypton-histograms Loops over the output of the krypton CF and sums the histograms + * (it will become obsolete, when the next option does all the work) + * + * -use-general It will become the standard general option for summing histograms + * + * -ignore-specification It ignores the last part of the histogram name, if it has + * the form "_Slice_%.2d%.2d_Partition_%.2d%.2d, minSlice, maxSlice, minPartition, maxPartition". + * It keeps the first part of the hist name and uses it to name the summed histogram. + * + * @ingroup alihlt_tpc + */ +class AliHLTGlobalHistoCollector : public AliHLTProcessor { + +public: + struct AliHLTHistoData + { + TH1 *fHisto; + AliHLTUInt32_t fSpecification; + }; + + struct AliHLTHistoBaseData + { + AliHLTHistoBaseData():fMergedHisto(0),fDataType(kAliHLTVoidDataType),fHistos(){} + AliHLTHistoBaseData( const AliHLTHistoBaseData &x):fMergedHisto(x.fMergedHisto),fDataType(x.fDataType),fHistos(x.fHistos){} + AliHLTHistoBaseData &operator=( const AliHLTHistoBaseData &x){ fMergedHisto= x.fMergedHisto; fDataType=x.fDataType; fHistos = x.fHistos; return *this; } + TH1 *fMergedHisto; + AliHLTComponentDataType fDataType; + std::vector fHistos; + }; + //typedef struct AliHLTHistoData AliHLTHistoData; //! + //typedef struct AliHLTHistoBaseData AliHLTHistoBaseData; //! + + /** standard constructor */ + AliHLTGlobalHistoCollector(); + /** destructor */ + virtual ~AliHLTGlobalHistoCollector(); + + // Public functions to implement AliHLTComponent's interface. + // These functions are required for the registration process + + /** interface function, see AliHLTComponent for description */ + const char* GetComponentID(); + /** interface function, see AliHLTComponent for description */ + void GetInputDataTypes( vector& list); + /** interface function, see AliHLTComponent for description */ + AliHLTComponentDataType GetOutputDataType(); + /** interface function, see AliHLTComponent for description */ + virtual void GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ); + /** interface function, see AliHLTComponent for description */ + AliHLTComponent* Spawn(); + +protected: + + // Protected functions to implement AliHLTComponent's interface. + // These functions provide initialization as well as the actual processing capabilities of the component. + + int DoInit( int argc, const char** argv ); + int DoDeinit(); + int DoEvent( const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData ); + int Reconfigure(const char* cdbEntry, const char* chainId); + + using AliHLTProcessor::DoEvent; + +private: + + int Configure(const char* arguments); + + /** copy constructor prohibited */ + AliHLTGlobalHistoCollector(const AliHLTGlobalHistoCollector&); + + /** assignment operator prohibited */ + AliHLTGlobalHistoCollector& operator=(const AliHLTGlobalHistoCollector&); + + void Clear(); // reset the store + + AliHLTUInt32_t fUID;// uID of the component + + std::vector fStore; + + ClassDef(AliHLTGlobalHistoCollector, 0) +}; + +#endif diff --git a/HLT/global/AliHLTGlobalVertexerHistoComponent.cxx b/HLT/global/AliHLTGlobalVertexerHistoComponent.cxx index 59dd5a02ea9..d0bab7105b1 100644 --- a/HLT/global/AliHLTGlobalVertexerHistoComponent.cxx +++ b/HLT/global/AliHLTGlobalVertexerHistoComponent.cxx @@ -21,6 +21,8 @@ #include "AliESDVertex.h" #include "AliESDEvent.h" +#include "TTimeStamp.h" +#include "TSystem.h" #include "AliHLTGlobalVertexerHistoComponent.h" @@ -28,6 +30,7 @@ ClassImp(AliHLTGlobalVertexerHistoComponent) AliHLTGlobalVertexerHistoComponent::AliHLTGlobalVertexerHistoComponent() : + fUID(0), fRefreshPeriod(1000), fFillSecond(0), fFillSecondSPD(0) @@ -74,7 +77,7 @@ AliHLTGlobalVertexerHistoComponent::AliHLTGlobalVertexerHistoComponent() fSPDVertexXY[i].SetMarkerSize(0.4); fSPDVertexXY[i].SetYTitle("Y [cm]"); fSPDVertexXY[i].SetXTitle("X [cm]"); - fSPDVertexXY[i].SetStats(0); + //fSPDVertexXY[i].SetStats(0); //fSPDVertexXY[i].SetBit(TH1::kCanRebin); fSPDVertexX[i].SetName("spdVertexX"); @@ -234,17 +237,18 @@ int AliHLTGlobalVertexerHistoComponent::DoInit(int argc, const char** argv) } fFillSecond = 0; fFillSecondSPD = 0; - + fUID = 0; return ret; } int AliHLTGlobalVertexerHistoComponent::DoDeinit() { //Nothing to delete or "do de init" yet. + fUID = 0; return 0; } -int AliHLTGlobalVertexerHistoComponent::DoEvent(const AliHLTComponentEventData& /*evtData*/, +int AliHLTGlobalVertexerHistoComponent::DoEvent(const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* /*blocks*/, AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* /*outputPtr*/, @@ -255,6 +259,12 @@ int AliHLTGlobalVertexerHistoComponent::DoEvent(const AliHLTComponentEventData& if (GetFirstInputBlock(kAliHLTDataTypeSOR) || GetFirstInputBlock(kAliHLTDataTypeEOR)) return 0; + if( fUID == 0 ){ + TTimeStamp t; + fUID = ( gSystem->GetPid() + t.GetNanoSec())*10 + evtData.fEventID; + //cout<<"\nSet id to "< size) { Logging(kHLTLogFatal, "HLT::AliHLTGlobalVertexerHistoComponent::DoEvent", "Too much data", "Data written over allowed buffer. Amount written: %lu, allowed amount: %lu.", @@ -336,20 +346,20 @@ int AliHLTGlobalVertexerHistoComponent::DoEvent(const AliHLTComponentEventData& int i = ( fPrimaryXY[1].GetEntries() > fPrimaryXY[0].GetEntries() ); - PushBack(&fPrimaryXY[i], kAliHLTDataTypeHistogram | kAliHLTDataOriginOut, 0); - PushBack(&fPrimaryZ[i], kAliHLTDataTypeHistogram | kAliHLTDataOriginOut, 0); - PushBack(&fPrimaryX[i], kAliHLTDataTypeHistogram | kAliHLTDataOriginOut, 0); - PushBack(&fPrimaryY[i], kAliHLTDataTypeHistogram | kAliHLTDataOriginOut, 0); + PushBack(&fPrimaryXY[i], kAliHLTDataTypeHistogram | kAliHLTDataOriginOut, fUID); + PushBack(&fPrimaryZ[i], kAliHLTDataTypeHistogram | kAliHLTDataOriginOut, fUID); + PushBack(&fPrimaryX[i], kAliHLTDataTypeHistogram | kAliHLTDataOriginOut, fUID); + PushBack(&fPrimaryY[i], kAliHLTDataTypeHistogram | kAliHLTDataOriginOut, fUID); i = ( fSPDVertexXY[1].GetEntries() > fSPDVertexXY[0].GetEntries() ); //cout<<"bla NEntr = "< @@ -48,6 +49,7 @@ ClassImp(AliHLTV0HistoComponent) AliHLTV0HistoComponent::AliHLTV0HistoComponent() : + fUID(0), fGamma(0), fKShort(0), fLambda(0), @@ -113,7 +115,9 @@ AliHLTComponent* AliHLTV0HistoComponent::Spawn() int AliHLTV0HistoComponent::DoInit( int argc, const char** argv ) { // init - + + fUID = 0; + fGamma = new TH1F("hGamma","HLT: #gamma inv mass",50,-.06,.2); fGamma->SetFillColor(kGreen); fGamma->SetStats(0); @@ -220,15 +224,21 @@ int AliHLTV0HistoComponent::DoDeinit() delete fLambda; delete fAP; delete fGammaXY; + fUID = 0; return 0; } -int AliHLTV0HistoComponent::DoEvent(const AliHLTComponentEventData& /*evtData*/, AliHLTComponentTriggerData& /*trigData*/) +int AliHLTV0HistoComponent::DoEvent(const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& /*trigData*/) { if ( GetFirstInputBlock( kAliHLTDataTypeSOR ) || GetFirstInputBlock( kAliHLTDataTypeEOR ) ) return 0; + if( fUID == 0 ){ + TTimeStamp t; + fUID = ( gSystem->GetPid() + t.GetNanoSec())*10 + evtData.fEventID; + } + fNEvents++; for ( const TObject *iter = GetFirstInputObject(kAliHLTDataTypeESDObject); iter != NULL; iter = GetNextInputObject() ) { @@ -417,17 +427,17 @@ int AliHLTV0HistoComponent::DoEvent(const AliHLTComponentEventData& /*evtData*/, } - if( fGamma ) PushBack( (TObject*) fGamma, kAliHLTDataTypeHistogram,0); + if( fGamma ) PushBack( (TObject*) fGamma, kAliHLTDataTypeHistogram,fUID); - if( fKShort ) PushBack( (TObject*) fKShort, kAliHLTDataTypeHistogram,0); + if( fKShort ) PushBack( (TObject*) fKShort, kAliHLTDataTypeHistogram,fUID); - if( fLambda ) PushBack( (TObject*) fLambda, kAliHLTDataTypeHistogram, 0); + if( fLambda ) PushBack( (TObject*) fLambda, kAliHLTDataTypeHistogram, fUID); - if( fPi0 ) PushBack( (TObject*) fPi0, kAliHLTDataTypeHistogram, 0); + if( fPi0 ) PushBack( (TObject*) fPi0, kAliHLTDataTypeHistogram, fUID); - if( fAP ) PushBack( (TObject*) fAP, kAliHLTDataTypeHistogram,0); + if( fAP ) PushBack( (TObject*) fAP, kAliHLTDataTypeHistogram, fUID); - if( fGammaXY ) PushBack( (TObject*) fGammaXY, kAliHLTDataTypeHistogram,0); + if( fGammaXY ) PushBack( (TObject*) fGammaXY, kAliHLTDataTypeHistogram, fUID); } if( fNPi0s>0 ){ HLTInfo("Found %d Gammas, %d KShorts, %d Lambdas and %d Pi0's in %d events", fNGammas, fNKShorts, fNLambdas, fNPi0s, fNEvents ); diff --git a/HLT/global/physics/AliHLTV0HistoComponent.h b/HLT/global/physics/AliHLTV0HistoComponent.h index a896d460cfb..a5fac5599b9 100644 --- a/HLT/global/physics/AliHLTV0HistoComponent.h +++ b/HLT/global/physics/AliHLTV0HistoComponent.h @@ -78,6 +78,8 @@ private: // [6] == 3.5 --- (v0 mass - true value)/sigma <= cut (for identification) // [7] == 0.05 --- (v0 mass - true value) <= cut (for identification) + AliHLTUInt32_t fUID;// uID of the component + Double_t fGammaCuts[8]; // cuts for gammas Double_t fKsCuts[8]; // cuts for Ks Double_t fLambdaCuts[8]; // cuts for Lambdas @@ -94,7 +96,7 @@ private: Int_t fNKShorts; // n found total Int_t fNLambdas; // n found total Int_t fNPi0s; // n found total - + ClassDef(AliHLTV0HistoComponent, 0); }; diff --git a/HLT/libAliHLTGlobal.pkg b/HLT/libAliHLTGlobal.pkg index 95210d181d4..c6326f2a73f 100644 --- a/HLT/libAliHLTGlobal.pkg +++ b/HLT/libAliHLTGlobal.pkg @@ -8,6 +8,7 @@ CLASS_HDRS:= AliHLTGlobalEsdConverterComponent.h \ AliHLTGlobalVertexerComponent.h \ AliHLTGlobalTrackMatcher.h \ AliHLTGlobalVertexerHistoComponent.h \ + AliHLTGlobalHistoCollector.h \ physics/AliHLTV0HistoComponent.h # physics/AliHLTPHOSHistoProdInvMass.h \ # physics/AliHLTPHOSHistoProdMatchedTracks.h \ -- 2.43.0