]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TRIGGER/AliTRIPreprocessor.cxx
In MUONRecoCheck.C:
[u/mrichter/AliRoot.git] / TRIGGER / AliTRIPreprocessor.cxx
CommitLineData
b48d2542 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// 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
25
26#include "AliTRIPreprocessor.h"
27
28#include "AliCDBMetaData.h"
29#include "AliCDBEntry.h"
30#include "AliLog.h"
31#include "AliITSTriggerConditions.h"
32
33#include <TTimeStamp.h>
34#include <TObjString.h>
35#include <TList.h>
36#include <TROOT.h>
37#include <TSystem.h>
38
39ClassImp(AliTRIPreprocessor)
40
41// names of detectors/systems in the DETECTORS_MAP in /date/db/detCodes.h
42const 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*/,
48 "HLT"/*30*/};
49
50//______________________________________________________________________________________________
51AliTRIPreprocessor::AliTRIPreprocessor(AliShuttleInterface* shuttle) :
52 AliPreprocessor("TRI", shuttle),
53 fShuttle(shuttle)
54
55{
56 //
57 // constructor
58 //
59
60 AddRunType("PHYSICS");
82abc1df 61 AddRunType("STANDALONE_PULSER");
b48d2542 62}
63
64//______________________________________________________________________________________________
65AliTRIPreprocessor::~AliTRIPreprocessor()
66{
67 //
68 // destructor
69 //
70}
71
72//______________________________________________________________________________________________
73void AliTRIPreprocessor::Initialize(Int_t run, UInt_t startTime,
74 UInt_t endTime)
75{
76
77 //
78 // Initialize preprocessor
79 //
80
81 AliPreprocessor::Initialize(run, startTime, endTime);
82
83 Log(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run,
84 TTimeStamp(startTime).AsString(),
85 TTimeStamp(endTime).AsString()));
86
87}
88
89//______________________________________________________________________________________________
90Bool_t AliTRIPreprocessor::ProcessDCS()
91{
92 //
93 // DCS data are never needed
94 //
95
96 return kFALSE;
97}
98
99//______________________________________________________________________________________________
100UInt_t AliTRIPreprocessor::Process(TMap* /*dcsAliasMap*/)
101{
102
103 // Procees function:
104 // After reading the TriggerDetectorMask, the
105 // corresponding triggering detector procedures to
106 // process the trigger data are called.
107
108 typedef Short_t (AliTRIPreprocessor::*AliProcessTriggerData)();
109 const AliProcessTriggerData processTriggerDataArray[AliTRIPreprocessor::kNDetectorsMap]= {
110 &AliTRIPreprocessor::ProcessSPDTriggerData,
c2f1e26c 111 &AliTRIPreprocessor::ProcessEmptyTriggerData,
112 &AliTRIPreprocessor::ProcessEmptyTriggerData,
113 &AliTRIPreprocessor::ProcessEmptyTriggerData,
114 &AliTRIPreprocessor::ProcessEmptyTriggerData,
1b950a11 115 &AliTRIPreprocessor::ProcessEmptyTriggerData,
c2f1e26c 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,
140 &AliTRIPreprocessor::ProcessEmptyTriggerData};
b48d2542 141
142
143 // getting the list of triggering detectors from DAQ logbook
144
145 TString triggerDetectorMask = (TString)GetTriggerDetectorMask();
146 Int_t result=0;
147 if (!triggerDetectorMask.IsNull()){
148 Int_t length = triggerDetectorMask.Length();
149 Log(Form("mask = %s", triggerDetectorMask.Data()));
150 for (Int_t i = 0; i<length; i++){
151 AliDebug(2,Form("%d-th bit = %c in index %d",i,triggerDetectorMask[length-1-i],length-1-i));
152 if (triggerDetectorMask[length-1-i] == '1'){
c2f1e26c 153 Log("****************************************");
154 Log(Form("Processing Trigger data for %s",fgkDetectorsMapName[i]));
155 Log("****************************************");
156
b48d2542 157 result+=(this->*processTriggerDataArray[i])();
158 }
159 }
160 }
161
162 // result should be 0 to end successfully
163
164 return result;
165
166}
167//______________________________________________________________________________________________
168Short_t AliTRIPreprocessor::ProcessSPDTriggerData()
169{
170 //
171 // Processing SPD Trigger Data
172 //
173
174 Log("************** Processing SPD Trigger data... **************");
175
176 // Read new conditions from dcs fxs
177 AliITSTriggerConditions* newCond = new AliITSTriggerConditions();
53aef915 178 TString fxsID = "pit_conditions";
b48d2542 179 TList* list = GetFileSources(kDCS, fxsID.Data());
180 if (!list) {
181 AliError("FXS file not found.");
182 return 1;
183 }
184 UInt_t nFiles = 0;
185 while (list->At(nFiles)!=NULL) {
186 TObjString* fileNameEntry = (TObjString*) list->At(nFiles);
187 TString fileName = GetFile(kDCS, fxsID.Data(), fileNameEntry->GetString().Data());
188 if (fileName.IsNull()) {
189 Log(Form("GetFile failed to retrieve file %s.",fileNameEntry->GetString().Data()));
190 return 1;
191 }
192 if (nFiles==0) newCond->ReadFromTextFile(fileName.Data());
193 nFiles++;
194 }
195 if (nFiles!=1) {
196 AliWarning(Form("Found %d files with id %s (expected exactly 1).",nFiles,fxsID.Data()));
197 }
198
199 // Read old conditions from ocdb
200 AliITSTriggerConditions* oldCond = NULL;
201 AliCDBEntry* pitCond = GetFromOCDB("SPD", "PITConditions");
202 if (pitCond) {
203 oldCond = (AliITSTriggerConditions*) pitCond->GetObject();
204 if (!oldCond) {
205 AliError("AliCDBEntry::GetObject() returned NULL.");
206 return 1;
207 }
208 }
209 else {
210 Log("Old conditions not found in database.");
211 }
212
213 // Do we need to update db?
214 Bool_t doUpdate = kTRUE;
215 if (oldCond) {
216 // compare to see if there were any changes...
217 if (newCond->IsEqualTo(oldCond)) {
218 Log("Old conditions equal to new conditions. Do nothing.");
219 doUpdate = kFALSE;
220 }
221 }
222
223 if (doUpdate) {
224 // store new conditions in ocdb
225 AliCDBMetaData metaData;
226 metaData.SetResponsible("Henrik Tydesjo");
227 metaData.SetComment("Created by Trigger PreProcessor");
228 if (!Store("SPD", "PITConditions", newCond, &metaData, 0, kTRUE)) {
229 Log("Failed to store conditions data.");
230 return 1;
231 }
232 Log("Database updated.");
233 }
234
235 delete newCond;
236
237 Log("************************* ...done.*************************");
238
239 return 0; // 0 means success
240
241}
242//______________________________________________________________________________________________
243Short_t AliTRIPreprocessor::ProcessTOFTriggerData()
244{
245 //
246 // Processing TOF Trigger Data
247 //
248
249 Log("************** Processing TOF Trigger data... **************");
7980897b 250 Log("************** Fake function **************");
b48d2542 251 Log("************************* ...done.*************************");
252 return 0;
253}
c2f1e26c 254//______________________________________________________________________________________________
255Short_t AliTRIPreprocessor::ProcessEmptyTriggerData()
256{
257 //
258 // Processing TOF Trigger Data
259 //
260
261 Log("************** Trigger data Processing not yet implemented **************");
262 return 0;
263}
b48d2542 264
265