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 AliHLTUInt8_t* outBPtr;
127 const AliHLTComponentBlockData* iter = 0;
130 UInt_t specification = 0;
131 AliHLTCaloChannelDataHeaderStruct* tmpChannelData = 0;
133 // fDigitMakerPtr->SetDigitHeaderPtr(reinterpret_cast<AliHLTCaloDigitHeaderStruct*>(outputPtr));
135 fDigitMakerPtr->SetDigitDataPtr(reinterpret_cast<AliHLTCaloDigitDataStruct*>(outputPtr));
137 for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
142 if(iter->fDataType != AliHLTPHOSDefinitions::fgkChannelDataType)
144 // HLTDebug("Data block is not of type fgkChannelDataType");
149 AliHLTPHOSMapper mapper;
150 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));
158 //delete fBadChannelMap;
159 fBCMInitialised = true;
161 if(!fGainsInitialised)
163 AliHLTPHOSMapper mapper;
164 Int_t module = mapper.GetModuleFromSpec(iter->fSpecification);
165 for(Int_t x = 0; x < fCaloConstants->GetNXCOLUMNSMOD(); x++)
167 for(Int_t z = 0; z < fCaloConstants->GetNZROWSMOD(); z++)
169 fDigitMakerPtr->SetGain(x, z, fCalibData->GetHighLowRatioEmc(module, z+1, x+1), fCalibData->GetADCchannelEmc(module, z+1, x+1));
172 fGainsInitialised = true;
175 specification |= iter->fSpecification;
176 tmpChannelData = reinterpret_cast<AliHLTCaloChannelDataHeaderStruct*>(iter->fPtr);
178 ret = fDigitMakerPtr->MakeDigits(tmpChannelData, size-(digitCount*sizeof(AliHLTCaloDigitDataStruct)));
181 HLTError("Trying to write over buffer size");
187 mysize += digitCount*sizeof(AliHLTCaloDigitDataStruct);
189 HLTDebug("# of digits: %d, used memory size: %d, available size: %d", digitCount, mysize, size);
193 AliHLTComponentBlockData bd;
197 bd.fDataType = AliHLTPHOSDefinitions::fgkDigitDataType;
198 bd.fSpecification = specification;
199 outputBlocks.push_back(bd);
202 fDigitMakerPtr->Reset();
210 AliHLTPHOSDigitMakerComponent::DoInit(int argc, const char** argv )
212 //see header file for documentation
214 fDigitMakerPtr = new AliHLTCaloDigitMaker("PHOS");
216 AliHLTCaloMapper *mapper = new AliHLTPHOSMapper();
217 fDigitMakerPtr->SetMapper(mapper);
219 Float_t mintime = 0.;
220 Float_t maxtime =50.;
222 for(int i = 0; i < argc; i++)
224 if(!strcmp("-lowgainfactor", argv[i]))
226 fDigitMakerPtr->SetGlobalLowGainFactor(atof(argv[i+1]));
228 if(!strcmp("-highgainfactor", argv[i]))
230 fDigitMakerPtr->SetGlobalHighGainFactor(atof(argv[i+1]));
232 if(!strcmp("-mintime", argv[i]))
234 mintime = atof(argv[i+1]);
236 if(!strcmp("-maxtime", argv[i]))
238 maxtime = atof(argv[i+1]);
242 fDigitMakerPtr->SetTimeWindow(mintime, maxtime);
244 if(GetBCMFromCDB()) return -1;
245 if(GetGainsFromCDB()) return -1;
247 //fDigitMakerPtr->SetDigitThreshold(2);
253 int AliHLTPHOSDigitMakerComponent::GetBCMFromCDB()
255 fBCMInitialised = false;
257 // HLTInfo("Getting bad channel map...");
259 AliCDBPath path("PHOS","Calib","EmcBadChannels");
262 // HLTInfo("configure from entry %s", path.GetPath());
263 AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/);
266 fBadChannelMap = (AliPHOSEmcBadChannelsMap*)pEntry->GetObject();
270 HLTError("can not fetch object \"%s\" from CDB", path.GetPath());
274 if(!fBadChannelMap) return -1;
278 int AliHLTPHOSDigitMakerComponent::GetGainsFromCDB()
280 fGainsInitialised = false;
282 // HLTInfo("Getting bad channel map...");
284 AliCDBPath path("PHOS","Calib","EmcGainPedestals");
287 // HLTInfo("configure from entry %s", path.GetPath());*/
288 AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/);
291 fCalibData = (AliPHOSEmcCalibData*)pEntry->GetObject();
295 HLTError("can not fetch object \"%s\" from CDB", path.GetPath());
300 if(!fCalibData) return -1;
307 AliHLTPHOSDigitMakerComponent::Spawn()
309 //see header file for documentation
310 return new AliHLTPHOSDigitMakerComponent();