]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGCF/EBYE/LRC/AliLRCProcess.cxx
Corrected end-of-line behavior
[u/mrichter/AliRoot.git] / PWGCF / EBYE / LRC / AliLRCProcess.cxx
1 /**************************************************************************
2  * Authors: Andrey Ivanov, Igor Altsybeev.                                                 *
3  * Contributors are mentioned in the code where appropriate.              *
4  *                                                                        *
5  * Permission to use, copy, modify and distribute this software and its   *
6  * documentation strictly for non-commercial purposes is hereby granted   *
7  * without fee, provided that the above copyright notice appears in all   *
8  * copies and that both the copyright notice and this permission notice   *
9  * appear in the supporting documentation. The authors make no claims     *
10  * about the suitability of this software for any purpose. It is          *
11  * provided "as is" without express or implied warranty.                  *
12  **************************************************************************/
13
14 // This class creates TH2D histogramms for Nch - Nch , Nch - Pt , Pt - Pt 
15 // dirtributions for given ETA windows and some supplementary data for Long Range Correlation (LRC) analysis .  
16 // Class is designid to work with AliAnalysisTaskLRC
17
18 // Authors : Andrey Ivanov, Igor Altsybeev, St.Peterburg State University
19 // Email: Igor.Altsybeev@cern.ch
20
21 #include "Riostream.h"
22 #include "AliLRCProcess.h"
23 //#include "THnSparse.h"
24 #include "TH1F.h"
25 #include "TH1D.h"
26 #include "TH2D.h"
27 #include "TProfile.h"
28 #include "TList.h"
29 #include "TString.h"
30 #include "TMath.h"
31 //#include "TClonesArray.h"
32
33 //#include <AliPID.h> //for particle mass only
34 ClassImp(AliLRCProcess)
35
36 //const bool useSparse = false;//false;
37 //const bool useAccumulatingHist = true;//false;
38 using std::endl;
39 using std::cout;
40
41 AliLRCProcess::AliLRCProcess():fIsEventOpend(kFALSE), fIsOnline(kFALSE), fDisplayInitOnDemandWarning(kTRUE)
42   ,fUseSparse(false)
43   ,fUseAccumulatingHist(true)
44   ,fEventCount(0),fStartForwardETA(0), fEndForwardETA(0)
45   ,fStartForwardPhi(0)
46   ,fEndForwardPhi(0)
47   ,fStartBackwardETA(0)
48   ,fEndBackwardETA(0)
49   ,fStartBackwardPhi(0)
50   ,fEndBackwardPhi(0)
51   ,fDoubleSidedBackwardPhiWindow(kFALSE)
52   ,fHiPt(0)
53   ,fLoPt(0)
54   ,fHiMultHor(0)
55   ,fLowMultHor(0)
56   ,fHiMultVert(0)
57   ,fLowMultVert(0)
58   ,fMultBinsHor(0)
59   ,fMultBinsVert(0)
60   ,fPtBins(0)
61   ,fPtHistXaxisRebinFactor(1)
62   ,fSumPtFw(0)
63   ,fSumPtBw(0)
64   ,fSumPtBw2(0)
65   ,fNchFw(0)
66   ,fNchBw(0)
67   ,fNchFwPlus(0)
68   ,fNchBwPlus(0)
69   ,fNchFwMinus(0)
70   ,fNchBwMinus(0)
71   ,fOutList(0), fShortDef(0),fOutputSlot(0), fHistPt(0),fHistEta(0),fHistClouds(0),fHistNN(0),fHistPtN(0),fHistPtPt(0),fProfNberr(0),fProfNberrPtPt(0),fProfdPtB(0),fProfTestLRC(0),fHistSparseDimensionLabeling(0),fHistSparsePIDblocksLabeling(0)
72
73   ,fHistPtForward(0)
74   ,fHistEtaForward(0)
75   ,fHistNchForward(0)
76   ,fHistNchForwardPtPt(0)
77   ,fHistPhiForward(0)
78   ,fHistTracksChargeForward(0)
79   ,fHistPtPlusForward(0)
80   ,fHistPtMinusForward(0)
81   ,fHistNetChargeVsPtForward(0)
82
83   ,fHistPtBackward(0)
84   ,fHistEtaBackward(0)
85   ,fHistNchBackward(0)
86   ,fHistPhiBackward(0)
87   ,fHistTracksChargeBackward(0)
88   ,fHistPtPlusBackward(0)
89   ,fHistPtMinusBackward(0)
90   ,fHistNetChargeVsPtBackward(0)
91
92   ,fArrAccumulatedValues(0)
93   //  ,fHistArrayLabeling(0)
94   ,fEventCentrality(0)
95   ,fHistNfCentrality(0)
96   ,fHistTestPIDForward(0)
97   ,fHistTestPIDBackward(0)
98   ,fHistDifferenceNf(0)
99   ,fHistDifferenceNb(0)
100
101   ,fPidForward(-1)//kLRCany)
102   ,fPidBackward(-1)//kLRCany)
103   //,fWhichParticleToProcess(kLRCany)//kLRCany)
104   //,fPidFillCondition(kLRCpidIgnored)
105   //,fNumberOfSectors(1)
106   //,fNeedToRotateSector(kFALSE)
107 {
108     //fWhichParticleToProcess = kLRCany;  //default - all particle types
109     //fPidFillCondition = kLRCpidIgnored;
110     SetCorrespondanceWithAliROOTpid();
111     ZeroPidArrays();
112 }
113
114 AliLRCProcess::AliLRCProcess(Double_t _StartForwardETA,Double_t _EndForwardETA,Double_t _StartBakwardETA,Double_t _EndBakwardETA ): fIsEventOpend(kFALSE), fIsOnline(kFALSE), fDisplayInitOnDemandWarning(kTRUE)
115   ,fUseSparse(false)
116   ,fUseAccumulatingHist(true)
117   ,fEventCount(0),fStartForwardETA(0), fEndForwardETA(0), fStartForwardPhi(0),fEndForwardPhi(0),fStartBackwardETA(0), fEndBackwardETA(0),fStartBackwardPhi(0)
118   ,fEndBackwardPhi(0)
119   ,fDoubleSidedBackwardPhiWindow(kFALSE)
120   ,fHiPt(0)
121   ,fLoPt(0)
122   ,fHiMultHor(0)
123   ,fLowMultHor(0)
124   ,fHiMultVert(0)
125   ,fLowMultVert(0)
126   ,fMultBinsHor(0)
127   ,fMultBinsVert(0)
128   ,fPtBins(0)
129   ,fPtHistXaxisRebinFactor(1)
130   ,fSumPtFw(0),  fSumPtBw(0), fSumPtBw2(0),fNchFw(0)
131   ,/*fNchFwPtPt(0),*/ fNchBw(0)
132   ,fNchFwPlus(0)
133   ,fNchBwPlus(0)
134   ,fNchFwMinus(0)
135   ,fNchBwMinus(0)
136   ,fOutList(0), fShortDef(0),fOutputSlot(0), fHistPt(0),fHistEta(0),fHistClouds(0),fHistNN(0),fHistPtN(0),fHistPtPt(0),fProfNberr(0),fProfNberrPtPt(0),fProfdPtB(0),fProfTestLRC(0),fHistSparseDimensionLabeling(0),fHistSparsePIDblocksLabeling(0)
137
138   ,fHistPtForward(0)
139   ,fHistEtaForward(0)
140   ,fHistNchForward(0)
141   ,fHistNchForwardPtPt(0)
142   ,fHistPhiForward(0)
143   ,fHistTracksChargeForward(0)
144   ,fHistPtPlusForward(0)
145   ,fHistPtMinusForward(0)
146   ,fHistNetChargeVsPtForward(0)
147
148   ,fHistPtBackward(0)
149   ,fHistEtaBackward(0)
150   ,fHistNchBackward(0)
151   ,fHistPhiBackward(0)
152   ,fHistTracksChargeBackward(0)
153   ,fHistPtPlusBackward(0)
154   ,fHistPtMinusBackward(0)
155   ,fHistNetChargeVsPtBackward(0)
156
157   ,fArrAccumulatedValues(0)
158   //  ,fHistArrayLabeling(0)
159   ,fEventCentrality(0)
160   ,fHistNfCentrality(0)
161   ,fHistTestPIDForward(0)
162   ,fHistTestPIDBackward(0)
163   ,fHistDifferenceNf(0)
164   ,fHistDifferenceNb(0)
165   ,fPidForward(-1)//kLRCany)
166   ,fPidBackward(-1)//kLRCany)
167   //,fWhichParticleToProcess(kLRCany)//kLRCany)
168   //,fPidFillCondition(kLRCpidIgnored)
169   //,fNumberOfSectors(1)
170   //,fNeedToRotateSector(kFALSE)
171 {
172     // Constructor with window setup makes ready-to-run processor
173     fEventCount=0;
174
175     //fWhichParticleToProcess = kLRCany;  //default - all particle types
176     //fPidFillCondition = kLRCpidIgnored;
177     
178     //cout << "TEST" << endl;
179     SetETAWindows( _StartForwardETA, _EndForwardETA,_StartBakwardETA,_EndBakwardETA);
180     SetHistPtRange( 0.15, 1.5, 270 );
181     SetHistMultRange( 0, 0, 100 );
182     SetForwardWindowPhi( 0, 2*TMath::Pi() );
183     SetBackwardWindowPhi( 0, 2*TMath::Pi() );
184
185     SetCorrespondanceWithAliROOTpid();
186     ZeroPidArrays();
187
188     
189
190 }
191
192 Bool_t AliLRCProcess::InitDataMembers()
193 {
194     //Printf("INITDATAMEMBERS");
195     // This method is actualy creating output histogramms
196     // Thist method  is to be called in CreateOutputObjects method of AliAnalysisTask
197     //cout<<" # Init for "<<fShortDef<<" this="<<this<<"\n";
198     if( fIsOnline )
199     {
200         Printf("Can't init data members more then one time! \n");
201         return kFALSE;
202     }
203     fEventCount=0;
204     fOutList = new TList();
205     fOutList->SetOwner();  // IMPORTANT!
206
207     fOutList->SetName(fShortDef);
208
209     Double_t lowMultHor, hiMultHor;
210     Double_t lowMultVert, hiMultVert;
211
212     lowMultHor = fLowMultHor - 0.5;
213     hiMultHor = fHiMultHor + 0.5;
214
215     lowMultVert = fLowMultVert - 0.5;
216     hiMultVert = fHiMultVert + 0.5;
217
218
219     //TArray to accumulate data, with names hist
220     //26.01.2013: array with accumulated values
221     //fArrAccumulatedValues = new TClonesArray("Float_t", en_arr_labels_total );//TArrayF(en_arr_labels_total);
222     if ( fUseAccumulatingHist )
223     {
224         fArrAccumulatedValues = new TH1D( "fArrAccumulatedValues", "Accumulating hist with labeling", en_arr_labels_total,-0.5,en_arr_labels_total-0.5);
225         TString gArrayMemberNames[en_arr_labels_total];
226         gArrayMemberNames[ en_arr_labels_NN_Nevents  ] = "NN_Nevents"       ;
227         gArrayMemberNames[ en_arr_labels_NN_Nf       ] = "NN_Nf"            ;
228         gArrayMemberNames[ en_arr_labels_NN_Nb       ] = "NN_Nb"            ;
229         gArrayMemberNames[ en_arr_labels_NN_N2_f     ] = "NN_N2_f"          ;
230         gArrayMemberNames[ en_arr_labels_NN_Nf_Nb    ] = "NN_Nf_Nb"         ;
231         gArrayMemberNames[ en_arr_labels_NN_N2_b     ] = "NN_N2_b"          ;
232
233         gArrayMemberNames[ en_arr_labels_PtN_Nevents ] = "PtN_Nevents"      ;
234         gArrayMemberNames[ en_arr_labels_PtN_Nf      ] = "PtN_Nf"           ;
235         gArrayMemberNames[ en_arr_labels_PtN_PtB     ] = "PtN_PtB"          ;
236         gArrayMemberNames[ en_arr_labels_PtN_N2_f    ] = "PtN_N2_f"         ;
237         gArrayMemberNames[ en_arr_labels_PtN_Ptb_Nf  ] = "PtN_Ptb_Nf"       ;
238
239         gArrayMemberNames[ en_arr_labels_PtPt_Nevents] = "PtPt_Nevents"     ;
240         gArrayMemberNames[ en_arr_labels_PtPt_PtF    ] = "PtPt_PtF"         ;
241         gArrayMemberNames[ en_arr_labels_PtPt_PtB    ] = "PtPt_PtB"         ;
242         gArrayMemberNames[ en_arr_labels_PtPt_Pt2_f  ] = "PtPt_Pt2_f"       ;
243         gArrayMemberNames[ en_arr_labels_PtPt_Ptf_Ptb] = "PtPt_Ptf_Ptb"     ;
244
245         for( Int_t i = 1; i <= en_arr_labels_total; i++ )
246             fArrAccumulatedValues->GetXaxis()->SetBinLabel(i,gArrayMemberNames[i-1].Data());
247         //fOutList->Add(fArrAccumulatedValues);
248         fOutList->Add(fArrAccumulatedValues);
249     }
250
251
252
253     
254     // Window statistics histograms
255
256     // ########## Forward
257
258     fHistPtForward = new TH1D("fHistPtForward", "P_{T} distribution in Forward window", 100, 0.0, 5);
259     fHistPtForward->GetXaxis()->SetTitle("P_{T} (GeV/c)");
260     fHistPtForward->GetYaxis()->SetTitle("dN/dP_{T} (c/GeV)");
261     fHistPtForward->SetMarkerStyle(kFullCircle);
262
263
264     fHistEtaForward = new TH1D("fEtaForward", "#eta distribution in Forward window", 200, -2, 2);
265     fHistEtaForward->GetXaxis()->SetTitle("ETA");
266     fHistEtaForward->GetYaxis()->SetTitle("dN/ETA");
267     fHistEtaForward->SetMarkerStyle(kFullCircle);
268
269     
270     fHistNchForward = new TH1D("fHistNchForward", "N_{ch} distribution in Forward window", fMultBinsHor, lowMultHor, hiMultHor);
271     fHistNchForward->GetXaxis()->SetTitle("N_{ch}");
272     fHistNchForward->GetYaxis()->SetTitle("dN/dN_{ch}");
273     fHistNchForward->SetMarkerStyle(kFullCircle);
274
275     fHistNchForwardPtPt = new TH1D("fHistNchForwardPtPt", "N_{ch} distribution in Forward window for PtPt accept conditions", fMultBinsHor, lowMultHor, hiMultHor);
276     fHistNchForwardPtPt->GetXaxis()->SetTitle("N_{ch}");
277     fHistNchForwardPtPt->GetYaxis()->SetTitle("dN/dN_{ch}");
278     fHistNchForwardPtPt->SetMarkerStyle(kFullCircle);
279
280     fHistPhiForward = new TH1D("fPhiForward", "#phi distribution in Forward window", 144, 0, 2*TMath::Pi());
281     fHistPhiForward->GetXaxis()->SetTitle("Phi");
282     fHistPhiForward->GetYaxis()->SetTitle("dN/Phi");
283     fHistPhiForward->SetMarkerStyle(kFullCircle);
284
285     fHistTestPIDForward = new TH1D("fHistTestPIDForward","PID distribution in Forward window;PID;N",5,-0.5,4.5);
286     TString gBinParticleNames[5] = {/*"Other",*/"Electron","Muon","Pion","Kaon", "Proton"};
287     for(Int_t i = 1; i <= 5; i++)
288         fHistTestPIDForward->GetXaxis()->SetBinLabel(i,gBinParticleNames[i-1].Data());
289
290     //15/12/2012: charge hist
291     fHistTracksChargeForward = new TH1D("fHistTracksChargeForward","Accepted tracks charge;charge;Entries",3,-1.5,1.5);
292
293
294     // ### net charge vs pt study (July 2013)
295     const int kPtNetChargePtBins = 200;
296     const double kPtNetChargePtMin = 0.1;
297     const double kPtNetChargePtMax = 2.1;
298
299     //pt plus
300     fHistPtPlusForward = new TH1D("fHistPtPlusForward","p_{T} +;p_{T};dN/dpT", kPtNetChargePtBins,  kPtNetChargePtMin, kPtNetChargePtMax                                  );
301     fOutList->Add(fHistPtPlusForward);
302     //pt minus
303     fHistPtMinusForward = new TH1D("fHistPtMinusForward","p_{T} -;p_{T};dN/dpT", kPtNetChargePtBins,  kPtNetChargePtMin, kPtNetChargePtMax                                  );
304     fOutList->Add(fHistPtMinusForward);
305     //net charge vs pT
306     fHistNetChargeVsPtForward = new TH1D("fHistNetChargeVsPtForward","charge vs p_{T};p_{T};Q", kPtNetChargePtBins,  kPtNetChargePtMin, kPtNetChargePtMax                                  );
307     fOutList->Add(fHistNetChargeVsPtForward);
308
309
310     // ########## Backward
311
312     fHistPtBackward = new TH1D("fHistPtBakward", "P_{T} distribution in Backward window", 100, 0.0, 5);
313     fHistPtBackward->GetXaxis()->SetTitle("P_{T} (GeV/c)");
314     fHistPtBackward->GetYaxis()->SetTitle("dN/dP_{T} (c/GeV)");
315     fHistPtBackward->SetMarkerStyle(kFullCircle);
316
317
318     fHistEtaBackward = new TH1D("fEtaBakward", "#eta distribution in Backward window", 200, -2, 2);
319     fHistEtaBackward->GetXaxis()->SetTitle("ETA");
320     fHistEtaBackward->GetYaxis()->SetTitle("dN/ETA");
321     fHistEtaBackward->SetMarkerStyle(kFullCircle);
322
323
324     fHistNchBackward = new TH1D("fHistNchBakward", "N_{ch} distribution in Backward window", fMultBinsVert, lowMultVert, hiMultVert);
325     fHistNchBackward->GetXaxis()->SetTitle("N_{ch}");
326     fHistNchBackward->GetYaxis()->SetTitle("dN/dN_{ch}");
327     fHistNchBackward->SetMarkerStyle(kFullCircle);
328
329     fHistPhiBackward = new TH1D("fPhiBakward", "#phi distribution in Backward window", 144, 0, 2*TMath::Pi());
330     fHistPhiBackward->GetXaxis()->SetTitle("Phi");
331     fHistPhiBackward->GetYaxis()->SetTitle("dN/Phi");
332     fHistPhiBackward->SetMarkerStyle(kFullCircle);
333
334     fHistTestPIDBackward = new TH1D("fHistTestPIDBackward","PID distribution in Backward window;PID;N",5,-0.5,4.5);
335     for(Int_t i = 1; i <= 5; i++)
336         fHistTestPIDBackward->GetXaxis()->SetBinLabel(i,gBinParticleNames[i-1].Data());
337
338
339     //15/12/2012: charge hist
340     fHistTracksChargeBackward = new TH1D("fHistTracksChargeBackward","Accepted tracks charge;charge;Entries",3,-1.5,1.5);
341
342     // ### net charge vs pt study (July 2013)
343     //pt plus
344     fHistPtPlusBackward = new TH1D("fHistPtPlusBackward","p_{T} +;p_{T};dN/dpT", kPtNetChargePtBins,  kPtNetChargePtMin, kPtNetChargePtMax                                  );
345     fOutList->Add(fHistPtPlusBackward);
346     //pt minus
347     fHistPtMinusBackward = new TH1D("fHistPtMinusBackward","p_{T} -;p_{T};dN/dpT", kPtNetChargePtBins,  kPtNetChargePtMin, kPtNetChargePtMax                                  );
348     fOutList->Add(fHistPtMinusBackward);
349     //net charge vs pT
350     fHistNetChargeVsPtBackward = new TH1D("fHistNetChargeVsPtBackward","charge vs p_{T};p_{T};Q", kPtNetChargePtBins,  kPtNetChargePtMin, kPtNetChargePtMax                                  );
351     fOutList->Add(fHistNetChargeVsPtBackward);
352
353
354
355
356
357     //Overal statistics histograms
358
359     fHistPt = new TH1F("fHistPt", "P_{T} distribution", 100, 0.0, 5.0);
360     fHistPt->GetXaxis()->SetTitle("P_{T} (GeV/c)");
361     fHistPt->GetYaxis()->SetTitle("dN/dP_{T} (c/GeV)");
362     fHistPt->SetMarkerStyle(kFullCircle);
363
364
365     fHistEta = new TH1F("fHistEta", "#eta distribution", 200, -2, 2);
366     fHistEta->GetXaxis()->SetTitle("ETA");
367     fHistEta->GetYaxis()->SetTitle("dN/ETA");
368     fHistEta->SetMarkerStyle(kFullCircle);
369     
370     
371     
372     // -------- LRC histograms
373     //new cloud implementation
374     //const int lSparseDim = en_sparse_total;
375     //const int nSparseBins = 1000;
376
377
378     /* from AliROOT //deprecated!
379         enum EParticleType {
380             kElectron = 0,
381             kMuon = 1,
382             kPion = 2,
383             kKaon = 3,
384             kProton = 4,
385             kPhoton = 5,
386             kPi0 = 6,
387             kNeutron = 7,
388             kKaon0 = 8,
389             kEleCon = 9,
390             kDeuteron = 10,
391             kTriton = 11,
392             kHe3 = 12,
393             kAlpha = 13,
394             kUnknown = 14
395         };*/
396
397
398     if ( fUseSparse )
399     {
400
401         //correspondance of PID blocks
402         //it's a way to unlink THnSparse data dimenstion from enum
403         fHistSparsePIDblocksLabeling = new TH1D("fHistSparsePIDblocksLabeling","THnSparse PID blocks labeling", kSparsePIDtotal,-0.5,kSparsePIDtotal-0.5);
404         TString gEventCutBinPIDblocksNames[kSparsePIDtotal];    // = {"Total","No trigger","Centrality","No vertex","Bad vertex position","HighMult cut","LowMult cut","Analyzed"};
405         gEventCutBinPIDblocksNames[kSparsePIDany]               = "any";
406         gEventCutBinPIDblocksNames[kSparsePIDdefined]       = "defined";
407         gEventCutBinPIDblocksNames[kSparsePIDpion]      = "pion";
408         gEventCutBinPIDblocksNames[kSparsePIDkaon]      = "kaon";
409         gEventCutBinPIDblocksNames[kSparsePIDproton]    = "proton";
410
411
412         for(Int_t i = 1; i <= kSparsePIDtotal; i++)fHistSparsePIDblocksLabeling->GetXaxis()->SetBinLabel(i,gEventCutBinPIDblocksNames[i-1].Data());
413         //for(Int_t i = 0; i < nEnumBins; i++)fHistSparseDimensionLabeling->Fill( i );
414
415         //dimensions labelling
416
417         fHistSparseDimensionLabeling = new TH1D("fHistSparseDimensionLabeling","THnSparse labeling", kSparseTotal,-0.5,kSparseTotal-0.5);
418         TString gSparseDimensionsNames[kSparseTotal];    // = {"Total","No trigger","Centrality","No vertex","Bad vertex position","HighMult cut","LowMult cut","Analyzed"};
419         gSparseDimensionsNames[kSparseNf] = "N_f";
420         gSparseDimensionsNames[kSparseNb] = "N_b";
421         gSparseDimensionsNames[kSparsePtF] = "Pt_f";
422         gSparseDimensionsNames[kSparsePtB] = "Pt_b";
423         gSparseDimensionsNames[en_sparse_N2_f] = "N2_f";
424         gSparseDimensionsNames[en_sparse_Nf_Nb] = "Nf_Nb";
425         gSparseDimensionsNames[en_sparse_Ptb_Nf] = "Ptb_Nf";
426         gSparseDimensionsNames[en_sparse_Pt2_f] = "Pt2_f";
427         gSparseDimensionsNames[en_sparse_Ptf_Ptb] = "Ptf_Ptb";
428
429         for( Int_t i = 1; i <= kSparseTotal; i++ )
430             fHistSparseDimensionLabeling->GetXaxis()->SetBinLabel(i,gSparseDimensionsNames[i-1].Data());
431
432
433
434         Int_t* lSparseBins      = new Int_t[kSparseTotal*kSparsePIDtotal];
435         Double_t *lSparseXmin   = new Double_t[kSparseTotal*kSparsePIDtotal];
436         Double_t *lSparseXmax   = new Double_t[kSparseTotal*kSparsePIDtotal];
437         TString *lSparseAxisNames       = new TString[kSparseTotal*kSparsePIDtotal];
438
439         TString *lPIDNames      = new TString[kSparsePIDtotal];
440         lPIDNames[ kSparsePIDany      ] = Form( "any" );
441         lPIDNames[ kSparsePIDdefined  ] = Form( "defined" );
442         lPIDNames[ kSparsePIDpion     ] = Form( "pion" );
443         lPIDNames[ kSparsePIDkaon     ] = Form( "kaon" );
444         lPIDNames[ kSparsePIDproton   ] = Form( "proton" );
445
446
447
448         for ( Int_t d = 0; d < kSparsePIDtotal; ++d )
449         {
450             Int_t binShift = kSparseTotal*d;
451
452             lSparseAxisNames[kSparseNf + binShift] = Form( "axisNf_%s", lPIDNames[ d ].Data() );
453             lSparseAxisNames[kSparseNb + binShift] = Form( "axisNb_%s", lPIDNames[ d ].Data() );
454             lSparseAxisNames[kSparsePtF + binShift] = Form( "axisPtf_%s", lPIDNames[ d ].Data() );
455             lSparseAxisNames[kSparsePtB + binShift] = Form( "axisPtb_%s", lPIDNames[ d ].Data() );
456
457             lSparseAxisNames[en_sparse_N2_f + binShift]     = Form( "axisN2_%s", lPIDNames[ d ].Data() );
458             lSparseAxisNames[en_sparse_Nf_Nb + binShift]    = Form( "axisNf_Nb_%s", lPIDNames[ d ].Data() );
459             lSparseAxisNames[en_sparse_Ptb_Nf + binShift]   = Form( "axisPtb_Nf_%s", lPIDNames[ d ].Data() );
460             lSparseAxisNames[en_sparse_Pt2_f + binShift]    = Form( "axisPt2_f_%s", lPIDNames[ d ].Data() );
461             lSparseAxisNames[en_sparse_Ptf_Ptb + binShift]  = Form( "axisPtf_Ptb_%s", lPIDNames[ d ].Data() );
462
463
464             lSparseBins[kSparseNf + binShift ] = fMultBinsHor;
465             lSparseXmin[kSparseNf + binShift ] = lowMultHor;
466             lSparseXmax[kSparseNf + binShift ] = hiMultHor;
467             lSparseBins[kSparseNb + binShift ] = fMultBinsVert;
468             lSparseXmin[kSparseNb + binShift ] = lowMultVert;
469             lSparseXmax[kSparseNb + binShift ] = hiMultVert;
470             //}
471             //for (Int_t d = 2; d < lSparseDim; ++d) {
472             lSparseBins[kSparsePtF + binShift ] = fPtBins;
473             lSparseXmin[kSparsePtF + binShift ] = fLoPt;
474             lSparseXmax[kSparsePtF + binShift ] = fHiPt;
475             lSparseBins[kSparsePtB + binShift ] = fPtBins;
476             lSparseXmin[kSparsePtB + binShift ] = fLoPt;
477             lSparseXmax[kSparsePtB + binShift ] = fHiPt;
478
479
480
481
482
483             //}
484             /*
485                 lSparseBins[en_sparse_Et_f + binShift ] = 500;
486             lSparseXmin[en_sparse_Et_f + binShift ] = 0.2;
487             lSparseXmax[en_sparse_Et_f + binShift ] = 2.7;
488             lSparseBins[en_sparse_Et_b + binShift ] = 500;
489             lSparseXmin[en_sparse_Et_b + binShift ] = 0.2;
490             lSparseXmax[en_sparse_Et_b + binShift ] = 2.7;
491 */
492
493             lSparseBins[en_sparse_N2_f + binShift ] = (fMultBinsHor-1)*(fMultBinsHor-1)+1;
494             lSparseXmin[en_sparse_N2_f + binShift ] = fLowMultHor*fLowMultHor-0.5; // ! use global mult without shift
495             lSparseXmax[en_sparse_N2_f + binShift ] = fHiMultHor*fHiMultHor+0.5;
496             //lSparseBins[en_sparse_N_b] = fMultBinsVert;
497             //lSparseXmin[en_sparse_N_b] = lowMultVert;
498             //lSparseXmax[en_sparse_N_b] = hiMultVert;
499             lSparseBins[en_sparse_Nf_Nb + binShift ] = (fMultBinsHor-1)*(fMultBinsVert-1)+1;
500             lSparseXmin[en_sparse_Nf_Nb + binShift ] = fLowMultHor*fLowMultVert-0.5;
501             lSparseXmax[en_sparse_Nf_Nb + binShift ] = fHiMultHor*fHiMultVert+0.5;
502
503
504
505             lSparseBins[en_sparse_Ptb_Nf + binShift ] = /*(fMultBinsHor-1)**/(10*fPtBins);//+1;
506             lSparseXmin[en_sparse_Ptb_Nf + binShift ] = fLowMultHor*fLoPt-0.5;
507             lSparseXmax[en_sparse_Ptb_Nf + binShift ] = fHiMultHor*fHiPt+0.5;
508
509             lSparseBins[en_sparse_Pt2_f + binShift ] = (10*fPtBins);//*(fPtBins);//+1;
510             lSparseXmin[en_sparse_Pt2_f + binShift ] = fLoPt*fLoPt;
511             lSparseXmax[en_sparse_Pt2_f + binShift ] = fHiPt*fHiPt;
512
513             lSparseBins[en_sparse_Ptf_Ptb + binShift ] = (10*fPtBins);//*(fPtBins)+1;
514             lSparseXmin[en_sparse_Ptf_Ptb + binShift ] = fLoPt*fLoPt;
515             lSparseXmax[en_sparse_Ptf_Ptb + binShift ] = fHiPt*fHiPt;
516
517             /*
518                 lSparseBins[en_sparse_Nf_plus + binShift ] = fMultBinsHor;
519             lSparseXmin[en_sparse_Nf_plus + binShift ] = lowMultHor;
520             lSparseXmax[en_sparse_Nf_plus + binShift ] = hiMultHor;
521                 lSparseBins[en_sparse_Nf_minus + binShift ] = fMultBinsHor;
522             lSparseXmin[en_sparse_Nf_minus + binShift ] = lowMultHor;
523             lSparseXmax[en_sparse_Nf_minus + binShift ] = hiMultHor;
524
525                 lSparseBins[en_sparse_Nb_plus + binShift ] = fMultBinsVert;
526             lSparseXmin[en_sparse_Nb_plus + binShift ] = lowMultVert;
527             lSparseXmax[en_sparse_Nb_plus + binShift ] = hiMultVert;
528                 lSparseBins[en_sparse_Nb_minus + binShift ] = fMultBinsVert;
529             lSparseXmin[en_sparse_Nb_minus + binShift ] = lowMultVert;
530             lSparseXmax[en_sparse_Nb_minus + binShift ] = hiMultVert;
531
532                 lSparseBins[en_sparse_Nf_plus_Nb_minus + binShift ] = (fMultBinsHor-1)*(fMultBinsVert-1)+1;
533             lSparseXmin[en_sparse_Nf_plus_Nb_minus + binShift ] = fLowMultHor*fLowMultVert-0.5;
534             lSparseXmax[en_sparse_Nf_plus_Nb_minus + binShift ] = fHiMultHor*fHiMultVert+0.5;
535
536                 lSparseBins[en_sparse_Nb_plus_Nf_minus + binShift ] = (fMultBinsHor-1)*(fMultBinsVert-1);
537             lSparseXmin[en_sparse_Nb_plus_Nf_minus + binShift ] = fLowMultHor*fLowMultVert-0.5;
538             lSparseXmax[en_sparse_Nb_plus_Nf_minus + binShift ] = fHiMultHor*fHiMultVert+0.5;
539         */
540         }
541
542         fHistClouds = new THnSparseD("cloudLRC", "cloudLRC", kSparseTotal*kSparsePIDtotal, lSparseBins, lSparseXmin, lSparseXmax);
543         //end of cloud implementation
544
545         //set axis names
546         TAxis *lSparseAxis = 0x0;
547         for ( Int_t d = 0; d < kSparseTotal*kSparsePIDtotal; ++d )
548         {
549             lSparseAxis = fHistClouds->GetAxis( d );
550             lSparseAxis->SetNameTitle( lSparseAxisNames[d], lSparseAxisNames[d] );
551         }
552
553
554         delete [] lSparseBins;
555         delete [] lSparseXmin;
556         delete [] lSparseXmax;
557         delete [] lSparseAxisNames;
558
559
560         fOutList->Add(fHistSparseDimensionLabeling);
561         fOutList->Add(fHistSparsePIDblocksLabeling);
562
563         //    bool useSparse = false;
564
565         // !!!!!! temp comment!
566         fOutList->Add(fHistClouds);
567     }
568
569
570     fHistNN = new TH2D("NN","NN",fMultBinsHor, lowMultHor, hiMultHor,fMultBinsVert, lowMultVert, hiMultVert );
571     fHistPtN = new TH2D("PtN","PtN",fMultBinsHor, lowMultHor, hiMultHor,fPtBins/* /fPtHistXaxisRebinFactor*/,fLoPt,fHiPt);
572     fHistPtPt = new TH2D("PtPt","PtPt",fPtBins/fPtHistXaxisRebinFactor,fLoPt,fHiPt,fPtBins,fLoPt,fHiPt);
573     fProfNberr = new TProfile("nber","nber",fMultBinsHor, lowMultHor, hiMultHor);
574     fProfNberrPtPt = new TProfile("nberPtPt","nberPtPt",fPtBins/fPtHistXaxisRebinFactor,fLoPt,fHiPt);
575     fProfdPtB = new TProfile("dPtB","Overal multievent Pt_Backward (first bin) Pt_Backward^2 (sec. bin) ",16,0.5,16.5);
576     fProfTestLRC = new TProfile("TestLRC","Test LRC calculaion via TProfile",fMultBinsHor, lowMultHor, hiMultHor);
577
578     fHistNfCentrality = new TH2D("NfCentrality","NfCentrality",fMultBinsHor, lowMultHor, hiMultHor,101,-1.01,100.01);
579     fHistDifferenceNf = new TH2D("fHistDifferenceNf","Hist nF-nB;nF;nF-nB",fMultBinsHor, lowMultHor, hiMultHor,fMultBinsHor,-hiMultHor,hiMultHor);
580     fHistDifferenceNb = new TH2D("fHistDifferenceNb","Hist nB-nF;nB;nB-nF",fMultBinsVert, lowMultVert, hiMultVert,fMultBinsVert,-hiMultVert,hiMultVert);
581
582     // ---------- Adding data members to output list
583
584     // Adding overal statistics
585
586     //commented: to save memory
587     //fOutList->Add(fHistPt);
588     //fOutList->Add(fHistEta);
589
590     //Adding LRC hists
591
592     
593     if (1)
594     {
595         fOutList->Add(fHistNN);
596         fOutList->Add(fHistPtN);
597         fOutList->Add(fHistPtPt);
598     }
599     fOutList->Add(fProfNberr);
600     fOutList->Add(fProfNberrPtPt);
601     fOutList->Add(fProfdPtB);
602     fOutList->Add(fProfTestLRC);
603
604
605     //Adding window statistics
606     
607
608
609     fOutList->Add(fHistNchForward);
610     fOutList->Add(fHistNchBackward);
611     fOutList->Add(fHistNchForwardPtPt);
612
613     fOutList->Add(fHistPtForward);
614     fOutList->Add(fHistPtBackward);
615
616     fOutList->Add(fHistEtaForward);
617     fOutList->Add(fHistEtaBackward);
618
619     fOutList->Add(fHistPhiForward);
620     fOutList->Add(fHistPhiBackward);
621
622     fOutList->Add(fHistTracksChargeForward);
623     fOutList->Add(fHistTracksChargeBackward);
624
625     fOutList->Add(fHistTestPIDForward);
626     fOutList->Add(fHistTestPIDBackward);
627
628     //    fOutList->Add(fHistNfCentrality);
629     
630     
631     //fOutList->Add(fHistDifferenceNf);
632     //fOutList->Add(fHistDifferenceNb);
633
634     // Adding status to dPtB
635
636     fProfdPtB->Fill(3 , fStartForwardETA);
637     fProfdPtB->Fill(4 , fEndForwardETA);
638     fProfdPtB->Fill(5 , fStartBackwardETA);
639     fProfdPtB->Fill(6 , fEndBackwardETA);
640     fProfdPtB->Fill(7 , fStartForwardPhi);
641     fProfdPtB->Fill(8 , fEndForwardPhi);
642     fProfdPtB->Fill(9 , fStartBackwardPhi);
643     fProfdPtB->Fill(10 , fEndBackwardPhi);
644
645
646
647
648     fIsOnline = kTRUE;
649     return kTRUE;
650 }
651 AliLRCProcess::~AliLRCProcess()
652 {
653     //Destructor
654
655 }
656
657 // ---------------------------------------  Setters ------------------
658 void AliLRCProcess::SetShortDef()
659 {
660     // Creating task and output container name
661     char str[200];
662     snprintf(str,200, "TaskLRCw%3.1fto%3.1fvs%3.1fto%3.1f",fStartForwardETA,fEndForwardETA,fStartBackwardETA,fEndBackwardETA);
663     /*if ( fWhichParticleToProcess != kLRCany
664         && (int)fWhichParticleToProcess > 0 && (int)fWhichParticleToProcess <= 6 ) //to avoid program falling
665     {
666         char str2[80];
667         TString gBinParticleNames[6] = {"Other","Electron","Muon","Pion","Kaon", "Proton"};
668         snprintf(str2,80, "%s_%s",str,gBinParticleNames[(int)fWhichParticleToProcess].Data());
669         fShortDef= str2;
670     }
671     else*/
672     fShortDef= str;
673
674 }
675
676 void AliLRCProcess::SetForwardWindow(Double_t StartETA,Double_t EndETA)
677 {
678     //setter for the forward eta window
679     fStartForwardETA=StartETA;
680     fEndForwardETA=EndETA;
681     SetShortDef();
682 }
683 void AliLRCProcess::SetBackwardWindow(Double_t StartETA,Double_t EndETA)
684 {
685     //setter for the backward eta window
686     fStartBackwardETA=StartETA;
687     fEndBackwardETA=EndETA;
688     SetShortDef();
689 }
690 void AliLRCProcess::SetETAWindows(Double_t _StartForwardETA,Double_t _EndForwardETA,Double_t _StartBakwardETA,Double_t _EndBakwardETA)
691 {
692     //setter for the eta windows
693     fStartForwardETA=_StartForwardETA;
694     fEndForwardETA=_EndForwardETA;
695     fStartBackwardETA=_StartBakwardETA;
696     fEndBackwardETA=_EndBakwardETA;
697     SetShortDef();
698 }
699 void AliLRCProcess::GetETAWindows(Double_t &_StartForwardETA,Double_t &_EndForwardETA,Double_t &_StartBakwardETA,Double_t &_EndBakwardETA)
700 {
701     //getter for the eta windows
702     _StartForwardETA    = fStartForwardETA;
703     _EndForwardETA      = fEndForwardETA;
704     _StartBakwardETA    = fStartBackwardETA;
705     _EndBakwardETA      = fEndBackwardETA;
706 }
707
708 void AliLRCProcess::GetPhiWindows(Double_t &_StartForwardPhi,Double_t &_EndForwardPhi,Double_t &_StartBakwardPhi,Double_t &_EndBakwardPhi)
709 {
710     //getter for the eta windows
711     _StartForwardPhi    = fStartForwardPhi;
712     _EndForwardPhi      = fEndForwardPhi;
713     _StartBakwardPhi    = fStartBackwardPhi;
714     _EndBakwardPhi      = fEndBackwardPhi;
715 }
716
717 void AliLRCProcess::SetParticleType( char* strForwardOrBackward, char* strPid )
718 {
719     //cout << "hm! strForwardOrBackward = " << strForwardOrBackward
720     //  << ", strPid = " << strPid << endl;
721     //cout << "before ae! fPidForward = " << fPidForward << ", fPidBackward = " << fPidBackward << endl;
722
723     int lPid = -1;//kLRCany;
724     if ( !strcmp( strPid, "pion") )
725         lPid = 2;//kLRCpion;
726     else if ( !strcmp( strPid, "kaon") )
727         lPid = 3;//kLRCkaon;
728     else if ( !strcmp( strPid, "proton") )
729         lPid = 4;//kLRCproton;
730     else if ( !strcmp( strPid, "knownpid") )
731         lPid = 100;//will will histos if we KNOW PID! (not important which)
732
733     //set pid for window
734     if ( !strcmp( strForwardOrBackward, "fwd") )
735         fPidForward = lPid;
736     else if ( !strcmp( strForwardOrBackward, "bkwd") )
737         fPidBackward = lPid;
738     //cout << "ae! lPid = " << lPid << ", fPidForward = " << fPidForward << ", fPidBackward = " << fPidBackward << endl;
739     //int aaaa;
740     //cin>> aaaa;
741 }
742
743
744 void AliLRCProcess::SetHistPtRangeForwardWindowRebinFactor( Int_t ptHistXaxisRebinFactor )
745 {
746     // Rebining for Pt histograms X-axis
747     if(fIsOnline)
748     {
749         Printf("Can't change histos paramiters after InitDataMembers() was called! \n");
750         return ;
751     }
752     fPtHistXaxisRebinFactor = ptHistXaxisRebinFactor;
753 }
754
755 void AliLRCProcess::SetHistPtRange(Double_t LoPt,Double_t HiPt,Int_t PtBins)
756 {
757     // Sets Pt range and number of bins for Pt axis of histos
758     if(fIsOnline)
759     {
760         Printf("Can't change histos paramiters after InitDataMembers() was called! \n");
761         return ;
762     }
763     // Setter for Pt range and N bins in histos
764     fLoPt=LoPt;
765     fHiPt=HiPt;
766     fPtBins=PtBins;
767 }
768 void AliLRCProcess::SetHistMultRange( Int_t whichWindow, Int_t LoMult,Int_t HiMult,Int_t MultBins)
769 {
770     // Setter for multiplicity range and N bins in histos
771     if ( whichWindow == 0 ) //set range for both windows
772     {
773         SetHistMultRangeHor( LoMult, HiMult, MultBins) ;
774         SetHistMultRangeVert( LoMult, HiMult, MultBins) ;
775     }
776     else if ( whichWindow == 1 ) //for fwd
777         SetHistMultRangeHor( LoMult, HiMult, MultBins) ;
778     else if ( whichWindow == 2 ) //for bwd
779         SetHistMultRangeVert( LoMult, HiMult, MultBins) ;
780     /*
781
782     if(fIsOnline)
783     {
784         Printf("Can't change histos paramiters after InitDataMembers() was called! \n");
785         return ;
786     }
787     fLoMult=LoMult;
788     fHiMult=HiMult;
789     if(!MultBins)
790     {
791     fMultBins=fHiMult-fLoMult+1;
792     }else
793     {
794     fMultBins=MultBins;
795     }*/
796 }
797
798 void AliLRCProcess::SetHistMultRangeHor(Int_t LoMult,Int_t HiMult,Int_t MultBins)
799 {
800     // Setter for multiplicity range and N bins in histos
801     if(fIsOnline)
802     {
803         Printf("Can't change histos paramiters after InitDataMembers() was called! \n");
804         return ;
805     }
806     fLowMultHor = LoMult;
807     fHiMultHor  = HiMult;
808     if(!MultBins)
809     {
810         fMultBinsHor = fHiMultHor-fLowMultHor+1;
811     }else
812     {
813         fMultBinsHor = MultBins;
814     }
815 }
816
817 void AliLRCProcess::SetHistMultRangeVert(Int_t LoMult,Int_t HiMult,Int_t MultBins)
818 {
819     // Setter for multiplicity range and N bins in histos
820     if(fIsOnline)
821     {
822         Printf("Can't change histos parameters after InitDataMembers() was called! \n");
823         return ;
824     }
825     fLowMultVert        = LoMult;
826     fHiMultVert         = HiMult;
827     if(!MultBins)
828     {
829         fMultBinsVert = fHiMultVert-fLowMultVert+1;
830     }else
831     {
832         fMultBinsVert = MultBins;
833     }
834 }
835
836 void AliLRCProcess::SetOutputSlotNumber(Int_t SlotNumber)
837 {
838     //Sets number of output slot for LRCProcessor
839     fOutputSlot=SlotNumber;
840 }
841
842 //________________________________________________________________________
843
844
845
846 TList*   AliLRCProcess::CreateOutput() const
847 {
848     // Creates a link to output data TList
849     return fOutList;
850 }
851
852 TString  AliLRCProcess::GetShortDef() const
853 {
854     return fShortDef;
855 }
856
857 Int_t AliLRCProcess::GetOutputSlotNumber() const
858 {
859     // Returns number of output slot for LRCProcessor
860     return fOutputSlot;
861 }
862
863 void AliLRCProcess::StartEvent()
864 {
865     // Open new Event for track by track event import
866     if(fIsEventOpend)                     // Check if trying to open event more than once !
867     {
868         Printf("Event is already opened! Auto finishing ! \n");
869 //        cout<<fShortDef<<": event count = "<<fEventCount<<" ";
870         Printf("NchF = %i,NchB = %i \n",fNchFw,fNchBw);
871
872         FinishEvent();
873     }
874     if(!fIsOnline)                        // Autocreating histos if InitDataMembers was not called by hand
875     {
876         Printf("InitDataMembers was not called by hand ! Autocreating histos...\n");
877         InitDataMembers();
878     }
879
880     fNchFw=0;
881     fSumPtFw=0;
882     fNchBw=0;
883     fSumPtBw=0;
884     fSumPtBw2=0;
885     
886     fNchFwPlus = 0;
887     fNchBwPlus = 0;
888     fNchFwMinus = 0;
889     fNchBwMinus = 0;
890     
891     ZeroPidArrays();
892         
893     //fNchFwPtPt = 0;
894
895     fIsEventOpend=kTRUE;
896 }
897 void AliLRCProcess::AddTrackForward(Double_t Pt, Double_t Eta ,Double_t Phi, Short_t Charge, Int_t particleType  )
898 {
899     // Imports track to the event directly to Forward window
900     if(!fIsEventOpend)
901     {Printf("Event is not opened!\n");
902         return;}
903
904     //Bool_t lAddDecision = kFALSE;
905
906     //if ( fPidForward == 100 ) //add particle if we know pid (i.e. particleType != -1)
907     //{
908     //if ( particleType != -1 )
909     //{
910     //  lAddDecision = kTRUE;
911     //cout << "fill fwd with pid " << particleType << endl;
912     //}
913     //}
914     //else if ( fPidForward != -1 ) //if we specify pid for this window - just check it
915     //{
916     //if ( particleType == fPidForward )
917     //{
918     //lAddDecision = kTRUE;
919     //cout << "fill fwd with pid " << particleType << endl;
920     //}
921     //}
922     //else
923     //lAddDecision = kTRUE;
924
925     //if ( !lAddDecision )
926     //return;
927
928     fHistTestPIDForward->Fill( particleType );
929
930     fNchFw++;
931     Charge > 0 ? fNchFwPlus++ : fNchFwMinus++;
932     fSumPtFw+=Pt;
933     fHistPtForward->Fill(Pt);
934     fHistEtaForward->Fill(Eta);
935     fHistPhiForward->Fill(Phi);
936
937     //added 15.12.12
938     fHistTracksChargeForward->Fill(Charge);
939     
940     //added 23.03
941     for ( int pid = 0; pid < kSparsePIDtotal; pid++ )
942     {
943         if (   pid == kSparsePIDany //write ALL pid types
944                ||
945                ( pid == kSparsePIDdefined && particleType != -1 ) //write defined particles
946                ||
947                ( fCorrespondanceWithAliROOTpid[pid] == particleType ) //write not defined particles
948                )
949         {
950             fNchFwPID[pid]++;
951             Charge > 0 ? fNchFwPlusPID[pid]++ : fNchFwMinusPID[pid]++;
952             fSumPtFwPID[pid] += Pt;
953             if ( pid != kSparsePIDany )
954             {
955                 Double_t lMass = 0;//AliPID::ParticleMass( particleType );
956                 fSumEtFwPID[pid] += sqrt( Pt*Pt + lMass*lMass ) ;
957             }
958         }
959     }
960
961     //netcharge part (July 2013)
962     fHistNetChargeVsPtForward->Fill( Pt, Charge );
963     if ( Charge > 0 )
964         fHistPtPlusForward->Fill( Pt );
965     else if ( Charge < 0 )
966         fHistPtMinusForward->Fill( Pt );
967
968
969 }
970 void AliLRCProcess::AddTrackBackward(Double_t Pt, Double_t Eta ,Double_t Phi, Short_t Charge, Int_t particleType  )
971 {
972     // Imports track to the event directly to Backward window
973     if(!fIsEventOpend)
974     {Printf("Event is not opened!\n");
975         return;}
976
977     /*Bool_t lAddDecision = kFALSE;
978
979     if ( fPidBackward == 100 ) //add particle if we know pid (i.e. particleType != -1)
980     {
981         if ( particleType != -1 )
982         {
983             lAddDecision = kTRUE;
984             //cout << "fill fwd with pid " << particleType << endl;
985         }
986     }
987     else if ( fPidBackward != -1 ) //if we specify pid for this window - just check it
988     {
989         if ( particleType == fPidBackward )
990         {
991             lAddDecision = kTRUE;
992             //cout << "fill fwd with pid " << particleType << endl;
993         }
994     }
995     else
996         lAddDecision = kTRUE;
997
998     if ( !lAddDecision )
999         return;
1000         */
1001     fHistTestPIDBackward->Fill( particleType );
1002
1003     fNchBw++;
1004     Charge > 0 ? fNchBwPlus++ : fNchBwMinus++;
1005     fSumPtBw += Pt;
1006     fSumPtBw2 += Pt*Pt;
1007     fProfdPtB->Fill( 1, Pt );
1008     fProfdPtB->Fill( 2, Pt*Pt );
1009     fHistPtBackward->Fill( Pt );
1010     fHistEtaBackward->Fill( Eta );
1011     fHistPhiBackward->Fill( Phi );
1012
1013     //added 15.12.12
1014     fHistTracksChargeBackward->Fill(Charge);
1015
1016     //added 23.03
1017     for ( int pid = 0; pid < kSparsePIDtotal; pid++ )
1018     {
1019         if (   pid == kSparsePIDany //write ALL pid types
1020                ||
1021                ( pid == kSparsePIDdefined && particleType != -1 ) //write defined particles
1022                ||
1023                ( fCorrespondanceWithAliROOTpid[pid] == particleType )
1024                )
1025         {
1026             fNchBwPID[pid]++;
1027             Charge > 0 ? fNchBwPlusPID[pid]++ : fNchBwMinusPID[pid]++;
1028             fSumPtBwPID[pid] += Pt;
1029             if ( pid != kSparsePIDany )
1030             {
1031                 Double_t lMass = 0;//AliPID::ParticleMass( particleType );
1032                 fSumEtBwPID[pid] += sqrt( Pt*Pt + lMass*lMass ) ;
1033             }
1034             
1035         }
1036     }
1037
1038     //netcharge part (July 2013)
1039     fHistNetChargeVsPtBackward->Fill( Pt, Charge );
1040     if ( Charge > 0 )
1041         fHistPtPlusBackward->Fill( Pt );
1042     else if ( Charge < 0 )
1043         fHistPtMinusBackward->Fill( Pt );
1044
1045 }
1046
1047
1048
1049 void AliLRCProcess::AddTrackPtEta(Double_t Pt, Double_t Eta ,Double_t Phi, Short_t Charge, Int_t particleType  )
1050 {
1051     //cout << Pt << endl;
1052
1053
1054     //if particle type is different - ignore the track
1055     //if ( fWhichParticleToFill != -1 && ParticleType != fWhichParticleToFill )
1056     //  return;
1057     //Track by track event import :  Imports track to the event
1058
1059     //cout << "fWhichParticleToProcess = " << fWhichParticleToProcess
1060     //  << ", particleType = " << particleType << endl;
1061     if(!fIsEventOpend)
1062     {Printf("Event is not opened!\n");
1063         return;}
1064
1065     //  Global track data
1066     fHistPt->Fill(Pt);
1067     fHistEta->Fill(Eta);
1068
1069     //Bool_t lAddForwardDecision = kFALSE;
1070     //Bool_t lAddBackwardDecision = kFALSE;
1071
1072     //Forward window
1073     if( ( fStartForwardETA < Eta ) && ( Eta < fEndForwardETA ) )
1074         if( IsPhiInRange( Phi, fStartForwardPhi, fEndForwardPhi) )//( fStartForwardPhi < Phi ) && ( Phi < fEndForwardPhi ) )
1075         {
1076             AddTrackForward( Pt, Eta, Phi, Charge, particleType );
1077             //if ( fPidFillCondition == kLRCpidForForwardOnly
1078             //  || fPidFillCondition == kLRCpidForBoth )
1079             //if ( fPidForward != -1 )//kLRCany )
1080             //{
1081             //  if ( particleType == fPidForward )//kLRCpion )//particleType )
1082             //  {
1083             //          lAddForwardDecision = kTRUE;//AddTrackForward( Pt, Eta, Phi );
1084             //cout << "fill fwd with pid " << particleType << endl;
1085             //  }
1086             //}
1087             //else
1088             //  lAddForwardDecision = kTRUE;//AddTrackForward( Pt, Eta, Phi );
1089         }
1090     //if ( lAddForwardDecision )
1091     //{
1092     //  AddTrackForward( Pt, Eta, Phi, particleType );
1093     //  fHistTestPIDForward->Fill( particleType );
1094     //}
1095
1096     //Backward window
1097     if( ( fStartBackwardETA < Eta ) && ( Eta < fEndBackwardETA ) )
1098         if (
1099                 (
1100                     IsPhiInRange( Phi, fStartBackwardPhi, fEndBackwardPhi)  //( fStartBackwardPhi < Phi ) && ( Phi < fEndBackwardPhi )
1101                     )
1102                 ||
1103                 (
1104                     fDoubleSidedBackwardPhiWindow //if this option is true
1105                     && IsPhiInRange( Phi, fStartBackwardPhi + TMath::Pi(), fEndBackwardPhi + TMath::Pi() )  //
1106                     //&& ( fStartBackwardPhi + TMath::Pi() < Phi )
1107                     //&& ( Phi < fEndBackwardPhi + TMath::Pi() )
1108                     )
1109                 )
1110         {
1111             AddTrackBackward( Pt, Eta, Phi, Charge, particleType );
1112             //if ( fPidFillCondition == kLRCpidForBackwardOnly
1113             //  || fPidFillCondition == kLRCpidForBoth )
1114             //if ( fPidBackward != -1 )//kLRCany )
1115             //{
1116             //  if ( particleType == fPidBackward )//kLRCpion )//particleType )
1117             //  {
1118             //          lAddBackwardDecision = kTRUE;//AddTrackBackward( Pt, Eta, Phi );
1119             //cout << "fill bkwd with pid " << particleType << endl;
1120             //  }
1121
1122             //}
1123             //else
1124             //  lAddBackwardDecision = kTRUE;//AddTrackBackward( Pt, Eta, Phi );
1125         }
1126     //if ( lAddBackwardDecision )
1127     //{
1128     //  AddTrackBackward( Pt, Eta, Phi, particleType );
1129     //  fHistTestPIDBackward->Fill( particleType );
1130     //}
1131
1132 }
1133
1134
1135
1136 void AliLRCProcess::AddTrackPtEtaMixing( Int_t winFB, Double_t Pt, Double_t Eta ,Double_t Phi, Short_t Charge, Int_t particleType  )
1137 {
1138     // put track in F or B window using varible winFB
1139     if(!fIsEventOpend)
1140     {
1141         Printf("Event is not opened!\n");
1142         return;
1143     }
1144
1145     //  Global track data
1146     fHistPt->Fill(Pt);
1147     fHistEta->Fill(Eta);
1148
1149
1150     //Forward window
1151     if( winFB == 0
1152             && ( fStartForwardETA < Eta ) && ( Eta < fEndForwardETA ) )
1153         if( IsPhiInRange( Phi, fStartForwardPhi, fEndForwardPhi) ) // (fStartForwardPhi < Phi ) && ( Phi < fEndForwardPhi ) )
1154         {
1155             AddTrackForward( Pt, Eta, Phi, Charge, particleType );
1156         }
1157
1158     //Backward window
1159     if( winFB == 1
1160             && ( fStartBackwardETA < Eta ) && ( Eta < fEndBackwardETA ) )
1161         if (
1162                 (
1163                     IsPhiInRange( Phi, fStartBackwardPhi, fEndBackwardPhi)  //( fStartBackwardPhi < Phi ) && ( Phi < fEndBackwardPhi )
1164                     )
1165                 ||
1166                 (
1167                     fDoubleSidedBackwardPhiWindow //if this option is true
1168                     && IsPhiInRange( Phi, fStartBackwardPhi + TMath::Pi(), fEndBackwardPhi + TMath::Pi() )
1169                     //&& ( fStartBackwardPhi + TMath::Pi() < Phi )
1170                     //&& ( Phi < fEndBackwardPhi + TMath::Pi() )
1171                     )
1172                 )
1173         {
1174             AddTrackBackward( Pt, Eta, Phi, Charge, particleType );
1175         }
1176
1177
1178 }
1179
1180 void AliLRCProcess::FinishEvent(Bool_t kDontCount)
1181 {
1182     // Track by track event import : Close opened event and fill event summary histos
1183
1184     if(!fIsEventOpend)
1185     {
1186         Printf("Event is not opened!\n");
1187         return;
1188     }
1189     if ( kDontCount ) //don't count this event! just ignore it
1190     {
1191         fIsEventOpend = kFALSE;
1192         return;
1193     }
1194     //fHistSparseDimensionLabeling->Fill(1);
1195     //Filling even-total data
1196     //cout << "filling" << endl;
1197     /*Double_t lCloudData[en_sparse_total*en_sparse_PID_total];
1198     lCloudData[en_sparse_N_f] = fNchFw;     //write Nf
1199     lCloudData[en_sparse_N_b] = fNchBw;     //write Nb
1200     lCloudData[en_sparse_N2_f] = fNchFw*fNchFw;     //write Nf^2
1201     lCloudData[en_sparse_Nf_Nb] = fNchFw*fNchBw;     //write Nb
1202     
1203     lCloudData[en_sparse_Pt_f] = 0; //fill bin 0, if don't have appropriate PtSum
1204     lCloudData[en_sparse_Pt_b] = 0; //fill bin 0, if don't have appropriate PtSum
1205
1206     lCloudData[en_sparse_Nf_plus] = fNchFwPlus;
1207     lCloudData[en_sparse_Nf_minus] = fNchFwMinus;
1208     lCloudData[en_sparse_Nb_plus] = fNchBwPlus;
1209     lCloudData[en_sparse_Nb_minus] = fNchBwMinus;
1210     lCloudData[en_sparse_Nf_plus_Nb_minus] = fNchFwPlus * fNchBwMinus;
1211     lCloudData[en_sparse_Nb_plus_Nf_minus] = fNchBwPlus * fNchFwMinus; */
1212     
1213     fHistNN->Fill(fNchFw,fNchBw);
1214
1215     if ( fUseAccumulatingHist )
1216     {
1217         fArrAccumulatedValues->Fill( en_arr_labels_NN_Nevents,   1                  );
1218         fArrAccumulatedValues->Fill( en_arr_labels_NN_Nf     ,   fNchFw             );
1219         fArrAccumulatedValues->Fill( en_arr_labels_NN_Nb     ,   fNchBw             );
1220         fArrAccumulatedValues->Fill( en_arr_labels_NN_N2_f   ,   fNchFw*fNchFw      );
1221         fArrAccumulatedValues->Fill( en_arr_labels_NN_Nf_Nb  ,   fNchFw*fNchBw      );
1222         fArrAccumulatedValues->Fill( en_arr_labels_NN_N2_b   ,   fNchBw*fNchBw      );
1223     }
1224
1225     if( fNchBw != 0 )
1226     {
1227         fSumPtBw = fSumPtBw / fNchBw;
1228         //lCloudData[en_sparse_Pt_b] = fSumPtBw; //write <PtB>
1229         fProfTestLRC->Fill( fNchFw, fSumPtBw );
1230         fHistPtN->Fill( fNchFw, fSumPtBw );
1231         //cout << "fill PtN: fNchFw = " << fNchFw << ", fSumPtBw=" << fSumPtBw <<  endl;
1232         fProfNberr->Fill(fNchFw, 1.0 / fNchBw);
1233
1234         if ( fUseAccumulatingHist )
1235         {
1236             fArrAccumulatedValues->Fill( en_arr_labels_PtN_Nevents,  1                  );
1237             fArrAccumulatedValues->Fill( en_arr_labels_PtN_Nf     ,  fNchFw             );
1238             fArrAccumulatedValues->Fill( en_arr_labels_PtN_PtB    ,  fSumPtBw           );
1239             fArrAccumulatedValues->Fill( en_arr_labels_PtN_N2_f   ,  fNchFw*fNchFw      );
1240             fArrAccumulatedValues->Fill( en_arr_labels_PtN_Ptb_Nf ,  fSumPtBw*fNchFw    );
1241         }
1242
1243         if( fNchFw != 0 )
1244         {
1245             fSumPtFw = fSumPtFw / fNchFw;
1246             //lCloudData[en_sparse_Pt_f] = fSumPtFw; //write <PtF>
1247             fHistPtPt->Fill( fSumPtFw, fSumPtBw );
1248             fProfNberrPtPt->Fill( fSumPtFw, 1.0 / fNchBw );
1249             // dPtB for PtPt
1250             fProfdPtB->Fill( 15, fSumPtBw, fNchBw );
1251             fProfdPtB->Fill( 16, fSumPtBw2 / fNchBw, fNchBw );
1252             fHistNchForwardPtPt->Fill(fNchFw);
1253
1254             if ( fUseAccumulatingHist )
1255             {
1256                 fArrAccumulatedValues->Fill( en_arr_labels_PtPt_Nevents,   1                   );
1257                 fArrAccumulatedValues->Fill( en_arr_labels_PtPt_PtF    ,   fSumPtFw            );
1258                 fArrAccumulatedValues->Fill( en_arr_labels_PtPt_PtB    ,   fSumPtBw            );
1259                 fArrAccumulatedValues->Fill( en_arr_labels_PtPt_Pt2_f  ,   fSumPtFw*fSumPtFw   );
1260                 fArrAccumulatedValues->Fill( en_arr_labels_PtPt_Ptf_Ptb,   fSumPtBw*fSumPtFw   );
1261             }
1262
1263         }
1264     }
1265
1266
1267
1268
1269
1270     if ( fUseSparse )
1271     {
1272         Double_t lCloudData[kSparseTotal*kSparsePIDtotal];
1273
1274         for (Int_t d = 0; d < kSparsePIDtotal; ++d)
1275         {
1276             Int_t binShift = kSparseTotal*d; //step over dimension set
1277
1278             lCloudData[kSparseNf + binShift ] = fNchFwPID[d];     //write Nf
1279             lCloudData[kSparseNb + binShift ] = fNchBwPID[d];     //write Nb
1280             lCloudData[en_sparse_N2_f + binShift ] = fNchFwPID[d]*fNchFwPID[d];     //write Nf^2
1281             lCloudData[en_sparse_Nf_Nb + binShift ] = fNchFwPID[d]*fNchBwPID[d];     //write Nb
1282
1283             lCloudData[kSparsePtF + binShift ] = 0; //fill bin 0, if don't have appropriate PtSum
1284             lCloudData[kSparsePtB + binShift ] = 0; //fill bin 0, if don't have appropriate PtSum
1285
1286             lCloudData[en_sparse_Ptb_Nf + binShift ] = 0;
1287             lCloudData[en_sparse_Pt2_f + binShift ] = 0;
1288             lCloudData[en_sparse_Ptf_Ptb + binShift ] = 0;
1289
1290
1291             if( fNchBwPID[d] != 0 )
1292             {
1293                 double lSumPtBwPID = fSumPtBwPID[d] / fNchBwPID[d];
1294                 lCloudData[kSparsePtB + binShift ] = lSumPtBwPID; //write <PtB>
1295
1296                 fSumEtBwPID[d] = fSumEtBwPID[d] / fNchBwPID[d];
1297                 //lCloudData[en_sparse_Et_b + binShift ] = fSumEtBwPID[d]; //write <PtB>
1298                 lCloudData[en_sparse_Ptb_Nf + binShift ] = lSumPtBwPID * fNchFwPID[d];
1299
1300                 //fProfTestLRC->Fill( fNchFw, fSumPtBw );
1301                 //fHistPtN->Fill( fNchFw, fSumPtBw );
1302                 //cout << "fill PtN: fNchFw = " << fNchFw << ", fSumPtBw=" << fSumPtBw <<  endl;
1303
1304                 //fProfNberr->Fill(fNchFw, 1.0 / fNchBw);
1305
1306
1307                 if( fNchFwPID[d] != 0 )
1308                 {
1309                     double lSumPtFwPID = fSumPtFwPID[d] / fNchFwPID[d];
1310                     lCloudData[kSparsePtF + binShift ] = lSumPtFwPID; //write <PtF>
1311
1312                     fSumEtFwPID[d] = fSumEtFwPID[d] / fNchFwPID[d];
1313
1314                     lCloudData[en_sparse_Pt2_f + binShift ] = lSumPtFwPID * lSumPtFwPID;
1315                     lCloudData[en_sparse_Ptf_Ptb + binShift ] = lSumPtFwPID*lSumPtBwPID;
1316
1317                     //lCloudData[en_sparse_Et_f + binShift ] = fSumEtFwPID[d]; //write <PtF>
1318                     //fHistPtPt->Fill( fSumPtFw, fSumPtBw );
1319                     //fProfNberrPtPt->Fill( fSumPtFw, 1.0 / fNchBw );
1320                     // dPtB for PtPt
1321                     //fProfdPtB->Fill( 15, fSumPtBw, fNchBw );
1322                     //fProfdPtB->Fill( 16, fSumPtBw2 / fNchBw, fNchBw );
1323                     //fHistNchForwardPtPt->Fill(fNchFw);
1324
1325                 }
1326             }
1327             /*
1328             lCloudData[en_sparse_Nf_plus + binShift ] = fNchFwPlusPID[d];
1329             lCloudData[en_sparse_Nf_minus + binShift ] = fNchFwMinusPID[d];
1330             lCloudData[en_sparse_Nb_plus + binShift ] = fNchBwPlusPID[d];
1331             lCloudData[en_sparse_Nb_minus + binShift ] = fNchBwMinusPID[d];
1332             lCloudData[en_sparse_Nf_plus_Nb_minus + binShift ] = fNchFwPlusPID[d] * fNchBwMinusPID[d];
1333             lCloudData[en_sparse_Nb_plus_Nf_minus + binShift ] = fNchBwPlusPID[d] * fNchFwMinusPID[d];
1334              */
1335         }
1336
1337         //tmp (22.03): fill pid with fignya data
1338         /* for (Int_t d = 1; d < en_sparse_PID_total; ++d)
1339         {
1340             Int_t binShift = en_sparse_total*d;
1341             lCloudData[en_sparse_N_f + binShift ] = 1+d;     //write Nf
1342             lCloudData[en_sparse_N_b + binShift ] = 2+d;     //write Nb
1343             lCloudData[en_sparse_N2_f + binShift ] = 3+d;     //write Nf^2
1344             lCloudData[en_sparse_Nf_Nb + binShift ] = 4+d;     //write Nb
1345
1346             lCloudData[en_sparse_Pt_f + binShift ] = 5+d; //fill bin 0, if don't have appropriate PtSum
1347             lCloudData[en_sparse_Pt_b + binShift ] = 6+d; //fill bin 0, if don't have appropriate PtSum
1348
1349             lCloudData[en_sparse_Nf_plus + binShift ] = 7+d;
1350             lCloudData[en_sparse_Nf_minus + binShift ] = 8+d;
1351             lCloudData[en_sparse_Nb_plus + binShift ] = 9+d;
1352             lCloudData[en_sparse_Nb_minus + binShift ] = 10+d;
1353             lCloudData[en_sparse_Nf_plus_Nb_minus + binShift ] = 11+d;
1354             lCloudData[en_sparse_Nb_plus_Nf_minus + binShift ] = 12+d;
1355         }
1356     */
1357
1358         //    cout << "before filling" << endl;
1359         fHistClouds->Fill( lCloudData ); //fill sparse hist with Nf, Nb, <PtF>, <PtB>
1360         //        cout << "filled." << endl;
1361     }
1362
1363
1364
1365
1366     //additional info-hist
1367     if ( fNchFw > 0 || fNchBw > 0 )
1368     {
1369         Double_t lAvMult = ( fNchFw + fNchBw ) / 2.;
1370         fHistDifferenceNf->Fill( fNchFw, ( fNchFw-fNchBw ) / lAvMult );
1371         fHistDifferenceNb->Fill( fNchBw, ( fNchBw-fNchFw ) / lAvMult);
1372     }
1373
1374     //cout << "n particles: " << fNchFw << " , Back = " << fNchBw << endl;
1375     //cout << "fHistNN: " << fHistNN->GetEntries() <<  endl;
1376     //cout << "mean= " << fHistNN->GetMean() <<  endl;
1377
1378
1379     fHistNchForward->Fill(fNchFw);
1380     fHistNchBackward->Fill(fNchBw);
1381
1382     fEventCount++;
1383     fIsEventOpend = kFALSE;
1384     
1385     //fill nf-centr plot
1386     fHistNfCentrality->Fill( fNchFw, fEventCentrality );
1387     
1388     //cout<<fShortDef<<": event count = "<<fEventCount<<" ";
1389     //   Printf("NchF = %i,NchB = %i",fNchFw,fNchBw);
1390 }
1391
1392 Bool_t AliLRCProcess::IsPhiInRange( Double_t phi, Double_t phiBoundMin, Double_t phiBoundMax )
1393 {
1394     if ( ( phiBoundMin < phi ) && ( phi < phiBoundMax ) )
1395         return kTRUE;
1396
1397     //when bound is more than 2pi - check phi+2pi!
1398     phi += 2 * TMath::Pi();
1399     if ( ( phiBoundMin < phi ) && ( phi < phiBoundMax ) )
1400         return kTRUE;
1401
1402     return kFALSE; //phi not in range
1403 }
1404
1405 void AliLRCProcess::SetCorrespondanceWithAliROOTpid()
1406 {
1407     fCorrespondanceWithAliROOTpid[kSparsePIDany] = kSparsePIDany;
1408     fCorrespondanceWithAliROOTpid[kSparsePIDdefined] = -1000;
1409     fCorrespondanceWithAliROOTpid[kSparsePIDpion] = 2;
1410     fCorrespondanceWithAliROOTpid[kSparsePIDkaon] = 3;
1411     fCorrespondanceWithAliROOTpid[kSparsePIDproton] = 4;
1412 }
1413
1414 void AliLRCProcess::ZeroPidArrays()
1415 {
1416     //added 23.03
1417     for ( int pid = 0; pid < kSparsePIDtotal; pid++ )
1418     {
1419         fNchFwPID[pid] = 0;
1420         fNchFwPlusPID[pid] = 0;
1421         fNchFwMinusPID[pid] = 0;
1422         fSumPtFwPID[pid] = 0;
1423         fSumEtFwPID[pid] = 0;
1424
1425         fNchBwPID[pid] = 0;
1426         fNchBwPlusPID[pid] = 0;
1427         fNchBwMinusPID[pid] = 0;
1428         fSumPtBwPID[pid] = 0;
1429         fSumEtBwPID[pid] = 0;
1430     }
1431 }