]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - VZERO/VZEROda.cxx
added status information in AliTOFcalibHisto class to handle status of disconnected...
[u/mrichter/AliRoot.git] / VZERO / VZEROda.cxx
index 35aefb5c0405d0281d55b5550f22175548d86740..cda344a88a83a74c4dbc316ef01dff9aa31f7c5e 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
 **********************************************************************************/
 
@@ -66,12 +66,14 @@ int main(int argc, char **argv) {
      return -1;
   }
   
-  // Online values (using FEE channel numbering):
+  // 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): 
+  // 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];
@@ -80,20 +82,35 @@ int main(int argc, char **argv) {
 //___________________________________________________
 // Get cuts from V00DA.config file
 
+  Int_t    kClockMin;   // = 16;   LHC Clock Min for pedestal calculation
+  Int_t    kClockMax;   // = 19;   LHC Clock Max for pedestal calculation
   Int_t    kLowCut;     // = 60;   low cut on signal distribution - to be tuned
   Int_t    kHighCut;    // = 50;   high cut on pedestal distribution - to be tuned
   
   status = daqDA_DB_getFile("V00DA.config","./V00DA.config");
   if (status) {
-      printf("Failed to get config file (V00DA.config) from DAQ DB, status=%d\n", status);
-      return -1;   
+      printf("Failed to get Config file (V00DA.config) from DAQ DB, status=%d\n", status);
+      printf("Take default values of parameters for pedestal calculation \n");
+      kClockMin  =  16; 
+      kClockMax  =  19; 
+      kLowCut    =  60;   
+      kHighCut   =  50;  
+  } else {
+      /* open the config file and retrieve cuts */
+      FILE *fpConfig = fopen("V00DA.config","r");
+      int res = fscanf(fpConfig,"%d %d %d %d ",&kClockMin,&kClockMax,&kLowCut,&kHighCut);
+      if(res!=4) {
+           printf("Failed to get values from Config file (V00DA.config): wrong file format - 4 integers are expected - \n");
+           kClockMin  =  16; 
+            kClockMax  =  19; 
+            kLowCut    =  60;   
+            kHighCut   =  50; 
+      }
+      fclose(fpConfig);
   }
-  /* open the config file and retrieve cuts */
-  FILE *fpConfig = fopen("V00DA.config","r");
-  fscanf(fpConfig,"%d %d",&kLowCut,&kHighCut);
-  fclose(fpConfig);
   
-  printf("LowCut on signal = %d ; HighCut on pedestal = %d\n",kLowCut,kHighCut);
+  printf("LHC Clock Min for pedestal calculation = %d; LHC Clock Max for pedestal calculation = %d; LowCut on signal = %d ; HighCut on pedestal = %d\n",
+          kClockMin, kClockMax, kLowCut, kHighCut);
 
 //___________________________________________________
 // Book HISTOGRAMS - dynamics of p-p collisions -
@@ -113,6 +130,13 @@ 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;
@@ -184,14 +208,14 @@ int main(int argc, char **argv) {
           AliRawReader *rawReader = new AliRawReaderDate((void*)event);
   
           AliVZERORawStream* rawStream  = new AliVZERORawStream(rawReader); 
-          rawStream->Next();   
+          if (rawStream->Next()) {     
            for(Int_t i=0; i<64; i++) {
                Int_t nFlag = 0;
-               for(Int_t j=0; j<21; j++) {
+               for(Int_t j=kClockMin; j <= kClockMax; j++) {  // Check flags on clock range used for pedestal calculation
                   if((rawStream->GetBBFlag(i,j)) || (rawStream->GetBGFlag(i,j))) nFlag++; 
                }
-               if(nFlag == 0){       // Pedestal
-                  for(Int_t j=5;j<16;j++){
+               if(nFlag == 0){       // Fill 64*2 pedestal histograms  - 2 integrators -
+                  for(Int_t j=kClockMin;j <= kClockMax;j++){
                       Int_t Integrator = rawStream->GetIntegratorFlag(i,j);
                       Float_t pedestal = (float)(rawStream->GetPedestal(i,j));
                       hPEDname[i + 64 * Integrator]->Fill(pedestal);
@@ -199,10 +223,11 @@ int main(int argc, char **argv) {
                } 
                if((rawStream->GetBBFlag(i,10)) || (rawStream->GetBGFlag(i,10))){ // Charge
                    Int_t Integrator = rawStream->GetIntegratorFlag(i,10);
-                   Float_t charge = (float)(rawStream->GetADC(i));
+                   Float_t charge = (float)(rawStream->GetADC(i));   // Fill 64*2 ADCmax histograms 
                    hADCname[i + 64 * Integrator]->Fill(charge);
                }                          
-           }    
+             } 
+          }   
            delete rawStream;
            rawStream = 0x0;      
            delete rawReader;
@@ -235,6 +260,8 @@ int main(int argc, char **argv) {
       ADCmean[i]  = hADCname[i]->GetMean();
       ADCsigma[i] = hADCname[i]->GetRMS(); 
 //      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];
@@ -272,7 +299,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 */
@@ -282,7 +310,7 @@ int main(int argc, char **argv) {
       return -1; }
 
   /* store result file into Online DB */
-  status=daqDA_DB_storeFile("./V0_Ped_Width_Gain.dat","V00da_results");
+  status=daqDA_DB_storeFile("./V0_Pedestals.dat","V00da_results");
   if (status)    {
       printf("Failed to store file into Online DB: %d\n",status);
       return -1; }