added -verbose option to prevent couts and warnings during normal execution
[u/mrichter/AliRoot.git] / HLT / EMCAL / AliHLTEMCALRawHistoMaker.cxx
CommitLineData
fdf6f4e9 1/**************************************************************************\r
2 * This file is property of and copyright by the ALICE HLT Project * \r
3 * All rights reserved. *\r
4 * INFN Laboratori Nazionali di Frascati *\r
5 * Primary Authors: Federico Ronchetti *\r
6 * *\r
7 * Permission to use, copy, modify and distribute this software and its *\r
8 * documentation strictly for non-commercial purposes is hereby granted *\r
9 * without fee, provided that the above copyright notice appears in all *\r
10 * copies and that both the copyright notice and this permission notice *\r
11 * appear in the supporting documentation. The authors make no claims *\r
12 * about the suitability of this software for any purpose. It is * \r
13 * provided "as is" without express or implied warranty. *\r
14 **************************************************************************/\r
15\r
16/**\r
17 * @file AliHLTEMCALRawHistoMaker.cxx\r
18 * @author Federico Ronchetti\r
19 * @date \r
20 * @brief Histogram maker/pusher for EMCAL HLT \r
21 */\r
22 \r
23\r
24#include "AliHLTEMCALRawHistoMaker.h"\r
25#include "AliHLTEMCALConstants.h"\r
26#include "AliHLTEMCALMapper.h"\r
27#include "AliHLTCaloChannelDataStruct.h"\r
28#include "AliHLTCaloChannelDataHeaderStruct.h"\r
29#include "AliHLTCaloSharedMemoryInterfacev2.h"\r
30//#include "AliHLTCaloRawAnalyzer.h"\r
31#include "AliCaloRawAnalyzer.h"\r
32#include "AliCaloBunchInfo.h"\r
33#include "AliCaloFitResults.h"\r
34\r
35ClassImp(AliHLTEMCALRawHistoMaker);\r
36\r
37AliHLTEMCALRawHistoMaker::AliHLTEMCALRawHistoMaker():\r
38 AliHLTCaloConstantsHandler("EMCAL"),\r
39 fShmPtr(0),\r
40 fMapperPtr(0),\r
41 fRawCounterMemoryPtr(0),\r
42 fAltroRawStreamPtr(0),\r
43 fRawStreamPtr(0),\r
44 fSTURawStreamPtr(0),\r
45 fAnalyzerPtr(0),\r
46 fEMCALConstants(NULL),
47 hList(0),
4479217f 48 fChannelEMap(0), fChannelTMap(0), fChannelETMap(0), h2DTRU(0), h2DSTU(0)\r
49\r
fdf6f4e9 50{\r
51 // See header file for documentation\r
52\r
53 fShmPtr = new AliHLTCaloSharedMemoryInterfacev2("EMCAL");\r
54\r
55 fRawCounterMemoryPtr = new AliRawReaderMemory();\r
56\r
57 fAltroRawStreamPtr = new AliAltroRawStreamV3(fRawCounterMemoryPtr);\r
58\r
59 fRawStreamPtr = new AliCaloRawStreamV3(fRawCounterMemoryPtr, "EMCAL");\r
60\r
61 fSTURawStreamPtr = new AliEMCALTriggerSTURawStream(fRawCounterMemoryPtr);\r
62\r
63 fEMCALConstants = new AliHLTEMCALConstants();
64\r
65\r
66 // Booking sample histograms\r
67\r
68 char id[100];\r
69 char title[100];\r
70 \r
4479217f 71 hList = new TObjArray;\r
72\r
fdf6f4e9 73 fChannelEMap = new TProfile2D *[fCaloConstants->GetNMODULES()];\r
74 fChannelTMap = new TProfile2D *[fCaloConstants->GetNMODULES()];\r
75 fChannelETMap = new TH2F *[fCaloConstants->GetNMODULES()];\r
76 \r
4479217f 77 h2DTRU = new TH2I ("h2DTRU","",24,0,24,4,0,4);\r
78 hList->Add(h2DTRU);\r
79\r
80 h2DSTU = new TH2I ("h2DSTU","",24,0,24,4,0,4);\r
81 hList->Add(h2DSTU);\r
82\r
fdf6f4e9 83 \r
84 for (int i=0; i<fCaloConstants->GetNMODULES(); i++) {\r
85 sprintf(title, "E(X vs Z): SM %d ", i);\r
86 sprintf(id, "fChannelEMap%d", i);\r
87 fChannelEMap[i] = new TProfile2D(id,title,48 ,0, 47, 24, 0, 23);\r
88 \r
89 hList->Add(fChannelEMap[i]);\r
90 \r
91 sprintf(title, "T(X vs Z): SM %d ", i);\r
92 sprintf(id, "fChannelTMap%d", i);\r
93 fChannelTMap[i] = new TProfile2D(id,title,48 ,0, 47, 24, 0, 23);\r
94\r
95 hList->Add(fChannelTMap[i]);\r
96\r
97 printf(title, "(E vs T): SM %d ", i);\r
98 sprintf(id, "fChannelETMap%d", i);\r
99 fChannelETMap[i] = new TH2F(id,title,100 ,0, 50, 100, 0, 500);\r
100 \r
101 hList->Add(fChannelETMap[i]);\r
102 }\r
103 \r
104 \r
105}\r
106\r
107AliHLTEMCALRawHistoMaker::~AliHLTEMCALRawHistoMaker() \r
108{\r
109 //See header file for documentation\r
110}\r
111\r
112// Pointer for histograms objects\r
113TObjArray* AliHLTEMCALRawHistoMaker::GetHistograms()\r
114{\r
115 return hList;\r
116}\r
117\r
118\r
119Int_t\r
120AliHLTEMCALRawHistoMaker::MakeHisto(AliHLTCaloChannelDataHeaderStruct* channelDataHeader,\r
121 const AliHLTComponentBlockData* iter, AliHLTUInt8_t* outputPtr,\r
fb43b5cd 122 const AliHLTUInt32_t size, int beverbose)\r
fdf6f4e9 123{\r
fb43b5cd 124 //int tmpsize = 0;\r
fdf6f4e9 125 Int_t crazyness = 0;\r
126 Int_t nSamples = 0;\r
127 Short_t channelCount = 0;\r
128\r
129 AliHLTCaloCoordinate coord;
fdf6f4e9 130 AliHLTCaloChannelDataStruct* currentchannel = 0;\r
fdf6f4e9 131 fShmPtr->SetMemory(channelDataHeader);\r
132\r
133 AliHLTCaloChannelDataHeaderStruct *channelDataHeaderPtr = reinterpret_cast<AliHLTCaloChannelDataHeaderStruct*>(outputPtr);\r
134 AliHLTCaloChannelDataStruct *channelDataPtr = reinterpret_cast<AliHLTCaloChannelDataStruct*>(outputPtr+sizeof(AliHLTCaloChannelDataHeaderStruct));\r
135\r
4479217f 136 fRawCounterMemoryPtr->SetMemory( reinterpret_cast<UChar_t*>( iter->fPtr ), static_cast<ULong_t>( iter->fSize ) );\r
fdf6f4e9 137 fRawCounterMemoryPtr->SetEquipmentID( fMapperPtr->GetDDLFromSpec( iter->fSpecification) + fCaloConstants->GetDDLOFFSET() );\r
138 fRawCounterMemoryPtr->Reset();\r
fdf6f4e9 139\r
4479217f 140 //fRawCounterMemoryPtr->NextEvent();\r
141\r
142 //--- from STU macro\r
143 //while ( rawReader->NextEvent() )\r
144\r
145 while (fRawCounterMemoryPtr->NextEvent())\r
146 {\r
147 fRawCounterMemoryPtr->Reset();\r
148 fRawCounterMemoryPtr->Select("EMCAL",44);\r
149\r
150 const UInt_t* evtId = fRawCounterMemoryPtr->GetEventId();\r
151 int evno_raw = (int)evtId[0];\r
152\r
153 UInt_t eventType = fRawCounterMemoryPtr->GetType();\r
154\r
fb43b5cd 155 if (beverbose)\r
156 cout << "I-RAWHISTOMAKER: event type: " << eventType << endl;\r
4479217f 157\r
158// if (eventType != AliRawEventHeaderBase::kPhysicsEvent) continue;\r
159\r
160// fRawCounterMemoryPtr->DumpData();\r
161\r
162// fRawCounterMemoryPtr->Reset();\r
163\r
164 fSTURawStreamPtr->ReadPayLoad();\r
165// fSTURawStreamPtr->DumpPayLoad("ALL");\r
166\r
167 UInt_t adc[96];\r
168\r
169 for (Int_t i=0;i<96;i++)\r
170 adc[i] = 0;\r
171\r
172 fSTURawStreamPtr->GetADC(29, adc);\r
173\r
174 for (Int_t i=0;i<96;i++)\r
175 {\r
176 Int_t x = i / 4;\r
177 Int_t y = i % 4;\r
178\r
179 h2DSTU->Fill( x , y , adc[i] );\r
180 }\r
181\r
182 fRawCounterMemoryPtr->Reset();\r
183 fRawCounterMemoryPtr->Select("EMCAL",0,43);\r
184\r
185 while (fRawStreamPtr->NextDDL())\r
186 {\r
187 Int_t iRCU = fRawStreamPtr->GetDDLNumber() % 2;\r
188\r
189 while (fRawStreamPtr->NextChannel())\r
190 {\r
191 Int_t iSM = fRawStreamPtr->GetModule();\r
192\r
193 Int_t iTRUId = 3 * iSM + iRCU * fRawStreamPtr->GetBranch() + iRCU;\r
194\r
195 if (iSM==0)\r
196 {\r
197 Int_t nsamples = 0;\r
198 vector<AliCaloBunchInfo> bunchlist;\r
199 while (fRawStreamPtr->NextBunch())\r
200 {\r
201 nsamples += fRawStreamPtr->GetBunchLength();\r
202 bunchlist.push_back( AliCaloBunchInfo(fRawStreamPtr->GetStartTimeBin(), fRawStreamPtr->GetBunchLength(), fRawStreamPtr->GetSignals() ) );\r
203 }\r
204\r
205 Int_t max = 0;\r
206\r
207 for (std::vector<AliCaloBunchInfo>::iterator itVectorData = bunchlist.begin(); itVectorData != bunchlist.end(); itVectorData++)\r
208 {\r
209 AliCaloBunchInfo bunch = *(itVectorData);\r
210\r
211 const UShort_t* sig = bunch.GetData();\r
212 Int_t startBin = bunch.GetStartBin();\r
213\r
214 for (Int_t iS = 0; iS < bunch.GetLength(); iS++)\r
215 {\r
216 if ( sig[iS] > max ) max = sig[iS];\r
217 }\r
218 }\r
219\r
220 if (nsamples) // this check is needed for when we have zero-supp. on, but not sparse readout\r
221 {\r
222 if (fRawStreamPtr->IsTRUData() && fRawStreamPtr->GetColumn() < 96)\r
223 {\r
224 if (iTRUId == 2)\r
225 {\r
226 Int_t x = fRawStreamPtr->GetColumn() / 4;\r
227 Int_t y = fRawStreamPtr->GetColumn() % 4;\r
228\r
229 h2DTRU->Fill( x , y , max );\r
230 }\r
231 }\r
232 }\r
233 }\r
234 }\r
235 }\r
236\r
237// c_0->cd(1);\r
238// h2DTRU->Draw("TEXT");\r
239//\r
240// c_0->cd(2);\r
241// h2DSTU->Draw("TEXT");\r
242//\r
243// c_0->Update();\r
244//\r
245// h2DTRU->Reset();\r
246// h2DSTU->Reset();\r
247 }\r
248\r
249 //--- end of while\r
250\r
251\r
252//------ FIXME\r
253//------ old stuff to be removed or re-utilized\r
fdf6f4e9 254 //fRawDataWriter->NewEvent( );\r
255\r
256 if(fAltroRawStreamPtr->NextDDL())\r
257 {\r
258 int cnt = 0;\r
259 int fOffset = 0;\r
4479217f 260\r
fdf6f4e9 261 while( fAltroRawStreamPtr->NextChannel() )\r
262 {\r
263 // cout << __FILE__ << ":" << __LINE__ << ":" <<__FUNCTION__ << "T3" << endl;\r
264 if( fAltroRawStreamPtr->GetHWAddress() < 128 || ( fAltroRawStreamPtr->GetHWAddress() ^ 0x800) < 128 )\r
265 {\r
266 continue;\r
267 }\r
268 else\r
269 {\r
270 ++ cnt;\r
271 UShort_t* firstBunchPtr = 0;\r
272 int chId = fMapperPtr->GetChannelID(iter->fSpecification, fAltroRawStreamPtr->GetHWAddress());\r
4479217f 273 //HLTError("Channel HW address: %d", fAltroRawStreamPtr->GetHWAddress());\r
fdf6f4e9 274\r
fdf6f4e9 275\r
4479217f 276 //cout << fRawStreamPtr->GetCaloFlag() << endl;\r
fdf6f4e9 277 // return 1;\r
4479217f 278\r
fdf6f4e9 279 vector <AliCaloBunchInfo> bvctr;\r
280 while( fAltroRawStreamPtr->NextBunch() == true )\r
281 {\r
4479217f 282 bvctr.push_back( AliCaloBunchInfo( fAltroRawStreamPtr->GetStartTimeBin(), fAltroRawStreamPtr->GetBunchLength(), fAltroRawStreamPtr->GetSignals() ) );\r
fdf6f4e9 283\r
284 nSamples = fAltroRawStreamPtr->GetBunchLength();\r
285\r
286\r
287 // fRawDataWriter->WriteBunchData( fAltroRawStreamPtr->GetSignals(), nSamples, fAltroRawStreamPtr->GetEndTimeBin() );\r
288 firstBunchPtr = const_cast< UShort_t* >( fAltroRawStreamPtr->GetSignals() );\r
289 }\r
290\r
291 //return 1;\r
292\r
293\r
294 // fAnalyzerPtr->SetData( firstBunchPtr, nSamples);\r
295 AliCaloFitResults res = fAnalyzerPtr->Evaluate( bvctr, fAltroRawStreamPtr->GetAltroCFG1(), fAltroRawStreamPtr->GetAltroCFG2() );\r
296\r
297 HLTDebug("Channel energy: %f, max sig: %d, gain = %d, x = %d, z = %d", res.GetAmp(), res.GetMaxSig(), (chId >> 12)&0x1, chId&0x3f, (chId >> 6)&0x3f);\r
298\r
299 // if(fAnalyzerPtr->GetTiming() > fMinPeakPosition && fAnalyzerPtr->GetTiming() < fMaxPeakPosition)\r
300 {\r
301 channelDataPtr->fChannelID = chId;\r
302 channelDataPtr->fEnergy = static_cast<Float_t>( res.GetAmp() ) - fOffset;\r
303\r
304 channelDataPtr->fTime = static_cast<Float_t>( res.GetTof() );\r
305 channelDataPtr->fCrazyness = static_cast<Short_t>(crazyness);\r
306 channelCount++;\r
307 channelDataPtr++; // Updating position of the free output.\r
308 }\r
309 }\r
310\r
311\r
312 }\r
313\r
314 //fRawDataWriter->NewChannel();\r
315\r
316 }\r
317\r
318\r
319//-------\r
320 currentchannel = fShmPtr->NextChannel();\r
fdf6f4e9 321\r
4479217f 322 while(currentchannel != 0) {\r
323\r
324 AliHLTCaloChannelRawDataStruct rawdata = fShmPtr->GetRawData();\r
325\r
326 fMapperPtr->ChannelId2Coordinate(currentchannel->fChannelID, coord);
327\r
328 fChannelTMap[coord.fModuleId]->Fill( coord.fZ, coord.fX , currentchannel->fTime);\r
329 fChannelEMap[coord.fModuleId]->Fill( coord.fZ, coord.fX , currentchannel->fEnergy);\r
330 fChannelETMap[coord.fModuleId]->Fill(currentchannel->fEnergy, currentchannel->fTime);\r
331
332 currentchannel = fShmPtr->NextChannel(); // Get the next channel\r
333\r
334 }\r
fdf6f4e9 335\r
fdf6f4e9 336\r
fdf6f4e9 337return (0); \r
338}