]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TOF/AliTOFPreprocessor.cxx
Printout changed.
[u/mrichter/AliRoot.git] / TOF / AliTOFPreprocessor.cxx
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 <Riostream.h>
19 //#include <stdio.h>
20 //#include <stdlib.h>
21
22 #include <TFile.h>
23 #include <TH2S.h>
24 #include <TMath.h>
25 #include <TObjArray.h>
26 #include <TObjString.h>
27 #include <TTimeStamp.h>
28
29 #include "AliCDBMetaData.h"
30 #include "AliCDBEntry.h"
31 #include "AliLog.h"
32 #include "AliTOFChannelOnlineArray.h"
33 #include "AliTOFChannelOnlineStatusArray.h"
34 #include "AliTOFDataDCS.h"
35 #include "AliTOFGeometry.h"
36 #include "AliTOFPreprocessor.h"
37 #include "AliTOFFEEReader.h"
38 #include "AliTOFRawStream.h"
39 #include "AliTOFCableLengthMap.h"
40
41
42 // TOF preprocessor class.
43 // It takes data from DCS and passes them to the class AliTOFDataDCS, which
44 // processes them. The result is then written to the CDB.
45 // Analogously, it takes data form DAQ (both at Run level and inclusive - 
46 // of all the runs - level, processes them, and stores both Reference Data
47 // and Online Calibration files in the CDB. 
48 // Processing of Pulser/Noise Run data and of TOF FEE DCS map included also.
49
50 // return codes:
51 // return=0 : all ok
52 // return=1 : no DCS input data Map
53 // return=2 : no DCS input data processing
54 // return=3 : no DCS processed data was stored in Ref Data
55 // return=4 : no DAQ input for Ref Data
56 // return=5 : failed to store DAQ Ref Data
57 // return=6 : failed to retrieve DAQ data for calibration 
58 // return=7 : problems in processing histos in the input DAQ file 
59 // return=8 : failed to store Online Delays
60 // return=9 : failed to store Reference Data for Pulser
61 // return=10: failed to retrieve Pulser data 
62 // return=11: failed to store Pulser map in OCDB
63 // return=12: failed to store Reference Data for Noise
64 // return=13: failed to retrieve Noise data 
65 // return=14: failed to store Noise map in OCDB
66 // return=15: failed to retrieve FEE data from FXS
67 // return=16: failed to retrieve FEE data from OCDB
68 // return=17: failed to store FEE data in OCDB
69 // return=18: failed to store FEE reference data in OCDB
70 // return=20: failed in retrieving status variable
71
72 ClassImp(AliTOFPreprocessor)
73
74 const Int_t    AliTOFPreprocessor::fgkBinRangeAve = 13;    // number of bins where to calculate the mean 
75 const Double_t AliTOFPreprocessor::fgkIntegralThr = 100;   // min number of entries to perform computation of delay per channel 
76 const Double_t AliTOFPreprocessor::fgkThrPar      = 0.013; // parameter used to trigger the calculation of the delay
77
78 //_____________________________________________________________________________
79
80 AliTOFPreprocessor::AliTOFPreprocessor(AliShuttleInterface* shuttle) :
81   AliPreprocessor("TOF", shuttle),
82   fData(0),
83   fCal(0),
84   fNChannels(0),
85   fStoreRefData(kTRUE),
86   fFDRFlag(kFALSE),
87   fStatus(0),
88   fMatchingWindow(0)
89 {
90   // constructor
91   AddRunType("PHYSICS");
92   AddRunType("PULSER");
93   AddRunType("NOISE");
94
95 }
96
97 //_____________________________________________________________________________
98
99 AliTOFPreprocessor::~AliTOFPreprocessor()
100 {
101   // destructor
102 }
103
104 //______________________________________________________________________________
105 void AliTOFPreprocessor::Initialize(Int_t run, UInt_t startTime,
106         UInt_t endTime)
107 {
108   // Creates AliTOFDataDCS object
109
110   AliPreprocessor::Initialize(run, startTime, endTime);
111
112         AliInfo(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s \n\tStartTime DCS Query %s \n\tEndTime DCS Query %s", run,
113                 TTimeStamp(startTime).AsString(),
114                 TTimeStamp(endTime).AsString(), ((TTimeStamp)GetStartTimeDCSQuery()).AsString(), ((TTimeStamp)GetEndTimeDCSQuery()).AsString()));
115
116         fData = new AliTOFDataDCS(fRun, fStartTime, fEndTime, GetStartTimeDCSQuery(), GetEndTimeDCSQuery());
117         fNChannels = AliTOFGeometry::NSectors()*(2*(AliTOFGeometry::NStripC()+AliTOFGeometry::NStripB())+AliTOFGeometry::NStripA())*AliTOFGeometry::NpadZ()*AliTOFGeometry::NpadX();
118 }
119 //_____________________________________________________________________________
120 Bool_t AliTOFPreprocessor::ProcessDCS(){
121
122   // check whether DCS should be processed or not...
123
124   TString runType = GetRunType();
125   Log(Form("RunType %s",runType.Data()));
126
127   if (runType != "PHYSICS"){
128     return kFALSE;
129   }
130
131   return kTRUE;
132 }
133 //_____________________________________________________________________________
134
135 UInt_t AliTOFPreprocessor::ProcessDCSDataPoints(TMap* dcsAliasMap)
136 {
137   // Fills data into a AliTOFDataDCS object
138
139
140   Log("Processing DCS DP");
141   TH1::AddDirectory(0);
142
143   Bool_t resultDCSMap=kFALSE;
144   Bool_t resultDCSStore=kFALSE;
145
146   // processing DCS
147
148   fData->SetFDRFlag(fFDRFlag);
149   
150   if (!dcsAliasMap){
151     Log("No DCS map found: TOF exiting from Shuttle");
152     if (fData){
153             delete fData;
154             fData = 0;
155     }
156     return 1;// return error Code for DCS input data not found 
157   }
158   else {
159
160   // The processing of the DCS input data is forwarded to AliTOFDataDCS
161     resultDCSMap=fData->ProcessData(*dcsAliasMap);
162     if(!resultDCSMap){
163       Log("Some problems occurred while processing DCS data, TOF exiting from Shuttle");
164       if (fData){
165               delete fData;
166               fData = 0;
167       }
168       return 2;// return error Code for processed DCS data not stored 
169     }
170     else{
171       AliCDBMetaData metaDataDCS;
172       metaDataDCS.SetBeamPeriod(0);
173       metaDataDCS.SetResponsible("Chiara Zampolli");
174       metaDataDCS.SetComment("This preprocessor fills an AliTOFDataDCS object.");
175       AliInfo("Storing DCS Data");
176       resultDCSStore = StoreReferenceData("Calib","DCSData",fData, &metaDataDCS);
177       if (!resultDCSStore){
178         Log("Some problems occurred while storing DCS data results in Reference Data, TOF exiting from Shuttle");
179         if (fData){
180                 delete fData;
181                 fData = 0;
182         }
183         return 3;// return error Code for processed DCS data not stored 
184                  // in reference data
185         
186       }
187     }
188   }
189   if (fData){
190           delete fData;
191           fData = 0;
192   }
193   
194   return 0;
195 }
196 //_____________________________________________________________________________
197
198 UInt_t AliTOFPreprocessor::ProcessOnlineDelays()
199 {
200   // Processing data from DAQ for online calibration 
201
202   Log("Processing DAQ delays");
203
204   // reading configuration map 
205   TString compDelays = "kFALSE";
206   Int_t deltaStartingRun = fRun;
207   Int_t startingRun = fRun-deltaStartingRun;
208   Int_t binRangeAve = fgkBinRangeAve;
209   Double_t integralThr = fgkIntegralThr;
210   Double_t thrPar = fgkThrPar;
211
212   AliCDBEntry *cdbEntry = GetFromOCDB("Calib","Config");
213   if (!cdbEntry) {
214           Log(Form("No Configuration entry found in CDB, using default values: ComputingDelays = %s, StartingRun = %i",compDelays.Data(), startingRun));
215   }
216   else {
217           TMap *configMap = (TMap*)cdbEntry->GetObject();
218           if (!configMap){
219                   Log(Form("No map found in Config entry in CDB, using default values: ComputingDelays = %s, StartingRun = %i",compDelays.Data(), startingRun));
220           }
221           else{
222                   TObjString *strDelays = (TObjString*)configMap->GetValue("ComputingDelays");
223                   if (strDelays) {
224                           compDelays = (TString) strDelays->GetString();
225                   }
226                   else {
227                           Log(Form("No ComputingDelays value found in Map from Config entry in CDB, using default value: ComputingDelays =  %s",compDelays.Data()));
228                   }
229                   TObjString *strRun = (TObjString*)configMap->GetValue("StartingRun");
230                   if (strRun) {
231                           TString tmpstr = strRun->GetString();
232                           startingRun = tmpstr.Atoi();
233                           deltaStartingRun = fRun - startingRun;
234                   }
235                   else {
236                           Log(Form("No StartingRun value found in Map from Config entry in CDB, using default value: StartingRun = %i",startingRun));
237                   }
238                   TObjString *strBinRangeAve = (TObjString*)configMap->GetValue("BinRangeAve");
239                   if (strBinRangeAve) {
240                           TString tmpstr = strBinRangeAve->GetString();
241                           binRangeAve = tmpstr.Atoi();
242                   }
243                   else {
244                           Log(Form("No BinRangeAve value found in Map from Config entry in CDB, using default value: BinRangeAve = %i",binRangeAve));
245                   }
246                   TObjString *strIntegralThr = (TObjString*)configMap->GetValue("IntegralThr");
247                   if (strIntegralThr) {
248                           TString tmpstr = strIntegralThr->GetString();
249                           integralThr = tmpstr.Atof();
250                   }
251                   else {
252                           Log(Form("No IntegralThr value found in Map from Config entry in CDB, using default value: IntegralThr = %i",integralThr));
253                   }
254                   TObjString *strThrPar = (TObjString*)configMap->GetValue("ThrPar");
255                   if (strThrPar) {
256                           TString tmpstr = strThrPar->GetString();
257                           thrPar = tmpstr.Atof();
258                   }
259                   else {
260                           Log(Form("No ThrPar value found in Map from Config entry in CDB, using default value: ThrPar = %i",thrPar));
261                   }
262           }
263   }
264   if (compDelays == "kTRUE") fFDRFlag = kFALSE;
265   else fFDRFlag = kTRUE;
266
267   delete cdbEntry;
268   cdbEntry = 0x0;
269
270   Log(Form("ComputingDelays = %s, StartingRun = %i",compDelays.Data(),startingRun));
271
272   fCal = new AliTOFChannelOnlineArray(fNChannels);
273
274   TH1::AddDirectory(0);
275
276   Bool_t resultDAQRef=kFALSE;
277   Bool_t resultTOFPP=kFALSE;
278   TH2S *h2 = 0x0;
279   // processing DAQ
280   
281   TFile * daqFile=0x0;
282   
283   if(fStoreRefData){
284     //retrieving data at Run level
285           TList* list = GetFileSources(kDAQ, "RUNLevel");
286           if (list !=0x0 && list->GetEntries()!=0)
287                   {
288                           AliInfo("The following sources produced files with the id RUNLevel");
289                           list->Print();
290                           for (Int_t jj=0;jj<list->GetEntries();jj++){
291                                   TObjString * str = dynamic_cast<TObjString*> (list->At(jj));
292                                   AliInfo(Form("found source %s", str->String().Data()));
293                                   // file to be stored run per run
294                                   TString fileNameRun = GetFile(kDAQ, "RUNLevel", str->GetName());
295                                   if (fileNameRun.Length()>0){
296                                           AliInfo(Form("Got the file %s, now we can store the Reference Data for the current Run.", fileNameRun.Data()));
297                                           daqFile = new TFile(fileNameRun.Data(),"READ");
298                                           h2 = (TH2S*) daqFile->Get("htof");
299                                           AliCDBMetaData metaDataHisto;
300                                           metaDataHisto.SetBeamPeriod(0);
301                                           metaDataHisto.SetResponsible("Chiara Zampolli");
302                                           metaDataHisto.SetComment("This preprocessor stores the array of histos object as Reference Data.");
303                                           AliInfo("Storing Reference Data");
304                                           resultDAQRef = StoreReferenceData("Calib","DAQData",h2, &metaDataHisto);
305                                           if (!resultDAQRef){
306                                                   Log("some problems occurred::No Reference Data stored, TOF exiting from Shuttle");
307                                                   delete h2;
308                                                   delete list;
309                                                   delete fCal;
310                                                   fCal=0x0;
311                                                   return 5;//return error code for failure in storing Ref Data 
312                                           }
313                                           daqFile->Close();
314                                           delete daqFile;
315                                   }
316                                   
317                                   else{
318                                           Log("The input data file from DAQ (run-level) was not found, TOF exiting from Shuttle "); 
319                                           delete list;
320                                           delete fCal;
321                                           fCal=0x0;
322                                           return 4;//return error code for failure in retrieving Ref Data 
323                                   }
324                           }
325                           delete list;
326                   }
327           else{
328                   Log("The input data file list from DAQ (run-level) was not found, TOF exiting from Shuttle "); 
329                   delete fCal;
330                   fCal=0x0;
331                   return 4;//return error code for failure in retrieving Ref Data 
332           }     
333   }
334
335
336   //Total files, with cumulative histos
337   
338   TList* listTot = GetFileSources(kDAQ, "DELAYS");
339   if (listTot !=0x0 && listTot->GetEntries()!=0)
340           {
341                   AliInfo("The following sources produced files with the id DELAYS");
342                   listTot->Print();
343                   for (Int_t jj=0;jj<listTot->GetEntries();jj++){
344                           TObjString * str = dynamic_cast<TObjString*> (listTot->At(jj));
345                           AliInfo(Form("found source %s", str->String().Data()));
346                           
347                           // file with summed histos, to extract calib params
348                           TString fileName = GetFile(kDAQ, "DELAYS", str->GetName());
349                           if (fileName.Length()>0){
350                                   AliInfo(Form("Got the file %s, now we can extract some values.", fileName.Data()));
351                                   
352                                   daqFile = new TFile(fileName.Data(),"READ");
353                                   if (h2) delete h2;
354                                   h2 = (TH2S*) daqFile->Get("htoftot");
355                                   if (!h2){
356                                           Log("some problems occurred:: No histo retrieved, TOF exiting from Shuttle");
357                                           delete listTot;
358                                           delete daqFile;
359                                           delete fCal;
360                                           fCal=0x0;
361                                           return 7; //return error code for histograms not existing/junky
362                                   }
363                                   else {
364                                           static const Int_t kSize=h2->GetNbinsX();
365                                           static const Int_t kNBins=h2->GetNbinsY();
366                                           static const Double_t kXBinmin=h2->GetYaxis()->GetBinLowEdge(1);
367                                           if (kSize != fNChannels){
368                                                   Log(" number of bins along x different from number of pads, found only a subset of the histograms, TOF exiting from Shuttle");
369                                                   delete listTot;
370                                                   delete h2;
371                                                   delete daqFile;
372                                                   delete fCal;
373                                                   fCal=0x0;
374                                                   return 7; //return error code for histograms not existing/junky
375                                           }
376                                           Int_t nNotStatistics = 0; // number of channel with not enough statistics
377
378  /* FDR flag set. do not compute delays, use nominal cable delays */
379                                           if (fFDRFlag) {
380
381                                             Log(" Not computing delays according to flag set in Config entry in OCDB!");
382                                             Log(" Using nominal cable delays.");
383                                             
384                                             AliTOFRawStream tofrs;
385                                             Int_t det[5], dummy, index;
386                                             Float_t cableTimeShift;
387                                             
388                                             /* temporarly disable warnings */
389                                             AliLog::EType_t logLevel = (AliLog::EType_t)AliLog::GetGlobalLogLevel();
390                                             AliLog::SetGlobalLogLevel(AliLog::kError);
391
392                                             /* loop over EO indeces */
393                                             for (Int_t iddl = 0; iddl < 72; iddl++)
394                                               for (Int_t islot = 3; islot <= 12; islot++)
395                                                 for (Int_t ichain = 0; ichain < 2; ichain++)
396                                                   for (Int_t itdc = 0; itdc < 15; itdc++)
397                                                     for (Int_t ichannel = 0; ichannel < 8; ichannel++) {
398                                                       
399                                                       /* get DO index */
400                                                       tofrs.EquipmentId2VolumeId(iddl, islot, ichain, itdc, ichannel, det);
401                                                       
402                                                       /* swap det[3] and det[4] indeces (needed to obtain correct channel index) */
403                                                       dummy = det[3];
404                                                       det[3] = det[4];
405                                                       det[4] = dummy;
406                                                       
407                                                       /* check DO index */
408                                                       if (det[0] < 0 || det[0] > 17 ||
409                                                           det[1] < 0 || det[1] > 4 ||
410                                                           det[2] < 0 || det[2] > 18 ||
411                                                           det[3] < 0 || det[3] > 1 ||
412                                                           det[4] < 0 || det[4] > 47)
413                                                         continue;
414                                                       
415                                                       /* get channel index */
416                                                       index = AliTOFGeometry::GetIndex(det);
417                                                       
418                                                       /* get cable time shift */
419                                                       cableTimeShift = AliTOFCableLengthMap::GetCableTimeShift(iddl, islot, ichain, itdc);
420                                                       
421                                                       /* set delay */
422                                                       if (index<fNChannels) {
423                                                         fCal->SetDelay(index,cableTimeShift);  // delay in ns
424                                                         AliDebug(2,Form("Setting delay %f (ns) for channel %i",cableTimeShift,index));
425                                                       }
426                                                       
427                                                     } /* loop over EO indeces */
428
429                                             /* re-enable warnings */
430                                             AliLog::SetGlobalLogLevel(logLevel);
431                                             
432                                           }
433
434                                           else {  // computing delays if not in FDR runs
435                                                   for (Int_t ich=0;ich<kSize;ich++){
436                                                           /* check whether channel has been read out during current run.
437                                                            * if the status is bad it means it has not been read out.
438                                                            * in this case skip channel in order to not affect the mean */ 
439                                                           if (fStatus->GetHWStatus(ich) == AliTOFChannelOnlineStatusArray::kTOFHWBad){
440                                                                   AliDebug(2,Form(" Channel %i found bad according to FEEmap, (HW status = %i), skipping from delay computing",ich, (Int_t)fStatus->GetHWStatus(ich)));
441                                                                   continue;
442                                                           }
443                                                           AliDebug(2,Form(" Channel %i found ok according to FEEmap, starting delay computing",ich));
444                                                           TH1S *h1 = new TH1S("h1","h1",kNBins,kXBinmin-0.5,kNBins*1.+kXBinmin-0.5);
445                                                           for (Int_t ibin=0;ibin<kNBins;ibin++){
446                                                                   h1->SetBinContent(ibin+1,h2->GetBinContent(ich+1,ibin+1));
447                                                           }
448                                                           if(h1->Integral()<integralThr) {
449                                                                   nNotStatistics++;
450                                                                   Log(Form(" Not enough statistics for bin %i, skipping this channel",ich));  // printing message only if not in FDR runs
451                                                                   delete h1;
452                                                                   h1=0x0;
453                                                                   continue;
454                                                           }
455                                                           Bool_t found=kFALSE; 
456                                                           Float_t minContent=h1->Integral()*thrPar; 
457                                                           Int_t nbinsX = h1->GetNbinsX();
458                                                           Int_t startBin=1;
459                                                           for (Int_t j=1; j<=nbinsX; j++){
460                                                                   if ((
461                                                                        h1->GetBinContent(j) +     
462                                                                        h1->GetBinContent(j+1)+
463                                                                        h1->GetBinContent(j+2)+ 
464                                                                        h1->GetBinContent(j+3))>minContent){
465                                                                           found=kTRUE;
466                                                                           startBin=j;
467                                                                           break;
468                                                                   }
469                                                           }
470                                                           if(!found) AliInfo(Form("WARNING!!! no start of fit found for histo # %i",ich));
471                                                           // Now calculate the mean over the interval. 
472                                                           Double_t mean = 0;
473                                                           Double_t sumw2 = 0;
474                                                           Double_t nent = 0;
475                                                           for(Int_t k=0;k<binRangeAve;k++){
476                                                                   mean=mean+h1->GetBinCenter(startBin+k)*h1->GetBinContent(startBin+k);                 
477                                                                   nent=nent+h1->GetBinContent(startBin+k);                 
478                                                                   sumw2=sumw2+(h1->GetBinCenter(startBin+k))*(h1->GetBinCenter(startBin+k))*(h1->GetBinContent(startBin+k));
479                                                           }
480                                                           mean= mean/nent; //<x>
481                                                           sumw2=sumw2/nent; //<x^2>
482                                                           Double_t rmsmean= 0;
483                                                           rmsmean = TMath::Sqrt((sumw2-mean*mean)/nent);
484                                                           if (ich<fNChannels) {
485                                                                   Float_t delay = mean*AliTOFGeometry::TdcBinWidth()*1.E-3; // delay in ns
486                                                                   fCal->SetDelay(ich,delay);  // delay in ns
487                                                                   AliDebug(2,Form("Setting delay %f (ns) for channel %i",delay,ich));
488                                                           }
489                                                           delete h1;
490                                                           h1=0x0;
491                                                   }
492                                           }
493                                           if (nNotStatistics!=0) Log(Form("Too little statistics for %d channels!",nNotStatistics)); 
494                                   }
495                                   delete h2;
496                                   daqFile->Close();
497                                   delete daqFile;
498                           }
499                           else{
500                                   Log("The Cumulative data file from DAQ does not exist, TOF exiting from Shuttle"); 
501                                   delete listTot;
502                                   delete fCal;
503                                   fCal=0x0;
504                                   return 6;//return error code for problems in retrieving DAQ data 
505                           }
506                   }
507                   delete listTot;
508           }
509   else{
510     Log("Problem: no list for Cumulative data file from DAQ was found, TOF exiting from Shuttle");
511     delete fCal;
512     fCal=0x0;
513     return 6; //return error code for problems in retrieving DAQ data 
514   }
515
516   daqFile=0;
517   AliCDBMetaData metaData;
518   metaData.SetBeamPeriod(0);
519   metaData.SetResponsible("Chiara Zampolli");
520   metaData.SetComment("This preprocessor fills an AliTOFChannelOnlineArray object for online calibration - delays.");
521   AliInfo("Storing Calibration Data");
522   resultTOFPP = Store("Calib","ParOnlineDelay",fCal, &metaData,deltaStartingRun,kTRUE);
523   if(!resultTOFPP){
524     Log("Some problems occurred while storing online object resulting from DAQ data processing");
525     delete fCal;
526     fCal=0x0;
527     return 8;//return error code for problems in storing DAQ data 
528   }
529
530   if (fCal){
531     delete fCal;
532     fCal = 0;
533   }
534
535   return 0;
536 }
537 //_____________________________________________________________________________
538
539 UInt_t AliTOFPreprocessor::ProcessPulserData()
540 {
541   // Processing Pulser Run data for TOF channel status
542
543   Log("Processing Pulser");
544
545   if (fStatus==0x0){
546           AliError("No valid fStatus found, some errors must have occurred!!");
547           return 20;
548   }
549
550   TH1::AddDirectory(0);
551   
552   Bool_t resultPulserRef=kFALSE;
553   Bool_t resultPulser=kFALSE;
554   
555   static const Int_t kSize = AliTOFGeometry::NPadXSector()*AliTOFGeometry::NSectors();
556   TH1S * htofPulser = new TH1S("hTOFpulser","histo with signals on TOF during pulser", kSize,-0.5,kSize-0.5);
557   for (Int_t ibin =1;ibin<=kSize;ibin++){
558           htofPulser->SetBinContent(ibin,-1);
559   }
560   
561   // processing pulser
562   
563   TFile * daqFile=0x0;
564   TH1S *h1=0x0;
565   
566   //retrieving Pulser data 
567   TList* listPulser = GetFileSources(kDAQ, "PULSER");
568   if (listPulser !=0x0 && listPulser->GetEntries()!=0)
569           {
570                   AliInfo("The following sources produced files with the id PULSER");
571                   listPulser->Print();
572                   Int_t nPulser = 0;
573                   for (Int_t jj=0;jj<listPulser->GetEntries();jj++){
574                           Int_t nPulserSource = 0;
575                           TObjString * str = dynamic_cast<TObjString*> (listPulser->At(jj));
576                           AliInfo(Form("found source %s", str->String().Data()));
577                           // file to be stored run per run
578                           TString fileNamePulser = GetFile(kDAQ, "PULSER", str->GetName());
579                           if (fileNamePulser.Length()>0){
580                                   // storing refernce data
581                                   AliInfo(Form("Got the file %s, now we can process pulser data.", fileNamePulser.Data()));
582                                   daqFile = new TFile(fileNamePulser.Data(),"READ");
583                                   h1 = (TH1S*) daqFile->Get("hTOFpulser");
584                                   for (Int_t ibin=0;ibin<kSize;ibin++){
585                                           if ((h1->GetBinContent(ibin+1))!=-1){
586                                                   if ((htofPulser->GetBinContent(ibin+1))==-1){
587                                                           htofPulser->SetBinContent(ibin+1,h1->GetBinContent(ibin+1));
588                                                   }
589                                                   else {
590                                                           Log(Form("Something strange occurred during Pulser run, channel %i already read by another LDC, please check!",ibin));
591                                                   }
592                                           }
593                                   }
594                                   
595                                   // elaborating infos
596                                   Double_t mean =0;
597                                   Int_t nread=0;
598                                   Int_t nreadNotEmpty=0;
599                                   for (Int_t ientry=1;ientry<=h1->GetNbinsX();ientry++){
600                                           
601                                           AliDebug(3,Form(" channel %i pulser status before pulser = %i, with global status = %i",ientry,(Int_t)fStatus->GetPulserStatus(ientry),(Int_t)fStatus->GetStatus(ientry)));
602                                           /* check whether channel has been read out during current run.
603                                            * if the status is bad it means it has not been read out.
604                                            * in this case skip channel in order to not affect the mean */ 
605                                           if (fStatus->GetHWStatus(ientry-1) == AliTOFChannelOnlineStatusArray::kTOFHWBad)
606                                                   continue;
607                                           nPulser++;
608                                           nPulserSource++;
609                                           if (h1->GetBinContent(ientry)==-1) continue;
610                                           else {
611                                                   if (h1->GetBinContent(ientry)>0) {
612                                                           nreadNotEmpty++;
613                                                           AliDebug(2,Form(" channel %i is ok with entry = %f; so far %i channels added ",ientry-1,h1->GetBinContent(ientry),nreadNotEmpty));
614                                                   }
615                                                   mean+=h1->GetBinContent(ientry);
616                                                   nread++;
617                                           }
618                                   }
619                                   if (nread!=0) {
620                                           mean/=nread;
621                                           AliDebug(2,Form(" nread =  %i , nreadNotEmpty = %i, mean = %f",nread,nreadNotEmpty,mean));
622                                           for (Int_t ich =0;ich<fNChannels;ich++){
623                                                   if (h1->GetBinContent(ich+1)==-1) continue;
624                                                   AliDebug(3,Form(" channel %i pulser status before pulser = %i",ich,(Int_t)fStatus->GetPulserStatus(ich)));
625                                                   
626                                                   /* check whether channel has been read out during current run.
627                                                    * if the status is bad it means it has not been read out.
628                                                    * in this case skip channel in order to leave its status 
629                                                    * unchanged */
630                                                   if (fStatus->GetHWStatus(ich) == AliTOFChannelOnlineStatusArray::kTOFHWBad)
631                                                           continue;
632                                                   
633                                                   if (h1->GetBinContent(ich+1)<0.05*mean){
634                                                           fStatus->SetPulserStatus(ich,AliTOFChannelOnlineStatusArray::kTOFPulserBad);  // bad status for pulser
635                                                           AliDebug(2,Form( " channel %i pulser status after pulser = %i (bad, content = %f), with global status = %i",ich,(Int_t)fStatus->GetPulserStatus(ich),h1->GetBinContent(ich+1),(Int_t)fStatus->GetStatus(ich)));
636                                                   }
637                                                   else {
638                                                           fStatus->SetPulserStatus(ich,AliTOFChannelOnlineStatusArray::kTOFPulserOk);  // good status for pulser
639                                                           AliDebug(2,Form( " channel %i pulser status after pulser = %i (good), with global status = %i",ich,(Int_t)fStatus->GetPulserStatus(ich),(Int_t)fStatus->GetStatus(ich)));
640                                                   }
641                                           }
642                                   }
643                                   else {
644                                           Log("No channels read!! No action taken, keeping old status");
645                                   }
646                                   
647                                   daqFile->Close();
648                                   delete daqFile;
649                                   delete h1;
650                           }
651                           
652                           else{
653                                   Log("The input data file from DAQ (pulser) was not found, TOF exiting from Shuttle "); 
654                                   delete listPulser;
655                                   delete htofPulser;
656                                   htofPulser = 0x0;
657                                   if (fStatus){
658                                           delete fStatus;
659                                           fStatus = 0;
660                                   }
661                                   return 10;//return error code for failure in retrieving Ref Data 
662                           }
663                           AliDebug(2,Form(" Number of channels processed during pulser run from source %i = %i",jj, nPulserSource));             
664                   }
665                   AliDebug(2,Form(" Number of channels processed during pulser run = %i",nPulser));
666                   delete listPulser;
667           }
668   
669   else{
670           Log("The input data file list from DAQ (pulser) was not found, TOF exiting from Shuttle "); 
671           delete htofPulser;
672           htofPulser = 0x0;
673           if (fStatus){
674                   delete fStatus;
675                   fStatus = 0;
676           }
677           return 10;//return error code for failure in retrieving Ref Data 
678   }     
679   
680   //storing in OCDB  
681   
682   AliCDBMetaData metaData;
683   metaData.SetBeamPeriod(0);
684   metaData.SetResponsible("Chiara Zampolli");
685   metaData.SetComment("This preprocessor fills an AliTOFChannelOnlineStatusArray object after a Pulser run.");
686   AliInfo("Storing Calibration Data from Pulser Run");
687   resultPulser = Store("Calib","Status",fStatus, &metaData,0,kTRUE);
688   if(!resultPulser){
689     Log("Some problems occurred while storing online object resulting from Pulser data processing");
690     delete htofPulser;
691     htofPulser = 0x0;
692     if (fStatus){
693             delete fStatus;
694             fStatus = 0;
695     }
696     return 11;//return error code for problems in storing Pulser data 
697   }
698
699   if(fStoreRefData){
700     
701     AliCDBMetaData metaDataHisto;
702     metaDataHisto.SetBeamPeriod(0);
703     metaDataHisto.SetResponsible("Chiara Zampolli");
704     char comment[200];
705     sprintf(comment,"This preprocessor stores the Ref data from a pulser run.");
706     metaDataHisto.SetComment(comment);
707     AliInfo("Storing Reference Data");
708     resultPulserRef = StoreReferenceData("Calib","PulserData",htofPulser, &metaDataHisto);
709     if (!resultPulserRef){
710       Log("some problems occurred::No Reference Data for pulser stored, TOF exiting from Shuttle");
711       delete htofPulser;
712       htofPulser = 0x0;
713       if (fStatus){
714               delete fStatus;
715               fStatus = 0;
716       }
717       return 9;//return error code for failure in storing Ref Data 
718     }
719   }
720   
721   daqFile=0;
722
723   delete htofPulser;
724   htofPulser = 0x0;
725
726   if (fStatus){
727     delete fStatus;
728     fStatus = 0;
729   }
730
731   return 0;
732 }
733 //_____________________________________________________________________________
734
735 UInt_t AliTOFPreprocessor::ProcessNoiseData()
736 {
737
738   // Processing Noise Run data for TOF channel status
739
740   Log("Processing Noise");
741
742   if (fStatus==0x0){
743           AliError("No valid fStatus found, some errors must have occurred!!");
744           return 20;
745   }
746
747   Float_t noiseThr = 1;   // setting default threshold for noise to 1 Hz
748   // reading config map
749   AliCDBEntry *cdbEntry = GetFromOCDB("Calib","ConfigNoise");
750   if (!cdbEntry) {
751           Log(Form("No Configuration entry found in CDB, using default values: NoiseThr = %d",noiseThr));
752   }
753   else {
754           TMap *configMap = (TMap*)cdbEntry->GetObject();
755           if (!configMap){
756                   Log(Form("No map found in Config entry in CDB, using default values: NoiseThr = %d", noiseThr));
757           }
758           else{
759                   TObjString *strNoiseThr = (TObjString*)configMap->GetValue("NoiseThr");
760                   if (strNoiseThr) {
761                           TString tmpstr = strNoiseThr->GetString();
762                           noiseThr = tmpstr.Atoi();
763                   }
764                   else {
765                           Log(Form("No NoiseThr value found in Map from ConfigNoise entry in CDB, using default value: NoiseThr = %i",noiseThr));
766                   }
767           }
768   }
769
770   delete cdbEntry;
771   cdbEntry = 0x0;
772
773   TH1::AddDirectory(0);
774
775   Bool_t resultNoiseRef=kFALSE;
776   Bool_t resultNoise=kFALSE;
777
778   static const Int_t kSize = AliTOFGeometry::NPadXSector()*AliTOFGeometry::NSectors();
779   TH1F * htofNoise = new TH1F("hTOFnoise","histo with signals on TOF during noise", kSize,-0.5,kSize-0.5);
780   for (Int_t ibin =1;ibin<=kSize;ibin++){
781           htofNoise->SetBinContent(ibin,-1);
782   }
783   
784   // processing noise
785   
786   TFile * daqFile=0x0;
787   TH1F * h1=0x0;
788   
789   // useful counters
790   Int_t nNoise = 0;
791   Int_t nNoisyChannels = 0;
792   Int_t nNotNoisyChannels = 0;
793   Int_t nChannelsFromDA = 0;
794   Int_t nMatchingWindowNullNonZero = 0;
795   Int_t nMatchingWindowNullEqualZero = 0;
796
797   // retrieving Noise data 
798   TList* listNoise = GetFileSources(kDAQ, "NOISE");
799   if (listNoise !=0x0 && listNoise->GetEntries()!=0)
800           {
801                   AliInfo("The following sources produced files with the id NOISE");
802                   listNoise->Print();
803                   for (Int_t jj=0;jj<listNoise->GetEntries();jj++){
804                           Int_t nNoiseSource = 0;
805                           TObjString * str = dynamic_cast<TObjString*> (listNoise->At(jj));
806                           AliInfo(Form("found source %s", str->String().Data()));
807                           // file to be stored run per run
808                           TString fileNameNoise = GetFile(kDAQ, "NOISE", str->GetName());
809                           if (fileNameNoise.Length()>0){
810                                   // storing reference data
811                                   AliInfo(Form("Got the file %s, now we can process noise data.", fileNameNoise.Data()));
812                                   daqFile = new TFile(fileNameNoise.Data(),"READ");
813                                   h1 = (TH1F*) daqFile->Get("hTOFnoise");
814                                   for (Int_t ibin=0;ibin<kSize;ibin++){
815                                           if ((h1->GetBinContent(ibin+1))!=-1){
816                                                   nNoiseSource++;
817                                                   // checking the matching window for current channel
818                                                   if (fMatchingWindow[ibin] == 0){
819                                                           Log(Form("Matching window for channel %i null, but the channel was read by the LDC! skipping channel, BUT Please check!",ibin));
820                                                           if ((h1->GetBinContent(ibin+1))!=0) nMatchingWindowNullNonZero++;                                             
821                                                           if ((h1->GetBinContent(ibin+1))==0) nMatchingWindowNullEqualZero++;                                           
822                                                           continue;
823                                                   }
824                                                   if ((htofNoise->GetBinContent(ibin+1))==-1){
825                                                           htofNoise->SetBinContent(ibin+1,h1->GetBinContent(ibin+1)/(fMatchingWindow[ibin]*1.E-9));
826                                                           if ((h1->GetBinContent(ibin+1))!= 0) AliDebug(2,Form("Channel = %i, Matching window = %i, Content = %f", ibin, fMatchingWindow[ibin], htofNoise->GetBinContent(ibin+1)));
827                                                   }
828                                                   else {
829                                                           Log(Form("Something strange occurred during Noise run, channel %i already read by another LDC, please check!",ibin));
830                                                   }
831                                           }
832                                   }
833
834                                   Log(Form(" Number of channels processed during noise run from source %i = %i",jj, nNoiseSource));
835                                   daqFile->Close();
836                                   delete daqFile;
837                                   delete h1;
838                                   daqFile = 0x0;
839                                   h1 = 0x0;
840
841                           }
842                           else{
843                                   Log("The input data file from DAQ (noise) was not found, TOF exiting from Shuttle "); 
844                                   delete listNoise;
845                                   listNoise = 0x0;
846                                   delete htofNoise;
847                                   htofNoise = 0x0;
848                                   if (fStatus){
849                                           delete fStatus;
850                                           fStatus = 0;
851                                   }
852                                   if (fMatchingWindow){
853                                           delete [] fMatchingWindow;
854                                           fMatchingWindow = 0;
855                                   }
856                                   return 13;//return error code for failure in retrieving Ref Data 
857                           }
858                   }               
859           }
860                           
861   else{
862           Log("The input data file list from DAQ (noise) was not found, TOF exiting from Shuttle "); 
863           delete htofNoise;
864           htofNoise = 0x0;
865           if (fStatus){
866                   delete fStatus;
867                   fStatus = 0;
868           }
869           if (fMatchingWindow){
870                   delete [] fMatchingWindow;
871                   fMatchingWindow = 0;
872           }
873           return 13;//return error code for failure in retrieving Ref Data 
874   }     
875   
876   // elaborating infos to set NOISE status
877   for (Int_t ich =0;ich<fNChannels;ich++){
878           if (htofNoise->GetBinContent(ich+1)== -1) continue;
879
880           nChannelsFromDA++;
881
882           AliDebug(3,Form(" channel %i noise status before noise = %i, with global status = %i",ich,(Int_t)fStatus->GetNoiseStatus(ich),(Int_t)fStatus->GetStatus(ich)));
883           //AliDebug(2,Form( " channel %i status before noise = %i",ich,(Int_t)fStatus->GetNoiseStatus(ich)));
884           
885           /* check whether channel has been read out during current run.
886            * if the status is bad it means it has not been read out.
887            * in this case skip channel in order to leave its status 
888            * unchanged */
889
890           if ((fStatus->GetHWStatus(ich)) == AliTOFChannelOnlineStatusArray::kTOFHWBad)
891                   continue;
892           
893           nNoise++;
894           if (htofNoise->GetBinContent(ich+1) >= noiseThr){
895                   fStatus->SetNoiseStatus(ich,AliTOFChannelOnlineStatusArray::kTOFNoiseBad); // bad status for noise
896                   AliDebug(3,Form( " channel %i noise status after noise = %i, with global status = %i",ich,(Int_t)fStatus->GetNoiseStatus(ich),(Int_t)fStatus->GetStatus(ich)));
897                   nNoisyChannels++;
898           }
899           else {
900                   fStatus->SetNoiseStatus(ich,AliTOFChannelOnlineStatusArray::kTOFNoiseOk); // good status for noise
901                   AliDebug(3,Form(" channel %i noise status after noise = %i, with global status = %i",ich,(Int_t)fStatus->GetNoiseStatus(ich),(Int_t)fStatus->GetStatus(ich)));
902                   nNotNoisyChannels++;
903           }
904   }
905   
906   Log(Form(" Number of channels processed by DA during noise run, independetly from TOFFEE = %i",nChannelsFromDA));
907   Log(Form(" Number of channels processed during noise run (that were ON according to TOFFEE) = %i",nNoise));
908   Log(Form(" Number of noisy channels found during noise run = %i",nNoisyChannels));
909   Log(Form(" Number of not noisy channels found during noise run = %i",nNotNoisyChannels));
910   Log(Form(" Number of channels with matching window NULL (so skipped), but Non Zero content = %i",nMatchingWindowNullNonZero));
911   Log(Form(" Number of channels with matching window NULL (so skipped), and Zero content = %i",nMatchingWindowNullEqualZero));
912
913   delete listNoise;
914   
915   //daqFile=0;
916   
917   //storing in OCDB
918   
919   AliCDBMetaData metaData;
920   metaData.SetBeamPeriod(0);
921   metaData.SetResponsible("Chiara Zampolli");
922   metaData.SetComment("This preprocessor fills an AliTOFChannelOnlineStatusArray object after a Noise run.");
923   AliInfo("Storing Calibration Data from Noise Run");
924   resultNoise = Store("Calib","Status",fStatus, &metaData,0,kTRUE);
925   if(!resultNoise){
926     Log("Some problems occurred while storing online object resulting from Noise data processing");
927     delete htofNoise;
928     htofNoise = 0x0;
929     if (fStatus){
930             delete fStatus;
931             fStatus = 0;
932     }
933     if (fMatchingWindow){
934             delete [] fMatchingWindow;
935             fMatchingWindow = 0;
936     }
937     return 14;//return error code for problems in storing Noise data 
938   }
939
940   if(fStoreRefData){
941     
942     AliCDBMetaData metaDataHisto;
943     metaDataHisto.SetBeamPeriod(0);
944     metaDataHisto.SetResponsible("Chiara Zampolli");
945     char comment[200];
946     sprintf(comment,"This preprocessor stores the Ref data from a noise run. ");
947     metaDataHisto.SetComment(comment);
948     AliInfo("Storing Reference Data");
949     resultNoiseRef = StoreReferenceData("Calib","NoiseData",htofNoise, &metaDataHisto);
950     if (!resultNoiseRef){
951       Log("some problems occurred::No Reference Data for noise stored");
952       delete htofNoise;
953       htofNoise = 0x0;
954       if (fStatus){
955               delete fStatus;
956               fStatus = 0;
957       }
958       if (fMatchingWindow){
959               delete [] fMatchingWindow;
960               fMatchingWindow = 0;
961       }
962       return 12;//return error code for failure in storing Ref Data 
963     }
964   }
965
966   delete htofNoise;
967   htofNoise = 0x0;
968
969   if (fStatus){
970     delete fStatus;
971     fStatus = 0;
972   }
973
974   if (fMatchingWindow){
975           delete [] fMatchingWindow;
976           fMatchingWindow = 0;
977   }
978
979   return 0;
980 }
981 //_____________________________________________________________________________
982
983 UInt_t AliTOFPreprocessor::ProcessFEEData()
984 {
985   // Processing Pulser Run data for TOF channel status
986   // dummy for the time being
987
988   Log("Processing FEE");
989
990   Bool_t updateOCDB = kFALSE;
991   AliTOFFEEReader feeReader;
992
993   TH1C hCurrentFEE("hCurrentFEE","histo with current FEE channel status", fNChannels, 0, fNChannels);
994   
995   /* load current TOF FEE config from DCS FXS, parse, 
996    * fill current FEE histogram and set FEE status */
997   
998   const char * nameFile = GetFile(kDCS,"TofFeeMap",""); 
999   AliInfo(Form("nameFile = %s",nameFile));
1000   if (nameFile == NULL) {
1001           return 15;
1002   } 
1003   feeReader.LoadFEEConfig(nameFile);
1004   Int_t parseFee = feeReader.ParseFEEConfig();
1005   AliDebug(2,Form("%i enabled channels found in FEE configuration",parseFee));
1006   /* load stored TOF FEE from OCDB and compare it with current FEE.
1007    * if stored FEE is different from current FEE set update flag.
1008    * if there is no stored FEE in OCDB set update flag */
1009   
1010   fMatchingWindow = new Int_t[fNChannels];
1011
1012   AliCDBEntry *cdbEntry = GetFromOCDB("Calib","Status");
1013   if (!cdbEntry) {
1014           /* no CDB entry found. set update flag */
1015           Log("     ************ WARNING ************");
1016           Log("No CDB Status entry found, creating a new one!");
1017           Log("     *********************************");
1018           fStatus = new AliTOFChannelOnlineStatusArray(fNChannels);
1019           updateOCDB = kTRUE;
1020   }
1021   else {
1022           if (cdbEntry) cdbEntry->SetOwner(kFALSE);
1023           /* CDB entry OK. loop over channels */
1024           fStatus = (AliTOFChannelOnlineStatusArray*) cdbEntry->GetObject();
1025           delete cdbEntry;
1026           cdbEntry = 0x0;
1027   }
1028   for (Int_t iChannel = 0; iChannel < fNChannels; iChannel++){
1029           //AliDebug(2,Form("********** channel %i",iChannel));
1030           /* compare current FEE channel status with stored one 
1031            * if different set update flag and break loop */
1032           //AliDebug(2,Form( " channel %i status before FEE = %i",iChannel,(Int_t)fStatus->GetHWStatus(iChannel)));
1033           fMatchingWindow[iChannel] = feeReader.GetMatchingWindow(iChannel);
1034           if (feeReader.IsChannelEnabled(iChannel)) {
1035                   hCurrentFEE.SetBinContent(iChannel + 1, 1);
1036                   if (fStatus->GetHWStatus(iChannel)!=AliTOFChannelOnlineStatusArray::kTOFHWOk){
1037                           updateOCDB = kTRUE;
1038                           fStatus->SetHWStatus(iChannel,AliTOFChannelOnlineStatusArray::kTOFHWOk);
1039                           AliDebug(3,Form( " changed into enabled: channel %i status after FEE = %i",iChannel,(Int_t)fStatus->GetHWStatus(iChannel)));
1040                   }
1041           }
1042           else {
1043                   if (fStatus->GetHWStatus(iChannel)!=AliTOFChannelOnlineStatusArray::kTOFHWBad){
1044                           updateOCDB = kTRUE;
1045                           fStatus->SetHWStatus(iChannel,AliTOFChannelOnlineStatusArray::kTOFHWBad);
1046                           AliDebug(3,Form( " changed into disabled: channel %i status after FEE = %i",iChannel,(Int_t)fStatus->GetHWStatus(iChannel)));
1047                   }
1048           }
1049   }
1050
1051
1052   /* check whether we don't have to store reference data.
1053    * in this case we return without errors. */
1054   if (fStoreRefData) {
1055           /* store reference data */
1056           AliCDBMetaData metaDataHisto;
1057           metaDataHisto.SetBeamPeriod(0);
1058           metaDataHisto.SetResponsible("Roberto Preghenella");
1059           metaDataHisto.SetComment("This preprocessor stores the FEE Ref data of the current run.");
1060           AliInfo("Storing FEE reference data");
1061           /* store FEE reference data */
1062           if (!StoreReferenceData("Calib", "FEEData", &hCurrentFEE, &metaDataHisto)) {
1063                   /* failed */
1064                   Log("problems while storing FEE reference data");
1065                   if (fStatus){
1066                           delete fStatus;
1067                           fStatus = 0;
1068                   }
1069                   return 18; /* error return code for problems while storing FEE reference data */
1070           }
1071   }
1072
1073   /* check whether we don't need to update OCDB.
1074    * in this case we can return without errors and
1075    * the current FEE is stored in the fStatus object. */
1076   if (!updateOCDB) {
1077     AliInfo("TOF FEE config has not changed. Do not overwrite stored file.");
1078     return 0; /* return ok */
1079   }
1080
1081   TString runType = GetRunType();
1082   if (runType != "PHYSICS") {
1083           AliInfo(Form("Run Type = %s, waiting to store status map",GetRunType()));
1084     return 0; /* return ok */
1085   }
1086
1087   /* update the OCDB with the current FEE since even 
1088    * a little difference has been detected. */
1089
1090   AliCDBMetaData metaData;
1091   metaData.SetBeamPeriod(0);
1092   metaData.SetResponsible("Roberto Preghenella");
1093   metaData.SetComment("This preprocessor fills an AliTOFChannelOnlineStatusArray object from FEE data.");
1094   AliInfo("Storing Status data from current run after FEE parsing");
1095   /* store FEE data */
1096   if (!Store("Calib", "Status", fStatus, &metaData, 0, kTRUE)) {
1097     /* failed */
1098     Log("problems while storing FEE data object");
1099     if (fStatus){
1100             delete fStatus;
1101             fStatus = 0;
1102     }
1103     return 17; /* return error code for problems  while storing FEE data */
1104   }
1105
1106   /* everything fine. return */
1107
1108   if (fStatus){
1109     delete fStatus;
1110     fStatus = 0;
1111   }
1112
1113   return 0;
1114
1115 }
1116
1117 //_____________________________________________________________________________
1118
1119 UInt_t AliTOFPreprocessor::Process(TMap* dcsAliasMap)
1120 {
1121   //
1122   //
1123   //
1124
1125   TString runType = GetRunType();
1126   Log(Form("RunType %s",runType.Data()));
1127   
1128   // processing 
1129
1130   /* always process FEE data */
1131   Int_t iresultFEE = ProcessFEEData();
1132   if (iresultFEE != 0)
1133     return iresultFEE;
1134
1135   if (runType == "PULSER") {
1136     Int_t iresultPulser = ProcessPulserData();
1137     return iresultPulser; 
1138   }
1139
1140   if (runType == "NOISE") { // for the time being associating noise runs with pedestal runs; proper run type to be defined 
1141     Int_t iresultNoise = ProcessNoiseData();
1142     return iresultNoise; 
1143   }
1144   
1145   if (runType == "PHYSICS") {
1146     Int_t iresultDAQ = ProcessOnlineDelays();
1147     if (iresultDAQ != 0) {
1148       return iresultDAQ;
1149     }
1150     else {
1151       Int_t iresultDCS = ProcessDCSDataPoints(dcsAliasMap);
1152       return iresultDCS;
1153     }
1154   }
1155
1156   // storing
1157   return 0;
1158 }
1159
1160