]> git.uio.no Git - u/mrichter/AliRoot.git/blob - CORRFW/AliCFPairAcceptanceCuts.cxx
coveritiy
[u/mrichter/AliRoot.git] / CORRFW / AliCFPairAcceptanceCuts.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 ///////////////////////////////////////////////////////////////////////////
17 //          ----   CORRECTION FRAMEWORK   ----
18 // Class to cut on the number of AliTrackReference's 
19 // for each detector. Applies on pair of tracks (AliCFPair)
20 ///////////////////////////////////////////////////////////////////////////
21 // author : R. Vernet (renaud.vernet@cern.ch)
22 ///////////////////////////////////////////////////////////////////////////
23
24 #include "AliMCParticle.h"
25 #include "AliCFPairAcceptanceCuts.h"
26 #include "AliMCEvent.h"
27 #include "TBits.h"
28 #include "AliLog.h"
29
30 ClassImp(AliCFPairAcceptanceCuts)
31
32 //______________________________
33 AliCFPairAcceptanceCuts::AliCFPairAcceptanceCuts() : 
34   AliCFCutBase(),
35   fMCInfo(0x0),
36   fCutNeg(new AliCFAcceptanceCuts()),
37   fCutPos(new AliCFAcceptanceCuts()),
38   fBitmap(new TBits(0))
39 {
40   //
41   //Default Constructor
42   //
43 }
44
45 //______________________________
46 AliCFPairAcceptanceCuts::AliCFPairAcceptanceCuts(const Char_t* name, const Char_t* title) : 
47   AliCFCutBase(name,title),
48   fMCInfo(0x0),
49   fCutNeg(new AliCFAcceptanceCuts(name,title)),
50   fCutPos(new AliCFAcceptanceCuts(name,title)),
51   fBitmap(new TBits(0))
52 {
53   //
54   //Named Constructor
55   //
56 }
57
58 //______________________________
59 AliCFPairAcceptanceCuts::AliCFPairAcceptanceCuts(const AliCFPairAcceptanceCuts& c) : 
60   AliCFCutBase(c),
61   fMCInfo(c.fMCInfo),
62   fCutNeg(c.fCutNeg),
63   fCutPos(c.fCutPos),
64   fBitmap(c.fBitmap)
65 {
66   //
67   //Copy Constructor
68   //
69 }
70
71 //______________________________
72 AliCFPairAcceptanceCuts& AliCFPairAcceptanceCuts::operator=(const AliCFPairAcceptanceCuts& c)
73 {
74   //
75   // Assignment operator
76   //
77   if (this != &c) {
78     AliCFCutBase::operator=(c) ;
79     fMCInfo = c.fMCInfo ;
80     fCutNeg = c.fCutNeg ;
81     fCutPos = c.fCutPos ;
82     fBitmap = c.fBitmap ;
83   }
84   return *this ;
85 }
86
87 //__________________________________________________________
88 Bool_t AliCFPairAcceptanceCuts::IsSelected(TObject* obj) {
89   //
90   // checks the number of track references associated to 'obj'
91   // 'obj' must be an AliMCParticle
92   //
93   //
94   // check if selections on 'obj' are passed
95   // 'obj' must be an AliMCParticle
96   //
97   
98   SelectionBitMap(obj);
99
100   //   if (fIsQAOn) FillHistograms(obj,kFALSE);
101   Bool_t isSelected = kTRUE;
102
103   for (UInt_t icut=0; icut<fBitmap->GetNbits(); icut++) {
104     if (!fBitmap->TestBitNumber(icut)) {
105       isSelected = kFALSE;
106       break;
107     }
108   }  
109
110   if (!isSelected) return kFALSE ;
111   //   if (fIsQAOn) FillHistograms(obj,kTRUE);
112   return kTRUE;
113 }
114
115 //__________________________________________________________
116 void AliCFPairAcceptanceCuts::SelectionBitMap(TObject* obj) 
117 {
118   //
119   // test if the track passes the single cuts
120   // and store the information in a bitmap
121   //
122
123   for (UInt_t i=0; i<kNCuts; i++) fBitmap->SetBitNumber(i,kFALSE);
124
125   AliMCParticle* mcpart = dynamic_cast<AliMCParticle*>(obj) ;
126
127   if (!mcpart) return;
128   TString className(mcpart->ClassName());
129   if (className.CompareTo("AliMCParticle") != 0) {
130     AliError("obj must point to an AliMCParticle !");
131     return ;
132   }
133
134   TParticle* part = mcpart->Particle() ;
135   if (!part || part->GetNDaughters() !=2) return ;
136
137   Int_t lab0 = part->GetDaughter(0);
138   Int_t lab1 = part->GetDaughter(1);
139   AliMCParticle* negDaughter =  (AliMCParticle*) fMCInfo->GetTrack(lab0) ;
140   AliMCParticle* posDaughter =  (AliMCParticle*) fMCInfo->GetTrack(lab1) ;
141
142   Int_t iCutBit = 0;
143
144   if (fCutNeg->IsSelected(negDaughter)) fBitmap->SetBitNumber(iCutBit,kTRUE);
145   iCutBit++;
146   
147   if (fCutPos->IsSelected(posDaughter)) fBitmap->SetBitNumber(iCutBit,kTRUE);
148 }
149
150 //______________________________
151 void AliCFPairAcceptanceCuts::SetMCEventInfo(const TObject* mcInfo) {
152   //
153   // Sets pointer to MC event information (AliMCEvent)
154   //
155
156   if (!mcInfo) {
157     Error("SetMCEventInfo","Pointer to MC Event is null !");
158     return;
159   }
160   
161   TString className(mcInfo->ClassName());
162   if (className.CompareTo("AliMCEvent") != 0) {
163     Error("SetMCEventInfo","argument must point to an AliMCEvent !");
164     return ;
165   }
166   
167   fMCInfo = (AliMCEvent*) mcInfo ;
168 }