feature added to store and fetch from DB for online gain calibration
authorbasanta <basanta@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 1 Jul 2008 10:36:00 +0000 (10:36 +0000)
committerbasanta <basanta@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 1 Jul 2008 10:36:00 +0000 (10:36 +0000)
PMD/AliPMDCalibGain.cxx
PMD/AliPMDCalibGain.h
PMD/PMDGAINda.cxx
PMD/PMDPEDESTALda.cxx
PMD/PMD_GAIN_CONFIGFILE [new file with mode: 0644]

index 28a602d..f59fce1 100644 (file)
@@ -134,7 +134,7 @@ AliPMDCalibGain::~AliPMDCalibGain()
 
 // ------------------------------------------------------------------------ //
 
-Int_t AliPMDCalibGain::ExtractPedestal()
+Int_t AliPMDCalibGain::ExtractPedestal(const Char_t *rootFile)
 {
   // Pedestal extraction from the PMD_PED.root file
   // To be called once at the beginning
@@ -142,7 +142,7 @@ Int_t AliPMDCalibGain::ExtractPedestal()
   Int_t   det, sm, row, col;
   Float_t mean, rms;
 
-  TFile *pedfile = new TFile("PMD_PED1.root");
+  TFile *pedfile = new TFile(rootFile);
 
   if(!pedfile)
     {
@@ -178,11 +178,11 @@ Int_t AliPMDCalibGain::ExtractPedestal()
 }
 // ------------------------------------------------------------------------ //
 
-void AliPMDCalibGain::ReadIntermediateFile()
+void AliPMDCalibGain::ReadTempFile(const Char_t *tempFile)
 {
   // Read the variables from the file
   
-  fpw = fopen("interfile.dat","r");
+  fpw = fopen(tempFile,"r");
 
   Float_t detcount, detiso;
   Float_t smcount, smiso;
@@ -228,12 +228,13 @@ void AliPMDCalibGain::ReadIntermediateFile()
 
 }
 // ------------------------------------------------------------------------ //
-void AliPMDCalibGain::WriteIntermediateFile()
+void AliPMDCalibGain::WriteTempFile(const Char_t *tempFile)
 {
+  // Write the Temporary file if the required statics is not achieved
 
- //Following variables to be written
 
   /*
+    Following variables to be written to a file
     fDetIso[idet] ;
     fSMIso[idet][ismn]; 
     fCellIso[idet][ismn][irow][icol]; 
@@ -243,7 +244,8 @@ void AliPMDCalibGain::WriteIntermediateFile()
     fCellCount[idet][ismn][irow][icol];
   */                             
 
-  fpw = fopen("interfile.dat","w+");
+
+  fpw = fopen(tempFile,"w+");
 
   for (Int_t idet = 0; idet < kDet; idet++)
     {
@@ -325,12 +327,16 @@ Bool_t AliPMDCalibGain::ProcessEvent(AliRawReader *rawReader, TObjArray *pmdddlc
          
          Int_t idet = pmdddl->GetDetector();
          Int_t ismn = pmdddl->GetSMN();
-         //Int_t mcm = pmdddl->GetMCM();
+         Int_t mcm = pmdddl->GetMCM();
          //Int_t ichno = pmdddl->GetChannel();
          Int_t irow = pmdddl->GetRow();
          Int_t icol = pmdddl->GetColumn();
          Int_t isig = pmdddl->GetSignal();
 
+         // This is the protection not to crash the code 
+
+         if(mcm == 0) continue;
+         if (irow < 0 || icol < 0 || irow > 47 || icol > 95) continue;
 
          // Pedestal subtraction
 
@@ -413,7 +419,6 @@ void AliPMDCalibGain::Analyse(TTree *gaintree)
              {
                for(Int_t icol = 0; icol < kMaxCol; icol++)
                  {
-                   
                    if (fCellCount[idet][ism][irow][icol] > 0.)
                       {
                        cellmean = fCellIso[idet][ism][irow][icol]/fCellCount[idet][ism][irow][icol];
index e2ae41f..d5f0343 100644 (file)
@@ -17,9 +17,9 @@ class AliPMDCalibGain : public TObject
 
   virtual ~AliPMDCalibGain() ;           // dtor
 
-  Int_t ExtractPedestal();               // Assign the pedestal values
-  void  ReadIntermediateFile();          // reads the intermediate file
-  void  WriteIntermediateFile();         // writes the intermediate file
+  Int_t ExtractPedestal(const Char_t *rootFile);       // pedestal 
+  void  ReadTempFile(const Char_t *tempFile); // read inter file
+  void  WriteTempFile(const Char_t *tempFile);// write inter file
 
   Bool_t ProcessEvent(AliRawReader *rawReader, TObjArray *pmdddlcont);  //Looks for iso cells
 
@@ -43,8 +43,8 @@ class AliPMDCalibGain : public TObject
   Float_t fCellCount[kDet][kMaxSMN][kMaxRow][kMaxCol]; // counter
 
   Float_t fPedMeanRMS[kDet][kMaxSMN][kMaxRow][kMaxCol];// Pedestal Mean
-  FILE    *fpw;         // write the intermediate file
+  FILE    *fpw;                            // write the temp file
 
-ClassDef(AliPMDCalibGain,4)        // description 
+ClassDef(AliPMDCalibGain,5)        // description 
 };
 #endif // ALIPMDCALIBGAIN_H
index 0fe0d75..79f6e62 100644 (file)
@@ -2,13 +2,13 @@
 PMD DA for online calibration
 
 contact: basanta@phy.iitb.ac.in
-Link:http://www.veccal.ernet.in/~pmd/
-Reference run:
+Link:
+Reference run:/afs/cern.ch/user/b/bnandi/public/gaindata/pythia100evts.date
 Run Type: PHYSICS
 DA Type: MON
 Number of events needed: 1 million for PB+PB, 200 milion for p+p
-Input Files: PMD_PED.root, Configfile
-Output Files: PMDGAINS.root, to be exported to the DAQ FXS
+Input Files: PMD_PED.root, PMD_GAIN_CONFIGFILE, pmd_gain_tempfile.dat
+Output Files: PMDGAINS.root, to be exported to the DAQ FES
 Trigger types used: PHYSICS_EVENT
 
 */
@@ -52,30 +52,47 @@ int main(int argc, char **argv) {
                                          "RIO",
                                          "TStreamerInfo()");
 
+
+    int status = 0;
+
+
     Int_t filestatus = -1, totevt = -1;
     Int_t maxevt = -1;
 
     // Reads the pedestal file and keep the values in memory for subtraction
 
     AliPMDCalibGain calibgain;
-    Int_t pstatus = calibgain.ExtractPedestal();
+
+    // Fetch the pedestal file - PMD_PED.root 
+    status = daqDA_DB_getFile("PMD_PED.root","PMD_PED.root");
+
+    if(!status)
+      {
+       printf("*** Pedestal file retrieved from DB *** \n");
+      }
+    else
+      {
+       printf("*** Pedestal file NOT retrieved from DB *** \n");
+       return -1;
+      }
+
+    Int_t pstatus = calibgain.ExtractPedestal("PMD_PED.root");
 
     if(pstatus == -3) return -3;
 
     TTree *ic = NULL;
 
+    // Retrieve the PMD_GAIN_CONFIGFILE
+    status = daqDA_DB_getFile("PMD_GAIN_CONFIGFILE","PMD_GAIN_CONFIGFILE");
+
     FILE *fp1 = NULL;
 
-    fp1 = fopen("Configfile","r");
+    fp1 = fopen("PMD_GAIN_CONFIGFILE","r");
 
     if (fp1 == NULL)
       {
-       printf("**** Configfile doesn't exist, creating the file ****\n");
-       fp1 = fopen("Configfile","w");
-       filestatus = 0;
-       totevt     = 0;
-       maxevt     = 2000;
-       fprintf(fp1,"%d %d %d\n",filestatus, totevt,maxevt);
+       printf("*** PMD GAIN Configfile doesn't exist,Provide one ***\n");
+       return -1;
       }
     else
       {
@@ -86,12 +103,20 @@ int main(int argc, char **argv) {
     
     if (filestatus == 1)
       {
-       calibgain.ReadIntermediateFile();
+       // Retrieve the Temporray ascii file from DB
+       status = daqDA_DB_getFile("pmd_gain_tempfile.dat","pmd_gain_tempfile.dat");
+       if(!status)
+         {
+           calibgain.ReadTempFile("pmd_gain_tempfile.dat");
+         }
+       else
+         {
+           printf("--- pmd_gain_tempfile.dat: not retrieved from DB ---\n");
+         }
       }
 
     // decoding the events
     
-    int status;
 
     if (argc!=2) {
        printf("Wrong number of arguments\n");
@@ -193,21 +218,35 @@ int main(int argc, char **argv) {
 
     totevt += nevents_physics++;
 
-    fp1 = fopen("Configfile","w+");
+    fp1 = fopen("PMD_GAIN_CONFIGFILE","w+");
 
     if (totevt < maxevt)
       {
-       printf("Required Number of Events not reached\n");
-       printf("Number of Events processed = %d\n",totevt);
-       printf("Writing the intermediate ASCII file\n");
-       calibgain.WriteIntermediateFile();
+       printf("-----------------------------------------------\n");
+       printf("***  Required Number of Events not reached  ***\n");
+       printf("***  Number of Events processed = %d        ***\n",totevt);
+       printf("***  Writing the intermediate ASCII file    ***\n");
+       printf("-----------------------------------------------\n");
+
+       calibgain.WriteTempFile("pmd_gain_tempfile.dat");
+
+       // Store the Intermediate ascii file in the DB
+       status = daqDA_DB_storeFile("pmd_gain_tempfile.dat","pmd_gain_tempfile.dat");
 
        filestatus = 1;
        fprintf(fp1,"%d %d %d\n",filestatus,totevt,maxevt);
+
+       // Store the configfile in the DB
+       status = daqDA_DB_storeFile("PMD_GAIN_CONFIGFILE","PMD_GAIN_CONFIGFILE");
+
       }
     else if (totevt >= maxevt)
       {
-       printf("Required Number of Events reached = %d\n",totevt);
+       printf("-----------------------------------------------\n");
+       printf("***  Required Number of Events reached = %d ***\n",totevt);
+       printf("***  Writing the PMDGAINS.root file           ***\n");
+       printf("-----------------------------------------------\n");
+
        calibgain.Analyse(ic);
 
        TFile * gainRun = new TFile ("PMDGAINS.root","RECREATE"); 
@@ -217,6 +256,10 @@ int main(int argc, char **argv) {
        filestatus = 0;
        totevt     = 0;
        fprintf(fp1,"%d %d %d\n",filestatus,totevt,maxevt);
+
+       // Store the configfile in the DB
+       status = daqDA_DB_storeFile("PMD_GAIN_CONFIGFILE","PMD_GAIN_CONFIGFILE");
+
       }
     fclose(fp1);
     
index 2c8ede2..91ada1f 100644 (file)
@@ -36,8 +36,6 @@ extern "C" {
 #include "TROOT.h"
 #include "TPluginManager.h"
 
-
-
 /* Main routine
       Arguments: 
       1- monitoring data source
@@ -171,13 +169,28 @@ int main(int argc, char **argv) {
     delete ped;
     ped = 0;
 
+/* store the pedestal file in database */
+
+    status = daqDA_DB_storeFile("PMD_PED.root","PMD_PED.root");
+
+    if (!status)
+      {
+       printf("--- PEDESTAL root FILE IS IN THE DAQ DATABASE\n");
+      }
+    else
+      {
+       printf("--- Storing the root file into the database failed\n");
+      }
 
-/* store the result file on FES */
+/* store the pedestal file on FES */
  
     status = daqDA_FES_storeFile("PMD_PED.root","pedestal");
     if (status) {
        status = -2;
     }
 
+
+
+
     return status;
 }
diff --git a/PMD/PMD_GAIN_CONFIGFILE b/PMD/PMD_GAIN_CONFIGFILE
new file mode 100644 (file)
index 0000000..fb171c2
--- /dev/null
@@ -0,0 +1 @@
+0 0 2000