- updates for AN67
[u/mrichter/AliRoot.git] / PWGDQ / dielectron / macrosJPSI / ConfigJpsiQA_jb_PbPb.C
1 void InitHistograms(AliDielectron *die, Int_t cutDefinition);
2 void InitCF(AliDielectron* die, Int_t cutDefinition);
3
4 void SetupTrackCuts(AliDielectron *die, Int_t cutDefinition);
5 void SetupElectronCuts(AliDielectron *die, Int_t cutDefinition);
6
7 TVectorD *GetRunNumbers();
8 TVectorD *BinsToVector(Int_t nbins, Double_t min, Double_t max);
9
10 TString names=("CutStats;noPID;TPC;TOF;TRD;TOFTRD;TOFTRD2D;TRDeff;e_mcPid;jpsi_mcPid;conv_mcPid");
11 enum {kCutStats=0, knoPID, kTPC, kTOF, kTRD, kTOFTRD, kTOFTRD2D, kTRDeff, kEleMC, kEleJPsiMC, kEleConvMC};
12 TObjArray *arrNames=names.Tokenize(";");
13
14 const Int_t nDie=arrNames->GetEntries();
15
16 Bool_t  isESD = kTRUE;
17 Bool_t  hasMC = kFALSE;
18 TString list  = gSystem->Getenv("LIST");
19
20 AliDielectron* ConfigJpsiQA_jb_PbPb(Int_t cutDefinition, TString prod="")
21 {
22   //
23   // Setup the instance of AliDielectron
24   //
25
26   // find mc or not?
27   if( list.IsNull()) list=prod;
28   if( list.Contains("LHC10h")   || list.Contains("LHC11h")   ) hasMC=kFALSE;
29   if( list.Contains("LHC11a10") || list.Contains("LHC12a17") ) hasMC=kTRUE;
30
31   //ESD handler?
32   isESD=(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()->IsA()==AliESDInputHandler::Class());
33
34   // switch off some configurations
35   if(hasMC) { // MONTE CARLO
36     switch(cutDefinition) {
37     case kCutStats:  return 0x0;
38     case knoPID:     return 0x0;
39     case kTPC:       return 0x0;
40     case kTOF:       return 0x0;
41     case kTRD:       return 0x0;
42     case kTOFTRD:    return 0x0;
43     case kTOFTRD2D:  return 0x0;
44     case kTRDeff:    return 0x0;
45     case kEleMC:     return 0x0;
46     case kEleJPsiMC: return 0x0;
47     case kEleConvMC: return 0x0;
48     }
49   } else { // COLLISION DATA
50     switch(cutDefinition) {
51       //            case kCutStats:  return 0x0;
52       //            case knoPID:     return 0x0;
53       //            case kTPC:       return 0x0;
54       //            case kTOF:       return 0x0;
55       //            case kTRD:       return 0x0;
56       //            case kTOFTRD:    return 0x0;
57       //            case kTOFTRD2D:  return 0x0;
58     case kTRDeff:    return 0x0;
59     case kEleMC:     return 0x0;
60     case kEleJPsiMC: return 0x0;
61     case kEleConvMC: return 0x0;
62     }
63   }
64
65   // create the actual framework object
66   TString name=Form("%02d",cutDefinition);
67   if (cutDefinition<arrNames->GetEntriesFast()){
68     name=arrNames->At(cutDefinition)->GetName();
69   }
70   AliDielectron *die = new AliDielectron(Form("%s",name.Data()),Form("Track cuts: %s",name.Data()));
71   die->SetHasMC(hasMC);
72
73   printf(" Add %s %s config %s for %s \n",(isESD?"ESD":"AOD"),(hasMC?"MC":""),name.Data(),list.Data());
74
75   //only track QA, no Pairing
76   if(cutDefinition<kTRDeff) {
77     die->SetNoPairing();
78     printf(" Set no pairing \n");
79   }
80   
81   // cut setup
82   if(cutDefinition!=kTRDeff) SetupTrackCuts(die,cutDefinition);
83   if(cutDefinition==kTRDeff) SetupElectronCuts(die,cutDefinition);
84   
85   // histogram setup
86   InitHistograms(die,cutDefinition);
87   //  printf(" Add %d types and %03d histos to the manager \n",die->GetHistogramList()->GetEntries(),
88   //     die->GetHistoManager()->GetList()->GetEntries());
89   
90   // CF container setup
91   if(cutDefinition == kTRDeff ) {
92     InitCF(die,cutDefinition);
93     printf(" Add %d pair, %d leg vars, %p steps and %p bins to the container \n",
94            die->GetCFManagerPair()->GetNvarsPair(),die->GetCFManagerPair()->GetNvarsLeg(),
95            die->GetCFManagerPair()->GetContainer(), die->GetCFManagerPair()->GetContainer() );
96   }
97
98   
99   return die;
100 }
101 //______________________________________________________________________________________
102 void SetupElectronCuts(AliDielectron *die, Int_t cutDefinition)
103 {
104   // Quality cuts
105   AliDielectronCutGroup* cuts = new AliDielectronCutGroup("cuts","cuts",AliDielectronCutGroup::kCompAND);
106   die->GetTrackFilter().AddCuts(cuts);
107   
108   // track cuts ESD and AOD
109   AliDielectronVarCuts *varCuts = new AliDielectronVarCuts("VarCuts","VarCuts");
110   varCuts->AddCut(AliDielectronVarManager::kEta,         -0.9,   0.9);
111   varCuts->AddCut(AliDielectronVarManager::kP,             .75,  1e30);
112   varCuts->AddCut(AliDielectronVarManager::kTRDpidQuality,1.0,   6.0);
113   if(!isESD) varCuts->AddCut(AliDielectronVarManager::kV0Index0,     1.0);
114   //  varCuts->AddCut(AliDielectronVarManager::kTPCchi2Cl,    0.0,   4.0);
115   //  varCuts->AddCut(AliDielectronVarManager::kNclsTPC,     60.0, 160.0);
116   //  varCuts->AddCut(AliDielectronVarManager::kKinkIndex0,   0.0);
117   //  varCuts->AddCut(AliDielectronVarManager::kPt,           0.8,  1e30);
118   cuts->AddCut(varCuts);
119   
120   AliDielectronTrackCuts *trkCuts = new AliDielectronTrackCuts("TrkCuts","TrkCuts");
121   trkCuts->SetRequireTPCRefit(kTRUE);
122   cuts->AddCut(trkCuts);
123   
124   // PID
125   AliDielectronPID *pid = new AliDielectronPID("PID","PID cut");
126   pid->AddCut(AliDielectronPID::kTPC,AliPID::kElectron,-5.0, 3.5, 0.0, 0.0,  kFALSE, AliDielectronPID::kRequire); 
127   cuts->AddCut(pid);
128   
129   // Pair inclusion
130   AliDielectronVarCuts *gammaCuts = new AliDielectronVarCuts("GammaCuts","GammaCuts");
131   gammaCuts->AddCut(AliDielectronVarManager::kOpeningAngle, 0.0,   0.035); // 0.1
132   //  gammaCuts->AddCut(AliDielectronVarManager::kCosPointingAngle, TMath::Cos(0.02),   1.0);
133   //  gammaCuts->AddCut(AliDielectronVarManager::kLegDist,      0.0,   0.25);
134   //  gammaCuts->AddCut(AliDielectronVarManager::kR,            3.0,   90.0);
135   //  gammaCuts->AddCut(AliDielectronVarManager::kPsiPair,      0.0,   0.05);
136   //  gammaCuts->AddCut(AliDielectronVarManager::kChi2NDF,      0.0,   10.0);
137   gammaCuts->AddCut(AliDielectronVarManager::kM,            0.0,   0.05);
138   die->GetPairFilter().AddCuts(gammaCuts);
139
140   // Pair exclusion
141   //  AliDielectronVarCuts *lambdaCuts = new AliDielectronVarCuts("LambdaCuts","LambdaCuts");
142   //  lambdaCuts->AddCut(AliDielectronVarManager::kOpeningAngle, 0.0,   0.035, kTRUE); // 0.035
143   //  lambdaCuts->AddCut(AliDielectronVarManager::kR,            3.0,   40.0, kTRUE);
144   //  lambdaCuts->AddCut(AliDielectronVarManager::kChi2NDF,      0.0,   0.5,  kTRUE);
145   //  lambdaCuts->AddCut(AliDielectronVarManager::kM,            1.01,  1.03, kTRUE);
146   //  lambdaCuts->AddCut(AliDielectronVarManager::kY,            -0.9,  0.9,  kTRUE);
147   //  die->GetPairFilter().AddCuts(lambdaCuts);
148   //
149   //  AliDielectronVarCuts *k0sCuts = new AliDielectronVarCuts("K0sCuts","K0sCuts");
150   //  k0sCuts->AddCut(AliDielectronVarManager::kR,            3.0,   40.0,  kTRUE);
151   //  k0sCuts->AddCut(AliDielectronVarManager::kChi2NDF,      0.0,   0.5,   kTRUE);
152   //  k0sCuts->AddCut(AliDielectronVarManager::kM,            4.90,  0.504, kTRUE);
153   //  k0sCuts->AddCut(AliDielectronVarManager::kY,            -0.9,  0.9,   kTRUE);
154   //  die->GetPairFilter().AddCuts(k0sCuts);
155   
156   
157 }
158 //______________________________________________________________________________________
159 void SetupTrackCuts(AliDielectron *die, Int_t cutDefinition)
160 {
161   //
162   // Setup the track cuts
163   //
164
165   // Quality cuts
166   AliDielectronCutGroup* cuts = new AliDielectronCutGroup("cuts","cuts",AliDielectronCutGroup::kCompAND);
167   die->GetTrackFilter().AddCuts(cuts);
168
169   // AOD track filter (needs to be first cut)
170   AliDielectronTrackCuts *trkFilter = new AliDielectronTrackCuts("TrkFilter","TrkFilter");
171   trkFilter->SetAODFilterBit(AliDielectronTrackCuts::kTPCqualSPDanyPIDele);
172   //  if(!isESD) cuts->AddCut(trkFilter);
173
174   //Pt cut, should make execution a bit faster
175   AliDielectronVarCuts *pt = new AliDielectronVarCuts("Pt>.8","Pt>.8");
176   if(cutDefinition<kEleMC) 
177     pt->AddCut(AliDielectronVarManager::kPt,0.8,1e30);
178   else   
179     pt->AddCut(AliDielectronVarManager::kPt,0.8,1e30);
180   if(cutDefinition!=kCutStats && cutDefinition!=knoPID) cuts->AddCut(pt);
181   
182   // track cuts ESD and AOD
183   AliDielectronVarCuts *varCuts = new AliDielectronVarCuts("VarCuts","VarCuts");
184   varCuts->AddCut(AliDielectronVarManager::kImpactParXY, -1.0,   1.0);
185   varCuts->AddCut(AliDielectronVarManager::kImpactParZ,  -3.0,   3.0);
186   varCuts->AddCut(AliDielectronVarManager::kEta,         -0.9,   0.9);
187   varCuts->AddCut(AliDielectronVarManager::kTPCchi2Cl,    0.0,   4.0);
188   varCuts->AddCut(AliDielectronVarManager::kNclsTPC,     70.0, 160.0);
189   varCuts->AddCut(AliDielectronVarManager::kKinkIndex0,   0.0);
190   //varCuts->AddCut(AliDielectronVarManager::kTOFbeta,      0.2,   0.9, kTRUE);
191   //if(!isESD) varCuts->AddCut(AliDielectronVarManager::kV0Index0,   0.0);
192   if(cutDefinition!=kCutStats) cuts->AddCut(varCuts);
193   
194   AliDielectronTrackCuts *trkCuts = new AliDielectronTrackCuts("TrkCuts","TrkCuts");
195   //  trkCuts->SetClusterRequirementITS(AliDielectronTrackCuts::kSPD,AliDielectronTrackCuts::kAny);
196   trkCuts->SetITSclusterCut(AliDielectronTrackCuts::kOneOf, 15); // ITS-4 = 1+2+4+8
197   trkCuts->SetRequireITSRefit(kTRUE);
198   trkCuts->SetRequireTPCRefit(kTRUE);
199   if(cutDefinition!=kCutStats) cuts->AddCut(trkCuts);
200   
201   /* vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv PID CUTS vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv */
202   AliDielectronPID *pid = new AliDielectronPID("PID","PID");
203   
204   ////////////////////////////////// DATA
205   if(!hasMC && cutDefinition==kTPC) {
206     pid->AddCut(AliDielectronPID::kTPC,AliPID::kPion,-100.,4.0,0.,0.,kTRUE);
207     pid->AddCut(AliDielectronPID::kTPC,AliPID::kProton,-100.,3.5,0.,0.,kTRUE);
208   }
209   
210   ////////////////////////////////// MC
211   if(hasMC) {
212     if (cutDefinition>=kEleMC) {
213       AliDielectronVarCuts *pdgCuts=new AliDielectronVarCuts("pdgCuts","pdgCuts");
214       pdgCuts->SetCutType(AliDielectronVarCuts::kAny);
215       pdgCuts->AddCut(AliDielectronVarManager::kPdgCode,11.);
216       pdgCuts->AddCut(AliDielectronVarManager::kPdgCode,-11.);
217       cuts->AddCut(pdgCuts);
218       
219       AliDielectronVarCuts *pdgMotherCutsT=new AliDielectronVarCuts("pdgMotherCutsT","pdgMotherCutsT");
220       AliDielectronVarCuts *pdgMotherCutsP=new AliDielectronVarCuts("pdgMotherCutsP","pdgMotherCutsP");
221       if (cutDefinition==kEleJPsiMC){
222         //        pdgMotherCutsT->AddCut(AliDielectronVarManager::kPdgCodeMother,443.);
223         //        cuts->AddCut(pdgMotherCutsT);        
224         pdgMotherCutsP->AddCut(AliDielectronVarManager::kPdgCode,443.);
225         pdgMotherCutsP->AddCut(AliDielectronVarManager::kHaveSameMother,1.);
226         die->GetPairFilter().AddCuts(pdgMotherCutsP);
227       }
228       if (cutDefinition==kEleConvMC){
229         pdgMotherCutsT->AddCut(AliDielectronVarManager::kPdgCodeMother,22.);
230         cuts->AddCut(pdgMotherCutsT);        
231         
232         pdgMotherCutsP->AddCut(AliDielectronVarManager::kHaveSameMother,1.);
233         die->GetPairFilter().AddCuts(pdgMotherCutsP);
234       }
235       
236     }
237   }
238   ////////////////////////////////// DATA + MC
239   // pid cuts TPC + TOF & TRD
240   pid->AddCut(AliDielectronPID::kTPC,AliPID::kElectron,-4.,4.);
241
242   if(cutDefinition==kTOF || cutDefinition==kTOFTRD || cutDefinition==kTOFTRD2D)
243     pid->AddCut(AliDielectronPID::kTOF,AliPID::kElectron,-3,3.,0.,0.,kFALSE,AliDielectronPID::kIfAvailable);
244
245   if(cutDefinition==kTRD || cutDefinition==kTOFTRD)
246     pid->AddCut(AliDielectronPID::kTRDeleEff,AliPID::kElectron,.8,1.,3.5.,6.,kFALSE,
247                 AliDielectronPID::kIfAvailable,AliDielectronVarManager::kTRDpidQuality);
248
249   if(cutDefinition==kTOFTRD2D)
250     pid->AddCut(AliDielectronPID::kTRDeleEff2D,AliPID::kElectron,.8,1.,3.5.,6.,kFALSE,
251                 AliDielectronPID::kIfAvailable,AliDielectronVarManager::kTRDpidQuality);
252
253   if(cutDefinition!=knoPID && cutDefinition!=kCutStats && cutDefinition!=kTRDeff && !hasMC ) cuts->AddCut(pid);
254   /* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PID CUTS ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
255
256   // exclude conversion electrons selected by the tender
257   AliDielectronTrackCuts *noconv=new AliDielectronTrackCuts("noConv","noConv");
258   noconv->SetV0DaughterCut(AliPID::kElectron,kTRUE);
259   cuts->AddCut(noconv);
260   
261 }
262
263 //______________________________________________________________________________________
264 void InitHistograms(AliDielectron *die, Int_t cutDefinition)
265 {
266   //
267   // Initialise the histograms
268   //
269   
270   //Setup histogram Manager
271   AliDielectronHistos *histos=new AliDielectronHistos(die->GetName(), die->GetTitle());
272   
273   //Initialise histogram classes
274   histos->SetReservedWords("Track;Pair");
275
276   // booleans for histo selection
277   Bool_t bHistEvts = kFALSE, bHistPair = kFALSE, bHistCuts = kFALSE, bHistPID = kFALSE, bHistEff=kFALSE, bHistRunQA=kFALSE;
278   switch (cutDefinition) {
279   case kCutStats:  bHistCuts=kTRUE; break;
280   case knoPID:     bHistEvts=kTRUE; bHistPID=kTRUE; bHistRunQA=kTRUE; break;
281   case kTPC:
282   case kTOF:
283   case kTRD:
284   case kTOFTRD:
285   case kTOFTRD2D:  bHistPID=kTRUE; break;
286   case kTRDeff:    bHistEff=kTRUE; break;
287   case kEleMC:
288   case kEleJPsiMC:
289   case kEleConvMC:
290     bHistPair=kTRUE; break;
291   }
292
293   //Track classes
294   //to fill also track info from 2nd event loop until 2
295   for (Int_t i=0; i<2; ++i){
296     histos->AddClass(Form("Track_%s",AliDielectron::TrackClassName(i)));
297   }
298
299   //add histograms to event class
300   if (bHistEvts) {
301     histos->AddClass("Event");
302     histos->UserHistogram("Event","RunNumber",";run;#events",GetRunNumbers(),AliDielectronVarManager::kRunNumber);
303     histos->UserHistogram("Event","VtxZ",";z_{vtx} (cm)",300,-15.,15.,AliDielectronVarManager::kZvPrim);
304     if(hasMC) {
305       histos->AddClass("MCEvent");
306       histos->UserHistogram("MCEvent","NumberOfJPsis",";N_{J/#psi};#events",20,0.,20.,AliDielectronVarManager::kNumberOfJPsis);
307     }
308   }
309
310   if (bHistRunQA) {
311     if(!hasMC) {
312     // Flow QA
313     histos->UserHistogram("Event","TPCrpH2uc_RunNumber",";run;#Psi^{TPC} (rad.)",
314                           GetRunNumbers(), BinsToVector(100,-2.,2.) ,
315                           AliDielectronVarManager::kRunNumber, AliDielectronVarManager::kTPCrpH2uc);
316     histos->UserHistogram("Event","vOArpH2_RunNumber",";run;#Psi_{2}^{V0A} (rad.)",
317                           GetRunNumbers(), BinsToVector(100,-2.,2.) ,
318                           AliDielectronVarManager::kRunNumber, AliDielectronVarManager::kv0ArpH2);
319     histos->UserHistogram("Event","vOCrpH2_RunNumber",";run;#Psi_{2}^{V0C} (rad.)",
320                           GetRunNumbers(), BinsToVector(100,-2.,2.) ,
321                           AliDielectronVarManager::kRunNumber, AliDielectronVarManager::kv0CrpH2);
322
323     histos->UserHistogram("Event","TPCrpH2uc_Cent_RunNumber",";centrality (%);#Psi^{TPC} (rad.);run",
324                           BinsToVector(10,0.,100.), BinsToVector(100,-2.,2.), GetRunNumbers(),
325                           AliDielectronVarManager::kCentrality,
326                           AliDielectronVarManager::kTPCrpH2uc,
327                           AliDielectronVarManager::kRunNumber );
328     histos->UserHistogram("Event","vOArpH2_Cent_RunNumber",";centrality (%);#Psi_{2}^{V0A} (rad.);run",
329                           BinsToVector(10,0.,100.), BinsToVector(100,-2.,2.), GetRunNumbers(),
330                           AliDielectronVarManager::kCentrality,
331                           AliDielectronVarManager::kv0ArpH2,
332                           AliDielectronVarManager::kRunNumber );
333     histos->UserHistogram("Event","vOCrpH2_Cent_RunNumber",";centrality (%);#Psi_{2}^{V0C} (rad.);run",
334                           BinsToVector(10,0.,100.), BinsToVector(100,-2.,2.), GetRunNumbers(),
335                           AliDielectronVarManager::kCentrality,
336                           AliDielectronVarManager::kv0CrpH2,
337                           AliDielectronVarManager::kRunNumber );
338     }
339
340     // PID QA
341     histos->UserHistogram("Track","TPCnSigmaPio_Nacc_RunNumber",";N_{acc};run;n#sigma_{pio}^{TPC}",
342                           BinsToVector(60,0.,3000.), GetRunNumbers(), BinsToVector(40,-5.,5.),
343                           AliDielectronVarManager::kNacc,
344                           AliDielectronVarManager::kRunNumber,
345                           AliDielectronVarManager::kTPCnSigmaPio);
346     histos->UserHistogram("Track","TPCnSigmaPio_Nacc",";N_{acc};n#sigma_{pio}^{TPC}",
347                           BinsToVector(60,0.,3000.), BinsToVector(40,-5.,5.),
348                           AliDielectronVarManager::kNacc,
349                           AliDielectronVarManager::kTPCnSigmaPio);
350
351     histos->UserProfile("Track","TPCnSigmaPio-Nacc-RunNumber",";N_{acc};run;n#sigma_{pio}^{TPC}",
352                         AliDielectronVarManager::kTPCnSigmaPio,
353                         BinsToVector(60,0.,3000.),      GetRunNumbers(),
354                         AliDielectronVarManager::kNacc, AliDielectronVarManager::kRunNumber, "s;-5;5" );
355     histos->UserProfile("Track","TPCnSigmaPio-RunNumber",";run;n#sigma_{pio}^{TPC}",
356                         AliDielectronVarManager::kTPCnSigmaPio,
357                         GetRunNumbers(), AliDielectronVarManager::kRunNumber, "s;-5;5");
358     histos->UserProfile("Track","TPCnSigmaPio-Nacc",";N_{acc};n#sigma_{pio}^{TPC}",
359                         AliDielectronVarManager::kTPCnSigmaPio,
360                         BinsToVector(60,0.,3000.), AliDielectronVarManager::kNacc , "s;-5;5");
361
362     histos->UserHistogram("Track","dEdx_RunNumber",";run;TPC signal (arb units)",
363                           GetRunNumbers(), BinsToVector(200,0.,200.),
364                           AliDielectronVarManager::kRunNumber,
365                           AliDielectronVarManager::kTPCsignal);
366     histos->UserHistogram("Track","TPCnSigmaEle_RunNumber",";run;TPC signal (arb units)",
367                           GetRunNumbers(), BinsToVector(100,-5.,5.),
368                           AliDielectronVarManager::kRunNumber,
369                           AliDielectronVarManager::kTPCnSigmaEle);
370     histos->UserHistogram("Track","dEdx_Eta",";#eta;TPC signal (arb units)",
371                           100,-1.,1.,200,0.,200.,AliDielectronVarManager::kEta,AliDielectronVarManager::kTPCsignal,kTRUE);
372     histos->UserHistogram("Track","dEdx_Phi",";#phi;TPC signal (arb units)",
373                           180,0.,6.285,200,0.,200.,AliDielectronVarManager::kPhi,AliDielectronVarManager::kTPCsignal,kTRUE);
374   } // end PID+Flow QA
375
376   if (bHistPID) {
377       histos->UserHistogram("Track","dEdx_P_Cent",";p (GeV/c);TPC signal (arb units);centrality (%)",
378                             400,0.2,20., 200,0.,200., 10,0.,100.,
379                             AliDielectronVarManager::kPIn,
380                             AliDielectronVarManager::kTPCsignal,
381                             AliDielectronVarManager::kCentrality, 
382                             kTRUE);
383
384       histos->UserHistogram("Track","TPCnSigmaEle_P_Cent",";p (GeV/c);n#sigma_{ele}^{TPC};centrality (%)",
385                             100,0.2,20., 100,-10.,10., 10,0.,100.,
386                             AliDielectronVarManager::kPIn,
387                             AliDielectronVarManager::kTPCnSigmaEle,
388                             AliDielectronVarManager::kCentrality, 
389                             kTRUE);
390
391       histos->UserHistogram("Track","TPCnSigmaPio_P_Cent",";p (GeV/c);n#sigma_{pio}^{TPC};centrality (%)",
392                             100,0.2,20., 100,-10.,10., 10,0.,100.,
393                             AliDielectronVarManager::kPIn,
394                             AliDielectronVarManager::kTPCnSigmaPio,
395                             AliDielectronVarManager::kCentrality, 
396                             kTRUE);
397
398       histos->UserHistogram("Track","TPCnSigmaPro_P_Cent",";p (GeV/c);n#sigma_{pro}^{TPC};centrality (%)",
399                             100,0.2,20., 100,-10.,10., 10,0.,100.,
400                             AliDielectronVarManager::kPIn,
401                             AliDielectronVarManager::kTPCnSigmaPro,
402                             AliDielectronVarManager::kCentrality, 
403                             kTRUE);
404
405       histos->UserHistogram("Track","TOFbeta_P_Cent",";p (GeV/c);#beta;centrality (%);#tracks",
406                             250,0.0,5., 300,0.,1.2, 10,0.,100.,
407                             AliDielectronVarManager::kPIn,
408                             AliDielectronVarManager::kTOFbeta,
409                             AliDielectronVarManager::kCentrality);
410
411       histos->UserHistogram("Track","TOFnSigmaEle_P_Cent","dEdxTOF;p (GeV/c);n#sigma_{ele}^{TOF};centrality (%);#tracks",
412                             250,0.0,5., 100,-10.,10., 10,0.,100.,
413                             AliDielectronVarManager::kPIn,
414                             AliDielectronVarManager::kTOFnSigmaEle,
415                             AliDielectronVarManager::kCentrality);
416
417       // main pid spectra
418       histos->UserHistogram("Track","dEdx_P",";p (GeV/c);TPC signal (arb units);#tracks",
419                             400,0.2,20.,200,0.,200.,AliDielectronVarManager::kPIn,AliDielectronVarManager::kTPCsignal,kTRUE);
420       histos->UserHistogram("Track","TPCnSigmaEle_P",";p (GeV/c);n#sigma_{ele}^{TPC}",
421                             100,0.2,20.,100,-10.,10.,AliDielectronVarManager::kPIn,AliDielectronVarManager::kTPCnSigmaEle,kTRUE);
422       histos->UserHistogram("Track","TPCnSigmaPio_P",";p (GeV/c);n#sigma_{pio}^{TPC}",
423                             100,0.2,20.,100,-10.,10.,AliDielectronVarManager::kPIn,AliDielectronVarManager::kTPCnSigmaPio,kTRUE);
424       histos->UserHistogram("Track","TPCnSigmaPro_P",";p (GeV/c);n#sigma_{pro}^{TPC}",
425                           100,0.2,20.,100,-10.,10.,AliDielectronVarManager::kPIn,AliDielectronVarManager::kTPCnSigmaPro,kTRUE);
426       histos->UserHistogram("Track","dEdx_NclsTPC",";N_{cls}^{TPC};TPC signal (arb units);#tracks",
427                             160,0.,160.,200,0.,200.,AliDielectronVarManager::kNclsTPC,AliDielectronVarManager::kTPCsignal);
428
429       histos->UserHistogram("Track","TOFbeta_P",";p (GeV/c);#beta;#tracks",
430                             250,0.0,5.0,300,0.,1.2,AliDielectronVarManager::kPIn,AliDielectronVarManager::kTOFbeta);
431       histos->UserHistogram("Track","TOFnSigmaEle_P",";p (GeV/c);n#sigma_{ele}^{TOF}",
432                             100,0.2,20.,50,-10.,10.,AliDielectronVarManager::kP,AliDielectronVarManager::kTOFnSigmaEle,kTRUE);
433   } // end PID hists
434
435   if (bHistPair) {
436     //Pair classes
437     for (Int_t i=1; i<=1; ++i){ // only +- pairs
438       histos->AddClass(Form("Pair_%s",AliDielectron::PairClassName(i)));
439     }
440     //add histograms to Pair classes
441     histos->UserHistogram("Pair","InvMass",";m_{ee} (GeV/c^{2});#pairs",
442                           100,.0,100*0.005, AliDielectronVarManager::kM); // 5MeV bins, 0.5GeV/c2
443     histos->UserHistogram("Pair","OpeningAngle",";angle (rad.)",
444                           100,0.,3.15, AliDielectronVarManager::kOpeningAngle);
445     histos->UserHistogram("Pair","CosPointingAngle",";|cos(#theta)|",
446                           110,0.0,1.1, AliDielectronVarManager::kCosPointingAngle);
447     histos->UserHistogram("Pair","Chi2NDF",";#chi^{2}/NDF",
448                           100,0.,20, AliDielectronVarManager::kChi2NDF);
449     histos->UserHistogram("Pair","PsiPair","PsiPair;#psi",
450                           100,0.,3.15, AliDielectronVarManager::kPsiPair);
451     histos->UserHistogram("Pair","R","Radius;r (cm)",
452                           200,0.,100., AliDielectronVarManager::kR);
453     histos->UserHistogram("Pair","LegDist",";dca (cm)",
454                           100,0.,1., AliDielectronVarManager::kLegDist);
455     histos->UserHistogram("Pair","LegDistXY",";dca_{xy} (cm)",
456                           100,0.,1., AliDielectronVarManager::kLegDistXY);
457     histos->UserHistogram("Pair","PdgCode",";mother PDG code;#tracks",
458                           10000,-5000.5,4999.5,AliDielectronVarManager::kPdgCode);
459
460     // ITS tracks
461     histos->UserHistogram("Track","NclsITS",";N_{cls}^{ITS};#tracks",
462                           "0,1,2,3,4,5,6,7",  AliDielectronVarManager::kNclsITS);
463     histos->UserHistogram("Track","ITSLayerFirstCls",";ITS layer first cls;#tracks",
464                           "-1,0,1,2,3,4,5,6", AliDielectronVarManager::kITSLayerFirstCls);
465   } // end pair hists
466
467   // TRD efficiency
468   if(bHistEff) {
469     for (Int_t i=1; i<=1; ++i){ // only +- pairs
470       //      histos->AddClass(Form("Pair_%s",AliDielectron::PairClassName(i)));
471       //legs from pair
472       histos->AddClass(Form("Track_Legs_%s",AliDielectron::PairClassName(i)));
473     }
474         
475     // purity
476     histos->UserHistogram("Track","TPCnSigmaEle",";n#sigma_{ele}^{TPC};#tracks",
477                           100,-10.,10.,AliDielectronVarManager::kTPCnSigmaEle);
478     // TRD
479     histos->UserHistogram("Track","TRDpidQuality",";N_{trkl}^{TRD};#tracks", 
480                           "0,1,2,3,4,5,6,7",    AliDielectronVarManager::kTRDpidQuality);
481     histos->UserHistogram("Track","TRDchi2",";#chi^{2}_{TRD};#tracks", 
482                           11,-1.,10.,    AliDielectronVarManager::kTRDchi2);
483     histos->UserHistogram("Track","TRDprobEle",";P_{ele}^{TRD};#tracks", 
484                           100,0.,1.,            AliDielectronVarManager::kTRDprobEle);
485     histos->UserHistogram("Track","TRDprobPio",";P_{pio}^{TRD};#tracks", 
486                           100,0.,1.,            AliDielectronVarManager::kTRDprobPio);
487
488     histos->UserHistogram("Track","TRDprobEle_TRDpidQuality",";N_{trkl}^{TRD};P_{ele}^{TRD}", 
489                           7,0.,7., 20,0.,1.,
490                           AliDielectronVarManager::kTRDpidQuality, AliDielectronVarManager::kTRDprobEle);
491     histos->UserHistogram("Track","TRDprobPio_TRDpidQuality",";N_{trkl}^{TRD};P_{pio}^{TRD}", 
492                           7,0.,7., 20,0.,1.,
493                           AliDielectronVarManager::kTRDpidQuality, AliDielectronVarManager::kTRDprobPio);
494     
495     histos->UserProfile("Track","TRDprobEle-TRDpidQuality",";N_{trkl}^{TRD};P_{ele}^{TRD}", 
496                         AliDielectronVarManager::kTRDprobEle,
497                         "0,1,2,3,4,5,6,7",    AliDielectronVarManager::kTRDpidQuality);
498     histos->UserProfile("Track","TRDprobPio-TRDpidQuality",";N_{trkl}^{TRD};P_{pio}^{TRD}", 
499                         AliDielectronVarManager::kTRDprobPio,
500                         "0,1,2,3,4,5,6,7",    AliDielectronVarManager::kTRDpidQuality);
501     // TPC track quality
502     histos->UserHistogram("Track","NclsTPC",";N_{cls}^{TPC};#tracks", 
503                           160,0.,160.,   AliDielectronVarManager::kNclsTPC);
504
505   } // end TRD eff
506   
507   if(0) {    
508     //histos->UserHistogram("Track","Pt",";p_{T} (GeV/c);#tracks",200,0,20.,AliDielectronVarManager::kPt);
509     //histos->UserHistogram("Track","Eta",";#eta;#tracks",100,-2.,2.,AliDielectronVarManager::kEta);
510     //histos->UserHistogram("Track","Phi",";#phi;#tracks",360,0.,6.285,AliDielectronVarManager::kPhi);  
511     if(isESD) {
512     histos->UserHistogram("Track","TRDchi2",";#chi^{2}_{TRD};#tracks",11,-1.,10.,    AliDielectronVarManager::kTRDchi2);
513     histos->UserHistogram("Track","TRDchi2_TRDpidQuality",";#chi^{2}_{TRD};N_{trkl}^{TRD};#tracks",
514                           11,-1.,10., 7,0.,7.,    AliDielectronVarManager::kTRDchi2, AliDielectronVarManager::kTRDpidQuality);
515     }
516     //    histos->UserHistogram("Track","V0Index0",";V0;#tracks",2,-0.5,1.5,AliDielectronVarManager::kV0Index0);
517     if(hasMC) {
518       histos->UserHistogram("Track","PdgCodeMother",";mother PDG code;#tracks",10000,-5000.5,4999.5,AliDielectronVarManager::kPdgCodeMother);
519       //    histos->UserHistogram("Track","PdgCode",";tracks PDG code;#tracks",10000,-5000.5,4999.5,AliDielectronVarManager::kPdgCode);
520     }
521   }
522   
523   //add histograms to get cut statistics
524   if (bHistCuts) {      
525     histos->UserHistogram("Track","Eta",";Eta;#tracks",
526                           "-5.,-0.9,-0.8,0.8,0.9,5.",          AliDielectronVarManager::kEta);
527     histos->UserHistogram("Track","Pt",";p_{T} (GeV/c);#tracks", 
528                           "0.0,0.8, 1.0, 1.2, 1.5, 100.0",    AliDielectronVarManager::kPt);
529     histos->UserHistogram("Track","ImpactParXY",";dXY (cm);#tracks",  
530                           500,-1.,1.,               AliDielectronVarManager::kImpactParXY);
531     histos->UserHistogram("Track","ImpactParZ",";dZ (cm);#tracks",        
532                           600,-3.,3.,               AliDielectronVarManager::kImpactParZ);
533     // ITS
534     histos->UserHistogram("Track","NclsITS",";N_{cls}^{ITS};#tracks", 
535                           "0,1,2,3,4,5,6,7",          AliDielectronVarManager::kNclsITS);
536     histos->UserHistogram("Track","ITSLayerFirstCls",";ITS layer first cls;#tracks", 
537                           "-1,0,1,2,3,4,5,6",          AliDielectronVarManager::kITSLayerFirstCls);
538     histos->UserHistogram("Track","NclsITS_ITSLayerFirstCls",";N_{cls}^{ITS};ITS layer first cls;#tracks", 
539                           7, 0., 7., 7, -1., 6.,
540                           AliDielectronVarManager::kNclsITS, AliDielectronVarManager::kITSLayerFirstCls);
541     // TPC
542     histos->UserHistogram("Track","NclsTPC",";N_{cls}^{TPC};#tracks", 
543                           "70, 90, 100, 120, 160",   AliDielectronVarManager::kNclsTPC);
544     histos->UserHistogram("Track","TPCchi2PerCluster",";#chi^{2}/N_{cls}^{TPC};#tracks", 
545                           10,0,10,AliDielectronVarManager::kTPCchi2Cl);
546     histos->UserHistogram("Track","TPC_nSigma_Electrons",";n#sigma_{ele}^{TPC};#tracks", 
547                           "-100,-4,-3,-2,-1.5,-1,1,1.5,2,3,4,100",AliDielectronVarManager::kTPCnSigmaEle);
548     histos->UserHistogram("Track","TPC_nSigma_Pions",";n#sigma_{pio}^{TPC};#tracks", 
549                           "-100,3.5,4.0,4.5,5.0,5.5,100",AliDielectronVarManager::kTPCnSigmaPio);
550     histos->UserHistogram("Track","TPC_nSigma_Protons",";n#sigma_{pro}^{TPC};#tracks", 
551                           "-100,3.5,4.0,4.5,5.0,5.5,100",AliDielectronVarManager::kTPCnSigmaPro);
552
553     histos->UserProfile("Track","NclsTPC-Eta-Phi",";#eta;#phi;N_{cls}^{TPC}",
554                         AliDielectronVarManager::kNclsTPC,
555                         BinsToVector(100,-2.,2.),      BinsToVector(360,0.,6.285),
556                         AliDielectronVarManager::kEta, AliDielectronVarManager::kPhi, "i;1;160");
557     // TRD
558     histos->UserHistogram("Track","TRDpidQuality",";N_{trkl}^{TRD};#tracks", 
559                           "0,1,2,3,4,5,6,7",            AliDielectronVarManager::kTRDpidQuality);
560     histos->UserHistogram("Track","TRDprobEle",";P_{ele}^{TRD};#tracks", 
561                           100,0.,1.,            AliDielectronVarManager::kTRDprobEle);
562     //    histos->UserHistogram("Track","TRD_PIDbit",";TRD pid bit;#tracks",
563     //                          "-.5,.5,1.5",              AliDielectronVarManager::kTRDPIDBit);
564     
565     // TOF
566     histos->UserHistogram("Track","TOF_PIDbit",";TOF pid bit;#tracks",
567                           "-.5,.5,1.5",              AliDielectronVarManager::kTOFPIDBit);
568     histos->UserHistogram("Track","TOF_nSigma_Electrons",";n#sigma_{ele}^{TOF};#tracks", 
569                           "-100,-3,-2,2,3,100",AliDielectronVarManager::kTOFnSigmaEle);
570   } // end cut hists
571   
572   
573   // track histos
574   //  histos->UserHistogram("Track","Pt",";p_{T} (GeV/c);#tracks",200,0,20.,AliDielectronVarManager::kPt);
575   //  histos->UserHistogram("Track","Eta",";#eta;#tracks",100,-2.,2.,AliDielectronVarManager::kEta);
576   //  histos->UserHistogram("Track","Phi",";#phi;#tracks",360,0.,6.285,AliDielectronVarManager::kPhi);  
577   //  histos->UserHistogram("Track","Eta_Phi",";#eta; #phi;#tracks",
578   //                        100,-2,2,144,0,6.285,AliDielectronVarManager::kEta,AliDielectronVarManager::kPhi);
579   //  
580   //  histos->UserHistogram("Track","Ncl",";Number clusters TPC;Number clusters TPC",
581   //                        160,-0.5,159.5,AliDielectronVarManager::kNclsTPC);
582   //  histos->UserHistogram("Track","NclFrFrac",";found/findable clusters (robust);#tracks",
583   //                        160,0,1.1,AliDielectronVarManager::kNFclsTPCrFrac);
584   //  histos->UserHistogram("Track","TPCsignalN","Number of Clusters TPC PID;#clusteres TPC PID;#tracks",
585   //                        160,-0.5,159.5,AliDielectronVarManager::kTPCsignalN);
586   //
587   //  histos->UserHistogram("Track","Ncl_NclPid","Number clusters TPC vs. number of clusters PID;#clusters TPC; #clusters TPC PID",
588   //                        160,-0.5,159.5,160,-0.5,159.5,AliDielectronVarManager::kNclsTPC,AliDielectronVarManager::kTPCsignalN);
589   //  histos->UserHistogram("Track","TPCchi2Cl","TPC #chi^{2}/cluster;TPC #chi^{2}/cluster;#tracks",
590   //                        100,0.,10.,AliDielectronVarManager::kTPCchi2Cl);
591   
592   die->SetHistogramManager(histos);
593 }
594
595 void InitCF(AliDielectron* die, Int_t cutDefinition)
596 {
597   //
598   // Setup the CF Manager if needed
599   //
600   
601   AliDielectronCF *cf=new AliDielectronCF(die->GetName(),die->GetTitle());
602   
603   // leg variables
604   cf->AddVariable(AliDielectronVarManager::kP, "1.0,1.5,2.0,3.0,5.0,10.0",kTRUE);
605   cf->AddVariable(AliDielectronVarManager::kTRDphi,       45, -3.15, +3.15, kTRUE);
606   cf->AddVariable(AliDielectronVarManager::kEta,          20, -1.0,   1.0,  kTRUE);
607   cf->AddVariable(AliDielectronVarManager::kTRDntracklets, 7, -0.5,   6.5,  kTRUE);
608   cf->AddVariable(AliDielectronVarManager::kTRDprobEle,   20,  0.0,   1.0,  kTRUE);
609   cf->AddVariable(AliDielectronVarManager::kTPCnSigmaEle, 10.,-3.5,  +3.5,  kTRUE);
610  
611   die->SetCFManagerPair(cf);
612 }
613
614 TVectorD *GetRunNumbers() {
615   
616   Double_t runLHC10h[] = { // all good runs based on RCT 29.Mai
617     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
618   };
619   
620   Double_t runLHC11h[] = { // all good runs based on RCT 29.Mai
621     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
622   };
623   
624   // selection via environement variable (works only for gsi trains)
625
626   
627   if(list.Contains("LHC10h") || list.Contains("LHC11a10")) {
628     Int_t size = (int) (sizeof(runLHC10h)/sizeof(Double_t));
629     TVectorD *vec = new TVectorD(size+1);
630     
631     (*vec)[size] = runLHC10h[0] + 1;
632     for (int i = 0; i < size; i++) {
633       (*vec)[i] = runLHC10h[size-1-i];
634     }
635     //    vec->Print("");
636     return vec;
637   }
638
639   if( list.Contains("LHC11h") || list.Contains("LHC12a17") ) {
640     
641     Int_t size = (int) (sizeof(runLHC11h)/sizeof(Double_t));
642     TVectorD *vec = new TVectorD(size+1);
643     
644     (*vec)[size] = runLHC11h[0] + 1;
645     for (int i = 0; i < size; i++) {
646       (*vec)[i] = runLHC11h[size-1-i];
647     }
648     //   vec->Print("");
649     return vec;
650   }
651
652   TVectorD *vec = new TVectorD(2);
653   (*vec)[0] = 0;
654   (*vec)[0] = 1;
655   return vec;
656   
657 }
658
659 TVectorD *BinsToVector(Int_t nbins, Double_t min, Double_t max) {
660   return AliDielectronHelper::MakeLinBinning(nbins,min,max);
661   //  TVectorD *vec = new TVectorD(nbins+1);
662   //
663   //  Double_t binwdth = (max-min)/nbins;
664   //  for (int i = 0; i < nbins+1; i++) (*vec)[i] = min + i*binwdth;
665   //  
666   //  return vec;
667 }
668
669