* provided "as is" without express or implied warranty. *
**************************************************************************/
-/*
-$Log$
-Revision 1.4 2006/12/19 08:53:27 arcelli
-Changed filenames types to TString + split file sources (C.Zampolli)
+/* $Id$ */
-Revision 1.3 2006/12/18 18:16:53 arcelli
-Change in the format of the input data from DAQ FXS (C.Zampolli)
-
-Revision 1.1 2006/10/26 09:09:29 arcelli
-prototype for the TOF Shuttle preprocessor (C.Zampolli)
+#include <Riostream.h>
+#include <stdio.h>
+#include <stdlib.h>
-*/
-
-#include "AliTOFPreprocessor.h"
+#include <TFile.h>
+#include <TH1.h>
+#include <TH1F.h>
+#include <TH1S.h>
+#include <TH2S.h>
+#include <TMath.h>
+#include <TObjArray.h>
+#include <TObjString.h>
+#include <TTimeStamp.h>
#include "AliCDBMetaData.h"
#include "AliLog.h"
-#include "AliTOFDataDCS.h"
-#include "TFile.h"
-#include "TObjArray.h"
-#include "TObjString.h"
-#include "AliTOFCalOnline.h"
#include "AliTOFChannelOnline.h"
-#include "AliTOFGeometryV5.h"
-#include "TTimeStamp.h"
-#include "TH1F.h"
-#include "TH2S.h"
-#include "TH1S.h"
-#include "TH1.h"
-#include <Riostream.h>
-#include <stdio.h>
-#include <stdlib.h>
+#include "AliTOFDataDCS.h"
+#include "AliTOFGeometry.h"
+#include "AliTOFPreprocessor.h"
class TF1;
class AliDCSValue;
fData(0),
fh2(0),
fCal(0),
- fTOFGeometry(0)
+ fNChannels(0),
+ fStoreRefData(kTRUE)
{
// constructor
+
}
//_____________________________________________________________________________
fData = 0;
delete fh2;
fh2 = 0;
+ fCal->Clear();
delete fCal;
fCal = 0;
- delete fTOFGeometry;
- fTOFGeometry = 0;
}
//______________________________________________________________________________
fData = new AliTOFDataDCS(fRun, fStartTime, fEndTime);
fh2 = 0x0;
- fTOFGeometry = new AliTOFGeometryV5();
- fCal = new AliTOFCalOnline(fTOFGeometry);
- fCal->CreateArray();
+ fNChannels = AliTOFGeometry::NSectors()*(2*(AliTOFGeometry::NStripC()+AliTOFGeometry::NStripB())+AliTOFGeometry::NStripA())*AliTOFGeometry::NpadZ()*AliTOFGeometry::NpadX();
+ fCal = new TObjArray(fNChannels);
+ fCal->SetOwner();
+ for (Int_t ich = 0; ich<fNChannels; ich ++){
+ AliTOFChannelOnline * calChOnline = new AliTOFChannelOnline();
+ fCal->AddAt(calChOnline,ich);
+ }
}
//_____________________________________________________________________________
UInt_t AliTOFPreprocessor::Process(TMap* dcsAliasMap)
{
// Fills data into a AliTOFDataDCS object
+ // return codes:
+ // return=0 : all ok
+ // return=1 : no DCS input data Map
+ // return=2 : no DCS input data processing
+ // return=3 : no DCS processed data was stored in Ref Data
+ // return=4 : no DAQ input for Ref Data
+ // return=5 : failed to store Ref Data
+ // return=6 : failed to retrieve DAQ data for calibration
+ // return=7 : problems in histos in the input DAQ file
+ // return=8 : failed to store Online Delays
TH1::AddDirectory(0);
- UInt_t resultDCS=0;
- UInt_t resultDAQ=0;
- UInt_t resultDAQRef=0;
- UInt_t result=0;
+
+ Bool_t resultDCSMap=kFALSE;
+ Bool_t resultDCSStore=kFALSE;
+ Bool_t resultDAQ=kFALSE;
+ Bool_t resultDAQRef=kFALSE;
// processing DCS
if (!dcsAliasMap){
- Log("No DCS map found");
+ Log("No DCS map found: TOF exiting from Shuttle");
+ return 1;// return error Code for DCS input data not found
}
else {
// The processing of the DCS input data is forwarded to AliTOFDataDCS
- fData->ProcessData(*dcsAliasMap);
- AliCDBMetaData metaDataDCS;
- metaDataDCS.SetBeamPeriod(0);
- metaDataDCS.SetResponsible("Chiara Zampolli");
- metaDataDCS.SetComment("This preprocessor fills an AliTOFDataDCS object."); resultDCS = Store("Calib","DCSData",fData, &metaDataDCS);
- // result+=resultDCS;
- if (!resultDCS){
- Log("Some problems occurred while storing DCS data processing results");
- return 0;
+ resultDCSMap=fData->ProcessData(*dcsAliasMap);
+ if(!resultDCSMap){
+ Log("Some problems occurred while processing DCS data, TOF exiting from Shuttle");
+ return 2;// return error Code for processed DCS data not stored
+ }
+ else{
+ AliCDBMetaData metaDataDCS;
+ metaDataDCS.SetBeamPeriod(0);
+ metaDataDCS.SetResponsible("Chiara Zampolli");
+ metaDataDCS.SetComment("This preprocessor fills an AliTOFDataDCS object.");
+ AliInfo("Storing DCS Data");
+ resultDCSStore = StoreReferenceData("Calib","DCSData",fData, &metaDataDCS);
+ if (!resultDCSStore){
+ Log("Some problems occurred while storing DCS data results in Reference Data, TOF exiting from Shuttle");
+ return 3;// return error Code for processed DCS data not stored
+ // in reference data
+
+ }
}
}
-
+
// processing DAQ
-
+
TFile * daqFile=0x0;
-
- //retrieving data at Run level
- TList* list = GetFileSources(kDAQ, "RUNLevel");
- if (list)
- {
- AliInfo("The following sources produced files with the id RUNLevel");
- list->Print();
- for (Int_t jj=0;jj<list->GetEntries();jj++){
- TObjString * str = dynamic_cast<TObjString*> (list->At(jj));
- AliInfo(Form("found source %s", str->String().Data()));
- // file to be stored run per run
- TString fileNameRun = GetFile(kDAQ, "RUNLevel", str->GetName());
- if (fileNameRun.Length()>0){
- AliInfo(Form("Got the file %s, now we can store the Reference Data for the current Run.", fileNameRun.Data()));
- daqFile = new TFile(fileNameRun.Data(),"READ");
- fh2 = (TH2S*) daqFile->Get("htof");
- AliCDBMetaData metaDataHisto;
- metaDataHisto.SetBeamPeriod(0);
- metaDataHisto.SetResponsible("Chiara Zampolli");
- metaDataHisto.SetComment("This preprocessor stores the array of histos object as Reference Data.");
- resultDAQRef = StoreReferenceData("Calib","DAQData",fh2, &metaDataHisto);
- // result+=resultDAQRef*2;
- if (!resultDAQRef){
- Log("some problems occurred::No Reference Data stored, still going on (please check!)");
+
+ if(fStoreRefData){
+ //retrieving data at Run level
+ TList* list = GetFileSources(kDAQ, "RUNLevel");
+ if (list)
+ {
+ AliInfo("The following sources produced files with the id RUNLevel");
+ list->Print();
+ for (Int_t jj=0;jj<list->GetEntries();jj++){
+ TObjString * str = dynamic_cast<TObjString*> (list->At(jj));
+ AliInfo(Form("found source %s", str->String().Data()));
+ // file to be stored run per run
+ TString fileNameRun = GetFile(kDAQ, "RUNLevel", str->GetName());
+ if (fileNameRun.Length()>0){
+ AliInfo(Form("Got the file %s, now we can store the Reference Data for the current Run.", fileNameRun.Data()));
+ daqFile = new TFile(fileNameRun.Data(),"READ");
+ fh2 = (TH2S*) daqFile->Get("htof");
+ AliCDBMetaData metaDataHisto;
+ metaDataHisto.SetBeamPeriod(0);
+ metaDataHisto.SetResponsible("Chiara Zampolli");
+ metaDataHisto.SetComment("This preprocessor stores the array of histos object as Reference Data.");
+ AliInfo("Storing Reference Data");
+ resultDAQRef = StoreReferenceData("Calib","DAQData",fh2, &metaDataHisto);
+ if (!resultDAQRef){
+ Log("some problems occurred::No Reference Data stored, TOF exiting from Shuttle");
+ return 5;//return error code for failure in storing Ref Data
+ }
+ daqFile->Close();
+ delete daqFile;
+ }
+
+ else{
+ Log("The input data file from DAQ (run-level) was not found, TOF exiting from Shuttle ");
+ return 4;//return error code for failure in retrieving Ref Data
}
- daqFile->Close();
- delete daqFile;
}
-
- else{
- Log("The input data file from DAQ (run-level) was not found, still going on with Cumulative data file (please check!) ");
- }
}
- }
- else{
- Log("The input data file list from DAQ (run-level) was not found, still going on with Cumulative data file (please check!) ");
+ else{
+ Log("The input data file list from DAQ (run-level) was not found, TOF exiting from Shuttle ");
+ return 4;//return error code for failure in retrieving Ref Data
+ }
}
- //Total files, with summed histos
+//Total files, with cumulative histos
+
TList* listTot = GetFileSources(kDAQ, "DELAYS");
if (listTot)
{
if (!fh2){
Log("some problems occurred:: No histo retrieved, TOF exiting from Shuttle");
delete daqFile;
- return 0;
+ return 7; //return error code for histograms not existing/junky
}
else {
- static const Int_t size=fh2->GetNbinsX();
- static const Int_t nbins=fh2->GetNbinsY();
- static const Double_t xbinmin=fh2->GetYaxis()->GetBinLowEdge(1);
- Int_t npads = fCal->NPads();
- if (size != npads){
+ static const Int_t kSize=fh2->GetNbinsX();
+ static const Int_t kNBins=fh2->GetNbinsY();
+ static const Double_t kXBinmin=fh2->GetYaxis()->GetBinLowEdge(1);
+ if (kSize != fNChannels){
Log(" number of bins along x different from number of pads, found only a subset of the histograms, TOF exiting from Shuttle");
delete daqFile;
- return 0;
+ return 7; //return error code for histograms not existing/junky
}
- for (Int_t ich=0;ich<size;ich++){
- TH1S *h1 = new TH1S("h1","h1",nbins,xbinmin-0.5,nbins*1.+xbinmin-0.5);
- for (Int_t ibin=0;ibin<nbins;ibin++){
+ for (Int_t ich=0;ich<kSize;ich++){
+ TH1S *h1 = new TH1S("h1","h1",kNBins,kXBinmin-0.5,kNBins*1.+kXBinmin-0.5);
+ for (Int_t ibin=0;ibin<kNBins;ibin++){
h1->SetBinContent(ibin+1,fh2->GetBinContent(ich+1,ibin+1));
}
Bool_t found=kFALSE;
sumw2=sumw2/nent; //<x^2>
Double_t rmsmean= 0;
rmsmean = TMath::Sqrt((sumw2-mean*mean)/nent);
- if (ich<npads) {
- AliTOFChannelOnline * ch = fCal->GetChannel(ich);
- ch->SetDelay(mean);
+ if (ich<fNChannels) {
+ AliTOFChannelOnline * ch = (AliTOFChannelOnline *)fCal->At(ich);
+ ch->SetDelay((Double_t)mean*AliTOFGeometry::TdcBinWidth()*1.E-3); // delay in ns
}
delete h1;
h1=0x0;
metaData.SetBeamPeriod(0);
metaData.SetResponsible("Chiara Zampolli");
metaData.SetComment("This preprocessor fills an AliTOFCal object.");
- resultDAQ = Store("Calib","OnlineDelay",fCal, &metaData);
+ AliInfo("Storing Calibration Data");
+ resultDAQ = Store("Calib","ParOnline",fCal, &metaData);
if(!resultDAQ){
Log("Some problems occurred while storing DAQ data processing results");
- return 0;
+ return 8;//return error code for problems in storing DAQ data
}
}
else{
Log("The Cumulative data file from DAQ does not exist, TOF exiting from Shuttle");
- return 0;
+ return 6;//return error code for problems in retrieving DAQ data
}
}
}
else{
Log("Problem: no list for Cumulative data file from DAQ was found, TOF exiting from Shuttle");
- return 0;
+ return 6; //return error code for problems in retrieving DAQ data
}
- // delete list;
- // list = 0;
- // delete listTot;
- // listTot = 0;
daqFile=0;
- if(resultDCS ==2|| resultDAQ ==2) {
- result=2;
- }
- else{
- result=1;
- }
-
- return result;
+ return 0;
}