X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=TRD%2FTRDPEDESTALda.cxx;h=667c968839c5c8d9cfeb4a33a6c2d1997b195757;hb=54beba6b13a9e829f476583afc1927277a33d4f7;hp=b18d6b624767a5fa83df09ec24083542bd6e25a6;hpb=289cc63762b21bbf75987ea9f506511e2e428730;p=u%2Fmrichter%2FAliRoot.git diff --git a/TRD/TRDPEDESTALda.cxx b/TRD/TRDPEDESTALda.cxx index b18d6b62476..667c968839c 100644 --- a/TRD/TRDPEDESTALda.cxx +++ b/TRD/TRDPEDESTALda.cxx @@ -1,23 +1,19 @@ /* -TRDPEDESTALda.cxx - calibration algorithm for the pedestal to be run in parallel on the LDCs -DAcase1.c - - -AliTRDCalibPadStatus - pad status calibration - -This program reads the DAQ data files passed as argument using the monitoring library. - -It fills a TRD calib object AliTRDCalibPadStatus and write it in a local file trdPedestal.root before -exporting it to the file exchange server. - -Messages on stdout are exported to DAQ log system. - -contact: alice-datesupport@cern.ch +Contact: r.bailhache@gsi.de +Link: +Reference run: 12170 +Run Type: PEDESTAL +DA Type: LDC +Number of events needed: 100 +Input Files: TRD raw files +Output Files: trdCalibration.root +Trigger types used: PHYSICS_EVENT */ -#define RESULT_FILE "trdCalibration.root" +#define RESULT_FILE "trdPedestal.root" +#define FILE_ID "PADSTATUS" extern "C" { #include @@ -33,25 +29,43 @@ extern "C" { // #include #include - +#include "TROOT.h" +#include "TPluginManager.h" +#include "TSystem.h" // // AliRoot includes // #include "AliRawReader.h" #include "AliRawReaderDate.h" -#include "AliTRDRawStreamV2.h" +#include "AliTRDgeometry.h" #include "AliCDBManager.h" +#include "AliLog.h" + +// +//AMORE +// +#include + // // AliRoot TRD calib classes // #include "AliTRDCalibPadStatus.h" +//functios, implementation below +void SendToAmoreDB(TObject *o, unsigned long32 runNb); /* Main routine Arguments: list of DATE raw data files */ int main(int argc, char **argv) { + /* magic line from Rene */ + gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo", + "*", + "TStreamerInfo", + "RIO", + "TStreamerInfo()"); + int status; @@ -80,18 +94,17 @@ int main(int argc, char **argv) { int nevents =0; //Instance of AliCDBManager: needed by AliTRDRawStream - AliCDBManager *man = AliCDBManager::Instance(); - man->SetDefaultStorage("local://$ALICE_ROOT"); - man->SetRun(0); + //AliCDBManager *man = AliCDBManager::Instance(); + //man->SetDefaultStorage("local://$ALICE_ROOT/OCDB"); + //man->SetRun(0); // AliTRDCalibPadStatus object AliTRDCalibPadStatus calipad = AliTRDCalibPadStatus(); Bool_t passpadstatus = kTRUE; + unsigned long32 runNb=0; //run number - - /*see the time*/ - TStopwatch timer; - timer.Start(); - + // setting + //AliTRDrawFastStream::DisableSkipData(); + AliLog::SetGlobalLogLevel(AliLog::kFatal); /* read the data files */ int n; @@ -108,6 +121,7 @@ int main(int argc, char **argv) { /* read the file until EOF */ for(;;) { struct eventHeaderStruct *event; + eventTypeType eventT; /* get next event */ status=monitorGetEventDynamic((void **)&event); @@ -125,19 +139,29 @@ int main(int argc, char **argv) { break; } - if(passpadstatus){ + /* use event - here, just write event id to result file */ + eventT=event->eventType; + + if((eventT==PHYSICS_EVENT) && (passpadstatus)){ AliRawReader *rawReader = new AliRawReaderDate((void*)event); - AliTRDRawStreamV2 *trdRawStream = new AliTRDRawStreamV2((AliRawReader *)rawReader); - if(!calipad.ProcessEvent(trdRawStream,(Bool_t)nevents_total)) passpadstatus = kFALSE; - nevents++; - delete trdRawStream; + rawReader->Select("TRD"); + // for debug + //rawReader->SelectEquipment(-1,1024,1025); + + Int_t result = calipad.ProcessEvent((AliRawReader *) rawReader); + // 0 error, 1 no input, 2 output + if(result == 2) nevents++; + if(result == 0) passpadstatus = kFALSE; delete rawReader; - + } nevents_total++; + // get the run number + runNb = event->eventRunNb; + /* free resources */ free(event); } @@ -147,34 +171,92 @@ int main(int argc, char **argv) { /* report progress */ printf("%d events processed and %d used\n",nevents_total,nevents); - /*see the time*/ - timer.Stop(); - timer.Print(); - /* write file in any case to see what happens in case of problems*/ - /*see the time*/ - TStopwatch timer1; - timer1.Start(); TFile *fileTRD = new TFile(RESULT_FILE,"recreate"); + if(nevents < 30) calipad.Destroy(); calipad.AnalyseHisto(); calipad.Write("calibpadstatus"); fileTRD->Close(); - printf("Wrote local file %s\n",RESULT_FILE); - /*see the time*/ - timer1.Stop(); - timer1.Print(); - + + /* Send to amore */ + SendToAmoreDB(&calipad,runNb); + + /* store the result file on FES */ - status=daqDA_FES_storeFile(RESULT_FILE,RESULT_FILE); + status=daqDA_FES_storeFile(RESULT_FILE,FILE_ID); if (status) { printf("Failed to export file : %d\n",status); return -1; } - - - /* report progress */ - daqDA_progressReport(100); return status; + +} +void SendToAmoreDB(TObject *calipad, unsigned long32 runNb) +{ + //cheet a little -- temporary solution (hopefully) + // + //currently amoreDA uses the environment variable AMORE_DA_NAME to create the mysql + //table in which the calib objects are stored. This table is dropped each time AmoreDA + //is initialised. This of course makes a problem if we would like to store different + //calibration entries in the AMORE DB. Therefore in each DA which writes to the AMORE DB + //the AMORE_DA_NAME env variable is overwritten. + + + // + // The reference data are stored in: + // PadStatus1 for sm-00-01-02 + // PadStatus2 for sm-03-04-05 + // PadStatus3 for sm-06-07-08 + // PadStatus4 for sm-09-10-11 + // PadStatus5 for sm-12-13-14 + // PadStatus6 for sm-15-16-17 + // PadStatus0 if nothing found..means problems + // + + /////////////////// + // Find wich LDC + /////////////////// + Int_t ldcnumber = -1; + Int_t sm = -1; + for (Int_t idet=0; idet<540; idet++) { + AliTRDCalROC *rocMean = ((AliTRDCalibPadStatus *) calipad)->GetCalRocMean(idet, kFALSE); + if ( rocMean ) { + sm = AliTRDgeometry::GetSector(idet); + if((sm==0) || (sm==1) || (sm==2)) ldcnumber = 1; + if((sm==3) || (sm==4) || (sm==5)) ldcnumber = 2; + if((sm==6) || (sm==7) || (sm==8)) ldcnumber = 3; + if((sm==9) || (sm==10) || (sm==11)) ldcnumber = 4; + if((sm==12) || (sm==13) || (sm==14)) ldcnumber = 5; + if((sm==15) || (sm==16) || (sm==17)) ldcnumber = 6; + } + } + const char *amoreDANameorig=gSystem->Getenv("AMORE_DA_NAME"); + + gSystem->Setenv("AMORE_DA_NAME",Form("TRD-dataQA-%02d-%s",ldcnumber,FILE_ID)); + + ///////////////////// + // Send the stuff + //////////////////// + if (ldcnumber>-1){ + TDatime time; + TObjString info(Form("Run: %u; Date: %s",runNb,time.AsSQLString())); + + amore::da::AmoreDA amoreDA(amore::da::AmoreDA::kSender); + Int_t statusDA=0; + statusDA+=amoreDA.Send("Pedestals",calipad); + statusDA+=amoreDA.Send("Info",&info); + if ( statusDA ) + printf("Warning: Failed to write one of the calib objects to the AMORE database\n"); + } else { + printf("Warning: No data found!\n"); + } + + // reset env var + if (amoreDANameorig) gSystem->Setenv("AMORE_DA_NAME",amoreDANameorig); + } + + +