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
48 AliHLTPHOSDigitMakerComponent gAliHLTPHOSDigitMakerComponent;
50 AliHLTPHOSDigitMakerComponent::AliHLTPHOSDigitMakerComponent() :
51 AliHLTPHOSProcessor(),
52 AliHLTCaloConstantsHandler("PHOS"),
54 fDigitContainerPtr(0),
57 fBCMInitialised(true),
58 fGainsInitialised(true)
60 //see header file for documentation
64 AliHLTPHOSDigitMakerComponent::~AliHLTPHOSDigitMakerComponent()
66 //see header file for documentation
70 AliHLTPHOSDigitMakerComponent::Deinit()
72 //see header file for documentation
75 delete fDigitMakerPtr;
82 AliHLTPHOSDigitMakerComponent::GetComponentID()
84 //see header file for documentation
85 return "PhosDigitMaker";
90 AliHLTPHOSDigitMakerComponent::GetInputDataTypes(vector<AliHLTComponentDataType>& list)
92 //see header file for documentation
94 list.push_back(AliHLTPHOSDefinitions::fgkChannelDataType);
97 AliHLTComponentDataType
98 AliHLTPHOSDigitMakerComponent::GetOutputDataType()
100 //see header file for documentation
101 return AliHLTPHOSDefinitions::fgkDigitDataType;
106 AliHLTPHOSDigitMakerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier)
108 //see header file for documentation
110 inputMultiplier = (float)sizeof(AliHLTCaloDigitDataStruct)/sizeof(AliHLTCaloChannelDataStruct) + 1;
114 AliHLTPHOSDigitMakerComponent::DoEvent(const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
115 AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size,
116 std::vector<AliHLTComponentBlockData>& outputBlocks)
118 //see header file for documentation
121 Int_t digitCount = 0;
124 AliHLTUInt8_t* outBPtr;
126 const AliHLTComponentBlockData* iter = 0;
129 UInt_t specification = 0;
130 AliHLTCaloChannelDataHeaderStruct* tmpChannelData = 0;
132 // fDigitMakerPtr->SetDigitHeaderPtr(reinterpret_cast<AliHLTCaloDigitHeaderStruct*>(outputPtr));
134 fDigitMakerPtr->SetDigitDataPtr(reinterpret_cast<AliHLTCaloDigitDataStruct*>(outputPtr));
136 for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
141 if(iter->fDataType != AliHLTPHOSDefinitions::fgkChannelDataType)
143 // HLTDebug("Data block is not of type fgkChannelDataType");
148 AliHLTPHOSMapper mapper;
149 Int_t module = mapper.GetModuleFromSpec(iter->fSpecification);
150 for(Int_t x = 0; x < fCaloConstants->GetNXCOLUMNSMOD(); x++)
152 for(Int_t z = 0; z < fCaloConstants->GetNZROWSMOD(); z++)
154 fDigitMakerPtr->SetBadChannel(x, z, fBadChannelMap->IsBadChannel(5-module, z+1, x+1));
157 //delete fBadChannelMap;
158 fBCMInitialised = true;
160 if(!fGainsInitialised)
162 AliHLTPHOSMapper mapper;
163 Int_t module = mapper.GetModuleFromSpec(iter->fSpecification);
164 for(Int_t x = 0; x < fCaloConstants->GetNXCOLUMNSMOD(); x++)
166 for(Int_t z = 0; z < fCaloConstants->GetNZROWSMOD(); z++)
168 fDigitMakerPtr->SetGain(x, z, fCalibData->GetHighLowRatioEmc(module, z+1, x+1), fCalibData->GetADCchannelEmc(module, z+1, x+1));
171 fGainsInitialised = true;
174 specification |= iter->fSpecification;
175 tmpChannelData = reinterpret_cast<AliHLTCaloChannelDataHeaderStruct*>(iter->fPtr);
177 ret = fDigitMakerPtr->MakeDigits(tmpChannelData, size-(digitCount*sizeof(AliHLTCaloDigitDataStruct)));
180 // HLTError("Trying to write over buffer size");
186 mysize += digitCount*sizeof(AliHLTCaloDigitDataStruct);
188 //HLTDebug("# of digits: %d, used memory size: %d, available size: %d", digitCount, mysize, size);
192 AliHLTComponentBlockData bd;
196 bd.fDataType = AliHLTPHOSDefinitions::fgkDigitDataType;
197 bd.fSpecification = specification;
198 outputBlocks.push_back(bd);
201 fDigitMakerPtr->Reset();
209 AliHLTPHOSDigitMakerComponent::DoInit(int argc, const char** argv )
211 //see header file for documentation
213 fDigitMakerPtr = new AliHLTCaloDigitMaker("PHOS");
215 AliHLTCaloMapper *mapper = new AliHLTPHOSMapper();
216 fDigitMakerPtr->SetMapper(mapper);
218 Float_t mintime = 0.;
219 Float_t maxtime =50.;
221 for(int i = 0; i < argc; i++)
223 if(!strcmp("-lowgainfactor", argv[i]))
225 fDigitMakerPtr->SetGlobalLowGainFactor(atof(argv[i+1]));
227 if(!strcmp("-highgainfactor", argv[i]))
229 fDigitMakerPtr->SetGlobalHighGainFactor(atof(argv[i+1]));
231 if(!strcmp("-mintime", argv[i]))
233 mintime = atof(argv[i+1]);
235 if(!strcmp("-maxtime", argv[i]))
237 maxtime = atof(argv[i+1]);
241 fDigitMakerPtr->SetTimeWindow(mintime, maxtime);
243 if(GetBCMFromCDB()) return -1;
244 if(GetGainsFromCDB()) return -1;
246 //fDigitMakerPtr->SetDigitThreshold(2);
252 int AliHLTPHOSDigitMakerComponent::GetBCMFromCDB()
254 fBCMInitialised = false;
256 // HLTInfo("Getting bad channel map...");
258 AliCDBPath path("PHOS","Calib","EmcBadChannels");
261 // HLTInfo("configure from entry %s", path.GetPath());
262 AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/);
265 fBadChannelMap = (AliPHOSEmcBadChannelsMap*)pEntry->GetObject();
269 // HLTError("can not fetch object \"%s\" from CDB", path);
273 if(!fBadChannelMap) return -1;
277 int AliHLTPHOSDigitMakerComponent::GetGainsFromCDB()
279 fGainsInitialised = false;
281 // HLTInfo("Getting bad channel map...");
283 AliCDBPath path("PHOS","Calib","EmcGainPedestals");
286 // HLTInfo("configure from entry %s", path.GetPath());*/
287 AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/);
290 fCalibData = (AliPHOSEmcCalibData*)pEntry->GetObject();
294 // HLTError("can not fetch object \"%s\" from CDB", path);
299 if(!fCalibData) return -1;
306 AliHLTPHOSDigitMakerComponent::Spawn()
308 //see header file for documentation
309 return new AliHLTPHOSDigitMakerComponent();