Line data Source code
1 : /**************************************************************************
2 : * This file is property of and copyright by the ALICE HLT Project *
3 : * All rights reserved. *
4 : * *
5 : * Primary Authors: Markus Fasel *
6 : * *
7 : * Permission to use, copy, modify and distribute this software and its *
8 : * documentation strictly for non-commercial purposes is hereby granted *
9 : * without fee, provided that the above copyright notice appears in all *
10 : * copies and that both the copyright notice and this permission notice *
11 : * appear in the supporting documentation. The authors make no claims *
12 : * about the suitability of this software for any purpose. It is *
13 : * provided "as is" without express or implied warranty. *
14 : **************************************************************************/
15 :
16 :
17 : #include "AliCaloRawAnalyzer.h"
18 : #include "AliCaloBunchInfo.h"
19 : #include "AliCaloFitResults.h"
20 : #include "AliDAQ.h"
21 : #include "AliHLTEMCALRawAnalyzerComponentTRU.h"
22 : #include "AliHLTEMCALDefinitions.h"
23 : #include "AliHLTCaloChannelDataHeaderStruct.h"
24 : #include "AliHLTCaloChannelDataStruct.h"
25 : #include "AliHLTEMCALMapper.h"
26 : #include "AliHLTCaloSanityInspector.h"
27 : #include "AliHLTEMCALTRURawDigitMaker.h"
28 : #include "AliRawReaderMemory.h"
29 : #include "AliCaloRawStreamV3.h"
30 : #include "AliHLTCaloConstantsHandler.h"
31 : #include "AliHLTCaloChannelRawDataStruct.h"
32 : #include "AliLog.h"
33 : #include "TStopwatch.h"
34 :
35 : #include "AliCaloRawAnalyzerFactory.h"
36 :
37 : //#include "AliCaloConstants.h"
38 :
39 : //#include "AliCaloRawAnalyzer.h"
40 :
41 : //using namespace Algo;
42 :
43 : #include <vector>
44 : using namespace std;
45 :
46 6 : ClassImp(AliHLTEMCALRawAnalyzerComponentTRU);
47 :
48 3 : AliHLTEMCALRawAnalyzerComponentTRU::AliHLTEMCALRawAnalyzerComponentTRU( ):AliHLTCaloProcessor(),
49 9 : AliHLTCaloConstantsHandler("EMCAL"),
50 3 : fTRUhandler(0),
51 3 : fDebug(false)
52 18 : {
53 : //Constructor
54 :
55 6 : }
56 :
57 :
58 0 : AliHLTEMCALRawAnalyzerComponentTRU::~AliHLTEMCALRawAnalyzerComponentTRU()
59 12 : {
60 : //destructor
61 12 : }
62 :
63 : void
64 : AliHLTEMCALRawAnalyzerComponentTRU::GetInputDataTypes( vector <AliHLTComponentDataType>& list)
65 : {
66 0 : list.clear();
67 0 : list.push_back( AliHLTEMCALDefinitions::fgkDDLRawDataType | kAliHLTDataOriginEMCAL );
68 0 : }
69 :
70 :
71 : AliHLTComponentDataType
72 : AliHLTEMCALRawAnalyzerComponentTRU::GetOutputDataType()
73 : {
74 : //comment
75 0 : return AliHLTEMCALDefinitions::fgkTriggerRawDigitDataType;
76 : }
77 :
78 : AliHLTComponent* AliHLTEMCALRawAnalyzerComponentTRU::Spawn(){
79 0 : return new AliHLTEMCALRawAnalyzerComponentTRU;
80 0 : }
81 :
82 : const char*
83 : AliHLTEMCALRawAnalyzerComponentTRU::GetComponentID()
84 : {
85 : // component id
86 300 : return "EmcalTruAnalyzer";
87 : }
88 :
89 :
90 : int
91 : AliHLTEMCALRawAnalyzerComponentTRU::DoInit( int argc, const char** argv )
92 : {
93 : //See base class for documentation
94 : int iResult=0;
95 :
96 0 : for(int i = 0; i < argc; i++)
97 : {
98 0 : if(!strcmp("-suppressalilogwarnings", argv[i]))
99 : {
100 0 : AliLog::SetGlobalLogLevel(AliLog::kError); //PHOS sometimes produces bad data -> Fill up the HLT logs...
101 0 : }
102 : }
103 :
104 0 : fTRUhandler = new AliHLTEMCALTRURawDigitMaker();
105 0 : fTRUhandler->Initialize(GetRunNo());
106 :
107 0 : return iResult;
108 0 : }
109 :
110 :
111 : int
112 : AliHLTEMCALRawAnalyzerComponentTRU::DoDeinit()
113 : {
114 : //comment
115 0 : if(fTRUhandler) delete fTRUhandler;
116 :
117 0 : return 0;
118 : }
119 :
120 : void
121 : AliHLTEMCALRawAnalyzerComponentTRU::PrintDebugInfo()
122 : {
123 : //comment
124 0 : static TStopwatch watch; //CRAP PTH
125 : static double wlast = -1;
126 : static double wcurrent = 0;
127 :
128 0 : if( true == fDebug )
129 : {
130 0 : if( fCaloEventCount %1000 == 0 )
131 : {
132 0 : cout << __FILE__ << __LINE__ << " : Processing event " << fCaloEventCount << endl;
133 0 : wlast = wcurrent;
134 0 : wcurrent = watch.RealTime();
135 0 : cout << __FILE__ << __LINE__ << "The event rate is " <<
136 0 : 1000/( wcurrent - wlast ) << " Hz" << endl; watch.Start(kFALSE);
137 0 : }
138 : }
139 0 : }
140 :
141 :
142 : void
143 : AliHLTEMCALRawAnalyzerComponentTRU::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier )
144 : {
145 : //comment
146 0 : constBase = 0;
147 0 : inputMultiplier = 1.5;
148 0 : }
149 :
150 :
151 : bool
152 : AliHLTEMCALRawAnalyzerComponentTRU::CheckInputDataType(const AliHLTComponentDataType &datatype)
153 : {
154 : //comment
155 0 : vector <AliHLTComponentDataType> validTypes;
156 0 : GetInputDataTypes(validTypes);
157 :
158 0 : for(UInt_t i=0; i < validTypes.size(); i++ )
159 : {
160 0 : if ( datatype == validTypes.at(i) )
161 : {
162 0 : return true;
163 : }
164 : }
165 :
166 : HLTDebug("Invalid Datatype");
167 0 : return false;
168 0 : }
169 :
170 :
171 : int
172 : AliHLTEMCALRawAnalyzerComponentTRU::DoEvent( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
173 : AliHLTComponentTriggerData& /*trigData*/,
174 : AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size, vector<AliHLTComponentBlockData>& outputBlocks )
175 : {
176 : //comment
177 0 : if(!IsDataEvent())
178 : {
179 0 : size = 0;
180 0 : return 0;
181 : }
182 0 : if( true == fDebug )
183 0 : { PrintDebugInfo();
184 0 : };
185 :
186 : Int_t blockSize = -1;
187 0 : UInt_t totSize = 0;
188 : const AliHLTComponentBlockData* iter = NULL;
189 : unsigned long ndx;
190 0 : AliHLTUInt32_t availableSize = size;
191 :
192 0 : for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
193 : {
194 0 : iter = blocks+ndx;
195 0 : if( ! CheckInputDataType(iter->fDataType) )
196 : {
197 : continue;
198 : }
199 :
200 0 : if(iter->fSpecification >= AliDAQ::GetFirstSTUDDL()) continue;
201 :
202 0 : blockSize = DoIt(iter, outputPtr, availableSize, totSize); // Processing the block
203 0 : totSize += blockSize; //Keeping track of the used size
204 0 : availableSize -= blockSize;
205 0 : AliHLTComponentBlockData bdChannelData;
206 0 : FillBlockData( bdChannelData );
207 0 : bdChannelData.fOffset = totSize-blockSize; //FIXME
208 0 : bdChannelData.fSize = blockSize;
209 0 : bdChannelData.fDataType = GetOutputDataType();
210 0 : bdChannelData.fSpecification = iter->fSpecification;
211 0 : outputBlocks.push_back(bdChannelData);
212 0 : outputPtr += blockSize; //Updating position of the output buffer
213 0 : }
214 :
215 0 : fCaloEventCount++;
216 0 : size = totSize; //telling the framework how much buffer space we have used.
217 :
218 : return 0;
219 :
220 0 : }//end DoEvent
221 :
222 :
223 :
224 : Int_t
225 : AliHLTEMCALRawAnalyzerComponentTRU::DoIt(const AliHLTComponentBlockData* iter, AliHLTUInt8_t* outputPtr, const AliHLTUInt32_t size, UInt_t& totSize)
226 : {
227 : //comment
228 : int tmpsize= 0;
229 : Int_t crazyness = 0;
230 : Int_t nSamples = 0;
231 : Short_t channelCount = 0;
232 :
233 0 : AliHLTCaloTriggerRawDigitDataStruct *digitDataPtr = reinterpret_cast<AliHLTCaloTriggerRawDigitDataStruct*>(outputPtr);
234 0 : AliRawReaderMemory rawReaderMemoryPtr;
235 0 : rawReaderMemoryPtr.SetMemory( reinterpret_cast<UChar_t*>( iter->fPtr ), static_cast<ULong_t>( iter->fSize ) );
236 0 : rawReaderMemoryPtr.SetEquipmentID( iter->fSpecification + fCaloConstants->GetDDLOFFSET() );
237 :
238 0 : AliCaloRawStreamV3 altroRawStreamPtr(&rawReaderMemoryPtr, "EMCAL");
239 0 : rawReaderMemoryPtr.Reset();
240 0 : rawReaderMemoryPtr.NextEvent();
241 :
242 :
243 0 : fTRUhandler->SetRawReader(&altroRawStreamPtr);
244 0 : fTRUhandler->Reset();
245 :
246 0 : if(altroRawStreamPtr.NextDDL()) {
247 : int cnt = 0;
248 0 : while(altroRawStreamPtr.NextChannel()) {
249 0 : if( altroRawStreamPtr.GetCaloFlag() == 2) { // These are the level1 triggers
250 0 : std::vector <AliCaloBunchInfo> bunchlist;
251 0 : while (altroRawStreamPtr.NextBunch())
252 0 : bunchlist.push_back( AliCaloBunchInfo(altroRawStreamPtr.GetStartTimeBin(), altroRawStreamPtr.GetBunchLength(), altroRawStreamPtr.GetSignals() ) );
253 0 : if (bunchlist.size() == 0) continue;
254 :
255 0 : fTRUhandler->Add(bunchlist);
256 0 : }
257 : }
258 0 : }
259 :
260 0 : AliHLTUInt32_t availableSize = size;
261 : HLTDebug("Number of TRU digits: %d",fTRUhandler->GetNumberOfRawDigits());
262 0 : tmpsize = fTRUhandler->WriteRawDigitsBuffer(digitDataPtr, availableSize);
263 :
264 : /*
265 : std::cout << "Found TRU raw digits: " << std::endl;
266 : for(Int_t idig = 0; idig < fTRUhandler->GetNumberOfRawDigits(); idig++){
267 : PrintRawDigit(digitDataPtr[idig]);
268 : }
269 : */
270 : return tmpsize;
271 0 : }
272 :
273 :
274 :
|