]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ZDC/ZDCLASERda.cxx
Updated DAs for LASER and EMD runs
[u/mrichter/AliRoot.git] / ZDC / ZDCLASERda.cxx
index f98068f2bb83db57043c9f4db947736a91ea8ab2..f69e5ceac5abf1de001d042aea88b86c4f955474 100644 (file)
@@ -21,6 +21,7 @@ Output Files: ZDCLaser.dat
 Trigger Types Used: Standalone Trigger
 
 */
+#define PEDDATA_FILE  "ZDCPedestal.dat"
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -55,7 +56,7 @@ int main(int argc, char **argv) {
   int status = 0;
 
   /* log start of process */
-  printf("ZDC LASER program started\n");  
+  printf("\nZDC LASER program started\n");  
 
   /* check that we got some arguments = list of files */
   if (argc<2) {
@@ -67,22 +68,12 @@ int main(int argc, char **argv) {
   //     20 signal channels + 2 reference PTMs
   //
   TH1F::AddDirectory(0);
-  TH1F *hZDCsideC[10], *hZDCsideA[10];
-  char nhistZDCC[50], nhistZDCA[50];
-  for(Int_t j=0; j<10; j++){
-     if(j<5){ // ZNs
-       sprintf(nhistZDCC,"ZNCtow%d",j);
-       sprintf(nhistZDCA,"ZNAtow%d",j);
-     }
-     else if(j>=5 && j<10){ // ZPs
-       sprintf(nhistZDCC,"ZPCtow%d",j);
-       sprintf(nhistZDCA,"ZPAtow%d",j);
-     }
-     hZDCsideC[j] = new TH1F(nhistZDCC, nhistZDCC, 100, 0., 1000.);
-     hZDCsideA[j] = new TH1F(nhistZDCA, nhistZDCA, 100, 0., 1000.);
-  }
-  TH1F *hPMRefsideC = new TH1F("hPMRefsideC","hPMRefsideC", 100,0.,1000.);
-  TH1F *hPMRefsideA = new TH1F("hPMRefsideA","hPMRefsideA", 100,0.,1000.);
+  //
+  TH1F *hPMRefChg = new TH1F("hPMRefChg","hPMRefChg", 100,0.,1000.);
+  TH1F *hPMRefAhg = new TH1F("hPMRefAhg","hPMRefAhg", 100,0.,1000.);
+  //
+  TH1F *hPMRefClg = new TH1F("hPMRefClg","hPMRefClg", 100,0.,4000.);
+  TH1F *hPMRefAlg = new TH1F("hPMRefAlg","hPMRefAlg", 100,0.,4000.);
 
 
   /* open result file */
@@ -95,6 +86,52 @@ int main(int argc, char **argv) {
   
   FILE *mapFile4Shuttle;
   const char *mapfName = "ZDCChMapping.dat";  
+        
+  // *** To analyze LASER events you MUST have a pedestal data file!!!
+  // *** -> check if a pedestal run has been analyzied
+  int read = 0;
+  read = daqDA_FES_storeFile(PEDDATA_FILE,"ZDCPEDESTAL_data");
+  if(read){
+    printf("\t ERROR!!! ZDCPedestal.dat file NOT FOUND in DAQ db!!!\n");
+    return -1;
+  }
+  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];;
+    }
+    */
+  }
 
   /* report progress */
   daqDA_progressReport(10);
@@ -140,9 +177,9 @@ int main(int argc, char **argv) {
       AliRawReader *reader = new AliRawReaderDate((void*)event);
       reader->Select("ZDC");
       // --- Reading event header
-      UInt_t evtype = reader->GetType();
-      //printf("\n\t ZDCPEDESTALda -> ev. type %d\n",evtype);
-      //printf("\t ZDCPEDESTALda -> run # %d\n",reader->GetRunNumber());
+      //UInt_t evtype = reader->GetType();
+      //printf("\n\t ZDCLASERda -> ev. type %d\n",evtype);
+      //printf("\t ZDCLASERda -> run # %d\n",reader->GetRunNumber());
       //
       AliZDCRawStream *rawStreamZDC = new AliZDCRawStream(reader);
         
@@ -173,7 +210,7 @@ int main(int argc, char **argv) {
           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]);
           //
-          //printf("ZDCPEDESTALDA.cxx ->  ch.%d mod %d, ch %d, code %d det %d, sec %d\n",
+          //printf("ZDCLASERDA.cxx ->  ch.%d mod %d, ch %d, code %d det %d, sec %d\n",
           //      i,adcMod[i],adcCh[i],sigCode[i],det[i],sec[i]);
         }
         fclose(mapFile4Shuttle);
