]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ZDC/ZDCMAPPINGda.cxx
Modifications in the output of the BF task (merging) - Michael Weber
[u/mrichter/AliRoot.git] / ZDC / ZDCMAPPINGda.cxx
index 1a5856d16218db018b51cb778c1c464d42c250f0..c7146bd696f07fe7614e45bf3883ce60157344c8 100644 (file)
@@ -2,19 +2,16 @@
 
 This program reads the DAQ data files passed as argument using the monitoring library.
 
-It computes the average event size and populates local "./result.txt" file with the 
-result.
-
 The program reports about its processing progress.
 
 Messages on stdout are exported to DAQ log system.
 
-DA to write mapping for the ZDC ADCs
+DA to write mapping for ADC modules and VME scaler
 
 Contact: Chiara.Oppedisano@to.infn.it
 Link: 
-Run Type: PHYSICS, STANDALONE_BC, STANDALONE_COSMIC, STANDALONE_CENTRAL, 
-         STANDALONE_MB, STANDALONE_SEMICENTRAL
+Run Type: PHYSICS, CALIBRATION_BC, CALIBRATION_CENTRAL, 
+         CALIBRATION_MB, CALIBRATION_SEMICENTRAL, CALIBRATION_COSMIC
 DA Type: MON
 Number of events needed: 1 (SOD is read) 
 Input Files:  none
@@ -48,10 +45,12 @@ int main(int argc, char **argv) {
   monitorDeclareTable(const_cast<char**>(tableSOD));
   
   int status = 0;
-  int const kNChannels = 48;
+  int const kNModules = 10;
+  int const kNChannels = 24;
+  int const kNScChannels = 32;
 
   /* log start of process */
-  printf("\nZDC MAPPING program started\n");  
+  printf("\n ZDC MAPPING program started\n");  
 
   /* check that we got some arguments = list of files */
   if (argc<2) {
@@ -106,6 +105,7 @@ int main(int argc, char **argv) {
       
       // Initalize raw-data reading and decoding
       AliRawReader *reader = new AliRawReaderDate((void*)event);
+      reader->Select("ZDC");
       // --- Reading event header
       //UInt_t evtype = reader->GetType();
       //printf("\t ZDCMAPPINGda -> run # %d\n",reader->GetRunNumber());
@@ -116,12 +116,36 @@ int main(int argc, char **argv) {
       /* use event - here, just write event id to result file */
       eventT=event->eventType;
       
-      Int_t ich=0;
-      Int_t adcMod[kNChannels], adcCh[kNChannels], sigCode[kNChannels];
-      Int_t det[kNChannels], sec[kNChannels];
-      
       if(eventT==START_OF_DATA){
-       sodRead = kTRUE;
+               
+      
+        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]=-1;
+        }
+      
+        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]=-1;
+        }
+      
+        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;
+        }
+       
        rawStreamZDC->SetSODReading(kTRUE);
        
        // --------------------------------------------------------
@@ -129,26 +153,67 @@ int main(int argc, char **argv) {
         mapFile4Shuttle = fopen(MAPDATA_FILE,"w");
        if(!rawStreamZDC->Next()) printf(" \t No raw data found!! \n");
         else{
-         while(rawStreamZDC->Next()){
-            if((rawStreamZDC->IsChMapping()) && (ich<kNChannels)){
-             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("ZDCMAPPINGda.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("  Mapping 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]);
+            //if(scMod[is]!=-1) printf("  Mapping 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("  Mapping DA -> Module mapping: geo %d type %d #ch %d\n",
+            //  modGeo[is],modType[is],modNCh[is]);
+         }
+         
        }
         fclose(mapFile4Shuttle);
-      } // SOD event
+      }// SOD event
       else{ 
         if(sodRead){
          printf("\t SOR read -> exiting from DA\n");
@@ -158,14 +223,15 @@ int main(int argc, char **argv) {
       }
       
       iev++; 
+
+      /* free resources */
+      free(event);
     }    
       
-    /* free resources */
-    //free(event);
   }
   
   /* store the result files on FES */
-  status = daqDA_FES_storeFile(MAPDATA_FILE, MAPDATA_FILE);
+  status = daqDA_FES_storeFile(MAPDATA_FILE, "MAPPING");
   if(status){
     printf("Failed to export file : %d\n",status);
     return -1;