]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/FORWARD/analysis/AliFMDAnaParameters.cxx
update to make available for other people
[u/mrichter/AliRoot.git] / PWG2 / FORWARD / analysis / AliFMDAnaParameters.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15 //
16 //The design of this class is based on the AliFMDParameters class. Its purpose
17 //is to hold parameters for the analysis such as background correction and 
18 //fit functions.
19 //
20 //Author: Hans Hjersing Dalsgaard, NBI, hans.dalsgaard@cern.ch
21 //
22
23 #include "AliFMDDebug.h"                   // ALILOG_H
24 #include "AliFMDAnaParameters.h"           // ALIFMDPARAMETERS_H
25 //#include <AliCDBManager.h>         // ALICDBMANAGER_H
26 //#include <AliCDBEntry.h>           // ALICDBMANAGER_H
27 //#include "AliFMDRing.h"
28 #include <AliLog.h>
29 #include <Riostream.h>
30 #include <sstream>
31 #include <TSystem.h>
32 #include <TH2D.h>
33 #include <TF1.h>
34 #include <TMath.h>
35 #include "AliTriggerAnalysis.h"
36 #include "AliPhysicsSelection.h"
37 //#include "AliBackgroundSelection.h"
38 #include "AliESDEvent.h"
39 #include "AliESDVertex.h"
40
41 //====================================================================
42 ClassImp(AliFMDAnaParameters)
43 #if 0
44   ; // This is here to keep Emacs for indenting the next line
45 #endif
46
47 //const char* AliFMDAnaParameters::fgkBackgroundCorrection  = "FMD/Correction/Background";
48 //const char* AliFMDAnaParameters::fgkEnergyDists = "FMD/Correction/EnergyDistribution";
49 const char* AliFMDAnaParameters::fgkBackgroundID         = "background";
50 const char* AliFMDAnaParameters::fgkEnergyDistributionID = "energydistributions";
51 const char* AliFMDAnaParameters::fgkEventSelectionEffID  = "eventselectionefficiency";
52 const char* AliFMDAnaParameters::fgkSharingEffID         = "sharingefficiency";
53 //____________________________________________________________________
54 AliFMDAnaParameters* AliFMDAnaParameters::fgInstance = 0;
55
56 //____________________________________________________________________
57
58 AliFMDAnaParameters* 
59 AliFMDAnaParameters::Instance() 
60 {
61   // Get static instance 
62   if (!fgInstance) fgInstance = new AliFMDAnaParameters;
63   return fgInstance;
64 }
65
66 //____________________________________________________________________
67 AliFMDAnaParameters::AliFMDAnaParameters() :
68   fIsInit(kFALSE),
69   fBackground(0),
70   fEnergyDistribution(0),
71   fEventSelectionEfficiency(0),
72   fSharingEfficiency(0),
73   fCorner1(4.2231, 26.6638),
74   fCorner2(1.8357, 27.9500),
75   fEnergyPath("$ALICE_ROOT/PWG2/FORWARD/corrections/EnergyDistribution"),
76   fBackgroundPath("$ALICE_ROOT/PWG2/FORWARD/corrections/Background"),
77   fEventSelectionEffPath("$ALICE_ROOT/PWG2/FORWARD/corrections/EventSelectionEfficiency"),
78   fSharingEffPath("$ALICE_ROOT/PWG2/FORWARD/corrections/SharingEfficiency"),
79   fProcessPrimary(kFALSE),
80   fProcessHits(kFALSE),
81   fTrigger(kMB1),
82   fEnergy(k10000),
83   fMagField(k5G),
84   fSpecies(kPP),
85   fPhysicsSelection(0),
86   fRealData(kFALSE),
87   fSPDlowLimit(0),
88   fSPDhighLimit(999999999),
89   fCentralSelection(kFALSE)
90 {
91   fPhysicsSelection = new AliPhysicsSelection;
92   //AliBackgroundSelection* backgroundSelection = new AliBackgroundSelection("bg","bg");
93   
94   //fPhysicsSelection->AddBackgroundIdentification(backgroundSelection);
95   //fPhysicsSelection->Initialize(104792);
96   // Do not use this - it is only for IO 
97   fgInstance = this;
98   // Default constructor 
99 }
100 //____________________________________________________________________
101 char* AliFMDAnaParameters::GetPath(const char* species) {
102   
103   char* path = "";
104   
105   if(species == fgkBackgroundID)
106     path = Form("%s/%s_%d_%d_%d_%d_%d_%d.root",
107                 fBackgroundPath.Data(),
108                 fgkBackgroundID,
109                 fEnergy,
110                 fTrigger,
111                 fMagField,
112                 fSpecies,
113                 0,
114                 0);
115   if(species == fgkEnergyDistributionID)
116     path = Form("%s/%s_%d_%d_%d_%d_%d_%d.root",
117                 fEnergyPath.Data(),
118                 fgkEnergyDistributionID,
119                 fEnergy,
120                 fTrigger,
121                 fMagField,
122                 fSpecies,
123                 0,
124                 0);
125   if(species == fgkEventSelectionEffID)
126     path = Form("%s/%s_%d_%d_%d_%d_%d_%d.root",
127                 fEventSelectionEffPath.Data(),
128                 fgkEventSelectionEffID,
129                 fEnergy,
130                 fTrigger,
131                 fMagField,
132                 fSpecies,
133                 0,
134                 0);
135   if(species == fgkSharingEffID)
136     path = Form("%s/%s_%d_%d_%d_%d_%d_%d.root",
137                 fSharingEffPath.Data(),
138                 fgkSharingEffID,
139                 fEnergy,
140                 fTrigger,
141                 fMagField,
142                 fSpecies,
143                 0,
144                 0);
145
146   return path;
147 }
148 //____________________________________________________________________
149 void AliFMDAnaParameters::Init(Bool_t forceReInit, UInt_t what)
150 {
151   // Initialize the parameters manager.  We need to get stuff from the
152   // CDB here. 
153   if (forceReInit) fIsInit = kFALSE;
154   if (fIsInit) return;
155   if (what & kBackgroundCorrection)       InitBackground();
156   if (what & kEnergyDistributions)        InitEnergyDists();
157   if (what & kEventSelectionEfficiency)   InitEventSelectionEff();
158   if (what & kSharingEfficiency)          InitSharingEff();
159   
160
161   
162   fIsInit = kTRUE;
163 }
164 //____________________________________________________________________
165
166 void AliFMDAnaParameters::InitBackground() {
167   
168   //AliCDBEntry*   background = GetEntry(fgkBackgroundCorrection);
169   
170   TFile* fin = TFile::Open(GetPath(fgkBackgroundID));
171   
172   if (!fin) return;
173   
174   fBackground = dynamic_cast<AliFMDAnaCalibBackgroundCorrection*>(fin->Get(fgkBackgroundID));
175   if (!fBackground) AliFatal("Invalid background object from CDB");
176   
177 }
178
179 //____________________________________________________________________
180
181 void AliFMDAnaParameters::InitEnergyDists() {
182   
183   TFile* fin = TFile::Open(GetPath(fgkEnergyDistributionID));
184   //AliCDBEntry*   edist = GetEntry(fgkEnergyDists);
185   if (!fin) return;
186   
187   fEnergyDistribution = dynamic_cast<AliFMDAnaCalibEnergyDistribution*>(fin->Get(fgkEnergyDistributionID));
188   
189   if (!fEnergyDistribution) AliFatal("Invalid background object from CDB");
190   
191 }
192
193 //____________________________________________________________________
194
195 void AliFMDAnaParameters::InitEventSelectionEff() {
196   
197   //AliCDBEntry*   background = GetEntry(fgkBackgroundCorrection);
198   TFile* fin = TFile::Open(GetPath(fgkEventSelectionEffID));
199                             
200   if (!fin) return;
201   
202   fEventSelectionEfficiency = dynamic_cast<AliFMDAnaCalibEventSelectionEfficiency*>(fin->Get(fgkEventSelectionEffID));
203   if (!fEventSelectionEfficiency) AliFatal("Invalid background object from CDB");
204   
205 }
206 //____________________________________________________________________
207
208 void AliFMDAnaParameters::PrintStatus() const
209 {
210   
211   TString energystring;
212   switch(fEnergy) {
213   case k900:
214     energystring.Form("900 GeV");   break;
215   case k7000:
216     energystring.Form("7000 GeV");  break;
217   case k10000:
218     energystring.Form("10000 GeV"); break;
219   case k14000:
220     energystring.Form("14000 GeV"); break;
221   default:
222     energystring.Form("invalid energy"); break;
223   }
224   TString triggerstring;
225   switch(fTrigger) {
226   case kMB1:
227     triggerstring.Form("Minimum bias 1");   break;
228   case kMB2:
229     triggerstring.Form("Minimum bias 2");   break;
230   case kSPDFASTOR:
231     triggerstring.Form("SPD FAST OR");   break;
232   case kNOCTP:
233     triggerstring.Form("NO TRIGGER TEST");   break;
234   default:
235     energystring.Form("invalid trigger"); break;
236   }
237   TString magstring;
238   switch(fMagField) {
239   case k5G:
240     magstring.Form("5 kGaus");   break;
241   case k0G:
242     magstring.Form("0 kGaus");   break;
243   default:
244     magstring.Form("invalid mag field"); break;
245   }
246   TString collsystemstring;
247   switch(fSpecies) {
248   case kPP:
249     collsystemstring.Form("p+p");   break;
250   case kPbPb:
251     collsystemstring.Form("Pb+Pb");   break;
252   default:
253     collsystemstring.Form("invalid collision system");   break;
254   }
255   
256
257   std::cout<<"Energy      = "<<energystring.Data()<<std::endl;
258   std::cout<<"Trigger     = "<<triggerstring.Data()<<std::endl;
259   std::cout<<"Mag Field   = "<<magstring.Data()<<std::endl;
260   std::cout<<"Coll System = "<<collsystemstring.Data()<<std::endl;
261   
262   
263   
264 }
265
266 //____________________________________________________________________
267
268 void AliFMDAnaParameters::InitSharingEff() {
269   
270   //AliCDBEntry*   background = GetEntry(fgkBackgroundCorrection);
271   TFile* fin = TFile::Open(GetPath(fgkSharingEffID));
272                             
273   if (!fin) return;
274   
275   fSharingEfficiency = dynamic_cast<AliFMDAnaCalibSharingEfficiency*>(fin->Get(fgkSharingEffID));
276   if (!fSharingEfficiency) AliFatal("Invalid background object from CDB");
277   
278 }
279 //____________________________________________________________________
280 Float_t AliFMDAnaParameters::GetVtxCutZ() {
281   
282   if(!fIsInit) {
283     AliWarning("Not initialized yet. Call Init() to remedy");
284     return -1;
285   }
286   
287   return fBackground->GetVtxCutZ();
288 }
289
290 //____________________________________________________________________
291 Int_t AliFMDAnaParameters::GetNvtxBins() {
292   
293   if(!fIsInit) {
294     AliWarning("Not initialized yet. Call Init() to remedy");
295     return -1;
296   }
297   
298   return fBackground->GetNvtxBins();
299 }
300 //____________________________________________________________________
301 TH1F* AliFMDAnaParameters::GetEnergyDistribution(Int_t det, Char_t ring, Float_t eta) {
302   
303   return fEnergyDistribution->GetEnergyDistribution(det, ring, eta);
304 }
305 //____________________________________________________________________
306 TH1F* AliFMDAnaParameters::GetEmptyEnergyDistribution(Int_t det, Char_t ring) {
307   
308   return fEnergyDistribution->GetEmptyEnergyDistribution(det, ring);
309 }
310 //____________________________________________________________________
311 TH1F* AliFMDAnaParameters::GetRingEnergyDistribution(Int_t det, Char_t ring) {
312   
313   return fEnergyDistribution->GetRingEnergyDistribution(det, ring);
314 }
315 //____________________________________________________________________
316 Float_t AliFMDAnaParameters::GetSigma(Int_t det, Char_t ring, Float_t eta) {
317   
318   if(!fIsInit) {
319     AliWarning("Not initialized yet. Call Init() to remedy");
320     return 0;
321   }
322   
323   TH1F* hEnergyDist       = GetEnergyDistribution(det,ring, eta);
324   TF1*  fitFunc           = hEnergyDist->GetFunction("FMDfitFunc");
325   if(!fitFunc) {
326     //AliWarning(Form("No function for FMD%d%c, eta %f",det,ring,eta));
327     return 1024;
328   }
329   Float_t sigma           = fitFunc->GetParameter(2);
330   return sigma;
331 }
332
333
334 //____________________________________________________________________
335 Float_t AliFMDAnaParameters::GetMPV(Int_t det, Char_t ring, Float_t eta) {
336   
337   if(!fIsInit) {
338     AliWarning("Not initialized yet. Call Init() to remedy");
339     return 0;
340   }
341   //AliFMDAnaParameters* pars = AliFMDAnaParameters::Instance();
342   TH1F* hEnergyDist     = GetEnergyDistribution(det,ring,eta);
343   TF1*  fitFunc         = hEnergyDist->GetFunction("FMDfitFunc");
344   if(!fitFunc) {
345     AliWarning(Form("No function for FMD%d%c, eta %f",det,ring,eta));
346     std::cout<<hEnergyDist->GetEntries()<<"    "<<GetEtaBin(eta)<<std::endl;
347     return 1024;
348   }
349     
350   Float_t mpv           = fitFunc->GetParameter(1);
351   return mpv;
352 }
353 //____________________________________________________________________
354 Float_t AliFMDAnaParameters::GetConstant(Int_t det, Char_t ring, Float_t eta) {
355   
356   if(!fIsInit) {
357     AliWarning("Not initialized yet. Call Init() to remedy");
358     return 0;
359   }
360   
361   TH1F* hEnergyDist     = GetEnergyDistribution(det,ring,eta);
362   TF1*  fitFunc         = hEnergyDist->GetFunction("FMDfitFunc");
363   if(!fitFunc) {
364     AliWarning(Form("No function for FMD%d%c, eta %f",det,ring,eta));
365     return 0;
366   }
367     
368   Float_t mpv           = fitFunc->GetParameter(0);
369   return mpv;
370 }
371 //____________________________________________________________________
372 Float_t AliFMDAnaParameters::Get2MIPWeight(Int_t det, Char_t ring, Float_t eta) {
373   
374   if(!fIsInit) {
375     AliWarning("Not initialized yet. Call Init() to remedy");
376     return 0;
377   }
378   
379   TH1F* hEnergyDist     = GetEnergyDistribution(det,ring,eta);
380   TF1*  fitFunc         = hEnergyDist->GetFunction("FMDfitFunc");
381   if(!fitFunc) return 0;
382   Float_t twoMIPweight    = fitFunc->GetParameter(3);
383   
384   
385   
386   if(twoMIPweight < 1e-05)
387     twoMIPweight = 0;
388   
389   return twoMIPweight;
390 }
391 //____________________________________________________________________
392 Float_t AliFMDAnaParameters::Get3MIPWeight(Int_t det, Char_t ring, Float_t eta) {
393   
394   if(!fIsInit) {
395     AliWarning("Not initialized yet. Call Init() to remedy");
396     return 0;
397   }
398   
399   TH1F* hEnergyDist     = GetEnergyDistribution(det,ring,eta);
400   TF1*  fitFunc         = hEnergyDist->GetFunction("FMDfitFunc");
401   if(!fitFunc) return 0;
402   Float_t threeMIPweight    = fitFunc->GetParameter(4);
403   
404   if(threeMIPweight < 1e-05)
405     threeMIPweight = 0;
406   
407   Float_t twoMIPweight    = fitFunc->GetParameter(3);
408   
409   if(twoMIPweight < 1e-05)
410     threeMIPweight = 0;
411     
412   return threeMIPweight;
413 }
414 //____________________________________________________________________
415 Int_t AliFMDAnaParameters::GetNetaBins() {
416   return GetBackgroundCorrection(1,'I',0)->GetNbinsX();
417   
418 }
419 //____________________________________________________________________
420 Float_t AliFMDAnaParameters::GetEtaMin() {
421
422   return GetBackgroundCorrection(1,'I',0)->GetXaxis()->GetXmin();
423
424 //____________________________________________________________________
425 Float_t AliFMDAnaParameters::GetEtaMax() {
426
427 return GetBackgroundCorrection(1,'I',0)->GetXaxis()->GetXmax();
428
429 }
430 //____________________________________________________________________
431 Int_t AliFMDAnaParameters::GetEtaBin(Float_t eta) {
432   TAxis testaxis(GetNetaBins(),GetEtaMin(),GetEtaMax());
433   Int_t binnumber = testaxis.FindBin(eta) ;
434   
435   return binnumber;
436
437 }
438 //____________________________________________________________________
439
440 TH2F* AliFMDAnaParameters::GetBackgroundCorrection(Int_t det, 
441                                                    Char_t ring, 
442                                                    Int_t vtxbin) {
443   
444   if(!fIsInit) {
445     AliWarning("Not initialized yet. Call Init() to remedy");
446     return 0;
447   }
448   
449   
450   
451   if(vtxbin > fBackground->GetNvtxBins()) {
452     AliWarning(Form("No background object for vertex bin %d", vtxbin));
453     return 0;
454   } 
455   
456   return fBackground->GetBgCorrection(det,ring,vtxbin);
457 }
458 //____________________________________________________________________
459
460 TH1F* AliFMDAnaParameters::GetDoubleHitCorrection(Int_t det, 
461                                                   Char_t ring) {
462   
463   if(!fIsInit) {
464     AliWarning("Not initialized yet. Call Init() to remedy");
465     return 0;
466   }
467   
468   return fBackground->GetDoubleHitCorrection(det,ring);
469 }
470 //_____________________________________________________________________
471 Float_t AliFMDAnaParameters::GetEventSelectionEfficiency(Int_t vtxbin) {
472   if(!fIsInit) {
473     AliWarning("Not initialized yet. Call Init() to remedy");
474     return 0;
475   }
476   return fEventSelectionEfficiency->GetCorrection(vtxbin);
477
478 }
479 //_____________________________________________________________________
480 TH1F* AliFMDAnaParameters::GetSharingEfficiency(Int_t det, Char_t ring, Int_t vtxbin) {
481   if(!fIsInit) {
482     AliWarning("Not initialized yet. Call Init() to remedy");
483     return 0;
484   }
485   
486   return fSharingEfficiency->GetSharingEff(det,ring,vtxbin);
487
488 }
489 //_____________________________________________________________________
490 TH1F* AliFMDAnaParameters::GetSharingEfficiencyTrVtx(Int_t det, Char_t ring, Int_t vtxbin) {
491   if(!fIsInit) {
492     AliWarning("Not initialized yet. Call Init() to remedy");
493     return 0;
494   }
495   
496   return fSharingEfficiency->GetSharingEffTrVtx(det,ring,vtxbin);
497
498 }
499 //_____________________________________________________________________
500 Float_t AliFMDAnaParameters::GetMaxR(Char_t ring) const{
501   Float_t radius = 0;
502   if(ring == 'I')
503     radius = 17.2;
504   else if(ring == 'O')
505     radius = 28.0;
506   else
507     AliWarning("Unknown ring - must be I or O!");
508   
509   return radius;
510 }
511 //_____________________________________________________________________
512 Float_t AliFMDAnaParameters::GetMinR(Char_t ring) const{
513   Float_t radius = 0;
514   if(ring == 'I')
515     radius = 4.5213;
516   else if(ring == 'O')
517     radius = 15.4;
518   else
519     AliWarning("Unknown ring - must be I or O!");
520   
521   return radius;
522
523 }
524 //_____________________________________________________________________
525 void AliFMDAnaParameters::SetCorners(Char_t ring) {
526   
527   if(ring == 'I') {
528     fCorner1.Set(4.9895, 15.3560);
529     fCorner2.Set(1.8007, 17.2000);
530   }
531   else {
532     fCorner1.Set(4.2231, 26.6638);
533     fCorner2.Set(1.8357, 27.9500);
534   }
535   
536 }
537 //_____________________________________________________________________
538 Float_t AliFMDAnaParameters::GetPhiFromSector(UShort_t det, Char_t ring, UShort_t sec) const
539 {
540   Int_t nsec = (ring == 'I' ? 20 : 40);
541   Float_t basephi = 0;
542   if(det == 1) 
543     basephi = 1.72787594; 
544   if(det == 2 && ring == 'I')
545     basephi = 0.15707963;
546   if(det == 2 && ring == 'O')
547     basephi = 0.078539818;
548   if(det == 3 && ring == 'I')
549     basephi = 2.984513044;
550   if(det == 3 && ring == 'O')
551     basephi = 3.06305289;
552   
553   Float_t step = 2*TMath::Pi() / nsec;
554   Float_t phi = 0;
555   if(det == 3)
556     phi = basephi - sec*step;
557   else
558     phi = basephi + sec*step;
559   
560   if(phi < 0) 
561     phi = phi +2*TMath::Pi();
562   if(phi > 2*TMath::Pi() )
563     phi = phi - 2*TMath::Pi();
564   
565   return phi;
566 }
567 //_____________________________________________________________________
568 Float_t AliFMDAnaParameters::GetEtaFromStrip(UShort_t det, Char_t ring, UShort_t sec, UShort_t strip, Float_t zvtx) const
569 {
570   // AliFMDRing fmdring(ring);
571   // fmdring.Init();
572   Float_t   rad       = GetMaxR(ring)-GetMinR(ring);
573   Float_t   nStrips   = (ring == 'I' ? 512 : 256);
574   Float_t   segment   = rad / nStrips;
575   Float_t   r         = GetMinR(ring) + segment*strip;
576   Float_t   z         = 0;
577   Int_t hybrid = sec / 2;
578   
579   if(det == 1) {
580     if(!(hybrid%2)) z = 320.266; else z = 319.766;
581   }
582   if(det == 2 && ring == 'I' ) {
583     if(!(hybrid%2)) z = 83.666; else z = 83.166;
584   }
585   if(det == 2 && ring == 'O' ) {
586     if(!(hybrid%2)) z = 74.966; else z = 75.466;
587   }
588   if(det == 3 && ring == 'I' ) {
589     if(!(hybrid%2)) z = -63.066; else z = -62.566;
590   }
591   if(det == 3 && ring == 'O' ) {
592     if(!(hybrid%2)) z = -74.966; else z = -75.466;
593   }
594   
595   //std::cout<<det<<"   "<<ring<<"   "<<sec<<"   "<<hybrid<<"    "<<z<<std::endl;
596   
597   // Float_t   r     = TMath::Sqrt(TMath::Power(x,2)+TMath::Power(y,2));
598   Float_t   theta = TMath::ATan2(r,z-zvtx);
599   Float_t   eta   = -1*TMath::Log(TMath::Tan(0.5*theta));
600   
601   return eta;
602 }
603
604 //_____________________________________________________________________
605
606 Bool_t AliFMDAnaParameters::GetVertex(AliESDEvent* esd, Double_t* vertexXYZ) 
607 {
608   const AliESDVertex* vertex = 0;
609   vertex = esd->GetPrimaryVertexSPD();
610   
611   if(vertex)
612     vertex->GetXYZ(vertexXYZ);
613     
614   //if(vertexXYZ[0] == 0 || vertexXYZ[1] == 0 )
615   //  return kFALSE;
616   
617   if(vertex->GetNContributors() <= 0)
618     return kFALSE;
619   
620   if(vertex->GetZRes() > 0.1 ) 
621     return kFALSE;
622   
623   return vertex->GetStatus();
624   
625 }
626 //____________________________________________________________________
627 Bool_t AliFMDAnaParameters::IsEventTriggered(const AliESDEvent *esd, Trigger trig) {
628
629   Trigger old = fTrigger;
630   fTrigger = trig;
631   Bool_t retval = IsEventTriggered(esd);
632   fTrigger = old;
633   return retval;
634
635 }
636 //____________________________________________________________________
637 Bool_t AliFMDAnaParameters::IsEventTriggered(const AliESDEvent *esd) const {
638   // check if the event was triggered
639   
640   if (fCentralSelection) return kTRUE;
641   ULong64_t triggerMask = esd->GetTriggerMask();
642   
643   TString triggers = esd->GetFiredTriggerClasses();
644   // std::cout<<triggers.Data()<<std::endl;
645   //if(triggers.Contains("CINT1B-ABCE-NOPF-ALL") || triggers.Contains("CINT1B-E-NOPF-ALL")) return kTRUE;
646   //else return kFALSE;
647   //if(triggers.Contains("CINT1B-E-NOPF-ALL"))    return kFALSE;
648   
649   // if(triggers.Contains("CINT1A-ABCE-NOPF-ALL")) return kFALSE;
650   // if(triggers.Contains("CINT1C-ABCE-NOPF-ALL")) return kFALSE;
651   
652   // definitions from p-p.cfg
653   ULong64_t spdFO = (1 << 14);
654   ULong64_t v0left = (1 << 11);
655   ULong64_t v0right = (1 << 12);
656   AliTriggerAnalysis tAna;
657   
658   //REMOVE WHEN FINISHED PLAYING WITH TRIGGERS!
659   //fPhysicsSelection->IsCollisionCandidate(esd);
660   
661   
662   switch (fTrigger) {
663   case kMB1: {
664     //if (triggerMask & spdFO || ((triggerMask & v0left) || (triggerMask & v0right)))
665     //  if(/*tAna.IsOfflineTriggerFired(esd,AliTriggerAnalysis::kMB1) &&*/ (triggers.Contains("CINT1B-ABCE-NOPF-ALL")))// || triggers.Contains("CINT1-E-NOPF-ALL")))
666     if(fRealData) {
667       if( fPhysicsSelection->IsCollisionCandidate(esd))
668         return kTRUE;
669         
670        //  triggers.Contains("CINT1C-ABCE-NOPF-ALL") || triggers.Contains("CINT1A-ABCE-NOPF-ALL"))
671     
672     }
673     else
674       if(triggerMask & spdFO || ((triggerMask & v0left) || (triggerMask & v0right)))
675         return kTRUE;
676     break;
677   }
678   case kMB2: { 
679     if (triggerMask & spdFO && ((triggerMask & v0left) || (triggerMask & v0right)))
680       return kTRUE;
681     break;
682   }
683   case kSPDFASTOR: {
684     if (triggerMask & spdFO)
685       return kTRUE;
686     break;
687   }
688   case kNOCTP: {
689     return kTRUE;
690     break;
691   }
692   case kEMPTY: {
693     if(triggers.Contains("CBEAMB-ABCE-NOPF-ALL"))
694       return kTRUE;
695     break;
696   }
697   }//switch
698   
699   return kFALSE;
700 }
701
702 //____________________________________________________________________
703 Float_t 
704 AliFMDAnaParameters::GetStripLength(Char_t ring, UShort_t strip)  
705 {
706   //AliFMDRing fmdring(ring);
707   // fmdring.Init();
708   
709   Float_t rad        = GetMaxR(ring)-GetMinR(ring);
710   Float_t   nStrips   = (ring == 'I' ? 512 : 256);
711   Float_t segment    = rad / nStrips;
712   
713   //TVector2* corner1  = fmdring.GetVertex(2);  
714   // TVector2* corner2  = fmdring.GetVertex(3);
715   
716   SetCorners(ring);
717   /*
718   std::cout<<GetMaxR(ring)<<"   "<<fmdring.GetMaxR()<<std::endl;
719   std::cout<<GetMinR(ring)<<"   "<<fmdring.GetMinR()<<std::endl;
720   std::cout<<corner1->X()<<"   "<<fCorner1.X()<<std::endl;
721   std::cout<<corner2->X()<<"   "<<fCorner2.X()<<std::endl;
722   std::cout<<corner1->Y()<<"   "<<fCorner1.Y()<<std::endl;
723   std::cout<<corner2->Y()<<"   "<<fCorner2.Y()<<std::endl;*/
724   Float_t slope      = (fCorner1.Y() - fCorner2.Y()) / (fCorner1.X() - fCorner2.X());
725   Float_t constant   = (fCorner2.Y()*fCorner1.X()-(fCorner2.X()*fCorner1.Y())) / (fCorner1.X() - fCorner2.X());
726   Float_t radius     = GetMinR(ring) + strip*segment;
727   
728   Float_t d          = TMath::Power(TMath::Abs(radius*slope),2) + TMath::Power(radius,2) - TMath::Power(constant,2);
729   
730   Float_t arclength  = GetBaseStripLength(ring,strip);
731   if(d>0) {
732     
733     Float_t x        = (-1*TMath::Sqrt(d) -slope*constant) / (1+TMath::Power(slope,2));
734     Float_t y        = slope*x + constant;
735     Float_t theta    = TMath::ATan2(x,y);
736     
737     if(x < fCorner1.X() && y > fCorner1.Y()) {
738       arclength = radius*theta;                        //One sector since theta is by definition half-hybrid
739       
740     }
741     
742   }
743   
744   return arclength;
745   
746   
747 }
748 //____________________________________________________________________
749 Float_t 
750 AliFMDAnaParameters::GetBaseStripLength(Char_t ring, UShort_t strip)  
751 {  
752   // AliFMDRing fmdring(ring);
753   // fmdring.Init();
754   Float_t rad             = GetMaxR(ring)-GetMinR(ring);
755   Float_t nStrips         = (ring == 'I' ? 512 : 256);
756   Float_t nSec            = (ring == 'I' ? 20 : 40);
757   Float_t segment         = rad / nStrips;
758   Float_t basearc         = 2*TMath::Pi() / (0.5*nSec); // One hybrid: 36 degrees inner, 18 outer
759   Float_t radius          = GetMinR(ring) + strip*segment;
760   Float_t basearclength   = 0.5*basearc * radius;                // One sector   
761   
762   return basearclength;
763 }
764 //____________________________________________________________________
765 //
766 // EOF
767 //