LCOV - code coverage report
Current view: top level - HLT/EMCAL - AliHLTEMCALTriggerQAComponent.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 21 153 13.7 %
Date: 2016-06-14 17:26:59 Functions: 9 25 36.0 %

          Line data    Source code
       1             : /**************************************************************************
       2             :  * This file is property of and copyright by the ALICE HLT Project        *
       3             :  * All rights reserved.                                                   *
       4             :  *                                                                        *
       5             :  * Primary Authors: Salvatore Aiola                                       *
       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             : #include <vector>
      16             : 
      17             : #include <TObjArray.h>
      18             : #include <THashList.h>
      19             : #include <TH1.h>
      20             : #include <TString.h>
      21             : #include <TStopwatch.h>
      22             : 
      23             : #include "AliEMCALTriggerConstants.h"
      24             : #include "AliEMCALTriggerFastOR.h"
      25             : #include "AliEMCALTriggerOnlineQAPbPb.h"
      26             : #include "AliEMCALTriggerOnlineQAPP.h"
      27             : #include "AliEMCALTriggerPatchInfo.h"
      28             : #include "AliEMCALTriggerBitConfig.h"
      29             : #include "AliEMCALGeometry.h"
      30             : 
      31             : #include "AliHLTCTPData.h"
      32             : 
      33             : #include "AliHLTCaloTriggerPatchDataStruct.h"
      34             : #include "AliHLTCaloTriggerHeaderStruct.h"
      35             : #include "AliHLTCaloTriggerDataStruct.h"
      36             : 
      37             : #include "AliHLTEMCALDefinitions.h"
      38             : #include "AliHLTEMCALGeometry.h"
      39             : //#include "AliHLTEMCALCaloCells.h"
      40             : 
      41             : #include "AliHLTEMCALTriggerQAComponent.h"
      42          27 : 
      43           6 : ClassImp(AliHLTEMCALTriggerQAComponent)
      44             : 
      45             : AliHLTEMCALTriggerQAComponent::AliHLTEMCALTriggerQAComponent() :
      46           3 :   AliHLTCaloProcessor(),
      47           3 :   fTriggerBitConfig(NULL),
      48           3 :   fHistoResetOnPush(kTRUE),
      49           3 :   fFilterTrgClass(""),
      50           3 :   fBeamType(kPP),
      51           3 :   fLocalEventCount(0),
      52           3 :   fGeometry(NULL),
      53           3 :   fTriggerQAPtr(NULL),
      54           3 :   fFiredTriggerClasses()
      55          15 : {
      56           3 :   SetPP2016TriggerClasses();
      57           6 : }
      58             : 
      59             : AliHLTEMCALTriggerQAComponent::~AliHLTEMCALTriggerQAComponent()
      60          18 : {
      61           3 :   if (fTriggerQAPtr) delete fTriggerQAPtr;
      62           3 :   if (fGeometry) delete fGeometry;
      63           9 : }
      64             : 
      65             : int AliHLTEMCALTriggerQAComponent::RetrieveFiredTriggerClasses()
      66             : {
      67             :   int nTrgClasses = 0;
      68           0 :   fFiredTriggerClasses.clear();
      69           0 :   const AliHLTCTPData * ctpdata = this->CTPData();
      70           0 :   if (ctpdata) {
      71           0 :     AliHLTComponentTriggerData trgdat;
      72           0 :     AliHLTTriggerMask_t mask = ctpdata->ActiveTriggers(trgdat);
      73           0 :     for (int index=0; index<gkNCTPTriggerClasses; index++) {
      74           0 :       if ((mask&(AliHLTTriggerMask_t(0x1)<<index)) == 0) continue;
      75           0 :       TString trgClass = ctpdata->Name(index);
      76           0 :       if (!fFilterTrgClass.IsNull() && !fFilterTrgClass.Contains(trgClass)) continue;
      77           0 :       fFiredTriggerClasses.push_back(trgClass);
      78           0 :       nTrgClasses++;
      79           0 :     }
      80           0 :   }
      81           0 :   return nTrgClasses;
      82           0 : }
      83             : 
      84             : int AliHLTEMCALTriggerQAComponent::DoEvent(const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
      85             :     AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* /*outputPtr*/, AliHLTUInt32_t& /*size*/,
      86             :     std::vector<AliHLTComponentBlockData>& /*outputBlocks*/)
      87             : {
      88             :   //static AliHLTEMCALCaloCells cells;
      89             :   // Creates the container, if not yet done. It also clears it.
      90             :   //cells.CreateContainer(fGeometry->GetGeometryPtr()->GetNCells());
      91             : 
      92             :   //patch in order to skip calib events
      93           0 :   if (!IsDataEvent()) return 0;
      94             : 
      95           0 :   if (!blocks) return 0;
      96             : 
      97             : #ifdef __PROFILE__
      98             :   TStopwatch profile;
      99             :   profile.Start();
     100             : #endif
     101             : 
     102           0 :   if (!RetrieveFiredTriggerClasses()) {
     103             :     HLTDebug("No trigger classes received\n");
     104             :   }
     105             : 
     106             :   const AliHLTComponentBlockData* iter = 0;
     107             : 
     108             :   const AliHLTComponentBlockData* patchData = 0;
     109             :   const AliHLTComponentBlockData* fastorData = 0;
     110             :   const AliHLTComponentBlockData* cellData = 0;
     111             : 
     112           0 :   for (Int_t ndx = 0; ndx < evtData.fBlockCnt; ndx++) {
     113           0 :     iter = blocks + ndx;
     114             : 
     115           0 :     if(!CheckInputDataType(iter->fDataType)) continue;
     116             : 
     117             :     /*
     118             :     if (iter->fDataType == AliHLTEMCALDefinitions::fgkDigitDataType) {
     119             :       cellData = iter;
     120             :     }
     121             :     else
     122             :     */
     123             : 
     124           0 :     if (iter->fDataType == AliHLTEMCALDefinitions::fgkTriggerPatchDataType) {
     125             :       patchData = iter;
     126           0 :     }
     127           0 :     else if (iter->fDataType == (kAliHLTDataTypeCaloTrigger | kAliHLTDataOriginEMCAL)) {
     128             :       fastorData = iter;
     129           0 :     }
     130             :   }
     131             : 
     132             :   //ProcessCells(cellData, cells);
     133           0 :   ProcessTriggerPatches(patchData);
     134           0 :   ProcessTriggerFastors(fastorData, 0);
     135             : 
     136           0 :   fTriggerQAPtr->EventCompleted();
     137             : 
     138           0 :   fLocalEventCount++;
     139             : 
     140             : #ifdef __PROFILE__
     141             :   profile.Stop();
     142             :   printf("End of trigger maker QA: %f (Wall) / %f (CPU)\n", profile.RealTime(), profile.CpuTime());
     143             : #endif
     144             : 
     145           0 :   PushHistograms(fTriggerQAPtr->GetListOfHistograms());
     146             : 
     147             :   return 0;
     148           0 : }
     149             : /*
     150             : void AliHLTEMCALTriggerQAComponent::ProcessCells(const AliHLTComponentBlockData* block, AliHLTEMCALCaloCells& cells)
     151             : {
     152             :   if (!block) return;
     153             :   AliHLTCaloDigitDataStruct* digit = reinterpret_cast<AliHLTCaloDigitDataStruct*>(block->fPtr);
     154             :   if (!digit) return;
     155             : 
     156             : #ifdef __PROFILE__
     157             :   TStopwatch profile;
     158             :   profile.Start();
     159             : #endif
     160             : 
     161             :   Int_t nDigits = block->fSize/sizeof(AliHLTCaloDigitDataStruct);
     162             : 
     163             :   for (Int_t idigit = 0; idigit < nDigits; idigit++){
     164             :     cells.AddCell(digit->fID, digit->fEnergy);
     165             :     digit++;
     166             :   }
     167             : 
     168             : #ifdef __PROFILE__
     169             :   profile.Stop();
     170             :   printf("End of ProcessCells: %f (Wall) / %f (CPU)\n", profile.RealTime(), profile.CpuTime());
     171             : #endif
     172             : }
     173             : */
     174             : void AliHLTEMCALTriggerQAComponent::PushHistograms(TCollection* list)
     175             : {
     176           0 :   TIter next(list);
     177             : 
     178             :   TH1* histo = 0;
     179             : 
     180           0 :   while ((histo = static_cast<TH1*>(next()))) {
     181           0 :     if (histo->GetEntries() > 0) {
     182           0 :       Int_t nbytes = PushBack(histo, kAliHLTDataTypeHistogram | kAliHLTDataOriginEMCAL , 0);
     183           0 :       if (fHistoResetOnPush && nbytes > 0) {
     184           0 :         histo->Reset();
     185             :       }
     186           0 :     }
     187             :   }
     188           0 : }
     189             : 
     190             : void AliHLTEMCALTriggerQAComponent::ProcessTriggerPatches(const AliHLTComponentBlockData* block)
     191             : {
     192           0 :   if (!block) return;
     193           0 :   AliHLTCaloTriggerPatchDataStruct* hltpatchPtr = reinterpret_cast<AliHLTCaloTriggerPatchDataStruct*>(block->fPtr);
     194           0 :   if (!hltpatchPtr) return;
     195             : 
     196             : #ifdef __PROFILE__
     197             :   TStopwatch profile;
     198             :   profile.Start();
     199             : #endif
     200             : 
     201           0 :   UInt_t nPatches = block->fSize/sizeof(AliHLTCaloTriggerPatchDataStruct);
     202             : 
     203           0 :   AliEMCALTriggerPatchInfo patch;
     204           0 :   patch.SetTriggerBitConfig(fTriggerBitConfig);
     205           0 :   patch.SetOffSet(fTriggerBitConfig->GetTriggerTypesEnd());
     206             : 
     207           0 :   if (fBeamType == kPbPb) {
     208           0 :     for(UInt_t ipatch = 0; ipatch < nPatches; ipatch++) {
     209           0 :       HLTPatch2Patch(hltpatchPtr[ipatch], patch);
     210           0 :       fTriggerQAPtr->ProcessBkgPatch(&patch);
     211             :     }
     212             : 
     213           0 :     fTriggerQAPtr->ComputeBackground();
     214             :   }
     215             : 
     216             :   HLTDebug("Number of patches: %d", nPatches);
     217           0 :   for(UInt_t ipatch = 0; ipatch < nPatches; ipatch++) {
     218           0 :     HLTPatch2Patch(hltpatchPtr[ipatch], patch);
     219           0 :     fTriggerQAPtr->ProcessPatch(&patch);
     220             :   }
     221             : #ifdef __PROFILE__
     222             :   profile.Stop();
     223             :   printf("End of ProcessTriggerPatches: %f (Wall) / %f (CPU)\n", profile.RealTime(), profile.CpuTime());
     224             : #endif
     225           0 : }
     226             : 
     227             : void AliHLTEMCALTriggerQAComponent::ProcessTriggerFastors(const AliHLTComponentBlockData* block, const AliHLTEMCALCaloCells* /*cells*/)
     228             : {
     229           0 :   if (!block) return;
     230           0 :   AliHLTCaloTriggerPatchDataStruct* hltpatchPtr = reinterpret_cast<AliHLTCaloTriggerPatchDataStruct*>(block->fPtr);
     231           0 :   if (!hltpatchPtr) return;
     232             : 
     233             : #ifdef __PROFILE__
     234             :   TStopwatch profile;
     235             :   profile.Start();
     236             : #endif
     237             : 
     238           0 :   AliHLTCaloTriggerHeaderStruct* triggerhead = reinterpret_cast<AliHLTCaloTriggerHeaderStruct *>(block->fPtr);
     239           0 :   AliHLTCaloTriggerDataStruct *dataptr = reinterpret_cast<AliHLTCaloTriggerDataStruct *>(reinterpret_cast<AliHLTUInt8_t* >(block->fPtr) + sizeof(AliHLTCaloTriggerHeaderStruct));
     240             : 
     241           0 :   AliEMCALTriggerFastOR fastor;
     242             : 
     243             :   HLTDebug("Received %d fastor triggers", triggerhead->fNfastor);
     244           0 :   for(Int_t datacount = 0; datacount < triggerhead->fNfastor; datacount++) {
     245           0 :     HLTFastor2Fastor(dataptr[datacount], fastor);
     246           0 :     fTriggerQAPtr->ProcessFastor(&fastor, 0);
     247             :   }
     248             : 
     249             : #ifdef __PROFILE__
     250             :   profile.Stop();
     251             :   printf("End of ProcessTriggerFastors: %f (Wall) / %f (CPU)\n", profile.RealTime(), profile.CpuTime());
     252             : #endif
     253           0 : }
     254             : 
     255             : bool AliHLTEMCALTriggerQAComponent::CheckInputDataType(const AliHLTComponentDataType &datatype)
     256             : {
     257           0 :   vector <AliHLTComponentDataType> validTypes;
     258           0 :   GetInputDataTypes(validTypes);
     259             : 
     260           0 :   for(UInt_t i = 0; i < validTypes.size(); i++) {
     261           0 :     if (datatype == validTypes.at(i)) {
     262           0 :       return true;
     263             :     }
     264             :   }
     265             : 
     266             :   HLTDebug("Invalid Datatype");
     267           0 :   return false;
     268           0 : }
     269             : 
     270             : void AliHLTEMCALTriggerQAComponent::HLTPatch2Patch(const AliHLTCaloTriggerPatchDataStruct& htlpatch, AliEMCALTriggerPatchInfo& patch) const
     271             : {
     272           0 :   const TVector3 vect(0,0,0);
     273           0 :   patch.Initialize(htlpatch.fCol, htlpatch.fRow, htlpatch.fSize, htlpatch.fADC, htlpatch.fOfflineADC, EMCALTrigger::kEMCL1ADCtoGeV*htlpatch.fADC, htlpatch.fBitMask, vect, fGeometry->GetGeometryPtr());
     274           0 : }
     275             : 
     276             : void AliHLTEMCALTriggerQAComponent::HLTFastor2Fastor(const AliHLTCaloTriggerDataStruct& hltfastor, AliEMCALTriggerFastOR& fastor) const
     277             : {  
     278             :   Int_t l0time = 0;
     279           0 :   if (hltfastor.fNL0Times > 0) {
     280           0 :     l0time = hltfastor.fL0Times[0];
     281           0 :   }
     282           0 :   fastor.Initialize(hltfastor.fAmplitude, hltfastor.fL1TimeSum, hltfastor.fRow, hltfastor.fCol, l0time, fGeometry->GetGeometryPtr());
     283           0 : }
     284             : 
     285             : const char* AliHLTEMCALTriggerQAComponent::GetComponentID()
     286             : {
     287             :   //See headerfile for documentation
     288         264 :   return "EmcalTriggerQA";
     289             : }
     290             : 
     291             : void AliHLTEMCALTriggerQAComponent::GetInputDataTypes(std::vector<AliHLTComponentDataType>& list)
     292             : {
     293           0 :   list.clear();
     294           0 :   list.push_back(AliHLTEMCALDefinitions::fgkTriggerPatchDataType);
     295           0 :   list.push_back(kAliHLTDataTypeCaloTrigger | kAliHLTDataOriginEMCAL);
     296             :   //list.push_back(AliHLTEMCALDefinitions::fgkDigitDataType);
     297           0 : }
     298             : 
     299             : AliHLTComponentDataType AliHLTEMCALTriggerQAComponent::GetOutputDataType()
     300             : {
     301           0 :   return kAliHLTDataTypeHistogram | kAliHLTDataOriginEMCAL;
     302             : }
     303             : 
     304             : void AliHLTEMCALTriggerQAComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier)
     305             : {
     306             :   //see header file for documentation
     307             :   //constBase = 250000000;
     308           0 :   constBase = 250000;
     309             :   // to be reviewed later
     310           0 :   inputMultiplier = 0;
     311           0 : }
     312             : 
     313             : AliHLTComponent* AliHLTEMCALTriggerQAComponent::Spawn()
     314             : {
     315           0 :   return new AliHLTEMCALTriggerQAComponent();
     316           0 : }
     317             : 
     318             : 
     319             : int AliHLTEMCALTriggerQAComponent::DoInit(int argc, const char** argv)
     320             : {
     321             :   //Init the CTP data
     322           0 :   if (SetupCTPData() == -ENOMEM) {
     323           0 :     HLTError("could not SetupCTPData(); ENOMEM");
     324           0 :     return -ENOMEM;
     325             :   }
     326           0 :   InitialiseGeometry();
     327             : 
     328             :   Int_t debugLevel = 0;
     329             : 
     330           0 :   Bool_t isPbPb = GetRunNo() > 244823 && GetRunNo() < 246995; // For the moment quick hack to distinguish PbPb from pp
     331           0 :   fBeamType = isPbPb ? kPbPb : kPP;
     332             : 
     333           0 :   for (int i = 0; i < argc; i++) {
     334           0 :     TString option(argv[i]);
     335           0 :     if (option == "-pp") fBeamType = kPP;
     336           0 :     if (option == "-PbPb") fBeamType = kPbPb;
     337           0 :     if (option == "-newTriggerBitConfig") fTriggerBitConfig = new AliEMCALTriggerBitConfigNew;
     338           0 :     if (option == "-oldTriggerBitConfig") fTriggerBitConfig = new AliEMCALTriggerBitConfigOld;
     339           0 :     if (option == "-noHistoReset") fHistoResetOnPush = kFALSE;
     340           0 :     if (option.BeginsWith("-debugLevel")) {
     341           0 :       option.Remove(0, 11);
     342           0 :       debugLevel = option.Atoi();
     343           0 :       if (debugLevel < 0) debugLevel = 0;
     344           0 :     }
     345           0 :   }
     346             : 
     347           0 :   switch (fBeamType) {
     348             :   case kPP:
     349           0 :     fTriggerQAPtr = new AliEMCALTriggerOnlineQAPP("PPTriggerQA");
     350           0 :     break;
     351             :   case kPbPb:
     352           0 :     fTriggerQAPtr = new AliEMCALTriggerOnlineQAPbPb("PbPbTriggerQA");
     353           0 :     break;
     354             :   }
     355             : 
     356           0 :   fTriggerQAPtr->SetEMCALGeometry(fGeometry->GetGeometryPtr());
     357           0 :   fTriggerQAPtr->Init();
     358             : 
     359           0 :   fTriggerQAPtr->SetDebugLevel(debugLevel);
     360             : 
     361             :   // if not specified use new trigger bit config
     362           0 :   if (!fTriggerBitConfig) fTriggerBitConfig = new AliEMCALTriggerBitConfigNew;
     363             : 
     364             :   return 0;
     365           0 : }
     366             : 
     367             : int AliHLTEMCALTriggerQAComponent::Deinit()
     368             : {
     369           0 :   if (fTriggerQAPtr) {
     370           0 :     delete fTriggerQAPtr;
     371           0 :     fTriggerQAPtr = 0;
     372           0 :   }
     373             : 
     374           0 :   if (fGeometry) {
     375           0 :     delete fGeometry;
     376           0 :     fGeometry = 0;
     377           0 :   }
     378             : 
     379           0 :   return 0;
     380             : }
     381             : 
     382             : void AliHLTEMCALTriggerQAComponent::InitialiseGeometry()
     383             : {
     384           0 :   fGeometry = new AliHLTEMCALGeometry(GetRunNo());
     385           0 : }
     386             : 
     387             : void AliHLTEMCALTriggerQAComponent::SetPbPb2015TriggerClasses()
     388             : {
     389           0 :   fFilterTrgClass = "CINT7-B-NOPF-CENT"
     390             :       "CINT7EG1-B-NOPF-CENTNOPMD CINT7EG2-B-NOPF-CENTNOPMD CINT7EJ1-B-NOPF-CENTNOPMD CINT7EJ2-B-NOPF-CENTNOPMD"
     391             :       "CINT7DG1-B-NOPF-CENTNOPMD CINT7DG2-B-NOPF-CENTNOPMD CINT7DJ1-B-NOPF-CENTNOPMD CINT7DJ2-B-NOPF-CENTNOPMD";
     392           0 : }
     393             : 
     394             : void AliHLTEMCALTriggerQAComponent::SetPP2016TriggerClasses()
     395             : {
     396           6 :   fFilterTrgClass = "";
     397           3 : }

Generated by: LCOV version 1.11