]> git.uio.no Git - u/mrichter/AliRoot.git/blob - FMD/analysis/AliFMDAnalysisTaskSharing.cxx
Various small fixes
[u/mrichter/AliRoot.git] / FMD / analysis / AliFMDAnalysisTaskSharing.cxx
1  
2 #include <TROOT.h>
3 #include <TSystem.h>
4 #include <TInterpreter.h>
5 #include <TChain.h>
6 #include <TFile.h>
7 #include <TList.h>
8 #include <iostream>
9
10 #include "AliFMDAnalysisTaskSharing.h"
11 #include "AliAnalysisManager.h"
12 #include "AliESDFMD.h"
13 #include "AliMCEventHandler.h"
14 #include "AliStack.h"
15 #include "AliESDVertex.h"
16 #include "AliFMDAnaParameters.h"
17
18 ClassImp(AliFMDAnalysisTaskSharing)
19
20 //_____________________________________________________________________
21 AliFMDAnalysisTaskSharing::AliFMDAnalysisTaskSharing()
22 : fDebug(0),
23   fESD(0x0),
24   fOutputESD(),
25   foutputESDFMD(),
26   fSharedThis(kFALSE),
27   fSharedPrev(kFALSE)
28 {
29   // Default constructor
30   DefineInput (0, AliESDEvent::Class());
31   DefineOutput(0, AliESDEvent::Class());
32 }
33 //_____________________________________________________________________
34 AliFMDAnalysisTaskSharing::AliFMDAnalysisTaskSharing(const char* name):
35     AliAnalysisTask(name, "AnalysisTaskFMD"),
36     fDebug(0),
37     fESD(0x0),
38     fOutputESD(),
39     foutputESDFMD(),
40     fSharedThis(kFALSE),
41     fSharedPrev(kFALSE)
42
43 {
44   DefineInput (0, AliESDEvent::Class());
45   DefineOutput(0, AliESDEvent::Class());
46 }
47 //_____________________________________________________________________
48 void AliFMDAnalysisTaskSharing::CreateOutputObjects()
49 {
50   fOutputESD.CreateStdContent();
51 }
52 //_____________________________________________________________________
53 void AliFMDAnalysisTaskSharing::ConnectInputData(Option_t */*option*/)
54 {
55   fESD = (AliESDEvent*)GetInputData(0);
56 }
57 //_____________________________________________________________________
58 void AliFMDAnalysisTaskSharing::Exec(Option_t */*option*/)
59 {
60   AliESD* old = fESD->GetAliESDOld();
61   if (old) {
62     fESD->CopyFromOldESD();
63   }
64   
65   foutputESDFMD.Clear();
66   
67   fOutputESD.SetPrimaryVertexSPD(fESD->GetPrimaryVertexSPD());
68   
69   AliESDFMD* fmd = fESD->GetFMDData();
70   
71   if (!fmd) return;
72   
73   for(UShort_t det=1;det<=3;det++) {
74     Int_t nRings = (det==1 ? 1 : 2);
75     for (UShort_t ir = 0; ir < nRings; ir++) {
76       Char_t   ring = (ir == 0 ? 'I' : 'O');
77       UShort_t nsec = (ir == 0 ? 20  : 40);
78       UShort_t nstr = (ir == 0 ? 512 : 256);
79       for(UShort_t sec =0; sec < nsec;  sec++) {
80         fSharedThis      = kFALSE;
81         fSharedPrev      = kFALSE;
82         for(UShort_t strip = 0; strip < nstr; strip++) {
83           foutputESDFMD.SetMultiplicity(det,ring,sec,strip,0.);
84           Float_t mult = fmd->Multiplicity(det,ring,sec,strip);
85           if(mult == AliESDFMD::kInvalidMult || mult == 0) continue;
86                   
87           Float_t Eprev = 0;
88           Float_t Enext = 0;
89           if(strip != 0)
90             if(fmd->Multiplicity(det,ring,sec,strip-1) != AliESDFMD::kInvalidMult)
91               Eprev = fmd->Multiplicity(det,ring,sec,strip-1);
92           if(strip != nstr - 1)
93             if(fmd->Multiplicity(det,ring,sec,strip+1) != AliESDFMD::kInvalidMult)
94             Enext = fmd->Multiplicity(det,ring,sec,strip+1);
95           
96           Float_t nParticles = GetMultiplicityOfStrip(mult,Eprev,Enext,det,ring);
97           foutputESDFMD.SetMultiplicity(det,ring,sec,strip,nParticles);
98           foutputESDFMD.SetEta(det,ring,sec,strip,fmd->Eta(det,ring,sec,strip));
99                   
100         }
101       }
102     }
103   }
104   fOutputESD.SetFMDData(&foutputESDFMD);
105     
106   PostData(0, &fOutputESD); 
107   
108 }
109 //_____________________________________________________________________
110 Float_t AliFMDAnalysisTaskSharing::GetMultiplicityOfStrip(Float_t mult,
111                                                           Float_t Eprev,
112                                                           Float_t Enext,
113                                                           Int_t   det,
114                                                           Char_t  ring) {
115   AliFMDAnaParameters* pars = AliFMDAnaParameters::Instance();
116   Float_t nParticles = 0;
117   Float_t cutLow  = 0.2;
118   Float_t cutHigh = pars->GetMPV(det,ring) - 2*pars->GetSigma(det,ring);
119   Float_t Etotal = mult;
120   /* 
121   if(mult > 3*pars->GetMPV(det,ring) && 
122      (Enext > 3*pars->GetMPV(det,ring) || (Enext > 3*pars->GetMPV(det,ring))))
123     return 0;
124   
125   if(mult > 5*pars->GetMPV(det,ring))
126     return 0;
127   */
128   if(fSharedThis) {
129     fSharedThis      = kFALSE;
130     fSharedPrev      = kTRUE;
131     return 0.;
132   }
133   
134   if(Etotal < 0.33*pars->GetMPV(det,ring)) {
135     fSharedThis      = kFALSE;
136     fSharedPrev      = kFALSE;
137     return 0.; 
138   }
139   
140   if(Eprev > cutLow && Eprev < cutHigh && !fSharedPrev ) {
141     Etotal += Eprev;
142   }
143   
144   if(Enext > cutLow && Enext < cutHigh ) {
145     Etotal += Enext;
146     fSharedThis      = kTRUE;
147   }
148   
149   if(Etotal > cutHigh ) {
150     nParticles = 1;
151     fSharedPrev      = kTRUE;
152   }
153   else {
154     fSharedThis      = kFALSE;
155     fSharedPrev      = kFALSE;
156   }
157   
158   return nParticles;
159 }
160
161 //_____________________________________________________________________
162 //
163 // EOF
164 //