]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - VZERO/VZEROPbPbda.cxx
Merge branch 'master' of https://git.cern.ch/reps/AliRoot
[u/mrichter/AliRoot.git] / VZERO / VZEROPbPbda.cxx
index 4f00c964cc37af3ee453271a5d7c548e4d9ca727..191d679c25c77d55b25d163318b8ee80d567405f 100644 (file)
@@ -60,14 +60,14 @@ int main(int argc, char **argv) {
   
 //___________________________________________________
 // Get parameters from V00DAEqualFactors.config file
+  Int_t    neventsMin = 2000;
 
   Int_t    kStartClock = 9;  // First clock in the search for max adc
   Int_t    kEndClock = 11;   // Last clock in the search for max adc
   Int_t    kNPreClocks = 6;  // Number of clock before max used in the charge sum
   Int_t    kNPostClocks = 1; // Number of clock after max used in the charge sum
 
-  UShort_t    kTriggerAcc = 64;    // Trigger mask for accepted events (64 = CTA1 & CTC1)
-  UShort_t    kTriggerRej = 256;   // Trigger mask for rejected events (256 = CTA2 & CTC2)
+  UChar_t  kNFlagsCut   = 63;// Minimum number of TDC flags requested, replaces the trigger selection
 
   Int_t    kNBins = 10000;
   Float_t  kRange = 0.1;
@@ -79,16 +79,16 @@ int main(int argc, char **argv) {
   } else {
     /* open the config file and retrieve cuts */
     FILE *fpConfig = fopen("V00DAEqualFactors.config","r");
-    int res = fscanf(fpConfig,"%d %d %d %d %u %u %d %f",
-                    &kStartClock,&kEndClock,&kNPreClocks,&kNPostClocks,&kTriggerAcc,&kTriggerRej,&kNBins,&kRange);
+    int res = fscanf(fpConfig,"%d %d %d %d %d %hhu %d %f",
+                    &neventsMin,&kStartClock,&kEndClock,&kNPreClocks,&kNPostClocks,&kNFlagsCut,&kNBins,&kRange);
     if(res!=8) {
       printf("Failed to get values from Config file (V00DAEqualFactors.config): wrong file format - 7 integers and 1 float are expected - \n");
     }
     fclose(fpConfig);
   }
   
-  printf("First LHC Clock = %d; Last LHC Clock = %d; N Pre Clock = %d ; N Post Clock = %d; Trigger mask for accepted events = %u; Trigger mask for rejected events = %u; Number of histogram bins = %d; Histogram range = %.3f\n",
-        kStartClock, kEndClock, kNPreClocks, kNPostClocks, kTriggerAcc, kTriggerRej, kNBins, kRange);
+  printf("Minimum number of events to process = %d; First LHC Clock = %d; Last LHC Clock = %d; N Pre Clock = %d; N Post Clock = %d; Minimum number of TDC flags = %hhu; Number of histogram bins = %d; Histogram range = %.3f\n",
+        neventsMin,kStartClock, kEndClock, kNPreClocks, kNPostClocks, kNFlagsCut, kNBins, kRange);
 
   TH1D *fMedian[64];
   for(Int_t j = 0; j < 64; ++j) fMedian[j] = new TH1D(Form("fMedian_%d",j),"Slopes weighted median, channel par channel",kNBins,0,kRange);
@@ -119,6 +119,7 @@ int main(int argc, char **argv) {
   monitorSetNoWaitNetworkTimeout(1000);
   
   /* init counters on events */
+  int neventsPhysicsAll=0;
   int neventsPhysics=0;
   int neventsTotal=0;
 
@@ -164,9 +165,14 @@ int main(int argc, char **argv) {
   
           AliVZERORawStream* rawStream  = new AliVZERORawStream(rawReader); 
           if (rawStream->Next()) {     
+            neventsPhysicsAll++;
             UShort_t triggers = rawStream->GetTriggerInputs();
-            if (((triggers & kTriggerAcc) == kTriggerAcc) &&  // Check if the requested trigger(s) is fired
-                ((triggers & kTriggerRej) == 0)) { // Check if the requested trigger(s) is NOT fired
+            UChar_t nFlags = 0;
+            for(Int_t i = 0; i < 64; ++i) {
+              if (rawStream->GetBBFlag(i,10)) nFlags++;
+            }
+            if (nFlags >= kNFlagsCut) { // Check if the number of minimum number of TDC flags is reached (trigger selection)
+
               neventsPhysics++;
 
               Float_t adc[64];
@@ -231,13 +237,13 @@ int main(int argc, char **argv) {
 
   }  // loop over events
   
-  printf("%d physics events processed\n",neventsPhysics);
+  printf("%d physics events processed (out of %d physics and %d total events)\n",neventsPhysics,neventsPhysicsAll,neventsTotal);
     
 //___________________________________________________________________________
 //  Computes regression parameters
 // charge_i = p0 + charge_tot * p1
 
-  if(neventsPhysics>2000){
+  if(neventsPhysics>neventsMin){
     /* open result file to be exported to FES */
     FILE *fp=NULL;
     fp=fopen("./V0_EqualizationFactors.dat","w");
@@ -250,27 +256,38 @@ int main(int argc, char **argv) {
     for(int i = 0; i < 64; ++i) fMedian[i]->GetQuantiles(1,&beta[i],&q);
 
     for(Int_t i=0; i<64; i++) {
-      fprintf(fp," %d %.3f\n",GetOfflineChannel(i), beta[i]*64.);                                     
-      printf(" %d %.3f\n",GetOfflineChannel(i), beta[i]*64.);                                 
+      fprintf(fp," %d %.5f\n",GetOfflineChannel(i), beta[i]*64.);                                     
+      printf(" %d %.5f\n",GetOfflineChannel(i), beta[i]*64.);                                 
     }
 
     /* close local result file and FXS result file*/
     fclose(fp);
-  }
-
-//________________________________________________________________________
    
-  /* export result file to FES */
-  status=daqDA_FES_storeFile("./V0_EqualizationFactors.dat","V00DAEqualFactors");
-  if (status)    {
-    printf("Failed to export file : %d\n",status);
-    return -1; }
-
-  /* store result file into Online DB */
-  status=daqDA_DB_storeFile("./V0_EqualizationFactors.dat","V00DAEqualFactors");
-  if (status)    {
-    printf("Failed to store file into Online DB: %d\n",status);
-    return -1; }
+    /* export result file to FES */
+    status=daqDA_FES_storeFile("./V0_EqualizationFactors.dat","V00DAEqualFactors");
+    if (status)    {
+      printf("Failed to export file : %d\n",status);
+      return -1; }
+
+    /* store result file into Online DB */
+    status=daqDA_DB_storeFile("./V0_EqualizationFactors.dat","V00DAEqualFactors");
+    if (status)    {
+      printf("Failed to store file into Online DB: %d\n",status);
+      return -1; }
+  }
+  else {
+    // Take the last run's file from the DB
+    status=daqDA_DB_getFile("V00DAEqualFactors","./V0_EqualizationFactors.dat");
+    if (status)    {
+      printf("Failed to get file from Online DB: %d\n",status);
+      return -1; }
+
+    /* export result file to FES */
+    status=daqDA_FES_storeFile("./V0_EqualizationFactors.dat","V00DAEqualFactors");
+    if (status)    {
+      printf("Failed to export file : %d\n",status);
+      return -1; }
+  }
 
   return status;
 }