Updated serial number for station345
[u/mrichter/AliRoot.git] / MUON / MUONRawStreamTrigger.C
CommitLineData
99e11065 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
e54bf126 16// $Id$
17
18/// \ingroup macros
19/// \file MUONRawStreamTrigger.C
20/// \brief Macro for reading trigger raw data
21///
22/// \author Ch. Finck, Subatech, April 2006
23///
24/// Implement "digits" iterator.
25/// This macro is interface with AliRawReader for RAW.
26/// The different stucture of the patload are readout and stored in TClonesArray
27/// with AliMUONRawStreamTrigger class.
28/// The macro just simply reads again the TClonesArray contents.
29/// The parameter of each structure could be seen in the container classes
30/// AliMUONDarcHeader, AliMUONRegHeader, AliMUONLocalStruct.
31/// The class AliMUONDDLTrigger manages the structure containers.
32/// The number of structures in the rawdata file could be set.
33/// The DATE format reading is no more supported please use the MUONTRGda code.
34
99e11065 35
36#if !defined(__CINT__) || defined(__MAKECINT__)
37
38// RAW includes
ce22afdc 39#include "AliRawReader.h"
99e11065 40
41// MUON includes
42#include "AliMUONRawStreamTrigger.h"
43#include "AliMUONDarcHeader.h"
44#include "AliMUONRegHeader.h"
45#include "AliMUONLocalStruct.h"
46#include "AliMUONDDLTrigger.h"
9d1949d2 47#include "AliMpTriggerCrate.h"
48#include "AliMpDDLStore.h"
a89c7656 49#include "AliMpCDB.h"
50
51#include "TStopwatch.h"
52
53
99e11065 54#endif
55
63898c67 56void MUONRawStreamTrigger(Int_t maxEvent = 1, Int_t minDDL = 0, Int_t maxDDL = 1, TString fileName = "./")
99e11065 57{
a89c7656 58
59 TStopwatch timer;
60 timer.Start(kTRUE);
61
ce22afdc 62 AliRawReader* rawReader = AliRawReader::Create(fileName.Data());
99e11065 63
a89c7656 64 // Load mapping
65 if ( ! AliMpCDB::LoadDDLStore() ) {
66 printf("Could not access mapping from OCDB !\n");
67 }
99e11065 68
69 // raw stream
70 AliMUONRawStreamTrigger* rawStream = new AliMUONRawStreamTrigger(rawReader);
71
a89c7656 72 // set the number ofreg & local that are PRESENT in the rawdata file
99e11065 73 // it's NOT the number to be read.
a89c7656 74 // default wise set to 8, 16 respectively.
75 // rawStream->SetMaxReg(2);
99e11065 76 // rawStream->SetMaxLoc(xx);
77
78 // containers
79 AliMUONDDLTrigger* ddlTrigger = 0x0;
80 AliMUONDarcHeader* darcHeader = 0x0;
81 AliMUONRegHeader* regHeader = 0x0;
82 AliMUONLocalStruct* localStruct = 0x0;
83
63898c67 84
99e11065 85 // Loop over events
86 Int_t iEvent = 0;
87
88 while (rawReader->NextEvent()) {
89
90 if (iEvent == maxEvent)
91 break;
92
93 printf("Event %d\n",iEvent++);
94
95 // read DDL while < 2 DDL
96 while(rawStream->NextDDL()) {
97
98 if (rawStream->GetDDL() < minDDL || rawStream->GetDDL() > maxDDL)
99 continue;
100
101 printf("\niDDL %d\n", rawStream->GetDDL());
102
103 ddlTrigger = rawStream->GetDDLTrigger();
104 darcHeader = ddlTrigger->GetDarcHeader();
105
106 printf("Global output %x\n", (Int_t)darcHeader->GetGlobalOutput());
107
108 // loop over regional structures
109 Int_t nReg = darcHeader->GetRegHeaderEntries();
110 for(Int_t iReg = 0; iReg < nReg ;iReg++){ //REG loop
111
a89c7656 112// printf("RegionalId %d\n", iReg);
99e11065 113
114 regHeader = darcHeader->GetRegHeaderEntry(iReg);
115 // printf("Reg length %d\n",regHeader->GetHeaderLength());
116
9d1949d2 117 // crate info
118 AliMpTriggerCrate* crate = AliMpDDLStore::Instance()->
119 GetTriggerCrate(rawStream->GetDDL(), iReg);
63898c67 120
99e11065 121 // loop over local structures
122 Int_t nLocal = regHeader->GetLocalEntries();
123 for(Int_t iLocal = 0; iLocal < nLocal; iLocal++) {
124
125 localStruct = regHeader->GetLocalEntry(iLocal);
126
9d1949d2 127 Int_t iLocCard = crate->GetLocalBoardId(localStruct->GetId());
128
129 if ( !iLocCard ) continue; // empty slot
130
99e11065 131 // check if trigger
a89c7656 132 if (localStruct->GetTriggerX()
8d1deca2 133 || localStruct->GetTriggerY()) { // no empty data
99e11065 134
a89c7656 135 printf("LocalId %d\n", localStruct->GetId());
63898c67 136
a89c7656 137 Int_t loStripX = (Int_t)localStruct->GetXPos();
138 Int_t loStripY = (Int_t)localStruct->GetYPos();
139 Int_t loDev = (Int_t)localStruct->GetXDev();
140
63898c67 141 printf("iLocCard: %d, XPos: %d, YPos: %d Dev: %d\n", iLocCard, loStripX, loStripY, loDev);
a89c7656 142
99e11065 143 }
144 } // iLocal
145 } // iReg
146 } // NextDDL
147 }// NextEvent
148
149 delete rawReader;
150 delete rawStream;
a89c7656 151
152 timer.Print();
153
154}
155
156
157void MUONRawStreamTriggerSimple(Int_t maxEvent = 1, TString fileName = "./")
158{
159 /// Reads the raw data in fileName, using a simplified interface (iterator
160 /// over local structure response).
161
162 TStopwatch timer;
163 timer.Start(kTRUE);
164
165 AliRawReader* rawReader = 0x0;
166
167 if (fileName.EndsWith("/")) {
168 rawReader = new AliRawReaderFile(fileName);// DDL files
169 } else if (fileName.EndsWith(".root")) {
170 rawReader = new AliRawReaderRoot(fileName);
171 }
172
173 // raw stream
174 AliMUONRawStreamTrigger* rawStream = new AliMUONRawStreamTrigger(rawReader);
175
176 // set the number of reg & local that are PRESENT in the rawdata file
177 // it's NOT the number to be read.
178 // default wise set to 8, 16 respectively.
179 // rawStream->SetMaxReg(2);
180 // rawStream->SetMaxLoc(xx);
181
182 UChar_t id;
183 UChar_t dec;
184 Bool_t trigY;
185 UChar_t yPos;
186 UChar_t sXDev;
187 UChar_t xDev;
188 UChar_t xPos;
189
190 Bool_t triggerX;
191 Bool_t triggerY;
192
193
194 TArrayS xPattern;
195 TArrayS yPattern;
196
197 // Loop over events
198 Int_t iEvent = 0;
199
200 while (rawReader->NextEvent()) {
201
202 if (iEvent == maxEvent)
203 break;
204
205 printf("Event %d\n",iEvent++);
206
207 rawStream->First();
208
209 // read while there are digits
210 while( rawStream->Next(id, dec, trigY, yPos, sXDev, xDev, xPos,
211 triggerX, triggerY, xPattern, yPattern) )
212 {
213 if ( triggerX || triggerY ) // no empty data
214 printf("iLocCard: %d, XPos: %d, YPos: %d Dev: %d\n", id, xPos, yPos, xDev);
215
216 }// Next
217
218 }// NextEvent
219
220 delete rawReader;
221 delete rawStream;
222
223 timer.Print();
224
99e11065 225}