AliPhysics  vAN-20150425 (2dcf1b0)
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros
AliEMCalTriggerWeightHandler.cxx
Go to the documentation of this file.
1 /**************************************************************************
2  * Copyright(c) 1998-2014, 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 #include <TF1.h>
16 
18 #include "AliGenPythiaEventHeader.h"
19 #include "AliLog.h"
20 #include "AliMCEvent.h"
21 
25 
26 namespace EMCalTriggerPtAnalysis {
27 
31 AliEMCalTriggerWeightHandler::AliEMCalTriggerWeightHandler() :
32  fWeightModel(NULL),
33  fUsePtHard(kTRUE)
34 {
35 
36 }
37 
43 double AliEMCalTriggerWeightHandler::GetEventWeight(const AliMCEvent* const event) const {
44  if(!fWeightModel) {
45  AliError("Weight model not set - returning 1");
46  return 1.;
47  }
48  double weight = 1.;
49  if(fUsePtHard){
50  const AliGenPythiaEventHeader *header = dynamic_cast<const AliGenPythiaEventHeader *>(event->GenEventHeader());
51  if(header)
52  weight = fWeightModel->Eval(header->GetPtHard());
53  else
54  AliError("Event not a pythia event - returning 1");
55  } else {
56  // Using cross section
57  const AliGenPythiaEventHeader *header = dynamic_cast<const AliGenPythiaEventHeader *>(event->GenEventHeader());
58  if(header)
59  weight = header->GetXsection()/static_cast<double>(header->Trials());
60  else
61  AliError("Event not a pythia event - returning 1");
62  }
63  return weight;
64 }
65 
66 } /* namespace EMCalTriggerPtAnalysis */
ClassImp(AliAnalysisTaskTriggerRates) AliAnalysisTaskTriggerRates
Weight handler for the analysis of high- tracks in EMCAL-triggered events.
double GetEventWeight(const AliMCEvent *const event) const