]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGHF/correlationHF/AliDxHFECorrelationMC.cxx
Coverity fixes (8443)
[u/mrichter/AliRoot.git] / PWGHF / correlationHF / AliDxHFECorrelationMC.cxx
1
2 //**************************************************************************
3 //* This file is property of and copyright by the ALICE Project            * 
4 //* ALICE Experiment at CERN, All rights reserved.                         *
5 //*                                                                        *
6 //* Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no>        *
7 //*                  Sedat Altinpinar <Sedat.Altinpinar@cern.ch>           *
8 //*                  Hege Erdal       <hege.erdal@gmail.com>               *
9 //*                                                                        *
10 //* Permission to use, copy, modify and distribute this software and its   *
11 //* documentation strictly for non-commercial purposes is hereby granted   *
12 //* without fee, provided that the above copyright notice appears in all   *
13 //* copies and that both the copyright notice and this permission notice   *
14 //* appear in the supporting documentation. The authors make no claims     *
15 //* about the suitability of this software for any purpose. It is          *
16 //* provided "as is" without express or implied warranty.                  *
17 //**************************************************************************
18
19 // $Id$
20
21 /// @file   AliDxHFECorrelationMC.cxx
22 /// @author Sedat Altinpinar, Hege Erdal, Matthias Richter
23 /// @date   2012-11-02
24 /// @brief  Worker class for DxHFE correlation
25 ///
26
27 #include "AliDxHFECorrelationMC.h"
28 #include "AliVParticle.h"
29 #include "AliLog.h"
30 //#include "AliAnalysisCuts.h"         // required dependency libANALYSISalice.so
31 //#include "AliFlowTrackSimple.h"      // required dependency libPWGflowBase.so
32 //#include "AliFlowCandidateTrack.h"   // required dependency libPWGflowTasks.so
33 //#include "AliCFContainer.h"          // required dependency libCORRFW.so
34 //#include "AliAODRecoDecayHF2Prong.h"   // libPWGHFvertexingHF
35 #include "TObjArray.h"
36 #include "AliDxHFECorrelation.h"
37 #include "TMath.h"
38 #include "TFile.h"
39 #include "TCanvas.h"
40 #include "TDatabasePDG.h"
41 #include "TLorentzVector.h"
42 #include "AliReducedParticle.h"
43 #include "AliDxHFEParticleSelection.h"
44 #include <iostream>
45 #include <cerrno>
46 #include <memory>
47
48 using namespace std;
49
50 ClassImp(AliDxHFECorrelationMC)
51
52 AliDxHFECorrelationMC::AliDxHFECorrelationMC(const char* name)
53   : AliDxHFECorrelation(name?name:"AliDxHFECorrelationMC")
54   , fMCEventType(0)
55 {
56   // default constructor
57   // 
58   //
59
60 }
61
62
63 AliDxHFECorrelationMC::~AliDxHFECorrelationMC()
64 {
65   // destructor
66   //
67   //
68
69 }
70
71 THnSparse* AliDxHFECorrelationMC::DefineTHnSparse()
72 {
73   //
74   // Defines the THnSparse. 
75
76   AliDebug(1, "Creating Corr THnSparse");
77   // here is the only place to change the dimension
78   static const int sizeEventdphi = 10;  
79   InitTHnSparseArray(sizeEventdphi);
80   const double pi=TMath::Pi();
81   Double_t minPhi=GetMinPhi();
82   Double_t maxPhi=GetMaxPhi();
83
84   // TODO: Everything here needed for eventmixing? 
85   //                                            0        1     2      3      4     5       6      7    8      9
86   //                                          D0invmass  PtD0 PhiD0 PtbinD0 Pte  dphi    dEta OrigD0 origEl process
87   int         binsEventdphi[sizeEventdphi] = {   200,   1000,  100,  21,   1000, 100,     100,   10,     14,  100 };
88   double      minEventdphi [sizeEventdphi] = { 1.5648,     0,    0,   0,     0 , minPhi, -0.9, -1.5,   -1.5, -0.5 };
89   double      maxEventdphi [sizeEventdphi] = { 2.1648,   100, 2*pi,  20,    100, maxPhi,  0.9,  8.5,   12.5, 99.5 };
90   const char* nameEventdphi[sizeEventdphi] = {
91     "D0InvMass",
92     "PtD0",
93     "PhiD0",
94     "PtBinD0",
95     "PtEl",
96     "#Delta#Phi",
97     "#Delta#eta", 
98     "Origin D0", 
99     "Origin Electron",
100     "Original Process"
101 };
102
103   TString name;
104   name.Form("%s info", GetName());
105
106
107   return CreateControlTHnSparse(name,sizeEventdphi,binsEventdphi,minEventdphi,maxEventdphi,nameEventdphi);
108
109
110 }
111
112
113 int AliDxHFECorrelationMC::FillParticleProperties(AliVParticle* tr, AliVParticle *as, Double_t* data, int dimension) const
114 {
115   // fill the data array from the particle data
116   if (!data) return -EINVAL;
117   AliReducedParticle *ptrigger=(AliReducedParticle*)tr;
118   AliReducedParticle *assoc=(AliReducedParticle*)as;
119   if (!ptrigger || !assoc) return -ENODATA;
120   int i=0;
121   if (dimension!=GetDimTHnSparse()) {
122     // TODO: think about filling only the available data and throwing a warning
123     return -ENOSPC;
124   }
125   if(AliDxHFECorrelation::GetTriggerParticleType()==kD){
126     data[i++]=ptrigger->GetInvMass();
127     data[i++]=ptrigger->Pt();
128     data[i++]=ptrigger->Phi();
129     data[i++]=ptrigger->GetPtBin(); 
130     data[i++]=assoc->Pt();
131   } 
132   else{
133     data[i++]=assoc->GetInvMass();
134     data[i++]=assoc->Pt();
135     data[i++]=assoc->Phi();
136     data[i++]=assoc->GetPtBin(); 
137     data[i++]=ptrigger->Pt();
138   }
139   data[i++]=AliDxHFECorrelation::GetDeltaPhi();
140   data[i++]=AliDxHFECorrelation::GetDeltaEta();
141   if(AliDxHFECorrelation::GetTriggerParticleType()==kD){
142     data[i++]=ptrigger->GetOriginMother();
143     data[i++]=assoc->GetOriginMother();
144   }
145   else {
146     data[i++]=assoc->GetOriginMother();
147     data[i++]=ptrigger->GetOriginMother();
148   }
149   data[i++]=fMCEventType;
150   
151   return i;
152 }
153
154 int AliDxHFECorrelationMC::Fill(const TObjArray* triggerCandidates, TObjArray* associatedTracks, const AliVEvent* pEvent)
155 {
156   // TODO: Implement more on MC?? (Needed?)
157   return AliDxHFECorrelation::Fill(triggerCandidates,associatedTracks,pEvent);
158 }
159