--- /dev/null
+ /**************************************************************************
+ * This file is property of and copyright by the ALICE HLT Project *
+ * All rights reserved. *
+ * *
+ * Primary Authors: Oystein Djuvsland *
+ * *
+ * 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. *
+ **************************************************************************/
+
+#include "AliHLTPHOSMIPCounter.h"
+#include "AliHLTPHOSDigitContainerDataStruct.h"
+#include "TH2I.h"
+
+AliHLTPHOSMIPCounter::AliHLTPHOSMIPCounter()
+ : AliHLTPHOSBase(),
+ fMIPCountEvent ( 0 ),
+ fMIPCountTotal ( 0 ),
+ fMIPRate ( 0 ),
+ fLowerBound ( 0 ),
+ fUpperBound ( 0 ),
+ fUpperStartTime ( 0 ),
+ fLowerStartTime ( 0 ),
+ fZeroThreshold ( 0 ),
+ fChannelHistPtr ( 0 )
+{
+
+}
+
+
+AliHLTPHOSMIPCounter::~AliHLTPHOSMIPCounter()
+{
+}
+
+Int_t
+AliHLTPHOSMIPCounter::CountMIPs(AliHLTPHOSDigitContainerDataStruct* digitContainerPtr)
+{
+ fMIPCountEvent = 0;
+ Bool_t IsMIP = true;
+ Int_t *dataPtr = 0;
+ AliHLTPHOSDigitDataStruct *digitPtr;
+ for(Int_t i = 0; i < digitContainerPtr->fNDigits; i++)
+ {
+ digitPtr = &(digitContainerPtr->fDigitDataStruct[i]);
+ dataPtr = digitPtr->fData;
+ if(digitPtr->fCrazyness != 0)
+ {
+ continue;
+ }
+ if(digitPtr->fAmplitude < fLowerBound || digitPtr->fAmplitude > fUpperBound)
+ {
+ continue;
+ }
+ for(Int_t time = (Int_t)(digitPtr->fTime - 2); time < (digitPtr->fTime - 3); time++)
+ {
+ if((Float_t)dataPtr[time] < (digitPtr->fAmplitude - (digitPtr->fAmplitude)/10))
+ {
+ IsMIP = false;
+ break;
+ }
+ }
+ if(!IsMIP)
+ continue;
+ for(Int_t sample = 0; sample < fLowerStartTime; sample++)
+ {
+ if(dataPtr[sample] > fZeroThreshold || dataPtr[sample] < -fZeroThreshold)
+ {
+ IsMIP = false;
+ break;
+ }
+ }
+ if(dataPtr[(Int_t)fUpperStartTime + 3] < fZeroThreshold)
+ IsMIP = false;
+ if(IsMIP)
+ {
+ fMIPCountEvent++;
+ fChannelHistPtr->Fill(digitPtr->fX, digitPtr->fZ);
+ }
+ }
+ fMIPCountTotal += fMIPCountEvent;
+ return fMIPCountEvent;
+}
--- /dev/null
+
+ /**************************************************************************
+ * This file is property of and copyright by the ALICE HLT Project *
+ * All rights reserved. *
+ * *
+ * Primary Authors: Oystein Djuvsland *
+ * *
+ * 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. *
+ **************************************************************************/
+
+#ifndef ALIHLTPHOSMIPCOUNTER_H
+#define ALIHLTPHOSMIPCOUNTER_H
+
+#include "AliHLTPHOSBase.h"
+
+class AliHLTPHOSDigitContainerDataStruct;
+class TH2I;
+
+/**
+ @author Øystein Djuvsland <oystein.djuvsland@gmail.com>
+*/
+
+class AliHLTPHOSMIPCounter : public AliHLTPHOSBase
+ {
+ public:
+ /**
+ * Default constructor
+ */
+ AliHLTPHOSMIPCounter();
+
+ /**
+ * Default destructor
+ */
+ ~AliHLTPHOSMIPCounter();
+
+ /**
+ * This functions counts the number of approved MIP hits in one digit container
+ * @param digitContainer ContainerStruct for digits
+ * @return Number of approved MIP hits
+ */
+ Int_t CountMIPs(AliHLTPHOSDigitContainerDataStruct* digitContainer);
+
+
+ /**
+ * Sets the upper bound of the amplitude accepted for a MIP
+ * @param val Upper bound value
+ */
+ void SetUpperBound ( const Float_t& val ) { fUpperBound = val; }
+
+ /**
+ * Gets the upper bound of the amplitude accepted for a MIP
+ * @return Upper bound value
+ */
+ Float_t GetUpperBound() const { return fUpperBound; }
+
+ /**
+ * Sets the lower bound of the amplitude accepted for a MIP
+ * @param val lower bound value
+ */
+ void SetLowerBound ( const Float_t& val ) { fLowerBound = val; }
+
+ /**
+ * Gets the lower bound of the amplitude accepted for a MIP
+ * @return Lower bound value
+ */
+ Float_t GetLowerBound() const { return fLowerBound; }
+
+ /**
+ * Sets the upper bound for the start time of the signal, i.e. where the
+ * baseline shouldn't be zero anymore
+ * @param val Upper start time
+ */
+ void SetUpperStartTime ( const Float_t& val ) { fUpperStartTime = val; }
+
+ /**
+ * Sets the upper bound for the start time of the signal, i.e. where the
+ * baseline shouldn't be zero anymore
+ * @return Upper start time
+ */
+ Float_t GetUpperStartTime() const { return fUpperStartTime; }
+
+ /**
+ * Sets the lower bound for the start time of the signal, i.e. where the
+ * baseline shouldn't be zero anymore
+ * @param val Lower start time
+ */
+ void SetLowerStartTime ( const Float_t& val ) { fLowerStartTime = val; }
+
+ /**
+ * Gets the lower bound for the start time of the signal, i.e. where the
+ * baseline shouldn't be zero anymore
+ * @return Lower start time
+ */
+ Float_t GetLowerStartTime() const { return fLowerStartTime; }
+
+ /**
+ * Sets the threshold for what is zero when checking the baseline
+ * @param val Zero threshold
+ */
+ void SetZeroThreshold ( const Float_t& val ) { fZeroThreshold = val; }
+
+ /**
+ * Gets the threshold for what is zero when checking the baseline
+ * @return Zero threshold
+ */
+ Float_t GetZeroThreshold() const { return fZeroThreshold; }
+
+ /**
+ * Get the total count of MIPs which the MIP counter has seen
+ * @return Total count of MIPs
+ */
+ Int_t GetMIPCountTotal() const { return fMIPCountTotal; }
+
+ /**
+ * Get the total count of MIPs in the last event
+ * @return Total count of MIPs in last event
+ */
+ Int_t GetMIPCountEvent() const { return fMIPCountEvent; }
+
+ /**
+ * Sets a pointer to the TH2I histogram of channels with MIP hits
+ * @param hist Pointer to the histogram
+ */
+ void SetChannelHistogram(TH2I *hist) { fChannelHistPtr = hist; }
+
+ /**
+ * Get the pointer to the TH2I histogram of channels with MIP hits
+ * @return Pointer to the histogram
+ */
+ TH2I* GetChannelHistogram() { return fChannelHistPtr; }
+
+
+ private:
+ Int_t fMIPCountEvent;
+ Int_t fMIPCountTotal;
+ Float_t fMIPRate;
+ Float_t fLowerBound;
+ Float_t fUpperBound;
+ Float_t fUpperStartTime;
+ Float_t fLowerStartTime;
+ Float_t fZeroThreshold;
+ TH2I *fChannelHistPtr;
+ };
+
+#endif
--- /dev/null
+ /**************************************************************************
+ * This file is property of and copyright by the ALICE HLT Project *
+ * All rights reserved. *
+ * *
+ * Primary Authors: Oystein Djuvsland *
+ * *
+ * 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. *
+ **************************************************************************/
+
+#include "AliHLTPHOSMIPCounterComponent.h"
+#include "AliHLTPHOSProcessor.h"
+#include "AliHLTPHOSMIPCounter.h"
+#include "TH1I.h"
+#include "TH1F.h"
+#include "TH2I.h"
+#include "TFile.h"
+#include "AliHLTPHOSDigitContainerDataStruct.h"
+
+
+const AliHLTComponentDataType AliHLTPHOSMIPCounterComponent::fgkInputDataTypes[]={kAliHLTVoidDataType,{0,"",""}};
+
+AliHLTPHOSMIPCounterComponent gAliHLTPHOSMIPCounterComponent;
+
+AliHLTPHOSMIPCounterComponent::AliHLTPHOSMIPCounterComponent()
+ : AliHLTPHOSProcessor(),
+ fEventCount ( 0 ),
+ fInterval ( 0 ),
+ fMIPCount ( 0 ),
+ fTRUThreshold ( 0 ),
+ fMIPCountInterval ( 0 ),
+ fPath ( 0 ),
+ fMIPCounterPtr ( 0 ),
+ fHistPtr ( 0 ),
+ fIntervalHistPtr ( 0 ),
+ fRateHistPtr ( 0 ),
+ fChannelHistPtr ( 0 ),
+ fRatioHistPtr ( 0 )
+{
+}
+
+
+AliHLTPHOSMIPCounterComponent::~AliHLTPHOSMIPCounterComponent()
+{
+}
+
+int
+AliHLTPHOSMIPCounterComponent::Deinit()
+{
+ printf("AliHLTPHOSMIPCounterComponent::Deinit()\n");
+ char filename[50];
+ sprintf(filename, "%s/MIPCount_TRUThreshold%s.root", fPath, fTRUThreshold);
+ TFile *outfile = new TFile(filename, "recreate");
+ fHistPtr->Write();
+ fIntervalHistPtr->Write();
+ fRateHistPtr->Write();
+ fChannelHistPtr->Write();
+ fRatioHistPtr->Write();
+ outfile->Close();
+
+ printf("Total number of MIPs in %d events: %d\nGives a rate of: %f\n", fEventCount, fMIPCounterPtr->GetMIPCountTotal(),
+ ((float)(fMIPCounterPtr->GetMIPCountTotal()))/((float)fEventCount));
+
+ return 0;
+}
+
+const char*
+AliHLTPHOSMIPCounterComponent::GetComponentID()
+{
+ return "PhosMIPCounter";
+}
+
+void
+ AliHLTPHOSMIPCounterComponent::GetInputDataTypes(vector<AliHLTComponentDataType>& list)
+{
+ //Get datatypes for input
+ const AliHLTComponentDataType* pType=fgkInputDataTypes;
+ while (pType->fID!=0) {
+ list.push_back(*pType);
+ pType++;
+ }
+}
+
+AliHLTComponentDataType
+AliHLTPHOSMIPCounterComponent::GetOutputDataType()
+{
+ return AliHLTPHOSDefinitions::fgkAliHLTMIPDataType;
+}
+
+
+void
+ AliHLTPHOSMIPCounterComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier)
+{
+ constBase = 30;
+ inputMultiplier = 1;
+}
+
+int
+AliHLTPHOSMIPCounterComponent::DoEvent(const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
+ AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size,
+ vector<AliHLTComponentBlockData>& outputBlocks)
+{
+ //Do event
+ int digitCount = 0;
+
+ const AliHLTComponentBlockData* iter = 0;
+ unsigned long ndx;
+
+ for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
+ {
+ iter = blocks+ndx;
+
+ if(iter->fDataType != AliHLTPHOSDefinitions::fgkAliHLTDigitDataType)
+ {
+ // cout << "Warning: data type is not fgkCellEnergyDataType " << endl;
+ continue;
+ }
+ digitCount += (reinterpret_cast<AliHLTPHOSDigitContainerDataStruct*>(iter->fPtr))->fNDigits;
+ fMIPCount += fMIPCounterPtr->CountMIPs(reinterpret_cast<AliHLTPHOSDigitContainerDataStruct*>(iter->fPtr));
+ }
+ fRatioHistPtr->Fill((float)(((float)fMIPCount)/((float)digitCount)));
+ fEventCount++;
+ fMIPCountInterval += fMIPCount;
+ fMIPCount = 0;
+
+ if(fEventCount % fInterval == 0)
+ {
+ printf("Event #: %d -- Number of MIPs the last %d events: %d -- Which gives a rate of: %f\n",
+ fInterval, fMIPCountInterval, (Float_t)fMIPCountInterval/(Float_t)fInterval);
+ fIntervalHistPtr->Fill(fMIPCountInterval);
+ fRateHistPtr->Fill((Float_t)fMIPCountInterval/(Float_t)fInterval);
+ fMIPCountInterval = 0;
+ }
+
+ return 0;
+}
+
+
+int
+AliHLTPHOSMIPCounterComponent::DoInit(int argc, const char** argv )
+{
+ //Do initialization
+ cout << "Initializing AliHLTPHOSMIPCounterComponent...\n";
+ cout << endl;
+ Char_t intervalHistName[50];
+ Char_t rateHistName[50];
+ fPath = new Char_t[50];
+ fTRUThreshold = new Char_t[50];
+ fMIPCounterPtr = new AliHLTPHOSMIPCounter();
+ for(int i = 0; i < argc; i++)
+ {
+ if(!strcmp("-interval", argv[i]))
+ {
+ fInterval = atoi(argv[i+1]);
+ }
+ if(!strcmp("-path", argv[i]))
+ {
+ strcpy(fPath, argv[i+1]);
+ }
+ if(!strcmp("-upperbound", argv[i]))
+ {
+ fMIPCounterPtr->SetUpperBound(atoi(argv[i+1]));
+ }
+ if(!strcmp("-lowerbound", argv[i]))
+ {
+ fMIPCounterPtr->SetLowerBound(atoi(argv[i+1]));
+ }
+ if(!strcmp("-zerothreshold", argv[i]))
+ {
+ fMIPCounterPtr->SetZeroThreshold(atoi(argv[i+1]));
+ }
+ if(!strcmp("-truthreshold", argv[i]))
+ {
+ strcpy(fTRUThreshold, argv[i+1]);
+ }
+ if(!strcmp("-lowerstarttime", argv[i]))
+ {
+ fMIPCounterPtr->SetLowerStartTime(atoi(argv[i+1]));
+ }
+ if(!strcmp("-upperstarttime", argv[i]))
+ {
+ fMIPCounterPtr->SetUpperStartTime(atoi(argv[i+1]));
+ }
+ }
+
+ sprintf(intervalHistName, "Number of MIPs in %d Events", fInterval);
+ sprintf(rateHistName, "MIP Rate for %d Events", fInterval);
+
+ fHistPtr = new TH1I("MIPHist", "Number of MIPs in event", 20, 0, 100);
+ fIntervalHistPtr = new TH1I("intervalMIPHist", intervalHistName, 100, 0, 500);
+ fRateHistPtr = new TH1F("rateHist", rateHistName, 100, 0, 100);
+ fChannelHistPtr = new TH2I("channelHist", "MIP Hits in Channels", 64, 0, 63, 56, 0, 55);
+ fRatioHistPtr = new TH1F("ratioHist", "Ratio of MIP digits in Event", 100, 0, 0.2);
+
+ fMIPCounterPtr->SetChannelHistogram(fChannelHistPtr);
+
+
+ return 0;
+}
+
+AliHLTComponent*
+ AliHLTPHOSMIPCounterComponent::Spawn()
+{
+ return new AliHLTPHOSMIPCounterComponent();
+}
--- /dev/null
+
+ /**************************************************************************
+ * This file is property of and copyright by the ALICE HLT Project *
+ * All rights reserved. *
+ * *
+ * Primary Authors: Oystein Djuvsland *
+ * *
+ * 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. *
+ **************************************************************************/
+
+#ifndef ALIHLTPHOSMIPCOUNTERCOMPONENT_H
+#define ALIHLTPHOSMIPCOUNTERCOMPONENT_H
+
+#include "AliHLTPHOSProcessor.h"
+
+class AliHLTPHOSMIPCounter;
+class TH1F;
+class TH1I;
+class TH2I;
+
+/**
+ @author Øystein Djuvsland <oystein.djuvsland@gmail.com>
+*/
+class AliHLTPHOSMIPCounterComponent : public AliHLTPHOSProcessor
+{
+public:
+ AliHLTPHOSMIPCounterComponent();
+
+ ~AliHLTPHOSMIPCounterComponent();
+
+ const char* GetComponentID();
+
+ void GetInputDataTypes(std::vector<AliHLTComponentDataType>& list);
+
+ AliHLTComponentDataType GetOutputDataType();
+
+ void GetOutputDataSize(unsigned long& constBase, double& inputMultiplier);
+
+ int DoEvent(const AliHLTComponentEventData&, const AliHLTComponentBlockData*,
+ AliHLTComponentTriggerData&, AliHLTUInt8_t*, AliHLTUInt32_t&,
+ std::vector<AliHLTComponentBlockData>&);
+
+ AliHLTComponent* Spawn();
+
+ protected:
+ int DoInit(int argc, const char** argv);
+ virtual int Deinit(); ////////// PTH WARNING you should Define a class AliHLTPHOSModuleProcessor
+
+ private:
+
+ Int_t fEventCount;
+ Int_t fInterval;
+ Int_t fMIPCount;
+ Char_t *fTRUThreshold;
+ Float_t fMIPCountInterval;
+ Char_t *fPath;
+ AliHLTPHOSMIPCounter *fMIPCounterPtr;
+ TH1I *fHistPtr;
+ TH1I *fIntervalHistPtr;
+ TH1F *fRateHistPtr;
+ TH2I *fChannelHistPtr;
+ TH1F *fRatioHistPtr;
+ static const AliHLTComponentDataType fgkInputDataTypes[]; //HLT input data type
+};
+#endif
+
+