]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TPC/TPCPEDESTALda.cxx
Adding simple example to load default debug streamer
[u/mrichter/AliRoot.git] / TPC / TPCPEDESTALda.cxx
index 3b62e74e4ee3a97225ac87e07f3314ec9d305407..3895f87570a7f3ed1cb820d3aad71db06bd17860 100644 (file)
@@ -1,3 +1,18 @@
+/*
+TPC DA for online calibration
+
+Contact: Haavard.Helstrup@cern.ch
+Link:
+Run Type: PEDESTAL
+DA Type: LDC
+Number of events needed: 100
+Input Files: 
+Output Files: tpcPedestal.root, to be exported to the DAQ FXS
+fileId:   pedestals    
+Trigger types used: CALIBRATION_EVENT
+
+*/
+
 /*
 
 TPCda_pedestal.cxx - calibration algorithm for TPC pedestal runs
@@ -17,8 +32,9 @@ and save results in a file (named from RESULT_FILE define - see below).
 */
 
 #define RESULT_FILE  "tpcPedestal.root"
+#define FILE_ID "pedestals"
 #define MAPPING_FILE "tpcMapping.root"
-
+#define AliDebugLevel() -1
 
 extern "C" {
 #include <daqDA.h>
@@ -50,6 +66,8 @@ extern "C" {
 #include "AliTPCCalPad.h"
 #include "AliMathBase.h"
 #include "TTreeStream.h"
+#include "AliLog.h"
+#include "TSystem.h"
 
 //
 // TPC calibration algorithm includes
@@ -66,6 +84,11 @@ int main(int argc, char **argv) {
   // Main for TPC pedestal detector algorithm
   //
 
+  AliLog::SetClassDebugLevel("AliTPCRawStream",-5);
+  AliLog::SetClassDebugLevel("AliRawReaderDate",-5);
+  AliLog::SetClassDebugLevel("AliTPCAltroMapping",-5);
+  AliLog::SetModuleDebugLevel("RAW",-5);
+
   Bool_t timeAnalysis = kTRUE;
 
   if (argc<2) {
@@ -91,30 +114,36 @@ int main(int argc, char **argv) {
     return -1;
   }
 
-  /* copy locally the mapping file from daq detector config db */
-  status = daqDA_DB_getFile(MAPPING_FILE,"./tpcMapping.root");
-  if (status) {
-    printf("Failed to get mapping file (%s) from DAQdetDB, status=%d\n", MAPPING_FILE, status);
-    printf("Continue anyway ... maybe it works?\n");              // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-    //return -1;   // temporarily uncommented for testing on pcald47 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+  AliTPCmapper *mapping = 0;   // The TPC mapping
+   
+  if (!mapping){
+    /* copy locally the mapping file from daq detector config db */
+    status = daqDA_DB_getFile(MAPPING_FILE,"./tpcMapping.root");
+    if (status) {
+      printf("Failed to get mapping file (%s) from DAQdetDB, status=%d\n", MAPPING_FILE, status);
+      printf("Continue anyway ... maybe it works?\n");              // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+      return -1;   // temporarily uncommented for testing on pcald47 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+    }
+
+    /* open the mapping file and retrieve mapping object */
+    TFile *fileMapping = new TFile(MAPPING_FILE, "read");
+    mapping = (AliTPCmapper*) fileMapping->Get("tpcMapping");
+    delete fileMapping;
   }
 
-  /* open the mapping file and retrieve mapping object */
-  AliTPCmapper *mapping = 0;   // The TPC mapping
-  TFile *fileMapping = new TFile(MAPPING_FILE, "read");
-  mapping = (AliTPCmapper*) fileMapping->Get("tpcMapping");
   if (mapping == 0) {
-    printf("Failed to get mapping object from %s. Exiting ...\n", MAPPING_FILE);
-    delete fileMapping;
-    return -1;
+    printf("Failed to get mapping object from %s.  ...\n", MAPPING_FILE);
+    //return -1;
   } else {
     printf("Got mapping object from %s\n", MAPPING_FILE);
   }
 
   AliTPCCalibPedestal calibPedestal;                         // pedestal and noise calibration
+  calibPedestal.SetRangeTime(60,940);                        // set time bin range
   calibPedestal.SetTimeAnalysis(timeAnalysis);               // pedestal(t) calibration
-  calibPedestal.SetAltroMapping(mapping->GetAltroMapping()); // Use altro mapping we got from daqDetDb
-
+  if (mapping){
+    calibPedestal.SetAltroMapping(mapping->GetAltroMapping()); // Use altro mapping we got from daqDetDb
+  }
   /* loop over RAW data files */
   int nevents=0;
   for ( i=1; i<argc; i++ ) {
@@ -124,7 +153,6 @@ int main(int argc, char **argv) {
     status=monitorSetDataSource( argv[i] );
     if (status!=0) {
       printf("monitorSetDataSource() failed. Error=%s. Exiting ...\n", monitorDecodeError(status));
-      delete fileMapping;
       return -1;
     }
 
@@ -158,8 +186,8 @@ int main(int argc, char **argv) {
 
       //  Pedestal calibration
       AliRawReader *rawReader = new AliRawReaderDate((void*)event);
-      //calibPedestal.ProcessEvent(rawReader);
-      calibPedestal.ProcessEventFast(rawReader);   // fast data reader
+      calibPedestal.ProcessEvent(rawReader);
+      //calibPedestal.ProcessEventFast(rawReader);   // fast data reader
       delete rawReader;
 
       /* free resources */
@@ -176,10 +204,18 @@ int main(int argc, char **argv) {
   printf ("%d physics/calibration events processed.\n",nevents);
 
   TFile *fileTPC = new TFile(RESULT_FILE, "recreate");
-  calibPedestal.Write("calibPedestal");
+  calibPedestal.Write("tpcCalibPedestal");
   delete fileTPC;
   printf("Wrote %s.\n",RESULT_FILE);
 
+ /* store the result file on FES */
+   status=daqDA_FES_storeFile(RESULT_FILE,FILE_ID);
+   if (status) {
+     status = -2;
+   }
+
+
   //
   // Now prepare ASCII files for local ALTRO configuration through DDL.
   //
@@ -261,7 +297,6 @@ int main(int argc, char **argv) {
   pedmemfile.close();
   printf("Wrote ASCII files.\n");
 
-  delete fileMapping;
 
   return status;
 }