LCOV - code coverage report
Current view: top level - STEER/STEERBase - AliGenEventHeader.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 27 40 67.5 %
Date: 2016-06-14 17:26:59 Functions: 7 9 77.8 %

          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             : //---------------------------------------------------------------------
      19             : // Event header base class for generator. 
      20             : // Stores as a minimum the date, run number, event number,
      21             : // number of particles produced  
      22             : // and the impact parameter.
      23             : // Author: andreas.morsch@cern.ch
      24             : //---------------------------------------------------------------------
      25             : 
      26             : #include "AliLog.h"
      27             : #include "AliGenEventHeader.h"
      28         176 : ClassImp(AliGenEventHeader)
      29             : 
      30             : //_______________________________________________________________________
      31         619 : AliGenEventHeader::AliGenEventHeader():
      32         619 :   fNProduced(-1),
      33         619 :   fVertex(3),
      34         619 :   fInteractionTime(0.),
      35         619 :   fEventWeight(1.),
      36         619 :   fEventWeights(),
      37         619 :   fEventWeightNameGenerator("gen")
      38        2861 : {
      39             :   //
      40             :   // Constructor
      41             :   //
      42        1121 : }
      43             : 
      44             : //_______________________________________________________________________
      45          20 : AliGenEventHeader::AliGenEventHeader(const char * name):
      46          20 :   TNamed(name, "Event Header"),
      47          20 :   fNProduced(-1),
      48          20 :   fVertex(3),
      49          20 :   fInteractionTime(0.),
      50          20 :   fEventWeight(1.)
      51          92 : {
      52             :   //
      53             :   // Constructor
      54             :   //
      55          36 : }
      56             : 
      57             : //_______________________________________________________________________
      58             : void AliGenEventHeader::SetPrimaryVertex(const TArrayF &o)
      59             : {
      60             :     //
      61             :     // Set the primary vertex for the event
      62             :     //
      63          40 :     fVertex[0]=o.At(0);
      64          20 :     fVertex[1]=o.At(1);
      65          20 :     fVertex[2]=o.At(2);
      66          20 : }
      67             : 
      68             : //_______________________________________________________________________
      69             : void  AliGenEventHeader::PrimaryVertex(TArrayF &o) const
      70             : {
      71             :     //
      72             :     // Return the primary vertex for the event
      73             :     //
      74           8 :     o.Set(3);
      75           4 :     o[0] = fVertex.At(0);
      76           4 :     o[1] = fVertex.At(1);
      77           4 :     o[2] = fVertex.At(2);    
      78           4 : }
      79             : 
      80             : Float_t AliGenEventHeader::GetEventWeight(const TString &name)
      81             : {
      82             :   // return weight associated to name,
      83             :   // if not found return 1
      84             : 
      85             :   // for compatibility we return fEventWeight
      86             :   // when generator weight is requested but map is empty
      87           0 :   if (fEventWeights.empty() && (name == fEventWeightNameGenerator))
      88           0 :     return fEventWeight;
      89           0 :   else if (fEventWeights.find(name.Data()) != fEventWeights.end())
      90           0 :     return fEventWeights[name.Data()];
      91             :   else
      92           0 :     return 1.;
      93           0 : }
      94             :  
      95             : void AliGenEventHeader::AddEventWeight(const TString &name, Float_t w)
      96             : {
      97             :   // add new event name
      98             : 
      99           0 :   if (fEventWeights.find(name.Data()) != fEventWeights.end()) {
     100           0 :     AliWarning(Form("Updating already existing event weight <%s>", name.Data()));
     101           0 :     fEventWeights[name.Data()] *= w;
     102           0 :   } else {
     103           0 :     fEventWeights[name.Data()] = w;
     104             :   }
     105             :   
     106           0 :   fEventWeight *= w;
     107           0 : }

Generated by: LCOV version 1.11