f09ff69485eb8b30652334fabe93958bfc46df9a
[u/mrichter/AliRoot.git] / PWGDQ / dielectron / macrosJPSI / ConfigJpsi_jb_PbPb.C
1 void InitHistograms(AliDielectron *die, Int_t cutDefinition);
2 void InitCF(AliDielectron* die, Int_t cutDefinition);
3 void InitHF(AliDielectron* die, Int_t cutDefinition);
4
5 void SetupEventCuts(AliDielectron *die, ULong64_t triggers, Int_t cutDefinition);
6 void SetupTrackCuts(AliDielectron *die, Int_t cutDefinition);
7 void SetupV0Cuts( AliDielectron *die,  Int_t cutDefinition);
8 void SetupPairCuts( AliDielectron *die,  Int_t cutDefinition);
9
10 void ConfigEvtPlane(AliDielectron *die,  Int_t cutDefinition);
11 void ConfigBgrd(    AliDielectron *die,  Int_t cutDefinition);
12
13 void AddMCSignals(AliDielectron *die);
14 void SetEtaCorrection();
15 TVectorD *GetRunNumbers();
16 TVectorD *GetDeltaPhiBins();
17
18 TString names=("TPC;TOF;TRD;Ionut;NOPID");
19 enum { kTPC=0, kTOF, kTRD, kIonut, kNoPID };
20
21 TObjArray *arrNames=names.Tokenize(";");
22 const Int_t nDie=arrNames->GetEntries();
23
24 Bool_t  isESD = kTRUE;
25 TString list  = gSystem->Getenv("LIST");
26
27 AliDielectron* ConfigJpsi_jb_PbPb(Int_t cutDefinition, Bool_t hasMC=kFALSE, ULong64_t triggers=AliVEvent::kCentral | AliVEvent::kSemiCentral | AliVEvent::kMB)
28 {
29   //
30   // Setup the instance of AliDielectron
31   //
32
33   // gsi train?
34   TString trainRoot = gSystem->Getenv("TRAIN_ROOT");
35   Bool_t isGSItrain = (trainRoot.IsNull()?kFALSE:kTRUE); 
36   if(isGSItrain) {
37     // find mc or not?
38     if( list.IsNull()) list=prod;
39     if( list.Contains("LHC10h")   || list.Contains("LHC11h")   ) hasMC=kFALSE;
40     if( list.Contains("LHC11a10") || list.Contains("LHC12a17") ) hasMC=kTRUE;
41   }
42
43   //ESD handler?
44   isESD=(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()->IsA()==AliESDInputHandler::Class());
45
46   // switch configurations ON and OFF
47   if(hasMC) { // MONTE CARLO
48     switch(cutDefinition) {
49     case kTPC:   /* */ break;
50     case kTOF:   /* */ break;
51     case kTRD:   /* */ break;
52     case kIonut: /* */ break;
53       //    case kNoPID: /* */ break;
54     default:         return 0x0;
55     }
56   } else { // COLLISION DATA
57     switch(cutDefinition) {
58     case kTPC:   /* */ break;
59     case kTOF:   /* */ break;
60     case kTRD:   /* */ break;
61     case kIonut: /* */ break;
62     default:         return 0x0;
63     }
64   }
65
66   // task name
67   TString name=Form("%02d",cutDefinition);
68   if (cutDefinition<arrNames->GetEntriesFast())  name=arrNames->At(cutDefinition)->GetName();
69   printf(" Adding %s%s config %s for %s \n",(isESD?"ESD":"AOD"),(hasMC?" MC":""),name.Data(),list.Data());
70
71   // init AliDielectron
72   AliDielectron *die = new AliDielectron(Form("%s",name.Data()), Form("%s",name.Data()));
73   die->SetHasMC(hasMC);
74
75   // cut setup
76   SetupEventCuts(die,triggers,cutDefinition);
77   SetupTrackCuts(die,cutDefinition);
78   SetupV0Cuts(die,cutDefinition);
79   SetupPairCuts(die,cutDefinition);
80
81   // Monte Carlo Signals
82   if(hasMC) {
83     AddMCSignals(die);
84     printf(" Add %d MC signals \n",die->GetMCSignals()->GetEntriesFast());
85   }
86
87   // TRD efficiencies tables
88   /*
89     if (hasMC && list.Contains("LHC11a") ) {
90      TString pidTab="$TRAIN_ROOT/util/dielectron/dielectron/TRDpidEff_eleProb07_TRDntr4_6.root";
91      if(!isGSItrain) pidTab="$ALICE_ROOT/PWGDQ/dielectron/files/TRDpidEff_eleProb07_TRDntr4_6.root";
92
93      if (gSystem->AccessPathName(gSystem->ExpandPathName(pidTab.Data())))
94      Error("ConfigPbPb","PID table not found: %s",pidTab.Data());
95      else
96      die->SetTRDcorrectionFilename(pidTab.Data());
97      }
98   */
99
100   // histogram setup
101   InitHistograms(die,cutDefinition);
102   printf(" Add %d class types to the histo manager \n",die->GetHistogramList()->GetEntries());
103
104   // HF array setup
105   if(!hasMC) InitHF(die,cutDefinition);
106
107   // CF container setup, switched off
108   InitCF(die,cutDefinition);
109   /*
110     printf(" Add %d pair, %d leg vars, %p steps and %p bins to the container \n",
111     die->GetCFManagerPair()->GetNvarsPair(),die->GetCFManagerPair()->GetNvarsLeg(),
112     die->GetCFManagerPair()->GetContainer(), die->GetCFManagerPair()->GetContainer() );
113   */
114
115   // bgrd estimators
116   if(!hasMC) ConfigBgrd(die,cutDefinition);
117
118   // tpc event plane configuration
119   if(!hasMC) ConfigEvtPlane(die,cutDefinition);
120
121   // prefilter settings
122   die->SetPreFilterUnlikeOnly();
123   //die->SetPreFilterAllSigns();
124   //die->SetNoPairing();
125
126   // setup eta correction
127   // if(isESD && list.Contains("LHC10h")) SetEtaCorrection();
128
129   // VZERO calibration
130   if (isGSItrain && list.Contains("LHC10h")) {
131     die->SetVZEROCalibrationFilename("$TRAIN_ROOT/util/dielectron/dielectron/VzeroCalibrationLHC10h.root");
132     die->SetVZERORecenteringFilename("$TRAIN_ROOT/util/dielectron/dielectron/VzeroRecenteringLHC10h.root");
133   }
134
135   return die;
136 }
137
138 //______________________________________________________________________________________
139 void SetupEventCuts(AliDielectron *die, ULong64_t triggers, Int_t cutDefinition)
140 {
141   //
142   // Setup the event cuts
143   //
144
145   // trigger specific centrality cuts (reject trigger inefficiencies)
146   Double_t minCent=0.0, maxCent=100.;
147   if(!die->GetHasMC()) {
148     switch(triggers) {
149     case AliVEvent::kCentral:     minCent= 0.; maxCent= 9.; break;
150     case AliVEvent::kSemiCentral: minCent=12.; maxCent=53.; break;
151     case AliVEvent::kMB:          minCent= 0.; maxCent=80.; break;
152     default:                      minCent= 0.; maxCent=80.; break;
153     }
154   }
155   //  if(cutDefinition >= kEtaGap01) {minCent=20.; maxCent=50.;} // v2 analysis
156
157   // VZERO multiplicity vs. number ob global tracks cut
158   TF1 *fMean  = new TF1("fMean", "pol1",               0,25e+3);
159   fMean->SetParameters(691.633, 1.4892);
160   TF1 *fSigma = new TF1("fSigma","[0]+sqrt([1]*x+[2])",0,25e+3);
161   fSigma->SetParameters(-83.6599, 36.7677, 69530.7);
162
163   AliDielectronEventCuts *eventCuts=new AliDielectronEventCuts("eventCuts","eventCuts");
164   if(!isESD) eventCuts->SetVertexType(AliDielectronEventCuts::kVtxAny);
165   eventCuts->SetRequireVertex();
166   eventCuts->SetMinVtxContributors(1);
167   eventCuts->SetVertexZ(-10.,+10.);
168   eventCuts->SetCentralityRange(minCent,maxCent);
169   //  eventCuts->SetCutOnV0MultipicityNTrks(fMean, fSigma, 4.0);
170   eventCuts->Print();
171   die->GetEventFilter().AddCuts(eventCuts);
172
173 }
174
175 //______________________________________________________________________________________
176 void SetupTrackCuts(AliDielectron *die, Int_t cutDefinition)
177 {
178   //
179   // Setup the track cuts
180   //
181
182   // Quality cuts
183   AliDielectronCutGroup* cuts = new AliDielectronCutGroup("cuts","cuts",AliDielectronCutGroup::kCompAND);
184   die->GetTrackFilter().AddCuts(cuts);
185
186   /* vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv FILTER CUTS vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv */
187   // AOD track filter (needs to be first cut to speed up)
188   AliDielectronTrackCuts *trkFilter = new AliDielectronTrackCuts("TrkFilter","TrkFilter");
189   trkFilter->SetAODFilterBit(AliDielectronTrackCuts::kTPCqual);
190   //  trkFilter->SetMinNCrossedRowsOverFindable(0.6);
191
192   /* vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv TRACK CUTS vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv */
193   AliDielectronVarCuts *varCuts   = new AliDielectronVarCuts("VarCuts","VarCuts");
194   AliDielectronTrackCuts *trkCuts = new AliDielectronTrackCuts("TrkCuts","TrkCuts");
195   // config specific cuts
196   switch(cutDefinition) {
197   case kIonut:
198     varCuts->AddCut(AliDielectronVarManager::kPt,0.85,1e30);
199     varCuts->AddCut(AliDielectronVarManager::kEta,         -0.8,   0.8);
200     varCuts->AddCut(AliDielectronVarManager::kTPCclsSegments,7.,   8.0);
201     trkCuts->SetITSclusterCut(AliDielectronTrackCuts::kOneOf, 3); // SPD any
202     break;
203   case kNoPID:
204     varCuts->AddCut(AliDielectronVarManager::kPt,0.85,1e30);    //0.8
205     varCuts->AddCut(AliDielectronVarManager::kEta,         -0.9,   0.9); // -0.9, 0.9
206     varCuts->AddCut(AliDielectronVarManager::kNclsTPC,     70.0, 160.0);
207     trkCuts->SetITSclusterCut(AliDielectronTrackCuts::kOneOf, 7); // ITS-3 = 1+2+4
208     break;
209   case kTOF:
210   case kTRD:
211   case kTPC:
212     varCuts->AddCut(AliDielectronVarManager::kPt,0.95,1e30);    //0.8
213     varCuts->AddCut(AliDielectronVarManager::kEta,         -0.9,   0.9); // -0.9, 0.9
214     varCuts->AddCut(AliDielectronVarManager::kNclsTPC,     70.0, 160.0);
215     trkCuts->SetITSclusterCut(AliDielectronTrackCuts::kOneOf, 7); // ITS-3 = 1+2+4
216     break;
217   }
218   // standard cuts
219   varCuts->AddCut(AliDielectronVarManager::kImpactParXY, -1.0,   1.0);
220   varCuts->AddCut(AliDielectronVarManager::kImpactParZ,  -3.0,   3.0);
221   varCuts->AddCut(AliDielectronVarManager::kTPCchi2Cl,    0.0,   4.0);
222   varCuts->AddCut(AliDielectronVarManager::kKinkIndex0,   0.0);
223   //  varCuts->AddCut(AliDielectronVarManager::kV0Index0,     0.0);
224   trkCuts->SetRequireITSRefit(kTRUE);
225   trkCuts->SetRequireTPCRefit(kTRUE);
226
227   /* vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv PID CUTS vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv */
228   AliDielectronVarCuts *pidVarCuts = new AliDielectronVarCuts("varPIDCuts","varPIDCuts");
229   AliDielectronPID *pidCuts        = new AliDielectronPID("PIDCuts","PIDCuts");
230   switch(cutDefinition) {
231   case kTRD:
232     pidCuts->AddCut(AliDielectronPID::kTRDeleEff,AliPID::kElectron,.8,1.,3.5,6.,kFALSE,
233                     AliDielectronPID::kIfAvailable,AliDielectronVarManager::kTRDpidQuality);
234   case kTOF:
235     pidVarCuts->AddCut(AliDielectronVarManager::kTOFbeta,      0.2,   0.9, kTRUE);
236     pidCuts->AddCut(AliDielectronPID::kTOF,AliPID::kElectron,-3,3.,0.,0.,kFALSE,
237                     AliDielectronPID::kIfAvailable);
238   case kTPC:
239     pidCuts->AddCut(AliDielectronPID::kTPC,AliPID::kElectron,-3.,4.);
240     pidCuts->AddCut(AliDielectronPID::kTPC,AliPID::kPion,-100.,4.0,0.,0.,kTRUE);
241     pidCuts->AddCut(AliDielectronPID::kTPC,AliPID::kProton,-100.,3.5,0.,0.,kTRUE);
242     break;
243   case kIonut:
244     pidCuts->AddCut(AliDielectronPID::kTPC,AliPID::kElectron,-1.5.,3.);
245     pidCuts->AddCut(AliDielectronPID::kTPC,AliPID::kElectron,-0.9,3.0,-0.5,+0.5,kFALSE,
246                 AliDielectronPID::kRequire,AliDielectronVarManager::kEta);
247     pidCuts->AddCut(AliDielectronPID::kTPC,AliPID::kElectron,-0.65,3.0,-0.3,+0.3,kFALSE,
248                 AliDielectronPID::kRequire,AliDielectronVarManager::kEta);
249     pidCuts->AddCut(AliDielectronPID::kTPC,AliPID::kElectron,-0.4,3.0,-0.1,+0.1,kFALSE,
250                 AliDielectronPID::kRequire,AliDielectronVarManager::kEta);
251     pidCuts->AddCut(AliDielectronPID::kTPC,AliPID::kProton,-100.,4.0,0.,0.,kTRUE);
252     break;
253   }
254
255   /* vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv TENDER CUTS vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv */
256   // exclude conversion electrons selected by the tender
257   AliDielectronTrackCuts *noconv=new AliDielectronTrackCuts("noConv","noConv");
258   noconv->SetV0DaughterCut(AliPID::kElectron,kTRUE);
259
260   // activate the cut sets (order might be CPU timewise important)
261   if(!isESD) cuts->AddCut(trkFilter);
262   cuts->AddCut(varCuts);
263   cuts->AddCut(trkCuts);
264   if(cutDefinition!=kNoPID) cuts->AddCut(pidCuts);
265   if(cutDefinition!=kNoPID) cuts->AddCut(pidVarCuts);
266   //cuts->AddCut(noconv);
267   cuts->Print();
268
269 }
270
271 //______________________________________________________________________________________
272 void SetupV0Cuts(AliDielectron *die, Int_t cutDefinition)
273 {
274   //
275   // Setup the V0 cuts
276   //
277
278   // Quality cuts (add the gamma filter to the cut group)
279   TIter next(die->GetTrackFilter().GetCuts());
280   AliAnalysisCuts *cuts;
281   while((cuts = (AliAnalysisCuts*)next())) {
282     if(cuts->IsA() == AliDielectronCutGroup::Class())  break;
283   }
284
285   AliDielectronV0Cuts *gammaV0Cuts = new AliDielectronV0Cuts("IsGamma","IsGamma");
286   gammaV0Cuts->SetPdgCodes(22,11,11);
287   gammaV0Cuts->SetDefaultPID(13); // TPC+-3.5 TOF+-4
288   gammaV0Cuts->AddCut(AliDielectronVarManager::kCosPointingAngle, TMath::Cos(0.02),   1.0, kFALSE);
289   gammaV0Cuts->AddCut(AliDielectronVarManager::kChi2NDF,                       0.0,  10.0, kFALSE);
290   gammaV0Cuts->AddCut(AliDielectronVarManager::kLegDist,                       0.0,   0.25, kFALSE);
291   gammaV0Cuts->AddCut(AliDielectronVarManager::kR,                             3.0,  90.0, kFALSE);
292   gammaV0Cuts->AddCut(AliDielectronVarManager::kPsiPair,                       0.0,   0.05, kFALSE);
293   gammaV0Cuts->AddCut(AliDielectronVarManager::kM,                             0.0,   0.05, kFALSE);
294   //  gammaV0Cuts->AddCut(AliDielectronVarManager::kOpeningAngle,              0.0,   0.1, kFALSE);
295   gammaV0Cuts->AddCut(AliDielectronVarManager::kArmPt,                         0.0,   0.05, kFALSE);
296   //  gammaV0Cuts->AddCut(AliDielectronVarManager::kArmAlpha,                     -0.35,  0.35, kFALSE); // not sure if it works as expected
297   gammaV0Cuts->SetExcludeTracks(kTRUE);
298   gammaV0Cuts->Print();
299
300  //  const Double_t |cutAlphaG| < 0.35; &&  const Double_t cutQTG < 0.05;
301  //  const Double_t |cutAlphaG2|[2] = {0.6, 0.8}; &&  const Double_t cutQTG2 < 0.04;
302
303   if(cuts)
304     ((AliDielectronCutGroup*)cuts)->AddCut(gammaV0Cuts);
305   else
306     die->GetTrackFilter().AddCuts(gammaV0Cuts);
307 }
308
309 //______________________________________________________________________________________
310 void SetupPairCuts(AliDielectron *die, Int_t cutDefinition)
311 {
312   //
313   // Setup the pair cuts
314   //
315
316   // conversion rejection
317   Double_t gCut;
318   switch(cutDefinition) {
319     //   case kTPC:    gCut=0.05;  break;
320     //   case kTOF:    gCut=0.05;  break;
321     //   case kTRD:    gCut=0.05;  break;
322     //   case kIonut:  gCut=0.05;  break;
323   default: gCut=0.05;       // default
324   }
325
326   AliDielectronVarCuts *gammaCuts = new AliDielectronVarCuts("GammaCuts","GammaCuts");
327   gammaCuts->AddCut(AliDielectronVarManager::kM,            0.0,   gCut);
328   die->GetPairPreFilter().AddCuts(gammaCuts);
329
330   // rapidity selection
331   //  AliDielectronVarCuts *rapCut=new AliDielectronVarCuts("|Y|<.9","|Y|<.9");
332   // rapCut->AddCut(AliDielectronVarManager::kY,-0.9,0.9);
333   // die->GetPairFilter().AddCuts(rapCut);
334
335 }
336
337 //______________________________________________________________________________________
338 void ConfigBgrd(AliDielectron *die, Int_t cutDefinition)
339 {
340   //
341   // Configurate the background estimators
342   //
343
344   // add track rotations
345   AliDielectronTrackRotator *rot=new AliDielectronTrackRotator;
346   rot->SetIterations(10);
347   rot->SetConeAnglePhi(TMath::Pi());
348   rot->SetStartAnglePhi(TMath::Pi());
349   //      die->SetTrackRotator(rot);
350
351   // add mixed events
352   AliDielectronMixingHandler *mix=new AliDielectronMixingHandler;
353   mix->AddVariable(AliDielectronVarManager::kZvPrim,      "-10.,-5.,-4.,-3.,-2.,-1.,0.,1.,2.,3.,4.,5.,10.");
354   mix->AddVariable(AliDielectronVarManager::kCentrality,  8,  0.,80.);
355   mix->AddVariable(AliDielectronVarManager::kTPCrpH2,     8,  TMath::Pi()/-2., TMath::Pi()/2.);
356   mix->AddVariable(AliDielectronVarManager::kTPCmagH2,    "0.,20.,50.,80.,110.,150.,500.");
357   mix->SetMixType(AliDielectronMixingHandler::kAll);
358   mix->SetDepth(150);
359   die->SetMixingHandler(mix);
360
361 }
362
363 //______________________________________________________________________________________
364 void ConfigEvtPlane(AliDielectron *die, Int_t cutDefinition)
365 {
366   //
367   // Configurate the TPC event plane 
368   //
369
370   //   Double_t gGap;
371   //   switch(cutDefinition) {
372   //   case kEtaGap01:   gGap=0.1;   break;
373   //   case kEtaGap02:   gGap=0.2;   break;
374   //   case kEtaGap03:   gGap=0.3;   break;
375   //   case kEtaGap04:   gGap=0.4;   break;
376   //   case kEtaGap05:   gGap=0.5;   break;
377   //   default: gGap=0.0;
378   //   }
379   // eta gap in tpc event plane
380   //   AliDielectronVarCuts *etaGap = new AliDielectronVarCuts(AliDielectronVarManager::GetValueName(AliDielectronVarManager::kEta),"etaGap");
381   //   etaGap->AddCut(AliDielectronVarManager::kEta,-1*gGap,gGap,kTRUE);
382   //   die->GetEventPlanePreFilter().AddCuts(etaGap);
383
384   AliDielectronVarCuts *poi = new AliDielectronVarCuts("PoI","PoI");
385   poi->AddCut(AliDielectronVarManager::kM,2.92,3.20);     // particles of interest, jpsi mass window
386   die->GetEventPlanePOIPreFilter().AddCuts(poi);
387
388   // die->SetLikeSignSubEvents();
389   die->SetPreFilterEventPlane();
390 }
391
392 //______________________________________________________________________________________
393 void InitHistograms(AliDielectron *die, Int_t cutDefinition)
394 {
395   //
396   // Initialise the histograms
397   //
398   Bool_t hasMC=die->GetHasMC();
399
400   // booleans for histo selection
401   Bool_t bHistTrackQA=kFALSE, bHistEvts = kFALSE, bHistPair = kFALSE, bHistPairME = kFALSE, bHistFlow = kFALSE, bHistFlowQA=kFALSE;
402   switch (cutDefinition) {
403   case kTPC:   bHistEvts=kTRUE;
404   case kTOF:
405   case kTRD:
406   case kIonut: bHistFlow=kTRUE; bHistFlowQA=kTRUE; bHistPair=kTRUE; bHistPairME=kFALSE;
407
408     //   case kTOFTRD:
409     //   case kTOFTRD2D: bHistFlow=kTRUE; bHistPair=kTRUE; break;
410     //   case krec:      break;
411     //  case kITScls:
412     //  case kITSamy:
413     //  case kDCA:
414     //  case kChi:      break;
415     //   case kEtaGap01:
416     //   case kEtaGap02:
417     //   case kEtaGap03:
418     //   case kEtaGap04:
419     //   case kEtaGap05:
420     //   case kSubRndm:  bHistFlow=kTRUE; bHistFlowQA=kTRUE; break;
421     //   case kSubLS:    bHistFlow=kTRUE; bHistFlowQA=kTRUE; bHistEvts=kTRUE; break;
422     //   case kGam0:
423     //   case kGam01:
424     //   case kGam05:
425     //   case kGam10:
426     //   case kGam15:
427     //   case kGam20:    break;
428   }
429   if(hasMC) { bHistFlow=kFALSE; bHistFlowQA=kFALSE; bHistPairME=kFALSE; }
430
431   //Setup histogram Manager
432   AliDielectronHistos *histos=new AliDielectronHistos(die->GetName(),die->GetTitle());
433
434   //add histograms to event class
435   histos->AddClass("Event");
436   histos->UserHistogram("Event","","", 100, 0.0, 100.0,   AliDielectronVarManager::kCentrality);
437
438   ////// EVENT HISTOS /////
439   if(bHistEvts) {
440     histos->UserHistogram("Event","","", GetRunNumbers(), AliDielectronVarManager::kRunNumber);
441     histos->UserHistogram("Event","","", 300,-15.,15.,    AliDielectronVarManager::kZvPrim);
442     histos->UserProfile(  "Event","","", AliDielectronVarManager::kNacc,        80, 0., 80.,     AliDielectronVarManager::kCentrality);
443     histos->UserProfile(  "Event","","", AliDielectronVarManager::kNVtxContrib, 80, 0., 80.,   AliDielectronVarManager::kCentrality);
444   } //hist: event
445
446
447   ////// FLOW //////
448   if(bHistFlow) {
449     // EP Qvector magnitudes // TODO move to QA
450     //     histos->UserHistogram("Event","","", 200,0.,200., AliDielectronVarManager::kTPCmagH2uc);
451     //     histos->UserHistogram("Event","","", 200,0.,800., AliDielectronVarManager::kv0ACmagH2);
452     //     histos->UserHistogram("Event","","", 200,0.,800., AliDielectronVarManager::kv0AmagH2);
453     //     histos->UserHistogram("Event","","", 200,0.,800., AliDielectronVarManager::kv0CmagH2);
454     // RP angles versus centrality
455     histos->UserHistogram("Event","","", 16,0.,80.,100,-2.,2., AliDielectronVarManager::kCentrality,AliDielectronVarManager::kTPCrpH2);
456     histos->UserHistogram("Event","","", 16,0.,80.,100,-2.,2., AliDielectronVarManager::kCentrality,AliDielectronVarManager::kTPCsub1rpH2);
457     histos->UserHistogram("Event","","", 16,0.,80.,100,-2.,2., AliDielectronVarManager::kCentrality,AliDielectronVarManager::kTPCsub2rpH2);
458     histos->UserHistogram("Event","","", 16,0.,80.,100,-2.,2., AliDielectronVarManager::kCentrality,AliDielectronVarManager::kv0ArpH2);
459     histos->UserHistogram("Event","","", 16,0.,80.,100,-2.,2., AliDielectronVarManager::kCentrality,AliDielectronVarManager::kv0CrpH2);
460     histos->UserHistogram("Event","","", 16,0.,80.,100,-2.,2., AliDielectronVarManager::kCentrality,AliDielectronVarManager::kv0ACrpH2);
461     histos->UserHistogram("Event","","", 16,0.,80.,100,-2.,2., AliDielectronVarManager::kCentrality,AliDielectronVarManager::kv0A0rpH2);
462     histos->UserHistogram("Event","","", 16,0.,80.,100,-2.,2., AliDielectronVarManager::kCentrality,AliDielectronVarManager::kv0C0rpH2);
463     histos->UserHistogram("Event","","", 16,0.,80.,100,-2.,2., AliDielectronVarManager::kCentrality,AliDielectronVarManager::kv0A3rpH2);
464     histos->UserHistogram("Event","","", 16,0.,80.,100,-2.,2., AliDielectronVarManager::kCentrality,AliDielectronVarManager::kv0C3rpH2);
465   } // hist: flow
466
467   if(bHistFlowQA) {
468     // TPC event plane
469     histos->UserHistogram("Event","","", 100,-1500.,1500., AliDielectronVarManager::kTPCxH2);
470     histos->UserHistogram("Event","","", 100,-1500.,1500., AliDielectronVarManager::kTPCyH2);
471     histos->UserHistogram("Event","","", 100,   -2.,   2., AliDielectronVarManager::kTPCrpH2);
472     histos->UserHistogram("Event","","", 100,   -2.,   2., AliDielectronVarManager::kTPCsub1rpH2);
473     histos->UserHistogram("Event","","", 100,   -2.,   2., AliDielectronVarManager::kTPCsub2rpH2);
474     histos->UserHistogram("Event","","", 100,   -1.,   1., AliDielectronVarManager::kTPCsub12DiffH2);
475     // EP resolution calculation
476     histos->UserHistogram("Event","","", 80,0.,80., 300,-1.0,1.0, AliDielectronVarManager::kCentrality, AliDielectronVarManager::kv0ATPCDiffH2);
477     histos->UserHistogram("Event","","", 80,0.,80., 300,-1.0,1.0, AliDielectronVarManager::kCentrality, AliDielectronVarManager::kv0CTPCDiffH2);
478     histos->UserHistogram("Event","","", 80,0.,80., 300,-1.0,1.0, AliDielectronVarManager::kCentrality, AliDielectronVarManager::kv0Av0CDiffH2);
479     histos->UserHistogram("Event","","", 80,0.,80., 300,-1.0,1.0, AliDielectronVarManager::kCentrality, AliDielectronVarManager::kTPCsub12DiffH2);
480     histos->UserHistogram("Event","","", 80,0.,80., 300,-1.0,1.0, AliDielectronVarManager::kCentrality, AliDielectronVarManager::kv0Av0C0DiffH2);
481     histos->UserHistogram("Event","","", 80,0.,80., 300,-1.0,1.0, AliDielectronVarManager::kCentrality, AliDielectronVarManager::kv0Av0C3DiffH2);
482     histos->UserHistogram("Event","","", 80,0.,80., 300,-1.0,1.0, AliDielectronVarManager::kCentrality, AliDielectronVarManager::kv0Cv0A0DiffH2);
483     histos->UserHistogram("Event","","", 80,0.,80., 300,-1.0,1.0, AliDielectronVarManager::kCentrality, AliDielectronVarManager::kv0Cv0A3DiffH2);
484     histos->UserHistogram("Event","","", 80,0.,80., 300,-1.0,1.0, AliDielectronVarManager::kCentrality, AliDielectronVarManager::kv0A0v0A3DiffH2);
485     histos->UserHistogram("Event","","", 80,0.,80., 300,-1.0,1.0, AliDielectronVarManager::kCentrality, AliDielectronVarManager::kv0C0v0C3DiffH2);
486     // detector effects
487     histos->UserHistogram("Event","","", 10,0.,100., 300,-1.0,1.0, AliDielectronVarManager::kCentrality, AliDielectronVarManager::kTPCsub12DiffH2Sin);
488     // recentering stuff
489     histos->UserProfile("Event","","", AliDielectronVarManager::kTPCxH2,
490                         AliDielectronHelper::MakeLinBinning(8, 0.,80.), GetRunNumbers(),
491                         AliDielectronVarManager::kCentrality, AliDielectronVarManager::kRunNumber);
492     histos->UserProfile("Event","","", AliDielectronVarManager::kTPCyH2,
493                         AliDielectronHelper::MakeLinBinning(8, 0.,80.), GetRunNumbers(),
494                         AliDielectronVarManager::kCentrality, AliDielectronVarManager::kRunNumber);
495   } //hist: flowQA
496
497   if(bHistPair) {
498     //Initialise histogram classes
499     histos->SetReservedWords("Track;Pair");
500
501     //Pair classes
502     // to fill also mixed event histograms loop until 7 or 10
503     for (Int_t i=0; i<(bHistPairME ? 8 : 3); ++i){
504       histos->AddClass(Form("Pair_%s",AliDielectron::PairClassName(i)));
505     }
506     //add MC signal histograms to track class
507     if(die->GetMCSignals()) {
508       for (Int_t i=0; i<die->GetMCSignals()->GetEntriesFast(); ++i)
509         histos->AddClass(Form("Pair_%s",die->GetMCSignals()->At(i)->GetName()));
510     }
511
512     //Track classes
513     //legs from pair (fill SE)
514     for (Int_t i=0; i<3; ++i){
515       histos->AddClass(Form("Track_Legs_%s",AliDielectron::PairClassName(i)));
516     }
517     //to fill also track info from 2nd event loop until 2
518     //    for (Int_t i=0; i<2; ++i) histos->AddClass(Form("Track_%s",AliDielectron::TrackClassName(i)));
519     histos->AddClass(Form("Track_%s",     AliDielectron::PairClassName(AliDielectron::kEv1PM)));
520
521     // Vertex
522     histos->UserHistogram("Track","","", 500,-1.,1., AliDielectronVarManager::kImpactParXY);
523     histos->UserHistogram("Track","","", 600,-3.,3., AliDielectronVarManager::kImpactParZ);
524     // Kinematics
525     histos->UserHistogram("Track","","", 400,0,20.,  AliDielectronVarManager::kPt);
526     histos->UserHistogram("Track","","", 200,-1,1, 200,0,6.285, AliDielectronVarManager::kEta,AliDielectronVarManager::kPhi);
527     // TPC
528     histos->UserHistogram("Track","","", 160,-0.5,159.5, AliDielectronVarManager::kNclsTPC);
529     histos->UserHistogram("Track","","", 160,-0.5,159.5, AliDielectronVarManager::kTPCsignalN);
530     histos->UserHistogram("Track","","", 160,-0.5,159.5, AliDielectronVarManager::kNFclsTPCr);
531     histos->UserHistogram("Track","","", 160,-0.5,159.5, 160,-0.5,159.5, AliDielectronVarManager::kNclsTPC,AliDielectronVarManager::kNFclsTPCr);
532     // TRD
533     histos->UserHistogram("Track","","",   8,-0.5,  7.5, AliDielectronVarManager::kTRDpidQuality);
534     // PID
535     histos->UserHistogram("Track","","", 400,0.2,20.,200,0.,200., AliDielectronVarManager::kPIn,AliDielectronVarManager::kTPCsignal,kTRUE);
536     histos->UserHistogram("Track","","", 400,0.2,20.,200,-10.,10.,AliDielectronVarManager::kPIn,AliDielectronVarManager::kTPCnSigmaEle,kTRUE);
537     histos->UserHistogram("Track","","", 250,0.0,5.0,300,0.,1.2,  AliDielectronVarManager::kPIn,AliDielectronVarManager::kTOFbeta,kTRUE);
538
539     histos->UserHistogram("Pair","","", 210,-1.05,1.05, 100,0.,2.5, AliDielectronVarManager::kArmAlpha,AliDielectronVarManager::kArmPt);
540
541     ///// add histograms to Pair classes /////
542     histos->UserHistogram("Pair","","",  300,.0,300*0.04, AliDielectronVarManager::kM); // 40MeV bins, 12GeV/c2
543     histos->UserHistogram("Pair","","",  100,-1.,1.,      AliDielectronVarManager::kY);
544     histos->UserHistogram("Pair","","",  400,0,20.,       AliDielectronVarManager::kPt);
545     histos->UserHistogram("Pair","","",  100,0.,3.15,     AliDielectronVarManager::kOpeningAngle);
546     histos->UserHistogram("Pair","","",  100,0.,20,       AliDielectronVarManager::kChi2NDF);
547     histos->UserHistogram("Pair","","",  100,0.,3.15,     AliDielectronVarManager::kPsiPair);
548     histos->UserHistogram("Pair","","",  200,0.,100.,     AliDielectronVarManager::kR);
549     histos->UserHistogram("Pair","","",   50,0.,5.,       AliDielectronVarManager::kLegDist);
550     histos->UserHistogram("Pair","","",   50,0.,5.,       AliDielectronVarManager::kLegDistXY);
551
552     //// FLOW results use tprofiles
553     if(bHistFlow) {
554       // differential observed v2 (pt and centrality)
555       histos->UserProfile("Pair","","",
556                           AliDielectronVarManager::kv0ArpH2FlowV2,
557                           125,0.,125*.04, 10, 0.,100., 20,0.,10.,
558                           AliDielectronVarManager::kM, AliDielectronVarManager::kCentrality, AliDielectronVarManager::kPt);
559       histos->UserProfile("Pair","","",
560                           AliDielectronVarManager::kv0CrpH2FlowV2,
561                           125,0.,125*.04, 10, 0.,100., 20,0.,10.,
562                           AliDielectronVarManager::kM, AliDielectronVarManager::kCentrality, AliDielectronVarManager::kPt);
563       histos->UserProfile("Pair","","",
564                           AliDielectronVarManager::kv0ArpH2FlowV2,
565                           125,0.,125*.04, 10, 0.,100., 20,0.,10.,
566                           AliDielectronVarManager::kM, AliDielectronVarManager::kCentrality, AliDielectronVarManager::kPt,
567                           0, 0, 0, "S");
568       histos->UserProfile("Pair","","",
569                           AliDielectronVarManager::kv0CrpH2FlowV2,
570                           125,0.,125*.04, 10, 0.,100., 20,0.,10.,
571                           AliDielectronVarManager::kM, AliDielectronVarManager::kCentrality, AliDielectronVarManager::kPt,
572                           0, 0, 0, "S");
573
574       // pt dependence
575       histos->UserProfile("Pair","","",                   AliDielectronVarManager::kv0ArpH2FlowV2,
576                           125,0.,125*.04, 20, 0.,10.,     AliDielectronVarManager::kM, AliDielectronVarManager::kPt);
577       histos->UserProfile("Pair","","",                   AliDielectronVarManager::kv0ArpH2FlowV2,
578                           125,0.,125*.04, 20, 0.,10.,     AliDielectronVarManager::kM, AliDielectronVarManager::kPt, 0, 0, "S");
579       histos->UserProfile("Pair","","",                   AliDielectronVarManager::kv0CrpH2FlowV2,
580                           125,0.,125*.04, 20, 0.,10.,     AliDielectronVarManager::kM, AliDielectronVarManager::kPt);
581       histos->UserProfile("Pair","","",                   AliDielectronVarManager::kv0CrpH2FlowV2,
582                           125,0.,125*.04, 20, 0.,10.,     AliDielectronVarManager::kM, AliDielectronVarManager::kPt, 0, 0, "S");
583
584       // centrality dependence
585       histos->UserProfile("Pair","","",                   AliDielectronVarManager::kv0ArpH2FlowV2,
586                           125,0.,125*.04, 10, 0.,100.,    AliDielectronVarManager::kM, AliDielectronVarManager::kCentrality);
587       histos->UserProfile("Pair","","",                   AliDielectronVarManager::kv0ArpH2FlowV2,
588                           125,0.,125*.04, 10, 0.,100.,    AliDielectronVarManager::kM, AliDielectronVarManager::kCentrality, 0, 0, "S");
589       histos->UserProfile("Pair","","",                   AliDielectronVarManager::kv0CrpH2FlowV2,
590                           125,0.,125*.04, 10, 0.,100.,    AliDielectronVarManager::kM, AliDielectronVarManager::kCentrality);
591       histos->UserProfile("Pair","","",                   AliDielectronVarManager::kv0CrpH2FlowV2,
592                           125,0.,125*.04, 10, 0.,100.,    AliDielectronVarManager::kM, AliDielectronVarManager::kCentrality, 0, 0, "S");
593
594       // integrated inv mass dependence
595       histos->UserProfile("Pair","","",   AliDielectronVarManager::kv0ArpH2FlowV2,
596                           125,0.,125*.04,  AliDielectronVarManager::kM);
597       histos->UserProfile("Pair","","",   AliDielectronVarManager::kv0ArpH2FlowV2,
598                           125,0.,125*.04,  AliDielectronVarManager::kM , 0, "S");
599
600       // control histograms
601       histos->UserHistogram("Pair","","",
602                             125,0.,125*.04,  200,-1.,+1.,
603                             AliDielectronVarManager::kM,          AliDielectronVarManager::kv0ArpH2FlowV2);
604
605
606     } //hist: flow
607   } //hist: pair
608
609
610   ////// MONTE CARLO //////
611   /*
612     if(cutDefinition == kTOFTRD && hasMC) {
613     histos->AddClass("MCEvent");
614     histos->UserHistogram("MCEvent","Cent_NJPsis","Centrality vs. generated incl. J/#psi per event;centrality (%);N_{J/#psi}",
615     10,0.,100., 21,-0.5,20.5,
616     AliDielectronVarManager::kCentrality,AliDielectronVarManager::kNumberOfJPsis);
617     }
618   */
619
620   //  histos->UserHistogram("Track","TRDprobEle",";P_{ele}^{TRD};#tracks", 
621   //                    100,0.,1.,            AliDielectronVarManager::kTRDprobEle);
622   
623   die->SetHistogramManager(histos);
624 }
625
626 void InitHF(AliDielectron* die, Int_t cutDefinition)
627 {
628   //
629   // Setup the HF arrays
630   //
631   Bool_t hasMC=die->GetHasMC();
632
633   AliDielectronHistos *histos=new AliDielectronHistos("abc","def");
634   //Initialise histogram classes
635   histos->SetReservedWords("Track;Pair");
636   // to fill also mixed event histograms loop until 7 or 10
637   for (Int_t i=0; i<1; ++i){
638       histos->AddClass(Form("Pair_%s",AliDielectron::PairClassName(i)));
639   }
640
641   AliDielectronHF *hf=new AliDielectronHF(die->GetName(),die->GetTitle());
642   //  if(hasMC) hf->SetStepForMCGenerated();
643   //  hf->SetPairTypes(AliDielectronHF::kAll);
644   //  hf->SetVariable(AliDielectronVarManager::kM, 125, 0.0, 0.04*125);
645   
646   hf->SetPairTypes(AliDielectronHF::kOSonly);
647   TProfile *prf = new TProfile("","",125,0.,125*.04);
648   UInt_t vars[] = {AliDielectronVarManager::kM, AliDielectronVarManager::kv0CrpH2FlowV2};
649   hf->SetRefHist(prf,vars);
650
651   hf->AddCutVariable(AliDielectronVarManager::kCentrality,  "0.,5.,10.,20.,40.,50.,60.,80."  );
652   hf->AddCutVariable(AliDielectronVarManager::kPt,          "0.,2.5,5.,100."                 );
653   //  hf->AddCutVariable(AliDielectronVarManager::kDeltaPhiv0ArpH2, 8,-1.*TMath::Pi(),TMath::Pi());
654   //  hf->AddCutVariable(AliDielectronVarManager::kDeltaPhiv0CrpH2, 8,-1.*TMath::Pi(),TMath::Pi());
655   //  hf->AddCutVariable(AliDielectronVarManager::kY,           1, -0.9, 0.9                     );
656   //  hf->AddCutVariable(AliDielectronVarManager::kPt,          "0.8, 1.0, 1.1, 1.2, 1.5, 100.0", kTRUE, AliDielectronHF::kBinToMax);
657   // hf->AddCutVariable(AliDielectronVarManager::kNclsTPC,     "70,90,100,120,160",              kTRUE, AliDielectronHF::kBinToMax);
658   //  hf->AddCutVariable(AliDielectronVarManager::kTPCnSigmaEle,"-4,-3,-2.5,-2,2,2.5,3,4",        kTRUE, AliDielectronHF::kSymBin);
659   //hf->AddCutVariable(AliDielectronVarManager::kTPCnSigmaPio,"3.,3.5,4.,100.",                 kTRUE, AliDielectronHF::kBinToMax);
660   //hf->AddCutVariable(AliDielectronVarManager::kITSLayerFirstCls,4,0.,4.,              kFALSE, kTRUE, AliDielectronHF::kBinFromMin);
661   //hf->AddCutVariable(AliDielectronVarManager::kNclsITS,         5,2.,7.,              kFALSE, kTRUE, AliDielectronHF::kBinToMax);
662   //hf->AddCutVariable(AliDielectronVarManager::kRunNumber,  GetRunNumbers());
663
664   die->SetHistogramArray(hf);
665 }
666
667 void InitCF(AliDielectron* die, Int_t cutDefinition)
668 {
669   //
670   // Setup the CF Manager if needed
671   //
672   Bool_t hasMC=die->GetHasMC();
673
674   AliDielectronCF *cf=new AliDielectronCF(die->GetName(),die->GetTitle());
675
676   // event variables
677   cf->AddVariable(AliDielectronVarManager::kCentrality,      "0.,5.,10.,20.,40.,50.,60.,80.");
678   if(hasMC)  cf->AddVariable(AliDielectronVarManager::kRunNumber, GetRunNumbers() );
679   //    if(hasMC)  cf->AddVariable(AliDielectronVarManager::kNacc,20,0.,3000.0);
680   //    if(hasMC)  cf->AddVariable(AliDielectronVarManager::kNVtxContrib,20,0.,4000.);
681
682   // pair variables
683   cf->AddVariable(AliDielectronVarManager::kY,  18, -0.9,  0.9);
684   cf->AddVariable(AliDielectronVarManager::kM, 125,  0.0,  5.0); //40Mev Steps
685   cf->AddVariable(AliDielectronVarManager::kPt, 50,  0.0, 10.0);
686   if(!hasMC) cf->AddVariable(AliDielectronVarManager::kPairType,11,0,11);
687   //    if(hasMC) cf->AddVariable(AliDielectronVarManager::kTRDpidEffPair,101,0.0,1.01);
688   //    if(hasMC) cf->AddVariable(AliDielectronVarManager::kThetaCS,15,-1.,1.);
689
690   // flow variables
691   if(!hasMC) cf->AddVariable(AliDielectronVarManager::kDeltaPhiv0ArpH2, GetDeltaPhiBins());
692   if(!hasMC) cf->AddVariable(AliDielectronVarManager::kDeltaPhiv0CrpH2, GetDeltaPhiBins());
693
694   // leg variables
695   cf->AddVariable(AliDielectronVarManager::kPt,"0.85, 0.95, 1.1, 100.0",kTRUE);
696   if(hasMC) cf->AddVariable(AliDielectronVarManager::kEta,"-0.9,-0.8,0.8,0.9",kTRUE);
697   //    cf->AddVariable(AliDielectronVarManager::kITSLayerFirstCls,7,-1.5,5.5,kTRUE);
698   //    cf->AddVariable(AliDielectronVarManager::kNclsITS,"1,2,3,4,5,6",kTRUE);
699   //    cf->AddVariable(AliDielectronVarManager::kTPCnSigmaEle,"-3,-2.5,-2,2,2.5,3",kTRUE);
700   //    cf->AddVariable(AliDielectronVarManager::kTPCnSigmaPio,"2.5,3.0,3.5,4.0,4.5,100",kTRUE);
701   //    cf->AddVariable(AliDielectronVarManager::kNclsTPC,"70, 90, 100, 120, 160",kTRUE);
702   //    cf->AddVariable(AliDielectronVarManager::kTPCnSigmaPro,"3.5,4.0,4.5,5.0,100",kTRUE);
703   //    cf->AddVariable(AliDielectronVarManager::kTOFnSigmaEle,"-3,-2,2,3",kTRUE); break;
704   //    cf->AddVariable(AliDielectronVarManager::kTRDpidQuality,"3.5, 4.5, 5.5, 6.5",kTRUE);
705   //    if(!hasMC && isESD) cf->AddVariable(AliDielectronVarManager::kTRDchi2,"-1.,0.,2.,4.",kTRUE);
706
707   // mc steps
708   if(hasMC) {
709     if(cutDefinition==kTPC) cf->SetStepForMCtruth();
710     //    cf->SetStepForNoCutsMCmotherPid();
711     //    cf->SetStepForAfterAllCuts();
712     //    cf->SetStepsForEachCut();
713     //    cf->SetStepsForSignal();
714     //    cf->SetStepsForBackground(); 
715     cf->SetStepsForMCtruthOnly();
716   }
717
718   die->SetCFManagerPair(cf);
719 }
720
721 void AddMCSignals(AliDielectron *die){
722   //Do we have an MC handler?
723   if (!die->GetHasMC()) return;
724
725   AliDielectronSignalMC* inclusiveJpsi = new AliDielectronSignalMC("inclusiveJpsi","Inclusive");
726   inclusiveJpsi->SetLegPDGs(11,-11);
727   inclusiveJpsi->SetMotherPDGs(443,443);
728   inclusiveJpsi->SetMothersRelation(AliDielectronSignalMC::kSame);
729   inclusiveJpsi->SetFillPureMCStep(kTRUE);
730   inclusiveJpsi->SetCheckBothChargesLegs(kTRUE,kTRUE);
731   inclusiveJpsi->SetCheckBothChargesMothers(kTRUE,kTRUE);
732   die->AddSignalMC(inclusiveJpsi);
733
734   AliDielectronSignalMC* beautyJpsi = new AliDielectronSignalMC("beautyJpsi","Beauty");
735   beautyJpsi->SetLegPDGs(11,-11);
736   beautyJpsi->SetMotherPDGs(443,443);
737   beautyJpsi->SetMothersRelation(AliDielectronSignalMC::kSame);
738   beautyJpsi->SetGrandMotherPDGs(500,500);
739   beautyJpsi->SetFillPureMCStep(kTRUE);
740   beautyJpsi->SetCheckBothChargesLegs(kTRUE,kTRUE);
741   beautyJpsi->SetCheckBothChargesMothers(kTRUE,kTRUE);
742   beautyJpsi->SetCheckBothChargesGrandMothers(kTRUE,kTRUE);
743   die->AddSignalMC(beautyJpsi);
744
745   AliDielectronSignalMC* promptJpsi = new AliDielectronSignalMC("promptJpsi","Prompt");   // prompt J/psi (not from beauty decays)
746   promptJpsi->SetLegPDGs(11,-11);
747   promptJpsi->SetMotherPDGs(443,443);
748   promptJpsi->SetGrandMotherPDGs(503,503,kTRUE,kTRUE);   // not from beauty hadrons
749   promptJpsi->SetMothersRelation(AliDielectronSignalMC::kSame);
750   promptJpsi->SetFillPureMCStep(kTRUE);
751   promptJpsi->SetLegSources(AliDielectronSignalMC::kFinalState, AliDielectronSignalMC::kFinalState);
752   promptJpsi->SetCheckBothChargesLegs(kTRUE,kTRUE);
753   promptJpsi->SetCheckBothChargesMothers(kTRUE,kTRUE);
754   promptJpsi->SetCheckBothChargesGrandMothers(kTRUE,kTRUE);
755   die->AddSignalMC(promptJpsi);
756
757   // prompt J/psi radiative channel
758   AliDielectronSignalMC* promptJpsiRad = new AliDielectronSignalMC("promptJpsiRad","PromptRadiative");   // prompt J/psi (not from beauty decays)
759   promptJpsiRad->SetLegPDGs(11,-11);
760   promptJpsiRad->SetMotherPDGs(443,443);
761   promptJpsiRad->SetGrandMotherPDGs(503,503,kTRUE,kTRUE);   // not from beauty hadrons
762   promptJpsiRad->SetMothersRelation(AliDielectronSignalMC::kSame);
763   promptJpsiRad->SetFillPureMCStep(kTRUE);
764   promptJpsiRad->SetLegSources(AliDielectronSignalMC::kFinalState, AliDielectronSignalMC::kFinalState);
765   promptJpsiRad->SetCheckBothChargesLegs(kTRUE,kTRUE);
766   promptJpsiRad->SetCheckBothChargesMothers(kTRUE,kTRUE);
767   promptJpsiRad->SetCheckBothChargesGrandMothers(kTRUE,kTRUE);
768   promptJpsiRad->SetJpsiRadiative(AliDielectronSignalMC::kIsRadiative);
769   die->AddSignalMC(promptJpsiRad);
770
771   // prompt J/psi Non radiative channel
772   AliDielectronSignalMC* promptJpsiNonRad = new AliDielectronSignalMC("promptJpsiNonRad","PromptNonRadiative");   // prompt J/psi (not from beauty decays)
773   promptJpsiNonRad->SetLegPDGs(11,-11);
774   promptJpsiNonRad->SetMotherPDGs(443,443);
775   promptJpsiNonRad->SetGrandMotherPDGs(503,503,kTRUE,kTRUE);   // not from beauty hadrons
776   promptJpsiNonRad->SetMothersRelation(AliDielectronSignalMC::kSame);
777   promptJpsiNonRad->SetFillPureMCStep(kTRUE);
778   promptJpsiNonRad->SetLegSources(AliDielectronSignalMC::kFinalState, AliDielectronSignalMC::kFinalState);
779   promptJpsiNonRad->SetCheckBothChargesLegs(kTRUE,kTRUE);
780   promptJpsiNonRad->SetCheckBothChargesMothers(kTRUE,kTRUE);
781   promptJpsiNonRad->SetCheckBothChargesGrandMothers(kTRUE,kTRUE);
782   promptJpsiNonRad->SetJpsiRadiative(AliDielectronSignalMC::kIsNotRadiative);
783   die->AddSignalMC(promptJpsiNonRad);
784
785   AliDielectronSignalMC* directJpsi = new AliDielectronSignalMC("directJpsi","Direct");   // embedded J/psi
786   directJpsi->SetLegPDGs(11,-11);
787   directJpsi->SetMotherPDGs(443,443);
788   directJpsi->SetMothersRelation(AliDielectronSignalMC::kSame);
789   directJpsi->SetFillPureMCStep(kTRUE);
790   directJpsi->SetLegSources(AliDielectronSignalMC::kFinalState, AliDielectronSignalMC::kFinalState);
791   directJpsi->SetMotherSources(AliDielectronSignalMC::kDirect, AliDielectronSignalMC::kDirect);
792   directJpsi->SetCheckBothChargesLegs(kTRUE,kTRUE);
793   directJpsi->SetCheckBothChargesMothers(kTRUE,kTRUE);
794   die->AddSignalMC(directJpsi);
795
796   AliDielectronSignalMC* gammaConversion = new AliDielectronSignalMC("gammaConversion","gamma conversions");
797   gammaConversion->SetLegPDGs(11,-11);
798   gammaConversion->SetCheckBothChargesLegs(kTRUE,kTRUE);
799   gammaConversion->SetLegSources(AliDielectronSignalMC::kSecondary, AliDielectronSignalMC::kSecondary);
800   gammaConversion->SetMotherPDGs(22,22);
801   gammaConversion->SetMothersRelation(AliDielectronSignalMC::kSame);
802   //  die->AddSignalMC(gammaConversion);
803
804 }
805
806 void SetEtaCorrection()
807 {
808   if (AliDielectronPID::GetEtaCorrFunction()) return;
809   
810   TString etaMap="$TRAIN_ROOT/jpsi_JPSI/EtaCorrMaps.root";
811   TString trainRoot=gSystem->Getenv("TRAIN_ROOT");
812   if (trainRoot.IsNull()) etaMap="$ALICE_ROOT/PWGDQ/dielectron/files/EtaCorrMaps.root";
813   if (gSystem->AccessPathName(gSystem->ExpandPathName(etaMap.Data()))){
814     Error("ConfigPbPb","Eta map not found: %s",etaMap.Data());
815     return;
816   }
817
818   TFile f(etaMap.Data());
819   if (!f.IsOpen()) return;
820   TList *keys=f.GetListOfKeys();
821
822   for (Int_t i=0; i<keys->GetEntries(); ++i){
823     TString kName=keys->At(i)->GetName();
824     TPRegexp reg(kName);
825     if (reg.MatchB(list)){
826       printf(" Using Eta Correction Function: %s\n",kName.Data());
827       AliDielectronPID::SetEtaCorrFunction((TF1*)f.Get(kName.Data()));
828     }
829   }
830 }
831
832 TVectorD *GetRunNumbers() {
833   
834   Double_t runLHC10h[] = { // all good runs based on RCT 29.Mai
835     139510, 139507, 139505, 139503, 139465, 139438, 139437, 139360, 139329, 139328, 139314, 139310, 139309, 139173, 139107, 139105, 139038, 139037, 139036, 139029, 139028, 138872, 138871, 138870, 138837, 138732, 138730, 138666, 138662, 138653, 138652, 138638, 138624, 138621, 138583, 138582, 138579, 138578, 138534, 138469, 138442, 138439, 138438, 138396, 138364, 138275, 138225, 138201, 138197, 138192, 138190, 137848, 137844, 137752, 137751, 137724, 137722, 137718, 137704, 137693, 137692, 137691, 137686, 137685, 137639, 137638, 137608, 137595, 137549, 137546, 137544, 137541, 137539, 137531, 137530, 137443, 137441, 137440, 137439, 137434, 137432, 137431, 137430, 137366, 137243, 137236, 137235, 137232, 137231, 137230, 137162, 137161, 137135
836   };
837   
838   Double_t runLHC11h[] = { // all good runs based on RCT 29.Mai
839     170593, 170572, 170388, 170387, 170315, 170313, 170312, 170311, 170309, 170308, 170306, 170270, 170269, 170268, 170230, 170228, 170207, 170204, 170203, 170193, 170163, 170159, 170155, 170091, 170089, 170088, 170085, 170084, 170083, 170081, 170040, 170027, 169965, 169923, 169859, 169858, 169855, 169846, 169838, 169837, 169835, 169591, 169590, 169588, 169587, 169586, 169557, 169555, 169554, 169553, 169550, 169515, 169512, 169506, 169504, 169498, 169475, 169420, 169419, 169418, 169417, 169415, 169411, 169238, 169167, 169160, 169156, 169148, 169145, 169144, 169138, 169099, 169094, 169091, 169045, 169044, 169040, 169035, 168992, 168988, 168826, 168777, 168514, 168512, 168511, 168467, 168464, 168460, 168458, 168362, 168361, 168342, 168341, 168325, 168322, 168311, 168310, 168115, 168108, 168107, 168105, 168076, 168069, 167988, 167987, 167985, 167920, 167915
840   };
841   
842   // selection via environement variable (works only for gsi trains)
843
844   
845   if(list.Contains("LHC10h") || list.Contains("LHC11a10")) {
846     Int_t size = (int) (sizeof(runLHC10h)/sizeof(Double_t));
847     TVectorD *vec = new TVectorD(size+1);
848     
849     (*vec)[size] = runLHC10h[0] + 1;
850     for (int i = 0; i < size; i++) {
851       (*vec)[i] = runLHC10h[size-1-i];
852     }
853     //    vec->Print("");
854     return vec;
855   }
856
857   if( list.Contains("LHC11h") || list.Contains("LHC12a17") ) {
858     
859     Int_t size = (int) (sizeof(runLHC11h)/sizeof(Double_t));
860     TVectorD *vec = new TVectorD(size+1);
861     
862     (*vec)[size] = runLHC11h[0] + 1;
863     for (int i = 0; i < size; i++) {
864       (*vec)[i] = runLHC11h[size-1-i];
865     }
866     //   vec->Print("");
867     return vec;
868   }
869
870   TVectorD *vec = new TVectorD(2);
871   (*vec)[0] = 0;
872   (*vec)[1] = 1;
873   return vec;
874      
875 }
876
877 TVectorD *GetDeltaPhiBins() {
878   //
879   // for in and out of event plane bins
880   //
881   Double_t pi = TMath::Pi();
882   TVectorD *deltaPhi = new TVectorD(6);
883   (*deltaPhi)[0] = -1.    *pi;
884   (*deltaPhi)[1] = -3./4. *pi;
885   (*deltaPhi)[2] = -1./4. *pi;
886   (*deltaPhi)[3] = +1./4. *pi;
887   (*deltaPhi)[4] = +3./4. *pi;
888   (*deltaPhi)[5] = +1.    *pi;
889   return deltaPhi;
890 }