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 // Trigger preprocessor class.
19 // According to the TriggerDetectorMask read from the logbook_trigger_clusters
20 // DAQ table, the triggering detectors are identified, and the
21 // corresponding procedure is called.
22 // Data are stored in the OCDB, in /TRIGGER/<DET>/<level3>, where
23 // <DET> correspond to the triggering detector,
24 // and <level3> is defined in the detector procedure
26 #include "AliTRIPreprocessor.h"
28 #include "AliCDBMetaData.h"
29 #include "AliCDBEntry.h"
31 #include "AliITSTriggerConditions.h"
33 #include "AliTOFFEEReader.h"
34 #include "AliTOFTriggerMask.h"
36 #include <TTimeStamp.h>
37 #include <TObjString.h>
42 ClassImp(AliTRIPreprocessor)
44 // names of detectors/systems in the DETECTORS_MAP in /date/db/detCodes.h
45 const char* AliTRIPreprocessor::fgkDetectorsMapName[AliTRIPreprocessor::kNDetectorsMap] = {"SPD"/*0*/, "SDD"/*1*/, "SSD"/*2*/, "TPC"/*3*/, "TRD"/*4*/,
46 "TOF"/*5*/, "HMP"/*6*/, "PHS"/*7*/, "CPV"/*8*/, "PMD"/*9*/,
47 "MCH"/*10*/,"MTR"/*11*/,"FMD"/*12*/,"T00"/*13*/,"V00"/*14*/,
48 "ZDC"/*15*/,"ACO"/*16*/,"TRI"/*17*/,"EMC"/*18*/,"TST"/*19*/,
49 ""/*20*/, ""/*21*/, ""/*22*/, ""/*23*/, ""/*24*/,
50 ""/*25*/, ""/*26*/, ""/*27*/, ""/*28*/, "GRP"/*29*/,
53 //______________________________________________________________________________________________
54 AliTRIPreprocessor::AliTRIPreprocessor(AliShuttleInterface* shuttle) :
55 AliPreprocessor("TRI", shuttle),
63 AddRunType("PHYSICS");
64 AddRunType("STANDALONE_PULSER");
67 //______________________________________________________________________________________________
68 AliTRIPreprocessor::~AliTRIPreprocessor()
75 //______________________________________________________________________________________________
76 void AliTRIPreprocessor::Initialize(Int_t run, UInt_t startTime,
81 // Initialize preprocessor
84 AliPreprocessor::Initialize(run, startTime, endTime);
86 Log(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run,
87 TTimeStamp(startTime).AsString(),
88 TTimeStamp(endTime).AsString()));
92 //______________________________________________________________________________________________
93 Bool_t AliTRIPreprocessor::ProcessDCS()
96 // DCS data are never needed
102 //______________________________________________________________________________________________
103 UInt_t AliTRIPreprocessor::Process(TMap* /*dcsAliasMap*/)
107 // After reading the TriggerDetectorMask, the
108 // corresponding triggering detector procedures to
109 // process the trigger data are called.
111 typedef Short_t (AliTRIPreprocessor::*AliProcessTriggerData)();
112 const AliProcessTriggerData processTriggerDataArray[AliTRIPreprocessor::kNDetectorsMap]= {
113 &AliTRIPreprocessor::ProcessSPDTriggerData,
114 &AliTRIPreprocessor::ProcessEmptyTriggerData,
115 &AliTRIPreprocessor::ProcessEmptyTriggerData,
116 &AliTRIPreprocessor::ProcessEmptyTriggerData,
117 &AliTRIPreprocessor::ProcessEmptyTriggerData,
118 &AliTRIPreprocessor::ProcessTOFTriggerData,
119 &AliTRIPreprocessor::ProcessEmptyTriggerData,
120 &AliTRIPreprocessor::ProcessEmptyTriggerData,
121 &AliTRIPreprocessor::ProcessEmptyTriggerData,
122 &AliTRIPreprocessor::ProcessEmptyTriggerData,
123 &AliTRIPreprocessor::ProcessEmptyTriggerData,
124 &AliTRIPreprocessor::ProcessEmptyTriggerData,
125 &AliTRIPreprocessor::ProcessEmptyTriggerData,
126 &AliTRIPreprocessor::ProcessEmptyTriggerData,
127 &AliTRIPreprocessor::ProcessEmptyTriggerData,
128 &AliTRIPreprocessor::ProcessEmptyTriggerData,
129 &AliTRIPreprocessor::ProcessEmptyTriggerData,
130 &AliTRIPreprocessor::ProcessEmptyTriggerData,
131 &AliTRIPreprocessor::ProcessEmptyTriggerData,
132 &AliTRIPreprocessor::ProcessEmptyTriggerData,
133 &AliTRIPreprocessor::ProcessEmptyTriggerData,
134 &AliTRIPreprocessor::ProcessEmptyTriggerData,
135 &AliTRIPreprocessor::ProcessEmptyTriggerData,
136 &AliTRIPreprocessor::ProcessEmptyTriggerData,
137 &AliTRIPreprocessor::ProcessEmptyTriggerData,
138 &AliTRIPreprocessor::ProcessEmptyTriggerData,
139 &AliTRIPreprocessor::ProcessEmptyTriggerData,
140 &AliTRIPreprocessor::ProcessEmptyTriggerData,
141 &AliTRIPreprocessor::ProcessEmptyTriggerData,
142 &AliTRIPreprocessor::ProcessEmptyTriggerData,
143 &AliTRIPreprocessor::ProcessEmptyTriggerData};
146 // getting the list of triggering detectors from DAQ logbook
148 TString triggerDetectorMask = (TString)GetTriggerDetectorMask();
150 if (!triggerDetectorMask.IsNull()){
151 Int_t length = triggerDetectorMask.Length();
152 Log(Form("mask = %s", triggerDetectorMask.Data()));
153 for (Int_t i = 0; i<length; i++){
154 AliDebug(2,Form("%d-th bit = %c in index %d",i,triggerDetectorMask[length-1-i],length-1-i));
155 if (triggerDetectorMask[length-1-i] == '1'){
156 Log("****************************************");
157 Log(Form("Processing Trigger data for %s",fgkDetectorsMapName[i]));
158 Log("****************************************");
160 result+=(this->*processTriggerDataArray[i])();
165 // result should be 0 to end successfully
170 //______________________________________________________________________________________________
171 Short_t AliTRIPreprocessor::ProcessSPDTriggerData()
174 // Processing SPD Trigger Data
177 Log("************** Processing SPD Trigger data... **************");
179 // Read new conditions from dcs fxs
180 AliITSTriggerConditions* newCond = new AliITSTriggerConditions();
181 TString fxsID = "pit_conditions";
182 TList* list = GetFileSources(kDCS, fxsID.Data());
184 AliError("FXS file not found.");
188 while (list->At(nFiles)!=NULL) {
189 TObjString* fileNameEntry = (TObjString*) list->At(nFiles);
190 TString fileName = GetFile(kDCS, fxsID.Data(), fileNameEntry->GetString().Data());
191 if (fileName.IsNull()) {
192 Log(Form("GetFile failed to retrieve file %s.",fileNameEntry->GetString().Data()));
195 if (nFiles==0) newCond->ReadFromTextFile(fileName.Data());
199 AliWarning(Form("Found %d files with id %s (expected exactly 1).",nFiles,fxsID.Data()));
202 // Read old conditions from ocdb
203 AliITSTriggerConditions* oldCond = NULL;
204 AliCDBEntry* pitCond = GetFromOCDB("SPD", "PITConditions");
206 oldCond = (AliITSTriggerConditions*) pitCond->GetObject();
208 AliError("AliCDBEntry::GetObject() returned NULL.");
213 Log("Old conditions not found in database.");
216 // Do we need to update db?
217 Bool_t doUpdate = kTRUE;
219 // compare to see if there were any changes...
220 if (newCond->IsEqualTo(oldCond)) {
221 Log("Old conditions equal to new conditions. Do nothing.");
227 // store new conditions in ocdb
228 AliCDBMetaData metaData;
229 metaData.SetResponsible("Henrik Tydesjo");
230 metaData.SetComment("Created by Trigger PreProcessor");
231 if (!Store("SPD", "PITConditions", newCond, &metaData, 0, kTRUE)) {
232 Log("Failed to store conditions data.");
235 Log("Database updated.");
240 Log("************************* ...done.*************************");
242 return 0; // 0 means success
245 //______________________________________________________________________________________________
246 Short_t AliTRIPreprocessor::ProcessTOFTriggerData()
249 // Processing TOF Trigger Data
252 Log("************** Processing TOF Trigger data... **************");
254 const char * nameFile = GetFile(kDCS,"TofFeeLightMap", "");
255 AliInfo(Form("toffeeLight file name = %s",nameFile));
256 if (nameFile == NULL) {
259 AliTOFFEEReader feeReader;
260 feeReader.LoadFEElightConfig(nameFile);
261 feeReader.ParseFEElightConfig();
262 AliTOFTriggerMask triggerMask;
263 triggerMask.SetTriggerMaskArray(feeReader.GetTriggerMaskArray());
265 AliCDBMetaData metaData;
266 metaData.SetBeamPeriod(0);
267 metaData.SetResponsible("Roberto Preghenella");
268 metaData.SetComment("TOF trigger mask");
269 if (!Store("TOF", "TriggerMask", &triggerMask, &metaData, 0, kTRUE)) {
270 Log("error while storing TriggerMask object");
273 Log("TriggerMask object successfully stored");
275 Log("************************* ...done.*************************");
278 //______________________________________________________________________________________________
279 Short_t AliTRIPreprocessor::ProcessEmptyTriggerData()
282 // Processing TOF Trigger Data
285 Log("************** Trigger data Processing not yet implemented **************");