LCOV - code coverage report
Current view: top level - TRIGGER - AliTRIPreprocessor.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 94 1.1 %
Date: 2016-06-14 17:26:59 Functions: 1 12 8.3 %

          Line data    Source code
       1             : /**************************************************************************
       2             :  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
       3             :  *                                                                        *
       4             :  * Author: The ALICE Off-line Project.                                    *
       5             :  * Contributors are mentioned in the code where appropriate.              *
       6             :  *                                                                        *
       7             :  * Permission to use, copy, modify and distribute this software and its   *
       8             :  * documentation strictly for non-commercial purposes is hereby granted   *
       9             :  * without fee, provided that the above copyright notice appears in all   *
      10             :  * copies and that both the copyright notice and this permission notice   *
      11             :  * appear in the supporting documentation. The authors make no claims     *
      12             :  * about the suitability of this software for any purpose. It is          *
      13             :  * provided "as is" without express or implied warranty.                  *
      14             :  **************************************************************************/
      15             : 
      16             : /* $Id$*/
      17             : 
      18             : // Trigger preprocessor class. 
      19             : // According to the TriggerDetectorMask read from the logbook_trigger_clusters
      20             : // DAQ table, the triggering detectors are identified, and the 
      21             : // corresponding procedure is called.
      22             : // Data are stored in the OCDB, in /TRIGGER/<DET>/<level3>, where
      23             : // <DET> correspond to the triggering detector,
      24             : // and <level3> is defined in the detector procedure
      25             : 
      26             : #include "AliTRIPreprocessor.h"
      27             : 
      28             : #include "AliCDBMetaData.h"
      29             : #include "AliCDBEntry.h"
      30             : #include "AliLog.h"
      31             : #include "AliITSTriggerConditions.h"
      32             : 
      33             : #include "AliTOFFEEReader.h"
      34             : #include "AliTOFTriggerMask.h"
      35             :           
      36             : #include <TTimeStamp.h>
      37             : #include <TObjString.h>
      38             : #include <TList.h>
      39             : #include <TROOT.h>
      40             : #include <TSystem.h>
      41             : 
      42          12 : ClassImp(AliTRIPreprocessor)
      43             : 
      44             : // names of detectors/systems in the DETECTORS_MAP in /date/db/detCodes.h
      45             : const char* AliTRIPreprocessor::fgkDetectorsMapName[AliTRIPreprocessor::kNDetectorsMap] = {"SPD"/*0*/, "SDD"/*1*/, "SSD"/*2*/, "TPC"/*3*/, "TRD"/*4*/, 
      46             :                                                                                "TOF"/*5*/, "HMP"/*6*/, "PHS"/*7*/, "CPV"/*8*/, "PMD"/*9*/, 
      47             :                                                                                "MCH"/*10*/,"MTR"/*11*/,"FMD"/*12*/,"T00"/*13*/,"V00"/*14*/, 
      48             :                                                                                "ZDC"/*15*/,"ACO"/*16*/,"TRI"/*17*/,"EMC"/*18*/,"TST"/*19*/, 
      49             :                                                                                ""/*20*/,   ""/*21*/,   ""/*22*/,   ""/*23*/,   ""/*24*/,   
      50             :                                                                                ""/*25*/,   ""/*26*/,   ""/*27*/,   ""/*28*/,   "GRP"/*29*/, 
      51             :                                                                                "HLT"/*30*/};
      52             : 
      53             : //______________________________________________________________________________________________
      54             : AliTRIPreprocessor::AliTRIPreprocessor(AliShuttleInterface* shuttle) :
      55           0 :   AliPreprocessor("TRI", shuttle),
      56           0 :   fShuttle(shuttle)
      57             : 
      58           0 : {
      59             :         //
      60             :         // constructor
      61             :         //
      62             :         
      63           0 :         AddRunType("PHYSICS");
      64           0 :         AddRunType("STANDALONE_PULSER");
      65           0 : }
      66             : 
      67             : //______________________________________________________________________________________________
      68             : AliTRIPreprocessor::~AliTRIPreprocessor()
      69           0 : {
      70             :         //
      71             :         // destructor
      72             :         //
      73           0 : }
      74             : 
      75             : //______________________________________________________________________________________________
      76             : void AliTRIPreprocessor::Initialize(Int_t run, UInt_t startTime,
      77             :         UInt_t endTime)
      78             : {
      79             : 
      80             :         //
      81             :         // Initialize preprocessor
      82             :         //
      83             : 
      84           0 :         AliPreprocessor::Initialize(run, startTime, endTime);
      85             : 
      86           0 :         Log(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run,
      87           0 :                 TTimeStamp(startTime).AsString(),
      88           0 :                 TTimeStamp(endTime).AsString()));
      89             : 
      90           0 : }
      91             : 
      92             : //______________________________________________________________________________________________
      93             : Bool_t AliTRIPreprocessor::ProcessDCS()
      94             : {
      95             :         //
      96             :         // DCS data are never needed
      97             :         //
      98             :         
      99           0 :         return kFALSE;
     100             : }
     101             : 
     102             : //______________________________________________________________________________________________
     103             : UInt_t AliTRIPreprocessor::Process(TMap* /*dcsAliasMap*/)
     104             : {
     105             : 
     106             :         // Procees function:
     107             :         // After reading the TriggerDetectorMask, the
     108             :         // corresponding triggering detector procedures to 
     109             :         // process the trigger data are called.
     110             : 
     111             :         typedef Short_t (AliTRIPreprocessor::*AliProcessTriggerData)();
     112             :         const AliProcessTriggerData processTriggerDataArray[AliTRIPreprocessor::kNDetectorsMap]= { 
     113             :                 &AliTRIPreprocessor::ProcessSPDTriggerData,
     114             :                 &AliTRIPreprocessor::ProcessEmptyTriggerData,
     115             :                 &AliTRIPreprocessor::ProcessEmptyTriggerData,
     116             :                 &AliTRIPreprocessor::ProcessEmptyTriggerData,
     117             :                 &AliTRIPreprocessor::ProcessEmptyTriggerData,
     118             :                 &AliTRIPreprocessor::ProcessTOFTriggerData,
     119             :                 &AliTRIPreprocessor::ProcessEmptyTriggerData,
     120             :                 &AliTRIPreprocessor::ProcessEmptyTriggerData,
     121             :                 &AliTRIPreprocessor::ProcessEmptyTriggerData,
     122             :                 &AliTRIPreprocessor::ProcessEmptyTriggerData,
     123             :                 &AliTRIPreprocessor::ProcessEmptyTriggerData,
     124             :                 &AliTRIPreprocessor::ProcessEmptyTriggerData,
     125             :                 &AliTRIPreprocessor::ProcessEmptyTriggerData,
     126             :                 &AliTRIPreprocessor::ProcessEmptyTriggerData,
     127             :                 &AliTRIPreprocessor::ProcessEmptyTriggerData,
     128             :                 &AliTRIPreprocessor::ProcessEmptyTriggerData,
     129             :                 &AliTRIPreprocessor::ProcessEmptyTriggerData,
     130             :                 &AliTRIPreprocessor::ProcessEmptyTriggerData,
     131             :                 &AliTRIPreprocessor::ProcessEmptyTriggerData,
     132             :                 &AliTRIPreprocessor::ProcessEmptyTriggerData,
     133             :                 &AliTRIPreprocessor::ProcessEmptyTriggerData,
     134             :                 &AliTRIPreprocessor::ProcessEmptyTriggerData,
     135             :                 &AliTRIPreprocessor::ProcessEmptyTriggerData,
     136             :                 &AliTRIPreprocessor::ProcessEmptyTriggerData,
     137             :                 &AliTRIPreprocessor::ProcessEmptyTriggerData,
     138             :                 &AliTRIPreprocessor::ProcessEmptyTriggerData,
     139             :                 &AliTRIPreprocessor::ProcessEmptyTriggerData,
     140             :                 &AliTRIPreprocessor::ProcessEmptyTriggerData,
     141             :                 &AliTRIPreprocessor::ProcessEmptyTriggerData,
     142             :                 &AliTRIPreprocessor::ProcessEmptyTriggerData,
     143             :                 &AliTRIPreprocessor::ProcessEmptyTriggerData}; 
     144             : 
     145             : 
     146             :         // getting the list of triggering detectors from DAQ logbook
     147             : 
     148           0 :         TString triggerDetectorMask = (TString)GetTriggerDetectorMask();
     149             :         Int_t result=0;
     150           0 :         if (!triggerDetectorMask.IsNull()){
     151           0 :                 Int_t length = triggerDetectorMask.Length();
     152           0 :                 Log(Form("mask = %s", triggerDetectorMask.Data()));
     153           0 :                   for (Int_t i = 0; i<length; i++){
     154           0 :                         AliDebug(2,Form("%d-th bit = %c in index %d",i,triggerDetectorMask[length-1-i],length-1-i));
     155           0 :                         if (triggerDetectorMask[length-1-i] == '1'){
     156           0 :                                 Log("****************************************");
     157           0 :                                 Log(Form("Processing Trigger data for %s",fgkDetectorsMapName[i]));
     158           0 :                                 Log("****************************************");
     159             :                                
     160           0 :                                 result+=(this->*processTriggerDataArray[i])();
     161           0 :                         }
     162             :                 }
     163           0 :         }
     164             : 
     165             :         // result should be 0 to end successfully
     166             : 
     167             :         return result;
     168             : 
     169           0 : }
     170             : //______________________________________________________________________________________________
     171             : Short_t AliTRIPreprocessor::ProcessSPDTriggerData() 
     172             : {
     173             :         //
     174             :         // Processing SPD Trigger Data
     175             :         //
     176             :         
     177           0 :         Log("************** Processing SPD Trigger data... **************");
     178             : 
     179             :         // Read new conditions from dcs fxs
     180           0 :         AliITSTriggerConditions* newCond = new AliITSTriggerConditions();
     181           0 :         TString fxsID = "pit_conditions";
     182           0 :         TList* list = GetFileSources(kDCS, fxsID.Data());
     183           0 :         if (!list) {
     184           0 :                 AliError("FXS file not found.");
     185           0 :                 return 1;
     186             :         }
     187             :         UInt_t nFiles = 0;
     188           0 :         while (list->At(nFiles)!=NULL) {
     189           0 :                 TObjString* fileNameEntry = (TObjString*) list->At(nFiles);
     190           0 :                 TString fileName = GetFile(kDCS, fxsID.Data(), fileNameEntry->GetString().Data());
     191           0 :                 if (fileName.IsNull()) {
     192           0 :                         Log(Form("GetFile failed to retrieve file %s.",fileNameEntry->GetString().Data()));
     193           0 :                         return 1;
     194             :                 }
     195           0 :                 if (nFiles==0) newCond->ReadFromTextFile(fileName.Data());
     196           0 :                 nFiles++;
     197           0 :         }
     198           0 :         if (nFiles!=1) {
     199           0 :                 AliWarning(Form("Found %d files with id %s (expected exactly 1).",nFiles,fxsID.Data()));
     200             :         }
     201             :         
     202             :         // Read old conditions from ocdb
     203             :         AliITSTriggerConditions* oldCond = NULL;
     204           0 :         AliCDBEntry* pitCond = GetFromOCDB("SPD", "PITConditions");
     205           0 :         if (pitCond) {
     206           0 :                 oldCond = (AliITSTriggerConditions*) pitCond->GetObject();
     207           0 :                 if (!oldCond) {
     208           0 :                         AliError("AliCDBEntry::GetObject() returned NULL.");
     209           0 :                         return 1;
     210             :                 }
     211             :         }
     212             :         else {
     213           0 :                 Log("Old conditions not found in database.");
     214             :         }
     215             :         
     216             :         // Do we need to update db?
     217             :         Bool_t doUpdate = kTRUE;
     218           0 :         if (oldCond) {
     219             :                 // compare to see if there were any changes...
     220           0 :                 if (newCond->IsEqualTo(oldCond)) {
     221           0 :                         Log("Old conditions equal to new conditions. Do nothing.");
     222             :                         doUpdate = kFALSE;
     223           0 :                 }
     224             :         }
     225             :         
     226           0 :         if (doUpdate) {
     227             :                 // store new conditions in ocdb
     228           0 :                 AliCDBMetaData metaData;
     229           0 :                 metaData.SetResponsible("Henrik Tydesjo");
     230           0 :                 metaData.SetComment("Created by Trigger PreProcessor");
     231           0 :                 if (!Store("SPD", "PITConditions", newCond, &metaData, 0, kTRUE)) {
     232           0 :                         Log("Failed to store conditions data.");
     233           0 :                         return 1;
     234             :                 }
     235           0 :                 Log("Database updated.");
     236           0 :         }
     237             :         
     238           0 :         delete newCond;
     239             :         
     240           0 :         Log("************************* ...done.*************************");
     241             : 
     242           0 :         return 0; // 0 means success
     243             :         
     244           0 : }
     245             : //______________________________________________________________________________________________
     246             : Short_t AliTRIPreprocessor::ProcessTOFTriggerData() 
     247             : {
     248             :         //
     249             :         // Processing TOF Trigger Data
     250             :         //
     251             : 
     252           0 :         Log("************** Processing TOF Trigger data... **************");
     253             : 
     254           0 :         const char * nameFile = GetFile(kDCS,"TofFeeLightMap", ""); 
     255           0 :         AliInfo(Form("toffeeLight file name = %s",nameFile));
     256           0 :         if (nameFile == NULL) {
     257           0 :           return 1;
     258             :         } 
     259           0 :         AliTOFFEEReader feeReader;
     260           0 :         feeReader.LoadFEElightConfig(nameFile);
     261           0 :         feeReader.ParseFEElightConfig();
     262           0 :         AliTOFTriggerMask triggerMask;
     263           0 :         triggerMask.SetTriggerMaskArray(feeReader.GetTriggerMaskArray());
     264             : 
     265           0 :         AliCDBMetaData metaData;
     266           0 :         metaData.SetBeamPeriod(0);
     267           0 :         metaData.SetResponsible("Roberto Preghenella");
     268           0 :         metaData.SetComment("TOF trigger mask");
     269           0 :         if (!Store("TOF", "TriggerMask", &triggerMask, &metaData, 0, kTRUE)) {
     270           0 :           Log("error while storing TriggerMask object");
     271           0 :           return 1;
     272             :         }
     273           0 :         Log("TriggerMask object successfully stored");
     274             : 
     275           0 :         Log("************************* ...done.*************************");
     276           0 :         return 0;
     277           0 : }
     278             : //______________________________________________________________________________________________
     279             : Short_t AliTRIPreprocessor::ProcessEmptyTriggerData() 
     280             : {
     281             :         //
     282             :         // Processing TOF Trigger Data
     283             :         //
     284             : 
     285           0 :         Log("************** Trigger data Processing not yet implemented **************");
     286           0 :         return 0;
     287             : }
     288             : 
     289             : 

Generated by: LCOV version 1.11