4 #include <TInterpreter.h>
10 //#include "AliFMDDebug.h"
11 #include "AliFMDAnalysisTaskSharing.h"
12 #include "AliAnalysisManager.h"
13 #include "AliESDFMD.h"
14 //#include "AliFMDGeometry.h"
15 #include "AliMCEventHandler.h"
17 #include "AliESDVertex.h"
18 #include "AliMultiplicity.h"
19 #include "AliFMDAnaParameters.h"
20 //#include "AliFMDParameters.h"
22 ClassImp(AliFMDAnalysisTaskSharing)
24 //_____________________________________________________________________
25 AliFMDAnalysisTaskSharing::AliFMDAnalysisTaskSharing()
38 // Default constructor
39 DefineInput (0, AliESDEvent::Class());
40 DefineOutput(0, AliESDFMD::Class());
41 DefineOutput(1, AliESDVertex::Class());
42 DefineOutput(2, AliESDEvent::Class());
43 DefineOutput(3, TList::Class());
45 //_____________________________________________________________________
46 AliFMDAnalysisTaskSharing::AliFMDAnalysisTaskSharing(const char* name, Bool_t SE):
47 AliAnalysisTask(name, "AnalysisTaskFMD"),
62 DefineInput (0, AliESDEvent::Class());
63 DefineOutput(0, AliESDFMD::Class());
64 DefineOutput(1, AliESDVertex::Class());
65 DefineOutput(2, AliESDEvent::Class());
66 DefineOutput(3, TList::Class());
69 //_____________________________________________________________________
70 void AliFMDAnalysisTaskSharing::CreateOutputObjects()
73 foutputESDFMD = new AliESDFMD();
76 fEsdVertex = new AliESDVertex();
79 fDiagList = new TList();
81 fDiagList->SetName("Sharing diagnostics");
82 for(Int_t det = 1; det<=3; det++) {
83 Int_t nRings = (det==1 ? 1 : 2);
85 for(Int_t iring = 0;iring<nRings; iring++) {
86 Char_t ringChar = (iring == 0 ? 'I' : 'O');
87 TH1F* hEdist = new TH1F(Form("Edist_before_sharing_FMD%d%c", det, ringChar),
88 Form("Edist_before_sharing_FMD%d%c", det, ringChar),
90 TH1F* hEdist_after = new TH1F(Form("Edist_after_sharing_FMD%d%c", det, ringChar),
91 Form("Edist_after_sharing_FMD%d%c", det, ringChar),
95 TH1F* hNstripsHit = new TH1F(Form("N_strips_hit_FMD%d%c",det,ringChar),
96 Form("N_strips_hit_FMD%d%c",det,ringChar),
98 fDiagList->Add(hEdist);
99 fDiagList->Add(hEdist_after);
100 fDiagList->Add(hNstripsHit);
105 //_____________________________________________________________________
106 void AliFMDAnalysisTaskSharing::ConnectInputData(Option_t */*option*/)
109 fESD = (AliESDEvent*)GetInputData(0);
111 //_____________________________________________________________________
112 void AliFMDAnalysisTaskSharing::Exec(Option_t */*option*/)
115 AliESD* old = fESD->GetAliESDOld();
117 fESD->CopyFromOldESD();
120 foutputESDFMD->Clear();
124 fEsdVertex->SetXYZ(vertex);
126 if(vertex[0] == 0 && vertex[1] == 0 && vertex[2] == 0) {
133 const AliMultiplicity* testmult = fESD->GetMultiplicity();
135 Int_t nTrackLets = testmult->GetNumberOfTracklets();
136 if(nTrackLets < 1000) foutputESDFMD->SetUniqueID(kTRUE);
137 else foutputESDFMD->SetUniqueID(kFALSE);
139 AliESDFMD* fmd = fESD->GetFMDData();
140 AliFMDAnaParameters* pars = AliFMDAnaParameters::Instance();
143 for(UShort_t det=1;det<=3;det++) {
144 Int_t nRings = (det==1 ? 1 : 2);
145 for (UShort_t ir = 0; ir < nRings; ir++) {
146 Char_t ring = (ir == 0 ? 'I' : 'O');
147 UShort_t nsec = (ir == 0 ? 20 : 40);
148 UShort_t nstr = (ir == 0 ? 512 : 256);
150 TH1F* hEdist = (TH1F*)fDiagList->FindObject(Form("Edist_before_sharing_FMD%d%c",det,ring));
152 for(UShort_t sec =0; sec < nsec; sec++) {
153 fSharedThis = kFALSE;
154 fSharedPrev = kFALSE;
157 for(UShort_t strip = 0; strip < nstr; strip++) {
158 foutputESDFMD->SetMultiplicity(det,ring,sec,strip,0.);
159 Float_t mult = fmd->Multiplicity(det,ring,sec,strip);
161 if(mult == AliESDFMD::kInvalidMult || mult == 0) continue;
163 //Double_t eta = EtaFromStrip(det,ring,sec,strip,vertex[2]);//fmd->Eta(det,ring,sec,strip);
164 //Double_t eta = fmd->Eta(det,ring,sec,strip);
165 Float_t eta = pars->GetEtaFromStrip(det,ring,sec,strip,vertex[2]);
166 //std::cout<<EtaFromStrip(det,ring,sec,strip,vertex[2]) <<" "<<fmd->Eta(det,ring,sec,strip)<<std::endl;
169 if(fmd->IsAngleCorrected())
170 mult = mult/TMath::Cos(Eta2Theta(eta));
174 if(fmd->Multiplicity(det,ring,sec,strip-1) != AliESDFMD::kInvalidMult) {
175 Eprev = fmd->Multiplicity(det,ring,sec,strip-1);
176 if(fmd->IsAngleCorrected())
177 Eprev = Eprev/TMath::Cos(Eta2Theta(fmd->Eta(det,ring,sec,strip-1)));
179 if(strip != nstr - 1)
180 if(fmd->Multiplicity(det,ring,sec,strip+1) != AliESDFMD::kInvalidMult) {
181 Enext = fmd->Multiplicity(det,ring,sec,strip+1);
182 if(fmd->IsAngleCorrected())
183 Enext = Enext/TMath::Cos(Eta2Theta(fmd->Eta(det,ring,sec,strip+1)));
186 Float_t merged_energy = GetMultiplicityOfStrip(mult,eta,Eprev,Enext,det,ring,sec,strip);
188 if(merged_energy > 0 )
190 foutputESDFMD->SetMultiplicity(det,ring,sec,strip,merged_energy);
191 foutputESDFMD->SetEta(det,ring,sec,strip,eta);
199 PostData(0, foutputESDFMD);
200 PostData(1, fEsdVertex);
202 PostData(3, fDiagList);
205 //_____________________________________________________________________
206 Float_t AliFMDAnalysisTaskSharing::GetMultiplicityOfStrip(Float_t mult,
213 UShort_t /*strip*/) {
214 AliFMDAnaParameters* pars = AliFMDAnaParameters::Instance();
216 Float_t merged_energy = 0;
217 //Float_t nParticles = 0;
218 Float_t cutLow = 0.15;
223 //AliFMDParameters* recopars = AliFMDParameters::Instance();
224 //cutLow = (5*recopars->GetPedestalWidth(det,ring,sec,strip))/(recopars->GetPulseGain(det,ring,sec,strip)*recopars->GetDACPerMIP());
228 Float_t cutHigh = pars->GetMPV(det,ring,eta) - 3*pars->GetSigma(det,ring,eta);
229 // Float_t cutPart = pars->GetMPV(det,ring,eta) - 5*pars->GetSigma(det,ring,eta);
230 Float_t Etotal = mult;
233 // std::cout<<mult<<" "<<det<<" "<<ring<<" "<<sec<<" "<<strip<<std::endl;
234 //Float_t slow_particle_cut = 2*pars->GetMPV(det,ring,eta);
236 //if(recopars->IsDead(det,ring,sec,strip))
237 // std::cout<<"dead channel"<<std::endl;
238 //if(foutputESDFMD->GetUniqueID() == kTRUE) {
239 // Float_t mpv = pars->GetMPV(det,ring,eta);
242 if(foutputESDFMD->GetUniqueID() == kFALSE) {
248 fEnergy = fEnergy + mult;
252 if( (Enext < cutLow && fEnergy > 0 ) || fNstrips >2 ){
254 //if((fEnergy*TMath::Cos(Eta2Theta(eta))) > cutPart || fNstrips > 1) {
256 merged_energy = fEnergy*TMath::Cos(Eta2Theta(eta));
257 TH1F* hEdist = (TH1F*)fDiagList.FindObject(Form("Edist_after_sharing_FMD%d%c",det,ring));
258 hEdist->Fill(fEnergy);
259 TH1F* hNstrips = (TH1F*)fDiagList.FindObject(Form("N_strips_hit_FMD%d%c",det,ring));
260 hNstrips->Fill(fNstrips);
261 // std::cout<<Form("Merged signals %f %f %f into %f , %f in det %d, ring %c, sec %d, strip %d",Eprev, mult, Enext, fEnergy/TMath::Cos(Eta2Theta(eta)),fEnergy,det,ring,sec,strip )<<std::endl;
265 //std::cout<<Form("NO HIT for %f %f %f into %f , %f in strip %d, sec %d, ring %c, det %d, cuts %f , %f",Eprev, mult, Enext, fEnergy/TMath::Cos(Eta2Theta(eta)),fEnergy,strip,sec,ring,det,cutPart,cutHigh )<<std::endl;
270 return merged_energy;
278 //std::cout<<det<<ring<<" "<<sec<<" "<<strip<<" "<<cutLow<<std::endl;
280 fSharedThis = kFALSE;
285 /* if(mult < 0.33*pars->GetMPV(det,ring,eta)) {
286 fSharedThis = kFALSE;
287 fSharedPrev = kFALSE;
290 if(mult<Enext && Enext>cutHigh && foutputESDFMD->GetUniqueID() == kTRUE)
292 fSharedThis = kFALSE;
293 fSharedPrev = kFALSE;
298 // std::cout<<"rejecting hit in FMD "<<det<<" "<<ring<<std::endl;
299 fSharedThis = kFALSE;
300 fSharedPrev = kFALSE;
304 if(Eprev > cutLow && Eprev < cutHigh && !fSharedPrev ) {
308 if(Enext > cutLow && Enext < cutHigh ) {
312 TH1F* hEdist = (TH1F*)fDiagList->FindObject(Form("Edist_after_sharing_FMD%d%c",det,ring));
313 hEdist->Fill(Etotal);
315 Etotal = Etotal*TMath::Cos(Eta2Theta(eta));
318 merged_energy = Etotal;
320 // if(det == 1 && ring =='I')
321 // std::cout<<Form("Merged signals %f %f %f into %f , %f in strip %d, sec %d, ring %c, det %d",Eprev, mult, Enext, Etotal/TMath::Cos(Eta2Theta(eta)),Etotal,strip,sec,ring,det )<<std::endl;
323 else{// if(Etotal > 0) {
324 //if(det == 3 && ring =='I')
325 // std::cout<<Form("NO HIT for %f %f %f into %f , %f in strip %d, sec %d, ring %c, det %d, cuts %f , %f",Eprev, mult, Enext, Etotal/TMath::Cos(Eta2Theta(eta)),Etotal,strip,sec,ring,det,cutPart,cutHigh )<<std::endl;
326 fSharedThis = kFALSE;
327 fSharedPrev = kFALSE;
329 // merged_energy = mult;
331 return merged_energy;
334 //_____________________________________________________________________
335 void AliFMDAnalysisTaskSharing::GetVertex(Double_t* vertexXYZ)
337 const AliESDVertex* vertex = 0;
338 vertex = fESD->GetPrimaryVertex();
339 if(!vertex || (vertexXYZ[0] == 0 && vertexXYZ[1] == 0 && vertexXYZ[2] == 0))
340 vertex = fESD->GetPrimaryVertexSPD();
341 if(!vertex || (vertexXYZ[0] == 0 && vertexXYZ[1] == 0 && vertexXYZ[2] == 0))
342 vertex = fESD->GetPrimaryVertexTPC();
343 if(!vertex || (vertexXYZ[0] == 0 && vertexXYZ[1] == 0 && vertexXYZ[2] == 0))
344 vertex = fESD->GetVertex();
345 if (vertex && (vertexXYZ[0] != 0 || vertexXYZ[1] != 0 || vertexXYZ[2] != 0)) {
346 vertex->GetXYZ(vertexXYZ);
347 //std::cout<<vertex->GetName()<<" "<< vertex->GetTitle() <<" "<< vertex->GetZv()<<std::endl;
350 else if (fESD->GetESDTZERO()) {
353 vertexXYZ[2] = fESD->GetT0zVertex();
361 //_____________________________________________________________________
362 Float_t AliFMDAnalysisTaskSharing::Eta2Theta(Float_t eta) {
364 Float_t theta = 2*TMath::ATan(TMath::Exp(-1*eta));
367 theta = theta-TMath::Pi();
369 // std::cout<<"From eta2Theta: "<<theta<<" "<<eta<<std::endl;
375 //_____________________________________________________________________
376 /*Double_t AliFMDAnalysisTaskSharing::EtaFromStrip(UShort_t det,
383 AliFMDGeometry* geo = AliFMDGeometry::Instance();
386 geo->Detector2XYZ(det,ring,sector,strip,x,y,z);
388 Double_t r = TMath::Sqrt(x*x+y*y);
390 Double_t z_real = z-zvtx;
391 Double_t theta = TMath::ATan2(r,z_real);
392 // std::cout<<"From EtaFromStrip "<<theta<<std::endl;
393 Double_t eta = -1*TMath::Log(TMath::Tan(0.5*theta));
395 // std::cout<<det<<" "<<ring<<" "<<sector<<" "<<strip<<" "<<r<<" "<<z_real<<" "<<theta<<" "<<eta<<std::endl;
399 //_____________________________________________________________________