3 /**************************************************************************
4 * This file is property of and copyright by the ALICE HLT Project *
5 * All rights reserved. *
7 * Primary Authors: Oystein Djuvsland *
9 * Permission to use, copy, modify and distribute this software and its *
10 * documentation strictly for non-commercial purposes is hereby granted *
11 * without fee, provided that the above copyright notice appears in all *
12 * copies and that both the copyright notice and this permission notice *
13 * appear in the supporting documentation. The authors make no claims *
14 * about the suitability of this software for any purpose. It is *
15 * provided "as is" without express or implied warranty. *
16 **************************************************************************/
18 #include "AliHLTPHOSDigitMakerComponent.h"
19 #include "AliHLTCaloDigitMaker.h"
20 #include "AliHLTCaloDigitDataStruct.h"
21 #include "AliHLTPHOSMapper.h"
22 #include "AliHLTCaloChannelDataHeaderStruct.h"
23 #include "AliHLTCaloChannelDataStruct.h"
24 #include "AliPHOSEmcBadChannelsMap.h"
25 #include "AliPHOSEmcCalibData.h"
27 #include "AliCDBEntry.h"
28 #include "AliCDBPath.h"
29 #include "AliCDBManager.h"
31 #include <sys/types.h>
35 * @file AliHLTPHOSDigitMakerComponent.cxx
36 * @author Oystein Djuvsland
38 * @brief A digit maker component for PHOS HLT
41 // see below for class documentation
43 // refer to README to build package
45 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
47 ClassImp(AliHLTPHOSDigitMakerComponent);
49 AliHLTPHOSDigitMakerComponent gAliHLTPHOSDigitMakerComponent;
51 AliHLTPHOSDigitMakerComponent::AliHLTPHOSDigitMakerComponent() :
52 AliHLTCaloProcessor(),
53 AliHLTCaloConstantsHandler("PHOS"),
55 fDigitContainerPtr(0),
58 fBCMInitialised(true),
59 fGainsInitialised(true)
61 //see header file for documentation
65 AliHLTPHOSDigitMakerComponent::~AliHLTPHOSDigitMakerComponent()
67 //see header file for documentation
71 AliHLTPHOSDigitMakerComponent::Deinit()
73 //see header file for documentation
76 delete fDigitMakerPtr;
83 AliHLTPHOSDigitMakerComponent::GetComponentID()
85 //see header file for documentation
86 return "PhosDigitMaker";
91 AliHLTPHOSDigitMakerComponent::GetInputDataTypes(vector<AliHLTComponentDataType>& list)
93 //see header file for documentation
95 list.push_back(AliHLTPHOSDefinitions::fgkChannelDataType);
98 AliHLTComponentDataType
99 AliHLTPHOSDigitMakerComponent::GetOutputDataType()
101 //see header file for documentation
102 return AliHLTPHOSDefinitions::fgkDigitDataType;
107 AliHLTPHOSDigitMakerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier)
109 //see header file for documentation
111 inputMultiplier = (float)sizeof(AliHLTCaloDigitDataStruct)/sizeof(AliHLTCaloChannelDataStruct) + 1;
115 AliHLTPHOSDigitMakerComponent::DoEvent(const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
116 AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size,
117 std::vector<AliHLTComponentBlockData>& outputBlocks)
119 //see header file for documentation
122 Int_t digitCount = 0;
125 const AliHLTComponentBlockData* iter = 0;
128 UInt_t specification = 0;
129 AliHLTCaloChannelDataHeaderStruct* tmpChannelData = 0;
131 // fDigitMakerPtr->SetDigitHeaderPtr(reinterpret_cast<AliHLTCaloDigitHeaderStruct*>(outputPtr));
133 fDigitMakerPtr->SetDigitDataPtr(reinterpret_cast<AliHLTCaloDigitDataStruct*>(outputPtr));
135 for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
140 if(iter->fDataType != AliHLTPHOSDefinitions::fgkChannelDataType)
142 // HLTDebug("Data block is not of type fgkChannelDataType");
147 AliHLTPHOSMapper mapper;
148 Int_t module = mapper.GetModuleFromSpec(iter->fSpecification);
151 for(Int_t x = 0; x < fCaloConstants->GetNXCOLUMNSMOD(); x++)
153 for(Int_t z = 0; z < fCaloConstants->GetNZROWSMOD(); z++)
155 fDigitMakerPtr->SetBadChannel(x, z, fBadChannelMap->IsBadChannel(5-module, z+1, x+1));
159 //delete fBadChannelMap;
160 fBCMInitialised = true;
162 if(!fGainsInitialised)
164 AliHLTPHOSMapper mapper;
165 Int_t module = mapper.GetModuleFromSpec(iter->fSpecification);
166 if(module >= 0 && module < 5)
168 for(Int_t x = 0; x < fCaloConstants->GetNXCOLUMNSMOD(); x++)
170 for(Int_t z = 0; z < fCaloConstants->GetNZROWSMOD(); z++)
172 fDigitMakerPtr->SetGain(x, z, fCalibData->GetHighLowRatioEmc(5-module, z+1, x+1), fCalibData->GetADCchannelEmc(5-module, z+1, x+1));
175 fGainsInitialised = true;
180 specification |= iter->fSpecification;
181 tmpChannelData = reinterpret_cast<AliHLTCaloChannelDataHeaderStruct*>(iter->fPtr);
183 ret = fDigitMakerPtr->MakeDigits(tmpChannelData, size-(digitCount*sizeof(AliHLTCaloDigitDataStruct)));
186 HLTError("Trying to write over buffer size");
192 mysize += digitCount*sizeof(AliHLTCaloDigitDataStruct);
194 HLTDebug("# of digits: %d, used memory size: %d, available size: %d", digitCount, mysize, size);
198 AliHLTComponentBlockData bd;
202 bd.fDataType = AliHLTPHOSDefinitions::fgkDigitDataType;
203 bd.fSpecification = specification;
204 outputBlocks.push_back(bd);
207 fDigitMakerPtr->Reset();
215 AliHLTPHOSDigitMakerComponent::DoInit(int argc, const char** argv )
217 //see header file for documentation
219 fDigitMakerPtr = new AliHLTCaloDigitMaker("PHOS");
221 AliHLTCaloMapper *mapper = new AliHLTPHOSMapper();
222 fDigitMakerPtr->SetMapper(mapper);
224 Float_t mintime = 0.;
225 Float_t maxtime =50.;
227 for(int i = 0; i < argc; i++)
229 if(!strcmp("-lowgainfactor", argv[i]))
231 fDigitMakerPtr->SetGlobalLowGainFactor(atof(argv[i+1]));
233 if(!strcmp("-highgainfactor", argv[i]))
235 fDigitMakerPtr->SetGlobalHighGainFactor(atof(argv[i+1]));
237 if(!strcmp("-mintime", argv[i]))
239 mintime = atof(argv[i+1]);
241 if(!strcmp("-maxtime", argv[i]))
243 maxtime = atof(argv[i+1]);
247 fDigitMakerPtr->SetTimeWindow(mintime, maxtime);
249 if(GetBCMFromCDB()) return -1;
250 if(GetGainsFromCDB()) return -1;
252 //fDigitMakerPtr->SetDigitThreshold(2);
258 int AliHLTPHOSDigitMakerComponent::GetBCMFromCDB()
260 fBCMInitialised = false;
262 // HLTInfo("Getting bad channel map...");
264 AliCDBPath path("PHOS","Calib","EmcBadChannels");
267 // HLTInfo("configure from entry %s", path.GetPath());
268 AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/);
271 fBadChannelMap = (AliPHOSEmcBadChannelsMap*)pEntry->GetObject();
275 HLTError("can not fetch object \"%s\" from CDB", path.GetPath().Data());
279 if(!fBadChannelMap) return -1;
283 int AliHLTPHOSDigitMakerComponent::GetGainsFromCDB()
285 fGainsInitialised = false;
287 // HLTInfo("Getting bad channel map...");
289 AliCDBPath path("PHOS","Calib","EmcGainPedestals");
292 // HLTInfo("configure from entry %s", path.GetPath());*/
293 AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/);
296 fCalibData = (AliPHOSEmcCalibData*)pEntry->GetObject();
300 HLTError("can not fetch object \"%s\" from CDB", path.GetPath().Data());
305 if(!fCalibData) return -1;
312 AliHLTPHOSDigitMakerComponent::Spawn()
314 //see header file for documentation
315 return new AliHLTPHOSDigitMakerComponent();