]>
Commit | Line | Data |
---|---|---|
86cbf5e7 | 1 | /************************************************************************** |
2 | * This file is property of and copyright by the ALICE HLT Project * | |
3 | * ALICE Experiment at CERN, All rights reserved. * | |
4 | * * | |
5 | * Primary Authors: Oystein Djuvsland <oysteind@ift.uib.no> * | |
6 | * for The ALICE HLT Project. * | |
7 | * * | |
8 | * Permission to use, copy, modify and distribute this software and its * | |
9 | * documentation strictly for non-commercial purposes is hereby granted * | |
10 | * without fee, provided that the above copyright notice appears in all * | |
11 | * copies and that both the copyright notice and this permission notice * | |
12 | * appear in the supporting documentation. The authors make no claims * | |
13 | * about the suitability of this software for any purpose. It is * | |
14 | * provided "as is" without express or implied warranty. * | |
15 | **************************************************************************/ | |
16 | ||
17 | #include "AliHLTEMCALDigitHandler.h" | |
18 | #include "AliRunLoader.h" | |
19 | #include "AliEMCALLoader.h" | |
20 | #include "AliHLTEMCALGeometry.h" | |
21 | #include "TTree.h" | |
22 | #include "AliEMCALDigit.h" | |
23 | #include "AliEMCALCalibData.h" | |
24 | #include "AliCDBManager.h" | |
25 | #include "AliCDBEntry.h" | |
26 | #include "AliCDBPath.h" | |
27 | ||
28 | AliHLTEMCALDigitHandler *AliHLTEMCALDigitHandler::fgkInstance = NULL; | |
29 | ||
30 | AliHLTEMCALDigitHandler::AliHLTEMCALDigitHandler() : AliHLTCaloDigitHandler("EMCAL") | |
31 | ,fCalibData(0) | |
32 | { | |
33 | ||
34 | } | |
35 | ||
36 | AliHLTEMCALDigitHandler::~AliHLTEMCALDigitHandler() | |
37 | { | |
38 | ||
39 | } | |
40 | ||
41 | AliHLTEMCALDigitHandler* AliHLTEMCALDigitHandler::Instance() | |
42 | { | |
43 | if (!fgkInstance) | |
44 | { | |
45 | fgkInstance = new AliHLTEMCALDigitHandler; | |
46 | } | |
47 | return fgkInstance; | |
48 | } | |
49 | ||
50 | Int_t AliHLTEMCALDigitHandler::Init(AliRunLoader* runLoader) | |
51 | { | |
52 | ||
53 | fGeometry = new AliHLTEMCALGeometry(); | |
54 | if (fGeometry) fGeometry->InitialiseGeometry(); | |
55 | if(GetGainsFromCDB()) | |
56 | { | |
57 | HLTFatal("Could not get gains from CDB"); | |
58 | return -3; | |
59 | } | |
60 | ||
61 | Int_t nev = AliHLTCaloDigitHandler::Init(runLoader); | |
62 | if (nev > 0) | |
63 | { | |
64 | if (fRunLoader) | |
65 | { | |
66 | fDetLoader = dynamic_cast<AliEMCALLoader*>(fRunLoader->GetDetectorLoader("EMCAL")); | |
67 | if (!fDetLoader) | |
68 | { | |
69 | HLTFatal("Could not get EMCAL loader"); | |
70 | return -1; | |
71 | } | |
72 | } | |
73 | else | |
74 | { | |
75 | return -2; | |
76 | } | |
77 | } | |
78 | ||
79 | return nev; | |
80 | } | |
81 | ||
82 | Int_t AliHLTEMCALDigitHandler::ConvertDigit(AliDigitNew *digit) | |
83 | { | |
84 | AliEMCALDigit *dig = dynamic_cast<AliEMCALDigit*>(digit); | |
85 | ||
86 | if(!dig) | |
87 | { | |
88 | HLTError("Wrong data, cannot create digits"); | |
89 | return -1; | |
90 | } | |
91 | ||
92 | Int_t module = 0; | |
93 | Int_t x = 0; | |
94 | Int_t z = 0; | |
95 | ||
96 | fGeometry->GetLocalCoordinatesFromAbsId(dig->GetId(), module, x, z); | |
97 | AliHLTCaloDigitDataStruct *hDig = &(fDigits[module][fDigitsInModule[module]]); | |
98 | ||
99 | hDig->fID = dig->GetId(); | |
100 | hDig->fX = x; | |
101 | hDig->fZ = z; | |
102 | hDig->fModule = module; | |
103 | hDig->fEnergy = dig->GetAmplitude()*(fCalibData->GetADCchannel(module, z, x)); | |
104 | hDig->fTime = dig->GetTime(); | |
105 | hDig->fAmplitude = 0; | |
106 | hDig->fOverflow = false; | |
107 | hDig->fHgPresent = true; | |
108 | hDig->fAssociatedCluster = -1; | |
109 | fDigitsInModule[module]++; | |
110 | ||
111 | return 0; | |
112 | } | |
113 | ||
114 | int AliHLTEMCALDigitHandler::GetGainsFromCDB() | |
115 | { | |
116 | // See header file for class documentation | |
117 | ||
118 | AliCDBPath path("EMCAL","Calib","Data"); | |
119 | if(path.GetPath()) | |
120 | { | |
121 | // HLTInfo("configure from entry %s", path.GetPath()); | |
122 | AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/); | |
123 | if (pEntry) | |
124 | { | |
125 | fCalibData = (AliEMCALCalibData*)pEntry->GetObject(); | |
126 | } | |
127 | else | |
128 | { | |
129 | // HLTError("can not fetch object \"%s\" from CDB", path); | |
130 | return -1; | |
131 | } | |
132 | } | |
133 | if(!fCalibData) return -1; | |
134 | return 0; | |
135 | } |