]> git.uio.no Git - u/mrichter/AliRoot.git/blob - CORRFW/AliCFPairAcceptanceCuts.cxx
Correct energy calibration in case of p-p data
[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   if (!obj) return;
126   TString className(obj->ClassName());
127   if (className.CompareTo("AliMCParticle") != 0) {
128     AliError("obj must point to an AliMCParticle !");
129     return ;
130   }
131
132   TParticle* part = (dynamic_cast<AliMCParticle*>(obj))->Particle() ;
133   if (!part || part->GetNDaughters() !=2) return ;
134
135   Int_t lab0 = part->GetDaughter(0);
136   Int_t lab1 = part->GetDaughter(1);
137   AliMCParticle* negDaughter =  (AliMCParticle*) fMCInfo->GetTrack(lab0) ;
138   AliMCParticle* posDaughter =  (AliMCParticle*) fMCInfo->GetTrack(lab1) ;
139
140   Int_t iCutBit = 0;
141
142   if (fCutNeg->IsSelected(negDaughter)) fBitmap->SetBitNumber(iCutBit,kTRUE);
143   iCutBit++;
144   
145   if (fCutPos->IsSelected(posDaughter)) fBitmap->SetBitNumber(iCutBit,kTRUE);
146 }
147
148 //______________________________
149 void AliCFPairAcceptanceCuts::SetEvtInfo(TObject* mcInfo) {
150   //
151   // Sets pointer to MC event information (AliMCEvent)
152   //
153
154   if (!mcInfo) {
155     Error("SetEvtInfo","Pointer to MC Event is null !");
156     return;
157   }
158   
159   TString className(mcInfo->ClassName());
160   if (className.CompareTo("AliMCEvent") != 0) {
161     Error("SetEvtInfo","argument must point to an AliMCEvent !");
162     return ;
163   }
164   
165   fMCInfo = (AliMCEvent*) mcInfo ;
166 }