]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ZDC/ZDCPEDESTALda.cxx
Change in comment
[u/mrichter/AliRoot.git] / ZDC / ZDCPEDESTALda.cxx
index 56a78084ed2c148543c6fbd86490f561c47afcc4..b5f81de51b4a2e03d337b769e23b592a98e896c0 100644 (file)
@@ -2,7 +2,6 @@
 
 This program reads the DAQ data files passed as argument using the monitoring library.
 
 
 This program reads the DAQ data files passed as argument using the monitoring library.
 
-
 The program reports about its processing progress.
 
 Messages on stdout are exported to DAQ log system.
 The program reports about its processing progress.
 
 Messages on stdout are exported to DAQ log system.
@@ -14,7 +13,7 @@ Link:
 Run Type: STANDALONE_PEDESTAL_RUN
 DA Type: LDC
 Number of events needed: no constraint (tipically ~10^3)
 Run Type: STANDALONE_PEDESTAL_RUN
 DA Type: LDC
 Number of events needed: no constraint (tipically ~10^3)
-Input Files:  
+Input Files: none
 Output Files: ZDCPedestal.dat, ZDCChMapping.dat
 Trigger Types Used: Standalone Trigger
 
 Output Files: ZDCPedestal.dat, ZDCChMapping.dat
 Trigger Types Used: Standalone Trigger
 
