1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
16 //---------------------------------------------------------------------
18 // Analyse Jets (already found jets)
19 // Authors: andreas.morsch@cern.ch, jgcn@mail.cern.ch
20 // mercedes.lopez.noriega@cern.ch
21 //---------------------------------------------------------------------
23 #include <Riostream.h>
24 #include "AliJetAnalysis.h"
25 ClassImp(AliJetAnalysis)
28 #include <Riostream.h>
36 #include <TLorentzVector.h>
39 #include "AliJetProductionDataPDC2004.h"
41 #include "AliJetKineReaderHeader.h"
42 #include "AliJetESDReaderHeader.h"
43 #include "AliUA1JetHeader.h"
44 #include "AliLeading.h"
47 AliJetAnalysis::AliJetAnalysis():
148 // Default constructor
149 fFile = "anaJets.root";
151 // initialize weight for dE/dr histo
155 AliJetAnalysis::~AliJetAnalysis()
161 ////////////////////////////////////////////////////////////////////////
162 // define histogrames
164 void AliJetAnalysis::DefineHistograms()
166 // Define the histograms to be filled
167 if (fDoKine) DefineKineH();
168 if (fDoCorr) DefineCorrH();
169 if (fDoCorr50) DefineCorr50H();
170 if (fDoShap) DefineShapH();
171 if (fDoFrag) DefineFragH();
172 if (fDoTrig) DefineTrigH();
173 if (fDoJt) DefineJtH();
174 if (fDodNdxi) DefinedNdxiH();
177 void AliJetAnalysis::DefineKineH()
181 fPKineEneH = new TH1F("PKineEne","Energy of leading particle",50,0,200);
182 SetProperties(fPKineEneH,"Energy (GeV)","Entries");
183 fPKinePtH = new TH1F("PKinePt","Pt of leading particle",50,0,200);
184 SetProperties(fPKinePtH,"P_{T} (GeV)","Entries");
185 fPKinePhiH = new TH1F("PKinePhiH","Azimuthal angle of leading particle",
186 90,0.,2.0*TMath::Pi());
187 SetProperties(fPKinePhiH,"#phi","Entries");
188 fPKineEtaH = new TH1F("PKineEtaH","Pseudorapidity of leading particle",
190 SetProperties(fPKineEtaH,"#eta","Entries");
192 // leading generated jet
194 fGKineEneH = new TH1F("GKineEne","Energy of generated jet",50,0,200);
195 SetProperties(fGKineEneH,"Energy (GeV)","Entries");
196 fGKinePtH = new TH1F("GKinePt","Pt of generated jet",50,0,200);
197 SetProperties(fGKinePtH,"P_{T} (GeV)","Entries");
198 fGKinePhiH = new TH1F("GKinePhiH","Azimuthal angle of generated jet",
199 90,0.,2.0*TMath::Pi());
200 SetProperties(fGKinePhiH,"#phi","Entries");
201 fGKineEtaH = new TH1F("GKineEtaH","Pseudorapidity of generated jet",
203 SetProperties(fGKineEtaH,"#eta","Entries");
205 // leading reconstructed jet
207 fRKineEneH = new TH1F("RKineEne","Energy of reconstructed jet",50,0,200);
208 SetProperties(fRKineEneH,"Energy (GeV)","Entries");
209 fRKinePtH = new TH1F("RKinePt","Pt of reconstructed jet",50,0,200);
210 SetProperties(fRKinePtH,"P_{T} (GeV)","Entries");
211 fRKinePhiH = new TH1F("RKinePhiH","Azimuthal angle of reconstructed jet",
212 90,0.,2.0*TMath::Pi());
213 SetProperties(fRKinePhiH,"#phi","Entries");
214 fRKineEtaH = new TH1F("RKineEtaH","Pseudorapidity of reconstructed jet",
216 SetProperties(fRKineEtaH,"#eta","Entries");
220 void AliJetAnalysis::DefineCorrH()
223 if (fDoPart && fDoGenJ) {
224 fPGCorrEneH = new TH2F("PGCorrEne","Energy correlation part-gen jet",
226 SetProperties(fPGCorrEneH,"Part Energy (GeV)","Gen Jet Energy (GeV)");
227 fPGCorrPtH = new TH2F("PGCorrPt","Pt correlation part-gen jet",
229 SetProperties(fPGCorrPtH,"Part P_{T} (GeV)","Gen Jet P_{T} (GeV)");
230 fPGCorrEtaH = new TH2F("PGCorrEta","Pseudorapidity correlation part-gen jet",
231 40,-1.0,1.0,40,-1.0,1.0);
232 SetProperties(fPGCorrEtaH,"Part #eta","Gen Jet #eta");
233 fPGCorrPhiH = new TH2F("PGCorrPhi","Azimuthal angle correlation part-gen jet",
234 90,0.,2.0*TMath::Pi(),90,0.,2.0*TMath::Pi());
235 SetProperties(fPGCorrPhiH,"Part #phi","Gen Jet #phi");
237 if (fDoPart && fDoRecJ) {
238 fPRCorrEneH = new TH2F("PRCorrEne","Energy correlation part-rec jet",
240 SetProperties(fPRCorrEneH,"Part Jet Energy (GeV)","Rec Jet Energy (GeV)");
241 fPRCorrPtH = new TH2F("PRCorrPt","Pt correlation part-rec jet",
243 SetProperties(fPRCorrPtH,"Part Jet P_{T} (GeV)","Rec Jet P_{T} (GeV)");
244 fPRCorrEtaH = new TH2F("PRCorrEta","Pseudorapidity correlation part-rec jet",
245 40,-1.0,1.0,40,-1.0,1.0);
246 SetProperties(fPRCorrEtaH,"part #eta","Rec Jet #eta");
247 fPRCorrPhiH = new TH2F("PRCorrPhi","Azimuthal angle correlation part-rec jet",
248 90,0.,2.0*TMath::Pi(),90,0.,2.0*TMath::Pi());
249 SetProperties(fPRCorrPhiH,"Part #phi","Rec Jet #phi");
251 if (fDoGenJ && fDoRecJ) {
252 fRGCorrEneH = new TH2F("RGCorrEne","Energy correlation rec jet-gen jet",
254 SetProperties(fRGCorrEneH,"Rec Jet Energy (GeV)","Gen Jet Energy (GeV)");
255 fRGCorrPtH = new TH2F("RGCorrPt","Pt correlation rec jet-gen jet",
257 SetProperties(fRGCorrPtH,"Rec Jet P_{T} (GeV)","Gen Jet P_{T} (GeV)");
258 fRGCorrEtaH = new TH2F("RGCorrEta","Pseudorapidity correlation rec jet-gen jet",
259 40,-1.0,1.0,40,-1.0,1.0);
260 SetProperties(fRGCorrEtaH,"Rec Jet #eta","Gen Jet #eta");
261 fRGCorrPhiH = new TH2F("RGCorrPhi","Azimuthal angle correlation rec jet-gen jet",
262 90,0.,2.0*TMath::Pi(),90,0.,2.0*TMath::Pi());
263 SetProperties(fRGCorrPhiH,"Rec Jet #phi","Gen Jet #phi");
267 void AliJetAnalysis::DefineCorr50H()
270 if (fDoPart && fDoRecJ) {
271 fPRCorr50EneH = new TH2F("PRCorr50Ene","Energy correlation part-rec jet",
273 SetProperties(fPRCorr50EneH,"Part Jet Energy (GeV)","Rec Jet Energy (GeV)");
274 fPRCorr50PtH = new TH2F("PRCorr50Pt","Pt correlation part-rec jet",
276 SetProperties(fPRCorr50PtH,"Part Jet P_{T} (GeV)","Rec Jet P_{T} (GeV)");
277 fPRCorr50EtaH = new TH2F("PRCorr50Eta","Pseudorapidity correlation part-rec jet",
278 40,-1.0,1.0,40,-1.0,1.0);
279 SetProperties(fPRCorr50EtaH,"part #eta","Rec Jet #eta");
280 fPRCorr50PhiH = new TH2F("PRCorr50Phi","Azimuthal angle correlation part-rec jet",
281 90,0.,2.0*TMath::Pi(),90,0.,2.0*TMath::Pi());
282 SetProperties(fPRCorr50PhiH,"Part #phi","Rec Jet #phi");
285 if (fDoGenJ && fDoRecJ) {
286 fRGCorr50EneH = new TH2F("RGCorr50Ene","Energy correlation rec jet-gen jet",
288 SetProperties(fRGCorr50EneH,"Rec Jet Energy (GeV)","Gen Jet Energy (GeV)");
289 fRGCorr50PtH = new TH2F("RGCorr50Pt","Pt correlation rec jet-gen jet",
291 SetProperties(fRGCorr50PtH,"Rec Jet P_{T} (GeV)","Gen Jet P_{T} (GeV)");
292 fRGCorr50EtaH = new TH2F("RGCorr50Eta","Pseudorapidity correlation rec jet-gen jet",
293 40,-1.0,1.0,40,-1.0,1.0);
294 SetProperties(fRGCorr50EtaH,"Rec Jet #eta","Gen Jet #eta");
295 fRGCorr50PhiH = new TH2F("RGCorr50Phi","Azimuthal angle correlation rec jet-gen jet",
296 90,0.,2.0*TMath::Pi(),90,0.,2.0*TMath::Pi());
297 SetProperties(fRGCorr50PhiH,"Rec Jet #phi","Gen Jet #phi");
301 void AliJetAnalysis::DefineShapH()
303 // leading reconstructed jet
305 fdEdrH = new TH2F("fdEdrH","dE/dr histo",20,0,1,40,0,200);
306 SetProperties(fdEdrH,"r","Rec Jet P_{T}");
307 fdEdrB = new TH2F("fdEdrB","dE/dr bkgdhisto",20,0,1,40,0,200);
308 SetProperties(fdEdrB,"r","Rec P_{T}");
309 fPtEneH2 = new TH2F("fPtEneH2","fPtEneH2",40,0,200,40,0,200);
310 SetProperties(fPtEneH2,"Rec Jet E","Rec Jet P_{T}");
311 fdEdrW = new TH1F("fdEdrW","weights for dE/dr",40,0,200);
312 SetProperties(fdEdrW,"Rec Jet P_{T}","weights");
314 fRShapSelH = new TH1F("RShapSel","Shape of generated jets (sel part)",20,0.,1.);
315 SetProperties(fRShapSelH,"r","1/N_{JET}#Sigma P_{T}(0,r)/P_{T}(0,R_{JET})");
316 fRShapRejH = new TH1F("RShapRej","Shape of generated jets (rej part)",20,0.,1.);
317 SetProperties(fRShapRejH,"r","1/N_{JET}#Sigma P_{T}(0,r)/P_{T}(0,R_{JET})");
318 fRShapAllH = new TH1F("RShapAll","Shape of generated jets (all part)",20,0.,1.);
319 SetProperties(fRShapAllH,"r","1/N_{JET}#Sigma P_{T}(0,r)/P_{T}(0,R_{JET})");
323 void AliJetAnalysis::DefineJtH()
325 // Define the histogram for J_T
327 fJtH = new TH2F("fJtH","J_{T} histogram",80,0.,4.,40,0.,200.);
328 SetProperties(fJtH,"J_{T}","Rec Jet P_{T}");
329 fJtB = new TH2F("fJtB","J_{T} bkgd histogram",80,0.,4.,40,0.,200.);
330 SetProperties(fJtB,"J_{T}","Rec P_{T}");
331 fJtW = new TH1F("fJtW","J_{T} weight",40,0,200);
332 SetProperties(fJtW,"J_{T}W","weight");
336 void AliJetAnalysis::DefinedNdxiH()
338 // Define the histogram for dN/dxi
340 fdNdxiH = new TH2F("fdNdxiH","dN/d#xi histo",200,0,10,40,0,200);
341 SetProperties(fdNdxiH,"xi","Rec Jet P_{T}");
342 fdNdxiB = new TH2F("fdNdxiB","dN/d#xi bkgd histo",200,0,10,40,0,200);
343 SetProperties(fdNdxiB,"xi","Rec P_{T}");
344 fdNdxiW = new TH1F("fdNdxiW","dN/d#xi histo",40,0,200);
345 SetProperties(fdNdxiW,"Rec Jet P_{T}","weights");
346 fPtEneH = new TH2F("fPtEneH","fPtEneH",40,0,200,40,0,200);
347 SetProperties(fPtEneH,"Rec Jet E","Rec Jet P_{T}");
351 void AliJetAnalysis::DefineFragH()
353 // leading reconstructed jet
355 fRFragSelH = new TH1F("RFragSel","Frag Fun of reconstructed jets (sel part)",20,0.,10.);
356 SetProperties(fRFragSelH,"#xi=ln(E_{JET}/E_{i})","1/N_{JET}dN_{ch}/d#xi");
357 fRFragRejH = new TH1F("RFragRej","Frag Fun of reconstructed jets (rej part)",20,0.,10.);
358 SetProperties(fRFragRejH,"#xi=ln(E_{JET}/E_{i})","1/N_{JET}dN_{ch}/d#xi");
359 fRFragAllH = new TH1F("RFragAll","Frag Fun of reconstructed jets (all part)",20,0.,10.);
360 SetProperties(fRFragAllH,"#xi=ln(E_{JET}/E_{i})","1/N_{JET}dN_{ch}/d#xi");
364 void AliJetAnalysis::DefineTrigH()
367 fGTriggerEneH = new TProfile("GTriggerEne","Generated energy (trigger bias)",
368 20, 0., 200., 0., 1., "S");
369 fGTriggerEneH->SetXTitle("E_{gen}");
370 fGTriggerEneH->SetYTitle("E_{rec}/E_{gen}");
371 // reconstructed energy
372 fRTriggerEneH = new TProfile("RTriggerEne","Reconstructed energy (trigger bias)",
373 20, 0., 200., 0., 1., "S");
374 fRTriggerEneH->SetXTitle("E_{rec}");
375 fRTriggerEneH->SetYTitle("E_{rec}/E_{gen}");
376 // generated energy vs generated/leading
377 fGPTriggerEneH = new TProfile("GPTriggerEne","Generated energy (trigger bias)",
378 20, 0., 200., 0., 1., "S");
379 fGPTriggerEneH->SetXTitle("E_{gen}");
380 fGPTriggerEneH->SetYTitle("E_{L}/E_{gen}");
381 // leading particle energy
382 fPTriggerEneH = new TProfile("PTriggerEne","Leading particle energy (trigger bias)",
383 20, 0., 200., 0., 1., "S");
384 fPTriggerEneH->SetXTitle("E_{L}/0.2");
385 fPTriggerEneH->SetYTitle("E_{L}/E_{gen}");
389 void AliJetAnalysis::SetProperties(TH1* h,const char* x, const char* y) const
391 //Set properties of histos (x and y title and error propagation)
397 ////////////////////////////////////////////////////////////////////////
398 // compute weights for dE/dr histogram
400 void AliJetAnalysis::SetdEdrWeight()
402 // Due to the limited acceptance, each bin in the dE/dr has a different
403 // weight given by the ratio of the area of a disk dR to the area
404 // within the eta acceptance. The weight depends on the eta position
405 // of the jet. Here a look up table for the weights is computed. It
406 // assumes |etaJet|<0.5 and |eta_lego|<0.9. It makes bins of 0.05
407 // units in eta. Note that this is fixed by the bin width chosen for
408 // the histogram --> this weights are tailored for the specific
409 // histogram definition used here!
411 // two dimensional table: first index, bin in eta of jet, second
412 // index bin of dE/dr histo
417 Float_t binSize = (xMax-xMin)/nBins;
419 Float_t da,ds,r1,r2,h1,h2,a1,a2,theta1,theta2,area1,area2;
421 for (Int_t i=0;i<(nBins/2);i++) {
422 // index of first histo bin needing a scale factor
424 for(Int_t j=0;j<nBins;j++) {
426 da = TMath::Pi()*(binSize*binSize)*(1.0+2.0*j);
428 if (j>=ji) { // compute missing area using segments of circle
433 a1=2.0*TMath::Sqrt(2.0*h1*r1-h1*h1);
434 a2=2.0*TMath::Sqrt(2.0*h2*r2-h2*h2);
435 theta1=2*TMath::ACos((r1-h1)/r1);
436 theta2=2*TMath::ACos((r2-h2)/r2);
437 area1=binSize*(r1*r1*theta1-a1*(r1-h1));
438 area2=binSize*(r2*r2*theta2-a2*(r2-h2));
439 ds = (da-(area2-area1))/da;
441 fWeightdEdr[i][j]=ds/da;
446 // get weight for dE/dr histogram
447 Float_t AliJetAnalysis::GetdEdrWeight(Float_t etaJet, Float_t r)
449 // Return the correponding weight for the dE/dr plot
453 Float_t binSize = (xMax-xMin)/nBins;
455 Float_t eta = TMath::Abs(etaJet);
456 if ((eta > 0.5) || (r > fdrdEdr)) return 0.0;
457 Int_t binJet = (Int_t) TMath::Floor(eta/binSize);
458 Int_t binR = (Int_t) TMath::Floor(r/binSize);
459 Float_t w = fWeightdEdr[binJet][binR];
464 ////////////////////////////////////////////////////////////////////////
467 void AliJetAnalysis::FillHistograms()
472 AliJetProductionDataPDC2004* runData = new AliJetProductionDataPDC2004();
477 for (Int_t iRun = fRunMin; iRun <= fRunMax; iRun++) {
480 sprintf(fn, "%s/%s.root", fDirectory, (runData->GetRunTitle(iRun)).Data());
481 jFile = new TFile(fn);
482 printf(" Analyzing run: %d %s\n", iRun,fn);
484 // Get reader header and events to be looped over
485 AliJetReaderHeader *jReaderH = (AliJetReaderHeader*)(jFile->Get(fReaderHeader));
486 if (fEventMin == -1) fEventMin = jReaderH->GetFirstEvent();
487 if (fEventMax == -1) {
488 fEventMax = jReaderH->GetLastEvent();
490 fEventMax = TMath::Min(fEventMax, jReaderH->GetLastEvent());
493 AliUA1JetHeader *jH = (AliUA1JetHeader *) (jFile->Get("AliUA1JetHeader"));
496 fWeight = runData->GetWeight(iRun)/ ( (Float_t) (fEventMax - fEventMin + 1));
499 for (Int_t i = fEventMin; i < fEventMax; i++) {
500 if (i%100 == 0) printf(" Analyzing event %d / %d \n",i,fEventMax);
502 // Get next tree with AliJet
504 sprintf(nameT, "TreeJ%d",i);
505 TTree *jetT =(TTree *)(jFile->Get(nameT));
506 if (fDoRecJ) jetT->SetBranchAddress("FoundJet", &fRecJ);
507 if (fDoGenJ) jetT->SetBranchAddress("GenJet", &fGenJ);
508 if (fDoPart) jetT->SetBranchAddress("LeadingPart", &fPart);
511 int nJets = fRecJ->GetNJets();
513 TArrayI inJet = fRecJ->GetInJet();
514 if(inJet.GetSize()>fminMult){ // removes events with low multiplicity
515 if (fDoKine) FillKineH();
516 if (fDoCorr) FillCorrH();
517 if (fDoCorr50) FillCorr50H();
518 if (fDoShap) FillShapH(jH->GetRadius());
519 if (fDoFrag) FillFragH();
520 if (fDoTrig) FillTrigH();
521 if (fDoJt) FillJtH();
522 if (fDodNdxi) FilldNdxiH();
524 delete jetT; // jet should be deleted before creating a new one
525 if(inJet.GetSize()>fminMult){ // removes events with low multiplicity
526 if (fDoBkgd && nJets>0) FillBkgd(i,iRun);
528 } // end loop over events in one file
529 if (jFile) jFile->Close();
531 } // end loop over files
534 void AliJetAnalysis::FillKineH()
537 if (fDoPart && fPart->LeadingFound()){
538 fPKineEneH->Fill(fPart->GetE(),fWeight);
539 fPKinePtH->Fill(fPart->GetPt(),fWeight);
540 fPKinePhiH->Fill(fPart->GetPhi(),fWeight);
541 fPKineEtaH->Fill(fPart->GetEta(),fWeight);
543 // leading generated jet
544 if (fDoGenJ && fGenJ->GetNJets()> 0){
545 fGKineEneH->Fill(fGenJ->GetE(0),fWeight);
546 fGKinePtH->Fill(fGenJ->GetPt(0),fWeight);
547 fGKinePhiH->Fill(fGenJ->GetPhi(0),fWeight);
548 fGKineEtaH->Fill(fGenJ->GetEta(0),fWeight);
550 // leading reconstructed jet
551 if (fDoRecJ && fRecJ->GetNJets()> 0) {
552 TArrayF p=fRecJ->GetPtFromSignal();
553 if (p[0]>fPercentage) {
554 fRKineEneH->Fill(fRecJ->GetE(0)/fEfactor,fWeight);
555 fRKinePtH->Fill(fRecJ->GetPt(0),fWeight);
556 fRKinePhiH->Fill(fRecJ->GetPhi(0),fWeight);
557 fRKineEtaH->Fill(fRecJ->GetEta(0),fWeight);
562 void AliJetAnalysis::FillCorrH()
564 // Fill correlation histograms
565 if (fDoPart && fPart->LeadingFound() && fDoGenJ && fGenJ->GetNJets()> 0)
566 Correlation(fPart->GetLeading(),fGenJ->GetJet(0),
567 fPGCorrEneH,fPGCorrPtH,fPGCorrEtaH,fPGCorrPhiH);
568 if (fDoPart && fPart->LeadingFound() && fDoRecJ && fRecJ->GetNJets()> 0) {
569 TArrayF p=fRecJ->GetPtFromSignal();
570 if (p[0]>fPercentage)
571 Correlation(fPart->GetLeading(),fRecJ->GetJet(0),
572 fPRCorrEneH,fPRCorrPtH,fPRCorrEtaH,fPRCorrPhiH);
574 if (fDoGenJ && fGenJ->GetNJets()> 0 && fDoRecJ && fRecJ->GetNJets()> 0) {
575 TArrayF p=fRecJ->GetPtFromSignal();
576 if (p[0]>fPercentage)
577 Correlation(fRecJ->GetJet(0), fGenJ->GetJet(0),
578 fRGCorrEneH,fRGCorrPtH,fRGCorrEtaH,fRGCorrPhiH);
582 void AliJetAnalysis::Correlation(TLorentzVector *lv1,TLorentzVector *lv2,
583 TH2F *h1, TH2F *h2, TH2F *h3, TH2F *h4)
585 // Correlation histograms
586 h1->Fill(lv1->E(),lv2->E(),fWeight);
587 h2->Fill(lv1->Pt(),lv2->Pt(),fWeight);
588 h3->Fill(lv1->Eta(),lv2->Eta(),fWeight);
590 p1 = ((lv1->Phi() < 0) ? (lv1->Phi()) + 2. * TMath::Pi() : lv1->Phi());
591 p2 = ((lv2->Phi() < 0) ? (lv2->Phi()) + 2. * TMath::Pi() : lv2->Phi());
592 h4->Fill(p1,p2,fWeight);
595 void AliJetAnalysis::FillCorr50H()
597 // Fill correlation histograms when one particle has > 50% of jet energy
598 if (fDoRecJ && fRecJ->GetNJets()> 0) {
599 TArrayF p = fRecJ->GetPtFromSignal();
600 if (p[0]>fPercentage) {
601 if (fDoPart && fPart->LeadingFound())
602 Correlation50(fRecJ, fPart->GetLeading(),fRecJ->GetJet(0),
603 fPRCorr50EneH,fPRCorr50PtH,fPRCorr50EtaH,fPRCorr50PhiH);
604 if (fDoGenJ && fGenJ->GetNJets()> 0)
605 Correlation50(fRecJ, fRecJ->GetJet(0), fGenJ->GetJet(0),
606 fRGCorr50EneH,fRGCorr50PtH,fRGCorr50EtaH,fRGCorr50PhiH);
611 void AliJetAnalysis::Correlation50(AliJet *j,TLorentzVector *lv1,TLorentzVector *lv2,
612 TH2F *h1, TH2F *h2, TH2F *h3, TH2F *h4)
614 // Correlation histograms when one particle has > 50% of jet energy
615 TArrayF ptin = j->GetPtIn();
616 TArrayF etain = j->GetEtaIn();
617 TArrayI inJet = j->GetInJet();
620 for(Int_t i=0;i<(inJet.GetSize());i++) {
622 Float_t t1 = TMath::Tan(2.0*TMath::ATan(TMath::Exp(-etain[i])));
623 Float_t x = (ptin[i]*TMath::Sqrt(1.+1./(t1*t1)))/(j->GetE(0));
627 if (flag>1) cout << " Flag = " << flag << endl;
629 h1->Fill(lv1->E(),lv2->E(),fWeight);
630 h2->Fill(lv1->Pt(),lv2->Pt(),fWeight);
631 h3->Fill(lv1->Eta(),lv2->Eta(),fWeight);
633 p1 = ((lv1->Phi() < 0) ?
634 (lv1->Phi()) + 2. * TMath::Pi() : lv1->Phi());
635 p2 = ((lv2->Phi() < 0) ?
636 (lv2->Phi()) + 2. * TMath::Pi() : lv2->Phi());
637 h4->Fill(p1,p2,fWeight);
641 void AliJetAnalysis::FillJtH()
643 // Fill J_T histogram
644 if (fRecJ->GetNJets()> 0) {
645 fjv3X = 0.0; fjv3Y = 0.0; fjv3Z = 0.0;
646 TArrayF p=fRecJ->GetPtFromSignal();
647 if (p[0]>fPercentage) {
649 const TVector3 kJv3 = fRecJ->GetJet(0)->Vect();
650 fjv3X = kJv3.X(); fjv3Y = kJv3.Y(); fjv3Z = kJv3.Z();
652 TArrayI inJet = fRecJ->GetInJet();
653 TArrayF etain = fRecJ->GetEtaIn();
654 TArrayF ptin = fRecJ->GetPtIn();
655 TArrayF phiin = fRecJ->GetPhiIn();
656 Float_t deta, dphi,jt, dr;
657 for(Int_t i=0;i<inJet.GetSize();i++) {
658 deta = etain[i] - fRecJ->GetEta(0);
659 dphi = phiin[i] - fRecJ->GetPhi(0);
660 if (dphi < -TMath::Pi()) dphi= -dphi - 2.0 * TMath::Pi();
661 if (dphi > TMath::Pi()) dphi = 2.0 * TMath::Pi() - dphi;
662 dr = TMath::Sqrt(deta * deta + dphi * dphi);
663 if ((dr<fdrJt) && (ptin[i] > fPartPtCut)) {
664 trk.SetPtEtaPhi(ptin[i],etain[i],phiin[i]);
665 jt = TMath::Sin(trk.Angle(kJv3))*trk.Mag();
666 fJtH->Fill(jt,fRecJ->GetPt(0),fWeight);
669 fJtW->Fill(fRecJ->GetPt(0),fWeight);
675 void AliJetAnalysis::FilldNdxiH()
677 // Fill dN/d#xi histograms
678 if (fRecJ->GetNJets()> 0) {
679 TArrayF p=fRecJ->GetPtFromSignal();
680 if (p[0]>fPercentage) {
682 TArrayI inJet = fRecJ->GetInJet();
683 TArrayF etain = fRecJ->GetEtaIn();
684 TArrayF ptin = fRecJ->GetPtIn();
685 TArrayF phiin = fRecJ->GetPhiIn();
686 Float_t xi,t1,ene,dr,deta,dphi;
687 for(Int_t i=0;i<inJet.GetSize();i++) {
688 deta = etain[i] - fRecJ->GetEta(0);
689 dphi = phiin[i] - fRecJ->GetPhi(0);
690 if (dphi < -TMath::Pi()) dphi= -dphi - 2.0 * TMath::Pi();
691 if (dphi > TMath::Pi()) dphi = 2.0 * TMath::Pi() - dphi;
692 dr = TMath::Sqrt(deta * deta + dphi * dphi);
693 if ((dr<fdrdNdxi) && (ptin[i] > fPartPtCut)) {
694 t1 = TMath::Tan(2.0*TMath::ATan(TMath::Exp(-etain[i])));
695 ene = ptin[i]*TMath::Sqrt(1.+1./(t1*t1));
696 xi = (Float_t) TMath::Log((fRecJ->GetE(0)/fEfactor)/ene);
697 fdNdxiH->Fill(xi,fRecJ->GetPt(0),fWeight);
700 fdNdxiW->Fill(fRecJ->GetPt(0),fWeight);
701 fPtEneH->Fill(fRecJ->GetE(0)/fEfactor,fRecJ->GetPt(0),fWeight);
707 void AliJetAnalysis::FillBkgd(Int_t eventN, Int_t runN)
709 // Background calculated with hijing events (no pythia)
710 if (fp0>fPercentage) {
711 fPtJ=0.,fEJ=0.,fEtaJ=0.,fPhiJ=0.;
712 // Background calculated with hijing events (no pythia)
713 AliJetProductionDataPDC2004* runDataB = new AliJetProductionDataPDC2004();
717 sprintf(fnB, "%s/%s.root", fBkgdDirectory, (runDataB->GetRunTitle(runN)).Data());
718 jFileB = new TFile(fnB);
721 sprintf(nameB, "TreeJ%d",eventN);
722 TTree *jetB =(TTree *)(jFileB->Get(nameB));
723 jetB->SetBranchAddress("FoundJet", &fRecB);
726 TArrayI inJetB = fRecB->GetInJet();
727 TArrayF etainB = fRecB->GetEtaIn();
728 TArrayF ptinB = fRecB->GetPtIn();
729 TArrayF phiinB = fRecB->GetPhiIn();
730 fPtJ = fRecJ->GetPt(0);
731 fEJ = fRecJ->GetE(0);
732 fEtaJ = fRecJ->GetEta(0);
733 fPhiJ = fRecJ->GetPhi(0);
734 Float_t t1,ene,xi,detaB,dphiB,drB,jt,wB;
737 jv3B.SetX(fjv3X); jv3B.SetY(fjv3Y); jv3B.SetZ(fjv3Z);
739 for(Int_t k=0;k<inJetB.GetSize();k++){
740 if(ptinB[k] > fPartPtCut){
741 detaB = etainB[k] - fEtaJ;
742 dphiB = phiinB[k] - fPhiJ;
743 if (dphiB < -TMath::Pi()) dphiB= -dphiB - 2.0 * TMath::Pi();
744 if (dphiB > TMath::Pi()) dphiB = 2.0 * TMath::Pi() - dphiB;
745 drB = TMath::Sqrt(detaB * detaB + dphiB * dphiB);
746 t1 = TMath::Tan(2.0*TMath::ATan(TMath::Exp(-etainB[k])));
747 ene = ptinB[k]*TMath::Sqrt(1.+1./(t1*t1));
748 trkB.SetPtEtaPhi(ptinB[k],etainB[k],phiinB[k]);
751 xi = (Float_t) TMath::Log(fEJ/ene);
752 fdNdxiB->Fill(xi,fPtJ,fWeight);
756 jt = TMath::Sin(trkB.Angle(jv3B))*(trkB.Mag());
757 fJtB->Fill(jt,fPtJ,fWeight);
761 wB = GetdEdrWeight(fEtaJ,drB)*fWeight*ene;
762 fdEdrB->Fill(drB,fPtJ,wB);
767 if (jFileB) jFileB->Close();
772 void AliJetAnalysis::FillShapH(Float_t r)
774 // Fill jet shape histograms
775 if (fDoRecJ && fRecJ->GetNJets()> 0) {
776 TArrayF p=fRecJ->GetPtFromSignal();
777 if (p[0]>fPercentage) {
778 Shape(fRecJ,fRShapSelH,fRShapRejH,fRShapAllH,fdEdrH,fPtEneH2,fdEdrW,r);
785 void AliJetAnalysis::Shape(AliJet *j,TH1F* hs, TH1F* hr, TH1F* ha,
786 TH2F *hdedr, TH2F *hptene, TH1F* wdedr, Float_t radius)
789 TArrayI inJet = j->GetInJet();
790 TArrayF etain = j->GetEtaIn();
791 TArrayF ptin = j->GetPtIn();
792 TArrayF phiin = j->GetPhiIn();
794 // first compute dE/dr histo
795 Float_t etaj = j->GetEta(0);
796 Float_t ene,w,deta,dphi,dr,t1;
797 for(Int_t i=0;i<inJet.GetSize();i++) {
798 deta = etain[i] - j->GetEta(0);
799 dphi = phiin[i] - j->GetPhi(0);
800 if (dphi < -TMath::Pi()) dphi= -dphi - 2.0 * TMath::Pi();
801 if (dphi > TMath::Pi()) dphi = 2.0 * TMath::Pi() - dphi;
802 dr = TMath::Sqrt(deta * deta + dphi * dphi);
803 if ((dr<fdrdEdr) && (ptin[i] > fPartPtCut)) {
804 t1 = TMath::Tan(2.0*TMath::ATan(TMath::Exp(-etain[i])));
805 ene = ptin[i]*TMath::Sqrt(1.+1./(t1*t1));
806 w = GetdEdrWeight(etaj,dr)*fWeight*ene;
807 hdedr->Fill(dr,j->GetPt(0),w);
810 hptene->Fill(fRecJ->GetE(0),fRecJ->GetPt(0),fWeight);
811 wdedr->Fill(j->GetPt(0),fWeight);
813 // now compute shape histos
814 Int_t nBins = ha->GetNbinsX();
815 Float_t xMin = ha->GetXaxis()->GetXmin();
816 Float_t xMax = ha->GetXaxis()->GetXmax();
817 Float_t binSize,halfBin;
818 binSize = (xMax-xMin)/nBins;
820 Float_t rptS[20], rptR[20], rptA[20];
821 for(Int_t i=0;i<nBins;i++) rptS[i]=rptR[i]=rptA[i]=0.0;
822 // fill bins in r for leading jet
823 for(Int_t i=0;i<inJet.GetSize();i++) {
824 if (inJet[i] == 1 || (inJet[i] == -1 && fPythia)) {
825 deta = etain[i] - j->GetEta(0);
826 dphi = phiin[i] - j->GetPhi(0);
827 if (dphi < -TMath::Pi()) dphi= -dphi - 2.0 * TMath::Pi();
828 if (dphi > TMath::Pi()) dphi = 2.0 * TMath::Pi() - dphi;
829 dr = TMath::Sqrt(deta * deta + dphi * dphi);
830 Float_t rR = dr/radius;
831 Int_t bin = (Int_t) TMath::Floor(rR/binSize);
832 rptA[bin]+=ptin[i]/(j->GetPt(0));
833 if (inJet[i] == 1) rptS[bin]+=ptin[i]/(j->GetPt(0));
834 if (fPythia && inJet[i] == -1)
835 rptR[bin]+=ptin[i]/(j->GetPt(0));
839 // compute shape and fill histogram
840 Float_t ptS,ptR,ptA,r;
842 for (Int_t i=0;i<nBins;i++) {
846 r=(i+1)*binSize-halfBin;
847 hs->Fill(r,ptS*fWeight);
849 hr->Fill(r,ptR*fWeight);
850 ha->Fill(r,ptA*fWeight);
855 void AliJetAnalysis::FillFragH()
857 // Fill fragmentation histogram
858 if (fDoRecJ && fRecJ->GetNJets()> 0) {
859 TArrayF p=fRecJ->GetPtFromSignal();
860 if (p[0]>fPercentage) {
861 FragFun(fRecJ,fRFragSelH,fRFragRejH,fRFragAllH);
867 void AliJetAnalysis::FragFun(AliJet *j,TH1F* hs, TH1F* hr, TH1F* ha)
869 // Calculate de fragmentation function
870 TArrayI inJet = j->GetInJet();
871 TArrayF etain = j->GetEtaIn();
872 TArrayF ptin = j->GetPtIn();
876 for(Int_t i=0;i<(inJet.GetSize());i++) {
877 if (inJet[i] == 1 || (inJet[i] == -1 && fPythia)) {
878 t1 = TMath::Tan(2.0*TMath::ATan(TMath::Exp(-etain[i])));
879 ene = ptin[i]*TMath::Sqrt(1.+1./(t1*t1));
880 xi = (Float_t) TMath::Log((j->GetE(0))/ene);
881 if (fPythia) ha->Fill(xi,fWeight);
882 if (inJet[i] == 1) hs->Fill(xi,fWeight);
883 if (fPythia && inJet[i] == -1) hr->Fill(xi,fWeight);
888 void AliJetAnalysis:: FillTrigH()
890 // Fill trigger bias histograms
891 if(fDoTrig && fGenJ->GetNJets()>0 && fRecJ->GetNJets()>0){
892 TArrayF p=fRecJ->GetPtFromSignal();
893 if (p[0]>fPercentage) {
894 float genEne = fGenJ->GetE(0);
895 float recEne = fRecJ->GetE(0);
896 float eneRatio = (recEne/fEfactor)/genEne;
898 fGTriggerEneH->Fill(genEne, eneRatio, fWeight);
899 fRTriggerEneH->Fill(recEne/fEfactor, eneRatio, fWeight);
901 if (fPart->LeadingFound()){
902 float leaEne = fPart->GetE();
903 float eneRatio2 = leaEne/genEne;
904 fGPTriggerEneH->Fill(genEne, eneRatio2, fWeight);
905 fPTriggerEneH->Fill(leaEne/0.2, eneRatio2, fWeight);
912 ////////////////////////////////////////////////////////////////////////
913 // Normalize histogrames
915 void AliJetAnalysis::NormHistograms()
917 // normalize shape histograms
919 if (fDoRecJ && fWShapR>0.) { // leading reconstructed jet
920 fRShapSelH->Scale(1.0/fWShapR);
921 fRShapRejH->Scale(1.0/fWShapR);
922 fRShapAllH->Scale(1.0/fWShapR);
926 // normalize fragmentation function histograms
928 if (fDoRecJ && fWFragR>0.) { // leading reconstructed jet
929 fRFragSelH->Scale(2.0/fWFragR);
930 fRFragRejH->Scale(2.0/fWFragR);
931 fRFragAllH->Scale(2.0/fWFragR);
936 ////////////////////////////////////////////////////////////////////////
938 void AliJetAnalysis::PlotHistograms()
940 // Plot histogramas (to be done...)
941 if (fDoKine) PlotKineH();
942 if (fDoCorr) PlotCorrH();
943 if (fDoCorr50) PlotCorr50H();
944 if (fDoShap) PlotShapH();
945 if (fDoFrag) PlotFragH();
946 if (fDoTrig) PlotTrigH();
949 void AliJetAnalysis::PlotKineH() const
957 void AliJetAnalysis::PlotCorrH() const
960 if (fDoPart && fDoGenJ) ;
961 if (fDoPart && fDoRecJ) ;
962 if (fDoGenJ && fDoRecJ) ;
964 void AliJetAnalysis::PlotCorr50H() const
967 if (fDoPart && fDoGenJ) ;
968 if (fDoPart && fDoRecJ) ;
969 if (fDoGenJ && fDoRecJ) ;
972 void AliJetAnalysis::PlotShapH() const
979 void AliJetAnalysis::PlotFragH() const
986 void AliJetAnalysis::PlotTrigH()
992 ////////////////////////////////////////////////////////////////////////
994 void AliJetAnalysis::SaveHistograms()
997 TFile *fOut = new TFile(fFile,"recreate");
999 if (fDoKine) SaveKineH();
1000 if (fDoCorr) SaveCorrH();
1001 if (fDoCorr50) SaveCorr50H();
1002 if (fDoShap) SaveShapH();
1003 if (fDoFrag) SaveFragH();
1004 if (fDoTrig) SaveTrigH();
1005 if (fDoJt) SaveJtH();
1006 if (fDodNdxi) SavedNdxiH();
1010 void AliJetAnalysis::SaveKineH()
1012 // Save kinematic histograms
1014 fPKineEneH->Write();
1016 fPKinePhiH->Write();
1017 fPKineEtaH->Write();
1021 fGKineEneH->Write();
1023 fGKinePhiH->Write();
1024 fGKineEtaH->Write();
1028 fRKineEneH->Write();
1030 fRKinePhiH->Write();
1031 fRKineEtaH->Write();
1035 void AliJetAnalysis::SaveCorrH()
1037 // Save correlation histograms
1038 if (fDoPart && fDoGenJ) {
1039 fPGCorrEneH->Write();
1040 fPGCorrPtH->Write();
1041 fPGCorrEtaH->Write();
1042 fPGCorrPhiH->Write();
1045 if (fDoPart && fDoRecJ) {
1046 fPRCorrEneH->Write();
1047 fPRCorrPtH->Write();
1048 fPRCorrEtaH->Write();
1049 fPRCorrPhiH->Write();
1052 if (fDoGenJ && fDoRecJ) {
1053 fRGCorrEneH->Write();
1054 fRGCorrPtH->Write();
1055 fRGCorrEtaH->Write();
1056 fRGCorrPhiH->Write();
1060 void AliJetAnalysis::SaveCorr50H()
1062 // Save correlation histograms (special case)
1063 if (fDoPart && fDoRecJ) {
1064 fPRCorr50EneH->Write();
1065 fPRCorr50PtH->Write();
1066 fPRCorr50EtaH->Write();
1067 fPRCorr50PhiH->Write();
1069 if (fDoGenJ && fDoRecJ) {
1070 fRGCorr50EneH->Write();
1071 fRGCorr50PtH->Write();
1072 fRGCorr50EtaH->Write();
1073 fRGCorr50PhiH->Write();
1077 void AliJetAnalysis::SaveShapH()
1079 // Save jet shape histograms
1081 fRShapSelH->Write();
1083 if(fDoBkgd) fdEdrB->Write();
1087 fRShapRejH->Write();
1088 fRShapAllH->Write();
1093 void AliJetAnalysis::SaveJtH()
1095 // Save J_T histograms
1098 if(fDoBkgd) fJtB->Write();
1103 void AliJetAnalysis::SavedNdxiH()
1105 // Save dN/d#xi histograms
1108 if(fDoBkgd) fdNdxiB->Write();
1114 void AliJetAnalysis::SaveFragH()
1116 // Save fragmentation histograms
1118 fRFragSelH->Write();
1120 fRFragRejH->Write();
1121 fRFragAllH->Write();
1126 void AliJetAnalysis::SaveTrigH()
1128 // Save trigger bias histograms
1130 fGTriggerEneH->Write();
1131 fRTriggerEneH->Write();
1132 fGPTriggerEneH->Write();
1133 fPTriggerEneH->Write();
1137 ////////////////////////////////////////////////////////////////////////
1138 // main Analysis function
1140 void AliJetAnalysis::Analyze()
1145 // leading generated jet
1146 // leading reconstructed jet
1148 // Correlations amd resolutions
1149 // a) correlations in energy, pt, phi, eta
1150 // b) resolutions in energy, pt, phi, eta, r
1151 // leading particle and leading generated jet
1152 // leading particle and leading reconstructed jet
1153 // leading generated jet and leading reconstructed jet
1155 // Fragmentation functions and Shapes
1156 // a) integrated over all pt
1158 // b.1) only for user selected particles in jet
1159 // b.2) only for user rejected particles in jet
1160 // b.3) for all particles in jet