1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 #include "AliMUONTriggerSubprocessor.h"
20 #include "AliCDBMetaData.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>
30 #include <TObjString.h>
33 /// \class AliMUONTriggerSubprocessor
35 /// Implementation of AliMUONVSubprocessor for MUON trigger system
37 /// Reads masks and LUT online files to feed the OCDB
39 /// \author L. Aphecetche
42 ClassImp(AliMUONTriggerSubprocessor)
45 //_____________________________________________________________________________
46 AliMUONTriggerSubprocessor::AliMUONTriggerSubprocessor(AliMUONPreprocessor* master)
47 : AliMUONVSubprocessor(master,
49 "Upload MUON Trigger masks and LUT to OCDB"),
58 //_____________________________________________________________________________
59 AliMUONTriggerSubprocessor::~AliMUONTriggerSubprocessor()
62 delete fRegionalMasks;
68 //_____________________________________________________________________________
70 AliMUONTriggerSubprocessor::GetFileName(const char* fid) const
72 /// Get filename for a given id
74 const Int_t kSystem = AliMUONPreprocessor::kDAQ;
76 TList* sources = Master()->GetFileSources(kSystem,fid);
77 if ( sources && sources->GetSize() == 1 )
79 return Master()->GetFile(kSystem,fid,static_cast<TObjString*>(sources->First())->GetName());
84 //_____________________________________________________________________________
86 AliMUONTriggerSubprocessor::Initialize(Int_t run, UInt_t startTime, UInt_t endTime)
88 /// When starting a new run, reads in the trigger online files.
90 Master()->Log(Form("Reading trigger masks for Run %d startTime %ld endTime %ld",
91 run,startTime,endTime));
93 delete fRegionalMasks;
97 fRegionalMasks = new AliMUON1DArray(16);
98 fLocalMasks = new AliMUON1DArray(AliMpConstants::NofLocalBoards()+1);
99 fGlobalMasks = 0x0; // new AliMUONCalibParamNI(1,16,1,0,0);
101 AliMUONTriggerIO tio;
103 tio.ReadMasks(GetFileName("LOCAL").Data(),
104 GetFileName("REGIONAL").Data(),
105 GetFileName("GLOBAL").Data(),
106 fLocalMasks,fRegionalMasks,fGlobalMasks);
109 fLUT = 0x0; // new AliMUONTriggerLut;
111 // Master()->Log(Form("Reading trigger LUT for Run %d startTime %ld endTime %ld",
112 // run,startTime,endTime));
113 // tio.ReadLut(lutFile,fLUT);
116 //_____________________________________________________________________________
118 AliMUONTriggerSubprocessor::Process(TMap* /*dcsAliasMap*/)
120 /// Store the trigger masks into the CDB
122 if ( !fGlobalMasks && !fRegionalMasks && !fLocalMasks && !fLUT )
128 Master()->Log(Form("N global = %d N regional = %d N local %d",
129 (fGlobalMasks ? 1 : 0 ),
130 (fRegionalMasks ? fRegionalMasks->GetSize() : 0 ),
131 (fLocalMasks ? fLocalMasks->GetSize() : 0 )));
133 AliCDBMetaData metaData;
134 metaData.SetBeamPeriod(0);
135 metaData.SetResponsible("MUON TRG");
136 metaData.SetComment("Computed by AliMUONTriggerSubprocessor $Id$");
138 Bool_t validToInfinity = kTRUE;
140 Bool_t result1(kTRUE);
141 Bool_t result2(kTRUE);
142 Bool_t result3(kTRUE);
143 Bool_t result4(kTRUE);
147 result1 = Master()->Store("Calib", "GlobalTriggerBoardMasks", fGlobalMasks,
148 &metaData, 0, validToInfinity);
151 if ( fRegionalMasks && fRegionalMasks->GetSize() > 0 )
153 result2 = Master()->Store("Calib", "RegionalTriggerBoardMasks", fRegionalMasks,
154 &metaData, 0, validToInfinity);
157 if ( fLocalMasks && fLocalMasks->GetSize() > 0 )
159 result3 = Master()->Store("Calib", "LocalTriggerBoardMasks", fLocalMasks,
160 &metaData, 0, validToInfinity);
165 result4 = Master()->Store("Calib", "TriggerLut", fLUT,
166 &metaData, 0, validToInfinity);
169 return ( result1 != kTRUE && result2 != kTRUE && result3 != kTRUE && result4 != kTRUE ); // return 0 if everything is ok.