@@ -67,7 +66,38 @@ int main(int argc, char **argv) {
   TVirtualFitter::SetDefaultFitter("Minuit");
 
   int status = 0;
   TVirtualFitter::SetDefaultFitter("Minuit");
 
   int status = 0;
+  int const kNModules = 9;
   int const kNChannels = 24;
   int const kNChannels = 24;
+  int const kNScChannels = 32;
+  Int_t kFirstADCGeo=0, kLastADCGeo=3;
+      
+  Int_t iMod=-1;
+  Int_t modGeo[kNModules], modType[kNModules],modNCh[kNModules];
+  for(Int_t kl=0; kl<kNModules; kl++){
+     modGeo[kl]=modType[kl]=modNCh[kl]=0;
+  }
+  
+  Int_t ich=0;
+  Int_t adcMod[2*kNChannels], adcCh[2*kNChannels], sigCode[2*kNChannels];
+  Int_t det[2*kNChannels], sec[2*kNChannels];
+  for(Int_t y=0; y<2*kNChannels; y++){
+    adcMod[y]=adcCh[y]=sigCode[y]=det[y]=sec[y]=0;
+  }
+  
+  Int_t iScCh=0;
+  Int_t scMod[kNScChannels], scCh[kNScChannels], scSigCode[kNScChannels];
+  Int_t scDet[kNScChannels], scSec[kNScChannels];
+  for(Int_t y=0; y<kNScChannels; y++){
+    scMod[y]=scCh[y]=scSigCode[y]=scDet[y]=scSec[y]=0;
+  }
+      
+  Int_t itdcCh=0;
+  Int_t tdcMod[kNScChannels], tdcCh[kNScChannels], tdcSigCode[kNScChannels];
+  Int_t tdcDet[kNScChannels], tdcSec[kNScChannels];
+  for(Int_t y=0; y<kNScChannels; y++){
+    tdcMod[y]=tdcCh[y]=tdcSigCode[y]=tdcDet[y]=tdcSec[y]=-1;
+  }
+       
 
   /* log start of process */
   printf("\n ZDC PEDESTAL program started\n");  
 
   /* log start of process */
   printf("\n ZDC PEDESTAL program started\n");  
@@ -110,13 +140,13 @@ int main(int argc, char **argv) {
        sprintf(namhist3lg,"PedCorrZPClg_%d",j-5);       
      }
      else if(j==10 || j==11){ // ZEM
        sprintf(namhist3lg,"PedCorrZPClg_%d",j-5);       
      }
      else if(j==10 || j==11){ // ZEM
-       sprintf(namhist1hg,"PedZEMhg_%d",j-10);
-       sprintf(namhist2hg,"PedZEMhgOutOfTime_%d",j-10);
-       sprintf(namhist3hg,"PedCorrZEMhg_%d",j-10);
+       sprintf(namhist1hg,"PedZEMhg_%d",j-9);
+       sprintf(namhist2hg,"PedZEMhgOutOfTime_%d",j-9);
+       sprintf(namhist3hg,"PedCorrZEMhg_%d",j-9);
        //
        //
-       sprintf(namhist1lg,"PedZEMlg_%d",j-10);
-       sprintf(namhist2lg,"PedZEMlgOutOfTime_%d",j-10);
-       sprintf(namhist3lg,"PedCorrZEMlg_%d",j-10);
+       sprintf(namhist1lg,"PedZEMlg_%d",j-9);
+       sprintf(namhist2lg,"PedZEMlgOutOfTime_%d",j-9);
+       sprintf(namhist3lg,"PedCorrZEMlg_%d",j-9);
      }
      else if(j>=12 && j<=16){ // ZNA
        sprintf(namhist1hg,"PedZNAhg_%d",j-12);
      }
      else if(j>=12 && j<=16){ // ZNA
        sprintf(namhist1hg,"PedZNAhg_%d",j-12);
@@ -136,7 +166,7 @@ int main(int argc, char **argv) {
        sprintf(namhist2lg,"PedZPAlgOutOfTime_%d",j-17);
        sprintf(namhist3lg,"PedCorrZPAlg_%d",j-17);
      }
        sprintf(namhist2lg,"PedZPAlgOutOfTime_%d",j-17);
        sprintf(namhist3lg,"PedCorrZPAlg_%d",j-17);
      }
-     else if(j==22 || j==24){ //Reference PMs
+     else if(j==22 || j==23){ //Reference PMs
        sprintf(namhist1hg,"PedRefhg_%d",j-22);
        sprintf(namhist2hg,"PedRefhgOutOfTime_%d",j-22);
        sprintf(namhist3hg,"PedCorrRefhg_%d",j-22);
        sprintf(namhist1hg,"PedRefhg_%d",j-22);
        sprintf(namhist2hg,"PedRefhgOutOfTime_%d",j-22);
        sprintf(namhist3hg,"PedCorrRefhg_%d",j-22);
@@ -150,9 +180,9 @@ int main(int argc, char **argv) {
      hPedOutOfTimehg[j] = new TH1F(namhist2hg, namhist2hg, 200, 0., 200.);
      hPedCorrhg[j] = new TH2F(namhist3hg,namhist3hg,100,0.,200.,100,0.,200.);
      // --- Low gain chain histos
      hPedOutOfTimehg[j] = new TH1F(namhist2hg, namhist2hg, 200, 0., 200.);
      hPedCorrhg[j] = new TH2F(namhist3hg,namhist3hg,100,0.,200.,100,0.,200.);
      // --- Low gain chain histos
-     hPedlg[j] = new TH1F(namhist1lg, namhist1lg, 100, 0., 1000.);
-     hPedOutOfTimelg[j] = new TH1F(namhist2lg, namhist2lg, 100, 0., 1000.);
-     hPedCorrlg[j] = new TH2F(namhist3lg,namhist3lg,100,0.,1000.,100,0.,1000.);
+     hPedlg[j] = new TH1F(namhist1lg, namhist1lg, 100, 0., 1500.);
+     hPedOutOfTimelg[j] = new TH1F(namhist2lg, namhist2lg, 100, 0., 1500.);
+     hPedCorrlg[j] = new TH2F(namhist3lg,namhist3lg,100,0.,1500.,100,0.,1500.);
   }
 
 
   }
 
 
@@ -174,6 +204,9 @@ int main(int argc, char **argv) {
   int nevents_physics=0;
   int nevents_total=0;
 
   int nevents_physics=0;
   int nevents_total=0;
 
+  struct eventHeaderStruct *event;
+  eventTypeType eventT;
+
   /* read the data files */
   int n;
   for(n=1;n<argc;n++){
   /* read the data files */
   int n;
   for(n=1;n<argc;n++){
@@ -190,8 +223,6 @@ int main(int argc, char **argv) {
 
     /* read the file */
     for(;;) {
 
     /* read the file */
     for(;;) {
-      struct eventHeaderStruct *event;
-      eventTypeType eventT;
 
       /* get next event */
       status=monitorGetEventDynamic((void **)&event);
 
       /* get next event */
       status=monitorGetEventDynamic((void **)&event);
@@ -220,12 +251,10 @@ int main(int argc, char **argv) {
       /* use event - here, just write event id to result file */
       eventT=event->eventType;
       
       /* use event - here, just write event id to result file */
       eventT=event->eventType;
       
-      Int_t ich=0;
-      Int_t adcMod[2*kNChannels], adcCh[2*kNChannels], sigCode[2*kNChannels];
-      Int_t det[2*kNChannels], sec[2*kNChannels];
-      
       if(eventT==START_OF_DATA){
       if(eventT==START_OF_DATA){
-               
+       
+       iMod=-1; ich=0; iScCh=0; itdcCh=0;
+                       
        rawStreamZDC->SetSODReading(kTRUE);
        
        // --------------------------------------------------------
        rawStreamZDC->SetSODReading(kTRUE);
        
        // --------------------------------------------------------
@@ -233,38 +262,80 @@ int main(int argc, char **argv) {
         mapFile4Shuttle = fopen(MAPDATA_FILE,"w");
        if(!rawStreamZDC->Next()) printf(" \t No raw data found!! \n");
         else{
         mapFile4Shuttle = fopen(MAPDATA_FILE,"w");
        if(!rawStreamZDC->Next()) printf(" \t No raw data found!! \n");
         else{
-         while((rawStreamZDC->Next()) && (ich<2*kNChannels)){
-            if(rawStreamZDC->IsChMapping()){
-             adcMod[ich] = rawStreamZDC->GetADCModFromMap(ich);
-             adcCh[ich] = rawStreamZDC->GetADCChFromMap(ich);
-             sigCode[ich] = rawStreamZDC->GetADCSignFromMap(ich);
-             det[ich] = rawStreamZDC->GetDetectorFromMap(ich);
-             sec[ich] = rawStreamZDC->GetTowerFromMap(ich);
-             //
-             fprintf(mapFile4Shuttle,"\t%d\t%d\t%d\t%d\t%d\t%d\n",
-               ich,adcMod[ich],adcCh[ich],sigCode[ich],det[ich],sec[ich]);
-             //
-             //printf("ZDCPEDESTALda.cxx -> %d mod %d ch %d, code %d det %d, sec %d\n",
-             //   ich,adcMod[ich],adcCh[ich],sigCode[ich],det[ich],sec[ich]);
-             //
-             ich++;
+         while((rawStreamZDC->Next())){
+            if(rawStreamZDC->IsHeaderMapping()){ // mapping header
+              iMod++;
+              modGeo[iMod]  = rawStreamZDC->GetADCModule();
+              modType[iMod] = rawStreamZDC->GetModType();
+              modNCh[iMod]  = rawStreamZDC->GetADCNChannels();
+           }
+            if(rawStreamZDC->IsChMapping()){ 
+             if(modType[iMod]==1){ // ADC mapping ----------------------
+               adcMod[ich]  = rawStreamZDC->GetADCModFromMap(ich);
+               adcCh[ich]   = rawStreamZDC->GetADCChFromMap(ich);
+               sigCode[ich] = rawStreamZDC->GetADCSignFromMap(ich);
+               det[ich]     = rawStreamZDC->GetDetectorFromMap(ich);
+               sec[ich]     = rawStreamZDC->GetTowerFromMap(ich);
+               ich++;
+             }
+             else if(modType[iMod]==2){ //VME scaler mapping --------------------
+               scMod[iScCh]     = rawStreamZDC->GetScalerModFromMap(iScCh);
+               scCh[iScCh]      = rawStreamZDC->GetScalerChFromMap(iScCh);
+               scSigCode[iScCh] = rawStreamZDC->GetScalerSignFromMap(iScCh);
+               scDet[iScCh]     = rawStreamZDC->GetScDetectorFromMap(iScCh);
+               scSec[iScCh]     = rawStreamZDC->GetScTowerFromMap(iScCh);
+               iScCh++;
+             }
+             else if(modType[iMod]==6 && modGeo[iMod]==4){ // ZDC TDC mapping --------------------
+               tdcMod[itdcCh]     = rawStreamZDC->GetTDCModFromMap(itdcCh);
+               tdcCh[itdcCh]      = rawStreamZDC->GetTDCChFromMap(itdcCh);
+               tdcSigCode[itdcCh] = rawStreamZDC->GetTDCSignFromMap(itdcCh);
+               itdcCh++;
+             }
            }
            }
+         }
+         // Writing data on output FXS file
+         for(Int_t is=0; is<2*kNChannels; is++){
+            fprintf(mapFile4Shuttle,"\t%d\t%d\t%d\t%d\t%d\t%d\n",
+              is,adcMod[is],adcCh[is],sigCode[is],det[is],sec[is]);
+            //printf("  Pedestal DA -> %d ADC: mod %d ch %d, code %d det %d, sec %d\n",
+            //  is,adcMod[is],adcCh[is],sigCode[is],det[is],sec[is]);
          }
          }
+         for(Int_t is=0; is<kNScChannels; is++){
+            fprintf(mapFile4Shuttle,"\t%d\t%d\t%d\t%d\t%d\t%d\n",
+              is,scMod[is],scCh[is],scSigCode[is],scDet[is],scSec[is]);
+            //printf("  Pedestal DA -> %d Scaler: mod %d ch %d, code %d det %d, sec %d\n",
+            //  is,scMod[is],scCh[is],scSigCode[is],scDet[is],scSec[is]);
+         }
+         for(Int_t is=0; is<kNScChannels; is++){
+            fprintf(mapFile4Shuttle,"\t%d\t%d\t%d\t%d\n",
+              is,tdcMod[is],tdcCh[is],tdcSigCode[is]);
+            //if(tdcMod[is]!=-1) printf("  Mapping DA -> %d TDC: mod %d ch %d, code %d\n",
+            //  is,tdcMod[is],tdcCh[is],tdcSigCode[is]);
+         }
+         for(Int_t is=0; is<kNModules; is++){
+            fprintf(mapFile4Shuttle,"\t%d\t%d\t%d\n",
+            modGeo[is],modType[is],modNCh[is]);
+            //printf("  Pedestal DA -> Module mapping: geo %d type %d #ch %d\n",
+            //  modGeo[is],modType[is],modNCh[is]);
+         }
+         
        }
         fclose(mapFile4Shuttle);
       }// SOD event
       
        }
         fclose(mapFile4Shuttle);
       }// SOD event
       
-      if(eventT==PHYSICS_EVENT){
+      else if(eventT==PHYSICS_EVENT){
        // --- Reading data header
         reader->ReadHeader();
         const AliRawDataHeader* header = reader->GetDataHeader();
         if(header){
          UChar_t message = header->GetAttributes();
        // --- Reading data header
         reader->ReadHeader();
         const AliRawDataHeader* header = reader->GetDataHeader();
         if(header){
          UChar_t message = header->GetAttributes();
-         if(message & 0x20){ // PEDESTAL RUN
+         if((message & 0x20) == 0x20){ // PEDESTAL RUN
             //printf("\t STANDALONE_PEDESTAL RUN raw data found\n");
          }
          else{
             printf("ZDCPEDESTALda.cxx -> NO STANDALONE_PEDESTAL RUN raw data found\n");
             //printf("\t STANDALONE_PEDESTAL RUN raw data found\n");
          }
          else{
             printf("ZDCPEDESTALda.cxx -> NO STANDALONE_PEDESTAL RUN raw data found\n");
+           printf("   CDH attributes: %x\n", message);
             return -1;
          }
         }
             return -1;
          }
         }
@@ -300,8 +371,12 @@ int main(int argc, char **argv) {
         Int_t index=-1;
         Int_t detector = rawStreamZDC->GetSector(0);
         Int_t sector = rawStreamZDC->GetSector(1);
         Int_t index=-1;
         Int_t detector = rawStreamZDC->GetSector(0);
         Int_t sector = rawStreamZDC->GetSector(1);
+        //
+        //printf(" rawData: det %d sec %d  value %d\n", 
+        //     detector, sector,rawStreamZDC->GetADCGain(),rawStreamZDC->GetADCValue() );
         
         
-        if(rawStreamZDC->IsADCDataWord() && (detector!=-1)){
+        if((rawStreamZDC->IsADCDataWord()) && (detector!=-1) &&
+            (rawStreamZDC->GetADCModule()>=kFirstADCGeo && rawStreamZDC->GetADCModule()<=kLastADCGeo)){
          if(sector!=5){ // Physics signals
            if(detector==1) index = sector; // *** ZNC
            else if(detector==2) index = sector+5; // *** ZPC
          if(sector!=5){ // Physics signals
            if(detector==1) index = sector; // *** ZNC
            else if(detector==2) index = sector+5; // *** ZPC
@@ -313,8 +388,8 @@ int main(int argc, char **argv) {
            index = (detector-1)/3+22;
          }
          //
            index = (detector-1)/3+22;
          }
          //
-         if(index==-1) printf("ERROR in ZDCPEDESTALda.cxx -> det %d quad %d res %d index %d \n", 
-           detector,sector,rawStreamZDC->GetADCGain(),index);
+         if(index==-1) printf("ERROR in ZDCPEDESTALda.cxx -> det %d quad %d index %d \n", 
+           detector,sector,index);
          
           //
           if(iraw<2*kNChannels){ // --- In-time pedestals (1st 48 raw data)
          
           //
           if(iraw<2*kNChannels){ // --- In-time pedestals (1st 48 raw data)
@@ -347,27 +422,34 @@ int main(int argc, char **argv) {
           }
            iraw++;
          }//IsADCDataWord()
           }
            iraw++;
          }//IsADCDataWord()
-         //
-         if(iraw == 4*kNChannels){ // Last ADC channel -> Filling correlation histos
-           for(Int_t k=0; k<kNChannels; k++){
-             hPedCorrhg[k]->Fill(RawADCoothg[k], RawADChg[k]);
-             hPedCorrlg[k]->Fill(RawADCootlg[k], RawADClg[k]);
-           }
+        }
+       //
+       if(iraw==4*kNChannels ){ // Last ADC channel -> Filling correlation histos
+         for(Int_t k=0; k<kNChannels; k++){
+           hPedCorrhg[k]->Fill(RawADCoothg[k], RawADChg[k]);
+           hPedCorrlg[k]->Fill(RawADCootlg[k], RawADClg[k]);
          }
          }
-         }
-         //
-         nevents_physics++;
-         //
-        delete reader;
-         delete rawStreamZDC;
+          //printf(" ev. %d -> Filling correlation histo %d\n",nevents_physics, kNChannels);
+       }
+        nevents_physics++;
+        //
+       delete reader;
+        delete rawStreamZDC;
 
       }//(if PHYSICS_EVENT) 
 
       }//(if PHYSICS_EVENT) 
+      
+      /* exit when last event received, no need to wait for TERM signal */
+      else if(eventT==END_OF_RUN) {
+        printf(" -> EOR event detected\n");
+        break;
+      }
+      
       nevents_total++;
       nevents_total++;
-
-      /* free resources */
-      free(event);
     
     }
     
     }
+         
+    /* free resources */
+    free(event);
   }  
   
   /* Analysis of the histograms */
   }  
   
   /* Analysis of the histograms */
@@ -403,6 +485,10 @@ int main(int argc, char **argv) {
   // --- Out-of-time pedestals
   TF1 *ADCootfunchg[kNChannels];
   for(Int_t i=0; i<kNChannels; i++){
   // --- Out-of-time pedestals
   TF1 *ADCootfunchg[kNChannels];
   for(Int_t i=0; i<kNChannels; i++){
+     if(hPedOutOfTimehg[i]->GetEntries() == 0){
+       printf("\n WARNING! Empty histos for out-of-time channels!!!\n\n");
+       return -1;
+     } 
      hPedOutOfTimehg[i]->Fit("gaus","Q");
      ADCootfunchg[i] = hPedOutOfTimehg[i]->GetFunction("gaus");
      MeanPedOOT[i] = (Double_t)  ADCootfunchg[i]->GetParameter(1);
      hPedOutOfTimehg[i]->Fit("gaus","Q");
      ADCootfunchg[i] = hPedOutOfTimehg[i]->GetFunction("gaus");
      MeanPedOOT[i] = (Double_t)  ADCootfunchg[i]->GetParameter(1);
@@ -421,35 +507,57 @@ int main(int argc, char **argv) {
   }
   
   // --- Correlations
   }
   
   // --- Correlations
-
-/*  Float_t CorrCoeff0[2*kNChannels], CorrCoeff1[2*kNChannels];
+  Float_t CorrCoeff0[2*kNChannels], CorrCoeff1[2*kNChannels];
   TProfile *hPedCorrProfhg[kNChannels], *hPedCorrProflg[kNChannels];
   TF1 *ffunchg[kNChannels], *ffunclg[kNChannels];
   char namhist4[50];
   for(int i=0;i<kNChannels;i++) {
   TProfile *hPedCorrProfhg[kNChannels], *hPedCorrProflg[kNChannels];
   TF1 *ffunchg[kNChannels], *ffunclg[kNChannels];
   char namhist4[50];
   for(int i=0;i<kNChannels;i++) {
+    if(i==0 || i==7 || i== 10 || i==11){
      sprintf(namhist4,"ADCHRvsOOT%d_Prof",i);
      hPedCorrProfhg[i] = hPedCorrhg[i]->ProfileX(namhist4,-1,-1,"S");
      hPedCorrProfhg[i]->SetName(namhist4);
      sprintf(namhist4,"ADCHRvsOOT%d_Prof",i);
      hPedCorrProfhg[i] = hPedCorrhg[i]->ProfileX(namhist4,-1,-1,"S");
      hPedCorrProfhg[i]->SetName(namhist4);
-     hPedCorrProfhg[i]->Fit("pol1","Q");
-     ffunchg[i] = hPedCorrProfhg[i]->GetFunction("pol1");
-     CorrCoeff0[i] = (Double_t)  ffunchg[i]->GetParameter(0);
-     CorrCoeff1[i] = (Double_t) ffunchg[i]->GetParameter(1);
-     fprintf(fileShuttle,"\t%f\t%f\n",CorrCoeff0[i],CorrCoeff1[i]);
-     //printf("\t CorrCoeff0[%d] = %f, CorrCoeff1[%d] = %f\n",i, CorrCoeff0[i], i, CorrCoeff1[i]);
+     if(hPedCorrProfhg[i]->GetEntries()!=0){
+       hPedCorrProfhg[i]->Fit("pol1","Q");
+       ffunchg[i] = hPedCorrProfhg[i]->GetFunction("pol1");
+       CorrCoeff0[i] = (Double_t)  ffunchg[i]->GetParameter(0);
+       CorrCoeff1[i] = (Double_t) ffunchg[i]->GetParameter(1);
+       //printf("\t CorrCoeff0[%d] = %f, CorrCoeff1[%d] = %f\n",i, CorrCoeff0[i], i, CorrCoeff1[i]);
+     }
+     else{
+       printf(" Warning -> Correlation for high range ch. %d has no entry and can't be fitted!\n",i);
+     }
+    }
+    else{
+       CorrCoeff0[i] = 0.;
+       CorrCoeff1[i] = 0.;
+    }
+    fprintf(fileShuttle,"\t%f\t%f\n",CorrCoeff0[i],CorrCoeff1[i]);
+     
   }    
   for(int i=0;i<kNChannels;i++) {
   }    
   for(int i=0;i<kNChannels;i++) {
+    if(i==0 || i==7 || i== 10 || i==11){
      sprintf(namhist4,"ADCLRvsOOT%d_Prof",i);
      hPedCorrProflg[i] = hPedCorrlg[i]->ProfileX(namhist4,-1,-1,"S");
      hPedCorrProflg[i]->SetName(namhist4);
      sprintf(namhist4,"ADCLRvsOOT%d_Prof",i);
      hPedCorrProflg[i] = hPedCorrlg[i]->ProfileX(namhist4,-1,-1,"S");
      hPedCorrProflg[i]->SetName(namhist4);
-     hPedCorrProflg[i]->Fit("pol1","Q");
-     ffunclg[i] = hPedCorrProflg[i]->GetFunction("pol1");
-     CorrCoeff0[i+kNChannels] =  (Double_t) ffunclg[i]->GetParameter(0);
-     CorrCoeff1[i+kNChannels] =  (Double_t) ffunclg[i]->GetParameter(1);
-     fprintf(fileShuttle,"\t%f\t%f\n",CorrCoeff0[i+kNChannels],CorrCoeff1[i+kNChannels]);
-     //printf("\t CorrCoeff0[%d] = %f, CorrCoeff1[%d] = %f\n",
-     //                i+kNChannels, CorrCoeff0[i+kNChannels], i+kNChannels, CorrCoeff1[i+kNChannels]);
+     if(hPedCorrProflg[i]->GetEntries()!=0){
+       hPedCorrProflg[i]->Fit("pol1","Q");
+       ffunclg[i] = hPedCorrProflg[i]->GetFunction("pol1");
+       CorrCoeff0[i+kNChannels] =  (Double_t) ffunclg[i]->GetParameter(0);
+       CorrCoeff1[i+kNChannels] =  (Double_t) ffunclg[i]->GetParameter(1);
+       //printf("\t CorrCoeff0[%d] = %f, CorrCoeff1[%d] = %f\n",
+       //              i+kNChannels, CorrCoeff0[i+kNChannels], i+kNChannels, CorrCoeff1[i+kNChannels]);
+     }
+     else{
+       printf(" Warning -> Correlation for low range ch. %d has no entry and can't be fitted!\n",i);
+     }
+    }
+    else{
+       CorrCoeff0[i+kNChannels] = 0.;
+       CorrCoeff1[i+kNChannels] = 0.;
+    }
+    fprintf(fileShuttle,"\t%f\t%f\n",CorrCoeff0[i+kNChannels],CorrCoeff1[i+kNChannels]);
   }    
   }    
-*/
+
   //                                                  
   fclose(fileShuttle);
   //
   //                                                  
   fclose(fileShuttle);
   //
@@ -489,26 +597,26 @@ int main(int argc, char **argv) {
 
   /* store the result files on FES */
   // [1] File with mapping
 
   /* store the result files on FES */
   // [1] File with mapping
-  status = daqDA_FES_storeFile(MAPDATA_FILE,MAPDATA_FILE);
+  status = daqDA_FES_storeFile(MAPDATA_FILE, "MAPPING");
   if(status){
     printf("Failed to export mapping data file to DAQ FES\n");
     return -1;
   }
   // [2] File with pedestal data
   if(status){
     printf("Failed to export mapping data file to DAQ FES\n");
     return -1;
   }
   // [2] File with pedestal data
-  status = daqDA_FES_storeFile(PEDDATA_FILE,PEDDATA_FILE);
+  status = daqDA_FES_storeFile(PEDDATA_FILE, "PEDESTALDATA");
   if(status){
     printf("Failed to export pedestal data file to DAQ FES\n");
     return -1;
   }
   // [3] File with pedestal histos
   if(status){
     printf("Failed to export pedestal data file to DAQ FES\n");
     return -1;
   }
   // [3] File with pedestal histos
-  status = daqDA_FES_storeFile(PEDHISTO_FILE,PEDHISTO_FILE);
+  status = daqDA_FES_storeFile(PEDHISTO_FILE, "PEDESTALHISTOS");
   if(status){
     printf("Failed to export pedestal histos file to DAQ FES\n");
     return -1;
   }
   
   /* store the result files on DB */
   if(status){
     printf("Failed to export pedestal histos file to DAQ FES\n");
     return -1;
   }
   
   /* store the result files on DB */
-  status = daqDA_DB_storeFile(PEDDATA_FILE,PEDDATA_FILE);  
+  status = daqDA_DB_storeFile(PEDDATA_FILE, PEDDATA_FILE);  
   if(status){
     printf("Failed to store pedestal data file to DAQ DB\n");
     return -1;
   if(status){
     printf("Failed to store pedestal data file to DAQ DB\n");
     return -1;