]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ZDC/ZDCEMDda.cxx
Move const in the right position
[u/mrichter/AliRoot.git] / ZDC / ZDCEMDda.cxx
index e295304f3e3806905a8368d9ba1eca3c8470738b..51c5370a7359c869cf5e51d03d39640415802391 100644 (file)
@@ -21,6 +21,9 @@ Output Files: ZDCEMDCalib.dat, ZDCChMapping.dat
 Trigger Types Used: Standalone Trigger
 
 */
+#define PEDDATA_FILE  "ZDCPedestal.dat"
+#define MAPDATA_FILE  "ZDCChMapping.dat"
+#define EMDDATA_FILE  "ZDCEMDCalib.dat"
 
 #include <stdio.h>
 #include <Riostream.h>
@@ -103,32 +106,53 @@ int main(int argc, char **argv) {
   }
   
   FILE *mapFile4Shuttle;
-  const char *mapfName = "ZDCChMapping.dat";
 
-  /* define data source : this is argument 1 */  
-  status = monitorSetDataSource( argv[1] );
-  if(status!=0) {
-    printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
+  // *** To analyze LASER events you MUST have a pedestal data file!!!
+  // *** -> check if a pedestal run has been analyzied
+  int read = 0;
+  read = daqDA_DB_getFile(PEDDATA_FILE,PEDDATA_FILE);
+  if(read){
+    printf("\t ERROR!!! ZDCPedestal.dat file NOT FOUND in DAQ db!!!\n");
     return -1;
   }
-
-
-  /* declare monitoring program */
-  status = monitorDeclareMp( __FILE__ );
-  if (status!=0) {
-    printf("monitorDeclareMp() failed : %s\n",monitorDecodeError(status));
+  else printf("\t ZDCPedestal.dat file retrieved from DAQ db\n");
+  
+  FILE *filePed = fopen(PEDDATA_FILE,"r");
+  if (filePed==NULL) {
+    printf("\t ERROR!!! Can't open ZDCPedestal.dat file!!!\n");
     return -1;
   }
 
+  // 144 = 48 in-time + 48 out-of-time + 48 correlations
+  Float_t readValues[2][144], MeanPed[44], MeanPedWidth[44], 
+       MeanPedOOT[44], MeanPedWidthOOT[44];
+  // ***************************************************
+  //   Unless we have a narrow correlation to fit we
+  //   don't fit and store in-time vs. out-of-time
+  //   histograms -> mean pedstal subtracted!!!!!!
+  // ***************************************************
+  //Float_t CorrCoeff0[44], CorrCoeff1[44];
+  //
+  for(int jj=0; jj<144; jj++){
+    for(int ii=0; ii<2; ii++){
+       fscanf(filePed,"%f",&readValues[ii][jj]);
+    }
+    if(jj<48){
+      MeanPed[jj] = readValues[0][jj];
+      MeanPedWidth[jj] = readValues[1][jj];
+      //printf("\t MeanPed[%d] = %1.1f\n",jj, MeanPed[jj]);
+    }
+    else if(jj>48 && jj<96){
+      MeanPedOOT[jj-48] = readValues[0][jj];
+      MeanPedWidthOOT[jj-48] = readValues[1][jj];
+    }
+    /*else if(jj>144){
+      CorrCoeff0[jj-96] = readValues[0][jj]; 
+      CorrCoeff1[jj-96] = readValues[1][jj];;
+    }
+    */
+  }
 
-  /* define wait event timeout - 1s max */
-  monitorSetNowait();
-  monitorSetNoWaitNetworkTimeout(1000);
-  
-
-  /* log start of process */
-  printf("ZDC EMD monitoring program started\n");  
-  
   /* report progress */
   daqDA_progressReport(10);
 
@@ -185,6 +209,8 @@ int main(int argc, char **argv) {
       
       Int_t ich=0, adcMod[48], adcCh[48], sigCode[48], det[48], sec[48];
       if(eventT==START_OF_DATA){
+
+       rawStreamZDC->SetSODReading(kTRUE);
                
        if(!rawStreamZDC->Next()) printf(" \t No raw data found!! \n");
         else{
@@ -201,7 +227,7 @@ int main(int argc, char **argv) {
        }
        // --------------------------------------------------------
        // --- Writing ascii data file for the Shuttle preprocessor
-        mapFile4Shuttle = fopen(mapfName,"w");
+        mapFile4Shuttle = fopen(MAPDATA_FILE,"w");
         for(Int_t i=0; i<ich; i++){
           fprintf(mapFile4Shuttle,"\t%d\t%d\t%d\t%d\t%d\t%d\n",i,
             adcMod[i],adcCh[i],sigCode[i],det[i],sec[i]);
@@ -213,41 +239,8 @@ int main(int argc, char **argv) {
       }
     
     if(eventT==PHYSICS_EVENT){
-      //
-      // *** To analyze EMD events you MUST have a pedestal data file!!!
-      // *** -> check if a pedestal run has been analyzied
-      FILE *filePed=NULL;
-      filePed=fopen("./ZDCPedestal.dat","r");
-      if (filePed==NULL) {
-        printf("\t ERROR!!! You MUST have a ZDCPedestal.dat file!!!\n");
-        return -1;
-      }
-      // 144 = 48 in-time + 48 out-of-time + 48 correlations
-      Float_t readValues[2][144], MeanPed[44], MeanPedWidth[44], 
-             MeanPedOOT[44], MeanPedWidthOOT[44],
-             CorrCoeff0[44], CorrCoeff1[44];
-      //
-      for(int jj=0; jj<144; jj++){
-        for(int ii=0; ii<2; ii++){
-           fscanf(filePed,"%f",&readValues[ii][jj]);
-        }
-       if(jj<48){
-         MeanPed[jj] = readValues[0][jj];
-         MeanPedWidth[jj] = readValues[1][jj];
-       }
-       else if(jj>48 && jj<96){
-         MeanPedOOT[jj-48] = readValues[0][jj];
-         MeanPedWidthOOT[jj-48] = readValues[1][jj];
-       }
-       else if(jj>144){
-         CorrCoeff0[jj-96] = readValues[0][jj]; 
-         CorrCoeff1[jj-96] = readValues[1][jj];;
-       }
-      }
-      //
-
-       // --- Reading data header
-        reader->ReadHeader();
+      // --- Reading data header
+      reader->ReadHeader();
       const AliRawDataHeader* header = reader->GetDataHeader();
       if(header){
          UChar_t message = header->GetAttributes();
@@ -264,6 +257,8 @@ int main(int argc, char **argv) {
          printf("\t ATTENTION! No Raw Data Header found!!!\n");
          return -1;
       }
+      
+      rawStreamZDC->SetSODReading(kTRUE);
 
       if (!rawStreamZDC->Next()) printf(" \t No raw data found!! ");
       //
@@ -341,8 +336,7 @@ int main(int argc, char **argv) {
   /* Analysis of the histograms */
   //
   FILE *fileShuttle;
-  const char *fName = "ZDCPedestal.dat";
-  fileShuttle = fopen(fName,"w");
+  fileShuttle = fopen(EMDDATA_FILE,"w");
   //
   Int_t BinMax[4];
   Float_t YMax[4];
@@ -360,19 +354,28 @@ int main(int argc, char **argv) {
      //printf("\n\t Mean Value from gaussian fit = %f\n", MeanFitVal[k]);
   }
   //
-   Float_t CalibCoeff[6];
-  /*for(Int_t j=0; j<6; j++){
-     if(j<4) CalibCoeff[j] = MeanFitVal[j];
-     else  CalibCoeff[j] = 1.;
-     fprintf(fileShuttle,"\t%f\n",CalibCoeff[j]);
-  }
-  */
-  // --- For the moment we have sim data only for ZN1!!!
-  for(Int_t j=0; j<6; j++){
-     if(j==0) CalibCoeff[j] = MeanFitVal[j];
-     else if(j>0 && j<4) CalibCoeff[j] = CalibCoeff[0];
-     else  CalibCoeff[j] = 1.;
-     fprintf(fileShuttle,"\t%f\n",CalibCoeff[j]);
+  Float_t CalibCoeff[6];     
+  Float_t icoeff[5];
+  //
+  for(Int_t j=0; j<10; j++){
+     if(j<4){
+       CalibCoeff[j] = MeanFitVal[j];
+       fprintf(fileShuttle,"\t%f\n",CalibCoeff[j]);
+     }
+     // ZEM calib. coeff. = 1
+     else if(j==4 || j==5){
+       CalibCoeff[j] = 1.; 
+       fprintf(fileShuttle,"\t%f\n",CalibCoeff[j]);
+     }
+     // Note -> For the moment the inter-calibration
+     //             coefficients are set to 1 
+     else if(j>5){
+       for(Int_t k=0; k<5; k++){  
+         icoeff[k] = 1.;
+         fprintf(fileShuttle,"\t%f",icoeff[k]);
+         if(k==4) fprintf(fileShuttle,"\n");
+       }
+     }
   }
   //                                                  
   fclose(fileShuttle);
@@ -395,13 +398,13 @@ int main(int argc, char **argv) {
   daqDA_progressReport(90);
 
   /* store the result file on FES */
-  status = daqDA_FES_storeFile(mapfName,"ZDCCHMAPPING_data");
+  status = daqDA_FES_storeFile(MAPDATA_FILE, MAPDATA_FILE);
   if(status){
     printf("Failed to export file : %d\n",status);
     return -1;
   }
   //
-  status = daqDA_FES_storeFile(fName,"ZDCEMD_data");
+  status = daqDA_FES_storeFile(EMDDATA_FILE, EMDDATA_FILE);
   if(status){
     printf("Failed to export file : %d\n",status);
     return -1;