Line data Source code
1 : // @(#) $Id$
2 :
3 : /**************************************************************************
4 : * This file is property of and copyright by the ALICE HLT Project *
5 : * ALICE Experiment at CERN, All rights reserved. *
6 : * *
7 : * Primary Authors: Oystein Djuvsland <oysteind@ift.uib.no> *
8 : * for The ALICE HLT Project. *
9 : * *
10 : * Permission to use, copy, modify and distribute this software and its *
11 : * documentation strictly for non-commercial purposes is hereby granted *
12 : * without fee, provided that the above copyright notice appears in all *
13 : * copies and that both the copyright notice and this permission notice *
14 : * appear in the supporting documentation. The authors make no claims *
15 : * about the suitability of this software for any purpose. It is *
16 : * provided "as is" without express or implied warranty. *
17 : **************************************************************************/
18 :
19 : /** @file AliHLTCaloDigitPublisherComponent.cxx
20 : @author Oystein Djuvsland
21 : @date
22 : @brief Calo digit publisher component (input from offline).
23 : */
24 :
25 : // see header file for class documentation
26 : // or
27 : // refer to README to build package
28 : // or
29 : // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
30 :
31 : #include "AliHLTCaloDigitPublisherComponent.h"
32 : #include "AliRunLoader.h"
33 : #include "AliLog.h"
34 : #include "TTree.h"
35 : #include "AliHLTTPCDigitData.h"
36 : #include "AliHLTTPCDefinitions.h"
37 : #include "AliHLTTPCFileHandler.h"
38 : #include "AliHLTCaloDigitDataStruct.h"
39 : #include "AliHLTCaloDefinitions.h"
40 : #include "AliHLTEMCALDigitHandler.h"
41 : #include "AliHLTPHOSDigitHandler.h"
42 : #include "AliHLTEMCALDefinitions.h"
43 : #include "AliHLTPHOSDefinitions.h"
44 :
45 :
46 : /** ROOT macro for the implementation of ROOT specific class methods */
47 6 : ClassImp(AliHLTCaloDigitPublisherComponent)
48 :
49 6 : AliHLTCaloDigitPublisherComponent gAliHLTCaloDigitPublisherComponent;
50 :
51 3 : AliHLTCaloDigitPublisherComponent::AliHLTCaloDigitPublisherComponent() : AliHLTOfflineDataSource()
52 3 : ,fDigitHandler(0)
53 3 : ,fSpecification(0)
54 3 : ,fDataType(kAliHLTAnyDataType)
55 3 : ,fModule(-1)
56 15 : {
57 : // see header file for class documentation
58 : // or
59 : // refer to README to build package
60 : // or
61 : // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
62 6 : }
63 :
64 0 : AliHLTCaloDigitPublisherComponent::~AliHLTCaloDigitPublisherComponent()
65 12 : {
66 : // see header file for class documentation
67 3 : DoDeinit();
68 6 : }
69 :
70 : const char* AliHLTCaloDigitPublisherComponent::GetComponentID()
71 : {
72 : // see header file for class documentation
73 372 : return "CaloDigitPublisher";
74 : }
75 :
76 : AliHLTComponentDataType AliHLTCaloDigitPublisherComponent::GetOutputDataType()
77 : {
78 0 : return fDataType;
79 : }
80 :
81 : void AliHLTCaloDigitPublisherComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
82 : {
83 0 : constBase=1000;
84 0 : inputMultiplier=10;
85 0 : }
86 :
87 : AliHLTComponent* AliHLTCaloDigitPublisherComponent::Spawn()
88 : {
89 : // see header file for class documentation
90 0 : return new AliHLTCaloDigitPublisherComponent;
91 0 : }
92 :
93 : int AliHLTCaloDigitPublisherComponent::DoInit( int argc, const char** argv )
94 : {
95 : // see header file for class documentation
96 : // scan arguments
97 0 : for (Int_t i = 0; i < argc; i++)
98 : {
99 0 : if (!strcmp(argv[i], "-detector"))
100 : {
101 0 : if (!strcmp(argv[i + 1], "EMCAL"))
102 : {
103 :
104 0 : fDigitHandler = AliHLTEMCALDigitHandler::Instance();
105 0 : if (fDigitHandler) fDigitHandler->Init(AliRunLoader::Instance());
106 : else
107 : {
108 0 : HLTFatal("Could not create EMCAL digit handler");
109 0 : return -1;
110 : }
111 0 : fDataType = fDigitHandler->GetDataType();
112 0 : }
113 0 : else if (!strcmp(argv[i + 1], "PHOS"))
114 : {
115 0 : fDigitHandler = AliHLTPHOSDigitHandler::Instance();
116 0 : if (fDigitHandler) fDigitHandler->Init(AliRunLoader::Instance());
117 : else
118 : {
119 0 : HLTFatal("Could not create PHOS digit handler");
120 0 : return -1;
121 : }
122 0 : fDataType = fDigitHandler->GetDataType();
123 0 : }
124 : }
125 0 : if(!strcmp(argv[i], "-module"))
126 : {
127 0 : fModule = atoi(argv[i+1]);
128 0 : }
129 0 : if(!strcmp(argv[i], "-spec"))
130 : {
131 0 : fSpecification = atoi(argv[i+1]);
132 : HLTDebug("Data specification: 0x%x", fSpecification);
133 0 : }
134 : }
135 0 : return 0;
136 0 : }
137 :
138 : int AliHLTCaloDigitPublisherComponent::DoDeinit()
139 : {
140 : // see header file for class documentation
141 : int iResult=0;
142 6 : return iResult;
143 : }
144 :
145 : int AliHLTCaloDigitPublisherComponent::GetEvent(const AliHLTComponentEventData& /*evtData*/,
146 : AliHLTComponentTriggerData& /*trigData*/,
147 : AliHLTUInt8_t* outputPtr,
148 : AliHLTUInt32_t& osize,
149 : vector<AliHLTComponentBlockData>& outputBlocks)
150 : {
151 :
152 : // see header file for class documentation
153 : int iResult=0;
154 0 : AliHLTUInt32_t capacity=osize;
155 0 : osize=0;
156 :
157 0 : AliHLTCaloDigitDataStruct *digOut = reinterpret_cast<AliHLTCaloDigitDataStruct*>(outputPtr);
158 :
159 : // process data events only
160 0 : if (!IsDataEvent()) return 0;
161 :
162 0 : if (outputPtr==NULL || capacity==0)
163 : {
164 0 : HLTError("no target buffer provided");
165 0 : return -EFAULT;
166 : }
167 :
168 0 : int event=GetEventCount();
169 :
170 0 : fDigitHandler->ProcessEvent(event);
171 :
172 0 : Int_t nDigs = fDigitHandler->GetDigits(fModule, digOut);
173 0 : if (nDigs > 0)
174 : {
175 0 : AliHLTComponentBlockData bd;
176 0 : FillBlockData( bd );
177 0 : bd.fOffset = 0;
178 0 : bd.fSize = nDigs*sizeof(AliHLTCaloDigitDataStruct);
179 0 : bd.fDataType = fDataType;
180 0 : bd.fSpecification = fSpecification;
181 0 : outputBlocks.push_back(bd);
182 0 : }
183 :
184 : return iResult;
185 0 : }
|