LCOV - code coverage report
Current view: top level - ZDC/ZDCbase - AliZDCPreprocessor.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 547 0.2 %
Date: 2016-06-14 17:26:59 Functions: 1 16 6.2 %

          Line data    Source code
       1             : // --- ROOT system
       2             : #include <TFile.h>
       3             : #include <TClonesArray.h>
       4             : #include <TList.h>
       5             : #include <TObjString.h>
       6             : #include <TTimeStamp.h>
       7             : 
       8             : #include "AliZDCPreprocessor.h"
       9             : #include "AliCDBManager.h"
      10             : #include "AliCDBEntry.h"
      11             : #include "AliCDBMetaData.h"
      12             : #include "AliDCSValue.h"
      13             : #include "AliAlignObj.h"
      14             : #include "AliAlignObjParams.h"
      15             : #include "AliLog.h"
      16             : #include "AliZDCDataDCS.h"
      17             : #include "AliZDCChMap.h"
      18             : #include "AliZDCPedestals.h"
      19             : #include "AliZDCLaserCalib.h"
      20             : #include "AliZDCEnCalib.h"
      21             : #include "AliZDCTowerCalib.h"
      22             : #include "AliZDCMBCalib.h"
      23             : #include "AliZDCTDCCalib.h"
      24             : 
      25             : /////////////////////////////////////////////////////////////////////
      26             : //                                                                 //
      27             : // Class implementing Shuttle ZDC pre-processor.                   //
      28             : // It takes data from DCS and DAQ and writes calibration objects   //
      29             : // in the OCDB and reference values/histos in the ReferenceData.   //
      30             : //                                                                 //
      31             : /////////////////////////////////////////////////////////////////////
      32             : 
      33             : // ******************************************************************
      34             : //    RETURN CODES:
      35             : // return 0 : everything OK
      36             : // return 1 : no DCS input data Map
      37             : // return 2 : error storing DCS data in RefData 
      38             : // return 3 : error storing alignment object in OCDB
      39             : // return 4 : error in ZDCMapping.dat file retrieved from DAQ FXS (not existing|empty|corrupted)
      40             : // return 5 : error storing mapping obj. in OCDB
      41             : // return 6 : error storing energy calibration obj. in OCDB
      42             : // return 7 : error storing tower inter-calibration obj. in OCDB
      43             : // return 8 : error in ZDCEnergyCalib.dat file retrieved from DAQ FXS 
      44             : // return 9 : error in ZDCTowerCalib.dat file retrieved from DAQ FXS 
      45             : // return 10: error in ZDCPedestal.dat file retrieved from DAQ FXS 
      46             : // return 11: error storing pedestal calibration obj. in OCDB
      47             : // return 12: error in ZDCPedHisto.root file retrieved from DAQ FXS 
      48             : // return 13: error storing pedestal histos in RefData 
      49             : // return 14: error in ZDCLaserCalib.dat file retrieved from DAQ FXS 
      50             : // return 15: error storing laser calibration obj. in OCDB
      51             : // return 16: error in ZDCLaserHisto.root file retrieved from DAQ FXS 
      52             : // return 17: error storing laser histos in RefData 
      53             : // return 18: error in ZDCMBCalib.root file retrieved from DAQ FXS 
      54             : // return 19: error storing MB calibration obj. in OCDB
      55             : // return 20: error in ZDCTDCCalib.root file retrieved from DAQ FXS
      56             : // return 21: error in storing TDC calibration obj. in OCDB
      57             : // return 22: error in ZDCTDCHisto.root file retrieved from DAQ FXS
      58             : // Return 23: error storing TDC reference histos in RefData
      59             : // ******************************************************************
      60             : 
      61          12 : ClassImp(AliZDCPreprocessor)
      62             : 
      63             : //______________________________________________________________________________________________
      64             : AliZDCPreprocessor::AliZDCPreprocessor(AliShuttleInterface* shuttle) :
      65           0 :   AliPreprocessor("ZDC", shuttle),
      66           0 :   fData(0)
      67           0 : {
      68             :   // constructor
      69             :   // May 2009 - run types updated according to
      70             :   // http://alice-ecs.web.cern.ch/alice-ecs/runtypes_3.36.html
      71           0 :   AddRunType("STANDALONE_PEDESTAL");
      72           0 :   AddRunType("STANDALONE_LASER");
      73           0 :   AddRunType("STANDALONE_COSMIC");
      74           0 :   AddRunType("CALIBRATION_EMD");
      75           0 :   AddRunType("CALIBRATION_MB");
      76           0 :   AddRunType("CALIBRATION_BC");
      77           0 :   AddRunType("PHYSICS");
      78           0 : }
      79             : 
      80             : 
      81             : //______________________________________________________________________________________________
      82             : AliZDCPreprocessor::~AliZDCPreprocessor()
      83           0 : {
      84             :   // destructor
      85           0 : }
      86             : 
      87             : 
      88             : //______________________________________________________________________________________________
      89             : void AliZDCPreprocessor::Initialize(Int_t run, UInt_t startTime, UInt_t endTime)
      90             : {
      91             :   // Creates AliZDCDataDCS object
      92             : 
      93           0 :   AliPreprocessor::Initialize(run, startTime, endTime);
      94             : 
      95           0 :   AliDebug(2,Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s \n\tStartTime DCS Query %s \n\tEndTime DCS Query %s", run,
      96             :                 TTimeStamp(startTime).AsString(),
      97             :                 TTimeStamp(endTime).AsString(), ((TTimeStamp)GetStartTimeDCSQuery()).AsString(), ((TTimeStamp)GetEndTimeDCSQuery()).AsString()));
      98             : 
      99           0 :   fRun = run;
     100           0 :   fStartTime = startTime;
     101           0 :   fEndTime = endTime;
     102             : 
     103           0 :   fData = new AliZDCDataDCS(fRun, fStartTime, fEndTime, GetStartTimeDCSQuery(), GetEndTimeDCSQuery());
     104           0 :   fPedSubMethFlag = kFALSE;
     105           0 : }
     106             : 
     107             : //_____________________________________________________________________________
     108             : Bool_t AliZDCPreprocessor::ProcessDCS(){
     109             : 
     110             :   // tells whether DCS should be processed or not
     111             : 
     112           0 :   TString runType = GetRunType();
     113           0 :   Log(Form("RunType %s",runType.Data()));
     114             : 
     115           0 :   if (runType=="STANDALONE_COSMIC" || runType=="STANDALONE_PEDESTAL"){
     116           0 :     return kFALSE;
     117             :   }
     118             : 
     119           0 :   return kTRUE;
     120           0 : }
     121             : 
     122             : //______________________________________________________________________________________________
     123             : UInt_t AliZDCPreprocessor::ProcessDCSData(TMap* dcsAliasMap)
     124             : {
     125             :   
     126             :   // Fills data into a AliZDCDataDCS object
     127           0 :   if(!dcsAliasMap){
     128           0 :     Log(" No DCS map found: ZDC exiting from Shuttle");
     129           0 :     if(fData){
     130           0 :       delete fData;
     131           0 :       fData = 0;
     132           0 :     }
     133           0 :     return 1;
     134             :   }
     135             : 
     136           0 :   Log(Form("Processing data from DCS"));
     137             :    
     138             :   // The processing of the DCS input data is forwarded to AliZDCDataDCS
     139             :   //dcsAliasMap->Print(""); 
     140           0 :   Bool_t resDCSProcess = fData->ProcessData(*dcsAliasMap);
     141           0 :   if(resDCSProcess==kFALSE){
     142           0 :     Log(" Problems in processing DCS DP");
     143           0 :     return 1;
     144             :   }  
     145             :   
     146             :   // ------------------------------------------------------
     147             :   // Change introduced 26/9/09 in order NOT to process the
     148             :   // HV DP since some of them are never found in amanda DB
     149             :   // ------------------------------------------------------
     150             :   // Store DCS data as reference
     151           0 :   AliCDBMetaData metadata;
     152           0 :   metadata.SetResponsible("Chiara Oppedisano");
     153           0 :   metadata.SetComment("DCS DP TMap for ZDC");
     154             :   Bool_t resDCSRef = kTRUE;
     155           0 :   resDCSRef = StoreReferenceData("DCS","Data", dcsAliasMap, &metadata);
     156             :   
     157           0 :   if(resDCSRef==kFALSE) return 2;
     158             : 
     159             :   // --- Writing ZDC table positions into alignment object
     160           0 :   TClonesArray *array = new TClonesArray("AliAlignObjParams",10);
     161             :   TClonesArray &alobj = *array;
     162           0 :   AliAlignObjParams a;
     163             :   Double_t dx=0., dz=0., dpsi=0., dtheta=0., dphi=0.;
     164             :   // Vertical table position in mm from DCS
     165           0 :   Double_t dyZN1 = (Double_t) ((fData->GetAlignData(0)-184.0)/10.);
     166           0 :   Double_t dyZP1 = (Double_t) ((fData->GetAlignData(1)-198.1)/10.);
     167           0 :   Double_t dyZN2 = (Double_t) ((fData->GetAlignData(2)-186.5)/10.);
     168           0 :   Double_t dyZP2 = (Double_t) ((fData->GetAlignData(3)-202.9)/10.);
     169             :   //
     170             :   const char *n1ZDC="ZDC/NeutronZDC_C";  
     171             :   const char *p1ZDC="ZDC/ProtonZDC_C";
     172             :   const char *n2ZDC="ZDC/NeutronZDC_A";
     173             :   const char *p2ZDC="ZDC/ProtonZDC_A";
     174             :   //
     175             :   UShort_t iIndex=0;
     176             :   AliGeomManager::ELayerID iLayer = AliGeomManager::kInvalidLayer;
     177           0 :   UShort_t volid = AliGeomManager::LayerToVolUID(iLayer,iIndex);
     178             :   //
     179           0 :   new(alobj[0]) AliAlignObjParams(n1ZDC, volid, dx, dyZN1, dz, dpsi, dtheta, dphi, kTRUE);
     180           0 :   new(alobj[1]) AliAlignObjParams(p1ZDC, volid, dx, dyZP1, dz, dpsi, dtheta, dphi, kTRUE);
     181           0 :   new(alobj[2]) AliAlignObjParams(n2ZDC, volid, dx, dyZN2, dz, dpsi, dtheta, dphi, kTRUE);
     182           0 :   new(alobj[3]) AliAlignObjParams(p2ZDC, volid, dx, dyZP2, dz, dpsi, dtheta, dphi, kTRUE);
     183             :  
     184             :   // save in CDB storage
     185           0 :   AliCDBMetaData mdDCS;
     186           0 :   mdDCS.SetResponsible("Chiara Oppedisano");
     187           0 :   mdDCS.SetComment("Alignment object for ZDC");
     188           0 :   Bool_t resultAl = Store("Align","Data", array, &mdDCS, 0, kFALSE);
     189           0 :   if(resultAl==kFALSE)  return 3;
     190             :   
     191           0 :   return 0;
     192           0 : }
     193             : 
     194             : //______________________________________________________________________________________________
     195             : UInt_t AliZDCPreprocessor::ProcessChMap()
     196             : { 
     197             :   const int kNModules=10, kNch=48, kNScch=32, kNtdcch=32;
     198             :   
     199             :   // Reading the file for mapping from FXS
     200           0 :   TList* daqSource = GetFileSources(kDAQ, "MAPPING");
     201           0 :   if(!daqSource){
     202           0 :     AliError(Form("No sources for file ZDCChMapping.dat in run %d ", fRun));
     203           0 :     return 4;
     204             :   }
     205           0 :   if(daqSource->GetEntries()==0) return 4;
     206           0 :   Log("\t List of DAQ sources for MAPPING id: "); daqSource->Print();
     207             :   //
     208           0 :   TIter iter(daqSource);
     209             :   TObjString* source = 0;
     210             :   Int_t isou = 0;
     211           0 :   Int_t modMap[kNModules][3], adcMap[kNch][6], scMap[kNScch][6], tdcMap[kNtdcch][4]; 
     212             :   //
     213           0 :   while((source = dynamic_cast<TObjString*> (iter.Next()))){
     214           0 :      TString fileName = GetFile(kDAQ, "MAPPING", source->GetName());
     215           0 :      Log(Form("\t Getting file #%d: ZDCChMapping.dat from %s\n",++isou, source->GetName()));
     216             : 
     217           0 :      if(fileName.Length() <= 0){
     218           0 :        Log(Form("No file from source %s!", source->GetName()));
     219           0 :        return 4;
     220             :      }
     221             :      // --- Reading file with calibration data
     222             :      //const char* fname = fileName.Data();
     223           0 :      if(fileName){
     224             :        FILE *file;
     225           0 :        if((file = fopen(fileName,"r")) == NULL){
     226           0 :          printf("Cannot open file %s \n",fileName.Data());
     227           0 :          return 4;
     228             :        }
     229           0 :        Log(Form("File %s connected to process data for ADC mapping", fileName.Data()));
     230             :        //
     231           0 :        for(Int_t j=0; j<kNch; j++){    
     232           0 :            for(Int_t k=0; k<6; k++){
     233           0 :              int read = fscanf(file,"%d",&adcMap[j][k]);
     234           0 :              if(read == 0) AliDebug(3," Failing in reading data from mapping file");
     235             :            }
     236             :        }
     237           0 :        for(Int_t j=kNch; j<kNch+kNScch; j++){          
     238           0 :            for(Int_t k=0; k<6; k++){
     239           0 :              int read = fscanf(file,"%d",&scMap[j-kNch][k]);
     240           0 :              if(read == 0) AliDebug(3," Failing in reading data from mapping file");
     241             :            }
     242             :        }
     243           0 :        for(Int_t j=kNch+kNScch; j<kNch+kNScch+kNtdcch; j++){   
     244           0 :            for(Int_t k=0; k<4; k++){
     245           0 :              int read = fscanf(file,"%d",&tdcMap[j-kNch-kNScch][k]);
     246           0 :              if(read == 0) AliDebug(3," Failing in reading data from mapping file");
     247             :            }
     248             :        }
     249           0 :        for(Int_t j=kNch+kNScch+kNtdcch; j<kNch+kNScch+kNtdcch+kNModules; j++){         
     250           0 :            for(Int_t k=0; k<3; k++){
     251           0 :              int read = fscanf(file,"%d",&modMap[j-kNch-kNScch-kNtdcch][k]);
     252           0 :              if(read == 0) AliDebug(3," Failing in reading data from mapping file");
     253             :            }
     254             :        }
     255           0 :        fclose(file);
     256           0 :      }
     257             :      else{
     258           0 :        Log(Form("File %s not found", fileName.Data()));
     259           0 :        return 4;
     260             :      }
     261           0 :   }
     262             :   
     263             :   // Store the currently read map ONLY IF it is different
     264             :   // from the entry in the OCDB
     265             :   Bool_t adcMapUpdated=kFALSE, scMapUpdated=kFALSE, tdcMapUpdated=kFALSE;
     266             :   Bool_t updateOCDB = kFALSE;
     267             :   
     268           0 :   AliCDBEntry *cdbEntry = GetFromOCDB("Calib","ChMap");
     269           0 :   if(!cdbEntry){
     270           0 :     Log(" No existing CDB entry for ADC mapping");
     271             :     updateOCDB = kTRUE;
     272           0 :   }
     273             :   else{
     274           0 :     AliZDCChMap *chMap = (AliZDCChMap*) cdbEntry->GetObject();
     275           0 :     for(Int_t i=0; i<kNch; i++){
     276           0 :       if(  (adcMap[i][1] != chMap->GetADCModule(i)) 
     277           0 :         || (adcMap[i][2] != chMap->GetADCChannel(i)) 
     278           0 :         || (adcMap[i][3] != chMap->GetADCSignalCode(i)) 
     279           0 :         || (adcMap[i][4] != chMap->GetDetector(i)) 
     280           0 :         || (adcMap[i][5] != chMap->GetSector(i))) 
     281           0 :          adcMapUpdated = kTRUE;
     282             :     }
     283           0 :     for(Int_t i=0; i<kNScch; i++){
     284           0 :       if(  (scMap[i][2] != chMap->GetScChannel(i)) 
     285           0 :         || (scMap[i][3] != chMap->GetScSignalCode(i)) )
     286           0 :          scMapUpdated = kTRUE;
     287             :     }
     288           0 :     for(Int_t i=0; i<kNtdcch; i++){
     289           0 :       if(  (tdcMap[i][2] != chMap->GetTDCChannel(i)) 
     290           0 :         || (tdcMap[i][3] != chMap->GetTDCSignalCode(i)))
     291           0 :          tdcMapUpdated = kTRUE;
     292             :     }
     293             :   }
     294           0 :   if(adcMapUpdated || scMapUpdated || tdcMapUpdated) updateOCDB = kTRUE;
     295             :   //
     296             :   Bool_t resChMapStore = kTRUE;
     297           0 :   if(updateOCDB==kTRUE){
     298           0 :     Log(" A new entry ZDC/Calib/ChMap will be created");
     299             :     //
     300             :     // --- Initializing mapping calibration object
     301           0 :     AliZDCChMap *mapCalib = new AliZDCChMap("ZDC");
     302             :     // Writing channel map in the OCDB
     303           0 :     for(Int_t k=0; k<kNModules; k++){
     304           0 :       mapCalib->SetModuleMap(k, modMap[k][0], modMap[k][1], modMap[k][2]);
     305             :     }
     306           0 :     for(Int_t k=0; k<kNch; k++){
     307           0 :       mapCalib->SetADCModule(k,adcMap[k][1]);
     308           0 :       mapCalib->SetADCChannel(k,adcMap[k][2]);
     309           0 :       mapCalib->SetADCSignalCode(k,adcMap[k][3]);
     310           0 :       mapCalib->SetDetector(k,adcMap[k][4]);
     311           0 :       mapCalib->SetSector(k,adcMap[k][5]);
     312             :     }
     313           0 :     for(Int_t k=0; k<kNScch; k++){
     314           0 :        mapCalib->SetScChannel(k, scMap[k][2]);
     315           0 :        mapCalib->SetScSignalCode(k, scMap[k][3]);
     316           0 :        mapCalib->SetScDetector(k, scMap[k][4]);
     317           0 :        mapCalib->SetScSector(k, scMap[k][5]);
     318             :     }
     319           0 :     for(Int_t k=0; k<kNtdcch; k++){
     320           0 :        mapCalib->SetTDCChannel(k, tdcMap[k][2]);
     321           0 :        mapCalib->SetTDCSignalCode(k, tdcMap[k][3]);
     322             :     }
     323             :     //
     324             :     //mapCalib->Print("");
     325             :     // 
     326           0 :     AliCDBMetaData metaData;
     327           0 :     metaData.SetBeamPeriod(0);
     328           0 :     metaData.SetResponsible("Chiara Oppedisano");
     329           0 :     metaData.SetComment("AliZDCChMap object created by ZDC preprocessor");  
     330             :     //
     331           0 :     resChMapStore = Store("Calib","ChMap",mapCalib, &metaData, 0, kTRUE);
     332           0 :     printf("  Mapping object stored in OCDB\n");
     333           0 :   }
     334             :   else{
     335           0 :     Log(" ZDC/Calib/ChMap entry in OCDB is valid and won't be updated");
     336             :     resChMapStore = kTRUE;
     337             :   }
     338           0 :   delete daqSource; daqSource=0;
     339             :   
     340           0 :   TString runType = GetRunType();
     341           0 :   if(runType.CompareTo("PHYSICS")==0){
     342           0 :     Log(Form("RunType %s -> producing TDC calibration data",runType.Data()));
     343             :     
     344             :     // Reading the file for mapping from FXS
     345           0 :     TList* daqSourcetdc = GetFileSources(kDAQ, "TDCDATA");
     346           0 :     if(!daqSourcetdc){
     347           0 :       AliError(Form("No sources for file ZDCChMappingTDCCalib.dat in run %d ", fRun));
     348           0 :       return 20;
     349             :     }
     350           0 :     if(daqSourcetdc->GetEntries()==0) return 20;
     351           0 :     Log("\t List of DAQ sources for TDCDATA id: "); daqSourcetdc->Print();
     352             :     //
     353             :     Bool_t resTDCcal = kTRUE;
     354           0 :     TIter itertdc(daqSourcetdc);
     355             :     TObjString* sourcetdc = 0;
     356             :     Int_t isoutdc = 0;
     357             :     //
     358           0 :     while((sourcetdc = dynamic_cast<TObjString*> (itertdc.Next()))){
     359           0 :      TString fileNametdc = GetFile(kDAQ, "TDCDATA", sourcetdc->GetName());
     360           0 :      Log(Form("\t Getting file #%d: ZDCTDCdata.dat from %s\n",++isoutdc, sourcetdc->GetName()));
     361             : 
     362           0 :      if(fileNametdc.Length() <= 0){
     363           0 :        Log(Form("No file from source %s!", sourcetdc->GetName()));
     364           0 :        return 20;
     365             :      }
     366             :      // --- Initializing TDC calibration object
     367           0 :      AliZDCTDCCalib *tdcCalib = new AliZDCTDCCalib("ZDC");
     368             :      // --- Reading file with calibration data
     369             :      //const char* fname = fileName.Data();
     370           0 :      if(fileNametdc){
     371             :        FILE *filetdc;
     372           0 :        if((filetdc = fopen(fileNametdc,"r")) == NULL){
     373           0 :          printf("Cannot open file %s \n",fileNametdc.Data());
     374           0 :          return 20;
     375             :        }
     376           0 :        Log(Form("File %s connected to process TDC data", fileNametdc.Data()));
     377             :        //
     378           0 :        Float_t tdcMean[6][2];
     379           0 :        for(Int_t it=0; it<6; it++){
     380           0 :          for(Int_t iu=0; iu<2; iu++) tdcMean[it][iu]=0.;
     381             :        }
     382           0 :        for(Int_t k=0; k<6; k++){
     383           0 :         for(Int_t j=0; j<2; j++){
     384           0 :            int leggi = fscanf(filetdc,"%f",&tdcMean[k][j]);
     385           0 :            if(leggi==0) AliDebug(3," Failing reading data from tdc file");
     386           0 :            tdcCalib->SetMeanTDC(k, tdcMean[k][0]);
     387           0 :            tdcCalib->SetWidthTDC(k, tdcMean[k][1]);
     388             :         }
     389             :        }
     390           0 :        fclose(filetdc);
     391           0 :      }
     392             :      else{
     393           0 :        Log(Form("File %s not found", fileNametdc.Data()));
     394           0 :        return 20;
     395             :      }
     396             :      //
     397           0 :      AliCDBMetaData metaData;
     398           0 :      metaData.SetBeamPeriod(0);
     399           0 :      metaData.SetResponsible("Chiara Oppedisano");
     400           0 :      metaData.SetComment("Filling AliZDCTDCCalib object");  
     401             :      //
     402           0 :      resTDCcal = Store("Calib","TDCCalib",tdcCalib, &metaData, 0, kTRUE);
     403           0 :      if(resTDCcal==kFALSE) return 21;
     404           0 :     }
     405           0 :     delete daqSourcetdc; daqSourcetdc = 0;
     406             : 
     407             :     Bool_t restdcHist = kTRUE;
     408           0 :     TList* daqSourceH = GetFileSources(kDAQ, "TDCHISTOS");
     409           0 :     if(!daqSourceH){
     410           0 :       Log(Form("No source for TDCHISTOS id run %d !", fRun));
     411           0 :       return 22;
     412             :     }
     413           0 :     Log("\t List of DAQ sources for TDCHISTOS id: "); daqSourceH->Print();
     414             :     //
     415           0 :     TIter iterH(daqSourceH);
     416             :     TObjString* sourceH = 0;
     417             :     Int_t iH=0;
     418           0 :     while((sourceH = dynamic_cast<TObjString*> (iterH.Next()))){
     419           0 :      TString stringTDCFileName = GetFile(kDAQ, "TDCHISTOS", sourceH->GetName());
     420           0 :      if(stringTDCFileName.Length() <= 0){
     421           0 :         Log(Form("No TDCHISTOS file from source %s!", sourceH->GetName()));
     422           0 :         return 22;
     423             :      }
     424           0 :      const char* tdcFileName = stringTDCFileName.Data();
     425           0 :      Log(Form("\t Getting file #%d: %s from %s\n",++iH, tdcFileName, sourceH->GetName()));
     426           0 :      restdcHist = StoreReferenceFile(tdcFileName, "tdcReference.root");
     427           0 :      if(restdcHist==kFALSE) return 23;
     428           0 :     }
     429           0 :     delete daqSourceH; daqSourceH=0;
     430           0 :   }
     431             :   
     432           0 :     if(resChMapStore==kFALSE) return 5;
     433           0 :     else return 0;
     434             : 
     435           0 : }
     436             : 
     437             : //______________________________________________________________________________________________
     438             : UInt_t AliZDCPreprocessor::ProcessppData()
     439             : {
     440             :    Bool_t resEnCal=kTRUE, resTowCal=kTRUE;
     441             :   
     442             :    // *********** Energy calibration
     443             :    // --- Cheking if there is already the entry in the OCDB
     444           0 :    AliCDBEntry *cdbEnEntry = GetFromOCDB("Calib", "EnergyCalib");
     445           0 :    if(!cdbEnEntry){   
     446           0 :      Log(Form(" ZDC/Calib/EnergyCalib entry will be created"));
     447             :      // --- Initializing calibration object
     448           0 :      AliCDBMetaData metaData;
     449           0 :      metaData.SetBeamPeriod(0);
     450           0 :      metaData.SetResponsible("Chiara Oppedisano");
     451             :      //
     452           0 :      AliZDCEnCalib *eCalib = new AliZDCEnCalib("ZDC");
     453           0 :      for(Int_t j=0; j<6; j++) eCalib->SetEnCalib(j,1.);
     454           0 :      metaData.SetComment("AliZDCEnCalib object");  
     455             :      //eCalib->Print("");
     456           0 :      resEnCal = Store("Calib", "EnergyCalib", eCalib, &metaData, 0, kTRUE);
     457           0 :    }
     458             :    else{ 
     459             :      // if entry exists it is still valid (=1 for all runs!)
     460           0 :      Log(Form(" Valid ZDC/Calib/EnergyCalib object already existing in OCDB!!!"));
     461             :      resEnCal = kTRUE;
     462             :    }
     463             :    
     464           0 :    if(resEnCal==kFALSE) return 6;
     465             : 
     466             :    //
     467             :    // *********** Tower inter-calibration
     468             :    // --- Cheking if there is already the entry in the OCDB
     469           0 :    AliCDBEntry *cdbTowEntry = GetFromOCDB("Calib", "TowerCalib");
     470           0 :    if(!cdbTowEntry){   
     471           0 :      AliZDCTowerCalib *towCalib = new AliZDCTowerCalib("ZDC");
     472           0 :      for(Int_t j=0; j<5; j++){  
     473           0 :         towCalib->SetZN1EqualCoeff(j, 1.);
     474           0 :         towCalib->SetZP1EqualCoeff(j, 1.);
     475           0 :         towCalib->SetZN2EqualCoeff(j, 1.);
     476           0 :         towCalib->SetZP2EqualCoeff(j, 1.);  
     477             :      }
     478             :      //towCalib->Print("");
     479             :      // 
     480           0 :      AliCDBMetaData metaData;
     481           0 :      metaData.SetBeamPeriod(0);
     482           0 :      metaData.SetResponsible("Chiara Oppedisano");
     483           0 :      metaData.SetComment("AliZDCTowerCalib object");  
     484             :      //
     485           0 :      resTowCal = Store("Calib", "TowerCalib", towCalib, &metaData, 0, kTRUE);
     486           0 :    }
     487             :    else{ 
     488             :      // if entry exists it is still valid (=1 for all runs!)
     489           0 :      Log(Form(" Valid ZDC/Calib/TowerCalib object already existing in OCDB!!!"));
     490             :      resTowCal = kTRUE;
     491             :    }
     492             :    
     493           0 :    if(resTowCal==kFALSE) return 7;
     494             :    
     495           0 :    return 0;
     496           0 : }
     497             : 
     498             : //______________________________________________________________________________________________
     499             : UInt_t AliZDCPreprocessor::ProcessCalibData(Float_t beamEnergy)
     500             : {
     501           0 :   TList* daqSources = GetFileSources(kDAQ, "EMDENERGYCALIB");
     502           0 :   if(!daqSources){
     503           0 :     AliError(Form("No sources for CALIBRATION_EMD run %d !", fRun));
     504           0 :     return 8;
     505             :   }
     506           0 :   Log("\t List of DAQ sources for EMDENERGYCALIB id: "); daqSources->Print();
     507             :   //
     508           0 :   TIter iter2(daqSources);
     509             :   TObjString* source = 0;
     510             :   Int_t i=0;
     511             :   Bool_t resEnCal=kTRUE, resTowCal=kTRUE;
     512             :   
     513           0 :   while((source = dynamic_cast<TObjString*> (iter2.Next()))){
     514           0 :     TString stringEMDFileName = GetFile(kDAQ, "EMDENERGYCALIB", source->GetName());
     515           0 :     if(stringEMDFileName.Length() <= 0){
     516           0 :       Log(Form("No file from source %s!", source->GetName()));
     517           0 :       return 8;
     518             :     }
     519           0 :     const char* emdFileName = stringEMDFileName.Data();
     520           0 :     Log(Form("\t Getting file #%d: %s from %s\n",++i,emdFileName,source->GetName()));
     521             :     //
     522             :     // --- Initializing energy calibration object
     523           0 :     AliZDCEnCalib *eCalib = new AliZDCEnCalib("ZDC");
     524             :     // --- Reading file with calibration data
     525           0 :     if(emdFileName){
     526             :       FILE *file;
     527           0 :       if((file = fopen(emdFileName,"r")) == NULL){
     528           0 :         printf("Cannot open file %s \n",emdFileName);
     529           0 :         return 8;
     530             :       }
     531           0 :       Log(Form("File %s connected to process data from EM dissociation events", emdFileName));
     532             :       //
     533           0 :       Float_t fitValEMD[6];
     534           0 :       for(Int_t j=0; j<6; j++){        
     535           0 :         if(j<6){
     536           0 :           int iread = fscanf(file,"%f",&fitValEMD[j]);
     537           0 :           if(iread==0) AliDebug(3," Failing reading data from EMD calibration data file");
     538           0 :           if(fitValEMD[j]!=1.) eCalib->SetEnCalib(j, beamEnergy/fitValEMD[j]);
     539           0 :           else eCalib->SetEnCalib(j, fitValEMD[j]);
     540           0 :         }
     541             :       }
     542             :       //
     543           0 :       fclose(file);
     544           0 :     }
     545             :     else{
     546           0 :       Log(Form("File %s not found", emdFileName));
     547           0 :       return 8;
     548             :     }
     549             :     //eCalib->Print("");
     550             :     // 
     551           0 :     AliCDBMetaData metaData;
     552           0 :     metaData.SetBeamPeriod(0);
     553           0 :     metaData.SetResponsible("Chiara Oppedisano");
     554           0 :     metaData.SetComment("Filling AliZDCEnCalib object");  
     555             :     //
     556           0 :     resEnCal = Store("Calib","EnergyCalib",eCalib, &metaData, 0, kTRUE);
     557           0 :     if(resEnCal==kFALSE) return 6;
     558           0 :   }
     559           0 :   delete daqSources; daqSources = 0;
     560             :   
     561           0 :   TList* daqSourcesH = GetFileSources(kDAQ, "EMDTOWERCALIB");
     562           0 :   if(!daqSourcesH){
     563           0 :     AliError(Form("No sources for CALIBRATION_EMD run %d !", fRun));
     564           0 :     return 9;
     565             :   }
     566           0 :   Log("\t List of DAQ sources for EMDTOWERCALIB id: "); daqSourcesH->Print();
     567             :   //
     568           0 :   TIter iter2H(daqSourcesH);
     569             :   TObjString* sourceH = 0;
     570             :   Int_t iH=0;
     571           0 :   while((sourceH = dynamic_cast<TObjString*> (iter2H.Next()))){
     572           0 :     TString stringtowEMDFileName = GetFile(kDAQ, "EMDTOWERCALIB", sourceH->GetName());
     573           0 :     if(stringtowEMDFileName.Length() <= 0){
     574           0 :       Log(Form("No file from source %s!", sourceH->GetName()));
     575           0 :       return 9;
     576             :     }
     577           0 :     const char * towEMDFileName = stringtowEMDFileName.Data();
     578           0 :     Log(Form("\t Getting file #%d: %s from source %s\n",++iH,towEMDFileName,sourceH->GetName()));
     579             :     // --- Initializing energy calibration object
     580           0 :     AliZDCTowerCalib *towCalib = new AliZDCTowerCalib("ZDC");
     581             :     // --- Reading file with calibration data
     582           0 :     if(towEMDFileName){
     583             :       FILE *file;
     584           0 :       if((file = fopen(towEMDFileName,"r")) == NULL){
     585           0 :         printf("Cannot open file %s \n",towEMDFileName);
     586           0 :         return 9;
     587             :       }
     588             :       //
     589           0 :       Float_t equalCoeff[4][5];
     590           0 :       for(Int_t j=0; j<4; j++){        
     591           0 :          for(Int_t k=0; k<5; k++){
     592           0 :            int leggi = fscanf(file,"%f",&equalCoeff[j][k]);
     593           0 :            if(leggi==0) AliDebug(3," Failing reading data from EMD calibration file");
     594           0 :            if(j==0)      towCalib->SetZN1EqualCoeff(k, equalCoeff[j][k]);
     595           0 :            else if(j==1) towCalib->SetZP1EqualCoeff(k, equalCoeff[j][k]);
     596           0 :            else if(j==2) towCalib->SetZN2EqualCoeff(k, equalCoeff[j][k]);
     597           0 :            else if(j==3) towCalib->SetZP2EqualCoeff(k, equalCoeff[j][k]);  
     598             :          }
     599             :       }
     600             :       //
     601           0 :       fclose(file);
     602           0 :     }
     603             :     else{
     604           0 :       Log(Form("File %s not found", towEMDFileName));
     605           0 :       return 9;
     606             :     }
     607             :     //towCalib->Print("");
     608             :     // 
     609           0 :     AliCDBMetaData metaData;
     610           0 :     metaData.SetBeamPeriod(0);
     611           0 :     metaData.SetResponsible("Chiara Oppedisano");
     612           0 :     metaData.SetComment("Filling AliZDCTowerCalib object");  
     613             :     //
     614           0 :     resTowCal = Store("Calib","TowerCalib",towCalib, &metaData, 0, kTRUE);
     615           0 :     if(resTowCal==kFALSE) return 7;
     616           0 :   }
     617           0 :   delete daqSourcesH; daqSourcesH = 0;
     618             :   
     619             :      
     620           0 :   return 0;
     621           0 : }
     622             : 
     623             : //______________________________________________________________________________________________
     624             : UInt_t AliZDCPreprocessor::ProcessPedestalData()
     625             : {
     626             :   // ____________________________________________________________________
     627             :   // 1: read mean values and fit parameters from ascii data file
     628           0 :   TList* daqSource1 = GetFileSources(kDAQ, "PEDESTALDATA");
     629           0 :   if(!daqSource1){
     630           0 :     Log(Form("No source1 for STANDALONE_PEDESTAL run %d !", fRun));
     631           0 :     return 10;
     632             :   }
     633           0 :   if(daqSource1->GetEntries()==0) return 10;
     634             :   //
     635             :   // ____________________________________________________________________
     636             :   // 2: read channels to be subtracted from correlation fit (implemented from RUN2)
     637             :   Bool_t resPedSubDecision=kFALSE;
     638           0 :   TList* daqSource2 = GetFileSources(kDAQ, "PEDCORRTOFIT");
     639           0 :   if(!daqSource2){
     640           0 :     Log(Form("No source2 for STANDALONE_PEDESTAL run %d !", fRun));
     641           0 :     return 10;
     642             :   }
     643           0 :   if(daqSource2->GetEntries()==0) return 10;
     644             :   else   resPedSubDecision = kTRUE;
     645             :   
     646           0 :   Log("\t List of DAQ sources for PEDESTALDATA id: "); 
     647           0 :   daqSource1->Print();
     648           0 :   daqSource2->Print();
     649             :   //
     650             :   // ____________________________________________________________________
     651             :   // 1: read mean values and fit parameters from ascii data file
     652           0 :   TIter iter(daqSource1);
     653             :   TObjString* source;
     654             :   //int i=0;
     655             :   Bool_t resPedCal=kTRUE, resPedHist=kTRUE;
     656             :   // --- Initializing pedestal calibration object
     657           0 :   AliZDCPedestals *pedCalib = new AliZDCPedestals("ZDC");
     658             :   
     659           0 :   while((source = dynamic_cast<TObjString*> (iter.Next()))){
     660           0 :      TString stringPedFileName = GetFile(kDAQ, "PEDESTALDATA", source->GetName());
     661           0 :      if(stringPedFileName.Length() <= 0){
     662           0 :         Log(Form("No PEDESTALDATA file from source %s!", source->GetName()));
     663           0 :         return 10;
     664             :      }
     665           0 :      const char* pedFileName = stringPedFileName.Data();
     666           0 :      Log(Form("\t Getting file %s from %s\n",pedFileName,source->GetName()));
     667             :      //
     668             :      // --- Reading file with pedestal calibration data
     669             :      // no. ADCch = (22 signal ch. + 2 reference PMs) * 2 gain chain = 48
     670             :      const Int_t knZDCch = 48;
     671             :      FILE *file;
     672           0 :      if((file = fopen(pedFileName,"r")) == NULL){
     673           0 :        printf("Cannot open file %s \n",pedFileName);
     674           0 :        return 10;
     675             :      }
     676           0 :      Log(Form("File %s connected to process pedestal data", pedFileName));
     677           0 :      Float_t pedVal[(3*knZDCch)][2];
     678           0 :      for(Int_t k=0; k<(3*knZDCch); k++){
     679           0 :         for(Int_t j=0; j<2; j++){
     680           0 :            int aleggi = fscanf(file,"%f",&pedVal[k][j]);
     681           0 :            if(aleggi==0) AliDebug(3," Failing reading data from PEDESTALDATA file");
     682             :            //if(j==1) printf("pedVal[%d] -> %f, %f \n",k,pedVal[k][0],pedVal[k][1]);
     683             :         }
     684           0 :         if(k<knZDCch){ // in time signals
     685           0 :           pedCalib->SetMeanPed(k,pedVal[k][0]);
     686           0 :           pedCalib->SetMeanPedWidth(k,pedVal[k][1]);
     687           0 :         }
     688           0 :         else if(k>=knZDCch && k<(2*knZDCch)){ // out of time signals
     689           0 :           pedCalib->SetOOTPed(k-knZDCch,pedVal[k][0]);
     690           0 :           pedCalib->SetOOTPedWidth(k-knZDCch,pedVal[k][1]);
     691           0 :         }
     692           0 :         else if(k>=(2*knZDCch) && k<(3*knZDCch)){ // correlazioni
     693           0 :           pedCalib->SetPedCorrCoeff(k-(2*knZDCch),pedVal[k][0],pedVal[k][1]);
     694           0 :         }
     695             :      }
     696           0 :      fclose(file);
     697           0 :   }
     698             :   // ____________________________________________________________________
     699             :   // 2: read channels to be subtracted from correlation fit (implemented from RUN2)
     700           0 :   if(resPedSubDecision){
     701           0 :     TIter iter2(daqSource2);
     702             :     TObjString* source2;
     703             :   
     704           0 :     while((source2 = dynamic_cast<TObjString*> (iter2.Next()))){
     705           0 :        TString stringFileName = GetFile(kDAQ, "PEDCORRTOFIT", source2->GetName());
     706           0 :        if(stringFileName.Length() <= 0){
     707           0 :           Log(Form("No PEDCORRTOFIT file from source %s!", source2->GetName()));
     708           0 :           return 10;
     709             :        }
     710           0 :        const char* pedFileName = stringFileName.Data();
     711           0 :        Log(Form("\t Getting file %s from %s\n",pedFileName,source2->GetName()));
     712             :        //
     713             :        const Int_t kNch = 24;
     714             :        FILE *file;
     715           0 :        if((file = fopen(pedFileName,"r")) == NULL){
     716           0 :          printf("Cannot open file %s \n",pedFileName);
     717           0 :          return 10;
     718             :        }
     719           0 :        Log(Form("File %s connected to process pedestal data", pedFileName));
     720           0 :        pedCalib->SetPedModeBit(kTRUE);
     721             :        //
     722           0 :        Int_t val[kNch][2];
     723           0 :        for(Int_t k=0; k<kNch; k++){
     724           0 :           for(int j=0; j<2; j++){
     725           0 :              int aleggi = fscanf(file,"%d",&val[k][1]);
     726           0 :              if(aleggi==0) AliDebug(3," Failing reading data from PEDCORRTOFIT file");
     727           0 :              if(j==1 && val[k][1]==1){
     728           0 :                pedCalib->SetSubFromCorr(k);
     729           0 :                printf("ped ch.%d -> subtraction from correlation mode (%d) \n",k,val[k][j]);
     730             :              }
     731             :           }
     732             :       }
     733           0 :       fclose(file);
     734           0 :     }
     735           0 :   }
     736             :   // 
     737           0 :   pedCalib->Print("");
     738             :   
     739           0 :   AliCDBMetaData metaData;
     740           0 :   metaData.SetBeamPeriod(0);
     741           0 :   metaData.SetResponsible("Chiara Oppedisano");
     742           0 :   metaData.SetComment("Creating AliZDCPedestals object");  
     743             :   //
     744           0 :   resPedCal = Store("Calib","Pedestals",pedCalib, &metaData, 0, kTRUE);
     745           0 :   if(resPedCal==kFALSE) return 11;
     746             :   //
     747           0 :   if(daqSource1){
     748           0 :     delete daqSource1; 
     749             :     daqSource1 = 0;
     750           0 :   }
     751           0 :   if(daqSource2){
     752           0 :     delete daqSource2; 
     753             :     daqSource2 = 0;
     754           0 :   }
     755             :   
     756           0 :   TList* daqSourceH = GetFileSources(kDAQ, "PEDESTALHISTOS");
     757           0 :   if(!daqSourceH){
     758           0 :     Log(Form("No source for PEDESTALHISTOS id run %d !", fRun));
     759           0 :     return 12;
     760             :   }
     761           0 :   Log("\t List of DAQ sources for PEDESTALHISTOS id: "); daqSourceH->Print();
     762             :   //
     763           0 :   TIter iterH(daqSourceH);
     764             :   TObjString* sourceH = 0;
     765             :   Int_t iH=0;
     766           0 :   while((sourceH = dynamic_cast<TObjString*> (iterH.Next()))){
     767           0 :      TString stringPedFileName = GetFile(kDAQ, "PEDESTALHISTOS", sourceH->GetName());
     768           0 :      if(stringPedFileName.Length() <= 0){
     769           0 :         Log(Form("No PEDESTALHISTOS file from source %s!", sourceH->GetName()));
     770           0 :         return 12;
     771             :      }
     772           0 :      const char* pedFileName = stringPedFileName.Data();
     773           0 :      Log(Form("\t Getting file #%d: %s from %s\n",++iH, pedFileName, sourceH->GetName()));
     774           0 :      resPedHist = StoreReferenceFile(pedFileName, "pedestalReference.root");
     775           0 :      if(resPedHist==kFALSE) return 13;
     776           0 :   }
     777           0 :   delete daqSourceH; daqSourceH=0;
     778             :   
     779           0 :   return 0;
     780           0 : }
     781             : 
     782             : //______________________________________________________________________________________________
     783             : UInt_t AliZDCPreprocessor::ProcessLaserData()
     784             : {
     785           0 :   TList* daqSources = GetFileSources(kDAQ, "LASERDATA");
     786           0 :   if(!daqSources){
     787           0 :     AliError(Form("No sources for STANDALONE_LASER run %d !", fRun));
     788           0 :     return 14;
     789             :   }
     790           0 :   if(daqSources->GetEntries()==0) return 14;
     791           0 :   Log("\t List of DAQ sources for LASERDATA id: "); daqSources->Print();
     792             :   //
     793           0 :   TIter iter2(daqSources);
     794             :   TObjString* source = 0;
     795             :   Int_t i=0;
     796             :   Bool_t resLaserCal=kTRUE, resLaserHist=kTRUE;
     797             :   
     798           0 :   while((source = dynamic_cast<TObjString*> (iter2.Next()))){
     799           0 :      TString stringLaserFileName = GetFile(kDAQ, "LASERDATA", source->GetName());
     800           0 :      if(stringLaserFileName.Length() <= 0){
     801           0 :        Log(Form("No LASER file from source %s!", source->GetName()));
     802           0 :        return 14;
     803             :      }
     804           0 :      const char* laserFileName = stringLaserFileName.Data();
     805           0 :      Log(Form("\t Getting file #%d: %s from %s\n",++i,laserFileName,source->GetName()));
     806             :      //
     807             :      // --- Initializing pedestal calibration object
     808           0 :      AliZDCLaserCalib *lCalib = new AliZDCLaserCalib("ZDC");
     809             :      // --- Reading file with pedestal calibration data
     810           0 :      if(laserFileName){
     811             :        FILE *file;
     812           0 :        if((file = fopen(laserFileName,"r")) == NULL){
     813           0 :          printf("Cannot open file %s \n",laserFileName);
     814           0 :          return 14;
     815             :        }
     816           0 :        Log(Form("File %s connected to process data from LASER events", laserFileName));
     817             :        //
     818           0 :        Float_t ivalRead[22][4]; 
     819           0 :        for(Int_t j=0; j<22; j++){
     820           0 :           for(Int_t k=0; k<4; k++){
     821           0 :             int aleggi = fscanf(file,"%f",&ivalRead[j][k]);
     822           0 :             if(aleggi==0) AliDebug(3," Failng reading data from laser file");
     823             :             //printf(" %d %1.0f  ",k, ivalRead[j][k]);
     824             :           }
     825           0 :           lCalib->SetDetector(j, (Int_t) ivalRead[j][0]);
     826           0 :           lCalib->SetSector(j, (Int_t) ivalRead[j][1]);
     827           0 :           lCalib->SetfPMValue(j, ivalRead[j][2]);
     828           0 :           lCalib->SetfPMWidth(j, ivalRead[j][3]);
     829             :        }
     830           0 :        fclose(file);
     831           0 :      }
     832             :      else{
     833           0 :        Log(Form("File %s not found", laserFileName));
     834           0 :        return 14;
     835             :      }
     836             :      //lCalib->Print("");
     837             :      // 
     838           0 :      AliCDBMetaData metaData;
     839           0 :      metaData.SetBeamPeriod(0);
     840           0 :      metaData.SetResponsible("Chiara Oppedisano");
     841           0 :      metaData.SetComment("Filling AliZDCLaserCalib object");  
     842             :      //
     843           0 :      resLaserCal = Store("Calib","LaserCalib",lCalib, &metaData, 0, kTRUE);
     844           0 :      if(resLaserCal==kFALSE) return 15;
     845           0 :   }
     846           0 :   delete daqSources; daqSources = 0;
     847             : 
     848           0 :   TList* daqSourceH = GetFileSources(kDAQ, "LASERHISTOS");
     849           0 :   if(!daqSourceH){
     850           0 :     AliError(Form("No sources for STANDALONE_LASER run %d !", fRun));
     851           0 :     return 16;
     852             :   }
     853           0 :   Log("\t List of DAQ sources for LASERHISTOS id: "); daqSourceH->Print();
     854             :   //
     855           0 :   TIter iter2H(daqSourceH);
     856             :   TObjString* sourceH = 0;
     857             :   Int_t iH=0;
     858           0 :   while((sourceH = dynamic_cast<TObjString*> (iter2H.Next()))){
     859           0 :      Log(Form("\t Getting file #%d\n",++iH));
     860           0 :      TString stringLaserFileName = GetFile(kDAQ, "LASERHISTOS", sourceH->GetName());
     861           0 :      if(stringLaserFileName.Length() <= 0){
     862           0 :        Log(Form("No LASER file from source %s!", sourceH->GetName()));
     863           0 :        return 16;
     864             :      }
     865           0 :      resLaserHist = StoreReferenceFile(stringLaserFileName.Data(), "laserReference.root");
     866             :      //
     867           0 :      if(resLaserHist==kFALSE) return 17;
     868           0 :   }
     869           0 :   delete daqSourceH; daqSourceH = 0;
     870             :   
     871           0 :   return 0;
     872           0 : }
     873             : 
     874             : 
     875             : //______________________________________________________________________________________________
     876             : UInt_t AliZDCPreprocessor::ProcessMBCalibData()
     877             : {
     878           0 :   TList* daqSources = GetFileSources(kDAQ, "MBCALIB");
     879           0 :   if(!daqSources){
     880           0 :     AliError(Form("No sources for CALIBRATION_MB run %d !", fRun));
     881           0 :     return 18;
     882             :   }
     883           0 :   if(daqSources->GetEntries()==0) return 18;
     884           0 :   Log("\t List of DAQ sources for MBCALIB id: "); daqSources->Print();
     885             :   //
     886           0 :   TIter iter2(daqSources);
     887             :   TObjString* source = 0;
     888             :   Int_t i=0;
     889             :   Bool_t resMBCal=kTRUE;
     890             :   
     891           0 :   while((source = dynamic_cast<TObjString*> (iter2.Next()))){
     892           0 :      TString stringMBFileName = GetFile(kDAQ, "MBCALIB", source->GetName());
     893           0 :      if(stringMBFileName.Length() <= 0){
     894           0 :        Log(Form("No MBCALIB file from source %s!", source->GetName()));
     895           0 :        return 18;
     896             :      }
     897           0 :      const char* mbFileName = stringMBFileName.Data();
     898           0 :      Log(Form("\t Getting file #%d: %s from %s\n",++i,mbFileName,source->GetName()));
     899             :      //
     900             :      // --- Initializing calibration object
     901           0 :      AliZDCMBCalib *mbCalib = new AliZDCMBCalib("ZDC");
     902             :      // --- Reading file with calibration data
     903           0 :      if(mbFileName){
     904           0 :        TFile * fileHistos = TFile::Open(mbFileName);
     905           0 :        Log(Form("File %s connected to process data from CALIBRATION_MB events", mbFileName));
     906             :        //
     907           0 :        fileHistos->cd();
     908           0 :        TH2F *hZDCvsZEM = (TH2F*)  fileHistos->Get("hZDCvsZEM");
     909           0 :        TH2F *hZDCCvsZEM = (TH2F*) fileHistos->Get("hZDCCvsZEM");
     910           0 :        TH2F *hZDCAvsZEM = (TH2F*) fileHistos->Get("hZDCAvsZEM");
     911             :        //
     912           0 :        mbCalib->SetZDCvsZEM(hZDCvsZEM);
     913           0 :        mbCalib->SetZDCCvsZEM(hZDCCvsZEM);
     914           0 :        mbCalib->SetZDCAvsZEM(hZDCAvsZEM);
     915             :        //
     916             :        //fileHistos->Close();
     917             :      }
     918             :      else{
     919           0 :        Log(Form("File %s not found", mbFileName));
     920           0 :        return 14;
     921             :      }
     922             :      // 
     923           0 :      AliCDBMetaData metaData;
     924           0 :      metaData.SetBeamPeriod(0);
     925           0 :      metaData.SetResponsible("Chiara Oppedisano");
     926           0 :      metaData.SetComment("Filling AliZDCMBCalib object");  
     927             :      //
     928             :      //mbCalib->Dump();
     929             :      //
     930           0 :      resMBCal = Store("Calib","MBCalib",mbCalib, &metaData, 0, kTRUE);
     931           0 :      if(resMBCal==kFALSE) return 19;
     932           0 :   }
     933           0 :   delete daqSources; daqSources = 0;
     934             :   
     935           0 :   return 0;
     936           0 : }
     937             : 
     938             : //______________________________________________________________________________________________
     939             : UInt_t AliZDCPreprocessor::Process(TMap* dcsAliasMap)
     940             : {
     941             :  UInt_t resDCS = 0;
     942             :  UInt_t resChMap=0;
     943             :  UInt_t resEnergyCalib=0, resPedestalCalib=0, resLaserCalib=0, resMBCalib=0;
     944             : 
     945             :  // ************************* Process DCS data ****************************
     946           0 :  if(ProcessDCS()) resDCS = ProcessDCSData(dcsAliasMap);
     947             :   
     948             :  // ********************************* From DAQ ************************************
     949             : 
     950           0 :  const char* beamType = GetRunParameter("beamType");
     951           0 :  TString runType = GetRunType();
     952           0 :  Float_t beamEnergy = (Float_t)(((TString)GetRunParameter("beamEnergy")).Atof()); 
     953           0 :  printf("\t **** AliZDCPreprocessor -> runType %s, beamType %s,  beamEnergy %1.0f ****\n",
     954           0 :         runType.Data(),beamType,beamEnergy);
     955             : 
     956             :  // ******************************************
     957             :  // ADC channel mapping
     958             :  // ******************************************
     959           0 :  resChMap = ProcessChMap();
     960             :  
     961             :  // ******************************************
     962             :  // Calibration param. for p-p data (all = 1)
     963             :  // ******************************************
     964             :  // NO ENERGY CALIBRATION -> coefficients set to 1.
     965             :  // Temp -> also inter-calibration coefficients are set to 1.
     966           0 :  if((strcmp(beamType,"p-p")==0) || (strcmp(beamType,"P-P")==0) 
     967           0 :      || (strcmp(beamType,"P-A")==0) || (strcmp(beamType,"A-P")==0)) 
     968           0 :         resEnergyCalib = ProcessppData();
     969             :  
     970             :  // *****************************************************
     971             :  // CALIBRATION_EMD -> Energy calibration and equalization
     972             :  // *****************************************************
     973           0 :  if((strcmp(beamType,"A-A")==0) && (runType.CompareTo("CALIBRATION_EMD")==0)) 
     974           0 :    resEnergyCalib =  ProcessCalibData(beamEnergy);
     975             :  
     976             :  // *****************************************************
     977             :  // STANDALONE_PEDESTALS -> Pedestal subtraction 
     978             :  // *****************************************************
     979           0 :  if(runType.CompareTo("STANDALONE_PEDESTAL")==0) resPedestalCalib = ProcessPedestalData();
     980             :  
     981             :  // *****************************************************
     982             :  // STANDALONE_LASER -> Signal stability and ageing 
     983             :  // *****************************************************
     984           0 :  else if(runType.CompareTo("STANDALONE_LASER")==0) resLaserCalib = ProcessLaserData();
     985             : 
     986             :  // *****************************************************
     987             :  // CALIBRATION_MB -> Signal stability and ageing 
     988             :  // *****************************************************
     989           0 :  else if(runType.CompareTo("CALIBRATION_MB")==0) resMBCalib = ProcessMBCalibData();
     990             :  
     991           0 :  if(resDCS!=0)                return resDCS;
     992           0 :  else if(resChMap!=0)         return resChMap;
     993           0 :  else if(resEnergyCalib!=0)   return resEnergyCalib;
     994           0 :  else if(resPedestalCalib!=0) return resPedestalCalib;
     995           0 :  else if(resLaserCalib!=0)    return resLaserCalib;
     996           0 :  else if(resMBCalib!=0)       return resMBCalib;
     997             :  
     998           0 :  return 0;
     999             :   
    1000           0 : }

Generated by: LCOV version 1.11