]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG/CaloTrackCorrBase/AliCaloTrackESDReader.cxx
replace printf's by AliDebug/AliInfo/AliWarning
[u/mrichter/AliRoot.git] / PWG / CaloTrackCorrBase / AliCaloTrackESDReader.cxx
1
2 /**************************************************************************
3  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4  *                                                                        *
5  * Author: The ALICE Off-line Project.                                    *
6  * Contributors are mentioned in the code where appropriate.              *
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 //_________________________________________________________________________
18 // Class for reading data (ESDs) in order to do prompt gamma 
19 // or other particle identification and correlations
20 //
21 //
22 //
23 //
24 //*-- Author: Gustavo Conesa (LNF-INFN) 
25 //////////////////////////////////////////////////////////////////////////////
26
27
28 //---- ANALYSIS system ----
29 #include "AliCaloTrackESDReader.h" 
30 #include "AliAODEvent.h"
31 #include "AliMultiEventInputHandler.h"
32 #include "AliAnalysisManager.h"
33 #include "AliMixedEvent.h"
34 #include "AliESDEvent.h"
35 #include "AliESDtrackCuts.h"
36 #include "AliLog.h"
37
38 ClassImp(AliCaloTrackESDReader)
39
40 //______________________________________________
41 AliCaloTrackESDReader::AliCaloTrackESDReader() : 
42 AliCaloTrackReader(), fConstrainTrack(0),
43 fESDtrackCuts(0), fESDtrackComplementaryCuts(0)
44 {
45   //Default Ctor
46   
47   //Initialize parameters
48   fDataType           = kESD;
49   fReadStack          = kTRUE;
50   fReadAODMCParticles = kFALSE;
51   fConstrainTrack     = kFALSE ; // constrain tracks to vertex
52
53 }
54
55 //_____________________________________________
56 AliCaloTrackESDReader::~AliCaloTrackESDReader()
57 {
58   //Dtor
59   
60   //AliCaloTrackReader::~AliCaloTrackReader();
61   AliCaloTrackReader::DeletePointers();
62   
63   delete fESDtrackCuts;
64   delete fESDtrackComplementaryCuts;
65 }
66
67 //_________________________________________________________
68 Bool_t AliCaloTrackESDReader::CheckForPrimaryVertex() const
69 {
70   //Check if the vertex was well reconstructed, copy of conversion group
71   
72   AliESDEvent * esdevent = dynamic_cast<AliESDEvent*> (fInputEvent);
73   if(!esdevent) return kFALSE;
74   
75   if(esdevent->GetPrimaryVertex()->GetNContributors() > 0)
76   {
77     return kTRUE;
78   }
79   
80   if(esdevent->GetPrimaryVertex()->GetNContributors() < 1)
81   {
82     // SPD vertex
83     if(esdevent->GetPrimaryVertexSPD()->GetNContributors() > 0)
84     {
85       return kTRUE;
86       
87     }
88     if(esdevent->GetPrimaryVertexSPD()->GetNContributors() < 1)
89     {
90       return kFALSE;
91     }
92   }
93
94   return kFALSE;
95
96 }
97
98 //________________________________
99 void AliCaloTrackESDReader::Init()
100 {
101   //Init reader. Method to be called in AliAnaCaloTrackCorrMaker
102   
103   AliCaloTrackReader::Init();
104   
105   if(!fESDtrackCuts)
106     fESDtrackCuts = AliESDtrackCuts::GetStandardTPCOnlyTrackCuts(); //initialize with TPC only tracks
107 }
108
109 //______________________________________________________________________________
110 Bool_t AliCaloTrackESDReader::SelectTrack(AliVTrack* track, Double_t pTrack[3])
111 {
112   // Select ESD track using the cuts declared in fESDtrackCuts
113   // in case of hybrid tracks, 2 different sets of cuts defined.
114   
115   AliESDtrack* esdTrack = dynamic_cast<AliESDtrack*> (track);
116   
117   if(!esdTrack) return kFALSE;
118   
119   const AliExternalTrackParam* constrainParam = esdTrack->GetConstrainedParam();
120   
121   if(fESDtrackCuts->AcceptTrack(esdTrack))
122   {
123     track->GetPxPyPz(pTrack) ;
124     
125     if(fConstrainTrack)
126     {
127       if( !constrainParam ) return kFALSE;
128       
129       esdTrack->Set(constrainParam->GetX(),constrainParam->GetAlpha(),constrainParam->GetParameter(),constrainParam->GetCovariance());
130       esdTrack->GetConstrainedPxPyPz(pTrack);
131       
132     } // use constrained tracks
133     
134     if(fSelectSPDHitTracks && !esdTrack->HasPointOnITSLayer(0) && !esdTrack->HasPointOnITSLayer(1))
135       return kFALSE ; // Not much sense to use with TPC only or Hybrid tracks
136   }
137   
138   // Complementary track to global : Hybrids (make sure that the previous selection is for Global)
139   else if(fESDtrackComplementaryCuts && fESDtrackComplementaryCuts->AcceptTrack(esdTrack))
140   {
141     // constrain the track
142     if( !constrainParam ) return kFALSE;
143     
144     esdTrack->Set(constrainParam->GetX(),constrainParam->GetAlpha(),constrainParam->GetParameter(),constrainParam->GetCovariance());
145     esdTrack->GetConstrainedPxPyPz(pTrack);
146     
147   }
148   else return kFALSE;
149   
150   return kTRUE;
151 }
152
153 //_______________________________________________________________
154 void  AliCaloTrackESDReader::SetTrackCuts(AliESDtrackCuts * cuts)
155 {
156   // Set Track cuts
157   
158   if(fESDtrackCuts) delete fESDtrackCuts ;
159   
160   fESDtrackCuts = cuts ;
161   
162 }
163
164 //____________________________________________________________________________
165 void  AliCaloTrackESDReader::SetTrackComplementaryCuts(AliESDtrackCuts * cuts)
166 {
167   // Set Track cuts for complementary tracks (hybrids)
168   
169   if(fESDtrackComplementaryCuts) delete fESDtrackComplementaryCuts ;
170   
171   fESDtrackComplementaryCuts = cuts ;
172   
173 }
174
175 //_________________________________________________________________
176 void AliCaloTrackESDReader::SetInputOutputMCEvent(AliVEvent* esd,
177                                                   AliAODEvent* aod,
178                                                   AliMCEvent* mc) 
179 {
180   // Connect the data pointers
181   
182   Bool_t tesd = kFALSE ; 
183   
184   if ( strcmp(esd->GetName(), "AliMixedEvent") == 0 ) 
185   {
186     AliMultiEventInputHandler* multiEH = dynamic_cast<AliMultiEventInputHandler*>((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler());
187     if(multiEH)
188     {
189       if (multiEH->GetFormat() == 0 ) 
190       {
191         tesd = kTRUE ; 
192       }
193     }
194     else
195     {
196       AliFatal("MultiEventHandler is NULL");
197       return;
198     }
199   }
200   if (strcmp(esd->GetName(),"AliESDEvent") == 0)
201   {
202     tesd = kTRUE ; 
203   }
204   
205   if(!tesd)
206   {
207     AliFatal(Form("STOP ::Wrong reader, here only ESDs. Input name: %s != AliESDEvent",esd->GetName()));
208   }
209   
210   SetInputEvent(esd);
211   SetOutputEvent(aod);
212   SetMC(mc);
213   
214 }
215
216
217