LCOV - code coverage report
Current view: top level - HLT/EMCAL - AliHLTEMCALTriggerMakerComponent.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 11 132 8.3 %
Date: 2016-06-14 17:26:59 Functions: 7 16 43.8 %

          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: Markus Fasel                                          *
       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 "AliHLTCaloDigitDataStruct.h"
      16             : #include "AliHLTCaloTriggerHeaderStruct.h"
      17             : #include "AliHLTCaloTriggerDataStruct.h"
      18             : #include "AliHLTCaloTriggerPatchDataStruct.h"
      19             : 
      20             : #include "AliHLTEMCALDefinitions.h"
      21             : #include "AliHLTEMCALGeometry.h"
      22             : #include "AliHLTEMCALTriggerMaker.h"
      23             : #include "AliHLTEMCALTriggerMakerComponent.h"
      24             : 
      25             : #include <TStopwatch.h>
      26             : 
      27             : #include <bitset>
      28             : #include <iostream>
      29             : 
      30           6 : ClassImp(AliHLTEMCALTriggerMakerComponent)
      31             : 
      32             : //AliHLTEMCALTriggerMakerComponent gAliHLTEMCALTriggerMakerComponent;
      33             : 
      34             : AliHLTEMCALTriggerMakerComponent::AliHLTEMCALTriggerMakerComponent() :
      35           3 :   AliHLTCaloProcessor(),
      36           3 :   fTriggerMakerPtr(NULL),
      37           3 :   fGeometry(NULL)
      38          15 : {
      39           6 : }
      40             : 
      41          18 : AliHLTEMCALTriggerMakerComponent::~AliHLTEMCALTriggerMakerComponent() {
      42           3 :   if(fTriggerMakerPtr) delete fTriggerMakerPtr;
      43           3 :   if(fGeometry) delete fGeometry;
      44           9 : }
      45             : 
      46             : int AliHLTEMCALTriggerMakerComponent::DoEvent ( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
      47             :                 AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size,
      48             :                 std::vector<AliHLTComponentBlockData>& outputBlocks ){  
      49           0 :   if(!blocks) {
      50           0 :     return 0;
      51             :   }
      52             : 
      53             :   //patch in order to skip calib events
      54           0 :   if(! IsDataEvent()){
      55           0 :     return 0;
      56             :   }
      57             : 
      58             : #ifdef __PROFILE__
      59             :   TStopwatch profile;
      60             :   profile.Start();
      61             : #endif
      62             : 
      63             :   //see header file for documentation
      64             :   UInt_t offset           = 0;
      65             :   UInt_t mysize           = 0;
      66             :   Int_t digitCount        = 0;
      67             :   Int_t ret               = 0;
      68             : 
      69             :   UInt_t specification = 0;
      70             : 
      71           0 :   fTriggerMakerPtr->ResetADC();
      72             : 
      73             :   const AliHLTComponentBlockData* iter = 0;
      74             :   AliHLTCaloDigitDataStruct *digit = NULL;
      75             :   AliHLTCaloTriggerHeaderStruct *triggerhead = NULL;
      76             :   AliHLTCaloTriggerDataStruct *dataptr = NULL;
      77             : 
      78             :   Int_t nDigits = 0, nDigitsGlob = 0, nfastor = 0;
      79           0 :   for(Int_t ndx = 0; ndx < evtData.fBlockCnt; ndx++){
      80           0 :     iter = blocks + ndx;
      81             : 
      82           0 :     if(!CheckInputDataType(iter->fDataType)){
      83             :       continue;
      84             :     }
      85             : 
      86           0 :     if(iter->fDataType == AliHLTEMCALDefinitions::fgkDigitDataType) {
      87           0 :       digit = reinterpret_cast<AliHLTCaloDigitDataStruct*>(iter->fPtr);
      88           0 :       nDigits = iter->fSize/sizeof(AliHLTCaloDigitDataStruct);
      89             :       HLTDebug("Block %d received %d digits\n", ndx, nDigits);
      90           0 :       for(Int_t idigit = 0; idigit < nDigits; idigit++){
      91           0 :         fTriggerMakerPtr->AddDigit(digit);
      92           0 :         digit++;
      93             :       }
      94           0 :       nDigitsGlob += nDigits;
      95           0 :     } else if(iter->fDataType == (kAliHLTDataTypeCaloTrigger | kAliHLTDataOriginEMCAL)){
      96           0 :       triggerhead = reinterpret_cast<AliHLTCaloTriggerHeaderStruct *>(iter->fPtr);
      97           0 :       AliHLTCaloTriggerDataStruct *dataptr = reinterpret_cast<AliHLTCaloTriggerDataStruct *>(reinterpret_cast<AliHLTUInt8_t* >(iter->fPtr) + sizeof(AliHLTCaloTriggerHeaderStruct));
      98             :       HLTDebug("Block %d received %d fastor triggers", ndx, triggerhead->fNfastor);
      99           0 :       for(Int_t datacount = 0; datacount < triggerhead->fNfastor; datacount++) {
     100           0 :         fTriggerMakerPtr->SetADC(dataptr->fCol, dataptr->fRow, static_cast<Float_t>(dataptr->fL1TimeSum));
     101           0 :         fTriggerMakerPtr->SetL0Amplitude(dataptr->fCol, dataptr->fRow, static_cast<Float_t>(dataptr->fAmplitude));
     102           0 :         fTriggerMakerPtr->SetBitMask(dataptr->fCol, dataptr->fRow, dataptr->fTriggerBits);
     103           0 :         if (dataptr->fNL0Times > 0) {
     104           0 :           fTriggerMakerPtr->SetL0Time(Int_t(dataptr->fCol), Int_t(dataptr->fRow), dataptr->fL0Times[0]);
     105           0 :         }
     106           0 :         dataptr++;
     107             :       }
     108           0 :       nfastor += triggerhead->fNfastor;
     109           0 :     }
     110             :   }
     111             :   
     112             :   Int_t npatches = 0;
     113           0 :   if(nfastor || nDigitsGlob){
     114           0 :     fTriggerMakerPtr->SetTriggerPatchDataPtr(reinterpret_cast<AliHLTCaloTriggerPatchDataStruct *>(outputPtr), size - sizeof(AliHLTCaloTriggerHeaderStruct));
     115           0 :     npatches = fTriggerMakerPtr->FindPatches();
     116             :     HLTDebug("Found %d patches from fastors\n", npatches);
     117           0 :     outputPtr += npatches;
     118           0 :     mysize += sizeof(AliHLTCaloTriggerPatchDataStruct) * npatches;
     119           0 :   }
     120             :   
     121           0 :   if(mysize != 0){
     122           0 :     AliHLTComponentBlockData bd;
     123           0 :     FillBlockData( bd );
     124           0 :     bd.fOffset = offset;
     125           0 :     bd.fSize = mysize;
     126           0 :     bd.fDataType = AliHLTEMCALDefinitions::fgkTriggerPatchDataType;
     127           0 :     bd.fSpecification = 0;
     128           0 :     outputBlocks.push_back(bd);
     129           0 :   }
     130           0 :   size = mysize;
     131             : 
     132             : #ifdef __PROFILE__
     133             :   profile.Stop();
     134             :   printf("End of trigger maker component: %f (Wall) / %f (CPU)\n", profile.RealTime(), profile.CpuTime());
     135             : #endif
     136             :   return 0;
     137           0 : }
     138             : 
     139             : bool AliHLTEMCALTriggerMakerComponent::CheckInputDataType(const AliHLTComponentDataType &datatype) {
     140             :   //comment
     141           0 :   vector <AliHLTComponentDataType> validTypes;
     142           0 :   GetInputDataTypes(validTypes);
     143             : 
     144           0 :   for(UInt_t i=0; i < validTypes.size(); i++) {
     145           0 :     if ( datatype  ==  validTypes.at(i) ) {
     146           0 :       return true;
     147             :     }
     148             :   }
     149             : 
     150             :   HLTDebug("Invalid Datatype");
     151           0 :   return false;
     152           0 : }
     153             : 
     154             : const char* AliHLTEMCALTriggerMakerComponent::GetComponentID(){
     155             :   //See headerfile for documentation
     156         270 :   return "EmcalTriggerMaker";
     157             : }
     158             : 
     159             : void AliHLTEMCALTriggerMakerComponent::GetInputDataTypes(std::vector<AliHLTComponentDataType>& list){
     160           0 :   list.clear();
     161           0 :   list.push_back(AliHLTEMCALDefinitions::fgkDigitDataType);
     162           0 :   list.push_back(kAliHLTDataTypeCaloTrigger | kAliHLTDataOriginEMCAL);
     163           0 : }
     164             : 
     165             : AliHLTComponentDataType AliHLTEMCALTriggerMakerComponent::GetOutputDataType(){
     166           0 :   return AliHLTEMCALDefinitions::fgkTriggerPatchDataType;
     167             : }
     168             : 
     169             : void AliHLTEMCALTriggerMakerComponent::GetOutputDataSize ( unsigned long& constBase, double& inputMultiplier ){
     170           0 :   constBase = 10000 *(float)sizeof(AliHLTCaloTriggerPatchDataStruct) + sizeof(AliHLTCaloTriggerHeaderStruct);
     171           0 :   inputMultiplier = 0; // (float)sizeof(AliHLTCaloTriggerPatchDataStruct)/sizeof(AliHLTCaloDigitDataStruct)+1;
     172           0 : }
     173             : 
     174             : AliHLTComponent* AliHLTEMCALTriggerMakerComponent::Spawn(){
     175           0 :   return new AliHLTEMCALTriggerMakerComponent();
     176           0 : }
     177             : 
     178             : 
     179             : int AliHLTEMCALTriggerMakerComponent::DoInit ( int argc, const char** argv ){
     180           0 :   InitialiseGeometry();
     181           0 :   Float_t jetTh[2*AliHLTEMCALTriggerMaker::kNthresholds] = {0};
     182           0 :   Float_t gammaTh[2*AliHLTEMCALTriggerMaker::kNthresholds] = {0};
     183             :   Float_t bkgTh[2] = {0}, l0Th[2] = {0};
     184           0 :   Bool_t isPbPb = GetRunNo() > 244823 && GetRunNo() < 246995; // For the moment quick hack to distinguish PbPb from pp
     185           0 :   Bool_t runBkgAlgo = isPbPb;
     186           0 :   Int_t jetpatchsize = isPbPb ? 8 : 16;
     187           0 :   for(Int_t iarg = 0; iarg < argc; iarg++){
     188           0 :     TString argstring(argv[iarg]);
     189           0 :     if(argstring.Contains("-gammalowonthresh")){
     190           0 :       gammaTh[AliHLTEMCALTriggerMaker::kLowThreshold] = TString(argv[++iarg]).Atof();
     191           0 :     } else if(argstring.Contains("-gammalowoffthresh")){
     192           0 :       gammaTh[AliHLTEMCALTriggerMaker::kLowThreshold + AliHLTEMCALTriggerMaker::kNthresholds] = TString(argv[++iarg]).Atof();
     193           0 :     } else if(argstring.Contains("-gammahighonthresh")){
     194           0 :       gammaTh[AliHLTEMCALTriggerMaker::kHighThreshold] = TString(argv[++iarg]).Atof();
     195           0 :     } else if(argstring.Contains("-gammahighoffthresh")){
     196           0 :       gammaTh[AliHLTEMCALTriggerMaker::kHighThreshold + AliHLTEMCALTriggerMaker::kNthresholds] = TString(argv[++iarg]).Atof();
     197           0 :     } else if(argstring.Contains("-jetlowonthresh")){
     198           0 :       jetTh[AliHLTEMCALTriggerMaker::kLowThreshold] = TString(argv[++iarg]).Atof();
     199           0 :     } else if(argstring.Contains("-jetlowoffthresh")){
     200           0 :       jetTh[AliHLTEMCALTriggerMaker::kLowThreshold + AliHLTEMCALTriggerMaker::kNthresholds] = TString(argv[++iarg]).Atof();
     201           0 :     } else if(argstring.Contains("-jethighonthresh")){
     202           0 :       jetTh[AliHLTEMCALTriggerMaker::kHighThreshold] = TString(argv[++iarg]).Atof();
     203           0 :     } else if(argstring.Contains("-jethighoffthresh")){
     204           0 :       jetTh[AliHLTEMCALTriggerMaker::kHighThreshold + AliHLTEMCALTriggerMaker::kNthresholds] = TString(argv[++iarg]).Atof();
     205           0 :     } else if(argstring.Contains("-runbkgalgo")){
     206             :       runBkgAlgo = true;
     207           0 :     } else if(argstring.Contains("-bkgonthresh")){
     208           0 :       bkgTh[0] = TString(argv[++iarg]).Atof();
     209           0 :     } else if(argstring.Contains("-bkgoffthresh")){
     210           0 :       bkgTh[1] = TString(argv[++iarg]).Atof();
     211           0 :     } else if(argstring.Contains("-l0onthresh")){
     212           0 :       l0Th[0] = TString(argv[++iarg]).Atof();
     213           0 :     } else if(argstring.Contains("-l0offthresh")){
     214           0 :       l0Th[1] = TString(argv[++iarg]).Atof();
     215           0 :     } else if(argstring.Contains("-jetpatchsize")){
     216           0 :       jetpatchsize = TString(argv[++iarg]).Atoi();
     217           0 :     }
     218           0 :   }
     219             :   if(runBkgAlgo)
     220             :     HLTDebug("running jet background algorithm\n");
     221             :   else
     222             :     HLTDebug("do not run the jet background algorithm\n");
     223           0 :   fTriggerMakerPtr = new AliHLTEMCALTriggerMaker;
     224           0 :   fTriggerMakerPtr->SetJetPatch(jetpatchsize, 4);
     225           0 :   fTriggerMakerPtr->SetRunBkgAlgorithm(runBkgAlgo);
     226           0 :   for(UInt_t ithresh = AliHLTEMCALTriggerMaker::kHighThreshold; ithresh < AliHLTEMCALTriggerMaker::kNthresholds; ithresh++){
     227           0 :     fTriggerMakerPtr->SetGammaThresholds(AliHLTEMCALTriggerMaker::ThresholdType_t(ithresh), gammaTh[ithresh], gammaTh[ithresh + AliHLTEMCALTriggerMaker::kNthresholds]);
     228           0 :     fTriggerMakerPtr->SetJetThresholds(AliHLTEMCALTriggerMaker::ThresholdType_t(ithresh), jetTh[ithresh], jetTh[ithresh + AliHLTEMCALTriggerMaker::kNthresholds]);
     229             :   }
     230           0 :   fTriggerMakerPtr->SetLevel0Thresholds(l0Th[0], l0Th[1]);
     231           0 :   fTriggerMakerPtr->SetBkgThresholds(bkgTh[0], bkgTh[1]);
     232           0 :   fTriggerMakerPtr->Initialise(fGeometry);
     233           0 :   return 0;
     234           0 : }
     235             : 
     236             : int AliHLTEMCALTriggerMakerComponent::Deinit(){
     237           0 :   if(fTriggerMakerPtr){
     238           0 :     delete fTriggerMakerPtr;
     239           0 :     fTriggerMakerPtr = 0;
     240           0 :   }
     241           0 :   if(fGeometry){
     242           0 :     delete fGeometry;
     243           0 :     fGeometry = 0;
     244           0 :   }
     245           0 :   return 0;
     246             : }
     247             : 
     248             : void AliHLTEMCALTriggerMakerComponent::InitialiseGeometry(){
     249           0 :   fGeometry = new AliHLTEMCALGeometry(GetRunNo());
     250           0 : }

Generated by: LCOV version 1.11