Line data Source code
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 0 : AliHLTEMCALDigitHandler::AliHLTEMCALDigitHandler() : AliHLTCaloDigitHandler("EMCAL")
31 0 : ,fCalibData(0)
32 0 : {
33 :
34 0 : }
35 :
36 0 : AliHLTEMCALDigitHandler::~AliHLTEMCALDigitHandler()
37 0 : {
38 :
39 0 : }
40 :
41 : AliHLTEMCALDigitHandler* AliHLTEMCALDigitHandler::Instance()
42 : {
43 0 : if (!fgkInstance)
44 : {
45 0 : fgkInstance = new AliHLTEMCALDigitHandler;
46 0 : }
47 0 : return fgkInstance;
48 0 : }
49 :
50 : Int_t AliHLTEMCALDigitHandler::Init(AliRunLoader* runLoader)
51 : {
52 :
53 0 : fGeometry = new AliHLTEMCALGeometry();
54 0 : if (fGeometry) fGeometry->InitialiseGeometry();
55 0 : if(GetGainsFromCDB())
56 : {
57 0 : HLTFatal("Could not get gains from CDB");
58 0 : return -3;
59 : }
60 :
61 0 : Int_t nev = AliHLTCaloDigitHandler::Init(runLoader);
62 0 : if (nev > 0)
63 : {
64 0 : if (fRunLoader)
65 : {
66 0 : fDetLoader = dynamic_cast<AliEMCALLoader*>(fRunLoader->GetDetectorLoader("EMCAL"));
67 0 : if (!fDetLoader)
68 : {
69 0 : HLTFatal("Could not get EMCAL loader");
70 0 : return -1;
71 : }
72 : }
73 : else
74 : {
75 0 : return -2;
76 : }
77 : }
78 :
79 0 : return nev;
80 0 : }
81 :
82 : Int_t AliHLTEMCALDigitHandler::ConvertDigit(AliDigitNew *digit)
83 : {
84 0 : AliEMCALDigit *dig = dynamic_cast<AliEMCALDigit*>(digit);
85 :
86 0 : if(!dig)
87 : {
88 0 : HLTError("Wrong data, cannot create digits");
89 0 : return -1;
90 : }
91 :
92 0 : Int_t module = 0;
93 0 : Int_t x = 0;
94 0 : Int_t z = 0;
95 :
96 0 : fGeometry->GetLocalCoordinatesFromAbsId(dig->GetId(), module, x, z);
97 0 : AliHLTCaloDigitDataStruct *hDig = &(fDigits[module][fDigitsInModule[module]]);
98 :
99 0 : hDig->fID = dig->GetId();
100 0 : hDig->fX = x;
101 0 : hDig->fZ = z;
102 0 : hDig->fModule = module;
103 0 : hDig->fEnergy = dig->GetAmplitude()*(fCalibData->GetADCchannel(module, z, x));
104 0 : hDig->fTime = dig->GetTime();
105 0 : hDig->fAmplitude = 0;
106 0 : hDig->fOverflow = false;
107 0 : hDig->fHgPresent = true;
108 0 : hDig->fAssociatedCluster = -1;
109 0 : fDigitsInModule[module]++;
110 :
111 : return 0;
112 0 : }
113 :
114 : int AliHLTEMCALDigitHandler::GetGainsFromCDB()
115 : {
116 : // See header file for class documentation
117 :
118 0 : AliCDBPath path("EMCAL","Calib","Data");
119 0 : if(path.GetPath())
120 : {
121 : // HLTInfo("configure from entry %s", path.GetPath());
122 0 : AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/);
123 0 : if (pEntry)
124 : {
125 0 : fCalibData = (AliEMCALCalibData*)pEntry->GetObject();
126 : }
127 : else
128 : {
129 : // HLTError("can not fetch object \"%s\" from CDB", path);
130 0 : return -1;
131 : }
132 0 : }
133 0 : if(!fCalibData) return -1;
134 0 : return 0;
135 0 : }
|