]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/EMCAL/AliHLTEMCALRawHistoMaker.cxx
FindFASTJET
[u/mrichter/AliRoot.git] / HLT / EMCAL / AliHLTEMCALRawHistoMaker.cxx
1 /**************************************************************************
2  * This file is property of and copyright by the ALICE HLT Project        * 
3  * All rights reserved.                                                   *
4  * INFN Laboratori Nazionali di Frascati                                  *
5  * Primary Authors: Federico Ronchetti                                    *
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  * @file   AliHLTEMCALRawHistoMaker.cxx
18  * @author Federico Ronchetti
19  * @date 
20  * @brief  Online Monitoring Histogram maker for EMCAL  
21  */
22   
23
24 #include "AliHLTEMCALRawHistoMaker.h"
25 #include "AliHLTEMCALConstants.h"
26 #include "AliHLTEMCALMapper.h"
27 //#include "AliHLTCaloChannelDataStruct.h"
28
29 #include "AliHLTCaloChannelDataHeaderStruct.h"
30 #include "AliHLTCaloSharedMemoryInterfacev2.h"
31
32 //#include "AliCaloRawAnalyzer.h"
33 //#include "AliCaloBunchInfo.h"
34 //#include "AliCaloFitResults.h"
35
36
37
38
39 ClassImp(AliHLTEMCALRawHistoMaker);
40
41 AliHLTEMCALRawHistoMaker::AliHLTEMCALRawHistoMaker():
42   AliHLTCaloConstantsHandler("EMCAL"),
43   fShmPtr(0),
44   fMapperPtr(0),
45   //  fRawCounterMemoryPtr(0),
46   //fAltroRawStreamPtr(0),
47   //fRawStreamPtr(0),
48   //fSTURawStreamPtr(0),
49   //fAnalyzerPtr(0),
50   fEMCALConstants(NULL),
51   hList(0),
52   fAmp(0), fTime(0), fAT(0), fCellVsEne(0),
53   fClusterReaderPtr(0)
54
55 {
56   // See header file for documentation
57
58   fShmPtr = new AliHLTCaloSharedMemoryInterfacev2("EMCAL");
59
60   //fRawCounterMemoryPtr = new AliRawReaderMemory();
61
62   //fAltroRawStreamPtr = new AliAltroRawStreamV3(fRawCounterMemoryPtr);
63
64   //fRawStreamPtr = new AliCaloRawStreamV3(fRawCounterMemoryPtr, "EMCAL");
65
66   //fSTURawStreamPtr = new AliEMCALTriggerSTURawStream(fRawCounterMemoryPtr);
67
68   fEMCALConstants = new AliHLTEMCALConstants();
69
70   fClusterReaderPtr = new AliHLTCaloClusterReader();
71
72   // Booking histograms
73
74   char id[100];
75   char title[100];
76  
77   hList = new TObjArray;
78
79   // channel histograms
80   fAmp = new TProfile2D *[fCaloConstants->GetNMODULES()];
81   fTime = new TProfile2D *[fCaloConstants->GetNMODULES()];
82   fAT = new TH2F *[fCaloConstants->GetNMODULES()];
83   
84   // cluster histograms
85   fCellVsEne = new TH2F  *[fCaloConstants->GetNMODULES()];
86
87   //  fCellVsClus = new TH1F ("fCellVsClus","",100,0,50);
88   //hList->Add(fCellVsClus);
89
90
91   for (int i=0; i<fCaloConstants->GetNMODULES(); i++) {
92
93
94
95     //sprintf(title, "Row vs Col : SM %d ", i);
96     //sprintf(id, "hAmp%d", i);
97     //hAmp[i] = new TProfile2D(id,title, 48, -0.5, 47.5, 24, -0.5, 23.5); 
98     //sprintf(id, "hTime%d", i);
99     //hTime[i] = new TProfile2D(id,title, 48, -0.5, 47.5, 24, -0.5, 23.5); 
100
101
102     sprintf(title, "X_Z AMP: SM %d ", i);
103     sprintf(id, "fAmp%d", i);
104     fAmp[i] = new TProfile2D(id,title, 48, -0.5, 47.5, 24, -0.5, 23.5); 
105     
106     hList->Add(fAmp[i]);
107     
108     sprintf(title, "X_Z TIME: SM %d ", i);
109     sprintf(id, "fTime%d", i);
110     fTime[i] = new TProfile2D(id,title, 48, -0.5, 47.5, 24, -0.5, 23.5); 
111
112     hList->Add(fTime[i]);
113
114     sprintf(title, "AMP_TIME: SM %d ", i);
115     sprintf(id, "fAT%d", i);
116     fAT[i] = new TH2F(id,title, 1024, -0.5, 1023.5, 200, -0.5, 199.5);
117     
118     hList->Add(fAT[i]);
119
120     sprintf(title, "Cell_Energy: SM %d ", i);
121     sprintf(id, "fCellVsEne%d", i);
122     fCellVsEne[i] = new TH2F(id,title,50 ,0, 50, 10, 0, 10);
123     
124     hList->Add(fCellVsEne[i]);
125
126   }
127   
128   
129 }
130
131 AliHLTEMCALRawHistoMaker::~AliHLTEMCALRawHistoMaker() 
132 {
133   //See header file for documentation
134 }
135
136 // Pointer to histograms objects
137 TObjArray* AliHLTEMCALRawHistoMaker::GetHistograms()
138 {
139   return hList;
140 }
141
142
143 Int_t
144 AliHLTEMCALRawHistoMaker::MakeHisto(AliHLTCaloChannelDataHeaderStruct* channelDataHeader,  
145                                     AliHLTCaloClusterHeaderStruct *caloClusterHeaderPtr, 
146                                     int beverbose)
147 {
148         //int tmpsize =  0;
149         Int_t crazyness          = 0;
150         Int_t nSamples           = 0;
151         Short_t channelCount     = 0;
152
153
154         // Channel variables
155         AliHLTCaloCoordinate coord;
156         AliHLTCaloChannelDataStruct* currentchannel = 0;
157
158
159         // Cluster variables
160         // Pointer to Cluster struture
161         AliHLTCaloClusterDataStruct* caloClusterStructPtr = 0;
162         Int_t nClusters = 0;
163
164         if (!caloClusterHeaderPtr) {
165                   
166         } else {
167           
168           // stuff to handle clusters here
169
170           fClusterReaderPtr->SetMemory(caloClusterHeaderPtr);
171           
172           while((caloClusterStructPtr = fClusterReaderPtr->NextCluster()) != 0)
173           
174             { 
175                
176               cout << "cluster type: " << caloClusterStructPtr->fClusterType << endl;
177                
178               cout << " COORDINATES FROM HISTOMAKER: " << 
179                 " fX:" << caloClusterStructPtr->fGlobalPos[0] <<
180                 " fY:" << caloClusterStructPtr->fGlobalPos[1] <<
181                 " fZ:" << caloClusterStructPtr->fGlobalPos[2] <<
182                 " fModule: " << caloClusterStructPtr->fModule << 
183                 " fCell: " << caloClusterStructPtr->fNCells   <<
184                 " fEnergy " << caloClusterStructPtr->fEnergy << endl;
185              
186               fCellVsEne[caloClusterStructPtr->fModule]->Fill(caloClusterStructPtr->fNCells, caloClusterStructPtr->fEnergy);
187                   
188
189               UShort_t *idArrayPtr = new UShort_t[caloClusterStructPtr->fNCells];
190               Double32_t *ampFracArrayPtr = new Double32_t[caloClusterStructPtr->fNCells];
191       
192               for(UInt_t index = 0; index < caloClusterStructPtr->fNCells; index++)
193                 {
194                   fClusterReaderPtr->GetCell(caloClusterStructPtr, idArrayPtr[index], ampFracArrayPtr[index], index);
195                   printf("EM: cellId: %d\n", idArrayPtr[index]);;
196                 }
197
198               delete [] idArrayPtr;
199               delete [] ampFracArrayPtr;
200
201               nClusters++;
202
203             }
204           
205         }
206
207
208
209         // begin scan channel data and fill histograms
210
211
212         if (channelDataHeader) {
213          
214           fShmPtr->SetMemory(channelDataHeader);
215
216           currentchannel = fShmPtr->NextChannel();
217
218           while(currentchannel != 0) {
219           
220             fMapperPtr->ChannelId2Coordinate(currentchannel->fChannelID, coord);
221             
222             cout << " from histo maker ->>>>>>>>>>>>>>>>>>>>>>>>>>>>>> " << endl;
223             cout << " fX: " << coord.fX << " fZ: " << coord.fZ << endl;
224             cout << " channel ID: " << currentchannel->fChannelID << endl;
225             cout << " channel AMPLITUDE (called energy): " << currentchannel->fEnergy << endl;
226             cout << " channel time: " << currentchannel->fTime << endl;
227             
228             
229             fTime[coord.fModuleId]->Fill( coord.fZ,  coord.fX , currentchannel->fTime);
230             fAmp[coord.fModuleId]->Fill( coord.fZ,  coord.fX , currentchannel->fEnergy);
231             fAT[coord.fModuleId]->Fill(currentchannel->fEnergy, currentchannel->fTime);
232             
233             currentchannel = fShmPtr->NextChannel(); // Get the next channel
234             
235           }
236         }
237         
238
239 return (0); 
240 }