@@ -183,37 +220,6 @@ int main(int argc, char **argv) {
       eventT=event->eventType;
     
       if(eventT==PHYSICS_EVENT){
-        //
-        // *** To analyze LASER 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();
@@ -247,24 +253,25 @@ int main(int argc, char **argv) {
        //
        while(rawStreamZDC->Next()){
          Int_t index=-1;
-         // Implemented only for HIGH gain chain
-         if((rawStreamZDC->IsADCDataWord()) && (rawStreamZDC->GetADCGain()==0)){
+         // Getting data only for reference PMTs (sector[1]=5)
+         if((rawStreamZDC->IsADCDataWord()) && (rawStreamZDC->GetSector(1)==5)){
            index = rawStreamZDC->GetADCChannel();
            Float_t Pedestal = MeanPed[index];
            Float_t CorrADC = rawStreamZDC->GetADCValue() - Pedestal;
-           if(rawStreamZDC->GetSector(0)==1){
-             if(rawStreamZDC->GetSector(1)==5) hPMRefsideC->Fill(CorrADC);
-             else hZDCsideC[rawStreamZDC->GetSector(1)]->Fill(CorrADC);
-           }
-           else if(rawStreamZDC->GetSector(0)==2){
-             hZDCsideC[rawStreamZDC->GetSector(1)+5]->Fill(CorrADC);
-           }
-           else if(rawStreamZDC->GetSector(0)==4){
-             if(rawStreamZDC->GetSector(1)==5) hPMRefsideA->Fill(CorrADC);
-             else hZDCsideA[rawStreamZDC->GetSector(1)]->Fill(CorrADC);
+           
+           // ==== HIGH GAIN CHAIN
+           if(rawStreamZDC->GetADCGain() == 0){
+             // %%%%% PMRef chain side C
+             if(rawStreamZDC->GetSector(0)==1) hPMRefChg->Fill(CorrADC);
+             // %%%%% PMRef side A
+             else if(rawStreamZDC->GetSector(0)==4) hPMRefAhg->Fill(CorrADC);
            }
-           else if(rawStreamZDC->GetSector(0)==5){
-             hZDCsideA[rawStreamZDC->GetSector(1)+5]->Fill(CorrADC);
+           // ==== LOW GAIN CHAIN
+           else{
+             // %%%%% PMRef chain side C
+             if(rawStreamZDC->GetSector(0)==1) hPMRefClg->Fill(CorrADC);
+             // %%%%% PMRef side A
+             else if(rawStreamZDC->GetSector(0)==4) hPMRefAlg->Fill(CorrADC);
            }
          }//IsADCDataWord()
          //
@@ -286,81 +293,70 @@ int main(int argc, char **argv) {
   
   /* Analysis of the histograms */
   //
-  Int_t maxBinC[10], maxBinA[10], maxBinRef[2];
-  Int_t nBinC[10], nBinA[10], nBinRef[2];
-  Float_t xMaxC[10], xMaxA[10], xMaxRef[2];
-  Float_t maxXvalC[10], maxXvalA[10], maxXvalRef[2];
-  Float_t xlowC[10], xlowA[10], xlowRef[10]; 
-  TF1 *funA[10], *funC[10], *funRef[2];
+  Int_t maxBinRef[4], nBinRef[4];
+  Float_t xMaxRef[4], maxXvalRef[4], xlowRef[4]; 
+  Float_t meanRef[2], sigmaRef[2];
+  TF1 *funRef[4];
   //
-  Float_t meanC[10], meanA[10], meanRef[2];
-  Float_t sigmaA[10], sigmaC[10], sigmaRef[10];
-  //
-  for(Int_t k=0; k<10; k++){
-     maxBinC[k] = hZDCsideC[k]->GetMaximumBin();
-     nBinC[k] = (hZDCsideC[k]->GetXaxis())->GetNbins();
-     xMaxC[k] = (hZDCsideC[k]->GetXaxis())->GetXmax();
-     maxXvalC[k] = maxBinC[k]*xMaxC[k]/nBinC[k];
-     //
-     if(maxXvalC[k]-100.<0.) {xlowC[k]=0.;}
-     else xlowC[k] = maxXvalC[k];
-     hZDCsideC[k]->Fit("gaus","Q","",xlowC[k],maxXvalC[k]+100.);
-     funC[k] = hZDCsideC[k]->GetFunction("gaus");
-     meanC[k] = (Float_t) (funC[k]->GetParameter(1));
-     sigmaC[k] = (Float_t) (funC[k]->GetParameter(2));
-     //
-     maxBinA[k] = hZDCsideA[k]->GetMaximumBin();
-     nBinA[k] = (hZDCsideA[k]->GetXaxis())->GetNbins();
-     xMaxA[k] = (hZDCsideA[k]->GetXaxis())->GetXmax();
-     maxXvalA[k] = maxBinA[k]*xMaxA[k]/nBinA[k];
-     //
-     if(maxXvalA[k]-100.<0.) {xlowA[k]=0.;}
-     else xlowA[k] = maxXvalA[k];
-     hZDCsideA[k]->Fit("gaus","Q","",xlowA[k],maxXvalA[k]+100.);
-     funA[k] = hZDCsideC[k]->GetFunction("gaus");
-     meanA[k] = (Float_t) (funA[k]->GetParameter(1));
-     sigmaA[k] = (Float_t) (funA[k]->GetParameter(2));
-  }
-  //
-  maxBinRef[0] = hPMRefsideC->GetMaximumBin();
-  nBinRef[0] = (hPMRefsideC->GetXaxis())->GetNbins();
-  xMaxRef[0] = (hPMRefsideC->GetXaxis())->GetXmax();
+  maxBinRef[0] = hPMRefChg->GetMaximumBin();
+  nBinRef[0] = (hPMRefChg->GetXaxis())->GetNbins();
+  xMaxRef[0] = (hPMRefChg->GetXaxis())->GetXmax();
   maxXvalRef[0] = maxBinRef[0]*xMaxRef[0]/nBinRef[0];
   //
   if(maxXvalRef[0]-100.<0.) {xlowRef[0]=0.;}
   else xlowRef[0] = maxXvalRef[0];
-  hPMRefsideC->Fit("gaus","Q","",xlowRef[0],maxXvalRef[0]+100.);
-  funRef[0] = hPMRefsideC->GetFunction("gaus");
+  hPMRefChg->Fit("gaus","Q","",xlowRef[0],maxXvalRef[0]+100.);
+  funRef[0] = hPMRefChg->GetFunction("gaus");
   meanRef[0] = (Float_t) (funRef[0]->GetParameter(1));
   sigmaRef[0] = (Float_t) (funRef[0]->GetParameter(2));
   //
-  maxBinRef[1] = hPMRefsideA->GetMaximumBin();
-  nBinRef[1] = (hPMRefsideA->GetXaxis())->GetNbins();
-  xMaxRef[1] = (hPMRefsideA->GetXaxis())->GetXmax();
+  maxBinRef[1] = hPMRefAhg->GetMaximumBin();
+  nBinRef[1] = (hPMRefAhg->GetXaxis())->GetNbins();
+  xMaxRef[1] = (hPMRefAhg->GetXaxis())->GetXmax();
   maxXvalRef[1] = maxBinRef[1]*xMaxRef[1]/nBinRef[1];
   //
   if(maxXvalRef[1]-100.<0.) {xlowRef[1]=0.;}
   else xlowRef[1] = maxXvalRef[1];
-  hPMRefsideA->Fit("gaus","Q","",xlowRef[1],maxXvalRef[1]+100.);
-  funRef[1] = hPMRefsideA->GetFunction("gaus");
+  hPMRefAhg->Fit("gaus","Q","",xlowRef[1],maxXvalRef[1]+100.);
+  funRef[1] = hPMRefAhg->GetFunction("gaus");
   meanRef[1] = (Float_t) (funRef[1]->GetParameter(1));
   sigmaRef[1] = (Float_t) (funRef[1]->GetParameter(2));
   //
+  maxBinRef[2] = hPMRefClg->GetMaximumBin();
+  nBinRef[2] = (hPMRefClg->GetXaxis())->GetNbins();
+  xMaxRef[2] = (hPMRefClg->GetXaxis())->GetXmax();
+  maxXvalRef[2] = maxBinRef[2]*xMaxRef[2]/nBinRef[2];
+  //
+  if(maxXvalRef[2]-100.<0.) {xlowRef[2]=0.;}
+  else xlowRef[2] = maxXvalRef[2];
+  hPMRefClg->Fit("gaus","Q","",xlowRef[2],maxXvalRef[2]+100.);
+  funRef[2] = hPMRefClg->GetFunction("gaus");
+  meanRef[2] = (Float_t) (funRef[2]->GetParameter(1));
+  sigmaRef[2] = (Float_t) (funRef[2]->GetParameter(2));
+  //
+  maxBinRef[3] = hPMRefAlg->GetMaximumBin();
+  nBinRef[3] = (hPMRefAlg->GetXaxis())->GetNbins();
+  xMaxRef[3] = (hPMRefAlg->GetXaxis())->GetXmax();
+  maxXvalRef[3] = maxBinRef[3]*xMaxRef[3]/nBinRef[3];
+  //
+  if(maxXvalRef[3]-100.<0.) {xlowRef[3]=0.;}
+  else xlowRef[3] = maxXvalRef[3];
+  hPMRefAlg->Fit("gaus","Q","",xlowRef[3],maxXvalRef[3]+100.);
+  funRef[3] = hPMRefAlg->GetFunction("gaus");
+  meanRef[3] = (Float_t) (funRef[3]->GetParameter(1));
+  sigmaRef[3] = (Float_t) (funRef[3]->GetParameter(2));
+  //
   FILE *fileShuttle;
   const char *fName = "ZDCLaser.dat";
   fileShuttle = fopen(fName,"w");
-  for(Int_t i=0; i<10; i++) fprintf(fileShuttle,"\t%f\t%f\n",meanC[i], sigmaC[i]);
-  for(Int_t i=0; i<10; i++) fprintf(fileShuttle,"\t%f\t%f\n",meanA[i], sigmaA[i]);
-  for(Int_t i=0; i<2; i++)  fprintf(fileShuttle,"\t%f\t%f\n",meanRef[i], sigmaRef[i]); 
+  for(Int_t i=0; i<4; i++)  fprintf(fileShuttle,"\t%f\t%f\n",meanRef[i], sigmaRef[i]); 
   //                                                  
   fclose(fileShuttle);
   //
-  for(Int_t j=0; j<10; j++){
-     delete hZDCsideC[j];
-     delete hZDCsideA[j];
-     delete hPMRefsideC;
-     delete hPMRefsideA;
-  }
+  delete hPMRefChg;
+  delete hPMRefAhg;
+  delete hPMRefClg;
+  delete hPMRefAlg;
 
   //delete minuitFit;
   TVirtualFitter::SetFitter(0);