]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ITS/ITSSSDPEDda.cxx
plitting of drift speed (updated at every physics run) from other calibration paramet...
[u/mrichter/AliRoot.git] / ITS / ITSSSDPEDda.cxx
index bab87ad4783b3e7663a795ffe82c5190efd65909..7a712b9be86c5f34ada23fd222c13e4ce8cad0b8 100644 (file)
@@ -1,24 +1,36 @@
+/**************************************************************************
+- "Contact": - Oleksandr Borysov, aborysov@ts.infnf.it
+- "Link:" - link to test files: /afs/infn.it/ts/user/aborysov/public/C23_run387.000.raw
+- "Run Type:" - run type (exactly as defined in the ECS)
+- "DA Type:" -  LDC
+- "Number of events needed:"   at least 500
 
-#include <Riostream.h>
-#include <sstream>
-#include <string>
+- "Input Files:" - config file:    ssdpeddaconfig 
+                   previous result files:  
+                  data source:   raw data file on LDC
+                   
+- "Output Files:" -  local names $DA_TEST_DIR/ssddaldc_<LDCID>_<RunID>.root 
+                     FXS name: ITSSSDda_<LDCID>_<RunID>.root, 
+                     local files are persistent over runs: data source
+- "Trigger types used:"
+ **************************************************************************/
+
+
+#include <iostream>
+#include "TString.h"
 #include "TFile.h"
 #include "daqDA.h"
-#include "event.h"
-#include "AliRawReaderDate.h" 
 #include "AliITSHandleDaSSD.h" 
 
 using namespace std;
 
