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
#include "AliHLTGlobalVertexerComponent.h"
#include "AliHLTV0HistoComponent.h"
#include "AliHLTGlobalVertexerHistoComponent.h"
+#include "AliHLTGlobalHistoCollector.h"
/** global instance for agent registration */
AliHLTGlobalAgent gAliHLTGlobalAgent;
pHandler->AddComponent(new AliHLTGlobalVertexerComponent);
pHandler->AddComponent(new AliHLTGlobalVertexerHistoComponent);
pHandler->AddComponent(new AliHLTV0HistoComponent );
+ pHandler->AddComponent(new AliHLTGlobalHistoCollector );
return 0;
}
--- /dev/null
+
+//**************************************************************************
+//* This file is property of and copyright by the ALICE HLT Project *
+//* ALICE Experiment at CERN, All rights reserved. *
+//* *
+//* Primary Authors: Kalliopi Kanaki <Kalliopi.Kanaki@ift.uib.no> *
+//* 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<AliHLTComponentDataType>& 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<argc && iResult>=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; i<pTokens->GetEntries() && 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:"<none>");
+ AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/);
+ if (pEntry) {
+ TObjString* pString=dynamic_cast<TObjString*>(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; i<fStore.size(); i++ ){
+ for( unsigned int j=0; j<fStore[i].fHistos.size(); j++ ){
+ delete fStore[i].fHistos[j].fHisto;
+ }
+ delete fStore[i].fMergedHisto;
+ }
+ fStore.clear();
+}
+
+
+
+
+int AliHLTGlobalHistoCollector::DoEvent(const AliHLTComponentEventData & evtData, AliHLTComponentTriggerData& /*trigData*/)
+{
+ // see header file for class documentation
+
+ if(GetFirstInputBlock( kAliHLTDataTypeSOR ) || GetFirstInputBlock( kAliHLTDataTypeEOR )) return 0;
+
+ if( fUID == 0 ){
+ TTimeStamp t;
+ fUID = ( gSystem->GetPid() + 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<TH1*>(const_cast<TObject*>( iter ) );
+ if( !h ) continue;
+ //cout<<"received histo "<<h->GetName()<<" with id="<<GetSpecification(iter)<<endl;
+ // search for the base entry, if not exist then create a new entry
+
+ int iBase = -1;
+ for( unsigned int i=0; i<fStore.size(); i++ ){
+ if( fStore[i].fDataType == GetDataType(iter) &&
+ TString(fStore[i].fMergedHisto->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; i<fStore[iBase].fHistos.size(); i++ ){
+ AliHLTHistoData &d = b.fHistos[i];
+ if( d.fSpecification == GetSpecification(iter) ){
+ iSpec = i;
+ break;
+ }
+ }
+
+ if( iSpec<0 ){
+ AliHLTHistoData d;
+ d.fSpecification = GetSpecification(iter);
+ d.fHisto = (TH1*) iter->Clone();
+ 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 = "<<iBase<<","<<iSpec<<", nentr="<<b.fHistos[iSpec].fHisto->GetEntries()<<endl;
+
+ // merge histos
+ b.fMergedHisto->Reset();
+
+ for( unsigned int i=0; i<b.fHistos.size(); i++ ){
+ b.fMergedHisto->Add(b.fHistos[i].fHisto,1);
+ }
+ //cout<<" merged="<<b.fMergedHisto->GetEntries()<<endl;
+
+ } // end for loop over histogram blocks
+
+ for( unsigned int i=0; i<fStore.size(); i++ ){
+ PushBack((TObject*) fStore[i].fMergedHisto, fStore[i].fDataType, fUID );
+ }
+ return 0;
+}
+
--- /dev/null
+// -*- Mode: C++ -*-
+// $Id$
+
+#ifndef ALIHLTGLOBALHISTOCOLLECTOR_H
+#define ALIHLTGLOBALHISTOCOLLECTOR_H
+
+//* This file is property of and copyright by the ALICE HLT Project *
+ //* ALICE Experiment at CERN, All rights reserved. *
+ //* See cxx source for full Copyright notice *
+
+ /** @file AliHLTGlobalHistoCollector.h
+ @author Kalliopi Kanaki, Kenneth Aamodt
+ @date
+ @brief Component for acting upon histograms
+ */
+
+// see below for class documentation
+// or
+// refer to README to build package
+// or
+// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
+
+#include "AliHLTProcessor.h"
+#include "AliHLTDataTypes.h"
+#include <vector>
+
+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<AliHLTHistoData> 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<AliHLTComponentDataType>& 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<AliHLTHistoBaseData> fStore;
+
+ ClassDef(AliHLTGlobalHistoCollector, 0)
+};
+
+#endif
#include "AliESDVertex.h"
#include "AliESDEvent.h"
+#include "TTimeStamp.h"
+#include "TSystem.h"
#include "AliHLTGlobalVertexerHistoComponent.h"
AliHLTGlobalVertexerHistoComponent::AliHLTGlobalVertexerHistoComponent()
:
+ fUID(0),
fRefreshPeriod(1000),
fFillSecond(0),
fFillSecondSPD(0)
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");
}
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*/,
if (GetFirstInputBlock(kAliHLTDataTypeSOR) || GetFirstInputBlock(kAliHLTDataTypeEOR))
return 0;
+ if( fUID == 0 ){
+ TTimeStamp t;
+ fUID = ( gSystem->GetPid() + t.GetNanoSec())*10 + evtData.fEventID;
+ //cout<<"\nSet id to "<<fUID<<endl;
+ }
+
if (GetOutputDataSize() > size) {
Logging(kHLTLogFatal, "HLT::AliHLTGlobalVertexerHistoComponent::DoEvent", "Too much data",
"Data written over allowed buffer. Amount written: %lu, allowed amount: %lu.",
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 = "<<fPrimaryXY[0].GetEntries()<<" / "<<fPrimaryXY[1].GetEntries()<<endl;
//cout<<"bla NEntr SPD = "<<fSPDVertexXY[0].GetEntries()<<" / "<<fSPDVertexXY[1].GetEntries()<<endl;
- PushBack(&fSPDVertexXY[i], kAliHLTDataTypeHistogram | kAliHLTDataOriginITSSPD, 0);
- PushBack(&fSPDVertexZ[i], kAliHLTDataTypeHistogram | kAliHLTDataOriginITSSPD, 0);
- PushBack(&fSPDVertexX[i], kAliHLTDataTypeHistogram | kAliHLTDataOriginITSSPD, 0);
- PushBack(&fSPDVertexY[i], kAliHLTDataTypeHistogram | kAliHLTDataOriginITSSPD, 0);
+ PushBack(&fSPDVertexXY[i], kAliHLTDataTypeHistogram | kAliHLTDataOriginITSSPD, fUID);
+ PushBack(&fSPDVertexZ[i], kAliHLTDataTypeHistogram | kAliHLTDataOriginITSSPD, fUID);
+ PushBack(&fSPDVertexX[i], kAliHLTDataTypeHistogram | kAliHLTDataOriginITSSPD, fUID);
+ PushBack(&fSPDVertexY[i], kAliHLTDataTypeHistogram | kAliHLTDataOriginITSSPD, fUID);
return iResult;
}
void SetDefaultConfiguration();
int ReadConfigurationString( const char* arguments );
+ AliHLTUInt32_t fUID;// uID of the component
+
Int_t fRefreshPeriod;// histos will refresh after fRefreshPeriod number of events
Int_t fFillSecond;//!
Int_t fFillSecondSPD ;//!
#include "AliESDtrack.h"
#include "AliESDv0.h"
#include "AliHLTMessage.h"
+#include "TTimeStamp.h"
//#include "AliHLTTPC.h"
//#include <stdlib.h>
AliHLTV0HistoComponent::AliHLTV0HistoComponent()
:
+ fUID(0),
fGamma(0),
fKShort(0),
fLambda(0),
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);
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() ) {
}
- 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 );
// [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
Int_t fNKShorts; // n found total
Int_t fNLambdas; // n found total
Int_t fNPi0s; // n found total
-
+
ClassDef(AliHLTV0HistoComponent, 0);
};
AliHLTGlobalVertexerComponent.h \
AliHLTGlobalTrackMatcher.h \
AliHLTGlobalVertexerHistoComponent.h \
+ AliHLTGlobalHistoCollector.h \
physics/AliHLTV0HistoComponent.h
# physics/AliHLTPHOSHistoProdInvMass.h \
# physics/AliHLTPHOSHistoProdMatchedTracks.h \