]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ZDC/ZDCPEDESTALda.cxx
Changes for report #76227: ZDC TDC info in ESD and physics selection (for release...
[u/mrichter/AliRoot.git] / ZDC / ZDCPEDESTALda.cxx
index e1d07b6c5d48baafb53be38067d364f225cee545..36096012b277bfc2b8203531e83c2e92538c243b 100644 (file)
@@ -66,8 +66,16 @@ int main(int argc, char **argv) {
   TVirtualFitter::SetDefaultFitter("Minuit");
 
   int status = 0;
+  int const kNModules = 10;
   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];
@@ -75,6 +83,21 @@ int main(int argc, char **argv) {
   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");  
@@ -228,17 +251,10 @@ int main(int argc, char **argv) {
       /* use event - here, just write event id to result file */
       eventT=event->eventType;
       
-      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 modNum=-1, modType=-1;
-      
       if(eventT==START_OF_DATA){
-               
+       
+       iMod=-1; ich=0; iScCh=0; itdcCh=0;
+                       
        rawStreamZDC->SetSODReading(kTRUE);
        
        // --------------------------------------------------------
@@ -248,42 +264,62 @@ int main(int argc, char **argv) {
         else{
          while((rawStreamZDC->Next())){
             if(rawStreamZDC->IsHeaderMapping()){ // mapping header
-              modNum = rawStreamZDC->GetADCModule();
-              modType = rawStreamZDC->GetModType();
+              iMod++;
+              modGeo[iMod]  = rawStreamZDC->GetADCModule();
+              modType[iMod] = rawStreamZDC->GetModType();
+              modNCh[iMod]  = rawStreamZDC->GetADCNChannels();
            }
             if(rawStreamZDC->IsChMapping()){ 
-             if(modType==1){ // ADC mapping ----------------------
+             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);
-               //
-               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("  Mapping in DA -> %d ADC: mod %d ch %d, code %d det %d, sec %d\n",
-               //  ich,adcMod[ich],adcCh[ich],sigCode[ich],det[ich],sec[ich]);
-               //
                ich++;
              }
-             else if(modType==2){ //VME scaler mapping --------------------
+             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);
-               //
-               fprintf(mapFile4Shuttle,"\t%d\t%d\t%d\t%d\t%d\t%d\n",
-                 iScCh,scMod[iScCh],scCh[iScCh],scSigCode[iScCh],scDet[iScCh],scSec[iScCh]);
-               //
-               //printf("  Mapping in DA -> %d Scaler: mod %d ch %d, code %d det %d, sec %d\n",
-               //  iScCh,scMod[iScCh],scCh[iScCh],scSigCode[iScCh],scDet[iScCh],scSec[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
@@ -299,7 +335,7 @@ int main(int argc, char **argv) {
          }
          else{
             printf("ZDCPEDESTALda.cxx -> NO STANDALONE_PEDESTAL RUN raw data found\n");
-           printf("   Attributes: %x\n", message);
+           printf("   CDH attributes: %x\n", message);
             return -1;
          }
         }
@@ -339,7 +375,8 @@ int main(int argc, char **argv) {
         //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
@@ -385,14 +422,15 @@ int main(int argc, char **argv) {
           }
            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]);
+         }
+          //printf(" ev. %d -> Filling correlation histo %d\n",nevents_physics, kNChannels);
+       }
         nevents_physics++;
         //
        delete reader;