LCOV - code coverage report
Current view: top level - HLT/TRD - AliHLTTRDClusterHistoComponent.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 20 113 17.7 %
Date: 2016-06-14 17:26:59 Functions: 7 15 46.7 %

          Line data    Source code
       1             : //**************************************************************************
       2             : //* This file is property of and copyright by the ALICE HLT Project        * 
       3             : //* ALICE Experiment at CERN, All rights reserved.                         *
       4             : //*                                                                        *
       5             : //* Primary Authors: Sylwester Radomski radomski@physi.uni-heidelberg.de    *
       6             : //*                  for The ALICE HLT Project.                            *
       7             : //*                                                                        *
       8             : //* Permission to use, copy, modify and distribute this software and its   *
       9             : //* documentation strictly for non-commercial purposes is hereby granted   *
      10             : //* without fee, provided that the above copyright notice appears in all   *
      11             : //* copies and that both the copyright notice and this permission notice   *
      12             : //* appear in the supporting documentation. The authors make no claims     *
      13             : //* about the suitability of this software for any purpose. It is          *
      14             : //* provided "as is" without express or implied warranty.                  *
      15             : //**************************************************************************
      16             : 
      17             : /** @file   AliHLTTRDClusterHistoComponent.cxx
      18             :     @author Sylwester Radomski
      19             :     @brief  Component for ploting charge in clusters
      20             : */
      21             : 
      22             : #include "TFile.h"
      23             : #include "TString.h"
      24             : #include "TObjString.h"
      25             : #include "TClonesArray.h"
      26             : #include "TH1F.h"
      27             : 
      28             : #include "AliHLTTRDClusterHistoComponent.h"
      29             : #include "AliHLTTRDDefinitions.h"
      30             : #include "AliTRDcluster.h"
      31             : #include "AliCDBEntry.h"
      32             : #include "AliCDBManager.h"
      33             : #include "AliHLTTRDUtils.h"
      34             : 
      35             : //#include "AliHLTTRD.h"
      36             : //#include <stdlib.h>
      37             : //#include <cerrno>
      38             : 
      39             : using namespace std;
      40             : 
      41             : /** ROOT macro for the implementation of ROOT specific class methods */
      42           6 : ClassImp(AliHLTTRDClusterHistoComponent)
      43             : 
      44             : AliHLTTRDClusterHistoComponent::AliHLTTRDClusterHistoComponent()
      45           3 : : AliHLTProcessor(),
      46           3 :   fOutputSize(100000),
      47           3 :   fSpec(0),
      48           3 :   fClusterArray(NULL),
      49           3 :   fNClsDet(NULL),
      50           3 :   fClsAmp(NULL),
      51           3 :   fClsAmpDrift(NULL),
      52           3 :   fClsTB(NULL),
      53           3 :   fClsAmpDriftDet(),
      54           3 :   fClsAmpDist(NULL),
      55           3 :   fSClsDist(NULL),
      56           3 :   fNScls(NULL),
      57           3 :   fEvSize(NULL)
      58          15 : {
      59             :   // see header file for class documentation
      60             :   // or
      61             :   // refer to README to build package
      62             :   // or
      63             :   // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
      64           3 :   memset(fClsAmpDriftDet, 0, sizeof(fClsAmpDriftDet));
      65           6 : }
      66             : 
      67             : AliHLTTRDClusterHistoComponent::~AliHLTTRDClusterHistoComponent()
      68          12 : {
      69             :   // see header file for class documentation
      70          12 : }
      71             : 
      72             : // Public functions to implement AliHLTComponent's interface.
      73             : // These functions are required for the registration process
      74             : 
      75             : const char* AliHLTTRDClusterHistoComponent::GetComponentID()
      76             : {
      77             :   // see header file for class documentation
      78             :   
      79         126 :   return "TRDClusterHisto";
      80             : }
      81             : 
      82             : void AliHLTTRDClusterHistoComponent::GetInputDataTypes(AliHLTComponentDataTypeList& list)
      83             : {
      84             :   // see header file for class documentation
      85           0 :   list.clear();
      86           0 :   list.push_back( AliHLTTRDDefinitions::fgkClusterDataType );
      87           0 : }
      88             : 
      89             : AliHLTComponentDataType AliHLTTRDClusterHistoComponent::GetOutputDataType()
      90             : {
      91             :   // see header file for class documentation
      92           0 :   return kAliHLTDataTypeHistogram  | kAliHLTDataOriginTRD;
      93             : 
      94             : }
      95             : 
      96             : void AliHLTTRDClusterHistoComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
      97             : {
      98             :   // see header file for class documentation
      99           0 :   constBase = fOutputSize;
     100           0 :   inputMultiplier = 0;
     101           0 : }
     102             : 
     103             : AliHLTComponent* AliHLTTRDClusterHistoComponent::Spawn()
     104             : {
     105             :   // see header file for class documentation
     106           0 :   return new AliHLTTRDClusterHistoComponent;
     107           0 : }
     108             : 
     109             : int AliHLTTRDClusterHistoComponent::DoInit(int argc, const char** argv)
     110             : {
     111             :   // Initialize histograms
     112             :   int iResult=0;
     113             :   
     114           0 :   TString configuration="";
     115           0 :   TString argument="";
     116           0 :   for (int i=0; i<argc && iResult>=0; i++) {
     117           0 :     argument=argv[i];
     118           0 :     if (!configuration.IsNull()) configuration+=" ";
     119           0 :     configuration+=argument;
     120             :   }
     121             : 
     122           0 :   if (!configuration.IsNull()) {
     123           0 :     iResult=Configure(configuration.Data());
     124           0 :   } 
     125             : 
     126           0 :   fClusterArray = new TClonesArray("AliTRDcluster");
     127             : 
     128           0 :   fNClsDet = new TH1F("trdClsDet", ";detector", 540, -0.5, 539.5);
     129           0 :   fClsAmp  = new TH1F("trdClsAmp", ";amplitude", 200, -0.5, 1999.5);
     130           0 :   fClsAmpDrift = new TH1F("trdClsAmpDrift", ";amplitude", 200, -0.5, 199.5) ;
     131           0 :   fClsTB = new TH1F("trdClsTB", ";time bin", 35, -0.5, 34.5);
     132           0 :   fClsAmpDist = new TH1F("trdClsAmpDist", "mean amplitude", 200, 0, 1000);
     133           0 :   fSClsDist = new TH1F("sclsdist", "Super cluster spectrum", 200, 0, 8000);
     134           0 :   fNScls = new TH1F("nscls", "No. of Kr clusters per event", 540, 0, 540);
     135           0 :   fEvSize = new TH1F("TrdClEvSize", "Clusters size per event per ddl in kbyte", 512, 0, 512);
     136             : 
     137           0 :   for(int i=0; i<540; i++) {
     138           0 :     fClsAmpDriftDet[i] = new TH1F(Form("trdClsDriftDet_%d",i), "", 200, -0.5, 199.5);
     139             :   }
     140             :   
     141             :   return 0;
     142           0 : }
     143             :   
     144             : int AliHLTTRDClusterHistoComponent::DoDeinit()
     145             : {
     146             :   // see header file for class documentation
     147             : 
     148           0 :   fClusterArray->Delete();
     149           0 :   delete fClusterArray;
     150             : 
     151             :   // delete histograms
     152           0 :   if (fNClsDet) delete fNClsDet;
     153           0 :   if (fClsAmp) delete fClsAmp;
     154           0 :   if (fClsAmpDrift) delete fClsAmpDrift;
     155           0 :   if (fClsTB) delete fClsTB;
     156           0 :   if (fClsAmpDist) delete fClsAmpDist;
     157           0 :   if (fSClsDist) delete fSClsDist;
     158           0 :   if (fNScls) delete fNScls;
     159           0 :   if (fEvSize) delete fEvSize;
     160             : 
     161           0 :   for(int i=0; i<540; i++){
     162           0 :     if (fClsAmpDriftDet[i]) delete fClsAmpDriftDet[i];
     163             :   }
     164             : 
     165           0 :   return 0;
     166             : }
     167             : 
     168             : int AliHLTTRDClusterHistoComponent::DoEvent(const AliHLTComponentEventData& /*evtData*/,
     169             :                                             AliHLTComponentTriggerData& /*trigData*/)
     170             : {
     171             : 
     172             :   // if (GetFirstInputBlock(kAliHLTDataTypeSOR)) return 0;
     173             :   // else if (GetFirstInputBlock(kAliHLTDataTypeEOR))
     174             :   //   {
     175             :   //     TString fileName="/tmp/ClusterHistoDump_run";
     176             :   //     fileName+=AliCDBManager::Instance()->GetRun();
     177             :   //     fileName+=".root";
     178             :   //     HLTInfo("Dumping Histogram file to %s",fileName.Data());
     179             :   //     TFile* file = TFile::Open(fileName, "RECREATE");
     180             :   //     fNClsDet->Write();
     181             :   //     fClsAmp->Write();
     182             :   //     fClsAmpDrift->Write();
     183             :   //     fClsTB->Write();
     184             :   //     fClsAmpDist->Write(); 
     185             :   //     fSClsDist->Write();
     186             :   //     fNScls->Write();
     187             :   //     file->Close();
     188             :   //     HLTInfo("Histogram file dumped");
     189             :   //     return 0;
     190             :   //   }
     191             : 
     192           0 :   if(!IsDataEvent())return 0;
     193             : 
     194             :   const AliHLTComponentBlockData* iter = NULL;
     195             :   Bool_t gotData = kFALSE;
     196             : 
     197           0 :   for ( iter = GetFirstInputBlock(AliHLTTRDDefinitions::fgkClusterDataType); 
     198           0 :         iter != NULL; iter = GetNextInputBlock() ) {
     199             : 
     200           0 :     fEvSize->Fill((iter->fSize+0.5f)/1024);
     201           0 :     AliHLTTRDUtils::ReadClusters(fClusterArray, iter->fPtr, iter->fSize);
     202             :     HLTDebug("TClonesArray of clusters: nbEntries = %i", fClusterArray->GetEntriesFast());
     203             :     gotData = kTRUE;
     204           0 :     fSpec |= iter->fSpecification;
     205             :   }
     206             : 
     207           0 :   if(!gotData) return 0;
     208             : 
     209           0 :   Float_t sClusterCharge[540] = { 0 };
     210             :     AliTRDcluster *cls;
     211             : 
     212             :     // loop over clusters 
     213           0 :     for(int i=0;i<fClusterArray->GetEntriesFast();i++) {
     214             : 
     215           0 :       cls=(AliTRDcluster*)fClusterArray->At(i);
     216             :       
     217           0 :       fNClsDet->Fill(cls->GetDetector());
     218           0 :       fClsAmp->Fill(cls->GetQ());
     219             :       
     220           0 :       int tb = cls->GetPadTime();
     221           0 :       fClsTB->Fill(tb);
     222           0 :     if (tb > 5 && tb <25){
     223           0 :         fClsAmpDrift->Fill(cls->GetQ()); 
     224           0 :     }
     225             :       
     226             :     //fClsAmpDriftDet[cls->GetDetector()]->Fill(cls->GetQ());
     227             : 
     228           0 :       Int_t det = cls->GetDetector();
     229           0 :       sClusterCharge[det] += cls->GetQ();
     230             : 
     231             :     }
     232             :     
     233           0 :     fClusterArray->Delete();
     234             :     
     235             :   //fClsAmpDist->Reset();
     236             :   //Int_t nSClusters = 0;
     237           0 :   for(int det=0; det<540; det++) {
     238             :     // if (fClsAmpDriftDet[det]->GetSum() > 0) 
     239             :     //   fClsAmpDist->Fill(fClsAmpDriftDet[det]->GetMean());
     240           0 :     if(sClusterCharge[det])
     241           0 :     fSClsDist->Fill(sClusterCharge[det]);
     242             :   }
     243             : 
     244             :   //fNScls->Fill(nSClusters);
     245             : 
     246           0 :   PushBack((TObject*)fNClsDet, kAliHLTDataTypeHistogram | kAliHLTDataOriginTRD, fSpec);
     247           0 :   PushBack((TObject*)fClsAmp, kAliHLTDataTypeHistogram | kAliHLTDataOriginTRD, fSpec);
     248           0 :   PushBack((TObject*)fClsAmpDrift, kAliHLTDataTypeHistogram | kAliHLTDataOriginTRD, fSpec);
     249           0 :   PushBack((TObject*)fClsTB, kAliHLTDataTypeHistogram | kAliHLTDataOriginTRD, fSpec);
     250             :   //PushBack((TObject*)fClsAmpDist, kAliHLTDataTypeHistogram | kAliHLTDataOriginTRD, fSpec);
     251             :   //PushBack((TObject*)fNScls, kAliHLTDataTypeHistogram | kAliHLTDataOriginTRD, fSpec);
     252           0 :   PushBack((TObject*)fSClsDist, kAliHLTDataTypeHistogram | kAliHLTDataOriginTRD, fSpec);
     253           0 :   PushBack((TObject*)fEvSize, kAliHLTDataTypeHistogram | kAliHLTDataOriginTRD, fSpec);
     254             : 
     255             :   return 0;
     256           0 : }
     257             : 
     258             : int AliHLTTRDClusterHistoComponent::Configure(const char* arguments){
     259             :   int iResult=0;
     260           0 :   if (!arguments) return iResult;
     261             :   
     262           0 :   TString allArgs=arguments;
     263           0 :   TString argument;
     264             :   int bMissingParam=0;
     265             : 
     266           0 :   TObjArray* pTokens=allArgs.Tokenize(" ");
     267           0 :   if (pTokens) {
     268           0 :     for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) {
     269           0 :       argument=((TObjString*)pTokens->At(i))->GetString();
     270           0 :       if (argument.IsNull()) continue;
     271             :       
     272           0 :       if (argument.CompareTo("output_size")==0) {
     273           0 :         if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
     274           0 :         HLTInfo("Setting output size to: %s", ((TObjString*)pTokens->At(i))->GetString().Data());
     275           0 :         fOutputSize=((TObjString*)pTokens->At(i))->GetString().Atoi();
     276           0 :         continue;
     277             :       } 
     278             :       else {
     279           0 :         HLTError("unknown argument: %s", argument.Data());
     280             :         iResult=-EINVAL;
     281           0 :         break;
     282             :       }
     283             :     }
     284           0 :     delete pTokens;
     285             :   }
     286           0 :   if (bMissingParam) {
     287           0 :     HLTError("missing parameter for argument %s", argument.Data());
     288             :     iResult=-EINVAL;
     289           0 :   }
     290             :   return iResult;
     291           0 : }

Generated by: LCOV version 1.11