AliPhysics  c7b8e89 (c7b8e89)
AliAnaRandomTrigger.cxx
Go to the documentation of this file.
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 // --- ROOT system ---
17 #include <TH2F.h>
18 #include <TClonesArray.h>
19 
20 //---- AliRoot system ----
21 #include "AliAnaRandomTrigger.h"
23 #include "AliEMCALGeometry.h"
24 
26 ClassImp(AliAnaRandomTrigger) ;
28 
29 //__________________________________________
31 //__________________________________________
34  fTriggerDetector(kEMCAL),
35  fTriggerDetectorString("EMCAL"),
36  fRandom(0), fNRandom(0),
37  fMomentum(),
38  fhE(0), fhPt(0),
39  fhPhi(0), fhEta(0),
40  fhEtaPhi(0)
41 {
43 }
44 
45 //_________________________________________________________________________
48 //_________________________________________________________________________
50 {
51  if(fTriggerDetector!=kEMCAL) return kFALSE;
52 
53  //-------------------------------------
54  // Get the corresponding cell in EMCAL, check if it exists in acceptance (phi gaps, borders)
55  //-------------------------------------
56 
57  Int_t absId = -1;
58  if(!GetEMCALGeometry()->GetAbsCellIdFromEtaPhi(eta,phi, absId)) return kTRUE; // remove if out of EMCAL acceptance, phi gaps
59 
60  Int_t icol = -1, irow = -1, iRCU = -1;
61  Int_t sm = GetCaloUtils()->GetModuleNumberCellIndexes(absId,kEMCAL, icol, irow, iRCU);
62 
63  //printf("eta %f, phi %f, ieta %d, iphi %d, sm %d\n",eta,phi,icol,irow,sm);
64 
65  //-------------------------------------
66  // Remove in case of close to border, by default always 1 but check what was set in reco utils
67  //-------------------------------------
68 
69  Bool_t okrow = kFALSE;
70  Bool_t okcol = kFALSE;
72  if (nborder<1) nborder = 1;
73 
74  // Rows
75  if(sm < 10)
76  {
77  if(irow >= nborder && irow < 24-nborder) okrow =kTRUE;
78  }
79  else
80  {
81  if((GetCaloUtils()->EMCALGeometryName()).Contains("12SM")) // 1/3 SM
82  {
83  if(irow >= nborder && irow < 8-nborder) okrow =kTRUE;
84  }
85  else // 1/2 SM
86  {
87  if(irow >= nborder && irow <12-nborder) okrow =kTRUE;
88  }
89  }
90 
91  // Columns
92  if(sm%2==0)
93  {
94  if(icol >= nborder) okcol = kTRUE;
95  }
96  else
97  {
98  if(icol < 48-nborder) okcol = kTRUE;
99  }
100 
101  //printf("okcol %d, okrow %d\n",okcol,okrow);
102  if (!okcol || !okrow) return kTRUE;
103 
104  //-------------------------------------
105  // Check if the cell or those around are bad
106  //-------------------------------------
107 
108  Int_t status = 0;
109  if ( GetCaloUtils()->GetEMCALChannelStatus(sm,icol, irow,status) )
110  return kTRUE ; // trigger falls into a bad channel
111 
112  // Check if close there was a bad channel
113 // for(Int_t i = -1; i <= 1; i++)
114 // {
115 // for(Int_t j = -1; j <= 1; j++)
116 // {
117 // //printf("\t check icol %d, irow %d \n",icol+i, irow+j);
118 // if(GetCaloUtils()->GetEMCALChannelStatus(sm,icol+i, irow+j) > 0) return kTRUE ; // trigger falls into a bad channel
119 // //printf("\t ok\n");
120 // }
121 // }
122 
123  //printf("\t OK\n");
124 
125  return kFALSE;
126 }
127 
128 //__________________________________________________
130 //__________________________________________________
132 {
133  TString parList ; //this will be list of parameters used for this analysis.
134  const Int_t buffersize = 255;
135  char onePar[buffersize] ;
136 
137  snprintf(onePar,buffersize,"--- AliAnaRandomTrigger ---:") ;
138  parList+=onePar ;
139  snprintf(onePar,buffersize,"Detector: %s;" , fTriggerDetectorString.Data()) ;
140  parList+=onePar ;
141  snprintf(onePar,buffersize,"N per event = %d;", fNRandom ) ;
142  parList+=onePar ;
143  snprintf(onePar,buffersize,"Min E = %3.2f - Max E = %3.2f;", GetMinPt(), GetMaxPt()) ;
144  parList+=onePar ;
145  snprintf(onePar,buffersize,"Min Eta = %3.2f - Max Eta = %3.2f;", fEtaCut[0], fEtaCut[1]) ;
146  parList+=onePar ;
147  snprintf(onePar,buffersize,"Min Phi = %3.2f - Max Phi = %3.2f;", fPhiCut[0], fPhiCut[1]) ;
148  parList+=onePar ;
149 
150  return new TObjString(parList) ;
151 }
152 
153 //____________________________________________________
156 //____________________________________________________
158 {
159  TList * outputContainer = new TList() ;
160  outputContainer->SetName("RandomTrigger") ;
161 
165 
166  fhE = new TH1F ("hE","Random E distribution", nptbins,ptmin,ptmax);
167  fhE->SetXTitle("E (GeV)");
168  outputContainer->Add(fhE);
169 
170  fhPt = new TH1F ("hPt","Random p_{T} distribution", nptbins,ptmin,ptmax);
171  fhPt->SetXTitle("p_{T} (GeV/c)");
172  outputContainer->Add(fhPt);
173 
174  fhPhi = new TH2F ("hPhi","Random #phi distribution",
175  nptbins,ptmin,ptmax, nphibins,phimin,phimax);
176  fhPhi->SetYTitle("#phi (rad)");
177  fhPhi->SetXTitle("p_{T} (GeV/c)");
178  outputContainer->Add(fhPhi);
179 
180  fhEta = new TH2F ("hEta","Random #eta distribution",
181  nptbins,ptmin,ptmax, netabins,etamin,etamax);
182  fhEta->SetYTitle("#eta ");
183  fhEta->SetXTitle("p_{T} (GeV/c)");
184  outputContainer->Add(fhEta);
185 
186  fhEtaPhi = new TH2F ("hEtaPhi","Random #eta vs #phi ",netabins,etamin,etamax, nphibins,phimin,phimax);
187  fhEtaPhi->SetXTitle("#eta ");
188  fhEtaPhi->SetYTitle("#phi (rad)");
189  outputContainer->Add(fhEtaPhi);
190 
191  return outputContainer;
192 }
193 
194 //________________________________________
196 //________________________________________
198 {
199  SetOutputAODClassName("AliCaloTrackParticleCorrelation");
200  SetOutputAODName("RandomTrigger");
201 
202  AddToHistogramsName("AnaRandomTrigger_");
203 
204  fNRandom = 1 ;
205  fPhiCut[0] = 0. ;
206  fPhiCut[1] = TMath::TwoPi() ;
207  fEtaCut[0] =-1. ;
208  fEtaCut[1] = 1. ;
209 }
210 
211 //_________________________________________________________
213 //_________________________________________________________
215 {
216  if(! opt)
217  return;
218 
219  printf("**** Print %s %s ****\n", GetName(), GetTitle() ) ;
221 
222  printf("Detector = %s\n", fTriggerDetectorString.Data());
223  printf("Min E = %3.2f - Max E = %3.2f\n", GetMinPt(), GetMaxPt());
224  printf("Min Eta = %3.2f - Max Eta = %3.2f\n", fEtaCut[0], fEtaCut[1]);
225  printf("Min Phi = %3.2f - Max Phi = %3.2f\n", fPhiCut[0], fPhiCut[1]);
226 }
227 
228 //______________________________________________
232 //______________________________________________
234 {
235  for(Int_t irandom = 0; irandom < fNRandom; irandom++)
236  {
237  // Get the random variables of the trigger
238  Float_t pt = fRandom.Uniform(GetMinPt(), GetMaxPt());
239  Float_t eta = fRandom.Uniform(fEtaCut[0], fEtaCut[1]);
240  Float_t phi = fRandom.Uniform(fPhiCut[0], fPhiCut[1]);
241 
242  // Check if particle falls into a dead region, if inside, get new
243  Bool_t excluded = ExcludeDeadBadRegions(eta,phi);
244 
245  // If excluded, generate a new trigger until accepted
246  while (excluded)
247  {
248  pt = fRandom.Uniform(GetMinPt(), GetMaxPt());
249  eta = fRandom.Uniform(fEtaCut[0], fEtaCut[1]);
250  phi = fRandom.Uniform(fPhiCut[0], fPhiCut[1]);
251 
252  excluded = ExcludeDeadBadRegions(eta,phi);
253  }
254 
255  // Create the AOD trigger object
256  fMomentum.SetPtEtaPhiM(pt,eta,phi,0);
257 
260  trigger.SetSModNumber(GetModuleNumber(&trigger));
261 
262  AliDebug(1,Form("iRandom %d, Trigger e %2.2f pt %2.2f, phi %2.2f, eta %2.2f, SM %d",
263  irandom, trigger.E(), trigger.Pt(), trigger.Phi(), trigger.Eta(), trigger.GetSModNumber()));
264 
265  AddAODParticle(trigger);
266  }
267 
268  AliDebug(1,Form("Final aod branch entries %d", GetOutputAODBranch()->GetEntriesFast()));
269 }
270 
271 //_____________________________________________________
272 // Fill control histograms with generated trigger kinematics.
273 //_____________________________________________________
275 {
276  // Loop on stored AODParticles
277  Int_t naod = GetOutputAODBranch()->GetEntriesFast();
278 
279  AliDebug(1,Form("AOD branch entries %d, fNRandom %d", naod, fNRandom));
280 
281  for(Int_t iaod = 0; iaod < naod ; iaod++)
282  {
284 
285  fhPt ->Fill(trigger->Pt (), GetEventWeight());
286  fhE ->Fill(trigger->E (), GetEventWeight());
287  fhPhi ->Fill(trigger->Pt (), trigger->Phi(), GetEventWeight());
288  fhEta ->Fill(trigger->Pt (), trigger->Eta(), GetEventWeight());
289  fhEtaPhi->Fill(trigger->Eta(), trigger->Phi(), GetEventWeight());
290  }// aod branch loop
291 }
292 
293 //_________________________________________________________
295 //_________________________________________________________
297 {
299 
300  if (det=="EMCAL") fTriggerDetector = kEMCAL;
301  else if(det=="PHOS" ) fTriggerDetector = kPHOS;
302  else if(det=="CTS") fTriggerDetector = kCTS;
303  else if(det=="DCAL") fTriggerDetector = kDCAL;
304  else if(det.Contains("DCAL") && det.Contains("PHOS")) fTriggerDetector = kDCALPHOS;
305  else AliFatal(Form("Detector < %s > not known!", det.Data()));
306 }
307 
308 //______________________________________________________
309 // Set the calorimeter for the analysis.
310 //______________________________________________________
312 {
313  fTriggerDetector = det;
314 
315  if ( det == kEMCAL ) fTriggerDetectorString = "EMCAL";
316  else if( det == kPHOS ) fTriggerDetectorString = "PHOS";
317  else if( det == kCTS ) fTriggerDetectorString = "CTS";
318  else if( det == kDCAL ) fTriggerDetectorString = "DCAL";
319  else if( det == kDCALPHOS) fTriggerDetectorString = "DCAL_PHOS";
320  else AliFatal(Form("Detector < %d > not known!", det));
321 }
322 
323 
Float_t GetHistoPtMax() const
virtual Int_t GetSModNumber() const
virtual Double_t Eta() const
virtual Double_t Pt() const
Float_t GetHistoPtMin() const
Int_t fNRandom
Number of random particles per event.
virtual void AddAODParticle(AliCaloTrackParticle part)
virtual void AddToHistogramsName(TString add)
Float_t fPhiCut[2]
Phi acceptance, radians.
Definition: External.C:236
Bool_t ExcludeDeadBadRegions(Float_t eta, Float_t phi)
TH2F * fhEta
! eta distribution vs pT, negative
AliEMCALRecoUtils * GetEMCALRecoUtils() const
void InitParameters()
Initialize the parameters of the analysis.
TObjString * GetAnalysisCuts()
Save parameters used for analysis.
virtual void SetOutputAODClassName(TString name)
Int_t GetHistoPhiBins() const
Int_t GetNumberOfCellsFromEMCALBorder() const
virtual void SetDetectorTag(UInt_t d)
void SetTriggerDetector(TString det)
Set the detrimeter for the analysis.
virtual TClonesArray * GetOutputAODBranch() const
Int_t fTriggerDetector
Detector : EMCAL, PHOS, CTS.
Float_t GetHistoPhiMin() const
virtual Double_t E() const
TLorentzVector fMomentum
! Avoid generating TLorentzVectors per event.
void Print(const Option_t *opt) const
Print some relevant parameters set for the analysis.
virtual void SetOutputAODName(TString name)
const Double_t etamin
Base class for CaloTrackCorr analysis algorithms.
int Int_t
Definition: External.C:63
TString fTriggerDetectorString
Detector : EMCAL, PHOS, CTS.
Container for input particle information on CaloTrackCorr package.
virtual AliHistogramRanges * GetHistogramRanges()
float Float_t
Definition: External.C:68
const Double_t ptmax
virtual AliEMCALGeometry * GetEMCALGeometry() const
virtual AliCalorimeterUtils * GetCaloUtils() const
TRandom3 fRandom
Random generator.
const Double_t ptmin
virtual Double_t GetEventWeight() const
TH2F * fhEtaPhi
! eta vs phi distribution of positive charge
Float_t GetHistoEtaMin() const
virtual void SetSModNumber(Int_t sm)
TH1F * fhPt
! pT distribution
Float_t GetHistoEtaMax() const
Int_t GetHistoPtBins() const
virtual Int_t GetModuleNumber(AliCaloTrackParticle *part) const
TH1F * fhE
! E distribution
Gerenate a random trigger.
const Double_t etamax
virtual Double_t Phi() const
virtual void Print(const Option_t *) const
Print some relevant parameters set for the analysis.
const char Option_t
Definition: External.C:48
TH2F * fhPhi
! phi distribution vs pT, negative
AliAnaRandomTrigger()
Default Constructor. Initialize parameters.
Float_t GetHistoPhiMax() const
bool Bool_t
Definition: External.C:53
Int_t GetHistoEtaBins() const
DCal, not used so far, just in case.
Float_t fEtaCut[2]
Eta acceptance.
Int_t nptbins
Int_t GetModuleNumberCellIndexes(Int_t absId, Int_t calo, Int_t &icol, Int_t &irow, Int_t &iRCU) const
Get the EMCAL/PHOS module, columns, row and RCU/DDL number that corresponds to this absId...
const Double_t phimin