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);
149 for(Int_t x = 0; x < fCaloConstants->GetNXCOLUMNSMOD(); x++)
151 for(Int_t z = 0; z < fCaloConstants->GetNZROWSMOD(); z++)
153 fDigitMakerPtr->SetBadChannel(x, z, fBadChannelMap->IsBadChannel(5-module, z+1, x+1));
156 //delete fBadChannelMap;
157 fBCMInitialised = true;
159 if(!fGainsInitialised)
161 AliHLTPHOSMapper mapper;
162 Int_t module = mapper.GetModuleFromSpec(iter->fSpecification);
163 for(Int_t x = 0; x < fCaloConstants->GetNXCOLUMNSMOD(); x++)
165 for(Int_t z = 0; z < fCaloConstants->GetNZROWSMOD(); z++)
167 fDigitMakerPtr->SetGain(x, z, fCalibData->GetHighLowRatioEmc(5-module, z+1, x+1), fCalibData->GetADCchannelEmc(5-module, z+1, x+1));
170 fGainsInitialised = true;
173 specification |= iter->fSpecification;
174 tmpChannelData = reinterpret_cast<AliHLTCaloChannelDataHeaderStruct*>(iter->fPtr);
176 ret = fDigitMakerPtr->MakeDigits(tmpChannelData, size-(digitCount*sizeof(AliHLTCaloDigitDataStruct)));
179 HLTError("Trying to write over buffer size");
185 mysize += digitCount*sizeof(AliHLTCaloDigitDataStruct);
187 HLTDebug("# of digits: %d, used memory size: %d, available size: %d", digitCount, mysize, size);
191 AliHLTComponentBlockData bd;
195 bd.fDataType = AliHLTPHOSDefinitions::fgkDigitDataType;
196 bd.fSpecification = specification;
197 outputBlocks.push_back(bd);
200 fDigitMakerPtr->Reset();
208 AliHLTPHOSDigitMakerComponent::DoInit(int argc, const char** argv )
210 //see header file for documentation
212 fDigitMakerPtr = new AliHLTCaloDigitMaker("PHOS");
214 AliHLTCaloMapper *mapper = new AliHLTPHOSMapper();
215 fDigitMakerPtr->SetMapper(mapper);
217 Float_t mintime = 0.;
218 Float_t maxtime =50.;
220 for(int i = 0; i < argc; i++)
222 if(!strcmp("-lowgainfactor", argv[i]))
224 fDigitMakerPtr->SetGlobalLowGainFactor(atof(argv[i+1]));
226 if(!strcmp("-highgainfactor", argv[i]))
228 fDigitMakerPtr->SetGlobalHighGainFactor(atof(argv[i+1]));
230 if(!strcmp("-mintime", argv[i]))
232 mintime = atof(argv[i+1]);
234 if(!strcmp("-maxtime", argv[i]))
236 maxtime = atof(argv[i+1]);
240 fDigitMakerPtr->SetTimeWindow(mintime, maxtime);
242 if(GetBCMFromCDB()) return -1;
243 if(GetGainsFromCDB()) return -1;
245 //fDigitMakerPtr->SetDigitThreshold(2);
251 int AliHLTPHOSDigitMakerComponent::GetBCMFromCDB()
253 fBCMInitialised = false;
255 // HLTInfo("Getting bad channel map...");
257 AliCDBPath path("PHOS","Calib","EmcBadChannels");
260 // HLTInfo("configure from entry %s", path.GetPath());
261 AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/);
264 fBadChannelMap = (AliPHOSEmcBadChannelsMap*)pEntry->GetObject();
268 HLTError("can not fetch object \"%s\" from CDB", path.GetPath().Data());
272 if(!fBadChannelMap) return -1;
276 int AliHLTPHOSDigitMakerComponent::GetGainsFromCDB()
278 fGainsInitialised = false;
280 // HLTInfo("Getting bad channel map...");
282 AliCDBPath path("PHOS","Calib","EmcGainPedestals");
285 // HLTInfo("configure from entry %s", path.GetPath());*/
286 AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/);
289 fCalibData = (AliPHOSEmcCalibData*)pEntry->GetObject();
293 HLTError("can not fetch object \"%s\" from CDB", path.GetPath().Data());
298 if(!fCalibData) return -1;
305 AliHLTPHOSDigitMakerComponent::Spawn()
307 //see header file for documentation
308 return new AliHLTPHOSDigitMakerComponent();