]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/MUONTRKPEDda.cxx
Fixing documentation
[u/mrichter/AliRoot.git] / MUON / MUONTRKPEDda.cxx
index 9dafddfa0e1d835388f863143cf8282aca022fb2..f9ba224e1bded78b00f7643505a8e8d80a6363b6 100644 (file)
@@ -1,13 +1,13 @@
 /*
-Contact: Jean-Luc Charvet <jean-luc.charvet@cea.fr>
-Link: http://aliceinfo.cern.ch/static/Offline/dimuon/muon_html/README_Mchda
-Run Type: PEDESTAL
-       DA Type: LDC
-       Number of events needed: 400 events for pedestal run
-       Input Files: Rawdata file (DATE format)
-       Output Files: local dir (not persistent) -> MUONTRKPEDda_<run#>.ped 
-       FXS -> run<#>_MCH_<ldc>_PEDESTALS
-       Trigger types used:
+  Contact: Jean-Luc Charvet <jean-luc.charvet@cern.ch>
+  Link: http://aliceinfo.cern.ch/static/Offline/dimuon/muon_html/README_mchda.html
+  Reference Run:
+  Run Type: PEDESTAL
+  DA Type: LDC
+  Number of events needed: 400 events for pedestal run
+  Input Files: mutrkpedvalues and config_ldc-MTRK-S3-0 
+  Output Files: local dir (not persistent) -> MUONTRKPEDda.ped  FXS -> run<#>_MCH_<ldc>_PEDESTALS
+  Trigger types used:
 */
 
 /**************************************************************************
@@ -29,7 +29,7 @@ Run Type: PEDESTAL
 
 /*
        -------------------------------------------------------------------------
-        2009-06-18 New version: MUONTRKPEDda.cxx,v 1.2
+        2009-11-05 New version: MUONTRKPEDda.cxx,v 1.4
        -------------------------------------------------------------------------
 
        Version for MUONTRKPEDda MUON tracking
@@ -39,6 +39,7 @@ Run Type: PEDESTAL
  Rem:  AliMUON2DMap stores all channels, even those which are not connected
  if pedMean == -1, channel not connected to a pad  
 
+&
 
 */
 extern "C" {
@@ -94,34 +95,33 @@ extern "C" {
 
 
 // main routine
-int main(Int_t argc, Char_t **argv) 
+int main(Int_t argc, const char **argv) 
 {
-
   Int_t status=0;
   TStopwatch timers;
   timers.Start(kTRUE); 
 
+  const char* prefixDA = "MUONTRKPEDda"; // program prefix
+  printf(" ######## Begin execution : %s ######## \n\n",prefixDA); 
+
   // needed for streamer application
   gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo",
                                        "*",
                                        "TStreamerInfo",
                                        "RIO",
                                        "TStreamerInfo()"); 
-
   // needed for Minuit plugin
   gROOT->GetPluginManager()->AddHandler("ROOT::Math::Minimizer",
                                        "Minuit",
                                        "TMinuitMinimizer",
                                        "Minuit",
                                        "TMinuitMinimizer(const char*)");
-
-  Char_t prefixDA[256]="MUONTRKPEDda"; // program prefix
 //   cout << argv[0];
  
   Int_t skipEvents = 0;
   Int_t maxEvents  = 1000000;
   Int_t maxDateEvents  = 1000000;
-  Char_t inputFile[256]="";
+  TString inputFile;
 
   Int_t  nDateEvents = 0;
   Int_t nGlitchErrors= 0;
@@ -137,14 +137,13 @@ int main(Int_t argc, Char_t **argv)
   Int_t nEventsRecovered = 0;
   Int_t nEvents = 0;
   UInt_t runNumber   = 0;
-  Int_t  nChannel    = 0;
+  Int_t nConfig = 1; 
   ofstream filcout;
-//   Int_t nIndex = -1; 
 
   // decode the input line
   for (Int_t i = 1; i < argc; i++) // argument 0 is the executable name
     {
-      Char_t* arg;
+      const char* arg = argv[i];
 
       arg = argv[i];
       if (arg[0] != '-') 
@@ -152,7 +151,7 @@ int main(Int_t argc, Char_t **argv)
          // If only one argument and no "-" => DA calling from ECS
          if (argc == 2)
            {
-             sprintf(inputFile,argv[i]);
+        inputFile=argv[i];
            }
          continue;
        }
@@ -160,7 +159,8 @@ int main(Int_t argc, Char_t **argv)
        {
        case 'f' : 
          i++;
-         sprintf(inputFile,argv[i]);
+      inputFile=argv[i];
+         nConfig=0;
          break;
        case 'a' : 
          i++;
@@ -178,19 +178,16 @@ int main(Int_t argc, Char_t **argv)
          i++; 
          sscanf(argv[i],"%d",&maxEvents);
          break;
-//     case 'p' : 
-//       i++;
-//       sscanf(argv[i],"%d",&recoverParityErrors);
-//       break;
        case 'h' :
          i++;
          printf("\n******************* %s usage **********************",argv[0]);
          printf("\nOnline (called from ECS) : %s <raw data file> (no inline options)\n",argv[0]);
+         printf("\n%s can be used locally only with options (without DiMuon configuration file)",argv[0]);
          printf("\n%s -options, the available options are :",argv[0]);
          printf("\n-h help                    (this screen)");
          printf("\n");
          printf("\n Input");
-         printf("\n-f <raw data file>         (default = %s)",inputFile); 
+         printf("\n-f <raw data file>         (default = %s)",inputFile.Data()); 
          printf("\n");
          printf("\n Output");
          printf("\n-a <Flat ASCII file>       (default = %s)",shuttleFile.Data()); 
@@ -199,7 +196,6 @@ int main(Int_t argc, Char_t **argv)
          printf("\n-m <max date events>       (default = %d)",maxDateEvents);
          printf("\n-s <skip events>           (default = %d)",skipEvents);
          printf("\n-n <max events>            (default = %d)",maxEvents);
-//       printf("\n-p <Recover parity errors> (default = %d)",recoverParityErrors);
 
          printf("\n\n");
          exit(-1);
@@ -219,13 +215,41 @@ int main(Int_t argc, Char_t **argv)
   AliMUONPedestal* muonPedestal = new AliMUONPedestal();
   muonPedestal->SetprefixDA(prefixDA);
 
+  Char_t dbfile[256]="";
+  // nConfig=1 : Reading configuration (or not) status via "mutrkpedvalues" file located in DetDB
+  if(nConfig)
+    { 
+  sprintf(dbfile,"mutrkpedvalues");
+  status=daqDA_DB_getFile(dbfile,dbfile);
+  if(status) {printf(" Failed  : input file %s is missing, status = %d\n",dbfile,status); return -1; } 
+  ifstream filein(dbfile,ios::in);
+  filein >> nConfig;
+  printf(" *** Copy: %s from DetDB to working directory  ***      Config= %d\n",dbfile,nConfig);
+    }
+  else
+    {
+      printf(" ***  Config= %d: no configuration ascii file is used \n",nConfig);
+    }
+  muonPedestal->SetconfigDA(nConfig);
+
+  // nConfig=1: configuration ascii file read from DetDB
+  if(nConfig)
+    {
+  // MuonTrk Configuration ascii file (initCROCUS.dat -> ascii file = config_$DATE_ROLE_NAME)
+  sprintf(dbfile,"config_%s",getenv("DATE_ROLE_NAME"));
+  status=daqDA_DB_getFile(dbfile,dbfile);
+  if(status) {printf(" Failed  : Configuration file %s is missing, status = %d\n",dbfile,status); return -1; }
+  else printf(" *** Copy ascii config file: %s from DetDB to working directory and reading ...*** \n",dbfile);
+  muonPedestal->LoadConfig(dbfile);  
+    } 
+
   // Rawdeader, RawStreamHP
   AliRawReader* rawReader = AliRawReader::Create(inputFile);
   AliMUONRawStreamTrackerHP* rawStream  = new AliMUONRawStreamTrackerHP(rawReader);    
   rawStream->DisableWarnings();
   rawStream->EnabbleErrorLogger();
 
-  cout << "\n" << prefixDA << " : Reading data from file " << inputFile  << endl;
+  printf("\n %s : Reading data from file %s\n",prefixDA,inputFile.Data());
 
   while (rawReader->NextEvent())
     {
@@ -294,7 +318,6 @@ int main(Int_t argc, Char_t **argv)
            {
              for(int i = 0; i < busPatch->GetLength(); ++i)
                {
-                 if (nEvents == 0) nChannel++;
                  busPatch->GetData(i, manuId, channelId, charge);
                  muonPedestal->MakePed(busPatch->GetBusPatchId(), (Int_t)manuId, (Int_t)channelId, (Int_t)charge);
                }
@@ -334,26 +357,21 @@ int main(Int_t argc, Char_t **argv)
                      // Good buspatch
                      for(int i = 0; i < busPatch->GetLength(); ++i)
                        {
-                         if (nEvents == 0) nChannel++;
                          busPatch->GetData(i, manuId, channelId, charge);
-                         // if (busPatch->GetBusPatchId()==1719 && manuId == 1 && channelId == 0) cout <<"Recovered charge "<<charge<<endl;
                          muonPedestal->MakePed(busPatch->GetBusPatchId(), (Int_t)manuId, (Int_t)channelId, (Int_t)charge);
                        }
                    }
                  else
                    {
-                     char bpname[256];
                      AliMUONErrorCounter* errorCounter;
                      // Bad buspatch -> not used (just print)
                      filcout<<"bpId "<<busPatch->GetBusPatchId()<<" words "<<busPatch->GetLength()
                                 <<" parity errors "<<errorCount<<endl;
                      // Number of events where this buspatch is missing
-                     sprintf(bpname,"bp%d",busPatch->GetBusPatchId());                                         
-                     if (!(errorCounter = (AliMUONErrorCounter*) (muonPedestal->GetErrorBuspatchTable()->FindObject(bpname))))
+                     if (!(errorCounter = (AliMUONErrorCounter*) (muonPedestal->GetErrorBuspatchTable()->FindObject(busPatch->GetBusPatchId()))))
                        {
                          // New buspatch
                          errorCounter = new AliMUONErrorCounter(busPatch->GetBusPatchId());
-                         errorCounter->SetName(bpname);
                          muonPedestal->GetErrorBuspatchTable()->Add(errorCounter);
                        }
                      else
@@ -403,7 +421,6 @@ int main(Int_t argc, Char_t **argv)
   if(shuttleFile.IsNull())shuttleFile=flatFile;
   muonPedestal->SetAliNEvents(nEvents);
   muonPedestal->SetAliRunNumber(runNumber);
-  muonPedestal->SetAliNChannel(nChannel);
   
   muonPedestal->Finalize();  
   muonPedestal->MakeControlHistos();  
@@ -469,29 +486,21 @@ int main(Int_t argc, Char_t **argv)
   unsigned int nLastVersions=90;
   cout << "\n ***  Local DataBase: " << dir << " (Max= " << nLastVersions << ") ***" << endl;
   status = daqDA_localDB_storeFile(muonPedestal->GetHistoFileName(),nLastVersions);
-  //  if (!status) printf(" Failed to store file : %s   status = %d\n",muonPedestal->GetHistoFileName(),status);
-  printf(" Store file : %s   status = %d\n",muonPedestal->GetHistoFileName(),status);
+  if(status)printf(" Store file : %s   status = %d\n",muonPedestal->GetHistoFileName(),status);
   status = daqDA_localDB_storeFile(shuttleFile.Data(),nLastVersions);
-  //  if (!status) printf(" Failed to store file : %s   status = %d\n",shuttleFile.Data(),status);
-  printf(" Store file : %s   status = %d\n",shuttleFile.Data(),status);
+  if(status)printf(" Store file : %s   status = %d\n",shuttleFile.Data(),status);
   status = daqDA_localDB_storeFile(logOutputFile.Data(),nLastVersions);
-  //  if (!status) printf(" Failed to store file : %s   status = %d\n",logOutputFile.Data(),status);
-  printf(" Store file : %s   status = %d\n",logOutputFile.Data(),status);
-
-  // Transferring to OCDB via the SHUTTLE
-  printf("\n *****  STORE FILE in FES ****** \n");
+  if(status)printf(" Store file : %s   status = %d\n",logOutputFile.Data(),status);
 
-  // be sure that env variable DAQDALIB_PATH is set in script file
-  //       gSystem->Setenv("DAQDALIB_PATH", "$DATE_SITE/infoLogger");
+  filcout.close();
 
+  // Transferring to OCDB via the SHUTTLE (be sure that env variable DAQDALIB_PATH is set)
+  printf("\n *****  STORE FILE in FES ****** \n");
   status = daqDA_FES_storeFile(shuttleFile.Data(),"PEDESTALS");
-  if (status) 
-    {
-      printf(" Failed to export file : %d\n",status);
-    }
+  if (status) { printf(" Failed to export file : %s , status = %d\n",shuttleFile.Data(),status); return -1; }
   else printf(" %s successfully exported to FES  \n",shuttleFile.Data());
 
-  filcout.close();
+  printf("\n ######## End execution : %s ######## \n",prefixDA); 
   timers.Stop();
   printf("\nExecution time : R:%7.2fs C:%7.2fs\n", timers.RealTime(), timers.CpuTime());
   return status;