]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/MUONTRGda.cxx
Update of calibration code (Raphaelle)
[u/mrichter/AliRoot.git] / MUON / MUONTRGda.cxx
CommitLineData
3e42bf30 1/*
113ad708 2MTR DA for online
3
3e42bf30 4Contact: Franck Manso <manso@clermont.in2p3.fr>
5Link: http://aliceinfo.cern.ch/static/Offline/dimuon/muon_html/README_mtrda.html
e8f1ed57 6Reference run: 61898
7Run Type: PHYSICS
41a38dec 8DA Type: MON
e8f1ed57 9Number of events needed: 1000 events
10Input files: MtgGlobalCrate.dat MtgRegionalCrate.dat MtgLocalMask.dat MtgLocalLut.dat MtgCurrent.dat DAConfig.dat
11Output Files: ExportedFiles.dat MtgGlobalCrate.dat
12Trigger types used: PHYSICS_EVENT CALIBRATION_EVENT
3e42bf30 13*/
14
327f7faa 15//////////////////////////////////////////////////////////////////////////////
16// Detector Algorithm for the MUON trigger configuration. //
17// //
18// Calculates masks for the global trigger input, by looking at dead //
e8f1ed57 19// channels in calibration events and at noisy channels in physics events. //
327f7faa 20// Transfers trigger configuration files to the File Exchange Server and //
21// writes them (if modified) into the trigger configuration data base. //
22// //
23// Authors: //
24// Christian Fink (formerly at Subatech, Nantes) //
25// Franck Manso (LPC Clermont-Ferrand, manso@clermont.in2p3.fr) //
26// Bogdan Vulpescu (LPC Clermont-Ferrand, vulpescu@clermont.in2p3.fr) //
27// //
28//////////////////////////////////////////////////////////////////////////////
3e42bf30 29
e8f1ed57 30//#define OFFLINE
31
9f5fafa6 32extern "C" {
33#include <daqDA.h>
34}
35
36#include "event.h"
37#include "monitor.h"
38
39#include <Riostream.h>
40#include <stdio.h>
41#include <stdlib.h>
42
4fd5ed63 43#include "AliRawReaderDate.h"
44
45#include "AliMpConstants.h"
9f5fafa6 46#include "AliMUONRawStreamTrigger.h"
e8f1ed57 47#include "AliMUONRawStreamTriggerHP.h"
9f5fafa6 48#include "AliMUONDarcHeader.h"
98bdda22 49#include "AliMUONRegHeader.h"
9f5fafa6 50#include "AliMUONDDLTrigger.h"
4fd5ed63 51#include "AliMUONVStore.h"
4fd5ed63 52#include "AliMUON1DArray.h"
53#include "AliMUONTriggerIO.h"
92c23b09 54#include "AliMUONRegionalTriggerConfig.h"
55#include "AliMUONGlobalCrateConfig.h"
98bdda22 56#include "AliMUONVCalibParam.h"
57#include "AliMUONCalibParamND.h"
58#include "AliMUONCalibParamNI.h"
59#include "AliMUONLocalStruct.h"
9f5fafa6 60
9f5fafa6 61#include "TString.h"
4fd5ed63 62#include "TSystem.h"
9f5fafa6 63#include "TStopwatch.h"
9f5fafa6 64#include "TROOT.h"
65#include "TPluginManager.h"
98bdda22 66#include "TArrayS.h"
9f5fafa6 67
37dacd7d 68/// class for DA run parameters and DA working space
69class AliDAConfig : TObject {
70
71public:
72
73 AliDAConfig() :
e8f1ed57 74 fDAConfigFileName("DAConfig.dat"),
37dacd7d 75 fCurrentFileName("MtgCurrent.dat"),
76 fLastCurrentFileName("MtgLastCurrent.dat"),
77 fSodName(""),
78 fSodFlag(0),
79 fDAName(""),
80 fDAFlag(0),
98bdda22 81 fDAMode(1),
37dacd7d 82 fGlobalFileName(""),
83 fRegionalFileName(""),
84 fLocalMaskFileName(""),
85 fLocalLutFileName(""),
86 fSignatureFileName(""),
87 fGlobalFileVersion(0),
88 fRegionalFileVersion(0),
89 fLocalMaskFileVersion(0),
90 fLocalLutFileVersion(0),
91 fSignatureFileVersion(0),
92 fGlobalFileLastVersion(0),
93 fRegionalFileLastVersion(0),
94 fLocalMaskFileLastVersion(0),
95 fLocalLutFileLastVersion(0),
96 fEventsN(0),
97 fEventsD(0),
98 fPrintLevel(0),
99 fLocalMasks(0x0),
98bdda22 100 fLocalMasksDA(0x0),
37dacd7d 101 fRegionalMasks(0x0),
102 fGlobalMasks(0x0),
103 fTriggerIO(new AliMUONTriggerIO),
98bdda22 104 fAlgoNoisyInput(kFALSE),
105 fAlgoDeadcInput(kFALSE),
37dacd7d 106 fThrN(0.1),
107 fThrD(0.9),
98bdda22 108 fThrLocN(0.1),
109 fThrLocD(0.9),
37dacd7d 110 fMinEvents(10),
111 fSkipEvents(0),
112 fMaxEvents(65535),
98bdda22 113 fWithWarnings(kFALSE),
114 fUseFastDecoder(kFALSE),
115 fNLocalBoard(AliMpConstants::TotalNofLocalBoards()+1),
116 fPatternStoreN(0x0),
117 fPatternStoreD(0x0)
37dacd7d 118 {
119 /// default constructor
120 for (Int_t ii = 0; ii < kGlobalInputs; ii++) {
121 for (Int_t il = 0; il < kGlobalInputLength; il++) {
122 fAccGlobalInputN[ii][il] = 0;
123 fAccGlobalInputD[ii][il] = 0;
124 }
125 }
126 fLocalMasks = new AliMUON1DArray(fNLocalBoard);
98bdda22 127 fLocalMasksDA = new AliMUON1DArray(fNLocalBoard);
37dacd7d 128 fRegionalMasks = new AliMUONRegionalTriggerConfig();
129 fGlobalMasks = new AliMUONGlobalCrateConfig();
98bdda22 130 fPatternStoreN = new AliMUON1DArray(fNLocalBoard);
131 fPatternStoreD = new AliMUON1DArray(fNLocalBoard);
132
133 // Generate local trigger masks store. All masks are set to FFFF
134 for (Int_t i = 1; i <= AliMpConstants::TotalNofLocalBoards(); i++) {
135 AliMUONVCalibParam* localBoard = new AliMUONCalibParamNI(1,8,i,0,0);
136 for (Int_t x = 0; x < 2; x++) {
137 for (Int_t y = 0; y < 4; y++) {
138 Int_t index = x*4+y;
139 localBoard->SetValueAsInt(index,0,0xFFFF);
140 }
141 }
142 fLocalMasksDA->Add(localBoard);
143 }
144
37dacd7d 145 }
146
37dacd7d 147 virtual ~AliDAConfig()
148 {
149 /// destructor
150 delete fLocalMasks;
98bdda22 151 delete fLocalMasksDA;
37dacd7d 152 delete fRegionalMasks;
153 delete fGlobalMasks;
98bdda22 154 delete fPatternStoreN;
155 delete fPatternStoreD;
37dacd7d 156 delete fTriggerIO;
157 }
158 void PrintConfig()
159 {
160 /// print DA parameters
161 printf("DA config file name: %s \n",GetDAConfigFileName());
162 printf("Current file name: %s \n",GetCurrentFileName());
163 printf("Last current file name: %s \n",GetLastCurrentFileName());
164 printf("Global file name: %s (%d %d)\n",GetGlobalFileName(),GetGlobalFileVersion(),GetGlobalFileLastVersion());
165 printf("Regional file name: %s (%d %d)\n",GetRegionalFileName(),GetRegionalFileVersion(),GetRegionalFileLastVersion());
166 printf("Local mask file name: %s (%d %d)\n",GetLocalMaskFileName(),GetLocalMaskFileVersion(),GetLocalMaskFileLastVersion());
167 printf("Local LUT file name: %s (%d %d)\n",GetLocalLutFileName(),GetLocalLutFileVersion(),GetLocalLutFileLastVersion());
168 printf("Signature file name: %s (%d)\n",GetSignatureFileName(),GetSignatureFileVersion());
169 }
170
bb440407 171 /// name of the DA configuration file from detector DB
37dacd7d 172 const Char_t* GetDAConfigFileName() { return fDAConfigFileName.Data(); }
bb440407 173 /// file with current versions of the configuration files, usually MtgCurrent.dat
37dacd7d 174 const Char_t* GetCurrentFileName() { return fCurrentFileName.Data(); }
bb440407 175 /// last known versions of the configuration files, usually MtgLastCurrent.dat
37dacd7d 176 const Char_t* GetLastCurrentFileName() { return fLastCurrentFileName.Data(); }
177
bb440407 178 /// name of the Start-of-data field in MtgCurrent.dat
37dacd7d 179 const Char_t* GetSodName() { return fSodName.Data(); }
bb440407 180 /// flag value of the Start-of-data field in MtgCurrent.dat
37dacd7d 181 Int_t GetSodFlag() const { return fSodFlag; }
182
bb440407 183 /// name of the Detector Algorithm field in MtgCurrent.dat
37dacd7d 184 const Char_t* GetDAName() { return fDAName.Data(); }
bb440407 185 /// flag value of the Detector Algorithm field in MtgCurrent.dat
37dacd7d 186 Int_t GetDAFlag() const { return fDAFlag; }
98bdda22 187 /// DA active mode (GLOBAL or GLOBAL+LOCAL)
188 Int_t GetDAMode() const { return fDAMode; }
37dacd7d 189
bb440407 190 /// global crate configuration file name
37dacd7d 191 const Char_t* GetGlobalFileName() { return fGlobalFileName.Data(); }
bb440407 192 /// regional crate configuration file name
37dacd7d 193 const Char_t* GetRegionalFileName() { return fRegionalFileName.Data(); }
bb440407 194 /// masks for the local cards, file name
37dacd7d 195 const Char_t* GetLocalMaskFileName() { return fLocalMaskFileName.Data(); }
bb440407 196 /// transverse momentum Look-Up-Table, file name
37dacd7d 197 const Char_t* GetLocalLutFileName() { return fLocalLutFileName.Data(); }
bb440407 198 /// signature file name
37dacd7d 199 const Char_t* GetSignatureFileName() { return fSignatureFileName.Data(); }
200
bb440407 201 /// version of the global crate configuration in the detector DB
37dacd7d 202 Int_t GetGlobalFileVersion() const { return fGlobalFileVersion; }
bb440407 203 /// version of the regional crate configuration in the detector DB
37dacd7d 204 Int_t GetRegionalFileVersion() const { return fRegionalFileVersion; }
bb440407 205 /// version of the masks for the local cards in the detector DB
37dacd7d 206 Int_t GetLocalMaskFileVersion() const { return fLocalMaskFileVersion; }
bb440407 207 /// version of the transverse momentum Look-Up-Table in the detector DB
37dacd7d 208 Int_t GetLocalLutFileVersion() const { return fLocalLutFileVersion; }
bb440407 209 /// version of the signature file in the detector DB
37dacd7d 210 Int_t GetSignatureFileVersion() const { return fSignatureFileVersion; }
211
bb440407 212 /// last known version of the global crate configuration
37dacd7d 213 Int_t GetGlobalFileLastVersion() const { return fGlobalFileLastVersion; }
bb440407 214 /// last known version of the regional crate configuration
37dacd7d 215 Int_t GetRegionalFileLastVersion() const { return fRegionalFileLastVersion; }
bb440407 216 /// last known version of the masks for the local cards
37dacd7d 217 Int_t GetLocalMaskFileLastVersion() const { return fLocalMaskFileLastVersion; }
bb440407 218 /// last known version of the transverse momentum Look-Up-Table
37dacd7d 219 Int_t GetLocalLutFileLastVersion() const { return fLocalLutFileLastVersion; }
220
bb440407 221 /// store for the masks for the local cards (own)
37dacd7d 222 AliMUONVStore* GetLocalMasks() const { return fLocalMasks; }
98bdda22 223 /// store for the DA-calculated masks for the local cards (own)
224 AliMUONVStore* GetLocalMasksDA() const { return fLocalMasksDA; }
bb440407 225 /// configuration object for the regional crate (own)
37dacd7d 226 AliMUONRegionalTriggerConfig* GetRegionalMasks() const { return fRegionalMasks; }
bb440407 227 /// configuration object for the global crate (own)
37dacd7d 228 AliMUONGlobalCrateConfig* GetGlobalMasks() const { return fGlobalMasks; }
229
bb440407 230 /// read/write configurations, masks and LUT to/from online files (own)
37dacd7d 231 AliMUONTriggerIO* GetTriggerIO() const { return fTriggerIO; }
232
98bdda22 233 /// store for local strips patterns (noisy strips)
234 AliMUONVStore* GetPatternStoreN() const { return fPatternStoreN; }
235 /// store for local strips patterns (dead strips)
236 AliMUONVStore* GetPatternStoreD() const { return fPatternStoreD; }
237
bb440407 238 /// number of accumulated PHYSICS events for noisy channels analysis
37dacd7d 239 Int_t GetEventsN() const { return fEventsN; }
bb440407 240 /// number of accumulated CALIBRATION events for dead channels analysis
37dacd7d 241 Int_t GetEventsD() const { return fEventsD; }
242
bb440407 243 /// print verbosity of the DA
37dacd7d 244 Int_t GetPrintLevel() const { return fPrintLevel; }
245
bb440407 246 /// select PHYSICS events for noisy channels analysis
37dacd7d 247 Bool_t GetAlgoNoisyInput() const { return fAlgoNoisyInput; }
bb440407 248 /// select CALIBRATION events for dead channels analysis
37dacd7d 249 Bool_t GetAlgoDeadcInput() const { return fAlgoDeadcInput; }
250
98bdda22 251 /// threshold for noisy global inputs (fraction of events)
37dacd7d 252 Float_t GetThrN() const { return fThrN; }
98bdda22 253 /// threshold for dead global inputs (fraction of events)
37dacd7d 254 Float_t GetThrD() const { return fThrD; }
98bdda22 255 /// threshold for noisy local strips (fraction of events)
256 Float_t GetThrLocN() const { return fThrLocN; }
257 /// threshold for dead local strips (fraction of events)
258 Float_t GetThrLocD() const { return fThrLocD; }
37dacd7d 259
bb440407 260 /// minumum nr of events for rate calculation
37dacd7d 261 Int_t GetMinEvents() const { return fMinEvents; }
bb440407 262 /// maximum number of events to analyze
37dacd7d 263 Int_t GetMaxEvents() const { return fMaxEvents; }
bb440407 264 /// number of events to skip from start
37dacd7d 265 Int_t GetSkipEvents() const { return fSkipEvents; }
266
bb440407 267 /// show warnings from the raw data decoder
37dacd7d 268 Bool_t WithWarnings() const { return fWithWarnings; }
bb440407 269 /// use the high-performance (HP) decoder
e8f1ed57 270 Bool_t UseFastDecoder() const { return fUseFastDecoder; }
37dacd7d 271
bb440407 272 /// number of global input words
37dacd7d 273 Int_t GetGlobalInputs() const { return kGlobalInputs; }
bb440407 274 /// length in bits of a global input word
37dacd7d 275 Int_t GetGlobalInputLength() const { return kGlobalInputLength; }
276
bb440407 277 /// get accumulated values for bit "ib" from global input word "ii", PHYSICS events
37dacd7d 278 Int_t GetAccGlobalInputN(Int_t ii, Int_t ib) const { return fAccGlobalInputN[ii][ib]; }
bb440407 279 /// get accumulated values for bit "ib" from global input word "ii", CALIBRATION events
37dacd7d 280 Int_t GetAccGlobalInputD(Int_t ii, Int_t ib) const { return fAccGlobalInputD[ii][ib]; }
281
bb440407 282 /// set the name of the Start-of-data field in MtgCurrent.dat
37dacd7d 283 void SetSodName(Char_t *name) { fSodName = TString(name); }
bb440407 284 /// set the flag value of the Start-of-data field in MtgCurrent.dat
37dacd7d 285 void SetSodFlag(Int_t flag) { fSodFlag = flag; }
286
bb440407 287 /// set the name of the Detector Algorithm field in MtgCurrent.dat
37dacd7d 288 void SetDAName(Char_t *name) { fDAName = TString(name); }
bb440407 289 /// set the flag value of the Detector Algorithm field in MtgCurrent.dat
37dacd7d 290 void SetDAFlag(Int_t flag) { fDAFlag = flag; }
98bdda22 291 /// set DA active mode, 1 = GLOBAL (default), 2 = GLOBAL and LOCAL
292 void SetDAMode(Int_t mode) { fDAMode = mode; }
37dacd7d 293
bb440407 294 /// set the global crate configuration file name
37dacd7d 295 void SetGlobalFileName(const Char_t *name) { fGlobalFileName = TString(name); }
bb440407 296 /// set the regional crate configuration file name
37dacd7d 297 void SetRegionalFileName(const Char_t *name) { fRegionalFileName = TString(name); }
bb440407 298 /// set the masks for the local cards, file name
37dacd7d 299 void SetLocalMaskFileName(const Char_t *name) { fLocalMaskFileName = TString(name); }
bb440407 300 /// set the transverse momentum Look-Up-Table, file name
37dacd7d 301 void SetLocalLutFileName(const Char_t *name) { fLocalLutFileName = TString(name); }
bb440407 302 /// set the signature file name
37dacd7d 303 void SetSignatureFileName(const Char_t *name) { fSignatureFileName = TString(name); }
304
bb440407 305 /// set the version of the global crate configuration in the detector DB
37dacd7d 306 void SetGlobalFileVersion(Int_t ver) { fGlobalFileVersion = ver; }
bb440407 307 /// set the version of the regional crate configuration in the detector DB
37dacd7d 308 void SetRegionalFileVersion(Int_t ver) { fRegionalFileVersion = ver; }
bb440407 309 /// set the version of the masks for the local cards in the detector DB
37dacd7d 310 void SetLocalMaskFileVersion(Int_t ver) { fLocalMaskFileVersion = ver; }
bb440407 311 /// set the version of the transverse momentum Look-Up-Table in the detector DB
37dacd7d 312 void SetLocalLutFileVersion(Int_t ver) { fLocalLutFileVersion = ver; }
bb440407 313 /// set the version of the signature file in the detector DB
37dacd7d 314 void SetSignatureFileVersion(Int_t ver) { fSignatureFileVersion = ver; }
315
bb440407 316 /// set the last known version of the global crate configuration
37dacd7d 317 void SetGlobalFileLastVersion(Int_t ver) { fGlobalFileLastVersion = ver; }
bb440407 318 /// set the last known version of the regional crate configuration
37dacd7d 319 void SetRegionalFileLastVersion(Int_t ver) { fRegionalFileLastVersion = ver; }
bb440407 320 /// set the last known version of the masks for the local cards
37dacd7d 321 void SetLocalMaskFileLastVersion(Int_t ver) { fLocalMaskFileLastVersion = ver; }
bb440407 322 /// set the last known version of the transverse momentum Look-Up-Table
37dacd7d 323 void SetLocalLutFileLastVersion(Int_t ver) { fLocalLutFileLastVersion = ver; }
324
bb440407 325 /// increment the number of selected PHYSICS events
37dacd7d 326 void IncNoiseEvent() { fEventsN++; }
bb440407 327 /// increment the number of selected CALIBRATION events
37dacd7d 328 void IncDeadcEvent() { fEventsD++; }
329
bb440407 330 /// count the value of the bit "ib" of global input word "ii" (PHYSICS events)
37dacd7d 331 void AddAccGlobalInputN(Int_t ii, Int_t ib, Int_t val) { fAccGlobalInputN[ii][ib] += val; }
bb440407 332 /// count the value of the bit "ib" of global input word "ii" (CALIBRATION events)
37dacd7d 333 void AddAccGlobalInputD(Int_t ii, Int_t ib, Int_t val) { fAccGlobalInputD[ii][ib] += val; }
334
bb440407 335 /// set the print verbosity level of the DA
37dacd7d 336 void SetPrintLevel(Int_t level) { fPrintLevel = level; }
337
bb440407 338 /// select PHYSICS events for noisy channels analysis
37dacd7d 339 void SetAlgoNoisyInput(Bool_t val) { fAlgoNoisyInput = val; }
bb440407 340 /// select CALIBRATION events for dead channels analysis
37dacd7d 341 void SetAlgoDeadcInput(Bool_t val) { fAlgoDeadcInput = val; }
342
98bdda22 343 /// set the threshold for noisy global inputs (fraction of events)
37dacd7d 344 void SetThrN(Float_t val) { fThrN = val; }
98bdda22 345 /// set the threshold for dead global inputs (fraction of events)
37dacd7d 346 void SetThrD(Float_t val) { fThrD = val; }
98bdda22 347 /// set the threshold for noisy local strips (fraction of events)
348 void SetThrLocN(Float_t val) { fThrLocN = val; }
349 /// set the threshold for dead local strips (fraction of events)
350 void SetThrLocD(Float_t val) { fThrLocD = val; }
37dacd7d 351
bb440407 352 /// set the minumum nr of events for rate calculation
37dacd7d 353 void SetMinEvents(Int_t val) { fMinEvents = val; }
bb440407 354 /// set the maximum number of events to analyze
37dacd7d 355 void SetMaxEvents(Int_t val) { fMaxEvents = val; }
bb440407 356 /// set the number of events to skip from start
37dacd7d 357 void SetSkipEvents(Int_t val) { fSkipEvents = val; }
358
bb440407 359 /// set/unset to show warnings from the raw data decoder
98bdda22 360 void SetWithWarnings() { fWithWarnings = kTRUE; }
bb440407 361 /// set/unset the use of the high-performance (HP) decoder
98bdda22 362 void SetUseFastDecoder() { fUseFastDecoder = kTRUE; }
37dacd7d 363
bb440407 364 /// increment version of the global crate configuration file
37dacd7d 365 void IncGlobalFileVersion() { fGlobalFileVersion++; }
98bdda22 366 /// increment version of the local mask configuration file
367 void IncLocalMaskFileVersion() { fLocalMaskFileVersion++; }
bb440407 368 /// count skipped events
37dacd7d 369 void DecSkipEvents() { fSkipEvents--; }
370
371private:
4fd5ed63 372
bb440407 373 /// copy constructor, not implemented
374 AliDAConfig (const AliDAConfig& cfg);
375 /// assignment operator, not implemented
376 AliDAConfig& operator=(const AliDAConfig& cfg);
4fd5ed63 377
bb440407 378 const TString fDAConfigFileName; //!< name of the DA configuration file from detector DB
379 const TString fCurrentFileName; //!< usually MtgCurrent.dat
380 const TString fLastCurrentFileName; //!< usually MtgLastCurrent.dat
4fd5ed63 381
bb440407 382 TString fSodName; //!< name of the Start-of-data field in MtgCurrent.dat
383 Int_t fSodFlag; //!< flag value of the Start-of-data field in MtgCurrent.dat
4fd5ed63 384
bb440407 385 TString fDAName; //!< name of the Detector Algorithm field in MtgCurrent.dat
386 Int_t fDAFlag; //!< flag value of the Detector Algorithm field in MtgCurrent.dat (enabled/disabled)
98bdda22 387 Int_t fDAMode; //!< DA active mode, GLOBAL or GLOBAL+LOCAL
4fd5ed63 388
98bdda22 389 TString fGlobalFileName; //!< global crate configuration, file name
390 TString fRegionalFileName; //!< regional crate configuration, file name
391 TString fLocalMaskFileName; //!< masks for the local cards, file name
392 TString fLocalLutFileName; //!< transverse momentum Look-Up-Table, file name
393 TString fSignatureFileName; //!< signature file name
bb440407 394
395 Int_t fGlobalFileVersion; //!< version of the global crate configuration in the detector DB
396 Int_t fRegionalFileVersion; //!< version of the regional crate configuration in the detector DB
397 Int_t fLocalMaskFileVersion; //!< version of the masks for the local cards in the detector DB
398 Int_t fLocalLutFileVersion; //!< version of the transverse momentum Look-Up-Table in the detector DB
399 Int_t fSignatureFileVersion; //!< version of the signature file in the detector DB
327f7faa 400
bb440407 401 Int_t fGlobalFileLastVersion; //!< last known version of the global crate configuration
402 Int_t fRegionalFileLastVersion; //!< last known version of the regional crate configuration
403 Int_t fLocalMaskFileLastVersion; //!< last known version of the masks for the local cards
404 Int_t fLocalLutFileLastVersion; //!< last known version of the transverse momentum Look-Up-Table
327f7faa 405
bb440407 406 Int_t fEventsN; //!< number of accumulated PHYSICS events
407 Int_t fEventsD; //!< number of accumulated CALIBRATION events
327f7faa 408
bb440407 409 Int_t fPrintLevel; //!< print verbosity of the DA
327f7faa 410
bb440407 411 AliMUONVStore* fLocalMasks; //!< store for the masks for the local cards
98bdda22 412 AliMUONVStore* fLocalMasksDA; //!< store for the DA-calculated masks for the local cards
bb440407 413 AliMUONRegionalTriggerConfig* fRegionalMasks; //!< configuration object for the regional crate
414 AliMUONGlobalCrateConfig* fGlobalMasks; //!< configuration object for the global crate
327f7faa 415
bb440407 416 AliMUONTriggerIO *fTriggerIO; //!< read/write masks and LUT to/from online files
327f7faa 417
bb440407 418 Bool_t fAlgoNoisyInput; //!< select PHYSICS events for noisy channels analysis
419 Bool_t fAlgoDeadcInput; //!< select CALIBRATION events for dead channels analysis
327f7faa 420
98bdda22 421 Float_t fThrN; //!< threshold for noisy global inputs (fraction of events)
422 Float_t fThrD; //!< threshold for dead global inputs (fraction of events)
423 Float_t fThrLocN; //!< threshold for noisy local strips (fraction of events)
424 Float_t fThrLocD; //!< threshold for dead local strips (fraction of events)
bb440407 425 Int_t fMinEvents; //!< minumum nr of events for rate calculation
426 Int_t fSkipEvents; //!< number of events to skip from start
427 Int_t fMaxEvents; //!< maximum number of events to analyze
428 Bool_t fWithWarnings; //!< show warnings from the raw data decoder
429 Bool_t fUseFastDecoder; //!< use the high-performance (HP) decoder
327f7faa 430
bb440407 431 const Int_t fNLocalBoard; //!< number of local boards
327f7faa 432
bb440407 433 enum { kGlobalInputs = 4, //!< number of global input words
434 kGlobalInputLength = 32 //!< length in bits of a global input word
435 };
327f7faa 436
52ce8802 437 AliMUONVStore *fPatternStoreN; //!< store for local strips patterns
438 AliMUONVStore *fPatternStoreD; //!< store for local strips patterns
98bdda22 439
bb440407 440 Int_t fAccGlobalInputN[kGlobalInputs][kGlobalInputLength]; //!< storage for global input (PHYSICS events)
441 Int_t fAccGlobalInputD[kGlobalInputs][kGlobalInputLength]; //!< storage for global input (CALIBRATION events)
327f7faa 442
327f7faa 443};
4fd5ed63 444
327f7faa 445//__________________________________________________________________
37dacd7d 446Bool_t ReadDAConfig(AliDAConfig& cfg)
327f7faa 447{
37dacd7d 448 /// read run parameters for the DA
4fd5ed63 449
327f7faa 450 char line[80];
4fd5ed63 451
327f7faa 452 TString file;
37dacd7d 453 file = cfg.GetDAConfigFileName();
327f7faa 454 std::ifstream in(gSystem->ExpandPathName(file.Data()));
455 if (!in.good()) {
456 printf("Cannot open DA configuration file %s ; use default values.\n",file.Data());
98bdda22 457 return kTRUE;
327f7faa 458 }
459
460 TString tmp;
461 Int_t pos;
462
463 in.getline(line,80);
464 tmp = line;
465 pos = tmp.First(" ");
466 tmp = tmp(0,pos);
37dacd7d 467 cfg.SetPrintLevel(tmp.Atoi());
327f7faa 468
469 in.getline(line,80);
470 tmp = line;
471 pos = tmp.First(" ");
472 tmp = tmp(0,pos);
37dacd7d 473 cfg.SetThrN(tmp.Atof());
327f7faa 474
475 in.getline(line,80);
476 tmp = line;
477 pos = tmp.First(" ");
478 tmp = tmp(0,pos);
37dacd7d 479 cfg.SetThrD(tmp.Atof());
327f7faa 480
481 in.getline(line,80);
482 tmp = line;
483 pos = tmp.First(" ");
484 tmp = tmp(0,pos);
37dacd7d 485 cfg.SetMinEvents(tmp.Atoi());
327f7faa 486
487 in.getline(line,80);
488 tmp = line;
489 pos = tmp.First(" ");
490 tmp = tmp(0,pos);
37dacd7d 491 cfg.SetSkipEvents(tmp.Atoi());
4fd5ed63 492
327f7faa 493 in.getline(line,80);
494 tmp = line;
495 pos = tmp.First(" ");
496 tmp = tmp(0,pos);
37dacd7d 497 cfg.SetMaxEvents(tmp.Atoi());
4fd5ed63 498
327f7faa 499 in.getline(line,80);
500 tmp = line;
501 pos = tmp.First(" ");
502 tmp = tmp(0,pos);
37dacd7d 503 if (tmp.Atoi() != 0) cfg.SetWithWarnings();
327f7faa 504
e8f1ed57 505 in.getline(line,80);
506 tmp = line;
507 pos = tmp.First(" ");
508 tmp = tmp(0,pos);
509 if (tmp.Atoi() != 0) cfg.SetUseFastDecoder();
510
98bdda22 511 in.getline(line,80);
512 tmp = line;
513 pos = tmp.First(" ");
514 tmp = tmp(0,pos);
515 cfg.SetThrLocN(tmp.Atof());
516
517 in.getline(line,80);
518 tmp = line;
519 pos = tmp.First(" ");
520 tmp = tmp(0,pos);
521 cfg.SetThrLocD(tmp.Atof());
522
523 in.getline(line,80);
524 tmp = line;
525 pos = tmp.First(" ");
526 tmp = tmp(0,pos);
527 cfg.SetDAMode(tmp.Atoi());
528
529 return kTRUE;
4fd5ed63 530
327f7faa 531}
4fd5ed63 532
4fd5ed63 533//__________________________________________________________________
37dacd7d 534void WriteLastCurrentFile(AliDAConfig& cfg, TString currentFile)
4fd5ed63 535{
37dacd7d 536 /// write last current file
4fd5ed63 537
4fd5ed63 538 ofstream out;
539 TString file;
540 file = currentFile;
541 out.open(file.Data());
37dacd7d 542 out << cfg.GetSodName() << " " << cfg.GetSodFlag() << endl;
543 out << cfg.GetDAName() << " " << cfg.GetDAFlag() << endl;
4fd5ed63 544
37dacd7d 545 out << cfg.GetGlobalFileName() << " " << cfg.GetGlobalFileVersion() << endl;
546 out << cfg.GetRegionalFileName() << " " << cfg.GetRegionalFileVersion() << endl;
547 out << cfg.GetLocalMaskFileName() << " " << cfg.GetLocalMaskFileVersion() << endl;
548 out << cfg.GetLocalLutFileName() << " " << cfg.GetLocalLutFileVersion() << endl;
549 out << cfg.GetSignatureFileName() << " " << cfg.GetSignatureFileVersion() << endl;
4fd5ed63 550
551 out.close();
552}
553
554//___________________________________________________________________________________________
98bdda22 555Bool_t ReadCurrentFile(AliDAConfig& cfg, TString currentFile, Bool_t lastCurrentFlag = kFALSE)
4fd5ed63 556{
37dacd7d 557 /// read last current file name and version
4fd5ed63 558
4fd5ed63 559 char line[80];
560 char name[80];
37dacd7d 561 Int_t flag;
4fd5ed63 562
563 TString file;
564 file = currentFile;
565 std::ifstream in(gSystem->ExpandPathName(file.Data()));
566 if (!in.good()) {
567 printf("Cannot open last current file %s\n",currentFile.Data());
98bdda22 568 return kFALSE;
4fd5ed63 569 }
570
4fd5ed63 571 // read SOD
572 in.getline(line,80);
37dacd7d 573 sscanf(line, "%s %d", name, &flag);
574 cfg.SetSodName(name);
575 cfg.SetSodFlag(flag);
576 if (cfg.GetPrintLevel()) printf("Sod Flag %d\n", cfg.GetSodFlag());
4fd5ed63 577
578 //read DA
579 in.getline(line,80);
37dacd7d 580 sscanf(line, "%s %d", name, &flag);
581 cfg.SetDAName(name);
582 cfg.SetDAFlag(flag);
583 if (cfg.GetPrintLevel()) printf("DA Flag: %d\n", cfg.GetDAFlag());
4fd5ed63 584
4fd5ed63 585 // read global
586 in.getline(line,80);
587 TString tmp(line);
588 Int_t pos = tmp.First(" ");
37dacd7d 589 TString tmp1 = tmp(0, pos);
590 cfg.SetGlobalFileName(tmp1.Data());
4fd5ed63 591
592 if (!lastCurrentFlag) {
37dacd7d 593 cfg.SetGlobalFileVersion(atoi(tmp(pos+1, tmp.Length()-pos).Data()));
594 if (cfg.GetPrintLevel()) printf("Global File Name: %s version: %d\n",
595 cfg.GetGlobalFileName(), cfg.GetGlobalFileVersion());
4fd5ed63 596 } else {
37dacd7d 597 cfg.SetGlobalFileLastVersion(atoi(tmp(pos+1, tmp.Length()-pos).Data()));
598 if (cfg.GetPrintLevel()) printf("Global File Name: %s last version: %d\n",
599 cfg.GetGlobalFileName(), cfg.GetGlobalFileLastVersion());
4fd5ed63 600 }
601
602 // read regional
603 in.getline(line,80);
604 tmp = line;
605 pos = tmp.First(" ");
37dacd7d 606 tmp1 = tmp(0, pos);
607 cfg.SetRegionalFileName(tmp1.Data());
4fd5ed63 608
609 if (!lastCurrentFlag) {
37dacd7d 610 cfg.SetRegionalFileVersion(atoi(tmp(pos+1, tmp.Length()-pos).Data()));
611 if (cfg.GetPrintLevel()) printf("Regional File Name: %s version: %d\n",
612 cfg.GetRegionalFileName(), cfg.GetRegionalFileVersion());
4fd5ed63 613
614 } else {
37dacd7d 615 cfg.SetRegionalFileLastVersion(atoi(tmp(pos+1, tmp.Length()-pos).Data()));
616 if (cfg.GetPrintLevel()) printf("Regional File Name: %s last version: %d\n",
617 cfg.GetRegionalFileName(), cfg.GetRegionalFileLastVersion());
4fd5ed63 618 }
619
4fd5ed63 620 // read mask
621 in.getline(line,80);
622 tmp = line;
623 pos = tmp.First(" ");
37dacd7d 624 tmp1 = tmp(0, pos);
625 cfg.SetLocalMaskFileName(tmp1.Data());
4fd5ed63 626
627 if (!lastCurrentFlag) {
37dacd7d 628 cfg.SetLocalMaskFileVersion(atoi(tmp(pos+1, tmp.Length()-pos).Data()));
629 if (cfg.GetPrintLevel()) printf("Mask File Name: %s version: %d\n",
630 cfg.GetLocalMaskFileName(), cfg.GetLocalMaskFileVersion());
4fd5ed63 631 } else {
37dacd7d 632 cfg.SetLocalMaskFileLastVersion(atoi(tmp(pos+1, tmp.Length()-pos).Data()));
633 if (cfg.GetPrintLevel()) printf("Mask File Name: %s last version: %d\n",
634 cfg.GetLocalMaskFileName(), cfg.GetLocalMaskFileLastVersion());
4fd5ed63 635 }
636 // read Lut
637 in.getline(line,80);
638 tmp = line;
639 pos = tmp.First(" ");
37dacd7d 640 tmp1 = tmp(0, pos);
641 cfg.SetLocalLutFileName(tmp1.Data());
4fd5ed63 642
643 if (!lastCurrentFlag) {
37dacd7d 644 cfg.SetLocalLutFileVersion(atoi(tmp(pos+1, tmp.Length()-pos).Data()));
645 if (cfg.GetPrintLevel()) printf("Lut File Name: %s version: %d\n",
646 cfg.GetLocalLutFileName(), cfg.GetLocalLutFileVersion());
4fd5ed63 647 } else {
37dacd7d 648 cfg.SetLocalLutFileLastVersion(atoi(tmp(pos+1, tmp.Length()-pos).Data()));
649 if (cfg.GetPrintLevel()) printf("Lut File Name: %s last version: %d\n",
650 cfg.GetLocalLutFileName(), cfg.GetLocalLutFileLastVersion());
4fd5ed63 651 }
652
653 in.getline(line,80);
654 tmp = line;
655 pos = tmp.First(" ");
37dacd7d 656 tmp1 = tmp(0, pos);
657 cfg.SetSignatureFileName(tmp1.Data());
658 cfg.SetSignatureFileVersion(atoi(tmp(pos+1, tmp.Length()-pos).Data()));
659 if (cfg.GetPrintLevel()) printf("Lut File Name: %s version: %d\n",
660 cfg.GetSignatureFileName(), cfg.GetSignatureFileVersion());
4fd5ed63 661
98bdda22 662 return kTRUE;
4fd5ed63 663}
664
665//_____________
37dacd7d 666void ReadFileNames(AliDAConfig& cfg)
4fd5ed63 667{
37dacd7d 668 /// if last current file does not exist than read current file
327f7faa 669
98bdda22 670 if (!ReadCurrentFile(cfg,cfg.GetLastCurrentFileName(), kTRUE))
4fd5ed63 671 {
98bdda22 672 ReadCurrentFile(cfg,cfg.GetCurrentFileName(), kTRUE);
4fd5ed63 673 }
37dacd7d 674
675 // any case read current file
676 ReadCurrentFile(cfg,cfg.GetCurrentFileName());
677
4fd5ed63 678}
679
680//__________________
37dacd7d 681Bool_t ExportFiles(AliDAConfig& cfg)
4fd5ed63 682{
37dacd7d 683 /// Export files to FES
4fd5ed63 684
4fd5ed63 685 // env variables have to be set (suppose by ECS ?)
686 // setenv DATE_FES_PATH
687 // setenv DATE_RUN_NUMBER
688 // setenv DATE_ROLE_NAME
689 // setenv DATE_DETECTOR_CODE
690
e8f1ed57 691#ifdef OFFLINE
692 gSystem->Setenv("DAQDALIB_PATH", "$DATE_SITE/infoLogger");
693 gSystem->Setenv("DAQDA_TEST_DIR", "/alisoft/FES");
694#endif
8f8ae0de 695
4fd5ed63 696 // update files
697 Int_t status = 0;
698
98bdda22 699 Bool_t modified = kFALSE;
700 Bool_t globalExported = kFALSE;
4fd5ed63 701
702 ofstream out;
703 TString fileExp("ExportedFiles.dat");
704 TString file;
705
706 out.open(fileExp.Data());
707 if (!out.good()) {
708 printf("Failed to create file: %s\n",file.Data());
98bdda22 709 return kFALSE;
113ad708 710 }
4fd5ed63 711
8f8ae0de 712 // check if MtgLastCurrent.dat exists
713 // if not, do initial export of all files
98bdda22 714 Bool_t initFES = kFALSE;
8f8ae0de 715 if (gSystem->AccessPathName("MtgLastCurrent.dat"))
98bdda22 716 initFES = kTRUE;
8f8ae0de 717 if (initFES) printf("Copy all configuration files to the FES.\n");
718
37dacd7d 719 file = cfg.GetLocalMaskFileName();
720 if ((cfg.GetLocalMaskFileLastVersion() != cfg.GetLocalMaskFileVersion()) || initFES) {
98bdda22 721 modified = kTRUE;
e8f1ed57 722 status = daqDA_FES_storeFile(file.Data(), "LOCAL");
4fd5ed63 723 if (status) {
37dacd7d 724 printf("Failed to export file: %s\n",cfg.GetLocalMaskFileName());
98bdda22 725 return kFALSE;
4fd5ed63 726 }
37dacd7d 727 if(cfg.GetPrintLevel()) printf("Export file: %s\n",cfg.GetLocalMaskFileName());
728 out << cfg.GetLocalMaskFileName() << endl;
4fd5ed63 729 }
730
37dacd7d 731 file = cfg.GetLocalLutFileName();
732 if ((cfg.GetLocalLutFileLastVersion() != cfg.GetLocalLutFileVersion()) || initFES) {
98bdda22 733 modified = kTRUE;
e8f1ed57 734 status = daqDA_FES_storeFile(file.Data(), "LUT");
4fd5ed63 735 if (status) {
37dacd7d 736 printf("Failed to export file: %s\n",cfg.GetLocalLutFileName());
98bdda22 737 return kFALSE;
4fd5ed63 738 }
37dacd7d 739 if(cfg.GetPrintLevel()) printf("Export file: %s\n",cfg.GetLocalLutFileName());
740 out << cfg.GetLocalLutFileName() << endl;
4fd5ed63 741
742 }
743
bb440407 744 file = cfg.GetGlobalFileName();
745 if ((cfg.GetGlobalFileLastVersion() != cfg.GetGlobalFileVersion()) || modified || initFES) {
98bdda22 746 modified = kTRUE;
747 globalExported = kTRUE;
bb440407 748 status = daqDA_FES_storeFile(file.Data(), "GLOBAL");
749 if (status) {
750 printf("Failed to export file: %s\n",cfg.GetGlobalFileName());
98bdda22 751 return kFALSE;
bb440407 752 }
753 if(cfg.GetPrintLevel()) printf("Export file: %s\n",cfg.GetGlobalFileName());
754 out << cfg.GetGlobalFileName() << endl;
755 }
756
37dacd7d 757 file = cfg.GetRegionalFileName();
758 if ( (cfg.GetRegionalFileLastVersion() != cfg.GetRegionalFileVersion()) || modified || initFES) {
e8f1ed57 759 status = daqDA_FES_storeFile(file.Data(), "REGIONAL");
4fd5ed63 760 if (status) {
37dacd7d 761 printf("Failed to export file: %s\n",cfg.GetRegionalFileName());
98bdda22 762 return kFALSE;
4fd5ed63 763 }
37dacd7d 764 if(cfg.GetPrintLevel()) printf("Export file: %s\n",cfg.GetRegionalFileName());
765 out << cfg.GetRegionalFileName() << endl;
bb440407 766
767 // needed for the initialisation of the mapping
768 if (!globalExported) {
769 file = cfg.GetGlobalFileName();
770 status = daqDA_FES_storeFile(file.Data(), "GLOBAL");
771 if (status) {
772 printf("Failed to export file: %s\n",cfg.GetGlobalFileName());
98bdda22 773 return kFALSE;
bb440407 774 }
775 if(cfg.GetPrintLevel()) printf("Export file: %s\n",cfg.GetGlobalFileName());
776 out << cfg.GetGlobalFileName() << endl;
777 }
778
4fd5ed63 779 }
780
781 out.close();
782
783 // export Exported file to FES anyway
e8f1ed57 784 status = daqDA_FES_storeFile(fileExp.Data(), "EXPORTED");
4fd5ed63 785 if (status) {
786 printf("Failed to export file: %s\n", fileExp.Data());
98bdda22 787 return kFALSE;
4fd5ed63 788 }
37dacd7d 789 if(cfg.GetPrintLevel()) printf("Export file: %s\n",fileExp.Data());
4fd5ed63 790
113ad708 791 // write last current file
37dacd7d 792 WriteLastCurrentFile(cfg,cfg.GetLastCurrentFileName());
113ad708 793
98bdda22 794 return kTRUE;
4fd5ed63 795}
41a38dec 796
4fd5ed63 797//__________________
37dacd7d 798Bool_t ImportFiles(AliDAConfig& cfg)
4fd5ed63 799{
37dacd7d 800 /// copy locally a file from daq detector config db
801 /// The current detector is identified by detector code in variable
802 /// DATE_DETECTOR_CODE. It must be defined.
803 /// If environment variable DAQDA_TEST_DIR is defined, files are copied from
804 /// DAQDA_TEST_DIR instead of the database.
805 /// The usual environment variables are not needed.
4fd5ed63 806
41a38dec 807 Int_t status = 0;
4fd5ed63 808
e8f1ed57 809#ifdef OFFLINE
810 gSystem->Setenv("DAQDALIB_PATH", "$DATE_SITE/db");
811#endif
113ad708 812
37dacd7d 813 status = daqDA_DB_getFile(cfg.GetDAConfigFileName(), cfg.GetDAConfigFileName());
4fd5ed63 814 if (status) {
37dacd7d 815 printf("Failed to get DA config file from DB: %s\n",cfg.GetDAConfigFileName());
98bdda22 816 return kFALSE;
4fd5ed63 817 }
818
327f7faa 819 ReadDAConfig(cfg);
e8f1ed57 820
37dacd7d 821 status = daqDA_DB_getFile(cfg.GetCurrentFileName(), cfg.GetCurrentFileName());
4fd5ed63 822 if (status) {
37dacd7d 823 printf("Failed to get current config file from DB: %s\n",cfg.GetCurrentFileName());
98bdda22 824 return kFALSE;
4fd5ed63 825 }
e8f1ed57 826
327f7faa 827 ReadFileNames(cfg);
4fd5ed63 828
37dacd7d 829 status = daqDA_DB_getFile(cfg.GetGlobalFileName(), cfg.GetGlobalFileName());
327f7faa 830 if (status) {
37dacd7d 831 printf("Failed to get current config file from DB: %s\n", cfg.GetGlobalFileName());
98bdda22 832 return kFALSE;
327f7faa 833 }
41a38dec 834
37dacd7d 835 status = daqDA_DB_getFile(cfg.GetRegionalFileName(), cfg.GetRegionalFileName());
4fd5ed63 836 if (status) {
37dacd7d 837 printf("Failed to get current config file from DB: %s\n",cfg.GetRegionalFileName());
98bdda22 838 return kFALSE;
4fd5ed63 839 }
840
37dacd7d 841 status = daqDA_DB_getFile(cfg.GetLocalMaskFileName(), cfg.GetLocalMaskFileName());
4fd5ed63 842 if (status) {
37dacd7d 843 printf("Failed to get current config file from DB: %s\n",cfg.GetLocalMaskFileName());
98bdda22 844 return kFALSE;
4fd5ed63 845 }
846
37dacd7d 847 status = daqDA_DB_getFile(cfg.GetLocalLutFileName(), cfg.GetLocalLutFileName());
4fd5ed63 848 if (status) {
37dacd7d 849 printf("Failed to get current config file from DB: %s\n",cfg.GetLocalLutFileName());
98bdda22 850 return kFALSE;
4fd5ed63 851 }
852
98bdda22 853 return kTRUE;
4fd5ed63 854}
855
856//_____________
37dacd7d 857void ReadMaskFiles(AliDAConfig& cfg)
4fd5ed63 858{
37dacd7d 859 /// read mask files
327f7faa 860
37dacd7d 861 const Char_t* localFile = cfg.GetLocalMaskFileName();
862 const Char_t* regionalFile = cfg.GetRegionalFileName();
863 const Char_t* globalFile = cfg.GetGlobalFileName();
4fd5ed63 864
37dacd7d 865 cfg.GetTriggerIO()->ReadConfig(localFile, regionalFile, globalFile, cfg.GetLocalMasks(), cfg.GetRegionalMasks(), cfg.GetGlobalMasks());
4fd5ed63 866}
4fd5ed63 867
41a38dec 868//______________________________________________________________
37dacd7d 869UInt_t GetFetMode(const AliDAConfig & cfg)
41a38dec 870{
37dacd7d 871 /// FET mode = 3 to run algorithm for dead global inputs
872 /// 0x3 prepulse
873 /// 0x0 internal
4fd5ed63 874
37dacd7d 875 return cfg.GetGlobalMasks()->GetFetRegister(3);
4fd5ed63 876
41a38dec 877}
4fd5ed63 878
41a38dec 879//______________________________________________________________
37dacd7d 880void StoreGlobalInput(AliDAConfig& cfg, const UInt_t * const globalInput)
41a38dec 881{
37dacd7d 882 /// accumulate and build statistics of global input values
41a38dec 883
37dacd7d 884 for (Int_t ii = 0; ii < cfg.GetGlobalInputs(); ii++) {
885 for (Int_t ib = 0; ib < cfg.GetGlobalInputLength(); ib++) {
41a38dec 886 // lsb -> msb
37dacd7d 887 if (cfg.GetAlgoNoisyInput())
888 cfg.AddAccGlobalInputN(ii,ib,((globalInput[ii] >> ib) & 0x1));
889 if (cfg.GetAlgoDeadcInput())
890 cfg.AddAccGlobalInputD(ii,ib,((globalInput[ii] >> ib) & 0x1));
4fd5ed63 891 }
41a38dec 892 }
4fd5ed63 893
894}
895
41a38dec 896//______________________________________________________________
37dacd7d 897void UpdateGlobalMasks(AliDAConfig& cfg)
4fd5ed63 898{
37dacd7d 899 /// update the global masks
4fd5ed63 900
e8f1ed57 901#ifdef OFFLINE
902 gSystem->Setenv("DAQDALIB_PATH", "$DATE_SITE/db");
903#endif
327f7faa 904
41a38dec 905 Float_t rateN = 0.0, rateD = 0.0;
906 UInt_t gmask[4], omask;
98bdda22 907 Bool_t noise, deadc, withEvN, withEvD, updated = kFALSE;
41a38dec 908
37dacd7d 909 for (Int_t ii = 0; ii < cfg.GetGlobalInputs(); ii++) {
41a38dec 910 gmask[ii] = 0;
911
37dacd7d 912 for (Int_t ib = 0; ib < cfg.GetGlobalInputLength(); ib++) {
41a38dec 913 // lsb -> msb
98bdda22 914 noise = kFALSE;
915 deadc = kFALSE;
916 withEvN = kFALSE;
917 withEvD = kFALSE;
37dacd7d 918 if (cfg.GetEventsN() > cfg.GetMinEvents()) {
919 rateN = (Float_t)cfg.GetAccGlobalInputN(ii,ib)/(Float_t)cfg.GetEventsN();
920 noise = (rateN > cfg.GetThrN());
98bdda22 921 withEvN = kTRUE;
4fd5ed63 922 }
37dacd7d 923 if (cfg.GetEventsD() > cfg.GetMinEvents()) {
924 rateD = (Float_t)cfg.GetAccGlobalInputD(ii,ib)/(Float_t)cfg.GetEventsD();
925 deadc = (rateD < cfg.GetThrD());
98bdda22 926 withEvD = kTRUE;
41a38dec 927 }
928 if (!withEvN && !withEvD) {
929 // - copy the bit from the old mask
37dacd7d 930 gmask[ii] |= ((cfg.GetGlobalMasks()->GetGlobalMask(ii) >> ib) & 0x1) << ib;
e8f1ed57 931 if (cfg.GetPrintLevel())
932 printf("Mask not changed (just copy the old values)\n");
41a38dec 933 }
934 if (!withEvN && withEvD) {
935 if (!deadc) {
936 // - create a new mask, set the bit to 1
8f8ae0de 937 // not allowed!
938 //gmask[ii] |= 0x1 << ib;
939 // - copy the bit from the old mask
37dacd7d 940 gmask[ii] |= ((cfg.GetGlobalMasks()->GetGlobalMask(ii) >> ib) & 0x1) << ib;
41a38dec 941 } else {
942 // - create a new mask, set the bit to 0
943 gmask[ii] |= 0x0 << ib;
e8f1ed57 944 if (cfg.GetPrintLevel())
945 printf("Found dead channel %1d:%02d (%4.2f) \n",ii,ib,rateD);
4fd5ed63 946 }
41a38dec 947 }
948 if (withEvN && !withEvD) {
949 if (!noise) {
950 // - create a new mask, set the bit to 1
8f8ae0de 951 // not allowed!
952 //gmask[ii] |= 0x1 << ib;
953 // - copy the bit from the old mask
37dacd7d 954 gmask[ii] |= ((cfg.GetGlobalMasks()->GetGlobalMask(ii) >> ib) & 0x1) << ib;
41a38dec 955 } else {
956 // - create a new mask, set the bit to 0
957 gmask[ii] |= 0x0 << ib;
e8f1ed57 958 if (cfg.GetPrintLevel())
959 printf("Found noisy channel %1d:%02d (%4.2f) \n",ii,ib,rateN);
41a38dec 960 }
961 }
962 if (withEvN && withEvD) {
963 if (!noise && !deadc) {
964 // - create a new mask, set the bit to 1
8f8ae0de 965 // not allowed!
966 //gmask[ii] |= 0x1 << ib;
967 // - copy the bit from the old mask
37dacd7d 968 gmask[ii] |= ((cfg.GetGlobalMasks()->GetGlobalMask(ii) >> ib) & 0x1) << ib;
41a38dec 969 } else {
970 // - create a new mask, set the bit to 0
971 gmask[ii] |= 0x0 << ib;
e8f1ed57 972 if (cfg.GetPrintLevel()) {
973 if (noise)
974 printf("Found noisy channel %1d:%02d (%4.2f) \n",ii,ib,rateN);
975 if (deadc)
976 printf("Found dead channel %1d:%02d (%4.2f) \n",ii,ib,rateD);
977 }
4fd5ed63 978 }
4fd5ed63 979 }
980 }
41a38dec 981 }
982
983 // check if at least one mask value has been changed from previous version
37dacd7d 984 for (Int_t ii = 0; ii < cfg.GetGlobalInputs(); ii++) {
327f7faa 985 printf("Global mask [%1d] %08x \n",ii,gmask[ii]);
37dacd7d 986 omask = cfg.GetGlobalMasks()->GetGlobalMask(ii);
41a38dec 987 if (gmask[ii] != omask) {
98bdda22 988 updated = kTRUE;
37dacd7d 989 cfg.GetGlobalMasks()->SetGlobalMask(ii,gmask[ii]);
4fd5ed63 990 }
41a38dec 991 }
4fd5ed63 992
41a38dec 993 Int_t status = 0;
994 if (updated) {
995
996 // update version
37dacd7d 997 cfg.IncGlobalFileVersion();
41a38dec 998
999 // don't change the file version ("-x.dat")
1000
37dacd7d 1001 cfg.GetTriggerIO()->WriteGlobalConfig(cfg.GetGlobalFileName(),cfg.GetGlobalMasks());
41a38dec 1002
1003 // write last current file
37dacd7d 1004 WriteLastCurrentFile(cfg,cfg.GetCurrentFileName());
4fd5ed63 1005
37dacd7d 1006 status = daqDA_DB_storeFile(cfg.GetGlobalFileName(), cfg.GetGlobalFileName());
41a38dec 1007 if (status) {
37dacd7d 1008 printf("Failed to export file to DB: %s\n",cfg.GetGlobalFileName());
41a38dec 1009 return;
1010 }
1011
37dacd7d 1012 status = daqDA_DB_storeFile(cfg.GetCurrentFileName(), cfg.GetCurrentFileName());
41a38dec 1013 if (status) {
37dacd7d 1014 printf("Failed to export file to DB: %s\n",cfg.GetCurrentFileName());
41a38dec 1015 return;
1016 }
113ad708 1017
41a38dec 1018 }
1019
1020}
113ad708 1021
98bdda22 1022//______________________________________________________________
1023void UpdateLocalMask(AliDAConfig& cfg, Int_t localBoardId, Int_t connector, Int_t strip)
1024{
1025
1026 /// update local strip mask
1027
1028 AliMUONVCalibParam* localMask =
1029 static_cast<AliMUONVCalibParam*>(cfg.GetLocalMasksDA()->FindObject(localBoardId));
1030
1031 UShort_t mask = static_cast<UShort_t>(localMask->ValueAsInt(connector,0));
1032
1033 mask &= ~(0x1 << strip); // set strip mask to zero
1034
1035 localMask->SetValueAsInt(connector, 0, mask);
1036
1037}
1038
1039//______________________________________________________________
1040void MakePattern(AliDAConfig& cfg, Int_t localBoardId, const TArrayS& xPattern, const TArrayS& yPattern)
1041{
1042 /// calculate the hit map for each strip in x and y direction
1043
1044 AliMUONVCalibParam* pat = 0x0;
1045
1046 if (cfg.GetAlgoNoisyInput())
1047 pat = static_cast<AliMUONVCalibParam*>(cfg.GetPatternStoreN()->FindObject(localBoardId));
1048 if (cfg.GetAlgoDeadcInput())
1049 pat = static_cast<AliMUONVCalibParam*>(cfg.GetPatternStoreD()->FindObject(localBoardId));
1050
1051 if (!pat) {
1052 pat = new AliMUONCalibParamND(2, 64, localBoardId, 0, 0.);
1053 if (cfg.GetAlgoNoisyInput())
1054 cfg.GetPatternStoreN()->Add(pat);
1055 if (cfg.GetAlgoDeadcInput())
1056 cfg.GetPatternStoreD()->Add(pat);
1057 }
1058
1059 for (Int_t i = 0; i < 4; ++i) {
1060 for (Int_t j = 0; j < 16; ++j) {
1061
1062 Int_t xMask = xPattern[i];
1063 Int_t yMask = yPattern[i];
1064
1065 Int_t index = 16*i + j;
1066 Double_t patOcc = 0.;
1067
1068 if ( (xMask >> j ) & 0x1 ) {
1069 patOcc = pat->ValueAsDouble(index, 0) + 1.;
1070 pat->SetValueAsDouble(index, 0, patOcc);
1071 }
1072 if ( (yMask >> j ) & 0x1 ) {
1073 patOcc = pat->ValueAsDouble(index, 1) + 1.;
1074 pat->SetValueAsDouble(index, 1, patOcc);
1075 }
1076 }
1077 }
1078
1079}
1080
1081//______________________________________________________________
1082void MakePatternStore(AliDAConfig& cfg)
1083{
1084 /// analyse patterns for local strips (calculate occupancy)
1085
1086#ifdef OFFLINE
1087 gSystem->Setenv("DAQDALIB_PATH", "$DATE_SITE/db");
1088#endif
1089
1090 AliMUONVCalibParam* pat;
1091 Int_t localBoardId = 0;
1092 Int_t nEventsN = 0, nEventsD = 0;
1093 UShort_t strip = 0;
1094 Int_t connector = 0;
1095 Bool_t updated = kFALSE;
1096
1097 if (cfg.GetEventsN() > cfg.GetMinEvents()) {
1098 nEventsN = cfg.GetEventsN();
1099 }
1100 if (cfg.GetEventsD() > cfg.GetMinEvents()) {
1101 nEventsD = cfg.GetEventsD();
1102 }
1103
1104 // noisy strips
1105 if (nEventsN > 0) {
1106
1107 TIter next(cfg.GetPatternStoreN()->CreateIterator());
1108
1109 while ( ( pat = dynamic_cast<AliMUONVCalibParam*>(next() ) ) ) {
1110
1111 localBoardId = pat->ID0();
1112
1113 for (Int_t index = 0; index < pat->Size(); index++) {
1114
1115 Double_t patXOcc = pat->ValueAsDouble(index, 0)/(Double_t)nEventsN;
1116 Double_t patYOcc = pat->ValueAsDouble(index, 1)/(Double_t)nEventsN;
1117
1118 pat->SetValueAsDouble(index, 0, patXOcc);
1119 pat->SetValueAsDouble(index, 1, patYOcc);
1120
1121 // check for x strip
1122 if (patXOcc > cfg.GetThrLocN()) {
1123 strip = index % 16;
1124 connector = index/16;
1125 UpdateLocalMask(cfg, localBoardId, connector, strip);
1126 }
1127 // check for y strip
1128 if (patYOcc > cfg.GetThrLocN()) {
1129 strip = index % 16;
1130 connector = index/16 + 4;
1131 UpdateLocalMask(cfg, localBoardId, connector, strip);
1132 }
1133
1134 }
1135 }
1136
1137 }
1138
1139 // dead strips
1140 if (nEventsD > 0) {
1141
1142 TIter next(cfg.GetPatternStoreD()->CreateIterator());
1143
1144 while ( ( pat = dynamic_cast<AliMUONVCalibParam*>(next() ) ) ) {
1145
1146 localBoardId = pat->ID0();
1147
1148 for (Int_t index = 0; index < pat->Size(); index++) {
1149
1150 Double_t patXOcc = pat->ValueAsDouble(index, 0)/(Double_t)nEventsD;
1151 Double_t patYOcc = pat->ValueAsDouble(index, 1)/(Double_t)nEventsD;
1152
1153 pat->SetValueAsDouble(index, 0, patXOcc);
1154 pat->SetValueAsDouble(index, 1, patYOcc);
1155
1156 // check for x strip
1157 if (patXOcc < cfg.GetThrLocD()) {
1158 strip = index % 16;
1159 connector = index/16;
1160 UpdateLocalMask(cfg, localBoardId, connector, strip);
1161 }
1162 // check for y strip
1163 if (patYOcc < cfg.GetThrLocD()) {
1164 strip = index % 16;
1165 connector = index/16 + 4;
1166 UpdateLocalMask(cfg, localBoardId, connector, strip);
1167 }
1168
1169 }
1170 }
1171
1172 }
1173
7df9b0e4 1174 // make and AND with the previous version of the mask and
1175 // check if the mask has changed
98bdda22 1176 UShort_t maskDA, mask;
7df9b0e4 1177 Int_t nMaskBits = AliMpConstants::TotalNofLocalBoards()*8*16;
1178 Int_t nMaskBitsChanged = 0;
98bdda22 1179 for (localBoardId = 1; localBoardId <= AliMpConstants::TotalNofLocalBoards(); localBoardId++) {
1180 AliMUONVCalibParam* localMaskDA = static_cast<AliMUONVCalibParam*>(cfg.GetLocalMasksDA()->FindObject(localBoardId));
1181 AliMUONVCalibParam* localMask = static_cast<AliMUONVCalibParam*>(cfg.GetLocalMasks()->FindObject(localBoardId));
1182 for (connector = 0; connector < 8; connector++) {
1183 maskDA = static_cast<UShort_t>(localMaskDA->ValueAsInt(connector,0));
7df9b0e4 1184 mask = static_cast<UShort_t>(localMask->ValueAsInt(connector,0));
1185 maskDA &= mask;
1186 localMaskDA->SetValueAsInt(connector, 0, maskDA);
98bdda22 1187 if (maskDA != mask) {
1188 updated = kTRUE;
7df9b0e4 1189 // calculated percentage of mask bits changed
1190 for (Int_t iBit = 0; iBit < 16; iBit++) {
1191 if (((maskDA >> iBit) & 0x1) != ((mask >> iBit) &0x1)) {
1192 nMaskBitsChanged++;
1193 }
1194 }
98bdda22 1195 }
1196 }
1197 }
1198
5f6ff25f 1199 printf("LOCAL mask bits changed = %5d (%7.3f %%) \n",nMaskBitsChanged,100*(Float_t)nMaskBitsChanged/(Float_t)nMaskBits);
7df9b0e4 1200
98bdda22 1201 Int_t status = 0;
1202 if (updated) {
1203
1204 // update version
1205 cfg.IncLocalMaskFileVersion();
1206
1207 // don't change the file version ("-x.dat")
1208
1209 cfg.GetTriggerIO()->WriteLocalMasks(cfg.GetLocalMaskFileName(),*cfg.GetLocalMasksDA(),cfg.GetRegionalMasks());
1210
1211 // write last current file
1212 WriteLastCurrentFile(cfg,cfg.GetCurrentFileName());
1213
1214 status = daqDA_DB_storeFile(cfg.GetLocalMaskFileName(), cfg.GetLocalMaskFileName());
1215 if (status) {
1216 printf("Failed to export file to DB: %s\n",cfg.GetLocalMaskFileName());
1217 return;
1218 }
1219
1220 status = daqDA_DB_storeFile(cfg.GetCurrentFileName(), cfg.GetCurrentFileName());
1221 if (status) {
1222 printf("Failed to export file to DB: %s\n",cfg.GetCurrentFileName());
1223 return;
1224 }
1225
1226 }
1227
1228}
1229
9f5fafa6 1230//*************************************************************//
9f5fafa6 1231int main(Int_t argc, Char_t **argv)
1232{
37dacd7d 1233 /// main routine
9f5fafa6 1234
1235 // needed for streamer application
327f7faa 1236 gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo", "*", "TStreamerInfo", "RIO", "TStreamerInfo()");
1237
1238 /* check that we got some arguments = list of files */
1239 if (argc<2) {
1240 printf("Wrong number of arguments\n");
1241 return -1;
1242 }
1243
37dacd7d 1244 AliDAConfig cfg;
9f5fafa6 1245
8f8ae0de 1246 Char_t inputFile[256] = "";
113ad708 1247 inputFile[0] = 0;
1248 if (argc > 1)
1249 if (argv[1] != NULL)
1250 strncpy(inputFile, argv[1], 256);
1251 else {
1252 printf("MUONTRGda : No input File !\n");
1253 return -1;
1254 }
9f5fafa6 1255
4fd5ed63 1256 // decoding the events
9f5fafa6 1257
bb440407 1258 Int_t status = 0;
4fd5ed63 1259 Int_t nDateEvents = 0;
9f5fafa6 1260
4fd5ed63 1261 void* event;
9f5fafa6 1262
4fd5ed63 1263 // containers
e8f1ed57 1264 // old decoder
98bdda22 1265 AliMUONDDLTrigger* ddlTrigger = 0x0;
1266 AliMUONDarcHeader* darcHeader = 0x0;
1267 AliMUONRegHeader* regHeader = 0x0;
1268 AliMUONLocalStruct* localStruct = 0x0;
e8f1ed57 1269 // new (fast) decoder
98bdda22 1270 const AliMUONRawStreamTriggerHP::AliHeader* darcHeaderHP = 0x0;
1271 const AliMUONRawStreamTriggerHP::AliLocalStruct* localStructHP = 0x0;
1272
1273 TArrayS xPattern(4);
1274 TArrayS yPattern(4);
1275 Int_t localBoardId = 0;
9f5fafa6 1276
4fd5ed63 1277 TStopwatch timers;
9f5fafa6 1278
4fd5ed63 1279 timers.Start(kTRUE);
9f5fafa6 1280
4fd5ed63 1281 // comment out, since we do not retrieve files from database
327f7faa 1282 if (!ImportFiles(cfg)) {
4fd5ed63 1283 printf("Import from DB failed\n");
1284 printf("For local test set DAQDA_TEST_DIR to the local directory where the Mtg files are located \n");
9f5fafa6 1285 return -1;
1286 }
327f7faa 1287
1288 ReadMaskFiles(cfg);
4fd5ed63 1289
e8f1ed57 1290#ifdef OFFLINE
1291 // the run number extracted from the file name
1292 TString tmp(inputFile);
5f6ff25f 1293 Int_t pos1 = tmp.First('d');
1294 Int_t pos2 = tmp.Last('.');
1295 Int_t len = pos2 - (pos1+3);
1296 tmp = tmp(pos1+3,len);
e8f1ed57 1297 gSystem->Setenv("DATE_RUN_NUMBER",tmp.Data());
1298 gSystem->Exec("echo \"DATE_RUN_NUMBER = \" $DATE_RUN_NUMBER");
1299#endif
37dacd7d 1300
327f7faa 1301 if(!ExportFiles(cfg)) {
41a38dec 1302 printf("ExportFiles failed\n");
1303 return -1;
1304 }
1305
bb440407 1306 if (!cfg.GetDAFlag()) {
1307
1308 cout << "MUONTRGda: DA enable: " << cfg.GetDAFlag() << endl;
1309 cout << "MUONTRGda: Print level: " << cfg.GetPrintLevel() << endl;
1310
1311 printf("MUONTRGda: Execution time : R:%7.2fs C:%7.2fs\n", timers.RealTime(), timers.CpuTime());
1312
1313 return status;
1314
1315 }
1316
41a38dec 1317 // FET is triggered by CTP
e8f1ed57 1318 Bool_t modeFET3 = kTRUE;
327f7faa 1319 if (GetFetMode(cfg) != 3) {
e8f1ed57 1320 printf("FET is not in mode 3. Only PHYSICS events will be analysed (noisy channels)\n");
1321 modeFET3 = kFALSE;
41a38dec 1322 }
1323
1324 // All 5 global cards are controlled by the Mts proxy
37dacd7d 1325 if (cfg.GetGlobalMasks()->GetGlobalCrateEnable() != 0x1F) {
41a38dec 1326 printf("The MTS proxy does not control all global cards\n");
1327 return -1;
1328 }
113ad708 1329
41a38dec 1330 // The global cards are ON (active on the global inputs)
37dacd7d 1331 if (!cfg.GetGlobalMasks()->GetMasksOn()) {
41a38dec 1332 printf("Global masks are not ON\n");
1333 return -1;
1334 }
113ad708 1335
41a38dec 1336 // make sure to catch the "rare" calib events (1 every 50s in physics)
1337 const Char_t* tableSOD[] = {"ALL", "yes", "CAL", "all", NULL, NULL};
1338 monitorDeclareTable(const_cast<char**>(tableSOD));
1339
4fd5ed63 1340 status = monitorSetDataSource(inputFile);
1341 if (status) {
1342 cerr << "ERROR : monitorSetDataSource status (hex) = " << hex << status
1343 << " " << monitorDecodeError(status) << endl;
1344 return -1;
1345 }
1346 status = monitorDeclareMp("MUON Trigger monitoring");
1347 if (status) {
1348 cerr << "ERROR : monitorDeclareMp status (hex) = " << hex << status
1349 << " " << monitorDecodeError(status) << endl;
1350 return -1;
9f5fafa6 1351 }
1352
113ad708 1353 /* define wait event timeout - 1s max */
1354 monitorSetNowait();
1355 monitorSetNoWaitNetworkTimeout(1000);
1356
113ad708 1357 cout << "MUONTRGda : Reading data from file " << inputFile <<endl;
4fd5ed63 1358
e8f1ed57 1359 UInt_t *globalInput = new UInt_t[4];
98bdda22 1360 Bool_t doUpdate = kFALSE;
327f7faa 1361 Int_t runNumber = 0;
1362 Int_t nEvents = 0;
1363
4fd5ed63 1364 while(1)
1365 {
37dacd7d 1366 if (nEvents >= cfg.GetMaxEvents()) break;
e8f1ed57 1367 if (cfg.GetPrintLevel()) {
1368 if (nEvents && nEvents % 1000 == 0)
327f7faa 1369 cout<<"Cumulated events " << nEvents << endl;
e8f1ed57 1370 }
4fd5ed63 1371 // check shutdown condition
1372 if (daqDA_checkShutdown())
1373 break;
1374
1375 // Skip Events if needed
37dacd7d 1376 while (cfg.GetSkipEvents()) {
4fd5ed63 1377 status = monitorGetEventDynamic(&event);
37dacd7d 1378 cfg.DecSkipEvents();
4fd5ed63 1379 }
1380
1381 // starts reading
1382 status = monitorGetEventDynamic(&event);
1383 if (status < 0) {
113ad708 1384 cout << "MUONTRGda : EOF found" << endl;
4fd5ed63 1385 break;
1386 }
1387
1388 nDateEvents++;
1389
1390 // decoding rawdata headers
1391 AliRawReader *rawReader = new AliRawReaderDate(event);
9f5fafa6 1392
4fd5ed63 1393 Int_t eventType = rawReader->GetType();
327f7faa 1394 runNumber = rawReader->GetRunNumber();
9f5fafa6 1395
113ad708 1396 // L1Swc1
1397 // CALIBRATION_EVENT
1398 // SYSTEM_SOFTWARE_TRIGGER_EVENT
1399 // DETECTOR_SOFTWARE_TRIGGER_EVENT
98bdda22 1400 cfg.SetAlgoNoisyInput(kFALSE);
1401 cfg.SetAlgoDeadcInput(kFALSE);
41a38dec 1402 if (eventType == PHYSICS_EVENT) {
98bdda22 1403 cfg.SetAlgoNoisyInput(kTRUE);
1404 doUpdate = kTRUE;
37dacd7d 1405 cfg.IncNoiseEvent();
e8f1ed57 1406 } else if (modeFET3 && eventType == CALIBRATION_EVENT) {
98bdda22 1407 cfg.SetAlgoDeadcInput(kTRUE);
1408 doUpdate = kTRUE;
37dacd7d 1409 cfg.IncDeadcEvent();
41a38dec 1410 } else {
1411 continue;
1412 }
1413
327f7faa 1414 nEvents++;
e8f1ed57 1415 if (cfg.GetPrintLevel() == 2) printf("\nEvent # %d\n",nEvents);
9f5fafa6 1416
4fd5ed63 1417 // decoding MUON payload
e8f1ed57 1418 AliMUONVRawStreamTrigger *rawStream = 0x0;
1419 if (cfg.UseFastDecoder()) {
1420 rawStream = new AliMUONRawStreamTriggerHP(rawReader);
1421 } else {
1422 rawStream = new AliMUONRawStreamTrigger(rawReader);
1423 }
1424
8f8ae0de 1425 // ... without warnings from the decoder !!!
37dacd7d 1426 if (!cfg.WithWarnings())
8f8ae0de 1427 rawStream->DisableWarnings();
9f5fafa6 1428
4fd5ed63 1429 // loops over DDL
1430 while((status = rawStream->NextDDL())) {
9f5fafa6 1431
e8f1ed57 1432 if (cfg.GetPrintLevel() == 2) printf("iDDL %d\n", rawStream->GetDDL());
9f5fafa6 1433
98bdda22 1434 if (cfg.UseFastDecoder()) {
1435 darcHeaderHP = static_cast<AliMUONRawStreamTriggerHP*>(rawStream)->GetHeaders();
1436 if (cfg.GetPrintLevel() == 2) printf("Global output (fast decoder) %x\n", (Int_t)darcHeaderHP->GetGlobalOutput());
1437 for (Int_t ig = 0; ig < cfg.GetGlobalInputs(); ig++) {
1438 globalInput[ig] = darcHeaderHP->GetGlobalInput(ig);
e8f1ed57 1439 }
98bdda22 1440 // loop over regional structure
1441 Int_t nReg = (Int_t)static_cast<AliMUONRawStreamTriggerHP*>(rawStream)->GetRegionalHeaderCount();
1442 for(Int_t iReg = 0; iReg < nReg; iReg++) {
1443 // loop over local structures
1444 Int_t nLoc = (Int_t)static_cast<AliMUONRawStreamTriggerHP*>(rawStream)->GetLocalStructCount(iReg);
1445 for(Int_t iLoc = 0; iLoc < nLoc; iLoc++) {
1446 localStructHP = static_cast<AliMUONRawStreamTriggerHP*>(rawStream)->GetLocalStruct(iReg, iLoc);
1447 localBoardId = cfg.GetTriggerIO()->LocalBoardId(rawStream->GetDDL(),iReg,localStructHP->GetId());
1448 if (localBoardId > 0) {
1449 localStructHP->GetXPattern(xPattern);
1450 localStructHP->GetYPattern(yPattern);
1451 MakePattern(cfg,localBoardId,xPattern,yPattern);
1452 }
1453 }
1454 }
1455 } else {
1456 ddlTrigger = rawStream->GetDDLTrigger();
1457 darcHeader = ddlTrigger->GetDarcHeader();
1458 if (cfg.GetPrintLevel() == 2) printf("Global output %x\n", (Int_t)darcHeader->GetGlobalOutput());
1459 globalInput = darcHeader->GetGlobalInput();
1460 // loop over regional structure
1461 Int_t nReg = darcHeader->GetRegHeaderEntries();
1462 for(Int_t iReg = 0; iReg < nReg; iReg++) {
1463 regHeader = darcHeader->GetRegHeaderEntry(iReg);
1464 // loop over local structures
1465 Int_t nLoc = regHeader->GetLocalEntries();
1466 for(Int_t iLoc = 0; iLoc < nLoc; iLoc++) {
1467 localStruct = regHeader->GetLocalEntry(iLoc);
1468 localBoardId = cfg.GetTriggerIO()->LocalBoardId(rawStream->GetDDL(),iReg,localStruct->GetId());
1469 if (localBoardId > 0) {
1470 localStruct->GetXPattern(xPattern);
1471 localStruct->GetYPattern(yPattern);
1472 MakePattern(cfg,localBoardId,xPattern,yPattern);
1473 }
1474 }
1475 }
1476 }
1477 if (rawStream->GetDDL() == 0) {
327f7faa 1478 StoreGlobalInput(cfg,globalInput);
41a38dec 1479 }
98bdda22 1480
4fd5ed63 1481 } // NextDDL
1482
1483 delete rawReader;
1484 delete rawStream;
1485
1486 } // while (1)
1487
41a38dec 1488 // update configuration files ifrequested event types were found
98bdda22 1489 if (doUpdate) {
1490 if (cfg.GetDAMode() > 0) UpdateGlobalMasks(cfg);
1491 if (cfg.GetDAMode() > 1) MakePatternStore(cfg);
1492 }
9f5fafa6 1493
4fd5ed63 1494 timers.Stop();
9f5fafa6 1495
e8f1ed57 1496 cout << "MUONTRGda: DA enable: " << cfg.GetDAFlag() << endl;
1497 cout << "MUONTRGda: Run number: " << runNumber << endl;
1498 cout << "MUONTRGda: Nb of DATE events: " << nDateEvents << endl;
1499 cout << "MUONTRGda: Nb of events used: " << nEvents << endl;
1500 cout << "MUONTRGda: Nb of events used (noise): " << cfg.GetEventsN() << endl;
1501 cout << "MUONTRGda: Nb of events used (deadc): " << cfg.GetEventsD() << endl;
1502 cout << "MUONTRGda: Minumum nr of events for rate calculation: " << cfg.GetMinEvents() << endl;
1503 cout << "MUONTRGda: Maximum nr of analyzed events: " << cfg.GetMaxEvents() << endl;
1504 cout << "MUONTRGda: Skip events from start: " << cfg.GetSkipEvents() << endl;
98bdda22 1505 cout << "MUONTRGda: Threshold for global noisy inputs: " << 100*cfg.GetThrN() << "%" << endl;
1506 cout << "MUONTRGda: Threshold for global dead inputs: " << 100*cfg.GetThrD() << "%" << endl;
1507 cout << "MUONTRGda: Threshold for local noisy inputs: " << 100*cfg.GetThrLocN() << "%" << endl;
1508 cout << "MUONTRGda: Threshold for local dead inputs: " << 100*cfg.GetThrLocD() << "%" << endl;
e8f1ed57 1509 cout << "MUONTRGda: Print level: " << cfg.GetPrintLevel() << endl;
1510 cout << "MUONTRGda: Show decoder warnings: " << cfg.WithWarnings() << endl;
1511 cout << "MUONTRGda: Use the fast decoder: " << cfg.UseFastDecoder() << endl;
98bdda22 1512 cout << "MUONTRGda: DA mode (1=GLOBAL, 2=GLOBAL+LOCAL): " << cfg.GetDAMode() << endl;
327f7faa 1513
1514 printf("MUONTRGda: Execution time : R:%7.2fs C:%7.2fs\n", timers.RealTime(), timers.CpuTime());
1515
4fd5ed63 1516 return status;
41a38dec 1517
9f5fafa6 1518}
92c23b09 1519