bug fix for Config file
[u/mrichter/AliRoot.git] / PWGDQ / dielectron / macrosLMEE / Config_mkoehler_lowmassMC.C
1
2 void InitHistograms(AliDielectron *die, Int_t cutDefinition);
3 void InitCF(AliDielectron* die, Int_t cutDefinition);
4
5 void SetupTrackCuts(AliDielectron *die, Int_t cutDefinition);
6
7 AliESDtrackCuts *SetupESDtrackCuts(Int_t cutDefinition);
8 AliDielectronPID *SetPIDcuts(Int_t cutDefinition);
9
10 void AddMCsignal(AliDielectron *die);
11
12 void SetEtaCorrection();
13
14 TString names= ("CorrBkg");
15
16 TObjArray *arrNames=names.Tokenize(";");
17 const Int_t nDie=arrNames->GetEntriesFast();
18
19
20        Bool_t kMix = 1;
21        Bool_t kRot = 0;
22        Bool_t kEff = 0;
23
24 AliDielectron* Config_mkoehler_lowmassMC(Int_t cutDefinition=1, Bool_t isAOD = kFALSE, Bool_t hasMC=kTRUE)
25 {
26   //
27   // Setup the instance of AliDielectron
28   //
29   
30   // create the actual framework object
31   TString name=Form("%02d",cutDefinition);
32   if (cutDefinition<arrNames->GetEntriesFast()){
33     name=arrNames->At(cutDefinition)->GetName();
34   }
35   AliDielectron *die =
36     new AliDielectron(Form("%s",name.Data()),
37                       Form("Track cuts: %s",name.Data()));
38   
39   die->SetHasMC(hasMC);
40
41
42
43   if(kRot){
44     AliDielectronTrackRotator *rot = new AliDielectronTrackRotator;
45     rot->SetConeAnglePhi(TMath::Pi());
46     rot->SetIterations(10);
47     die->SetTrackRotator(rot);
48   }//kRot
49   
50   
51   if(kMix){
52     AliDielectronMixingHandler *mix = new AliDielectronMixingHandler;
53     mix->SetMixType(AliDielectronMixingHandler::kAll);
54     mix->AddVariable(AliDielectronVarManager::kZvPrim,"-10., -7.5, -5., -2.5 , 0., 2.5, 5., 7.5 , 10.");
55     mix->SetDepth(10);
56     die->SetMixingHandler(mix);
57   }//kMix
58   
59   // cut setup
60   SetupTrackCuts(die,cutDefinition);
61   
62   
63   
64   //
65   // histogram setup
66   // only if an AliDielectronHistos object is attached to the
67   // dielectron framework histograms will be filled
68   //
69   
70   
71   InitHistograms(die,cutDefinition);
72   InitCF(die,cutDefinition);
73   
74   // eta correction
75   //  SetEtaCorrection();
76   
77   
78   return die;
79
80 }
81
82 //______________________________________________________________________________________
83 void SetupTrackCuts(AliDielectron *die, Int_t cutDefinition)
84 {
85   //
86   // Setup the track cuts
87   //
88
89
90
91   //
92         //options
93         die->SetPreFilterAllSigns();
94
95         //pairing with TLorentzVector
96         die->SetUseKF(kFALSE);
97
98         //track cuts
99         die->GetTrackFilter().AddCuts(SetupESDtrackCuts(cutDefinition));
100         
101         AddMCsignal(die);
102       
103         if(cutDefinition >= 0){
104   
105             AliDielectronVarCuts *mcpid =new AliDielectronVarCuts("mcpid","mcpid");
106             mcpid->SetCutType(AliDielectronVarCuts::kAny);
107             mcpid->AddCut(AliDielectronVarManager::kPdgCode, 11);
108             mcpid->AddCut(AliDielectronVarManager::kPdgCode, -11);
109             die->GetTrackFilter().AddCuts(mcpid);
110             
111             //      AliDielectronTrackCuts *noconv=new AliDielectronTrackCuts("noConv","conversion tagging");
112             //      noconv->SetV0DaughterCut(AliPID::kElectron,kTRUE);
113             //      die->GetTrackFilter().AddCuts(noconv);
114             
115             AliDielectronVarCuts *MCnoConv =new AliDielectronVarCuts("MCnoConv","MCnoConv");
116             MCnoConv->AddCut(AliDielectronVarManager::kPdgCodeMother, 22,kTRUE);
117             die->GetTrackFilter().AddCuts(MCnoConv);
118             
119             //pair rapidity
120             //      AliDielectronVarCuts *RapidityCut=new AliDielectronVarCuts("RapidityCut","RapidityCut");
121             //      RapidityCut->AddCut(AliDielectronVarManager::kY, -0.8 , 0.8);
122             //      die->GetPairFilter().AddCuts(RapidityCut); 
123             
124             
125         }//Base
126
127         //pid cuts
128         die->GetTrackFilter().AddCuts(SetPIDcuts(cutDefinition));
129
130
131
132 }
133
134 //-----------------------------------pid------------------------------------------------
135
136 AliDielectronPID *SetPIDcuts(Int_t cutDefinition){
137
138  
139     //take MC ID
140     AliDielectronPID *pid = new AliDielectronPID();
141
142     pid->AddCut(AliDielectronPID::kTPC,AliPID::kElectron,-1.5,3.,0.2,100.,kFALSE);
143     pid->AddCut(AliDielectronPID::kTPC,AliPID::kPion,-100.,4.,0.2,100.,kTRUE);
144   //TOF
145     pid->AddCut(AliDielectronPID::kTOF,AliPID::kElectron,-3.,3.,0.4, 5., kFALSE);
146     //    return pid;// no data PID ->  only MC PID
147   
148 }
149
150 //______________________________________________________________________________________
151 AliESDtrackCuts *SetupESDtrackCuts(Int_t cutDefinition)
152 {
153   //
154   // Setup default AliESDtrackCuts
155   //
156   AliESDtrackCuts *fesdTrackCuts = new AliESDtrackCuts;
157
158   //global
159   fesdTrackCuts->SetPtRange( 0.2 , 100. );//<-----------------pT cut
160   fesdTrackCuts->SetAcceptKinkDaughters(kFALSE);
161   fesdTrackCuts->SetRequireSigmaToVertex(kFALSE);
162   fesdTrackCuts->SetDCAToVertex2D(kFALSE);
163   fesdTrackCuts->SetMaxDCAToVertexZ(3.);
164   fesdTrackCuts->SetMaxDCAToVertexXY(1.);
165   fesdTrackCuts->SetEtaRange( -0.8 , 0.8 );
166   //ITS
167   fesdTrackCuts->SetRequireITSRefit(kTRUE);
168   fesdTrackCuts->SetMinNClustersITS(3); 
169   fesdTrackCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD,AliESDtrackCuts::kFirst);
170   
171   //TPC
172   fesdTrackCuts->SetRequireTPCRefit(kTRUE);
173   //  fesdTrackCuts->SetMinNClustersTPC(80);
174   fesdTrackCuts->SetMinNCrossedRowsTPC(100);
175   fesdTrackCuts->SetMinRatioCrossedRowsOverFindableClustersTPC(0.5);
176   fesdTrackCuts->SetMaxChi2PerClusterTPC(4);
177
178   //  if(cutDefinition == 1)fesdTrackCuts->SetMaxFractionSharedTPCClusters(0.01);
179
180   return fesdTrackCuts;
181
182 }
183
184 //______________________________________________________________________________________
185 void InitHistograms(AliDielectron *die, Int_t cutDefinition)
186 {
187   //
188   // Initialise the histograms
189   //
190   
191   //Setup histogram classes
192   AliDielectronHistos *histos=
193     new AliDielectronHistos(die->GetName(),
194                             die->GetTitle());
195   
196
197
198   //Initialise histogram classes
199   histos->SetReservedWords("Track;Pair");
200   
201   //Event class
202   histos->AddClass("Event");
203   
204
205   //Track classes
206   //to fill also track info from 2nd event loop until 2
207   for (Int_t i=0; i<2; ++i){
208     histos->AddClass(Form("Track_%s",AliDielectron::TrackClassName(i)));
209   }
210
211   //Pair classes
212   // to fill also mixed event histograms loop until 10
213
214   for (Int_t i=0; i<3; ++i){
215     histos->AddClass(Form("Pair_%s",AliDielectron::PairClassName(i)));
216   }
217
218
219
220   if(kMix){
221   histos->AddClass(Form("Pair_%s",AliDielectron::PairClassName(3))); //ME ++
222   histos->AddClass(Form("Pair_%s",AliDielectron::PairClassName(4)));//ME -+
223   histos->AddClass(Form("Pair_%s",AliDielectron::PairClassName(6)));//ME +-
224   histos->AddClass(Form("Pair_%s",AliDielectron::PairClassName(7))); // ME --
225   }
226
227   if(kRot)histos->AddClass(Form("Pair_%s",AliDielectron::PairClassName(10)));//Rot
228
229
230
231   //  histos->UserHistogram("Track","Label","Label;Label;#tracks",1000,0.,100000.,AliDielectronVarManager::kLabel);
232
233   //add histograms to event class
234   histos->UserHistogram("Event","nEvents","Number of processed events after cuts;Number events",1,0,1,AliDielectronVarManager::kNevents);
235   histos->UserHistogram("Event","ZVertex","ZVertex;ZVertex/cm",480,-12.,12.,AliDielectronVarManager::kZvPrim);
236   histos->UserHistogram("Event","nESDTracks","ESD tracks;ESD tracks;Number events",100,0,200,AliDielectronVarManager::kTracks);
237   histos->UserHistogram("Event","Nacc","Number of accepted tracks;Number events",100,0,200,AliDielectronVarManager::kNacc);
238   histos->UserHistogram("Event","NVtxContrib","Number of Vertex Contributor;NVtx;Number events",100,0,100,AliDielectronVarManager::kNVtxContrib);
239
240
241   //add histograms to Track classes
242   histos->UserHistogram("Track","P","P;P [GeV];#tracks",500,0.,10.,AliDielectronVarManager::kPIn);
243   histos->UserHistogram("Track","Pt","Pt;Pt [GeV];#tracks",500,0.,10.,AliDielectronVarManager::kPt);
244   histos->UserHistogram("Track","Eta","Eta; Eta ;#tracks",100,-1.,1.,AliDielectronVarManager::kEta);
245   histos->UserHistogram("Track","Phi","Phi; Phi ;#tracks",640,0.,6.4,AliDielectronVarManager::kPhi);
246   histos->UserHistogram("Track","ImpParXY","ImpParXY; \e$B9N\e(BpParXY ;#tracks",500,-5.,5.,AliDielectronVarManager::kImpactParXY);
247   histos->UserHistogram("Track","ImpParZ","ImpParZ; \e$B%X\e(BmpParZ ;#tracks",500,-5.,5.,AliDielectronVarManager::kImpactParZ);
248
249   histos->UserHistogram("Track","Eta_phi","Eta vs Phi;Eta;Phi",100,-1.,1.,320,0.,6.4,AliDielectronVarManager::kEta,AliDielectronVarManager::kPhi);
250   histos->UserHistogram("Track","Eta_pt","Eta vs Pt;Eta;Pt",100,-1.,1.,500,0.,10.,AliDielectronVarManager::kEta,AliDielectronVarManager::kPt);
251
252
253
254   //track checks (ITS)
255   histos->UserHistogram("Track","ITSchi2Cl_Mom","ITS Chi2 vs Momentum;Mom;ITS chi2",500,0.,5.,50,0.,5.,AliDielectronVarManager::kPIn,AliDielectronVarManager::kITSchi2Cl);
256   histos->UserHistogram("Track","NclsITS_Mom",";Mom;kNclsITS",500,0.,5.,7,0,7,AliDielectronVarManager::kPIn,AliDielectronVarManager::kNclsITS);
257
258   //track checks (TPC)
259   histos->UserHistogram("Track","TPCsignalNfrac_Mom",";fraction TPCSignalN/TPCncls vs Momentum;Mom;TPCSignalN/TPCncls",500,0.,5.,60,0.,1.2,AliDielectronVarManager::kPIn,AliDielectronVarManager::kTPCsignalNfrac);
260   histos->UserHistogram("Track","TPCchi2Cl_Mom","TPC Chi2 vs Momentum;Mom;TPC Chi2",500,0.,10.,100,0,5,AliDielectronVarManager::kPIn,AliDielectronVarManager::kTPCchi2Cl);
261   histos->UserHistogram("Track","TPCclsDiff_Mom","kTPCclsDiff vs Momentum;Mom;kTPCclsDiff",500,0.,10.,100,-10,10,AliDielectronVarManager::kPIn,AliDielectronVarManager::kTPCclsDiff);
262   histos->UserHistogram("Track","FindableTPCcls_Mom","kNFclsTPC vs Momentum;Mom;kNFclsTPC",500,0.,10.,200,0.,200.,AliDielectronVarManager::kPIn,AliDielectronVarManager::kNFclsTPC);
263   histos->UserHistogram("Track","TPCcls_Mom","kNclsTPC vs Momentum;Mom;kNclsTPC",500,0.,10.,200,0.,200.,AliDielectronVarManager::kPIn,AliDielectronVarManager::kNclsTPC);
264   histos->UserHistogram("Track","kNclsSFracTPC_Mom","kNclsSFracTPC vs Momentum;Mom;kTPCclsSFrac",500,0.,10.,60,0.,0.12,AliDielectronVarManager::kPIn,AliDielectronVarManager::kNclsSFracTPC);
265   histos->UserHistogram("Track","kNFclsTPCrFrac_Mom","kNFclsTPCrFrac vs Momentum;Mom;kNFclsTPCrFrac",500,0.,10.,60,0.,1.2.,AliDielectronVarManager::kPIn,AliDielectronVarManager::kNFclsTPCrFrac);
266
267   //track checks (TOF)
268   histos->UserHistogram("Track","TOFbeta_Mom","kTOFbeta vs Momentum;Mom;TOFbeta",500,0.,5.,120,0.,1.2,AliDielectronVarManager::kPIn,AliDielectronVarManager::kTOFbeta);
269   histos->UserHistogram("Track","TOFPIDBit_Mom","kTOFPIDBit vs Momentum;Mom;TOFPIDbit",500,0.,5.,2,0.,1.,AliDielectronVarManager::kPIn,AliDielectronVarManager::kTOFPIDBit);
270
271  //pid checks
272   histos->UserHistogram("Track","ITSnSigma_MomPio","ITS number of sigmas Pion vs Momentum;Mom;ITSsigmaPion",500,0.,5.,1000,-20,20,AliDielectronVarManager::kPIn,AliDielectronVarManager::kITSnSigmaPio);
273   histos->UserHistogram("Track","TPCnSigma_MomPio","TPC number of sigmas Pions vs Momentum;Mom;TPCsigmaPion",500,0.,5.,1000,-20,20,AliDielectronVarManager::kPIn,AliDielectronVarManager::kTPCnSigmaPio);
274
275   histos->UserHistogram("Track","ITSnSigma_MomEle","ITS number of sigmas Electrons vs Momentum;Mom;ITSsigmaEle",500,0.,5.,800,-40,40,AliDielectronVarManager::kPIn,AliDielectronVarManager::kITSnSigmaEle);
276   histos->UserHistogram("Track","TPCnSigma_MomEle","TPC number of sigmas Electrons vs Momentum;Mom;TPCsigmaEle",1000,0.,10.,800,-40,40,AliDielectronVarManager::kPIn,AliDielectronVarManager::kTPCnSigmaEle);
277   histos->UserHistogram("Track","TOFnSigma_MomEle","TOF number of sigmas Electrons vs Momentum;Mom;TOFsigmaEle",500,0.,5.,800,-40,40,AliDielectronVarManager::kPIn,AliDielectronVarManager::kTOFnSigmaEle);
278
279   histos->UserHistogram("Track","ITSdEdx_P","dEdx;P [GeV];ITS signal (arb units) vs Momentum;Mom;ITSsignal", 500,0,5,800,0,200,AliDielectronVarManager::kPIn,AliDielectronVarManager::kITSsignal);
280   histos->UserHistogram("Track","TPCdEdx_P","dEdx;P [GeV];TPC signal (arb units) vs Momentum;Mom;TPCsignal", 500,0,10.,800,0,200,AliDielectronVarManager::kPIn,AliDielectronVarManager::kTPCsignal);
281
282
283
284   //
285   //add histograms to Pair classes
286   //
287
288   histos->UserHistogram("Pair","Y",";Rapidity;#pairs",
289                         120,-1.2,1.2,AliDielectronVarManager::kY);
290                         
291   histos->UserHistogram("Pair","Eta",";PseudoRapidity;#pairs",
292                         120,-1.2,1.2,AliDielectronVarManager::kEta);
293                         
294   histos->UserHistogram("Pair","Phi",";PseudoRapidity;#pairs",
295                         320,0,3.2,AliDielectronVarManager::kPhi);
296                         
297   histos->UserHistogram("Pair","Eta_Phi",";PseudoRapidity;Phi",
298                         120,-1.2,1.2,320,0,3.2,AliDielectronVarManager::kEta,AliDielectronVarManager::kPhi);
299                         
300                         
301   histos->UserHistogram("Pair","InvMass","Inv.Mass;Inv. Mass [GeV];#pairs",
302                         500,0,4,AliDielectronVarManager::kM);
303
304
305   histos->UserHistogram("Pair","InvMassBin2000","Inv.Mass;Inv. Mass [GeV];#pairs",
306                         2000,0.,10.,AliDielectronVarManager::kM);
307
308    histos->UserHistogram("Pair","InvMass_bin2","Inv.Mass;Inv. Mass [GeV];#pairs",
309         "0. , 0.025, 0.05 , 0.075 ,0.1 ,0.15 , 0.2 , 0.25 , 0.3 , 
310         0.4 ,  0.5 , 0.6, 0.65 , 0.688 , 0.725, 0.75, 0.775, 0.8 , 0.85 ,
311          0.95,  0.975 , 1.0 , 1.025 , 1.05, 1.125 , 1.25 , 1.5 , 1.75 , 2.0 , 
312         2.25, 2.5 , 2.75 , 2.85, 2.95,3.05, 3.1 , 3.15 , 
313         3.3 , 3.5, 3.75 , 4.0",AliDielectronVarManager::kM);
314
315   histos->UserHistogram("Pair",
316                         "InvMass_PhivPair","InvMass_PhivPair;InvMass;PhivPair",
317                         500, 0. , 4., 320 , 0., 3.2 ,
318                          AliDielectronVarManager::kM , AliDielectronVarManager::kPhivPair );
319                          
320   histos->UserHistogram("Pair","PhiV",";PhiV;#pairs",
321                         320,0.,6.4,AliDielectronVarManager::kPhivPair);
322
323
324    histos->UserHistogram("Pair","PhiV_Pt",";Pt;PhiV",
325                          100,0.,10.,320,0.,6.4,AliDielectronVarManager::kPt,AliDielectronVarManager::kPhivPair);
326                          
327                          
328   histos->UserHistogram("Pair",
329                         "InvMass_Pt","InvMass_Pt;InvMass;Pt",
330                         500, 0. , 4., 100 , 0., 5. ,
331                          AliDielectronVarManager::kM , AliDielectronVarManager::kPt );
332
333   histos->UserHistogram("Pair",
334                         "OpAngle","Opening angle;Opening angle;#pairs",
335                         320, 0. , 3.2, 
336                          AliDielectronVarManager::kOpeningAngle);
337
338   histos->UserHistogram("Pair",
339                         "OpAngle_InvMass","OpAngle_InvMass;Opening angle;Invariant Mass",
340                         320, 0. , 3.2, 500 , 0. , 4. ,
341                          AliDielectronVarManager::kOpeningAngle,AliDielectronVarManager::kM);
342
343
344
345   histos->UserHistogram("Pair","kDeltaEta","kDeltaEta;kDeltaEta;#pairs",
346                         160,0.,1.6,AliDielectronVarManager::kDeltaEta);
347
348   histos->UserHistogram("Pair","kDeltaEta_low","kDeltaEta;kDeltaEta;#pairs",
349                         500,0.,0.5,AliDielectronVarManager::kDeltaEta);
350
351   histos->UserHistogram("Pair","kDeltaPhi","kDeltaPhi;kDeltaPhi;#pairs",
352                         320,0.,6.4,AliDielectronVarManager::kDeltaPhi);
353
354   histos->UserHistogram("Pair",
355                         "kDeltaEta_kDeltaPhi","kDeltaEta_kDeltaPhi;kDeltaEta;kDeltaPhi",
356                         160, 0. , 1.6, 320 , 0., 6.4 ,
357                          AliDielectronVarManager::kDeltaEta , AliDielectronVarManager::kDeltaPhi );
358
359
360
361   die->SetHistogramManager(histos);
362 }
363
364
365
366
367
368
369 void InitCF(AliDielectron* die, Int_t cutDefinition)
370 {
371   //
372   // Setup the CF Manager if needed
373   //
374   
375   AliDielectronCF *cf=new AliDielectronCF(die->GetName(),die->GetTitle());
376
377    
378     //pair variables
379   //   cf->AddVariable(AliDielectronVarManager::kM, 300,0.,3.);
380   cf->AddVariable(AliDielectronVarManager::kM, 500,0.,4.);
381
382   //  cf->AddVariable(AliDielectronVarManager::kSameLabel, 4,-1.,3.);
383
384   /*
385    cf->AddVariable(AliDielectronVarManager::kM,"0. , 0.025, 0.05 , 0.075 ,0.1 ,0.15 , 0.2 , 0.25 , 0.3 , 
386         0.4 ,  0.5 , 0.6, 0.65 , 0.688 , 0.725, 0.75, 0.775, 0.8 , 0.85 ,
387          0.95,  0.975 , 1.0 , 1.025 , 1.05, 1.125 , 1.25 , 1.5 , 1.75 , 2.0 , 
388         2.25, 2.5 , 2.75 , 2.85, 2.95,3.05, 3.1 , 3.15 , 
389         3.3 , 3.5, 3.75 , 4.0");//data
390 */
391         
392 //   cf->AddVariable(AliDielectronVarManager::kY,24,-1.2,1.2);
393    //   cf->AddVariable(AliDielectronVarManager::kPhi,64, -3.2, 3.2);
394       cf->AddVariable(AliDielectronVarManager::kPt,100,0.,5.);
395    
396    cf->AddVariable(AliDielectronVarManager::kPairType,12,-0.5,11.5);
397    //   cf->AddVariable(AliDielectronVarManager::kNumberOfDaughters,5,0,5);
398    //   cf->AddVariable(AliDielectronVarManager::kPhivPair,640,0.,3.2);
399    
400    //   cf->AddVariable(AliDielectronVarManager::kLabel,500,0.,500.,kTRUE);
401   //leg 
402   cf->AddVariable(AliDielectronVarManager::kPt,100,0.,10.,kTRUE);
403   //  cf->AddVariable(AliDielectronVarManager::kPhi,36,0.,360.,kTRUE);
404   cf->AddVariable(AliDielectronVarManager::kEta,100,-1.,1.,kTRUE);
405   /*
406   cf->AddVariable(AliDielectronVarManager::kTPCsignal,200,0.,200.,kTRUE);
407   cf->AddVariable(AliDielectronVarManager::kImpactParXY,40,-2.,2.,kTRUE);
408   cf->AddVariable(AliDielectronVarManager::kImpactParZ,40,-2.,2.,kTRUE);
409   cf->AddVariable(AliDielectronVarManager::kNclsITS,10,0.,10.,kTRUE);
410   cf->AddVariable(AliDielectronVarManager::kNFclsTPCrFrac,10,0.,1.,kTRUE);
411 */
412
413
414   if (cutDefinition == 0){
415     cf->SetStepForMCtruth();
416   }
417   
418 //     cf->SetStepsForEachCut();
419 //     cf->SetStepsForCutsIncreasing();
420
421
422   die->SetCFManagerPair(cf);
423   
424 }
425
426
427 void AddMCsignal(AliDielectron *die){
428
429
430   //signal pairs
431
432
433    AliDielectronSignalMC* CorrPair = new AliDielectronSignalMC("CorrPair","CorrPair");
434    CorrPair->SetLegPDGs(11,-11);
435    CorrPair->SetMothersRelation(AliDielectronSignalMC::kDifferent);
436    CorrPair->SetLegSources(AliDielectronSignalMC::kFinalState, AliDielectronSignalMC::kFinalState);
437    //   CorrPair->SetFillPureMCStep(kTRUE); // -> takes ages!!!! + not needed
438    CorrPair->SetCheckBothChargesLegs(kTRUE,kTRUE);
439    //   die->AddSignalMC(CorrPair);
440
441
442    AliDielectronSignalMC* pi0 = new AliDielectronSignalMC("pi0","pi0");
443    pi0->SetLegPDGs(11,-11);
444    pi0->SetMothersRelation(AliDielectronSignalMC::kSame);
445    pi0->SetMotherPDGs(111,111);//pi0
446    pi0->SetLegSources(AliDielectronSignalMC::kFinalState, AliDielectronSignalMC::kFinalState);
447    pi0->SetFillPureMCStep(kTRUE);
448    pi0->SetCheckBothChargesLegs(kTRUE,kTRUE);
449    die->AddSignalMC(pi0);
450
451    AliDielectronSignalMC* eta = new AliDielectronSignalMC("eta","eta");
452    eta->SetLegPDGs(11,-11);
453    eta->SetMothersRelation(AliDielectronSignalMC::kSame);
454    eta->SetMotherPDGs(221,221);//eta
455    eta->SetLegSources(AliDielectronSignalMC::kFinalState, AliDielectronSignalMC::kFinalState);
456    eta->SetFillPureMCStep(kTRUE);
457    eta->SetCheckBothChargesLegs(kTRUE,kTRUE);
458    die->AddSignalMC(eta);
459
460    AliDielectronSignalMC* etaprime = new AliDielectronSignalMC("etaprime","etaprime");
461    etaprime->SetMothersRelation(AliDielectronSignalMC::kSame);
462    etaprime->SetMotherPDGs(331,331);//etaprime
463    etaprime->SetLegSources(AliDielectronSignalMC::kFinalState, AliDielectronSignalMC::kFinalState);
464    etaprime->SetFillPureMCStep(kTRUE);
465    etaprime->SetCheckBothChargesLegs(kTRUE,kTRUE);
466    die->AddSignalMC(etaprime);
467
468    AliDielectronSignalMC* omega = new AliDielectronSignalMC("omega","omega");
469    omega->SetLegPDGs(11,-11);
470    omega->SetMothersRelation(AliDielectronSignalMC::kSame);
471    omega->SetMotherPDGs(223,223);//omega
472    omega->SetLegSources(AliDielectronSignalMC::kFinalState, AliDielectronSignalMC::kFinalState);
473    omega->SetFillPureMCStep(kTRUE);
474    omega->SetCheckBothChargesLegs(kTRUE,kTRUE);
475    die->AddSignalMC(omega);
476
477    AliDielectronSignalMC* phi = new AliDielectronSignalMC("phi","phi");
478    phi->SetLegPDGs(11,-11);
479    phi->SetMothersRelation(AliDielectronSignalMC::kSame);
480    phi->SetMotherPDGs(333,333);//phi
481    phi->SetLegSources(AliDielectronSignalMC::kFinalState, AliDielectronSignalMC::kFinalState);
482    phi->SetFillPureMCStep(kTRUE);
483    phi->SetCheckBothChargesLegs(kTRUE,kTRUE);
484    die->AddSignalMC(phi);
485
486
487    AliDielectronSignalMC* jpsi = new AliDielectronSignalMC("jpsi","jpsi");
488    jpsi->SetLegPDGs(11,-11);
489    jpsi->SetMothersRelation(AliDielectronSignalMC::kSame);
490    jpsi->SetMotherPDGs(443,443);//jpsi
491    jpsi->SetLegSources(AliDielectronSignalMC::kFinalState, AliDielectronSignalMC::kFinalState);
492    jpsi->SetFillPureMCStep(kTRUE);
493    jpsi->SetCheckBothChargesLegs(kTRUE,kTRUE);
494    die->AddSignalMC(jpsi);
495    
496    
497  AliDielectronSignalMC* diEleContinuum = new AliDielectronSignalMC("diEleContinuum","di-electron continuum");     // all di-electrons originating in the collision
498   diEleContinuum->SetLegPDGs(11,-11);
499   diEleContinuum->SetMotherPDGs(0,0,22,22);
500   diEleContinuum->SetLegSources(AliDielectronSignalMC::kFinalState, AliDielectronSignalMC::kFinalState);
501   diEleContinuum->SetMothersRelation(AliDielectronSignalMC::kSame);
502   diEleContinuum->SetCheckBothChargesLegs(kTRUE,kTRUE);
503   diEleContinuum->SetFillPureMCStep(kTRUE);
504   die->AddSignalMC(diEleContinuum);
505
506   AliDielectronSignalMC* diEleOpenCharm = new AliDielectronSignalMC("diEleOpenCharm","di-electrons from open charm");  // dielectrons originating from open charm hadrons
507   diEleOpenCharm->SetLegPDGs(11,-11);
508   diEleOpenCharm->SetMotherPDGs(402,402);
509   diEleOpenCharm->SetLegSources(AliDielectronSignalMC::kFinalState, AliDielectronSignalMC::kFinalState);
510   diEleOpenCharm->SetCheckBothChargesLegs(kTRUE,kTRUE);
511   diEleOpenCharm->SetCheckBothChargesMothers(kTRUE,kTRUE);
512   diEleOpenCharm->SetFillPureMCStep(kTRUE);
513   die->AddSignalMC(diEleOpenCharm);
514
515
516   //
517   // contamination from misidentification and conversions
518   //
519
520   //conversion
521   AliDielectronSignalMC* conversionElePairs = new AliDielectronSignalMC("conversionElePairs","conversion electron pairs");      // pairs made from conversion
522   conversionElePairs->SetLegPDGs(11,-11);
523   conversionElePairs->SetCheckBothChargesLegs(kTRUE,kTRUE);
524   //  conversionElePairs->SetMothersRelation(AliDielectronSignalMC::kSame);
525   conversionElePairs->SetLegSources(AliDielectronSignalMC::kSecondary, AliDielectronSignalMC::kSecondary);
526   conversionElePairs->SetMotherPDGs(22,22);
527   //  die->AddSignalMC(conversionElePairs);
528
529   AliDielectronSignalMC* conversionLeg = new AliDielectronSignalMC("conversionLeg","pairs with a leg from conversion");      // pairs made from conversion
530   conversionLeg->SetLegPDGs(11,-11);
531   conversionLeg->SetCheckBothChargesLegs(kTRUE,kTRUE);
532   conversionLeg->SetLegSources(AliDielectronSignalMC::kPrimary, AliDielectronSignalMC::kSecondary);
533   conversionLeg->SetMotherPDGs(22,0);
534   //  die->AddSignalMC(conversionLeg);
535
536
537
538   // background from secondary electrons
539   AliDielectronSignalMC* secondaryElectrons = new AliDielectronSignalMC("secondaryElectrons","Secondary electrons");   // all di-electrons from secondary electrons (interaction with detector)
540   secondaryElectrons->SetLegPDGs(11,-11);
541   secondaryElectrons->SetLegSources(AliDielectronSignalMC::kSecondary, AliDielectronSignalMC::kSecondary);
542   secondaryElectrons->SetCheckBothChargesLegs(kTRUE,kTRUE);
543   //  die->AddSignalMC(secondaryElectrons);
544
545   AliDielectronSignalMC* primarySecElePairs = new AliDielectronSignalMC("primarySecElePairs","Primary+Secondary electron pairs");  // primary-secondary pairs
546   primarySecElePairs->SetLegPDGs(11,-11);
547   primarySecElePairs->SetCheckBothChargesLegs(kTRUE,kTRUE);
548   primarySecElePairs->SetLegSources(AliDielectronSignalMC::kFinalState, AliDielectronSignalMC::kSecondary);
549 //  die->AddSignalMC(primarySecElePairs);
550
551   // misidentification
552   AliDielectronSignalMC* allEleMisIdPairs = new AliDielectronSignalMC("allEleMisIdPairs","all electron+misid. pairs");  // one true electron + a mis-id electron (all sources included)
553   allEleMisIdPairs->SetLegPDGs(11,11,kFALSE,kTRUE);
554   allEleMisIdPairs->SetCheckBothChargesLegs(kTRUE,kTRUE);
555 //  die->AddSignalMC(allEleMisIdPairs);
556
557   AliDielectronSignalMC* allMisIdMisIdPairs = new AliDielectronSignalMC("allMisIdMisIdPairs","all misid.+misid. pairs");  // mis-id + mis-id
558   allMisIdMisIdPairs->SetLegPDGs(11,11,kTRUE,kTRUE);
559   allMisIdMisIdPairs->SetCheckBothChargesLegs(kTRUE,kTRUE);
560 //  die->AddSignalMC(allMisIdMisIdPairs);
561
562   AliDielectronSignalMC* elePionPairs = new AliDielectronSignalMC("elePionPairs","electron+pion pairs");    // true electron + mis-id pion
563   elePionPairs->SetLegPDGs(11,211);
564   elePionPairs->SetCheckBothChargesLegs(kTRUE,kTRUE);
565 //  die->AddSignalMC(elePionPairs);
566
567   AliDielectronSignalMC* eleKaonPairs = new AliDielectronSignalMC("eleKaonPairs","electron+kaon pairs");   // true electron + mis-id kaon
568   eleKaonPairs->SetLegPDGs(11,321);
569   eleKaonPairs->SetCheckBothChargesLegs(kTRUE,kTRUE);
570 //  die->AddSignalMC(eleKaonPairs);
571
572   AliDielectronSignalMC* eleProtonPairs = new AliDielectronSignalMC("eleProtonPairs","Electron+proton pairs");  // true electron + mis-id proton
573   eleProtonPairs->SetLegPDGs(11,2212);
574   eleProtonPairs->SetCheckBothChargesLegs(kTRUE,kTRUE);
575 //  die->AddSignalMC(eleProtonPairs);
576
577   AliDielectronSignalMC* piPiPairs = new AliDielectronSignalMC("piPiPairs","pion+pion pairs");    // mis-id pion + mis-id pion
578   piPiPairs->SetLegPDGs(211,211);
579   piPiPairs->SetCheckBothChargesLegs(kTRUE,kTRUE);
580 //  die->AddSignalMC(piPiPairs);
581
582   AliDielectronSignalMC* piKaonPairs = new AliDielectronSignalMC("piKaonPairs","pion+kaon pairs");  // mis-id pion + mis-id kaon
583   piKaonPairs->SetLegPDGs(211,321);
584   piKaonPairs->SetCheckBothChargesLegs(kTRUE,kTRUE);
585 //  die->AddSignalMC(piKaonPairs);
586
587   AliDielectronSignalMC* piProtonPairs = new AliDielectronSignalMC("piProtonPairs","pion+proton pairs");  // mis-id pion + mis-id proton
588   piProtonPairs->SetLegPDGs(211,2212);
589   piProtonPairs->SetCheckBothChargesLegs(kTRUE,kTRUE);
590 //  die->AddSignalMC(piProtonPairs);
591
592   AliDielectronSignalMC* kaonKaonPairs = new AliDielectronSignalMC("kaonKaonPairs","kaon+kaon pairs");  // mis-id kaon + mis-id kaon
593   kaonKaonPairs->SetLegPDGs(321,321);
594   kaonKaonPairs->SetCheckBothChargesLegs(kTRUE,kTRUE);
595 //  die->AddSignalMC(kaonKaonPairs);
596
597   AliDielectronSignalMC* kaonProtonPairs = new AliDielectronSignalMC("kaonProtonPairs","kaon+proton pairs");   // mis-id kaon + mis-id proton
598   kaonProtonPairs->SetLegPDGs(321,2212);
599   kaonProtonPairs->SetCheckBothChargesLegs(kTRUE,kTRUE);
600 //  die->AddSignalMC(kaonProtonPairs);
601
602   AliDielectronSignalMC* protonProtonPairs = new AliDielectronSignalMC("protonProtonPairs","proton+proton pairs");  // mis-id proton + mis-id proton
603   protonProtonPairs->SetLegPDGs(2212,2212);
604   protonProtonPairs->SetCheckBothChargesLegs(kTRUE,kTRUE);
605 //  die->AddSignalMC(protonProtonPairs);
606
607   AliDielectronSignalMC* muonAllPairs = new AliDielectronSignalMC("muonAllPairs","muon+everything pairs");        // mis-id muon + something else (electron, pion, kaon, proton)
608   muonAllPairs->SetLegPDGs(13,13,kFALSE,kTRUE);
609   muonAllPairs->SetCheckBothChargesLegs(kTRUE,kTRUE);
610 //  die->AddSignalMC(muonAllPairs);
611
612
613
614 }
615
616
617
618 void SetEtaCorrection()
619 {
620   if (AliDielectronPID::GetEtaCorrFunction()) return;
621
622   TString list=gSystem->Getenv("LIST");
623   
624   TFile f("$TRAIN_ROOT/jpsi_JPSI/EtaCorrMaps.root");
625   if (!f.IsOpen()) return;
626   TList *keys=f.GetListOfKeys();
627
628   for (Int_t i=0; i<keys->GetEntries(); ++i){
629     TString kName=keys->At(i)->GetName();
630     TPRegexp reg(kName);
631     if (reg.MatchB(list)){
632       printf("Using Eta Correction Function: %s\n",kName.Data());
633       AliDielectronPID::SetEtaCorrFunction((TF1*)f.Get(kName.Data()));
634     }
635   }
636 }
637
638
639
640