]>
Commit | Line | Data |
---|---|---|
2ab3623b | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
16 | // $Id$ | |
17 | ||
18 | #include "AliMUONTriggerSubprocessor.h" | |
19 | ||
20 | #include "AliCDBMetaData.h" | |
21 | #include "AliLog.h" | |
22 | #include "AliMUON1DArray.h" | |
23 | #include "AliMUONCalibParamNI.h" | |
24 | #include "AliMUONPreprocessor.h" | |
25 | #include "AliMUONTriggerIO.h" | |
26 | #include "AliMUONTriggerLut.h" | |
27 | #include "AliMpConstants.h" | |
28 | #include <Riostream.h> | |
29 | #include <TList.h> | |
30 | #include <TObjString.h> | |
31 | #include <TSystem.h> | |
32 | ||
33 | /// \class AliMUONTriggerSubprocessor | |
34 | /// | |
35 | /// Implementation of AliMUONVSubprocessor for MUON trigger system | |
36 | /// | |
37 | /// Reads masks and LUT online files to feed the OCDB | |
38 | /// | |
39 | /// \author L. Aphecetche | |
40 | ||
41 | /// \cond CLASSIMP | |
42 | ClassImp(AliMUONTriggerSubprocessor) | |
43 | /// \endcond | |
44 | ||
45 | //_____________________________________________________________________________ | |
46 | AliMUONTriggerSubprocessor::AliMUONTriggerSubprocessor(AliMUONPreprocessor* master) | |
47 | : AliMUONVSubprocessor(master, | |
48 | "Triggers", | |
49 | "Upload MUON Trigger masks and LUT to OCDB"), | |
50 | fRegionalMasks(0x0), | |
51 | fLocalMasks(0x0), | |
52 | fGlobalMasks(0x0), | |
53 | fLUT(0x0) | |
54 | { | |
55 | /// default ctor | |
56 | } | |
57 | ||
58 | //_____________________________________________________________________________ | |
59 | AliMUONTriggerSubprocessor::~AliMUONTriggerSubprocessor() | |
60 | { | |
61 | /// dtor | |
62 | delete fRegionalMasks; | |
63 | delete fLocalMasks; | |
64 | delete fGlobalMasks; | |
65 | delete fLUT; | |
66 | } | |
67 | ||
68 | //_____________________________________________________________________________ | |
69 | TString | |
70 | AliMUONTriggerSubprocessor::GetFileName(const char* fid) const | |
71 | { | |
72 | /// Get filename for a given id | |
73 | ||
74 | const Int_t kSystem = AliMUONPreprocessor::kDAQ; | |
75 | ||
76 | TList* sources = Master()->GetFileSources(kSystem,fid); | |
77 | if ( sources && sources->GetSize() == 1 ) | |
78 | { | |
79 | return Master()->GetFile(kSystem,fid,static_cast<TObjString*>(sources->First())->GetName()); | |
80 | } | |
81 | return ""; | |
82 | } | |
83 | ||
84 | //_____________________________________________________________________________ | |
85 | void | |
86 | AliMUONTriggerSubprocessor::Initialize(Int_t run, UInt_t startTime, UInt_t endTime) | |
87 | { | |
88 | /// When starting a new run, reads in the trigger online files. | |
89 | ||
90 | Master()->Log(Form("Reading trigger masks for Run %d startTime %ld endTime %ld", | |
91 | run,startTime,endTime)); | |
92 | ||
93 | delete fRegionalMasks; | |
94 | delete fLocalMasks; | |
95 | delete fGlobalMasks; | |
96 | ||
97 | fRegionalMasks = new AliMUON1DArray(16); | |
98 | fLocalMasks = new AliMUON1DArray(AliMpConstants::NofLocalBoards()+1); | |
99 | fGlobalMasks = 0x0; // new AliMUONCalibParamNI(1,16,1,0,0); | |
100 | ||
101 | AliMUONTriggerIO tio; | |
102 | ||
890cc210 | 103 | Bool_t ok = tio.ReadMasks(GetFileName("LOCAL").Data(), |
104 | GetFileName("REGIONAL").Data(), | |
105 | GetFileName("GLOBAL").Data(), | |
106 | fLocalMasks,fRegionalMasks,fGlobalMasks); | |
107 | ||
108 | if (!ok) | |
109 | { | |
110 | Master()->Log("ERROR : ReadMasks failed"); | |
111 | delete fLocalMasks; | |
112 | delete fRegionalMasks; | |
113 | delete fGlobalMasks; | |
114 | fLocalMasks = 0x0; | |
115 | fRegionalMasks = 0x0; | |
116 | fGlobalMasks = 0x0; | |
117 | } | |
2ab3623b | 118 | |
119 | delete fLUT; | |
890cc210 | 120 | fLUT = new AliMUONTriggerLut; |
2ab3623b | 121 | |
890cc210 | 122 | Master()->Log(Form("Reading trigger LUT for Run %d startTime %ld endTime %ld", |
123 | run,startTime,endTime)); | |
124 | ||
125 | tio.ReadLUT(GetFileName("LUT").Data(),*fLUT); | |
126 | ||
127 | if (!ok) | |
128 | { | |
129 | Master()->Log("ERROR : ReadLUT failed"); | |
130 | delete fLUT; | |
131 | fLUT = 0x0; | |
132 | } | |
2ab3623b | 133 | } |
134 | ||
135 | //_____________________________________________________________________________ | |
136 | UInt_t | |
137 | AliMUONTriggerSubprocessor::Process(TMap* /*dcsAliasMap*/) | |
138 | { | |
139 | /// Store the trigger masks into the CDB | |
140 | ||
141 | if ( !fGlobalMasks && !fRegionalMasks && !fLocalMasks && !fLUT ) | |
142 | { | |
143 | // nothing to do | |
144 | return 0; | |
145 | } | |
146 | ||
147 | Master()->Log(Form("N global = %d N regional = %d N local %d", | |
148 | (fGlobalMasks ? 1 : 0 ), | |
149 | (fRegionalMasks ? fRegionalMasks->GetSize() : 0 ), | |
150 | (fLocalMasks ? fLocalMasks->GetSize() : 0 ))); | |
151 | ||
152 | AliCDBMetaData metaData; | |
153 | metaData.SetBeamPeriod(0); | |
154 | metaData.SetResponsible("MUON TRG"); | |
155 | metaData.SetComment("Computed by AliMUONTriggerSubprocessor $Id$"); | |
156 | ||
157 | Bool_t validToInfinity = kTRUE; | |
158 | ||
159 | Bool_t result1(kTRUE); | |
160 | Bool_t result2(kTRUE); | |
161 | Bool_t result3(kTRUE); | |
162 | Bool_t result4(kTRUE); | |
163 | ||
164 | if ( fGlobalMasks ) | |
165 | { | |
166 | result1 = Master()->Store("Calib", "GlobalTriggerBoardMasks", fGlobalMasks, | |
167 | &metaData, 0, validToInfinity); | |
168 | } | |
169 | ||
170 | if ( fRegionalMasks && fRegionalMasks->GetSize() > 0 ) | |
171 | { | |
172 | result2 = Master()->Store("Calib", "RegionalTriggerBoardMasks", fRegionalMasks, | |
173 | &metaData, 0, validToInfinity); | |
174 | } | |
175 | ||
176 | if ( fLocalMasks && fLocalMasks->GetSize() > 0 ) | |
177 | { | |
178 | result3 = Master()->Store("Calib", "LocalTriggerBoardMasks", fLocalMasks, | |
179 | &metaData, 0, validToInfinity); | |
180 | } | |
181 | ||
182 | if ( fLUT ) | |
183 | { | |
184 | result4 = Master()->Store("Calib", "TriggerLut", fLUT, | |
185 | &metaData, 0, validToInfinity); | |
186 | } | |
187 | ||
188 | return ( result1 != kTRUE && result2 != kTRUE && result3 != kTRUE && result4 != kTRUE ); // return 0 if everything is ok. | |
189 | } |