]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/MUONRawStreamTracker.C
Extended include path to cover all directories needed by all
[u/mrichter/AliRoot.git] / MUON / MUONRawStreamTracker.C
1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 *                                                                        *
4 * Author: The ALICE Off-line Project.                                    *
5 * Contributors are mentioned in the code where appropriate.              *
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 // Macro for reading tracker raw data
18 // Ch. Finck, Subatech Febuary
19 //
20
21 #if !defined(__CINT__) || defined(__MAKECINT__)
22
23 // RAW includes
24 #include "AliRawReaderDate.h"
25 #include "AliRawReaderFile.h"
26 #include "AliRawReaderRoot.h"
27
28 // MUON includes
29 #include "AliMUONRawStreamTracker.h"
30 #include "AliMUONDspHeader.h"
31 #include "AliMUONBlockHeader.h"
32 #include "AliMUONBusStruct.h"
33 #include "AliMUONDDLTracker.h"
34
35 #include "TStopwatch.h"
36
37 #endif
38
39 // Macro to read rawdata for tracker
40 // Ch. Finck, Subatech, April. 2006
41 //
42 // This macro is interfaced with AliRawReader for RAW
43 //
44 // There are 2 ways of reading the data : one where each intermediate structure
45 // (block, dsp, buspatch) is looped over, and one, using an iterator, where
46 // we're directly accessing the pad informations (charge).
47 //
48 // The different stucture of the payload are readout and stored in TClonesArray
49 // with AliMUONRawStreamTracker classe.
50 // The macro just simpy read again the TClonesArray contents.
51 // The parameter of each structure could be seen in the container classes
52 // AliMUONBlockHeader, AliMUONBlockHeader, AliMUONBusStruct.
53 // The class AliMUONDDLTracker manages the structure containers.
54 // The number of structures in the rawdata file could be set.
55 //
56 // 
57
58 void MUONRawStreamTrackerExpert(TString fileName = "./", Int_t maxEvent = 1000,  
59                                 Int_t minDDL = 0, Int_t maxDDL = 19)
60 {
61   /// Reads the data from fileName, using an "expert" mode where all substructures
62   /// are looped upon.
63   
64   TStopwatch timer;
65   timer.Start(kTRUE);
66   
67   AliRawReader* rawReader = 0x0;
68   
69   // check extention to choose the rawdata file format
70   if (fileName.EndsWith("/")) {
71     rawReader = new AliRawReaderFile(fileName); // DDL files
72   } else if (fileName.EndsWith(".root")) {
73     rawReader = new AliRawReaderRoot(fileName);
74   } else if (!fileName.IsNull()) {
75     rawReader = new AliRawReaderDate(fileName); // DATE file
76   }
77   
78   // raw stream
79   AliMUONRawStreamTracker* rawStream  = new AliMUONRawStreamTracker(rawReader);    
80   
81   // set the number of DDL block Dsp & buspatch structures that are PRESENT in the rawdata file
82   // it's NOT the number to be read.
83   // default wise set to 20, 2, 5 ans 5 respectively.
84   //    rawStream->SetMaxDDL(xx);
85   //    rawStream->SetMaxBlock(xx);
86   //    rawStream->SetMaxDsp(xx);
87   //    rawStream->SetMaxBus(xx);
88   
89   // containers
90   AliMUONDDLTracker*       ddlTracker = 0x0;
91   AliMUONBlockHeader*      blkHeader  = 0x0;
92   AliMUONDspHeader*        dspHeader  = 0x0;
93   AliMUONBusStruct*        busStruct  = 0x0;
94   
95   //   Loop over events  
96   Int_t iEvent = 0;
97   Int_t dataSize;
98   
99   while (rawReader->NextEvent()) {
100     
101     if (iEvent == maxEvent)
102       break;
103     
104     printf("Event %d\n",iEvent++);
105     
106     // read DDL while < 20 DDL
107     while(rawStream->NextDDL()) {
108       
109       if (rawStream->GetDDL() < minDDL || rawStream->GetDDL() > maxDDL)
110         continue;
111       
112       printf("\niDDL %d\n", rawStream->GetDDL());
113       
114       ddlTracker =  rawStream->GetDDLTracker();
115       
116       // loop over block structure
117       Int_t nBlock = ddlTracker->GetBlkHeaderEntries();
118       for(Int_t iBlock = 0; iBlock < nBlock ;iBlock++){
119         
120         blkHeader = ddlTracker->GetBlkHeaderEntry(iBlock);
121         printf("Block %d Total length %d\n",iBlock,blkHeader->GetTotalLength());
122        
123         // loop over DSP structure
124         Int_t nDsp = blkHeader->GetDspHeaderEntries();
125         for(Int_t iDsp = 0; iDsp < nDsp ;iDsp++){   //DSP loop
126           
127           dspHeader =  blkHeader->GetDspHeaderEntry(iDsp);
128           printf("Dsp %d length %d error word %d\n",iDsp,dspHeader->GetTotalLength(), dspHeader->GetErrorWord());
129           
130           // loop over BusPatch structure
131           Int_t nBusPatch = dspHeader->GetBusPatchEntries();
132           for(Int_t iBusPatch = 0; iBusPatch < nBusPatch; iBusPatch++) {  
133             
134             busStruct = dspHeader->GetBusPatchEntry(iBusPatch);
135             
136             //       printf("busPatchId %d", busStruct->GetBusPatchId());
137             //       printf(" BlockId %d", busStruct->GetBlockId());
138             //       printf(" DspId %d\n", busStruct->GetDspId());
139             
140             // loop over data
141             dataSize = busStruct->GetLength();
142             for (Int_t iData = 0; iData < dataSize; iData++) {
143               
144               Int_t  manuId    = busStruct->GetManuId(iData);
145               Int_t  channelId = busStruct->GetChannelId(iData);
146               Int_t  charge    = busStruct->GetCharge(iData);
147               printf("buspatch %5d manuI %4d channel %3d charge %4d\n", 
148                      busStruct->GetBusPatchId(),
149                      manuId, 
150                      channelId, charge);
151             } // iData
152           } // iBusPatch
153         } // iDsp
154       } // iBlock
155     } // NextDDL
156   }// NextEvent
157   
158   delete rawReader;
159   delete rawStream;
160   timer.Print();
161 }
162
163 void MUONRawStreamTrackerSimple(TString fileName, Int_t maxEvent)
164 {
165   /// Reads the raw data in fileName, using a simplified interface (iterator
166   /// over pads).
167   TStopwatch timer;
168   timer.Start(kTRUE);
169   
170   AliRawReader* rawReader = 0x0;
171   
172   // check extention to choose the rawdata file format
173   if (fileName.EndsWith("/")) {
174     rawReader = new AliRawReaderFile(fileName); // DDL files
175   } else if (fileName.EndsWith(".root")) {
176     rawReader = new AliRawReaderRoot(fileName);
177   } else if (!fileName.IsNull()) {
178     rawReader = new AliRawReaderDate(fileName); // DATE file
179   }
180   
181   // raw stream
182   AliMUONRawStreamTracker* rawStream  = new AliMUONRawStreamTracker(rawReader);    
183   
184   //   Loop over events  
185   Int_t iEvent = 0;
186   
187   while (rawReader->NextEvent()) {
188     
189     if (iEvent == maxEvent)
190       break;
191     
192     printf("Event %d\n",iEvent++);
193     
194     Int_t busPatch;
195     UShort_t manuId, adc;
196     UChar_t manuChannel;
197     
198     rawStream->First();
199     
200     while ( rawStream->Next(busPatch,manuId,manuChannel,adc) )
201     {      
202       printf("buspatch %5d manuI %4d channel %3d charge %4d\n", 
203              busPatch,manuId,manuChannel, adc);
204     }
205   }
206   
207   delete rawReader;
208   delete rawStream;
209   timer.Print();
210 }
211