]>
Commit | Line | Data |
---|---|---|
3e42bf30 | 1 | /* |
113ad708 | 2 | MTR DA for online |
3 | ||
3e42bf30 | 4 | Contact: Franck Manso <manso@clermont.in2p3.fr> |
5 | Link: http://aliceinfo.cern.ch/static/Offline/dimuon/muon_html/README_mtrda.html | |
e8f1ed57 | 6 | Reference run: 61898 |
7 | Run Type: PHYSICS | |
41a38dec | 8 | DA Type: MON |
e8f1ed57 | 9 | Number of events needed: 1000 events |
10 | Input files: MtgGlobalCrate.dat MtgRegionalCrate.dat MtgLocalMask.dat MtgLocalLut.dat MtgCurrent.dat DAConfig.dat | |
11 | Output Files: ExportedFiles.dat MtgGlobalCrate.dat | |
12 | Trigger 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 | 32 | extern "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 | ||
43 | //AliRoot | |
4fd5ed63 | 44 | #include "AliRawReaderDate.h" |
45 | ||
46 | #include "AliMpConstants.h" | |
9f5fafa6 | 47 | #include "AliMUONRawStreamTrigger.h" |
e8f1ed57 | 48 | #include "AliMUONRawStreamTriggerHP.h" |
9f5fafa6 | 49 | #include "AliMUONDarcHeader.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" | |
56 | #include "AliMUONTriggerCrateConfig.h" | |
9f5fafa6 | 57 | |
58 | //ROOT | |
9f5fafa6 | 59 | #include "TString.h" |
4fd5ed63 | 60 | #include "TSystem.h" |
9f5fafa6 | 61 | #include "TStopwatch.h" |
9f5fafa6 | 62 | #include "TROOT.h" |
63 | #include "TPluginManager.h" | |
9f5fafa6 | 64 | |
37dacd7d | 65 | /// class for DA run parameters and DA working space |
66 | class AliDAConfig : TObject { | |
67 | ||
68 | public: | |
69 | ||
70 | AliDAConfig() : | |
e8f1ed57 | 71 | fDAConfigFileName("DAConfig.dat"), |
37dacd7d | 72 | fCurrentFileName("MtgCurrent.dat"), |
73 | fLastCurrentFileName("MtgLastCurrent.dat"), | |
74 | fSodName(""), | |
75 | fSodFlag(0), | |
76 | fDAName(""), | |
77 | fDAFlag(0), | |
78 | fGlobalFileName(""), | |
79 | fRegionalFileName(""), | |
80 | fLocalMaskFileName(""), | |
81 | fLocalLutFileName(""), | |
82 | fSignatureFileName(""), | |
83 | fGlobalFileVersion(0), | |
84 | fRegionalFileVersion(0), | |
85 | fLocalMaskFileVersion(0), | |
86 | fLocalLutFileVersion(0), | |
87 | fSignatureFileVersion(0), | |
88 | fGlobalFileLastVersion(0), | |
89 | fRegionalFileLastVersion(0), | |
90 | fLocalMaskFileLastVersion(0), | |
91 | fLocalLutFileLastVersion(0), | |
92 | fEventsN(0), | |
93 | fEventsD(0), | |
94 | fPrintLevel(0), | |
95 | fLocalMasks(0x0), | |
96 | fRegionalMasks(0x0), | |
97 | fGlobalMasks(0x0), | |
98 | fTriggerIO(new AliMUONTriggerIO), | |
99 | fAlgoNoisyInput(false), | |
100 | fAlgoDeadcInput(false), | |
101 | fThrN(0.1), | |
102 | fThrD(0.9), | |
103 | fMinEvents(10), | |
104 | fSkipEvents(0), | |
105 | fMaxEvents(65535), | |
106 | fWithWarnings(false), | |
e8f1ed57 | 107 | fUseFastDecoder(false), |
37dacd7d | 108 | fNLocalBoard(AliMpConstants::TotalNofLocalBoards()+1) |
109 | { | |
110 | /// default constructor | |
111 | for (Int_t ii = 0; ii < kGlobalInputs; ii++) { | |
112 | for (Int_t il = 0; il < kGlobalInputLength; il++) { | |
113 | fAccGlobalInputN[ii][il] = 0; | |
114 | fAccGlobalInputD[ii][il] = 0; | |
115 | } | |
116 | } | |
117 | fLocalMasks = new AliMUON1DArray(fNLocalBoard); | |
118 | fRegionalMasks = new AliMUONRegionalTriggerConfig(); | |
119 | fGlobalMasks = new AliMUONGlobalCrateConfig(); | |
120 | } | |
121 | ||
37dacd7d | 122 | virtual ~AliDAConfig() |
123 | { | |
124 | /// destructor | |
125 | delete fLocalMasks; | |
126 | delete fRegionalMasks; | |
127 | delete fGlobalMasks; | |
128 | delete fTriggerIO; | |
129 | } | |
130 | void PrintConfig() | |
131 | { | |
132 | /// print DA parameters | |
133 | printf("DA config file name: %s \n",GetDAConfigFileName()); | |
134 | printf("Current file name: %s \n",GetCurrentFileName()); | |
135 | printf("Last current file name: %s \n",GetLastCurrentFileName()); | |
136 | printf("Global file name: %s (%d %d)\n",GetGlobalFileName(),GetGlobalFileVersion(),GetGlobalFileLastVersion()); | |
137 | printf("Regional file name: %s (%d %d)\n",GetRegionalFileName(),GetRegionalFileVersion(),GetRegionalFileLastVersion()); | |
138 | printf("Local mask file name: %s (%d %d)\n",GetLocalMaskFileName(),GetLocalMaskFileVersion(),GetLocalMaskFileLastVersion()); | |
139 | printf("Local LUT file name: %s (%d %d)\n",GetLocalLutFileName(),GetLocalLutFileVersion(),GetLocalLutFileLastVersion()); | |
140 | printf("Signature file name: %s (%d)\n",GetSignatureFileName(),GetSignatureFileVersion()); | |
141 | } | |
142 | ||
bb440407 | 143 | /// name of the DA configuration file from detector DB |
37dacd7d | 144 | const Char_t* GetDAConfigFileName() { return fDAConfigFileName.Data(); } |
bb440407 | 145 | /// file with current versions of the configuration files, usually MtgCurrent.dat |
37dacd7d | 146 | const Char_t* GetCurrentFileName() { return fCurrentFileName.Data(); } |
bb440407 | 147 | /// last known versions of the configuration files, usually MtgLastCurrent.dat |
37dacd7d | 148 | const Char_t* GetLastCurrentFileName() { return fLastCurrentFileName.Data(); } |
149 | ||
bb440407 | 150 | /// name of the Start-of-data field in MtgCurrent.dat |
37dacd7d | 151 | const Char_t* GetSodName() { return fSodName.Data(); } |
bb440407 | 152 | /// flag value of the Start-of-data field in MtgCurrent.dat |
37dacd7d | 153 | Int_t GetSodFlag() const { return fSodFlag; } |
154 | ||
bb440407 | 155 | /// name of the Detector Algorithm field in MtgCurrent.dat |
37dacd7d | 156 | const Char_t* GetDAName() { return fDAName.Data(); } |
bb440407 | 157 | /// flag value of the Detector Algorithm field in MtgCurrent.dat |
37dacd7d | 158 | Int_t GetDAFlag() const { return fDAFlag; } |
159 | ||
bb440407 | 160 | /// global crate configuration file name |
37dacd7d | 161 | const Char_t* GetGlobalFileName() { return fGlobalFileName.Data(); } |
bb440407 | 162 | /// regional crate configuration file name |
37dacd7d | 163 | const Char_t* GetRegionalFileName() { return fRegionalFileName.Data(); } |
bb440407 | 164 | /// masks for the local cards, file name |
37dacd7d | 165 | const Char_t* GetLocalMaskFileName() { return fLocalMaskFileName.Data(); } |
bb440407 | 166 | /// transverse momentum Look-Up-Table, file name |
37dacd7d | 167 | const Char_t* GetLocalLutFileName() { return fLocalLutFileName.Data(); } |
bb440407 | 168 | /// signature file name |
37dacd7d | 169 | const Char_t* GetSignatureFileName() { return fSignatureFileName.Data(); } |
170 | ||
bb440407 | 171 | /// version of the global crate configuration in the detector DB |
37dacd7d | 172 | Int_t GetGlobalFileVersion() const { return fGlobalFileVersion; } |
bb440407 | 173 | /// version of the regional crate configuration in the detector DB |
37dacd7d | 174 | Int_t GetRegionalFileVersion() const { return fRegionalFileVersion; } |
bb440407 | 175 | /// version of the masks for the local cards in the detector DB |
37dacd7d | 176 | Int_t GetLocalMaskFileVersion() const { return fLocalMaskFileVersion; } |
bb440407 | 177 | /// version of the transverse momentum Look-Up-Table in the detector DB |
37dacd7d | 178 | Int_t GetLocalLutFileVersion() const { return fLocalLutFileVersion; } |
bb440407 | 179 | /// version of the signature file in the detector DB |
37dacd7d | 180 | Int_t GetSignatureFileVersion() const { return fSignatureFileVersion; } |
181 | ||
bb440407 | 182 | /// last known version of the global crate configuration |
37dacd7d | 183 | Int_t GetGlobalFileLastVersion() const { return fGlobalFileLastVersion; } |
bb440407 | 184 | /// last known version of the regional crate configuration |
37dacd7d | 185 | Int_t GetRegionalFileLastVersion() const { return fRegionalFileLastVersion; } |
bb440407 | 186 | /// last known version of the masks for the local cards |
37dacd7d | 187 | Int_t GetLocalMaskFileLastVersion() const { return fLocalMaskFileLastVersion; } |
bb440407 | 188 | /// last known version of the transverse momentum Look-Up-Table |
37dacd7d | 189 | Int_t GetLocalLutFileLastVersion() const { return fLocalLutFileLastVersion; } |
190 | ||
bb440407 | 191 | /// store for the masks for the local cards (own) |
37dacd7d | 192 | AliMUONVStore* GetLocalMasks() const { return fLocalMasks; } |
bb440407 | 193 | /// configuration object for the regional crate (own) |
37dacd7d | 194 | AliMUONRegionalTriggerConfig* GetRegionalMasks() const { return fRegionalMasks; } |
bb440407 | 195 | /// configuration object for the global crate (own) |
37dacd7d | 196 | AliMUONGlobalCrateConfig* GetGlobalMasks() const { return fGlobalMasks; } |
197 | ||
bb440407 | 198 | /// read/write configurations, masks and LUT to/from online files (own) |
37dacd7d | 199 | AliMUONTriggerIO* GetTriggerIO() const { return fTriggerIO; } |
200 | ||
bb440407 | 201 | /// number of accumulated PHYSICS events for noisy channels analysis |
37dacd7d | 202 | Int_t GetEventsN() const { return fEventsN; } |
bb440407 | 203 | /// number of accumulated CALIBRATION events for dead channels analysis |
37dacd7d | 204 | Int_t GetEventsD() const { return fEventsD; } |
205 | ||
bb440407 | 206 | /// print verbosity of the DA |
37dacd7d | 207 | Int_t GetPrintLevel() const { return fPrintLevel; } |
208 | ||
bb440407 | 209 | /// select PHYSICS events for noisy channels analysis |
37dacd7d | 210 | Bool_t GetAlgoNoisyInput() const { return fAlgoNoisyInput; } |
bb440407 | 211 | /// select CALIBRATION events for dead channels analysis |
37dacd7d | 212 | Bool_t GetAlgoDeadcInput() const { return fAlgoDeadcInput; } |
213 | ||
bb440407 | 214 | /// threshold for noisy inputs (fraction of events) |
37dacd7d | 215 | Float_t GetThrN() const { return fThrN; } |
bb440407 | 216 | /// threshold for dead inputs (fraction of events) |
37dacd7d | 217 | Float_t GetThrD() const { return fThrD; } |
218 | ||
bb440407 | 219 | /// minumum nr of events for rate calculation |
37dacd7d | 220 | Int_t GetMinEvents() const { return fMinEvents; } |
bb440407 | 221 | /// maximum number of events to analyze |
37dacd7d | 222 | Int_t GetMaxEvents() const { return fMaxEvents; } |
bb440407 | 223 | /// number of events to skip from start |
37dacd7d | 224 | Int_t GetSkipEvents() const { return fSkipEvents; } |
225 | ||
bb440407 | 226 | /// show warnings from the raw data decoder |
37dacd7d | 227 | Bool_t WithWarnings() const { return fWithWarnings; } |
bb440407 | 228 | /// use the high-performance (HP) decoder |
e8f1ed57 | 229 | Bool_t UseFastDecoder() const { return fUseFastDecoder; } |
37dacd7d | 230 | |
bb440407 | 231 | /// number of global input words |
37dacd7d | 232 | Int_t GetGlobalInputs() const { return kGlobalInputs; } |
bb440407 | 233 | /// length in bits of a global input word |
37dacd7d | 234 | Int_t GetGlobalInputLength() const { return kGlobalInputLength; } |
235 | ||
bb440407 | 236 | /// get accumulated values for bit "ib" from global input word "ii", PHYSICS events |
37dacd7d | 237 | Int_t GetAccGlobalInputN(Int_t ii, Int_t ib) const { return fAccGlobalInputN[ii][ib]; } |
bb440407 | 238 | /// get accumulated values for bit "ib" from global input word "ii", CALIBRATION events |
37dacd7d | 239 | Int_t GetAccGlobalInputD(Int_t ii, Int_t ib) const { return fAccGlobalInputD[ii][ib]; } |
240 | ||
bb440407 | 241 | /// set the name of the Start-of-data field in MtgCurrent.dat |
37dacd7d | 242 | void SetSodName(Char_t *name) { fSodName = TString(name); } |
bb440407 | 243 | /// set the flag value of the Start-of-data field in MtgCurrent.dat |
37dacd7d | 244 | void SetSodFlag(Int_t flag) { fSodFlag = flag; } |
245 | ||
bb440407 | 246 | /// set the name of the Detector Algorithm field in MtgCurrent.dat |
37dacd7d | 247 | void SetDAName(Char_t *name) { fDAName = TString(name); } |
bb440407 | 248 | /// set the flag value of the Detector Algorithm field in MtgCurrent.dat |
37dacd7d | 249 | void SetDAFlag(Int_t flag) { fDAFlag = flag; } |
250 | ||
bb440407 | 251 | /// set the global crate configuration file name |
37dacd7d | 252 | void SetGlobalFileName(const Char_t *name) { fGlobalFileName = TString(name); } |
bb440407 | 253 | /// set the regional crate configuration file name |
37dacd7d | 254 | void SetRegionalFileName(const Char_t *name) { fRegionalFileName = TString(name); } |
bb440407 | 255 | /// set the masks for the local cards, file name |
37dacd7d | 256 | void SetLocalMaskFileName(const Char_t *name) { fLocalMaskFileName = TString(name); } |
bb440407 | 257 | /// set the transverse momentum Look-Up-Table, file name |
37dacd7d | 258 | void SetLocalLutFileName(const Char_t *name) { fLocalLutFileName = TString(name); } |
bb440407 | 259 | /// set the signature file name |
37dacd7d | 260 | void SetSignatureFileName(const Char_t *name) { fSignatureFileName = TString(name); } |
261 | ||
bb440407 | 262 | /// set the version of the global crate configuration in the detector DB |
37dacd7d | 263 | void SetGlobalFileVersion(Int_t ver) { fGlobalFileVersion = ver; } |
bb440407 | 264 | /// set the version of the regional crate configuration in the detector DB |
37dacd7d | 265 | void SetRegionalFileVersion(Int_t ver) { fRegionalFileVersion = ver; } |
bb440407 | 266 | /// set the version of the masks for the local cards in the detector DB |
37dacd7d | 267 | void SetLocalMaskFileVersion(Int_t ver) { fLocalMaskFileVersion = ver; } |
bb440407 | 268 | /// set the version of the transverse momentum Look-Up-Table in the detector DB |
37dacd7d | 269 | void SetLocalLutFileVersion(Int_t ver) { fLocalLutFileVersion = ver; } |
bb440407 | 270 | /// set the version of the signature file in the detector DB |
37dacd7d | 271 | void SetSignatureFileVersion(Int_t ver) { fSignatureFileVersion = ver; } |
272 | ||
bb440407 | 273 | /// set the last known version of the global crate configuration |
37dacd7d | 274 | void SetGlobalFileLastVersion(Int_t ver) { fGlobalFileLastVersion = ver; } |
bb440407 | 275 | /// set the last known version of the regional crate configuration |
37dacd7d | 276 | void SetRegionalFileLastVersion(Int_t ver) { fRegionalFileLastVersion = ver; } |
bb440407 | 277 | /// set the last known version of the masks for the local cards |
37dacd7d | 278 | void SetLocalMaskFileLastVersion(Int_t ver) { fLocalMaskFileLastVersion = ver; } |
bb440407 | 279 | /// set the last known version of the transverse momentum Look-Up-Table |
37dacd7d | 280 | void SetLocalLutFileLastVersion(Int_t ver) { fLocalLutFileLastVersion = ver; } |
281 | ||
bb440407 | 282 | /// increment the number of selected PHYSICS events |
37dacd7d | 283 | void IncNoiseEvent() { fEventsN++; } |
bb440407 | 284 | /// increment the number of selected CALIBRATION events |
37dacd7d | 285 | void IncDeadcEvent() { fEventsD++; } |
286 | ||
bb440407 | 287 | /// count the value of the bit "ib" of global input word "ii" (PHYSICS events) |
37dacd7d | 288 | void AddAccGlobalInputN(Int_t ii, Int_t ib, Int_t val) { fAccGlobalInputN[ii][ib] += val; } |
bb440407 | 289 | /// count the value of the bit "ib" of global input word "ii" (CALIBRATION events) |
37dacd7d | 290 | void AddAccGlobalInputD(Int_t ii, Int_t ib, Int_t val) { fAccGlobalInputD[ii][ib] += val; } |
291 | ||
bb440407 | 292 | /// set the print verbosity level of the DA |
37dacd7d | 293 | void SetPrintLevel(Int_t level) { fPrintLevel = level; } |
294 | ||
bb440407 | 295 | /// select PHYSICS events for noisy channels analysis |
37dacd7d | 296 | void SetAlgoNoisyInput(Bool_t val) { fAlgoNoisyInput = val; } |
bb440407 | 297 | /// select CALIBRATION events for dead channels analysis |
37dacd7d | 298 | void SetAlgoDeadcInput(Bool_t val) { fAlgoDeadcInput = val; } |
299 | ||
bb440407 | 300 | /// set the threshold for noisy inputs (fraction of events) |
37dacd7d | 301 | void SetThrN(Float_t val) { fThrN = val; } |
bb440407 | 302 | /// set the threshold for dead inputs (fraction of events) |
37dacd7d | 303 | void SetThrD(Float_t val) { fThrD = val; } |
304 | ||
bb440407 | 305 | /// set the minumum nr of events for rate calculation |
37dacd7d | 306 | void SetMinEvents(Int_t val) { fMinEvents = val; } |
bb440407 | 307 | /// set the maximum number of events to analyze |
37dacd7d | 308 | void SetMaxEvents(Int_t val) { fMaxEvents = val; } |
bb440407 | 309 | /// set the number of events to skip from start |
37dacd7d | 310 | void SetSkipEvents(Int_t val) { fSkipEvents = val; } |
311 | ||
bb440407 | 312 | /// set/unset to show warnings from the raw data decoder |
37dacd7d | 313 | void SetWithWarnings() { fWithWarnings = true; } |
bb440407 | 314 | /// set/unset the use of the high-performance (HP) decoder |
e8f1ed57 | 315 | void SetUseFastDecoder() { fUseFastDecoder = true; } |
37dacd7d | 316 | |
bb440407 | 317 | /// increment version of the global crate configuration file |
37dacd7d | 318 | void IncGlobalFileVersion() { fGlobalFileVersion++; } |
bb440407 | 319 | /// count skipped events |
37dacd7d | 320 | void DecSkipEvents() { fSkipEvents--; } |
321 | ||
322 | private: | |
4fd5ed63 | 323 | |
bb440407 | 324 | /// copy constructor, not implemented |
325 | AliDAConfig (const AliDAConfig& cfg); | |
326 | /// assignment operator, not implemented | |
327 | AliDAConfig& operator=(const AliDAConfig& cfg); | |
4fd5ed63 | 328 | |
bb440407 | 329 | const TString fDAConfigFileName; //!< name of the DA configuration file from detector DB |
330 | const TString fCurrentFileName; //!< usually MtgCurrent.dat | |
331 | const TString fLastCurrentFileName; //!< usually MtgLastCurrent.dat | |
4fd5ed63 | 332 | |
bb440407 | 333 | TString fSodName; //!< name of the Start-of-data field in MtgCurrent.dat |
334 | Int_t fSodFlag; //!< flag value of the Start-of-data field in MtgCurrent.dat | |
4fd5ed63 | 335 | |
bb440407 | 336 | TString fDAName; //!< name of the Detector Algorithm field in MtgCurrent.dat |
337 | Int_t fDAFlag; //!< flag value of the Detector Algorithm field in MtgCurrent.dat (enabled/disabled) | |
4fd5ed63 | 338 | |
bb440407 | 339 | TString fGlobalFileName; //!< global crate configuration, file name |
340 | TString fRegionalFileName; //!< regional crate configuration, file name | |
341 | TString fLocalMaskFileName; //!< masks for the local cards, file name | |
342 | TString fLocalLutFileName; //!< transverse momentum Look-Up-Table, file name | |
343 | TString fSignatureFileName; //!< signature file name | |
344 | ||
345 | Int_t fGlobalFileVersion; //!< version of the global crate configuration in the detector DB | |
346 | Int_t fRegionalFileVersion; //!< version of the regional crate configuration in the detector DB | |
347 | Int_t fLocalMaskFileVersion; //!< version of the masks for the local cards in the detector DB | |
348 | Int_t fLocalLutFileVersion; //!< version of the transverse momentum Look-Up-Table in the detector DB | |
349 | Int_t fSignatureFileVersion; //!< version of the signature file in the detector DB | |
327f7faa | 350 | |
bb440407 | 351 | Int_t fGlobalFileLastVersion; //!< last known version of the global crate configuration |
352 | Int_t fRegionalFileLastVersion; //!< last known version of the regional crate configuration | |
353 | Int_t fLocalMaskFileLastVersion; //!< last known version of the masks for the local cards | |
354 | Int_t fLocalLutFileLastVersion; //!< last known version of the transverse momentum Look-Up-Table | |
327f7faa | 355 | |
bb440407 | 356 | Int_t fEventsN; //!< number of accumulated PHYSICS events |
357 | Int_t fEventsD; //!< number of accumulated CALIBRATION events | |
327f7faa | 358 | |
bb440407 | 359 | Int_t fPrintLevel; //!< print verbosity of the DA |
327f7faa | 360 | |
bb440407 | 361 | AliMUONVStore* fLocalMasks; //!< store for the masks for the local cards |
362 | AliMUONRegionalTriggerConfig* fRegionalMasks; //!< configuration object for the regional crate | |
363 | AliMUONGlobalCrateConfig* fGlobalMasks; //!< configuration object for the global crate | |
327f7faa | 364 | |
bb440407 | 365 | AliMUONTriggerIO *fTriggerIO; //!< read/write masks and LUT to/from online files |
327f7faa | 366 | |
bb440407 | 367 | Bool_t fAlgoNoisyInput; //!< select PHYSICS events for noisy channels analysis |
368 | Bool_t fAlgoDeadcInput; //!< select CALIBRATION events for dead channels analysis | |
327f7faa | 369 | |
bb440407 | 370 | Float_t fThrN; //!< threshold for noisy inputs (fraction of events) |
371 | Float_t fThrD; //!< threshold for dead inputs (fraction of events) | |
372 | Int_t fMinEvents; //!< minumum nr of events for rate calculation | |
373 | Int_t fSkipEvents; //!< number of events to skip from start | |
374 | Int_t fMaxEvents; //!< maximum number of events to analyze | |
375 | Bool_t fWithWarnings; //!< show warnings from the raw data decoder | |
376 | Bool_t fUseFastDecoder; //!< use the high-performance (HP) decoder | |
327f7faa | 377 | |
bb440407 | 378 | const Int_t fNLocalBoard; //!< number of local boards |
327f7faa | 379 | |
bb440407 | 380 | enum { kGlobalInputs = 4, //!< number of global input words |
381 | kGlobalInputLength = 32 //!< length in bits of a global input word | |
382 | }; | |
327f7faa | 383 | |
bb440407 | 384 | Int_t fAccGlobalInputN[kGlobalInputs][kGlobalInputLength]; //!< storage for global input (PHYSICS events) |
385 | Int_t fAccGlobalInputD[kGlobalInputs][kGlobalInputLength]; //!< storage for global input (CALIBRATION events) | |
327f7faa | 386 | |
327f7faa | 387 | }; |
4fd5ed63 | 388 | |
327f7faa | 389 | //__________________________________________________________________ |
37dacd7d | 390 | Bool_t ReadDAConfig(AliDAConfig& cfg) |
327f7faa | 391 | { |
37dacd7d | 392 | /// read run parameters for the DA |
4fd5ed63 | 393 | |
327f7faa | 394 | char line[80]; |
4fd5ed63 | 395 | |
327f7faa | 396 | TString file; |
37dacd7d | 397 | file = cfg.GetDAConfigFileName(); |
327f7faa | 398 | std::ifstream in(gSystem->ExpandPathName(file.Data())); |
399 | if (!in.good()) { | |
400 | printf("Cannot open DA configuration file %s ; use default values.\n",file.Data()); | |
401 | return true; | |
402 | } | |
403 | ||
404 | TString tmp; | |
405 | Int_t pos; | |
406 | ||
407 | in.getline(line,80); | |
408 | tmp = line; | |
409 | pos = tmp.First(" "); | |
410 | tmp = tmp(0,pos); | |
37dacd7d | 411 | cfg.SetPrintLevel(tmp.Atoi()); |
327f7faa | 412 | |
413 | in.getline(line,80); | |
414 | tmp = line; | |
415 | pos = tmp.First(" "); | |
416 | tmp = tmp(0,pos); | |
37dacd7d | 417 | cfg.SetThrN(tmp.Atof()); |
327f7faa | 418 | |
419 | in.getline(line,80); | |
420 | tmp = line; | |
421 | pos = tmp.First(" "); | |
422 | tmp = tmp(0,pos); | |
37dacd7d | 423 | cfg.SetThrD(tmp.Atof()); |
327f7faa | 424 | |
425 | in.getline(line,80); | |
426 | tmp = line; | |
427 | pos = tmp.First(" "); | |
428 | tmp = tmp(0,pos); | |
37dacd7d | 429 | cfg.SetMinEvents(tmp.Atoi()); |
327f7faa | 430 | |
431 | in.getline(line,80); | |
432 | tmp = line; | |
433 | pos = tmp.First(" "); | |
434 | tmp = tmp(0,pos); | |
37dacd7d | 435 | cfg.SetSkipEvents(tmp.Atoi()); |
4fd5ed63 | 436 | |
327f7faa | 437 | in.getline(line,80); |
438 | tmp = line; | |
439 | pos = tmp.First(" "); | |
440 | tmp = tmp(0,pos); | |
37dacd7d | 441 | cfg.SetMaxEvents(tmp.Atoi()); |
4fd5ed63 | 442 | |
327f7faa | 443 | in.getline(line,80); |
444 | tmp = line; | |
445 | pos = tmp.First(" "); | |
446 | tmp = tmp(0,pos); | |
37dacd7d | 447 | if (tmp.Atoi() != 0) cfg.SetWithWarnings(); |
327f7faa | 448 | |
e8f1ed57 | 449 | in.getline(line,80); |
450 | tmp = line; | |
451 | pos = tmp.First(" "); | |
452 | tmp = tmp(0,pos); | |
453 | if (tmp.Atoi() != 0) cfg.SetUseFastDecoder(); | |
454 | ||
327f7faa | 455 | return true; |
4fd5ed63 | 456 | |
327f7faa | 457 | } |
4fd5ed63 | 458 | |
4fd5ed63 | 459 | //__________________________________________________________________ |
37dacd7d | 460 | void WriteLastCurrentFile(AliDAConfig& cfg, TString currentFile) |
4fd5ed63 | 461 | { |
37dacd7d | 462 | /// write last current file |
4fd5ed63 | 463 | |
4fd5ed63 | 464 | ofstream out; |
465 | TString file; | |
466 | file = currentFile; | |
467 | out.open(file.Data()); | |
37dacd7d | 468 | out << cfg.GetSodName() << " " << cfg.GetSodFlag() << endl; |
469 | out << cfg.GetDAName() << " " << cfg.GetDAFlag() << endl; | |
4fd5ed63 | 470 | |
37dacd7d | 471 | out << cfg.GetGlobalFileName() << " " << cfg.GetGlobalFileVersion() << endl; |
472 | out << cfg.GetRegionalFileName() << " " << cfg.GetRegionalFileVersion() << endl; | |
473 | out << cfg.GetLocalMaskFileName() << " " << cfg.GetLocalMaskFileVersion() << endl; | |
474 | out << cfg.GetLocalLutFileName() << " " << cfg.GetLocalLutFileVersion() << endl; | |
475 | out << cfg.GetSignatureFileName() << " " << cfg.GetSignatureFileVersion() << endl; | |
4fd5ed63 | 476 | |
477 | out.close(); | |
478 | } | |
479 | ||
480 | //___________________________________________________________________________________________ | |
37dacd7d | 481 | Bool_t ReadCurrentFile(AliDAConfig& cfg, TString currentFile, Bool_t lastCurrentFlag = false) |
4fd5ed63 | 482 | { |
37dacd7d | 483 | /// read last current file name and version |
4fd5ed63 | 484 | |
4fd5ed63 | 485 | char line[80]; |
486 | char name[80]; | |
37dacd7d | 487 | Int_t flag; |
4fd5ed63 | 488 | |
489 | TString file; | |
490 | file = currentFile; | |
491 | std::ifstream in(gSystem->ExpandPathName(file.Data())); | |
492 | if (!in.good()) { | |
493 | printf("Cannot open last current file %s\n",currentFile.Data()); | |
494 | return false; | |
495 | } | |
496 | ||
4fd5ed63 | 497 | // read SOD |
498 | in.getline(line,80); | |
37dacd7d | 499 | sscanf(line, "%s %d", name, &flag); |
500 | cfg.SetSodName(name); | |
501 | cfg.SetSodFlag(flag); | |
502 | if (cfg.GetPrintLevel()) printf("Sod Flag %d\n", cfg.GetSodFlag()); | |
4fd5ed63 | 503 | |
504 | //read DA | |
505 | in.getline(line,80); | |
37dacd7d | 506 | sscanf(line, "%s %d", name, &flag); |
507 | cfg.SetDAName(name); | |
508 | cfg.SetDAFlag(flag); | |
509 | if (cfg.GetPrintLevel()) printf("DA Flag: %d\n", cfg.GetDAFlag()); | |
4fd5ed63 | 510 | |
4fd5ed63 | 511 | // read global |
512 | in.getline(line,80); | |
513 | TString tmp(line); | |
514 | Int_t pos = tmp.First(" "); | |
37dacd7d | 515 | TString tmp1 = tmp(0, pos); |
516 | cfg.SetGlobalFileName(tmp1.Data()); | |
4fd5ed63 | 517 | |
518 | if (!lastCurrentFlag) { | |
37dacd7d | 519 | cfg.SetGlobalFileVersion(atoi(tmp(pos+1, tmp.Length()-pos).Data())); |
520 | if (cfg.GetPrintLevel()) printf("Global File Name: %s version: %d\n", | |
521 | cfg.GetGlobalFileName(), cfg.GetGlobalFileVersion()); | |
4fd5ed63 | 522 | } else { |
37dacd7d | 523 | cfg.SetGlobalFileLastVersion(atoi(tmp(pos+1, tmp.Length()-pos).Data())); |
524 | if (cfg.GetPrintLevel()) printf("Global File Name: %s last version: %d\n", | |
525 | cfg.GetGlobalFileName(), cfg.GetGlobalFileLastVersion()); | |
4fd5ed63 | 526 | } |
527 | ||
528 | // read regional | |
529 | in.getline(line,80); | |
530 | tmp = line; | |
531 | pos = tmp.First(" "); | |
37dacd7d | 532 | tmp1 = tmp(0, pos); |
533 | cfg.SetRegionalFileName(tmp1.Data()); | |
4fd5ed63 | 534 | |
535 | if (!lastCurrentFlag) { | |
37dacd7d | 536 | cfg.SetRegionalFileVersion(atoi(tmp(pos+1, tmp.Length()-pos).Data())); |
537 | if (cfg.GetPrintLevel()) printf("Regional File Name: %s version: %d\n", | |
538 | cfg.GetRegionalFileName(), cfg.GetRegionalFileVersion()); | |
4fd5ed63 | 539 | |
540 | } else { | |
37dacd7d | 541 | cfg.SetRegionalFileLastVersion(atoi(tmp(pos+1, tmp.Length()-pos).Data())); |
542 | if (cfg.GetPrintLevel()) printf("Regional File Name: %s last version: %d\n", | |
543 | cfg.GetRegionalFileName(), cfg.GetRegionalFileLastVersion()); | |
4fd5ed63 | 544 | } |
545 | ||
4fd5ed63 | 546 | // read mask |
547 | in.getline(line,80); | |
548 | tmp = line; | |
549 | pos = tmp.First(" "); | |
37dacd7d | 550 | tmp1 = tmp(0, pos); |
551 | cfg.SetLocalMaskFileName(tmp1.Data()); | |
4fd5ed63 | 552 | |
553 | if (!lastCurrentFlag) { | |
37dacd7d | 554 | cfg.SetLocalMaskFileVersion(atoi(tmp(pos+1, tmp.Length()-pos).Data())); |
555 | if (cfg.GetPrintLevel()) printf("Mask File Name: %s version: %d\n", | |
556 | cfg.GetLocalMaskFileName(), cfg.GetLocalMaskFileVersion()); | |
4fd5ed63 | 557 | } else { |
37dacd7d | 558 | cfg.SetLocalMaskFileLastVersion(atoi(tmp(pos+1, tmp.Length()-pos).Data())); |
559 | if (cfg.GetPrintLevel()) printf("Mask File Name: %s last version: %d\n", | |
560 | cfg.GetLocalMaskFileName(), cfg.GetLocalMaskFileLastVersion()); | |
4fd5ed63 | 561 | } |
562 | // read Lut | |
563 | in.getline(line,80); | |
564 | tmp = line; | |
565 | pos = tmp.First(" "); | |
37dacd7d | 566 | tmp1 = tmp(0, pos); |
567 | cfg.SetLocalLutFileName(tmp1.Data()); | |
4fd5ed63 | 568 | |
569 | if (!lastCurrentFlag) { | |
37dacd7d | 570 | cfg.SetLocalLutFileVersion(atoi(tmp(pos+1, tmp.Length()-pos).Data())); |
571 | if (cfg.GetPrintLevel()) printf("Lut File Name: %s version: %d\n", | |
572 | cfg.GetLocalLutFileName(), cfg.GetLocalLutFileVersion()); | |
4fd5ed63 | 573 | } else { |
37dacd7d | 574 | cfg.SetLocalLutFileLastVersion(atoi(tmp(pos+1, tmp.Length()-pos).Data())); |
575 | if (cfg.GetPrintLevel()) printf("Lut File Name: %s last version: %d\n", | |
576 | cfg.GetLocalLutFileName(), cfg.GetLocalLutFileLastVersion()); | |
4fd5ed63 | 577 | } |
578 | ||
579 | in.getline(line,80); | |
580 | tmp = line; | |
581 | pos = tmp.First(" "); | |
37dacd7d | 582 | tmp1 = tmp(0, pos); |
583 | cfg.SetSignatureFileName(tmp1.Data()); | |
584 | cfg.SetSignatureFileVersion(atoi(tmp(pos+1, tmp.Length()-pos).Data())); | |
585 | if (cfg.GetPrintLevel()) printf("Lut File Name: %s version: %d\n", | |
586 | cfg.GetSignatureFileName(), cfg.GetSignatureFileVersion()); | |
4fd5ed63 | 587 | |
588 | return true; | |
589 | } | |
590 | ||
591 | //_____________ | |
37dacd7d | 592 | void ReadFileNames(AliDAConfig& cfg) |
4fd5ed63 | 593 | { |
37dacd7d | 594 | /// if last current file does not exist than read current file |
327f7faa | 595 | |
37dacd7d | 596 | if (!ReadCurrentFile(cfg,cfg.GetLastCurrentFileName(), true)) |
4fd5ed63 | 597 | { |
37dacd7d | 598 | ReadCurrentFile(cfg,cfg.GetCurrentFileName(), true); |
4fd5ed63 | 599 | } |
37dacd7d | 600 | |
601 | // any case read current file | |
602 | ReadCurrentFile(cfg,cfg.GetCurrentFileName()); | |
603 | ||
4fd5ed63 | 604 | } |
605 | ||
606 | //__________________ | |
37dacd7d | 607 | Bool_t ExportFiles(AliDAConfig& cfg) |
4fd5ed63 | 608 | { |
37dacd7d | 609 | /// Export files to FES |
4fd5ed63 | 610 | |
4fd5ed63 | 611 | // env variables have to be set (suppose by ECS ?) |
612 | // setenv DATE_FES_PATH | |
613 | // setenv DATE_RUN_NUMBER | |
614 | // setenv DATE_ROLE_NAME | |
615 | // setenv DATE_DETECTOR_CODE | |
616 | ||
e8f1ed57 | 617 | #ifdef OFFLINE |
618 | gSystem->Setenv("DAQDALIB_PATH", "$DATE_SITE/infoLogger"); | |
619 | gSystem->Setenv("DAQDA_TEST_DIR", "/alisoft/FES"); | |
620 | #endif | |
8f8ae0de | 621 | |
4fd5ed63 | 622 | // update files |
623 | Int_t status = 0; | |
624 | ||
625 | Bool_t modified = false; | |
bb440407 | 626 | Bool_t globalExported = false; |
4fd5ed63 | 627 | |
628 | ofstream out; | |
629 | TString fileExp("ExportedFiles.dat"); | |
630 | TString file; | |
631 | ||
632 | out.open(fileExp.Data()); | |
633 | if (!out.good()) { | |
634 | printf("Failed to create file: %s\n",file.Data()); | |
635 | return false; | |
113ad708 | 636 | } |
4fd5ed63 | 637 | |
8f8ae0de | 638 | // check if MtgLastCurrent.dat exists |
639 | // if not, do initial export of all files | |
640 | Bool_t initFES = false; | |
641 | if (gSystem->AccessPathName("MtgLastCurrent.dat")) | |
642 | initFES = true; | |
643 | if (initFES) printf("Copy all configuration files to the FES.\n"); | |
644 | ||
37dacd7d | 645 | file = cfg.GetLocalMaskFileName(); |
646 | if ((cfg.GetLocalMaskFileLastVersion() != cfg.GetLocalMaskFileVersion()) || initFES) { | |
4fd5ed63 | 647 | modified = true; |
e8f1ed57 | 648 | status = daqDA_FES_storeFile(file.Data(), "LOCAL"); |
4fd5ed63 | 649 | if (status) { |
37dacd7d | 650 | printf("Failed to export file: %s\n",cfg.GetLocalMaskFileName()); |
4fd5ed63 | 651 | return false; |
652 | } | |
37dacd7d | 653 | if(cfg.GetPrintLevel()) printf("Export file: %s\n",cfg.GetLocalMaskFileName()); |
654 | out << cfg.GetLocalMaskFileName() << endl; | |
4fd5ed63 | 655 | } |
656 | ||
37dacd7d | 657 | file = cfg.GetLocalLutFileName(); |
658 | if ((cfg.GetLocalLutFileLastVersion() != cfg.GetLocalLutFileVersion()) || initFES) { | |
4fd5ed63 | 659 | modified = true; |
e8f1ed57 | 660 | status = daqDA_FES_storeFile(file.Data(), "LUT"); |
4fd5ed63 | 661 | if (status) { |
37dacd7d | 662 | printf("Failed to export file: %s\n",cfg.GetLocalLutFileName()); |
4fd5ed63 | 663 | return false; |
664 | } | |
37dacd7d | 665 | if(cfg.GetPrintLevel()) printf("Export file: %s\n",cfg.GetLocalLutFileName()); |
666 | out << cfg.GetLocalLutFileName() << endl; | |
4fd5ed63 | 667 | |
668 | } | |
669 | ||
bb440407 | 670 | file = cfg.GetGlobalFileName(); |
671 | if ((cfg.GetGlobalFileLastVersion() != cfg.GetGlobalFileVersion()) || modified || initFES) { | |
672 | modified = true; | |
673 | globalExported = true; | |
674 | status = daqDA_FES_storeFile(file.Data(), "GLOBAL"); | |
675 | if (status) { | |
676 | printf("Failed to export file: %s\n",cfg.GetGlobalFileName()); | |
677 | return false; | |
678 | } | |
679 | if(cfg.GetPrintLevel()) printf("Export file: %s\n",cfg.GetGlobalFileName()); | |
680 | out << cfg.GetGlobalFileName() << endl; | |
681 | } | |
682 | ||
37dacd7d | 683 | file = cfg.GetRegionalFileName(); |
684 | if ( (cfg.GetRegionalFileLastVersion() != cfg.GetRegionalFileVersion()) || modified || initFES) { | |
e8f1ed57 | 685 | status = daqDA_FES_storeFile(file.Data(), "REGIONAL"); |
4fd5ed63 | 686 | if (status) { |
37dacd7d | 687 | printf("Failed to export file: %s\n",cfg.GetRegionalFileName()); |
4fd5ed63 | 688 | return false; |
689 | } | |
37dacd7d | 690 | if(cfg.GetPrintLevel()) printf("Export file: %s\n",cfg.GetRegionalFileName()); |
691 | out << cfg.GetRegionalFileName() << endl; | |
bb440407 | 692 | |
693 | // needed for the initialisation of the mapping | |
694 | if (!globalExported) { | |
695 | file = cfg.GetGlobalFileName(); | |
696 | status = daqDA_FES_storeFile(file.Data(), "GLOBAL"); | |
697 | if (status) { | |
698 | printf("Failed to export file: %s\n",cfg.GetGlobalFileName()); | |
699 | return false; | |
700 | } | |
701 | if(cfg.GetPrintLevel()) printf("Export file: %s\n",cfg.GetGlobalFileName()); | |
702 | out << cfg.GetGlobalFileName() << endl; | |
703 | } | |
704 | ||
4fd5ed63 | 705 | } |
706 | ||
707 | out.close(); | |
708 | ||
709 | // export Exported file to FES anyway | |
e8f1ed57 | 710 | status = daqDA_FES_storeFile(fileExp.Data(), "EXPORTED"); |
4fd5ed63 | 711 | if (status) { |
712 | printf("Failed to export file: %s\n", fileExp.Data()); | |
713 | return false; | |
714 | } | |
37dacd7d | 715 | if(cfg.GetPrintLevel()) printf("Export file: %s\n",fileExp.Data()); |
4fd5ed63 | 716 | |
113ad708 | 717 | // write last current file |
37dacd7d | 718 | WriteLastCurrentFile(cfg,cfg.GetLastCurrentFileName()); |
113ad708 | 719 | |
4fd5ed63 | 720 | return true; |
721 | } | |
41a38dec | 722 | |
4fd5ed63 | 723 | //__________________ |
37dacd7d | 724 | Bool_t ImportFiles(AliDAConfig& cfg) |
4fd5ed63 | 725 | { |
37dacd7d | 726 | /// copy locally a file from daq detector config db |
727 | /// The current detector is identified by detector code in variable | |
728 | /// DATE_DETECTOR_CODE. It must be defined. | |
729 | /// If environment variable DAQDA_TEST_DIR is defined, files are copied from | |
730 | /// DAQDA_TEST_DIR instead of the database. | |
731 | /// The usual environment variables are not needed. | |
4fd5ed63 | 732 | |
41a38dec | 733 | Int_t status = 0; |
4fd5ed63 | 734 | |
e8f1ed57 | 735 | #ifdef OFFLINE |
736 | gSystem->Setenv("DAQDALIB_PATH", "$DATE_SITE/db"); | |
737 | #endif | |
113ad708 | 738 | |
37dacd7d | 739 | status = daqDA_DB_getFile(cfg.GetDAConfigFileName(), cfg.GetDAConfigFileName()); |
4fd5ed63 | 740 | if (status) { |
37dacd7d | 741 | printf("Failed to get DA config file from DB: %s\n",cfg.GetDAConfigFileName()); |
4fd5ed63 | 742 | return false; |
743 | } | |
744 | ||
327f7faa | 745 | ReadDAConfig(cfg); |
e8f1ed57 | 746 | |
37dacd7d | 747 | status = daqDA_DB_getFile(cfg.GetCurrentFileName(), cfg.GetCurrentFileName()); |
4fd5ed63 | 748 | if (status) { |
37dacd7d | 749 | printf("Failed to get current config file from DB: %s\n",cfg.GetCurrentFileName()); |
4fd5ed63 | 750 | return false; |
751 | } | |
e8f1ed57 | 752 | |
327f7faa | 753 | ReadFileNames(cfg); |
4fd5ed63 | 754 | |
37dacd7d | 755 | status = daqDA_DB_getFile(cfg.GetGlobalFileName(), cfg.GetGlobalFileName()); |
327f7faa | 756 | if (status) { |
37dacd7d | 757 | printf("Failed to get current config file from DB: %s\n", cfg.GetGlobalFileName()); |
327f7faa | 758 | return false; |
759 | } | |
41a38dec | 760 | |
37dacd7d | 761 | status = daqDA_DB_getFile(cfg.GetRegionalFileName(), cfg.GetRegionalFileName()); |
4fd5ed63 | 762 | if (status) { |
37dacd7d | 763 | printf("Failed to get current config file from DB: %s\n",cfg.GetRegionalFileName()); |
4fd5ed63 | 764 | return false; |
765 | } | |
766 | ||
37dacd7d | 767 | status = daqDA_DB_getFile(cfg.GetLocalMaskFileName(), cfg.GetLocalMaskFileName()); |
4fd5ed63 | 768 | if (status) { |
37dacd7d | 769 | printf("Failed to get current config file from DB: %s\n",cfg.GetLocalMaskFileName()); |
4fd5ed63 | 770 | return false; |
771 | } | |
772 | ||
37dacd7d | 773 | status = daqDA_DB_getFile(cfg.GetLocalLutFileName(), cfg.GetLocalLutFileName()); |
4fd5ed63 | 774 | if (status) { |
37dacd7d | 775 | printf("Failed to get current config file from DB: %s\n",cfg.GetLocalLutFileName()); |
4fd5ed63 | 776 | return false; |
777 | } | |
778 | ||
779 | return true; | |
780 | } | |
781 | ||
782 | //_____________ | |
37dacd7d | 783 | void ReadMaskFiles(AliDAConfig& cfg) |
4fd5ed63 | 784 | { |
37dacd7d | 785 | /// read mask files |
327f7faa | 786 | |
37dacd7d | 787 | const Char_t* localFile = cfg.GetLocalMaskFileName(); |
788 | const Char_t* regionalFile = cfg.GetRegionalFileName(); | |
789 | const Char_t* globalFile = cfg.GetGlobalFileName(); | |
4fd5ed63 | 790 | |
37dacd7d | 791 | cfg.GetTriggerIO()->ReadConfig(localFile, regionalFile, globalFile, cfg.GetLocalMasks(), cfg.GetRegionalMasks(), cfg.GetGlobalMasks()); |
4fd5ed63 | 792 | } |
4fd5ed63 | 793 | |
41a38dec | 794 | //______________________________________________________________ |
37dacd7d | 795 | UInt_t GetFetMode(const AliDAConfig & cfg) |
41a38dec | 796 | { |
37dacd7d | 797 | /// FET mode = 3 to run algorithm for dead global inputs |
798 | /// 0x3 prepulse | |
799 | /// 0x0 internal | |
4fd5ed63 | 800 | |
37dacd7d | 801 | return cfg.GetGlobalMasks()->GetFetRegister(3); |
4fd5ed63 | 802 | |
41a38dec | 803 | } |
4fd5ed63 | 804 | |
41a38dec | 805 | //______________________________________________________________ |
37dacd7d | 806 | void StoreGlobalInput(AliDAConfig& cfg, const UInt_t * const globalInput) |
41a38dec | 807 | { |
37dacd7d | 808 | /// accumulate and build statistics of global input values |
41a38dec | 809 | |
37dacd7d | 810 | for (Int_t ii = 0; ii < cfg.GetGlobalInputs(); ii++) { |
811 | for (Int_t ib = 0; ib < cfg.GetGlobalInputLength(); ib++) { | |
41a38dec | 812 | // lsb -> msb |
37dacd7d | 813 | if (cfg.GetAlgoNoisyInput()) |
814 | cfg.AddAccGlobalInputN(ii,ib,((globalInput[ii] >> ib) & 0x1)); | |
815 | if (cfg.GetAlgoDeadcInput()) | |
816 | cfg.AddAccGlobalInputD(ii,ib,((globalInput[ii] >> ib) & 0x1)); | |
4fd5ed63 | 817 | } |
41a38dec | 818 | } |
4fd5ed63 | 819 | |
820 | } | |
821 | ||
41a38dec | 822 | //______________________________________________________________ |
37dacd7d | 823 | void UpdateGlobalMasks(AliDAConfig& cfg) |
4fd5ed63 | 824 | { |
37dacd7d | 825 | /// update the global masks |
4fd5ed63 | 826 | |
e8f1ed57 | 827 | #ifdef OFFLINE |
828 | gSystem->Setenv("DAQDALIB_PATH", "$DATE_SITE/db"); | |
829 | #endif | |
327f7faa | 830 | |
41a38dec | 831 | Float_t rateN = 0.0, rateD = 0.0; |
832 | UInt_t gmask[4], omask; | |
833 | Bool_t noise, deadc, withEvN, withEvD, updated = false; | |
834 | ||
37dacd7d | 835 | for (Int_t ii = 0; ii < cfg.GetGlobalInputs(); ii++) { |
41a38dec | 836 | gmask[ii] = 0; |
837 | ||
37dacd7d | 838 | for (Int_t ib = 0; ib < cfg.GetGlobalInputLength(); ib++) { |
41a38dec | 839 | // lsb -> msb |
840 | noise = false; | |
841 | deadc = false; | |
842 | withEvN = false; | |
843 | withEvD = false; | |
37dacd7d | 844 | if (cfg.GetEventsN() > cfg.GetMinEvents()) { |
845 | rateN = (Float_t)cfg.GetAccGlobalInputN(ii,ib)/(Float_t)cfg.GetEventsN(); | |
846 | noise = (rateN > cfg.GetThrN()); | |
41a38dec | 847 | withEvN = true; |
4fd5ed63 | 848 | } |
37dacd7d | 849 | if (cfg.GetEventsD() > cfg.GetMinEvents()) { |
850 | rateD = (Float_t)cfg.GetAccGlobalInputD(ii,ib)/(Float_t)cfg.GetEventsD(); | |
851 | deadc = (rateD < cfg.GetThrD()); | |
41a38dec | 852 | withEvD = true; |
853 | } | |
854 | if (!withEvN && !withEvD) { | |
855 | // - copy the bit from the old mask | |
37dacd7d | 856 | gmask[ii] |= ((cfg.GetGlobalMasks()->GetGlobalMask(ii) >> ib) & 0x1) << ib; |
e8f1ed57 | 857 | if (cfg.GetPrintLevel()) |
858 | printf("Mask not changed (just copy the old values)\n"); | |
41a38dec | 859 | } |
860 | if (!withEvN && withEvD) { | |
861 | if (!deadc) { | |
862 | // - create a new mask, set the bit to 1 | |
8f8ae0de | 863 | // not allowed! |
864 | //gmask[ii] |= 0x1 << ib; | |
865 | // - copy the bit from the old mask | |
37dacd7d | 866 | gmask[ii] |= ((cfg.GetGlobalMasks()->GetGlobalMask(ii) >> ib) & 0x1) << ib; |
41a38dec | 867 | } else { |
868 | // - create a new mask, set the bit to 0 | |
869 | gmask[ii] |= 0x0 << ib; | |
e8f1ed57 | 870 | if (cfg.GetPrintLevel()) |
871 | printf("Found dead channel %1d:%02d (%4.2f) \n",ii,ib,rateD); | |
4fd5ed63 | 872 | } |
41a38dec | 873 | } |
874 | if (withEvN && !withEvD) { | |
875 | if (!noise) { | |
876 | // - create a new mask, set the bit to 1 | |
8f8ae0de | 877 | // not allowed! |
878 | //gmask[ii] |= 0x1 << ib; | |
879 | // - copy the bit from the old mask | |
37dacd7d | 880 | gmask[ii] |= ((cfg.GetGlobalMasks()->GetGlobalMask(ii) >> ib) & 0x1) << ib; |
41a38dec | 881 | } else { |
882 | // - create a new mask, set the bit to 0 | |
883 | gmask[ii] |= 0x0 << ib; | |
e8f1ed57 | 884 | if (cfg.GetPrintLevel()) |
885 | printf("Found noisy channel %1d:%02d (%4.2f) \n",ii,ib,rateN); | |
41a38dec | 886 | } |
887 | } | |
888 | if (withEvN && withEvD) { | |
889 | if (!noise && !deadc) { | |
890 | // - create a new mask, set the bit to 1 | |
8f8ae0de | 891 | // not allowed! |
892 | //gmask[ii] |= 0x1 << ib; | |
893 | // - copy the bit from the old mask | |
37dacd7d | 894 | gmask[ii] |= ((cfg.GetGlobalMasks()->GetGlobalMask(ii) >> ib) & 0x1) << ib; |
41a38dec | 895 | } else { |
896 | // - create a new mask, set the bit to 0 | |
897 | gmask[ii] |= 0x0 << ib; | |
e8f1ed57 | 898 | if (cfg.GetPrintLevel()) { |
899 | if (noise) | |
900 | printf("Found noisy channel %1d:%02d (%4.2f) \n",ii,ib,rateN); | |
901 | if (deadc) | |
902 | printf("Found dead channel %1d:%02d (%4.2f) \n",ii,ib,rateD); | |
903 | } | |
4fd5ed63 | 904 | } |
4fd5ed63 | 905 | } |
906 | } | |
41a38dec | 907 | } |
908 | ||
909 | // check if at least one mask value has been changed from previous version | |
37dacd7d | 910 | for (Int_t ii = 0; ii < cfg.GetGlobalInputs(); ii++) { |
327f7faa | 911 | printf("Global mask [%1d] %08x \n",ii,gmask[ii]); |
37dacd7d | 912 | omask = cfg.GetGlobalMasks()->GetGlobalMask(ii); |
41a38dec | 913 | if (gmask[ii] != omask) { |
914 | updated = true; | |
37dacd7d | 915 | cfg.GetGlobalMasks()->SetGlobalMask(ii,gmask[ii]); |
4fd5ed63 | 916 | } |
41a38dec | 917 | } |
4fd5ed63 | 918 | |
41a38dec | 919 | Int_t status = 0; |
920 | if (updated) { | |
921 | ||
922 | // update version | |
37dacd7d | 923 | cfg.IncGlobalFileVersion(); |
41a38dec | 924 | |
925 | // don't change the file version ("-x.dat") | |
926 | ||
37dacd7d | 927 | cfg.GetTriggerIO()->WriteGlobalConfig(cfg.GetGlobalFileName(),cfg.GetGlobalMasks()); |
41a38dec | 928 | |
929 | // write last current file | |
37dacd7d | 930 | WriteLastCurrentFile(cfg,cfg.GetCurrentFileName()); |
4fd5ed63 | 931 | |
37dacd7d | 932 | status = daqDA_DB_storeFile(cfg.GetGlobalFileName(), cfg.GetGlobalFileName()); |
41a38dec | 933 | if (status) { |
37dacd7d | 934 | printf("Failed to export file to DB: %s\n",cfg.GetGlobalFileName()); |
41a38dec | 935 | return; |
936 | } | |
937 | ||
37dacd7d | 938 | status = daqDA_DB_storeFile(cfg.GetCurrentFileName(), cfg.GetCurrentFileName()); |
41a38dec | 939 | if (status) { |
37dacd7d | 940 | printf("Failed to export file to DB: %s\n",cfg.GetCurrentFileName()); |
41a38dec | 941 | return; |
942 | } | |
113ad708 | 943 | |
41a38dec | 944 | } |
945 | ||
946 | } | |
113ad708 | 947 | |
9f5fafa6 | 948 | //*************************************************************// |
9f5fafa6 | 949 | int main(Int_t argc, Char_t **argv) |
950 | { | |
37dacd7d | 951 | /// main routine |
9f5fafa6 | 952 | |
953 | // needed for streamer application | |
327f7faa | 954 | gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo", "*", "TStreamerInfo", "RIO", "TStreamerInfo()"); |
955 | ||
956 | /* check that we got some arguments = list of files */ | |
957 | if (argc<2) { | |
958 | printf("Wrong number of arguments\n"); | |
959 | return -1; | |
960 | } | |
961 | ||
37dacd7d | 962 | AliDAConfig cfg; |
9f5fafa6 | 963 | |
8f8ae0de | 964 | Char_t inputFile[256] = ""; |
113ad708 | 965 | inputFile[0] = 0; |
966 | if (argc > 1) | |
967 | if (argv[1] != NULL) | |
968 | strncpy(inputFile, argv[1], 256); | |
969 | else { | |
970 | printf("MUONTRGda : No input File !\n"); | |
971 | return -1; | |
972 | } | |
9f5fafa6 | 973 | |
4fd5ed63 | 974 | // decoding the events |
9f5fafa6 | 975 | |
bb440407 | 976 | Int_t status = 0; |
4fd5ed63 | 977 | Int_t nDateEvents = 0; |
9f5fafa6 | 978 | |
4fd5ed63 | 979 | void* event; |
9f5fafa6 | 980 | |
4fd5ed63 | 981 | // containers |
e8f1ed57 | 982 | // old decoder |
4fd5ed63 | 983 | AliMUONDDLTrigger* ddlTrigger = 0x0; |
984 | AliMUONDarcHeader* darcHeader = 0x0; | |
e8f1ed57 | 985 | // new (fast) decoder |
986 | const AliMUONRawStreamTriggerHP::AliHeader* darcHeaderHP = 0x0; | |
9f5fafa6 | 987 | |
4fd5ed63 | 988 | TStopwatch timers; |
9f5fafa6 | 989 | |
4fd5ed63 | 990 | timers.Start(kTRUE); |
9f5fafa6 | 991 | |
4fd5ed63 | 992 | // comment out, since we do not retrieve files from database |
327f7faa | 993 | if (!ImportFiles(cfg)) { |
4fd5ed63 | 994 | printf("Import from DB failed\n"); |
995 | printf("For local test set DAQDA_TEST_DIR to the local directory where the Mtg files are located \n"); | |
9f5fafa6 | 996 | return -1; |
997 | } | |
327f7faa | 998 | |
999 | ReadMaskFiles(cfg); | |
4fd5ed63 | 1000 | |
e8f1ed57 | 1001 | #ifdef OFFLINE |
1002 | // the run number extracted from the file name | |
1003 | TString tmp(inputFile); | |
1004 | Int_t pos = tmp.First("daq"); | |
1005 | tmp = tmp(pos+3,5); | |
1006 | gSystem->Setenv("DATE_RUN_NUMBER",tmp.Data()); | |
1007 | gSystem->Exec("echo \"DATE_RUN_NUMBER = \" $DATE_RUN_NUMBER"); | |
1008 | #endif | |
37dacd7d | 1009 | |
327f7faa | 1010 | if(!ExportFiles(cfg)) { |
41a38dec | 1011 | printf("ExportFiles failed\n"); |
1012 | return -1; | |
1013 | } | |
1014 | ||
bb440407 | 1015 | if (!cfg.GetDAFlag()) { |
1016 | ||
1017 | cout << "MUONTRGda: DA enable: " << cfg.GetDAFlag() << endl; | |
1018 | cout << "MUONTRGda: Print level: " << cfg.GetPrintLevel() << endl; | |
1019 | ||
1020 | printf("MUONTRGda: Execution time : R:%7.2fs C:%7.2fs\n", timers.RealTime(), timers.CpuTime()); | |
1021 | ||
1022 | return status; | |
1023 | ||
1024 | } | |
1025 | ||
41a38dec | 1026 | // FET is triggered by CTP |
e8f1ed57 | 1027 | Bool_t modeFET3 = kTRUE; |
327f7faa | 1028 | if (GetFetMode(cfg) != 3) { |
e8f1ed57 | 1029 | printf("FET is not in mode 3. Only PHYSICS events will be analysed (noisy channels)\n"); |
1030 | modeFET3 = kFALSE; | |
41a38dec | 1031 | } |
1032 | ||
1033 | // All 5 global cards are controlled by the Mts proxy | |
37dacd7d | 1034 | if (cfg.GetGlobalMasks()->GetGlobalCrateEnable() != 0x1F) { |
41a38dec | 1035 | printf("The MTS proxy does not control all global cards\n"); |
1036 | return -1; | |
1037 | } | |
113ad708 | 1038 | |
41a38dec | 1039 | // The global cards are ON (active on the global inputs) |
37dacd7d | 1040 | if (!cfg.GetGlobalMasks()->GetMasksOn()) { |
41a38dec | 1041 | printf("Global masks are not ON\n"); |
1042 | return -1; | |
1043 | } | |
113ad708 | 1044 | |
41a38dec | 1045 | // make sure to catch the "rare" calib events (1 every 50s in physics) |
1046 | const Char_t* tableSOD[] = {"ALL", "yes", "CAL", "all", NULL, NULL}; | |
1047 | monitorDeclareTable(const_cast<char**>(tableSOD)); | |
1048 | ||
4fd5ed63 | 1049 | status = monitorSetDataSource(inputFile); |
1050 | if (status) { | |
1051 | cerr << "ERROR : monitorSetDataSource status (hex) = " << hex << status | |
1052 | << " " << monitorDecodeError(status) << endl; | |
1053 | return -1; | |
1054 | } | |
1055 | status = monitorDeclareMp("MUON Trigger monitoring"); | |
1056 | if (status) { | |
1057 | cerr << "ERROR : monitorDeclareMp status (hex) = " << hex << status | |
1058 | << " " << monitorDecodeError(status) << endl; | |
1059 | return -1; | |
9f5fafa6 | 1060 | } |
1061 | ||
113ad708 | 1062 | /* define wait event timeout - 1s max */ |
1063 | monitorSetNowait(); | |
1064 | monitorSetNoWaitNetworkTimeout(1000); | |
1065 | ||
113ad708 | 1066 | cout << "MUONTRGda : Reading data from file " << inputFile <<endl; |
4fd5ed63 | 1067 | |
e8f1ed57 | 1068 | UInt_t *globalInput = new UInt_t[4]; |
41a38dec | 1069 | Bool_t doUpdate = false; |
327f7faa | 1070 | Int_t runNumber = 0; |
1071 | Int_t nEvents = 0; | |
1072 | ||
4fd5ed63 | 1073 | while(1) |
1074 | { | |
37dacd7d | 1075 | if (nEvents >= cfg.GetMaxEvents()) break; |
e8f1ed57 | 1076 | if (cfg.GetPrintLevel()) { |
1077 | if (nEvents && nEvents % 1000 == 0) | |
327f7faa | 1078 | cout<<"Cumulated events " << nEvents << endl; |
e8f1ed57 | 1079 | } |
4fd5ed63 | 1080 | // check shutdown condition |
1081 | if (daqDA_checkShutdown()) | |
1082 | break; | |
1083 | ||
1084 | // Skip Events if needed | |
37dacd7d | 1085 | while (cfg.GetSkipEvents()) { |
4fd5ed63 | 1086 | status = monitorGetEventDynamic(&event); |
37dacd7d | 1087 | cfg.DecSkipEvents(); |
4fd5ed63 | 1088 | } |
1089 | ||
1090 | // starts reading | |
1091 | status = monitorGetEventDynamic(&event); | |
1092 | if (status < 0) { | |
113ad708 | 1093 | cout << "MUONTRGda : EOF found" << endl; |
4fd5ed63 | 1094 | break; |
1095 | } | |
1096 | ||
1097 | nDateEvents++; | |
1098 | ||
1099 | // decoding rawdata headers | |
1100 | AliRawReader *rawReader = new AliRawReaderDate(event); | |
9f5fafa6 | 1101 | |
4fd5ed63 | 1102 | Int_t eventType = rawReader->GetType(); |
327f7faa | 1103 | runNumber = rawReader->GetRunNumber(); |
9f5fafa6 | 1104 | |
113ad708 | 1105 | // L1Swc1 |
1106 | // CALIBRATION_EVENT | |
1107 | // SYSTEM_SOFTWARE_TRIGGER_EVENT | |
1108 | // DETECTOR_SOFTWARE_TRIGGER_EVENT | |
37dacd7d | 1109 | cfg.SetAlgoNoisyInput(false); |
1110 | cfg.SetAlgoDeadcInput(false); | |
41a38dec | 1111 | if (eventType == PHYSICS_EVENT) { |
37dacd7d | 1112 | cfg.SetAlgoNoisyInput(true); |
41a38dec | 1113 | doUpdate = true; |
37dacd7d | 1114 | cfg.IncNoiseEvent(); |
e8f1ed57 | 1115 | } else if (modeFET3 && eventType == CALIBRATION_EVENT) { |
37dacd7d | 1116 | cfg.SetAlgoDeadcInput(true); |
41a38dec | 1117 | doUpdate = true; |
37dacd7d | 1118 | cfg.IncDeadcEvent(); |
41a38dec | 1119 | } else { |
1120 | continue; | |
1121 | } | |
1122 | ||
327f7faa | 1123 | nEvents++; |
e8f1ed57 | 1124 | if (cfg.GetPrintLevel() == 2) printf("\nEvent # %d\n",nEvents); |
9f5fafa6 | 1125 | |
4fd5ed63 | 1126 | // decoding MUON payload |
e8f1ed57 | 1127 | AliMUONVRawStreamTrigger *rawStream = 0x0; |
1128 | if (cfg.UseFastDecoder()) { | |
1129 | rawStream = new AliMUONRawStreamTriggerHP(rawReader); | |
1130 | } else { | |
1131 | rawStream = new AliMUONRawStreamTrigger(rawReader); | |
1132 | } | |
1133 | ||
8f8ae0de | 1134 | // ... without warnings from the decoder !!! |
37dacd7d | 1135 | if (!cfg.WithWarnings()) |
8f8ae0de | 1136 | rawStream->DisableWarnings(); |
9f5fafa6 | 1137 | |
4fd5ed63 | 1138 | // loops over DDL |
1139 | while((status = rawStream->NextDDL())) { | |
9f5fafa6 | 1140 | |
e8f1ed57 | 1141 | if (cfg.GetPrintLevel() == 2) printf("iDDL %d\n", rawStream->GetDDL()); |
9f5fafa6 | 1142 | |
41a38dec | 1143 | if (rawStream->GetDDL() == 0) { |
e8f1ed57 | 1144 | if (cfg.UseFastDecoder()) { |
1145 | darcHeaderHP = static_cast<AliMUONRawStreamTriggerHP*>(rawStream)->GetHeaders(); | |
1146 | if (cfg.GetPrintLevel() == 2) printf("Global output (fast decoder) %x\n", (Int_t)darcHeaderHP->GetGlobalOutput()); | |
1147 | for (Int_t ig = 0; ig < cfg.GetGlobalInputs(); ig++) | |
1148 | globalInput[ig] = darcHeaderHP->GetGlobalInput(ig); | |
1149 | } else { | |
1150 | ddlTrigger = rawStream->GetDDLTrigger(); | |
1151 | darcHeader = ddlTrigger->GetDarcHeader(); | |
1152 | if (cfg.GetPrintLevel() == 2) printf("Global output %x\n", (Int_t)darcHeader->GetGlobalOutput()); | |
1153 | globalInput = darcHeader->GetGlobalInput(); | |
1154 | } | |
327f7faa | 1155 | StoreGlobalInput(cfg,globalInput); |
41a38dec | 1156 | } |
9f5fafa6 | 1157 | |
4fd5ed63 | 1158 | } // NextDDL |
1159 | ||
1160 | delete rawReader; | |
1161 | delete rawStream; | |
1162 | ||
1163 | } // while (1) | |
1164 | ||
41a38dec | 1165 | // update configuration files ifrequested event types were found |
bb440407 | 1166 | if (doUpdate) |
327f7faa | 1167 | UpdateGlobalMasks(cfg); |
9f5fafa6 | 1168 | |
4fd5ed63 | 1169 | timers.Stop(); |
9f5fafa6 | 1170 | |
e8f1ed57 | 1171 | cout << "MUONTRGda: DA enable: " << cfg.GetDAFlag() << endl; |
1172 | cout << "MUONTRGda: Run number: " << runNumber << endl; | |
1173 | cout << "MUONTRGda: Nb of DATE events: " << nDateEvents << endl; | |
1174 | cout << "MUONTRGda: Nb of events used: " << nEvents << endl; | |
1175 | cout << "MUONTRGda: Nb of events used (noise): " << cfg.GetEventsN() << endl; | |
1176 | cout << "MUONTRGda: Nb of events used (deadc): " << cfg.GetEventsD() << endl; | |
1177 | cout << "MUONTRGda: Minumum nr of events for rate calculation: " << cfg.GetMinEvents() << endl; | |
1178 | cout << "MUONTRGda: Maximum nr of analyzed events: " << cfg.GetMaxEvents() << endl; | |
1179 | cout << "MUONTRGda: Skip events from start: " << cfg.GetSkipEvents() << endl; | |
1180 | cout << "MUONTRGda: Threshold for noisy inputs: " << 100*cfg.GetThrN() << "%" << endl; | |
1181 | cout << "MUONTRGda: Threshold for dead inputs: " << 100*cfg.GetThrD() << "%" << endl; | |
1182 | cout << "MUONTRGda: Print level: " << cfg.GetPrintLevel() << endl; | |
1183 | cout << "MUONTRGda: Show decoder warnings: " << cfg.WithWarnings() << endl; | |
1184 | cout << "MUONTRGda: Use the fast decoder: " << cfg.UseFastDecoder() << endl; | |
327f7faa | 1185 | |
1186 | printf("MUONTRGda: Execution time : R:%7.2fs C:%7.2fs\n", timers.RealTime(), timers.CpuTime()); | |
1187 | ||
4fd5ed63 | 1188 | return status; |
41a38dec | 1189 | |
9f5fafa6 | 1190 | } |
92c23b09 | 1191 |