-Bool_t GetRunSettings (const char *datafilename, Long_t &eventsnumber, Long_t &stripsnumber);
 
 int main( int argc, char** argv )
 {
   AliITSHandleDaSSD  *ssddaldc;
-  ostringstream       feefname;
+  TString             feefname, cmddbsave;
   Int_t               status;
-  string              dafname;
-  Char_t             *dadaqdir = NULL;
+  Char_t             *dafname = NULL, *dadaqdir = NULL;
 
   /* check that we got some arguments = list of files */
   if (argc<2) {
@@ -28,120 +40,43 @@ int main( int argc, char** argv )
 
   char *datafilename = argv[1];
 
-  Long_t strn, evn;
-  if (!GetRunSettings (datafilename, evn, strn))
-  {
-    cout << "Error GetRunSettings (datafilename, evn, strn)!" << endl;
-    return -1;
-  }
-  cout << "Pysics events : " << evn << ";   Total strip number : " << strn 
-       << ";   Modules number: " << strn / AliITSModuleDaSSD::GetStripsPerModuleConst() << endl;
-  
-  ssddaldc = new AliITSHandleDaSSD();
-//  if (!ssddaldc->SetNumberOfModules((Int_t)(strn / AliITSModuleDaSSD::GetStripsPerModuleConst())))
-  if (!ssddaldc->SetNumberOfModules(AliITSHandleDaSSD::GetNumberOfSSDModulesConst()))
+  ssddaldc = new AliITSHandleDaSSD(datafilename);
+  if (ssddaldc->IsZombie()) return -1;
+  if (!ssddaldc->ProcessRawData())
   {
-     cout << "Error ssddaldc->SetNumberOfModules" << endl;
+     cout << "Error !ssddaldc->ProcessRawData()" << endl;
      delete ssddaldc;
      return -1;
   }  
-  if (!ssddaldc->ReadCalibrationDataFile(datafilename, evn))
-  {
-     cout << "Error !ssddaldc->ReadCalibrationDataFile" << endl;
-     delete ssddaldc;
-     return -1;
-  }  
-  daqDA_progressReport(30);
-//  if (daqDA_checkShutdown() == 1) {
-//    cout << "Shutdown has been requested!" << endl;
-//    delete ssddaldc;
-//    return -1;
-//  }
-
-  if (!ssddaldc->CalculatePedestal()) {
-    cout << "Error, ssddaldc->CalculatePedestal()";
-    return 1; 
-  } 
-  daqDA_progressReport(50);
-  if (!ssddaldc->CalculateNoiseCM()) {
-    cout << "Error, ssddaldc->CalculateNoiseCM()";
-    return 2; 
-  } 
-  ssddaldc->DeleteSignal();
   daqDA_progressReport(90);
-  dadaqdir = getenv ("DAQDA_TEST_DIR");
+
+  if (!system(NULL)) {
+    cout << "Error: the call system(NULL) in main() returned NULL!" << endl;
+    return -1;
+  }
+  dadaqdir = getenv ("DA_TEST_DIR");
   if (dadaqdir) {
     dafname = dadaqdir;
     if (!(ssddaldc->SaveCalibrationSSDLDC(dafname))) 
-      cout << "Error saving DA data to the file! Probably $DAQDA_TEST_DIR defined incorrectly!" << endl;
+      cout << "Error saving DA data to the file! Probably $DA_TEST_DIR defined incorrectly!" << endl;
     else cout << "SSDDA data are saved in " << dafname << endl;
-      feefname << dadaqdir << "/ssddaldc.root";
-    cout << "Saving feessdda data in " << feefname.str() << endl;
-    TFile *fileRun = new TFile (feefname.str().data(),"RECREATE");
+    feefname = Form("%s/ssddaldc_%i_%i.root", dadaqdir, ssddaldc->GetLdcId(), ssddaldc->GetRunId());
+    cout << "Saving feessdda data in " << feefname << endl;
+    TFile *fileRun = new TFile (feefname.Data(),"RECREATE");
     ssddaldc->Write();
     fileRun->Close();
     delete fileRun;
-    status = daqDA_FES_storeFile(dafname.data(),"DASSD_DB_results");
+    status = daqDA_FES_storeFile(dafname"DASSD_DB_results");
     if (status) printf("Failed to export file : %d\n",status);
+
+    if (getenv("DATE_DB_DIR")) {
+      cmddbsave = Form("$DATE_DB_DIR/daqDetDB_store ssddaldc.root %s", feefname.Data());
+      status = system(cmddbsave.Data());
+      if (status) printf("Failed to export file to the detector db: %d\n",status);
+    } else cout << "Error main(): $DATE_DB_DIR is not defined!" << endl;
   }
-  else cout << "Error: DAQDA_TEST_DIR is not defined, DA data are not saved!" << endl;
+  else cout << "Error: DA_TEST_DIR is not defined, DA data are not saved!" << endl;
   delete ssddaldc;
   daqDA_progressReport(100);
   return 0;
-}
-
-
-
-Bool_t GetRunSettings (const char *datafilename, Long_t &eventsnumber, Long_t &stripsnumber)
-{
-  Long_t physeventind = 0, strn = 0, strneq = 0;
-  AliRawReaderDate  *rawreaderdate = NULL;
-  Int_t *data = NULL;
-  Long_t datasize = 0, eqdatasize = 0, eqbelsize = 1;
-  rawreaderdate = new AliRawReaderDate(datafilename, 0);
-  if (!rawreaderdate) {
-    cout << "GetRunSettings : Error  new DARawReader(datafilename, 0);" << endl;
-    return kFALSE;
-  }  
-  rawreaderdate->SelectEvents(-1);
-  while (rawreaderdate->NextEvent()) {
-    if ((rawreaderdate->GetType() != PHYSICS_EVENT) && (rawreaderdate->GetType() != CALIBRATION_EVENT)) continue;
-    physeventind += 1;
-    datasize = 0;
-    strn = 0;
-    while (rawreaderdate->ReadNextData((UChar_t*&)data)) {
-      eqdatasize = rawreaderdate->GetDataSize();
-      eqbelsize = rawreaderdate->GetEquipmentElementSize();
-      if ( (eqdatasize % eqbelsize) || (eqbelsize != sizeof(long32)) ) {
-        cout << "Error ReadCalibrationDataFile: equipment event data size " << eqdatasize  
-            << " is not an integer of equipment data size "      << eqbelsize << endl;
-       rawreaderdate->DumpData();
-        return kFALSE;
-      }
-      strneq = eqdatasize / eqbelsize;
-      datasize += eqdatasize;
-      strn += strneq;
-    }  
-    if ((strn * eqbelsize != datasize)) {
-      if (physeventind != 1) {
-        cout << "Something is wrong with data file, strip number changes from event to event! Ev = " << physeventind << endl;
-        rawreaderdate->DumpData();
-        return kFALSE;
-      }
-      if ((datasize % eqbelsize)) {
-        cout << "Wrong number :  (datasize % eqbelsize) != 0" << endl;
-        rawreaderdate->DumpData();
-        return kFALSE;
-      }
-      strneq = datasize / eqbelsize;
-    }
-  }
-  delete rawreaderdate;
-  if ((physeventind > 0) && (strn > 0))
-  {
-    eventsnumber = physeventind;
-    stripsnumber = strn;
-    return kTRUE;
-  }
-  return kFALSE;
-}
+}
\ No newline at end of file