]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - VZERO/VZEROda.cxx
Example macro for merging sets of alignment objects
[u/mrichter/AliRoot.git] / VZERO / VZEROda.cxx
index 6cdb4a20a10fb3bf6cb9d2d79884e385e2b649e8..c3f0586505a10c5d632cac54fe19723e0f079ba8 100755 (executable)
@@ -7,8 +7,8 @@
 - DA Type:    MON
 - Number of events needed: >=500
 - Input Files:  argument list
-- Output Files: local files  VZERO_Histos.root, V0_Ped_Width_Gain.dat
-                FXS file     V0_Ped_Width_Gain.dat
+- Output Files: local files  VZERO_Histos.root, V0_Pedestals.dat (Online mapping)
+                FXS file     V0_Ped_Width_Gain.dat (Offline mapping)
 - Trigger types used: PHYSICS_EVENT
 **********************************************************************************/
 
@@ -18,7 +18,7 @@
 *                                                                                 *
 * This program connects to the DAQ data source passed as argument.                *
 * It computes calibration parameters, populates local "./V0_Ped_Width_Gain.dat"   *            
-* file and exports it to the FES.                                                 *
+* file, exports it to the FES, and stores it into DAQ DB                          *
 * The program exits when being asked to shut down (daqDA_checkshutdown)           *
 * or on End of Run event.                                                         *
 * We have 128 channels instead of 64 as expected for V0 due to the two sets of    *
@@ -48,6 +48,8 @@
 #include <TH1F.h>
 #include <TMath.h>
 
+Int_t GetOfflineChannel(Int_t channel);
+
 /* Main routine --- Arguments: monitoring data source */
       
 int main(int argc, char **argv) {
@@ -64,11 +66,19 @@ int main(int argc, char **argv) {
      return -1;
   }
   
+  // Online values (using FEE channel numbering), 
+  // stored into local V0_Pedestals.dat:
   Double_t ADCmean[128];
   Double_t ADCsigma[128];
   Double_t PEDmean[128];
   Double_t PEDsigma[128];
-     
+  // Offline values(same but ordered as in aliroot for offliners)
+  // stored into V0_Ped_Width_Gain.dat: 
+  Double_t ADCmean_Off[128];
+  Double_t ADCsigma_Off[128];
+  Double_t PEDmean_Off[128];
+  Double_t PEDsigma_Off[128];
+       
 //___________________________________________________
 // Get cuts from V00DA.config file
 
@@ -77,7 +87,7 @@ int main(int argc, char **argv) {
   
   status = daqDA_DB_getFile("V00DA.config","./V00DA.config");
   if (status) {
-      printf("Failed to get config file (V00DA.config) from DAQdetDB, status=%d\n", status);
+      printf("Failed to get config file (V00DA.config) from DAQ DB, status=%d\n", status);
       return -1;   
   }
   /* open the config file and retrieve cuts */
@@ -105,8 +115,14 @@ int main(int argc, char **argv) {
        hPEDname[i]  = new TH1F(PEDname,texte,1024,-0.5, 1023.5);
   }
 //___________________________________________________ 
-  
+
+  /* open result file to be exported to FES */
+  FILE *fpLocal=NULL;
+  fpLocal=fopen("./V0_Pedestals.dat","w");
+  if (fpLocal==NULL) {
+      printf("Failed to open local result file\n");
+      return -1;}
+   
   /* open result file to be exported to FES */
   FILE *fp=NULL;
   fp=fopen("./V0_Ped_Width_Gain.dat","w");
@@ -216,8 +232,9 @@ int main(int argc, char **argv) {
   
   printf("%d physics events processed\n",nevents_physics);
     
-//________________________________________________________________________
-//  Computes mean values, dumps them into the output text file
+//___________________________________________________________________________
+//  Computes mean values, converts FEE channels into Offline AliRoot channels
+//  and dumps the ordered values into the output text file for SHUTTLE
        
   for(Int_t i=0; i<128; i++) {
       hPEDname[i]->GetXaxis()->SetRange(0,kHighCut);
@@ -226,7 +243,29 @@ int main(int argc, char **argv) {
       hADCname[i]->GetXaxis()->SetRange(kLowCut,1024);
       ADCmean[i]  = hADCname[i]->GetMean();
       ADCsigma[i] = hADCname[i]->GetRMS(); 
-      fprintf(fp," %.3f %.3f %.3f %.3f\n",PEDmean[i],PEDsigma[i],ADCmean[i],ADCsigma[i]);
+//      printf(" i = %d, %.3f %.3f %.3f %.3f\n",i,PEDmean[i],PEDsigma[i],ADCmean[i],ADCsigma[i]);
+      fprintf(fpLocal," %.3f %.3f %.3f %.3f\n",PEDmean[i],PEDsigma[i],
+                                               ADCmean[i],ADCsigma[i]);
+      if (i < 64) {
+          Int_t j = GetOfflineChannel(i);     
+          PEDmean_Off[j]  = PEDmean[i];
+          PEDsigma_Off[j] = PEDsigma[i];
+          ADCmean_Off[j]  = ADCmean[i];
+          ADCsigma_Off[j] = ADCsigma[i]; }
+      else{
+          Int_t j = GetOfflineChannel(i-64);     
+          PEDmean_Off[j+64]  = PEDmean[i];
+          PEDsigma_Off[j+64] = PEDsigma[i];
+          ADCmean_Off[j+64]  = ADCmean[i];
+          ADCsigma_Off[j+64] = ADCsigma[i];
+      }
+  }
+  
+  for(Int_t j=0; j<128; j++) {
+//      printf(" j = %d, %.3f %.3f %.3f %.3f\n",j,PEDmean_Off[j],PEDsigma_Off[j],
+//                                                ADCmean_Off[j],ADCsigma_Off[j]);
+      fprintf(fp," %.3f %.3f %.3f %.3f\n",PEDmean_Off[j],PEDsigma_Off[j],
+                                          ADCmean_Off[j],ADCsigma_Off[j]);                                    
   }
    
 //________________________________________________________________________
@@ -244,8 +283,8 @@ int main(int argc, char **argv) {
   
 //________________________________________________________________________
    
-
-  /* close result file */
+  /* close local result file and FXS result file*/
+  fclose(fpLocal);
   fclose(fp);
  
   /* export result file to FES */
@@ -254,5 +293,26 @@ int main(int argc, char **argv) {
       printf("Failed to export file : %d\n",status);
       return -1; }
 
+  /* store result file into Online DB */
+  status=daqDA_DB_storeFile("./V0_Pedestals.dat","V00da_results");
+  if (status)    {
+      printf("Failed to store file into Online DB: %d\n",status);
+      return -1; }
+      
   return status;
 }
+
+ Int_t GetOfflineChannel(Int_t channel) {
+
+// Channel mapping Online - Offline:
+ Int_t fOfflineChannel[64] = {39, 38, 37, 36, 35, 34, 33, 32, 
+                              47, 46, 45, 44, 43, 42, 41, 40, 
+                             55, 54, 53, 52, 51, 50, 49, 48, 
+                             63, 62, 61, 60, 59, 58, 57, 56,
+                              7,  6,  5,  4,  3,  2,  1,  0, 
+                             15, 14, 13, 12, 11, 10,  9,  8,
+                             23, 22, 21, 20, 19, 18, 17, 16, 
+                             31, 30, 29, 28, 27, 26, 25, 24};
+ return        fOfflineChannel[channel];                     
+}