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 <TTimeStamp.h>
34 #include <TObjString.h>
39 ClassImp(AliTRIPreprocessor)
41 // names of detectors/systems in the DETECTORS_MAP in /date/db/detCodes.h
42 const char* AliTRIPreprocessor::fgkDetectorsMapName[AliTRIPreprocessor::kNDetectorsMap] = {"SPD"/*0*/, "SDD"/*1*/, "SSD"/*2*/, "TPC"/*3*/, "TRD"/*4*/,
43 "TOF"/*5*/, "HMP"/*6*/, "PHS"/*7*/, "CPV"/*8*/, "PMD"/*9*/,
44 "MCH"/*10*/,"MTR"/*11*/,"FMD"/*12*/,"T00"/*13*/,"V00"/*14*/,
45 "ZDC"/*15*/,"ACO"/*16*/,"TRI"/*17*/,"EMC"/*18*/,"TST"/*19*/,
46 ""/*20*/, ""/*21*/, ""/*22*/, ""/*23*/, ""/*24*/,
47 ""/*25*/, ""/*26*/, ""/*27*/, ""/*28*/, "GRP"/*29*/,
50 //______________________________________________________________________________________________
51 AliTRIPreprocessor::AliTRIPreprocessor(AliShuttleInterface* shuttle) :
52 AliPreprocessor("TRI", shuttle),
60 AddRunType("PHYSICS");
63 //______________________________________________________________________________________________
64 AliTRIPreprocessor::~AliTRIPreprocessor()
71 //______________________________________________________________________________________________
72 void AliTRIPreprocessor::Initialize(Int_t run, UInt_t startTime,
77 // Initialize preprocessor
80 AliPreprocessor::Initialize(run, startTime, endTime);
82 Log(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run,
83 TTimeStamp(startTime).AsString(),
84 TTimeStamp(endTime).AsString()));
88 //______________________________________________________________________________________________
89 Bool_t AliTRIPreprocessor::ProcessDCS()
92 // DCS data are never needed
98 //______________________________________________________________________________________________
99 UInt_t AliTRIPreprocessor::Process(TMap* /*dcsAliasMap*/)
103 // After reading the TriggerDetectorMask, the
104 // corresponding triggering detector procedures to
105 // process the trigger data are called.
107 typedef Short_t (AliTRIPreprocessor::*AliProcessTriggerData)();
108 const AliProcessTriggerData processTriggerDataArray[AliTRIPreprocessor::kNDetectorsMap]= {
109 &AliTRIPreprocessor::ProcessSPDTriggerData,
110 &AliTRIPreprocessor::ProcessEmptyTriggerData,
111 &AliTRIPreprocessor::ProcessEmptyTriggerData,
112 &AliTRIPreprocessor::ProcessEmptyTriggerData,
113 &AliTRIPreprocessor::ProcessEmptyTriggerData,
114 &AliTRIPreprocessor::ProcessTOFTriggerData,
115 &AliTRIPreprocessor::ProcessEmptyTriggerData,
116 &AliTRIPreprocessor::ProcessEmptyTriggerData,
117 &AliTRIPreprocessor::ProcessEmptyTriggerData,
118 &AliTRIPreprocessor::ProcessEmptyTriggerData,
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};
142 // getting the list of triggering detectors from DAQ logbook
144 TString triggerDetectorMask = (TString)GetTriggerDetectorMask();
146 if (!triggerDetectorMask.IsNull()){
147 Int_t length = triggerDetectorMask.Length();
148 Log(Form("mask = %s", triggerDetectorMask.Data()));
149 for (Int_t i = 0; i<length; i++){
150 AliDebug(2,Form("%d-th bit = %c in index %d",i,triggerDetectorMask[length-1-i],length-1-i));
151 if (triggerDetectorMask[length-1-i] == '1'){
152 Log("****************************************");
153 Log(Form("Processing Trigger data for %s",fgkDetectorsMapName[i]));
154 Log("****************************************");
156 result+=(this->*processTriggerDataArray[i])();
161 // result should be 0 to end successfully
166 //______________________________________________________________________________________________
167 Short_t AliTRIPreprocessor::ProcessSPDTriggerData()
170 // Processing SPD Trigger Data
173 Log("************** Processing SPD Trigger data... **************");
175 // Read new conditions from dcs fxs
176 AliITSTriggerConditions* newCond = new AliITSTriggerConditions();
177 TString fxsID = "PITConditions";
178 TList* list = GetFileSources(kDCS, fxsID.Data());
180 AliError("FXS file not found.");
184 while (list->At(nFiles)!=NULL) {
185 TObjString* fileNameEntry = (TObjString*) list->At(nFiles);
186 TString fileName = GetFile(kDCS, fxsID.Data(), fileNameEntry->GetString().Data());
187 if (fileName.IsNull()) {
188 Log(Form("GetFile failed to retrieve file %s.",fileNameEntry->GetString().Data()));
191 if (nFiles==0) newCond->ReadFromTextFile(fileName.Data());
195 AliWarning(Form("Found %d files with id %s (expected exactly 1).",nFiles,fxsID.Data()));
198 // Read old conditions from ocdb
199 AliITSTriggerConditions* oldCond = NULL;
200 AliCDBEntry* pitCond = GetFromOCDB("SPD", "PITConditions");
202 oldCond = (AliITSTriggerConditions*) pitCond->GetObject();
204 AliError("AliCDBEntry::GetObject() returned NULL.");
209 Log("Old conditions not found in database.");
212 // Do we need to update db?
213 Bool_t doUpdate = kTRUE;
215 // compare to see if there were any changes...
216 if (newCond->IsEqualTo(oldCond)) {
217 Log("Old conditions equal to new conditions. Do nothing.");
223 // store new conditions in ocdb
224 AliCDBMetaData metaData;
225 metaData.SetResponsible("Henrik Tydesjo");
226 metaData.SetComment("Created by Trigger PreProcessor");
227 if (!Store("SPD", "PITConditions", newCond, &metaData, 0, kTRUE)) {
228 Log("Failed to store conditions data.");
231 Log("Database updated.");
236 Log("************************* ...done.*************************");
238 return 0; // 0 means success
241 //______________________________________________________________________________________________
242 Short_t AliTRIPreprocessor::ProcessTOFTriggerData()
245 // Processing TOF Trigger Data
248 Log("************** Processing TOF Trigger data... **************");
249 Log("************** Fake function **************");
250 Log("************************* ...done.*************************");
253 //______________________________________________________________________________________________
254 Short_t AliTRIPreprocessor::ProcessEmptyTriggerData()
257 // Processing TOF Trigger Data
260 Log("************** Trigger data Processing not yet implemented **************");