1 /**************************************************************************
2 * This file is property of and copyright by the ALICE HLT Project *
3 * All rights reserved. *
5 * Primary Authors: Oystein Djuvsland *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
16 #include "AliHLTPHOSMIPCounterComponent.h"
17 #include "AliHLTPHOSProcessor.h"
18 #include "AliHLTPHOSMIPCounter.h"
23 #include "AliHLTPHOSDigitContainerDataStruct.h"
26 const AliHLTComponentDataType AliHLTPHOSMIPCounterComponent::fgkInputDataTypes[]={kAliHLTVoidDataType,{0,"",""}};
28 AliHLTPHOSMIPCounterComponent gAliHLTPHOSMIPCounterComponent;
30 AliHLTPHOSMIPCounterComponent::AliHLTPHOSMIPCounterComponent()
31 : AliHLTPHOSProcessor(),
36 fMIPCountInterval ( 0 ),
40 fIntervalHistPtr ( 0 ),
42 fChannelHistPtr ( 0 ),
48 AliHLTPHOSMIPCounterComponent::~AliHLTPHOSMIPCounterComponent()
53 AliHLTPHOSMIPCounterComponent::Deinit()
55 printf("AliHLTPHOSMIPCounterComponent::Deinit()\n");
57 sprintf(filename, "%s/MIPCount_TRUThreshold%s.root", fPath, fTRUThreshold);
58 TFile *outfile = new TFile(filename, "recreate");
60 fIntervalHistPtr->Write();
61 fRateHistPtr->Write();
62 fChannelHistPtr->Write();
63 fRatioHistPtr->Write();
66 printf("Total number of MIPs in %d events: %d\nGives a rate of: %f\n", fEvtCnt, fMIPCounterPtr->GetMIPCountTotal(),
67 ((float)(fMIPCounterPtr->GetMIPCountTotal()))/((float)fEvtCnt));
73 AliHLTPHOSMIPCounterComponent::GetComponentID()
75 return "PhosMIPCounter";
79 AliHLTPHOSMIPCounterComponent::GetInputDataTypes(vector<AliHLTComponentDataType>& list)
81 //Get datatypes for input
82 const AliHLTComponentDataType* pType=fgkInputDataTypes;
83 while (pType->fID!=0) {
84 list.push_back(*pType);
89 AliHLTComponentDataType
90 AliHLTPHOSMIPCounterComponent::GetOutputDataType()
92 return AliHLTPHOSDefinitions::fgkAliHLTMIPDataType;
97 AliHLTPHOSMIPCounterComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier)
104 AliHLTPHOSMIPCounterComponent::DoEvent(const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
105 AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* /*outputPtr*/, AliHLTUInt32_t& /*size*/, //TODO: I think size should be set to zero when returning from this method if not data was written to the output buffer.
106 vector<AliHLTComponentBlockData>& /*outputBlocks*/)
111 const AliHLTComponentBlockData* iter = 0;
114 for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
118 if(iter->fDataType != AliHLTPHOSDefinitions::fgkAliHLTDigitDataType)
120 // cout << "Warning: data type is not fgkCellEnergyDataType " << endl;
123 digitCount += (reinterpret_cast<AliHLTPHOSDigitContainerDataStruct*>(iter->fPtr))->fNDigits;
124 fMIPCount += fMIPCounterPtr->CountMIPs(reinterpret_cast<AliHLTPHOSDigitContainerDataStruct*>(iter->fPtr));
126 fRatioHistPtr->Fill((float)(((float)fMIPCount)/((float)digitCount)));
128 fMIPCountInterval += fMIPCount;
131 if(fEvtCnt % fInterval == 0)
133 printf("Event #: %d -- Number of MIPs the last %d events: %d -- Which gives a rate of: %f\n",
134 fEvtCnt, fInterval, Int_t(fMIPCountInterval), ((Float_t)fMIPCountInterval/(Float_t)fInterval)); //TODO: check that the proper things are being written to screen.
135 fIntervalHistPtr->Fill(fMIPCountInterval);
136 fRateHistPtr->Fill((Float_t)fMIPCountInterval/(Float_t)fInterval);
137 fMIPCountInterval = 0;
145 AliHLTPHOSMIPCounterComponent::DoInit(int argc, const char** argv )
148 cout << "Initializing AliHLTPHOSMIPCounterComponent...\n";
150 Char_t intervalHistName[50];
151 Char_t rateHistName[50];
152 fPath = new Char_t[50];
153 fTRUThreshold = new Char_t[50];
154 fMIPCounterPtr = new AliHLTPHOSMIPCounter();
155 for(int i = 0; i < argc; i++)
157 if(!strcmp("-interval", argv[i]))
159 fInterval = atoi(argv[i+1]);
161 if(!strcmp("-path", argv[i]))
163 strcpy(fPath, argv[i+1]);
165 if(!strcmp("-upperbound", argv[i]))
167 fMIPCounterPtr->SetUpperBound(atoi(argv[i+1]));
169 if(!strcmp("-lowerbound", argv[i]))
171 fMIPCounterPtr->SetLowerBound(atoi(argv[i+1]));
173 if(!strcmp("-zerothreshold", argv[i]))
175 fMIPCounterPtr->SetZeroThreshold(atoi(argv[i+1]));
177 if(!strcmp("-truthreshold", argv[i]))
179 strcpy(fTRUThreshold, argv[i+1]);
181 if(!strcmp("-lowerstarttime", argv[i]))
183 fMIPCounterPtr->SetLowerStartTime(atoi(argv[i+1]));
185 if(!strcmp("-upperstarttime", argv[i]))
187 fMIPCounterPtr->SetUpperStartTime(atoi(argv[i+1]));
191 sprintf(intervalHistName, "Number of MIPs in %d Events", fInterval);
192 sprintf(rateHistName, "MIP Rate for %d Events", fInterval);
194 fHistPtr = new TH1I("MIPHist", "Number of MIPs in event", 20, 0, 100);
195 fIntervalHistPtr = new TH1I("intervalMIPHist", intervalHistName, 100, 0, 500);
196 fRateHistPtr = new TH1F("rateHist", rateHistName, 100, 0, 100);
197 fChannelHistPtr = new TH2I("channelHist", "MIP Hits in Channels", 64, 0, 63, 56, 0, 55);
198 fRatioHistPtr = new TH1F("ratioHist", "Ratio of MIP digits in Event", 100, 0, 0.2);
200 fMIPCounterPtr->SetChannelHistogram(fChannelHistPtr);
207 AliHLTPHOSMIPCounterComponent::Spawn()
209 return new AliHLTPHOSMIPCounterComponent();