]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TRD/TRDHALFCHAMBERSTATUSda.cxx
added slewing correction by data
[u/mrichter/AliRoot.git] / TRD / TRDHALFCHAMBERSTATUSda.cxx
index cada1575a9fc41f1a1b0f0aa60417cf17c8e0592..9364139aa8f31797227546cd11a47b8347eb5bac 100644 (file)
@@ -31,13 +31,14 @@ extern "C" {
 #include <TStopwatch.h>
 #include "TROOT.h"
 #include "TPluginManager.h"
+#include "TSystem.h"
 //
 // AliRoot includes
 //
 #include "AliRawReader.h"
 #include "AliRawReaderDate.h"
-#include "AliTRDrawFastStream.h"
-#include "AliTRDrawStreamBase.h"
+//#include "AliTRDrawFastStream.h"
+//#include "AliTRDrawStreamBase.h"
 #include "AliLog.h"
 //#include "AliCDBManager.h"
 
@@ -52,7 +53,7 @@ extern "C" {
 #include "AliTRDCalibChamberStatus.h"
 
 //functios, implementation below
-//void SendToAmoreDB(TObject *o, unsigned long32 runNb);
+void SendToAmoreDB(TObject *o, unsigned long32 runNb);
 
 /* Main routine
       Arguments: list of DATE raw data files
@@ -109,10 +110,11 @@ int main(int argc, char **argv) {
   // AliTRDCalibPadStatus object
   AliTRDCalibChamberStatus calipad = AliTRDCalibChamberStatus();
   calipad.Init();
-  //unsigned long32 runNb=0;      //run number
+    
+  unsigned long32 runNb=0;      //run number
 
   // setting
-  AliTRDrawFastStream::DisableSkipData();
+  //AliTRDrawFastStream::DisableSkipData();
   AliLog::SetGlobalLogLevel(AliLog::kFatal); 
 
   /* read the file  until EOF */
@@ -156,7 +158,7 @@ int main(int argc, char **argv) {
     nevents_total++;
     
     // get the run number
-    //runNb = event->eventRunNb;
+    runNb = event->eventRunNb;
     
     /* free resources */
     free(event);
@@ -168,15 +170,20 @@ int main(int argc, char **argv) {
     }
   }
   
-
+  Int_t neventused = calipad.GetNumberEventNotEmpty();
+  
   /* report progress */
-  printf("%d events processed and %d used\n",nevents_total,nevents);
+  printf("%d events processed and %d used\n",nevents_total,neventused);
   
   /* write file in any case to see what happens in case of problems*/
   TFile *fileTRD = new TFile(RESULT_FILE,"recreate");
   calipad.AnalyseHisto();
   calipad.Write("calibchamberstatus");
   fileTRD->Close();   
+  
+
+  /* Send to amore */
+  SendToAmoreDB(&calipad,runNb);
      
   /* store the result file on FES */
   status=daqDA_FES_storeFile(RESULT_FILE,FILE_ID);
@@ -184,8 +191,36 @@ int main(int argc, char **argv) {
     printf("Failed to export file : %d\n",status);
     return -1;
   }
-
   
   return status;
 
-}
\ No newline at end of file
+}
+void SendToAmoreDB(TObject *o, unsigned long32 runNb)
+{
+  //AMORE
+  const char *amoreDANameorig=gSystem->Getenv("AMORE_DA_NAME");
+  //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.
+  
+  gSystem->Setenv("AMORE_DA_NAME","TRD-dataHALFCHAMBERSTATUS");
+  //
+  // end cheet
+  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("DataHalfChamberStatus",o);
+  statusDA+=amoreDA.Send("Info",&info);
+  if ( statusDA!=0 )
+    printf("TRDQAda: Waring: Failed to write one of the calib objects to the AMORE database\n");
+  // reset env var
+  if (amoreDANameorig) gSystem->Setenv("AMORE_DA_NAME",amoreDANameorig);
+}
+
+