]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ZDC/ZDCPEDESTALda.cxx
Bug #92237 fixed as Barth suggested
[u/mrichter/AliRoot.git] / ZDC / ZDCPEDESTALda.cxx
index 196078b9dc14f5e5af703367d36a56b43d3bf232..8f5b4b043dc5e3c209ae7d2b6c441f1c15a8268b 100644 (file)
@@ -90,6 +90,14 @@ int main(int argc, char **argv) {
   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");  
@@ -172,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
-     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.);
   }
 
 
@@ -245,7 +253,7 @@ int main(int argc, char **argv) {
       
       if(eventT==START_OF_DATA){
        
-       iMod=-1; ich=0; iScCh=0;
+       iMod=-1; ich=0; iScCh=0; itdcCh=0;
                        
        rawStreamZDC->SetSODReading(kTRUE);
        
@@ -278,6 +286,12 @@ int main(int argc, char **argv) {
                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
@@ -293,6 +307,12 @@ int main(int argc, char **argv) {
             //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]);
@@ -487,36 +507,57 @@ int main(int argc, char **argv) {
   }
   
   // --- Correlations
-  // NB -> The correlations are NOT fitted since at the moment
-  // (Sptember 2009) they are NOT correlations and the DA would fail!!!
-/*  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++) {
+    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);
-     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++) {
+    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);
-     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);
   //