]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGGA/PHOSTasks/ClusterSelection/AliPHOSClusterSelection.cxx
Added AliPHOSClusterSelection::GetCurrentEvent()
[u/mrichter/AliRoot.git] / PWGGA / PHOSTasks / ClusterSelection / AliPHOSClusterSelection.cxx
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 #include "AliAnalysisManager.h"
19 #include "AliInputEventHandler.h"
20 #include "AliMultiInputEventHandler.h"
21 #include "AliVEvent.h"
22
23 #include "AliPHOSClusterSelection.h"
24
25 AliPHOSClusterSelection::AliPHOSClusterSelection()
26   : fMinChargedParticleTrackDistance(-1.), 
27     fNotUnfolded(false),
28     fMaxDispR2(-1.),
29     fMaxDispCoreR2(-1.),
30     fMaxTOF(-1.)
31 {
32   // Defaults to the most lenient selection allowable
33         return;
34 }
35
36 AliPHOSClusterSelection::~AliPHOSClusterSelection()
37 {
38 }
39
40 Bool_t AliPHOSClusterSelection::IsSelected(AliVCluster* cluster) const
41 {
42   return IsSelectedCPV(cluster)
43     && IsSelectedUnfolded(cluster)
44     && IsSelectedDisp(cluster)
45     && IsSelectedDispCore(cluster)
46     && IsSelectedTOF(cluster);
47 }
48
49 Bool_t IsSelectedCPV(AliVCluster* cluster) const
50 {
51   if( 0 > SetMinChargedParticleTrackDistance )
52     return true; 
53   //TODO: implement positive case
54 }
55
56 AliPHOSClusterSelection* AliPHOSClusterSelection::SetMinChargedParticleTrackDistance(Float_t distance)
57 {
58   // 'distance' set the minimal allowable distance between the cluster
59   // and the nearest extrapolated track.
60   // If 'distance' is negative, then all clusters are sellected, the selection
61   // being "not applied" or "disabled".
62   
63   fMinChargedParticleTrackDistance = distance;
64 }
65
66 TString AliPHOSClusterSelection::ToString() const
67 {
68   // returns a string an quasi-unique string for whatever selection 
69   // parameters the instance contains. The uniqueness of the string
70   // is limited by the precision given in the formatting of the string.
71   // Take care that the precision is sufficient for your needs.
72
73   return TString::Format("%f_%i_%f_%f_%f",
74                          fMinChargedParticleTrackDistance,
75                          fNotUnfolded,
76                          fMaxDispR2,
77                          fMaxDispCoreR2,
78                          fMaxTOF
79                          );
80 }
81
82
83 Float_t AliPHOSClusterSelection::SetMinChargedParticleTrackDistance(const TString& string)
84 {
85   TObjArray * objarray = string.Tokenize("_");
86   Float_t flt = objarray->At(0)->Atof();
87   delete objarray;
88   return flt;
89 }
90
91
92 AliVEvent* AliPHOSClusterSelection::GetCurrentEvent() const
93 {
94   // Hackish way of getting the current event.
95   // Its probably not appropriate to call this function outside of
96   // AliAnalysisTaskSE::UserExec
97   
98   AliAnalysisManager* analysisManager = dynamic_cast<AliAnalysisManager*>(AliAnalysisManager::GetAnalysisManager());
99   AliInputEventHandler* inputHandler = dynamic_cast<AliInputEventHandler*>(analysisManager->GetInputEventHandler());
100   AliMultiInputEventHandler *multiInputHandler = dynamic_cast<AliMultiInputEventHandler *>(fInputHandler);
101   if (multiInputHandler)
102     inputHandler = dynamic_cast<AliInputEventHandler *>(multiInputHandler->GetFirstInputEventHandler());
103   
104   AliVEvent* inputEvent = dynamic_cast<AliVEvent*>(inputHandler->GetEvent());
105   if( ! inputEvent ) 
106     AliError("Was not able to retrieve event!");
107   
108   return inputEvent;
109 }