Additional cuts for leading particle alignment in event mixing. (Alessandro Grelli)
[u/mrichter/AliRoot.git] / ANALYSIS / AliEventPoolOTF.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
19 // Realisation of an AliVEventPool via
20 // on the flight (OTF) generation of the bin using AliTagAnalysis.
21 // Author Andreas Morsch
22 // andreas.morsch@cern.ch
23
24 #include "AliEventPoolOTF.h"
25
26 #include "AliRunTagCuts.h"
27 #include "AliLHCTagCuts.h"
28 #include "AliDetectorTagCuts.h"
29 #include "AliEventTagCuts.h"
30 #include "AliTagAnalysis.h"
31
32 #include <TMath.h>
33 #include <TGridResult.h>
34
35 ClassImp(AliEventPoolOTF)
36
37
38 ////////////////////////////////////////////////////////////////////////
39
40 AliEventPoolOTF::AliEventPoolOTF():
41     AliVEventPool(),
42     fTagAnalysis(0),
43     fRunCuts(0),
44     fLHCCuts(0),
45     fDetectorCuts(0),
46     fEventCuts(0),
47     fGridTags(0),
48     fChain(0),
49     fTagDirectory(0),
50     fValueMin(),
51     fValueMax(),
52     fValueStep(),
53     fValue(),    
54     fBinNumber(0),
55     fNoMore(0)
56
57 {
58   // Default constructor
59     InitArrays();
60 }
61
62 AliEventPoolOTF::AliEventPoolOTF(const char* name, const char* title):
63     AliVEventPool(name, title),
64     fTagAnalysis(new AliTagAnalysis(title)),
65     fRunCuts(new AliRunTagCuts()),
66     fLHCCuts(new AliLHCTagCuts()),
67     fDetectorCuts(new AliDetectorTagCuts()),
68     fEventCuts(new AliEventTagCuts()),
69     fGridTags(0),
70     fChain(0),
71     fTagDirectory("."),
72     fValueMin(),
73     fValueMax(),
74     fValueStep(),
75     fValue(),    
76     fBinNumber(0),
77     fNoMore(0)
78
79 {
80   // Constructor
81     InitArrays();
82 }
83
84
85 AliEventPoolOTF::AliEventPoolOTF(const AliEventPoolOTF& obj):
86     AliVEventPool(obj),
87     fTagAnalysis(0),
88     fRunCuts(0),
89     fLHCCuts(0),
90     fDetectorCuts(0),
91     fEventCuts(0),
92     fGridTags(0),
93     fChain(0),
94     fTagDirectory(0),
95     fValueMin(),
96     fValueMax(),
97     fValueStep(),
98     fValue(),    
99     fBinNumber(0),
100     fNoMore(0)
101 {
102     // Copy constructor
103     InitArrays();
104 }
105
106 AliEventPoolOTF& AliEventPoolOTF::operator=(const AliEventPoolOTF& other)
107 {
108 // Assignment operator
109     AliVEventPool::operator=(other);
110     return *this;
111 }
112
113
114 void AliEventPoolOTF::Init()
115 {
116     //
117     if (!fGridTags) {
118         fTagAnalysis->ChainLocalTags(fTagDirectory);
119     } else {
120         fTagAnalysis->ChainGridTags(fGridTags);
121     }
122     
123     
124     for (Int_t i = 0; i < 4; i++) fValue[i] = fValueMin[i];    
125 }
126
127 TChain* AliEventPoolOTF::GetNextChain()
128 {
129     //
130     if (fChain) {
131         delete fChain;
132         fChain = 0;
133     }
134
135     fBinNumber++;
136     if (fNoMore) {
137         return 0;
138     } else {
139     printf("Current bin (lower) %13.3f %13.3f %13.3f %13.3f %13.3f \n", fValue[kMultiplicity], fValue[kZVertex], fValue[kEventPlane],fValue[kLeadingParticleEta],fValue[kLeadingParticlePhi]);
140     printf("Current bin (upper) %13.3f %13.3f %13.3f %13.3f %13.3f \n", fValue[kMultiplicity] + fValueStep[kMultiplicity], 
141            fValue[kZVertex]      + fValueStep[kZVertex], 
142            fValue[kEventPlane]   + fValueStep[kEventPlane],
143            fValue[kLeadingParticleEta]   + fValueStep[kLeadingParticleEta],
144            fValue[kLeadingParticlePhi]   + fValueStep[kLeadingParticlePhi]
145     
146            );
147
148         fEventCuts->SetMultiplicityRange(Int_t(fValue[kMultiplicity]) , Int_t(fValue[kMultiplicity] + fValueStep[kMultiplicity]));
149         fEventCuts->SetPrimaryVertexZRange(fValue[kZVertex] , fValue[kZVertex] + fValueStep[kZVertex]);
150         fEventCuts->SetEtaLeadingParticleRange(fValue[kLeadingParticleEta] , fValue[kLeadingParticleEta] + fValueStep[kLeadingParticleEta]);
151         fEventCuts->SetPhiLeadingParticleRange(fValue[kLeadingParticlePhi] , fValue[kLeadingParticlePhi] + fValueStep[kLeadingParticlePhi]);
152         fEventCuts->SetEventPlaneAngleRange(fValue[kEventPlane] , fValue[kEventPlane] + fValueStep[kEventPlane]);
153     
154         fChain = fTagAnalysis->QueryTags(fRunCuts, fLHCCuts, fDetectorCuts, fEventCuts);
155 //
156 //      Next bin 
157 //
158         for (Int_t i = 5; i >= 0; i--) 
159         {
160             fValue[i] += fValueStep[i];
161             if (i > 0  && fValue[i] >= fValueMax[i]) {
162                 fValue[i] = fValueMin[i];
163             } else if (i == 0 && fValue[i] >= fValueMax[i]) {
164                 fNoMore = kTRUE;
165             } else {
166                 break;
167             }
168         }
169         return fChain;
170     }
171 }
172
173 void  AliEventPoolOTF::GetCurrentBin(Float_t* /*bin*/)
174 {
175     //
176 }
177
178 Int_t AliEventPoolOTF::GetDimension()
179 {
180     //
181     return (5);
182 }
183
184 void AliEventPoolOTF::InitArrays()
185 {
186     // Initializes the pool axis
187     
188     SetMultiplicityBinning(0, 20000, 20000);
189     SetZVertexBinning(-1000., 1000., 2000.);
190     SetEventPlaneBinning(-1000., 1000., 2000.);
191     SetEventPlaneBinning(-1000., 1000., 2000.);
192     SetLeadingParticleEtaBinning(-13.0, 13.0, 26.); 
193     SetLeadingParticlePhiBinning(0, 2*(TMath::Pi()),2*(TMath::Pi()));   
194     for (Int_t i = 0; i < 4; i++) fValue[i] = fValueMin[i];
195 }
196
197