1 /*************************************************************************
2 * Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
16 ///////////////////////////////////////////////////////////////////////////
17 // Dielectron Analysis Main class //
20 Framework to perform event selectoin, single track selection and track pair
23 Convention for the signs of the pair in fPairCandidates:
24 The names are available via the function PairClassName(Int_t i)
26 0: ev1+ ev1+ (same event like sign +)
27 1: ev1+ ev1- (same event unlike sign)
28 2: ev1- ev1- (same event like sign -)
30 3: ev1+ ev2+ (mixed event like sign +)
31 4: ev1- ev2+ (mixed event unlike sign -+)
32 6: ev1+ ev2- (mixed event unlike sign +-)
33 7: ev1- ev2- (mixed event like sign -)
35 5: ev2+ ev2+ (same event like sign +)
36 8: ev2+ ev2- (same event unlike sign)
37 9: ev2- ev2- (same event like sign -)
43 ///////////////////////////////////////////////////////////////////////////
49 #include <AliESDEvent.h>
50 #include <AliESDtrack.h>
52 #include <AliVEvent.h>
53 #include <AliVParticle.h>
54 #include <AliVTrack.h>
55 #include "AliDielectronPair.h"
56 #include "AliDielectronHistos.h"
57 #include "AliDielectronCF.h"
58 #include "AliDielectronMC.h"
59 #include "AliDielectronVarManager.h"
60 #include "AliDielectron.h"
62 ClassImp(AliDielectron)
64 const char* AliDielectron::fgkTrackClassNames[4] = {
71 const char* AliDielectron::fgkPairClassNames[10] = {
84 //________________________________________________________________
85 AliDielectron::AliDielectron() :
86 TNamed("AliDielectron","AliDielectron"),
87 fEventFilter("EventFilter"),
88 fTrackFilter("TrackFilter"),
89 fPairFilter("PairFilter"),
92 fPairCandidates(new TObjArray(10)),
96 // Default constructor
101 //________________________________________________________________
102 AliDielectron::AliDielectron(const char* name, const char* title) :
104 fEventFilter("EventFilter"),
105 fTrackFilter("TrackFilter"),
106 fPairFilter("PairFilter"),
109 fPairCandidates(new TObjArray(10)),
118 //________________________________________________________________
119 AliDielectron::~AliDielectron()
122 // Default destructor
124 if (fHistos) delete fHistos;
125 if (fPairCandidates) delete fPairCandidates;
128 //________________________________________________________________
129 void AliDielectron::Init()
132 // Initialise objects
134 if (fCfManagerPair) fCfManagerPair->InitialiseContainer(fPairFilter);
137 //________________________________________________________________
138 void AliDielectron::Process(AliVEvent *ev1, AliVEvent *ev2)
141 // Process the events
144 //in case we have MC load the MC event and process the MC particles
145 if (AliDielectronMC::Instance()->ConnectMCEvent()) ProcessMC();
147 //if candidate array doesn't exist, create it
148 if (!fPairCandidates->UncheckedAt(0)) {
149 InitPairCandidateArrays();
154 //mask used to require that all cuts are fulfilled
155 UInt_t selectedMask=(1<<fEventFilter.GetCuts()->GetEntries())-1;
158 if (ev1&&fEventFilter.IsSelected(ev1)!=selectedMask ||
159 ev2&&fEventFilter.IsSelected(ev2)!=selectedMask) return;
161 //fill track arrays for the first event
162 if (ev1) FillTrackArrays(ev1);
164 //fill track arrays for the second event
165 if (ev2) FillTrackArrays(ev2,1);
167 // create pairs and fill pair candidate arrays
168 for (Int_t itrackArr1=0; itrackArr1<4; ++itrackArr1){
169 for (Int_t itrackArr2=itrackArr1; itrackArr2<4; ++itrackArr2){
170 FillPairArrays(itrackArr1, itrackArr2);
175 //________________________________________________________________
176 void AliDielectron::ProcessMC()
179 // Process the MC data
182 //loop over all MC data and Fill the CF container if it exist
183 if (!fCfManagerPair) return;
184 fCfManagerPair->SetPdgMother(fPdgMother);
186 AliDielectronMC *dieMC=AliDielectronMC::Instance();
187 for (Int_t ipart=0; ipart<dieMC->GetNMCTracks();++ipart){
188 //TODO: MC truth cut properly!!!
189 AliVParticle *mcPart=dieMC->GetMCTrackFromMCEvent(ipart);
190 if (!AliDielectronMC::Instance()->IsMCMotherToEE(mcPart, fPdgMother)) continue;
191 fCfManagerPair->FillMC(mcPart);
195 //________________________________________________________________
196 void AliDielectron::FillHistograms()
199 // Fill Histogram information for tracks and pairs
202 if (!fHistos) return;
205 //Fill track information, separately for the track array candidates
206 Double_t trackValues[AliDielectronVarManager::kNMaxValues];
207 for (Int_t i=0; i<4; ++i){
208 className.Form("Track_%s",fgkTrackClassNames[i]);
209 Int_t ntracks=fTracks[i].GetEntriesFast();
210 for (Int_t itrack=0; itrack<ntracks; ++itrack){
211 AliDielectronVarManager::Fill(fTracks[i].UncheckedAt(itrack), trackValues);
212 fHistos->FillClass(className, AliDielectronVarManager::kNMaxValues, trackValues);
216 //Fill Pair information, separately for all pair candidate arrays
217 Double_t pairValues[AliDielectronVarManager::kNMaxValues];
218 for (Int_t i=0; i<10; ++i){
219 className.Form("Pair_%s",fgkPairClassNames[i]);
220 Int_t ntracks=PairArray(i)->GetEntriesFast();
221 for (Int_t ipair=0; ipair<ntracks; ++ipair){
222 AliDielectronVarManager::Fill(PairArray(i)->UncheckedAt(ipair), pairValues);
223 fHistos->FillClass(className, AliDielectronVarManager::kNMaxValues, pairValues);
229 //________________________________________________________________
230 void AliDielectron::FillTrackArrays(AliVEvent * const ev, Int_t eventNr)
233 // select tracks and fill track candidate arrays
234 // eventNr = 0: First event, use track arrays 0 and 1
235 // eventNr = 1: Second event, use track arrays 2 and 3
238 Int_t ntracks=ev->GetNumberOfTracks();
239 UInt_t selectedMask=(1<<fTrackFilter.GetCuts()->GetEntries())-1;
240 for (Int_t itrack=0; itrack<ntracks; ++itrack){
242 AliVParticle *particle=ev->GetTrack(itrack);
243 //TODO: temporary solution, perhaps think about a better implementation
244 // This is needed to use AliESDpidCuts, which relies on the ESD event
245 // is set as a AliESDtrack attribute... somehow ugly!
246 if (ev->IsA()==AliESDEvent::Class()){
247 AliESDtrack *track=static_cast<AliESDtrack*>(particle);
248 track->SetESDEvent(static_cast<AliESDEvent*>(ev)); //only in trunk...
252 if (fTrackFilter.IsSelected(particle)!=selectedMask) continue;
254 //fill selected particle into the corresponding track arrays
255 Short_t charge=particle->Charge();
256 if (charge>0) fTracks[eventNr*2].Add(particle);
257 else if (charge<0) fTracks[eventNr*2+1].Add(particle);
261 //________________________________________________________________
262 void AliDielectron::FillPairArrays(Int_t arr1, Int_t arr2) {
264 // select pairs and fill pair candidate arrays
266 Int_t pairIndex=GetPairIndex(arr1,arr2);
268 Int_t ntrack1=fTracks[arr1].GetEntriesFast();
269 Int_t ntrack2=fTracks[arr2].GetEntriesFast();
271 AliDielectronPair *candidate=new AliDielectronPair;
273 UInt_t selectedMask=(1<<fPairFilter.GetCuts()->GetEntries())-1;
275 for (Int_t itrack1=0; itrack1<ntrack1; ++itrack1){
277 if (arr1==arr2) end=itrack1;
278 for (Int_t itrack2=0; itrack2<end; ++itrack2){
279 //create the pair TODO: change hardcoded PID of tracks
280 candidate->SetTracks(static_cast<AliVTrack*>(fTracks[arr1].UncheckedAt(itrack1)), 11,
281 static_cast<AliVTrack*>(fTracks[arr2].UncheckedAt(itrack2)), 11);
282 candidate->SetType(pairIndex);
285 UInt_t cutMask=fPairFilter.IsSelected(candidate);
287 //CF manager for the pair
288 if (fCfManagerPair) fCfManagerPair->Fill(cutMask,candidate);
291 if (cutMask!=selectedMask) continue;
293 //add the candidate to the candidate array
294 PairArray(pairIndex)->Add(candidate);
295 //get a new candidate
296 candidate=new AliDielectronPair;
299 //delete the surplus candidate