3 #include "AliHighMultiplicitySelector.h"
11 #include <TParticle.h>
14 #include <TGeoManager.h>
22 #include <AliRunLoader.h>
25 #include <AliITSgeom.h>
26 #include <AliITSLoader.h>
27 #include <AliITSdigitSPD.h>
28 #include <AliITSRecPoint.h>
30 #include "AliPWG0Helper.h"
33 // Selector that produces plots needed for the high multiplicity analysis with the
38 ClassImp(AliHighMultiplicitySelector)
40 AliHighMultiplicitySelector::AliHighMultiplicitySelector() :
54 fCentralRegion(kFALSE)
57 // Constructor. Initialization of pointers
61 AliHighMultiplicitySelector::~AliHighMultiplicitySelector()
67 // histograms are in the output list and deleted when the output
68 // list is deleted by the TSelector dtor
71 void AliHighMultiplicitySelector::SlaveBegin(TTree *tree)
75 AliSelectorRL::SlaveBegin(tree);
77 fChipsFired = new TH2F("fChipsFired", ";Module;Chip;Count", 240, -0.5, 239.5, 5, -0.5, 4.5);
79 fPrimaryL1 = new TNtuple("fPrimaryL1", "", "multiplicity:firedChips:chipsByPrimaries:clusters");
80 fPrimaryL2 = new TNtuple("fPrimaryL2", "", "multiplicity:firedChips:chipsByPrimaries:clusters");
82 fClusterZL1 = new TH1F("fClusterZL1", ";z", 400, -20, 20);
83 fClusterZL2 = new TH1F("fClusterZL2", ";z", 400, -20, 20);
86 void AliHighMultiplicitySelector::Init(TTree* tree)
88 // read the user objects
90 AliSelectorRL::Init(tree);
92 // enable only the needed branches
95 tree->SetBranchStatus("*", 0);
96 tree->SetBranchStatus("fTriggerMask", 1);
98 /*if (fTree->GetCurrentFile())
100 TString fileName(fTree->GetCurrentFile()->GetName());
101 fileName.ReplaceAll("AliESDs", "geometry");
104 TGeoManager::Import(fileName);
109 Bool_t AliHighMultiplicitySelector::Process(Long64_t entry)
115 if (AliSelectorRL::Process(entry) == kFALSE)
118 // Check prerequisites
121 AliDebug(AliLog::kError, "ESD branch not available");
125 Bool_t eventTriggered = AliPWG0Helper::IsEventTriggered(fESD, AliPWG0Helper::kMB1);
129 AliDebug(AliLog::kDebug, "Event not triggered. Skipping.");
133 AliStack* stack = GetStack();
136 AliDebug(AliLog::kError, "Stack not available");
140 Int_t nPrim = stack->GetNprimary();
141 Int_t multiplicity21 = 0;
142 Int_t multiplicity16 = 0;
144 for (Int_t iMc = 0; iMc < nPrim; ++iMc)
146 AliDebug(AliLog::kDebug+1, Form("MC Loop: Processing particle %d.", iMc));
148 TParticle* particle = stack->Particle(iMc);
152 AliDebug(AliLog::kError, Form("UNEXPECTED: particle with label %d not found in stack (mc loop).", iMc));
156 if (AliPWG0Helper::IsPrimaryCharged(particle, nPrim) == kFALSE)
161 if (TMath::Abs(particle->Eta()) < 1.05)
163 if (TMath::Abs(particle->Eta()) < 0.8)
168 if (TMath::Abs(particle->Eta()) < 2.1)
170 if (TMath::Abs(particle->Eta()) < 1.6)
173 }// end of mc particle
175 AliRunLoader* runLoader = GetRunLoader();
178 AliDebug(AliLog::kError, "runloader not available");
182 // TDirectory::TContext restores the current directory is restored when the scope ends.
183 // This helps around ROOT bug #26025 and is good behaviour anyway
184 TDirectory::TContext context(0);
185 AliITSLoader* loader = (AliITSLoader*) runLoader->GetLoader( "ITSLoader" );
186 loader->LoadDigits("READ");
187 TTree* treeD = loader->TreeD();
190 AliDebug(AliLog::kError, "Could not retrieve TreeD of ITS");
194 treeD->SetBranchStatus("*", 0);
195 treeD->SetBranchStatus("ITSDigitsSPD.fTracks*", 1);
196 treeD->SetBranchStatus("ITSDigitsSPD.fCoord1", 1);
198 TClonesArray* digits = 0;
199 treeD->SetBranchAddress("ITSDigitsSPD", &digits);
203 // each value for both layers
204 Int_t totalNumberOfFO[2];
205 Int_t chipsHitByPrimaries[2];
206 //Int_t chipsHitBySecondaries[2];
208 for (Int_t i=0; i<2; ++i)
210 totalNumberOfFO[i] = 0;
211 chipsHitByPrimaries[i] = 0;
212 //chipsHitBySecondaries[i] = 0;
215 Int_t startSPD = 0; //geom->GetStartSPD();
216 Int_t lastSPD = 239; //geom->GetLastSPD();
218 //printf("%d %d\n", startSPD, lastSPD);
219 // for (Int_t l=0; l<240; ++l) { AliITSgeomTGeo::GetModuleId(l, i, j, k); printf("%d --> %d\n", l, i); }
221 // loop over modules (ladders)
222 for (Int_t moduleIndex=startSPD; moduleIndex<lastSPD+1; moduleIndex++)
226 if ((moduleIndex % 4) == 0 || (moduleIndex % 4) == 3)
230 Int_t currentLayer = 0;
231 if (moduleIndex >= 80)
234 treeD->GetEvent(moduleIndex);
236 // get number of digits in this module
237 Int_t ndigitsInModule = digits->GetEntriesFast();
239 // get number of digits in each chip of the module
240 Int_t ndigitsInChip[5];
241 Bool_t hitByPrimary[5];
242 for( Int_t iChip=0; iChip<5; iChip++)
244 ndigitsInChip[iChip]=0;
245 hitByPrimary[iChip] = kFALSE;
248 // loop over digits in this module
249 for (Int_t iDig=0; iDig<ndigitsInModule; iDig++)
251 AliITSdigitSPD* dp = (AliITSdigitSPD*) digits->At(iDig);
252 Int_t column = dp->GetCoord1();
253 Int_t isChip = column / 32;
255 //printf("Digit %d has column %d which translates to chip %d\n", iDig, column, isChip);
257 fChipsFired->Fill(moduleIndex, isChip);
259 ndigitsInChip[isChip]++;
261 Bool_t debug = kFALSE;
263 // find out which particle caused this chip to fire
264 // if we find at least one primary we consider this chip being fired by a primary
265 for (Int_t track=0; track<10; ++track)
267 Int_t label = dp->GetTrack(track);
273 printf("track %d contains label %d\n", track, label);
275 TParticle* particle = stack->Particle(label);
279 AliDebug(AliLog::kError, Form("UNEXPECTED: particle with label %d not found in stack (digit loop).", label));
286 printf("statuscode = %d, p = %f, m = %d\n", particle->GetStatusCode(), particle->P(), particle->GetFirstMother());
289 // TODO delta electrons should be traced back to their mother. this is e.g. solved in AliITSClusterFinderV2::CheckLabels2
290 while (particle->P() < 0.02 && particle->GetStatusCode() == 0 && particle->GetFirstMother() >= 0)
292 label = particle->GetFirstMother();
293 particle = stack->Particle(label);
301 printf("statuscode = %d, p = %f, m = %d\n", particle->GetStatusCode(), particle->P(), particle->GetFirstMother());
308 AliDebug(AliLog::kError, Form("UNEXPECTED: particle with label %d not found in stack (digit loop, finding delta electrons).", label));
315 if (AliPWG0Helper::IsPrimaryCharged(particle, nPrim) == kFALSE)
319 printf("This was a primary (or delta-electron of a primary)!\n");
321 hitByPrimary[isChip] = kTRUE;
325 // get number of FOs in the module
326 for (Int_t ifChip=0; ifChip<5; ifChip++)
327 if( ndigitsInChip[ifChip] >= 1 )
329 totalNumberOfFO[currentLayer]++;
330 if (hitByPrimary[ifChip])
332 chipsHitByPrimaries[currentLayer]++;
335 // chipsHitBySecondaries[currentLayer]++;
339 //printf("Fired chips: %d %d\n", totalNumberOfFOLayer1, totalNumberOfFOLayer2);
342 Int_t clustersLayer[2];
343 clustersLayer[0] = 0;
344 clustersLayer[1] = 0;
346 loader->LoadRecPoints("READ");
347 TTree* treeR = loader->TreeR();
350 AliDebug(AliLog::kError, "Could not retrieve TreeR of ITS");
355 //treeR->SetBranchStatus("*", 0);
357 TClonesArray* itsClusters = 0;
358 treeR->SetBranchAddress("ITSRecPoints", &itsClusters);
360 Int_t nTreeEntries = treeR->GetEntries();
361 for (Int_t iEntry = 0; iEntry < nTreeEntries; ++iEntry)
363 if (!treeR->GetEvent(iEntry))
366 Int_t nClusters = itsClusters->GetEntriesFast();
370 AliITSRecPoint* cluster = (AliITSRecPoint*) itsClusters->UncheckedAt(nClusters);
372 if (cluster->GetLayer() == 0)
375 fClusterZL1->Fill(cluster->GetZ());
377 else if (cluster->GetLayer() == 1)
380 fClusterZL2->Fill(cluster->GetZ());
385 fPrimaryL1->Fill(multiplicity21, totalNumberOfFO[0], chipsHitByPrimaries[0], clustersLayer[0]);
386 fPrimaryL2->Fill(multiplicity16, totalNumberOfFO[1], chipsHitByPrimaries[1], clustersLayer[1]);
391 Bool_t AliHighMultiplicitySelector::Notify()
393 // get next ITS runloader
395 AliRunLoader* runLoader = GetRunLoader();
399 AliITSLoader* loader = (AliITSLoader* )runLoader->GetLoader( "ITSLoader" );
402 loader->UnloadDigits();
403 loader->UnloadRecPoints();
407 return AliSelectorRL::Notify();
410 void AliHighMultiplicitySelector::SlaveTerminate()
412 // The SlaveTerminate() function is called after all entries or objects
413 // have been processed. When running with PROOF SlaveTerminate() is called
414 // on each slave server.
416 AliSelectorRL::SlaveTerminate();
418 // Add the histograms to the output on each slave server
421 AliDebug(AliLog::kError, "ERROR: Output list not initialized.");
425 fOutput->Add(fChipsFired);
426 fOutput->Add(fPrimaryL1);
427 fOutput->Add(fPrimaryL2);
428 fOutput->Add(fClusterZL1);
429 fOutput->Add(fClusterZL2);
432 void AliHighMultiplicitySelector::Terminate()
434 // The Terminate() function is the last function to be called during
435 // a query. It always runs on the client, it can be used to present
436 // the results graphically or save the results to file.
438 AliSelectorRL::Terminate();
440 fChipsFired = dynamic_cast<TH2F*> (fOutput->FindObject("fChipsFired"));
441 fPrimaryL1 = dynamic_cast<TNtuple*> (fOutput->FindObject("fPrimaryL1"));
442 fPrimaryL2 = dynamic_cast<TNtuple*> (fOutput->FindObject("fPrimaryL2"));
443 fClusterZL1 = dynamic_cast<TH1F*> (fOutput->FindObject("fClusterZL1"));
444 fClusterZL2 = dynamic_cast<TH1F*> (fOutput->FindObject("fClusterZL2"));
446 if (!fClusterZL1 || !fClusterZL2 || !fChipsFired || !fPrimaryL1 || !fPrimaryL2)
448 AliError("Histograms not available");
455 void AliHighMultiplicitySelector::WriteHistograms(const char* filename)
457 // write the histograms to a file
459 TFile* file = TFile::Open(filename, "RECREATE");
461 fChipsFired->Write();
464 fClusterZL1->Write();
465 fClusterZL2->Write();
470 void AliHighMultiplicitySelector::ReadHistograms(const char* filename)
472 // read the data from a file and fill histograms
474 TFile* file = TFile::Open(filename);
479 fPrimaryL1 = dynamic_cast<TNtuple*> (file->Get("fPrimaryL1"));
480 fPrimaryL2 = dynamic_cast<TNtuple*> (file->Get("fPrimaryL2"));
481 fChipsFired = dynamic_cast<TH2F*> (file->Get("fChipsFired"));
482 fClusterZL1 = dynamic_cast<TH1F*> (file->Get("fClusterZL1"));
483 fClusterZL2 = dynamic_cast<TH1F*> (file->Get("fClusterZL2"));
485 #define MULT 1001, -0.5, 1000.5
486 #define BINNING_LAYER1 401, -0.5, 400.5
487 #define BINNING_LAYER2 801, -0.5, 800.5
489 fChipsLayer1 = new TH1F("fChipsLayer1", "Layer 1;Fired Chips;Count", BINNING_LAYER1);
490 fChipsLayer2 = new TH1F("fChipsLayer2", "Layer 2;Fired Chips;Count", BINNING_LAYER2);
492 fL1vsL2 = new TH2F("fL1vsL2", ";Fired Chips Layer 1;Fired Chips Layer 2", BINNING_LAYER1, BINNING_LAYER2);
493 fMvsL1 = new TH2F("fMvsL1", ";true multiplicity;fired chips layer1", MULT, BINNING_LAYER1);
494 fMvsL2 = new TH2F("fMvsL2", ";true multiplicity;fired chips layer2", MULT, BINNING_LAYER2);
496 fClvsL1 = new TH2F("fClvsL1", ";clusters layer1;fired chips layer1", MULT, BINNING_LAYER1);
497 fClvsL2 = new TH2F("fClvsL2", ";clusters layer2;fired chips layer2", MULT, BINNING_LAYER2);
499 for (Int_t i = 0; i < fPrimaryL1->GetEntries(); i++)
501 fPrimaryL1->GetEvent(i);
502 fPrimaryL2->GetEvent(i);
504 Int_t multiplicity21 = (Int_t) fPrimaryL1->GetArgs()[0];
505 Int_t multiplicity16 = (Int_t) fPrimaryL2->GetArgs()[0];
507 Int_t totalNumberOfFO[2];
508 totalNumberOfFO[0] = (Int_t) fPrimaryL1->GetArgs()[1];
509 totalNumberOfFO[1] = (Int_t) fPrimaryL2->GetArgs()[1];
511 Int_t chipsHitByPrimaries[2];
512 chipsHitByPrimaries[0] = (Int_t) fPrimaryL1->GetArgs()[2];
513 chipsHitByPrimaries[1] = (Int_t) fPrimaryL2->GetArgs()[2];
515 Int_t clustersLayer[2];
516 clustersLayer[0] = (Int_t) fPrimaryL1->GetArgs()[3];
517 clustersLayer[1] = (Int_t) fPrimaryL2->GetArgs()[3];
519 fChipsLayer1->Fill(totalNumberOfFO[0]);
520 fChipsLayer2->Fill(totalNumberOfFO[1]);
522 fL1vsL2->Fill(totalNumberOfFO[0], totalNumberOfFO[1]);
524 fMvsL1->Fill(multiplicity21, totalNumberOfFO[0]);
525 fMvsL2->Fill(multiplicity16, totalNumberOfFO[1]);
527 fClvsL1->Fill(clustersLayer[0], totalNumberOfFO[0]);
528 fClvsL2->Fill(clustersLayer[1], totalNumberOfFO[1]);
532 TH1* AliHighMultiplicitySelector::GetTriggerEfficiency(TH2* multVsLayer, Int_t cut)
535 // returns the trigger efficiency as function of multiplicity with a given cut
538 //cut and multiply with x-section
539 TH1* allEvents = multVsLayer->ProjectionX("fMvsL_x_total", 1, 1001);
540 //allEvents->Sumw2();
542 //cut and multiply with x-section
543 TH1* proj = multVsLayer->ProjectionX(Form("%s_x", multVsLayer->GetName()), cut, 1001);
546 //new TCanvas; allEvents->DrawCopy(); gPad->SetLogy();
547 //new TCanvas; proj->DrawCopy(); gPad->SetLogy();
549 // make probability distribution out of it
550 // TODO binomial errors do not work??? weird...
551 proj->Divide(proj, allEvents, 1, 1, "B");
556 TH1* AliHighMultiplicitySelector::GetXSectionCut(TH1* xSection, TH2* multVsLayer, Int_t cut)
558 // returns the rel. cross section of the true spectrum that is measured when a cut at <cut> is performed
560 TH1* proj = GetTriggerEfficiency(multVsLayer, cut);
562 //new TCanvas; proj->DrawCopy(); gPad->SetLogy();
564 for (Int_t i=1; i<=proj->GetNbinsX(); i++)
566 if (i <= xSection->GetNbinsX())
568 Double_t value = proj->GetBinContent(i) * xSection->GetBinContent(i);
572 error = value * (proj->GetBinError(i) / proj->GetBinContent(i) + xSection->GetBinError(i) / xSection->GetBinContent(i));
574 proj->SetBinContent(i, value);
575 proj->SetBinError(i, error);
579 proj->SetBinContent(i, 0);
580 proj->SetBinError(i, 0);
584 //new TCanvas; proj->DrawCopy(); gPad->SetLogy();
589 void AliHighMultiplicitySelector::MakeGraphs2(const char* title, TH1* xSection, TH2* fMvsL)
593 TGraph* effGraph = new TGraph;
594 effGraph->SetTitle(Form("%s;Cut on fired chips;mult. where eff. >50%%", title));
595 TGraph* ratioGraph = new TGraph;
596 ratioGraph->SetTitle(Form("%s;Cut on fired chips;x-section_(>=eff. limit) / x-section_(total)", title));
597 TGraph* totalGraph = new TGraph;
598 totalGraph->SetTitle(Form("%s;Cut on fired chips;rel x-section_(>=eff. limit)", title));
600 for (Int_t cut = 0; cut <= 300; cut+=50)
602 TH1* proj = (TH1*) GetTriggerEfficiency(fMvsL, cut)->Clone("clone");
605 //proj->Scale(1.0 / 3);
607 new TCanvas; proj->DrawCopy();
609 Int_t limitBin = proj->GetNbinsX()+1;
610 while (limitBin > 1 && proj->GetBinContent(limitBin-1) > 0.5)
613 Float_t limit = proj->GetXaxis()->GetBinCenter(limitBin);
615 effGraph->SetPoint(effGraph->GetN(), cut, limit);
617 proj = GetXSectionCut(xSection, fMvsL, cut);
621 if (proj->Integral(1, 1001) > 0)
623 ratio = proj->Integral(proj->FindBin(limit), 1001) / proj->Integral(1, 1001);
624 total = proj->Integral(proj->FindBin(limit), 1001);
627 ratioGraph->SetPoint(ratioGraph->GetN(), cut, ratio);
628 totalGraph->SetPoint(totalGraph->GetN(), cut, total);
630 Printf("Cut at %d --> trigger eff. is > 0.5 for mult. >= %.2f. That is the case for %f of the triggered, %e of all events", cut, limit, ratio, total);
633 TCanvas* canvas = new TCanvas(Form("%s_Efficiency", title), Form("%s_Efficiency", title), 1200, 800);
634 canvas->Divide(2, 2);
637 effGraph->Draw("A*");
639 for (Int_t i=8; i<=10; ++i)
641 TLine* line = new TLine(0, xSection->GetMean() * i, 300, xSection->GetMean() * i);
645 canvas->cd(2); ratioGraph->Draw("A*");
646 canvas->cd(3); gPad->SetLogy(); totalGraph->Draw("A*");
648 canvas->SaveAs(Form("%s.gif", canvas->GetName()));
651 void AliHighMultiplicitySelector::MakeGraphs(const char* title, TH1* xSection, TH2* fMvsL, Int_t limit)
653 // relative x-section, once we have a collision
655 xSection->Scale(1.0 / xSection->Integral());
657 TGraph* ratioGraph = new TGraph;
658 ratioGraph->SetTitle(Form("%s;Cut on fired chips;x-section_(>=%d) / x-section_(total)", title, limit));
659 TGraph* totalGraph = new TGraph;
660 totalGraph->SetTitle(Form("%s;Cut on fired chips;rel x-section_(>=%d)", title, limit));
664 Double_t bestRatio = -1;
665 Double_t bestTotal = -1;
667 Double_t fullRatio = -1;
668 Double_t fullTotal = -1;
672 for (Int_t cut = 50; cut <= 300; cut+=2)
674 TH1* proj = GetXSectionCut(xSection, fMvsL, cut);
678 if (proj->Integral(1, 1000) > 0)
680 ratio = proj->Integral(limit, 1000) / proj->Integral(1, 1000);
681 total = proj->Integral(limit, 1000);
684 max = TMath::Max(max, total);
686 //printf("Cut at %d: rel. x-section_(>=%d) = %e; x-section_(>=%d) / x-section_(total) = %f\n", cut, limit, total, limit, ratio);
688 if (total < max * 0.9 && bestCut == -1)
695 if (ratio == 1 && fullCut == -1)
702 ratioGraph->SetPoint(ratioGraph->GetN(), cut, ratio);
703 totalGraph->SetPoint(totalGraph->GetN(), cut, total);
707 printf("Best cut at %d: rel. x-section_(>=%d) = %e %%; x-section_(>=%d) / x-section_(total) = %f %%\n", bestCut, limit, bestTotal, limit, bestRatio);
709 printf("100%% cut at %d: rel. x-section_(>=%d) = %e %%; x-section_(>=%d) / x-section_(total) = %f %%\n", fullCut, limit, fullTotal, limit, fullRatio);
711 TCanvas* canvas = new TCanvas(Form("%s_RatioXSection_%d", title, limit), Form("%s_RatioXSection_%d", title, limit), 600, 400);
712 ratioGraph->Draw("A*");
713 canvas->SaveAs(Form("%s.gif", canvas->GetName()));
715 canvas = new TCanvas(Form("%s_TotalXSection_%d", title, limit), Form("%s_TotalXSection_%d", title, limit), 600, 400);
716 totalGraph->Draw("A*");
717 canvas->SaveAs(Form("%s.gif", canvas->GetName()));
720 void AliHighMultiplicitySelector::JPRPlots()
726 gSystem->Load("libPWG0base");
727 .L AliHighMultiplicitySelector.cxx+
728 x = new AliHighMultiplicitySelector();
729 x->ReadHistograms("highmult_hijing100k.root");
735 TFile* file = TFile::Open("crosssectionEx.root");
740 xSections[0] = dynamic_cast<TH1*> (gFile->Get("xSection2Ex"));
741 xSections[1] = dynamic_cast<TH1*> (gFile->Get("xSection15Ex"));
743 for (Int_t i=0; i<2; ++i)
748 TH1* xSection = xSections[i];
749 TH2* fMvsL = (i == 0) ? fMvsL1: fMvsL2;
750 //Int_t cut = (i == 0) ? 164 : 150; // 8 times the mean
751 //Int_t cut = (i == 0) ? 178 : 166; // 9 times the mean
752 Int_t cut = (i == 0) ? 190 : 182; // 10 times the mean
754 // limit is N times the mean
755 Int_t limit = (Int_t) (xSection->GetMean() * 10);
757 // 10^28 lum --> 1.2 kHz
758 // 10^31 lum --> 1200 kHz
759 Float_t rate = 1200e3;
762 Float_t lengthRun = 1e6;
764 xSection->SetStats(kFALSE);
765 xSection->SetTitle(""); //(i == 0) ? "SPD Layer 1" : "SPD Layer 2");
766 xSection->GetXaxis()->SetTitle(Form("true multiplicity in |#eta| < %.1f", (i == 0) ? 2.0 : 1.5));
767 xSection->GetXaxis()->SetRangeUser(0, (i == 0) ? 400 : 350);
768 //xSection->GetYaxis()->SetTitle("relative cross section");
769 xSection->GetYaxis()->SetTitleOffset(1.2);
771 // relative x-section, once we have a collision
772 xSection->Scale(1.0 / xSection->Integral());
774 TH1* proj = GetXSectionCut(xSection, fMvsL, cut);
778 if (proj->Integral(1, 1000) > 0)
780 ratio = proj->Integral(limit, 1000) / proj->Integral(1, 1000);
781 total = proj->Integral(limit, 1000);
784 printf("Cut at %d: rel. x-section_(>=%d) = %e; x-section_(>=%d) / x-section_(total) = %f\n", cut, limit, total, limit, ratio);
786 TCanvas* canvas = new TCanvas(Form("HMPlots_%d", i), Form("HMPlots_%d", i), 800, 600);
788 xSection->DrawCopy();
789 proj->SetLineColor(2);
790 proj->SetStats(kFALSE);
791 proj->DrawCopy("SAME");
793 TLegend* legend = new TLegend(0.15, 0.15, 0.45, 0.3);
794 legend->SetFillColor(0);
795 legend->AddEntry(xSection, "no trigger");
796 legend->AddEntry(proj, Form("FO trigger > %d chips", cut));
799 TLine* line = new TLine(limit, xSection->GetMinimum() * 0.5, limit, xSection->GetMaximum() * 2);
800 line->SetLineWidth(2);
803 canvas->SaveAs(Form("%s.gif", canvas->GetName()));
805 TCanvas* canvas2 = new TCanvas(Form("HMPlots_%d_Random", i), Form("HMPlots_%d_Random", i), 800, 600);
806 //canvas2->SetTopMargin(0.05);
807 //canvas2->SetRightMargin(0.05);
809 xSection->DrawCopy("HIST");
811 TLegend* legend2 = new TLegend(0.15, 0.15, 0.6, 0.3);
812 legend2->SetFillColor(0);
813 legend2->AddEntry(xSection, "no trigger");
815 TH1* proj2 = (TH1*) proj->Clone("random");
817 // MB lengthRun s 100 Hz
818 Int_t nTrigger = (Int_t) (100 * lengthRun * proj->Integral(1, 1000));
819 proj2->FillRandom(proj, nTrigger);
821 TH1* proj3 = (TH1*) proj2->Clone("random_clone");
823 proj3->Fit("pol0", "0", "");
824 proj2->Scale(1.0 / proj3->GetFunction("pol0")->GetParameter(0));
827 proj2->DrawCopy("SAME");
828 legend2->AddEntry(proj2, Form("%d evts, FO > %d chips (%d evts)", nTrigger, cut, (Int_t) (nTrigger * ratio)));
831 proj2 = (TH1*) proj->Clone("random2");
833 // 10^31 lum --> 1200 kHz; lengthRun s
834 nTrigger = (Int_t) (rate * proj->Integral(1, 1000) * lengthRun);
835 proj2->FillRandom(proj, nTrigger);
837 proj3 = (TH1*) proj2->Clone("random_clone2");
839 proj3->Fit("pol0", "0", "");
840 proj2->Scale(1.0 / proj3->GetFunction("pol0")->GetParameter(0));
842 proj2->SetLineColor(4);
843 proj2->SetMarkerStyle(7);
844 proj2->SetMarkerColor(4);
845 proj2->DrawCopy("SAME P");
846 //legend2->AddEntry(proj2, Form("%d evts, FO > %d chips (%d evts)", nTrigger, cut, (Int_t) (nTrigger * ratio)));
847 legend2->AddEntry(proj2, Form("FO trigger > %d chips", cut));
852 canvas2->SaveAs(Form("%s.gif", canvas2->GetName()));
853 canvas2->SaveAs(Form("%s.eps", canvas2->GetName()));
857 void AliHighMultiplicitySelector::Ntrigger(Bool_t relative)
860 // produces a spectrum created with N triggers
861 // number of triggers and thresholds for the moment fixed
866 gSystem->Load("libPWG0base");
867 .L AliHighMultiplicitySelector.cxx+g
868 x = new AliHighMultiplicitySelector();
869 x->ReadHistograms("highmult_hijing100k.root");
872 gSystem->Load("libPWG0base");
873 .L AliHighMultiplicitySelector.cxx+g
874 x = new AliHighMultiplicitySelector();
875 x->ReadHistograms("highmult_hijing100k.root");
881 TFile* file = TFile::Open("crosssectionEx.root");
886 xSections[0] = dynamic_cast<TH1*> (gFile->Get("xSection2Ex"));
887 xSections[1] = dynamic_cast<TH1*> (gFile->Get("xSection15Ex"));
889 // 10^28 lum --> 1.2 kHz
890 // 10^31 lum --> 1200 kHz
891 //Float_t rate = 1200e3;
892 Float_t rate = 250e3;
895 Float_t lengthRun = 1e6;
897 Int_t colors[] = { 2, 3, 4, 6, 7, 8 };
898 Int_t markers[] = { 7, 2, 4, 5, 6, 27 };
900 // put to 2 for second layer
901 for (Int_t i=0; i<1; ++i)
906 TH1* xSection = xSections[i];
907 TH2* fMvsL = (i == 0) ? fMvsL1: fMvsL2;
910 //Int_t cuts[] = { 0, 164, 178, 190, 204, 216 };
912 //Int_t cuts[] = { 0, 164, 190, 216 };
915 //Int_t cuts[] = { 0, 114, 145, 165 };
916 //Float_t ratePerTrigger[] = { 60, 13.3, 13.3, 13.3 };
919 Int_t cuts[] = { 0, 126, 162 };
920 Float_t ratePerTrigger[] = { 60, 20.0, 20.0 };
922 // desired trigger rate in Hz
923 //Float_t ratePerTrigger[] = { 100, 1, 1, 1, 1, 1 };
925 xSection->SetStats(kFALSE);
926 xSection->SetTitle(""); //(i == 0) ? "SPD Layer 1" : "SPD Layer 2");
927 xSection->GetXaxis()->SetTitle(Form("true multiplicity in |#eta| < %.1f", (i == 0) ? 2.0 : 1.5));
928 xSection->GetXaxis()->SetRangeUser(0, (i == 0) ? 450 : 350);
929 //xSection->GetYaxis()->SetTitle("relative cross section");
930 xSection->GetYaxis()->SetTitleOffset(1.2);
932 // relative x-section, once we have a collision
933 xSection->Scale(1.0 / xSection->Integral());
935 TCanvas* canvas2 = new TCanvas(Form("HMPlots2_%d_Random", i), Form("HMPlots2_%d_Random", i), 800, 600);
936 canvas2->SetTopMargin(0.05);
937 canvas2->SetRightMargin(0.05);
941 xSection->DrawCopy("HIST");
943 TLegend* legend2 = new TLegend(0.15, 0.15, 0.6, 0.4);
944 legend2->SetFillColor(0);
945 legend2->AddEntry(xSection, "cross-section");
947 for (Int_t currentCut = 0; currentCut<nCuts; ++currentCut)
949 Int_t cut = cuts[currentCut];
951 TH1* triggerEff = (TH1*) GetTriggerEfficiency(fMvsL, cut)->Clone("triggerEff");
953 TH1* proj = GetXSectionCut(xSection, fMvsL, cut);
955 Float_t triggerLimit = 0;
956 for (Int_t bin = 1; bin <= triggerEff->GetNbinsX(); bin++)
957 if (triggerEff->GetBinContent(bin) < 0.5)
958 triggerLimit = triggerEff->GetXaxis()->GetBinCenter(bin);
960 Printf("Efficiency limit (50%%) is at multiplicity %f", triggerLimit);
963 if (proj->Integral(1, 1000) > 0)
964 total = proj->Integral(1, 1000);
966 printf("Cut at %d: rel. x-section = %e\n", cut, total);
968 TH1* proj2 = (TH1*) proj->Clone("random2");
971 // calculate downscale factor
972 Float_t normalRate = rate * proj->Integral(1, 1000);
973 Float_t downScale = normalRate / ratePerTrigger[currentCut];
976 Long64_t nTrigger = (Long64_t) (normalRate / downScale * lengthRun);
978 Printf("Normal rate is %f, downscale: %f, Simulating %lld triggers", normalRate, downScale, nTrigger);
979 proj2->FillRandom(proj, nTrigger);
982 for (Int_t bin=1; bin<proj2->GetNbinsX(); ++bin)
983 if (proj2->GetBinContent(bin) < 5)
985 removed += (Int_t) proj2->GetBinContent(bin);
986 proj2->SetBinContent(bin, 0);
989 Printf("Removed %d events", removed);
992 proj2->Scale(1.0 / nTrigger * proj->Integral(1, 1000));
994 proj2->SetLineColor(colors[currentCut]);
995 proj2->SetMarkerStyle(markers[currentCut]);
996 proj2->SetMarkerColor(colors[currentCut]);
998 if (relative || currentCut > 0) {
999 proj2->DrawCopy("SAME P");
1001 proj2->DrawCopy(" P");
1003 legend2->AddEntry(proj2, Form("%lld evts, FO > %d chips", nTrigger, cut));
1005 TLine* line = new TLine(triggerLimit, proj2->GetMinimum(), triggerLimit, proj2->GetMaximum());
1006 line->SetLineColor(colors[currentCut]);
1012 canvas2->SaveAs(Form("%s.gif", canvas2->GetName()));
1013 canvas2->SaveAs(Form("%s.eps", canvas2->GetName()));
1017 void AliHighMultiplicitySelector::Contamination()
1020 // produces a spectrum created with N triggers
1021 // number of triggers and thresholds for the moment fixed
1026 gSystem->Load("libANALYSIS");
1027 gSystem->Load("libPWG0base");
1028 .L AliHighMultiplicitySelector.cxx+g
1029 x = new AliHighMultiplicitySelector();
1030 x->ReadHistograms("highmult_hijing100k.root");
1036 TFile* file = TFile::Open("crosssectionEx.root");
1041 xSections[0] = dynamic_cast<TH1*> (gFile->Get("xSection2Ex"));
1042 xSections[1] = dynamic_cast<TH1*> (gFile->Get("xSection15Ex"));
1045 // sigma ~ 80 mb (Pythia 14 TeV)
1046 // 10^28 lum --> 8e2 Hz
1047 // 10^31 lum --> 8e5 Hz
1048 Double_t rates[] = { 8e2, 8e3, 8e4, 8e5 };
1051 Int_t cuts[] = { 104, 134, 154, 170 };
1053 // put to 2 for second layer
1054 for (Int_t i=0; i<1; ++i)
1059 // relative x-section, once we have a collision
1060 xSections[i]->Scale(1.0 / xSections[i]->Integral());
1062 Int_t max = xSections[i]->GetNbinsX();
1065 Float_t* xSection = new Float_t[max];
1066 for (Int_t mult = 0; mult < max; mult++)
1067 xSection[mult] = xSections[i]->GetBinContent(mult+1);
1069 TH2* fMvsL = (i == 0) ? fMvsL1: fMvsL2;
1071 TGraph* graph = new TGraph;
1073 for (Int_t currentCut = 0; currentCut<nCuts; ++currentCut)
1075 Int_t cut = cuts[currentCut];
1076 Double_t rate = rates[currentCut];
1077 //Double_t rate = rates[3];
1079 // coll. in 100 ns window
1080 //Double_t windowSize = 100e-9;
1081 Double_t windowSize = 25e-9;
1082 Double_t collPerWindow = windowSize * rate;
1083 Printf("coll/window = %f", collPerWindow);
1084 Double_t windowsPerSecond = 1.0 / windowSize;
1086 TH1* triggerEffHist = (TH1*) GetTriggerEfficiency(fMvsL, cut)->Clone("triggerEff");
1087 Float_t* triggerEff = new Float_t[max];
1088 for (Int_t mult = 0; mult < max; mult++)
1089 triggerEff[mult] = triggerEffHist->GetBinContent(mult+1);
1091 Double_t triggerRate = 0;
1092 for (Int_t mult = 0; mult < max; mult++)
1093 triggerRate += xSection[mult] * triggerEff[mult];
1095 triggerRate *= TMath::Poisson(1, collPerWindow) * windowsPerSecond;
1097 Printf("Rate for 1 collision is %f Hz", triggerRate);
1099 Double_t triggerRate2 = 0;
1100 for (Int_t mult = 0; mult < max; mult++)
1101 for (Int_t mult2 = mult; mult2 < max; mult2++)
1102 if (mult+mult2 < max)
1103 triggerRate2 += ((mult2 > mult) ? 2. : 1.) * xSection[mult] * xSection[mult2] * triggerEff[mult+mult2];
1105 triggerRate2 *= TMath::Poisson(2, collPerWindow) * windowsPerSecond;
1107 Printf("Rate for 2 collisions is %f Hz --> %.1f%%", triggerRate2, triggerRate2 / triggerRate * 100);
1109 Double_t triggerRate3 = 0;
1111 for (Int_t mult = 0; mult < max; mult++)
1112 for (Int_t mult2 = mult; mult2 < max-mult; mult2++)
1113 for (Int_t mult3 = 0; mult3 < max-mult-mult2; mult3++)
1114 //if (mult+mult2+mult3 < max)
1115 triggerRate3 += ((mult2 > mult) ? 2. : 1.) * xSection[mult] * xSection[mult2] * xSection[mult3] * triggerEff[mult+mult2+mult3];
1117 triggerRate3 *= TMath::Poisson(3, collPerWindow) * windowsPerSecond;
1118 //triggerRate3 *= collPerWindow * collPerWindow * rate;
1120 Printf("Rate for 3 collisions is %f Hz --> %.1f%%", triggerRate3, triggerRate3 / triggerRate * 100);
1122 Float_t totalContamination = (triggerRate2 + triggerRate3) / (triggerRate + triggerRate2 + triggerRate3);
1124 Printf("Total contamination is %.1f%%", totalContamination * 100);
1126 graph->SetPoint(graph->GetN(), cut, totalContamination);
1130 Double_t triggerRate4 = 0;
1131 for (Int_t mult = 0; mult < max; mult++)
1132 for (Int_t mult2 = mult; mult2 < max-mult; mult2++)
1133 for (Int_t mult3 = 0; mult3 < max-mult-mult2; mult3++)
1134 for (Int_t mult4 = 0; mult4 < max-mult-mult2-mult3; mult4++)
1135 //if (mult+mult2+mult3+mult4 < max)
1136 triggerRate4 += ((mult2 > mult) ? 2. : 1.) * xSection[mult] * xSection[mult2] * xSection[mult3] * xSection[mult4] * triggerEff[mult+mult2+mult3+mult4];
1138 //triggerRate4 *= collPerWindow * collPerWindow * collPerWindow * rate;
1139 triggerRate4 *= TMath::Poisson(4, collPerWindow) * windowsPerSecond;
1141 Printf("Rate for 4 collisions is %f Hz --> %.1f%%", triggerRate4, triggerRate4 / triggerRate * 100);
1143 // general code for n collisions follows, however much slower...
1145 const Int_t maxdepth = 4;
1146 for (Int_t depth = 1; depth <= maxdepth; depth++) {
1147 Double_t triggerRate = 0;
1150 for (Int_t d=0; d<maxdepth; d++)
1153 while (m[0] < max) {
1156 for (Int_t d=0; d<depth; d++) {
1157 value *= xSection[m[d]];
1162 value *= triggerEff[sum];
1163 triggerRate += value;
1166 Int_t increase = depth-1;
1168 while (m[increase] == max && increase > 0) {
1175 triggerRate *= rate * TMath::Power(collPerWindow, depth - 1);
1177 Printf("Rate for %d collisions is %f Hz", depth, triggerRate);
1181 new TCanvas; graph->Draw("AP*");
1185 void AliHighMultiplicitySelector::Contamination2()
1188 // produces a spectrum created with N triggers
1189 // number of triggers and thresholds for the moment fixed
1194 gSystem->Load("libANALYSIS");
1195 gSystem->Load("libPWG0base");
1196 .L AliHighMultiplicitySelector.cxx+g
1197 x = new AliHighMultiplicitySelector();
1198 x->ReadHistograms("highmult_hijing100k.root");
1199 x->Contamination2();
1204 TFile* file = TFile::Open("crosssectionEx.root");
1209 xSections[0] = dynamic_cast<TH1*> (gFile->Get("xSection2Ex"));
1210 xSections[1] = dynamic_cast<TH1*> (gFile->Get("xSection15Ex"));
1213 Int_t cuts[] = { 104, 134, 154, 170 };
1217 Int_t colors[] = { 2, 3, 4, 6, 7, 8 };
1218 Int_t markers[] = { 7, 2, 4, 5, 6, 27 };
1220 // put to 2 for second layer
1221 for (Int_t i=0; i<1; ++i)
1226 // relative x-section, once we have a collision
1227 xSections[i]->Scale(1.0 / xSections[i]->Integral());
1229 Int_t max = xSections[i]->GetNbinsX();
1232 Float_t* xSection = new Float_t[max];
1233 for (Int_t mult = 0; mult < max; mult++)
1234 xSection[mult] = xSections[i]->GetBinContent(mult+1);
1236 TH2* fMvsL = (i == 0) ? fMvsL1: fMvsL2;
1238 for (Int_t currentCut = 0; currentCut<nCuts; ++currentCut)
1240 TGraph* graph = new TGraph;
1241 graph->SetMarkerColor(colors[currentCut]);
1242 graph->SetMarkerStyle(markers[currentCut]);
1244 Int_t cut = cuts[currentCut];
1246 TH1* triggerEffHist = (TH1*) GetTriggerEfficiency(fMvsL, cut)->Clone("triggerEff");
1247 Float_t* triggerEff = new Float_t[max];
1248 for (Int_t mult = 0; mult < max; mult++)
1249 triggerEff[mult] = triggerEffHist->GetBinContent(mult+1);
1251 Double_t triggerRate = 0;
1252 for (Int_t mult = 0; mult < max; mult++)
1253 triggerRate += xSection[mult] * triggerEff[mult];
1255 Printf("Raw value for 1 collision is %e", triggerRate);
1257 Double_t triggerRate2 = 0;
1258 for (Int_t mult = 0; mult < max; mult++)
1259 for (Int_t mult2 = mult; mult2 < max; mult2++)
1260 if (mult+mult2 < max)
1261 triggerRate2 += ((mult2 > mult) ? 2. : 1.) * xSection[mult] * xSection[mult2] * triggerEff[mult+mult2];
1263 Printf("Raw value for 2 collisions is %e", triggerRate2);
1265 for (Double_t doubleRate = 0; doubleRate <= 0.2; doubleRate += 0.005)
1267 Float_t totalContamination = (triggerRate2 * doubleRate) / (triggerRate + triggerRate2 * doubleRate);
1269 //Printf("Total contamination is %.1f%%", totalContamination * 100);
1271 graph->SetPoint(graph->GetN(), doubleRate, totalContamination);
1274 graph->Draw((currentCut == 0) ? "A*" : "* SAME");
1275 graph->GetXaxis()->SetRangeUser(0, 1);
1280 void AliHighMultiplicitySelector::DrawHistograms()
1282 // draws the histograms
1286 gSystem->Load("libPWG0base");
1287 .L AliHighMultiplicitySelector.cxx+
1288 x = new AliHighMultiplicitySelector();
1289 x->ReadHistograms("highmult_pythia.root");
1290 x->DrawHistograms();
1293 gSystem->Load("libPWG0base");
1294 .L AliHighMultiplicitySelector.cxx+
1295 x = new AliHighMultiplicitySelector();
1296 x->ReadHistograms("highmult_hijing.root");
1297 x->DrawHistograms();
1299 gSystem->Load("libPWG0base");
1300 .L AliHighMultiplicitySelector.cxx+
1301 x = new AliHighMultiplicitySelector();
1302 x->ReadHistograms("highmult_central.root");
1303 x->DrawHistograms();
1305 gSystem->Load("libPWG0base");
1306 .L AliHighMultiplicitySelector.cxx+
1307 x = new AliHighMultiplicitySelector();
1308 x->ReadHistograms("highmult_hijing100k.root");
1309 x->DrawHistograms();
1313 /*TCanvas* canvas = new TCanvas("chips", "chips", 600, 400);
1315 fChipsLayer2->SetLineColor(2);
1316 fChipsLayer2->SetStats(kFALSE);
1317 fChipsLayer1->SetStats(kFALSE);
1318 fChipsLayer2->SetTitle("");
1319 fChipsLayer2->DrawCopy();
1320 fChipsLayer1->DrawCopy("SAME");
1321 canvas->SaveAs("chips.gif");
1323 canvas = new TCanvas("L1vsL2", "L1vsL2", 600, 400);
1324 fL1vsL2->SetStats(kFALSE);
1325 fL1vsL2->DrawCopy("COLZ");
1327 canvas->SaveAs("L1vsL2.gif");*/
1329 TCanvas *canvas = new TCanvas("L1", "L1", 800, 600);
1330 canvas->SetTopMargin(0.05);
1331 canvas->SetRightMargin(0.12);
1332 fMvsL1->SetStats(kFALSE);
1333 fMvsL1->DrawCopy("COLZ");
1336 canvas->SaveAs("L1NoCurve.gif");
1337 canvas->SaveAs("L1NoCurve.eps");
1339 // draw corresponding theoretical curve
1340 TF1* func = new TF1("func", "[0]*(1-(1-1/[0])**x)", 1, 1000);
1341 func->SetParameter(0, 400-5*2);
1342 func->DrawCopy("SAME");
1344 canvas->SaveAs("L1.gif");
1346 canvas = new TCanvas("L2", "L2", 600, 400);
1347 //fMvsL2->GetYaxis()->SetRangeUser(0, 150);
1348 fMvsL2->SetStats(kFALSE);
1349 fMvsL2->DrawCopy("COLZ");
1351 func->SetParameter(0, 800-5*4);
1352 func->DrawCopy("SAME");
1353 canvas->SaveAs("L2.gif");
1356 TFile* file = TFile::Open("crosssectionEx.root");
1359 TH1* xSection2 = dynamic_cast<TH1*> (gFile->Get("xSection2Ex"));
1360 TH1* xSection15 = dynamic_cast<TH1*> (gFile->Get("xSection15Ex"));
1362 MakeGraphs2("Layer1", xSection2, fMvsL1);
1366 //MakeGraphs("Layer1", xSection2, fMvsL1, (Int_t) (xSection2->GetMean() * 5)); //75 * 2 * 2);
1367 //MakeGraphs("Layer2", xSection15, fMvsL2, (Int_t) (xSection15->GetMean() * 5)); //(Int_t) (75 * 1.5 * 2));
1369 MakeGraphs("Layer1", xSection2, fMvsL1, (Int_t) (xSection2->GetMean() * 8));
1370 MakeGraphs("Layer2", xSection15, fMvsL2, (Int_t) (xSection15->GetMean() * 8));
1371 MakeGraphs("Layer1", xSection2, fMvsL1, (Int_t) (xSection2->GetMean() * 9));
1372 MakeGraphs("Layer2", xSection15, fMvsL2, (Int_t) (xSection15->GetMean() * 9));
1373 MakeGraphs("Layer1", xSection2, fMvsL1, (Int_t) (xSection2->GetMean() * 10));
1374 MakeGraphs("Layer2", xSection15, fMvsL2, (Int_t) (xSection15->GetMean() * 10));
1379 // make spread hists
1380 TGraph* spread = new TGraph;
1381 spread->SetTitle("Spread L1;true multiplicity;RMS");
1383 for (Int_t i=1; i<=fMvsL1->GetNbinsX(); ++i)
1385 TH1* proj = fMvsL1->ProjectionY("proj", i, i);
1386 spread->SetPoint(spread->GetN(), i, proj->GetRMS());
1389 canvas = new TCanvas("SpreadL1", "SpreadL1", 600, 400);
1391 canvas->SaveAs(Form("%s.gif", canvas->GetName()));
1393 TF1* log = new TF1("log", "[0]*log([1]*x)", 1, 150);
1394 log->SetParLimits(0, 0, 10);
1395 log->SetParLimits(1, 1e-5, 10);
1397 spread->Fit(log, "", "", 1, 150);
1398 log->DrawCopy("SAME");
1400 TGraph* spread2 = new TGraph;
1401 spread2->SetTitle("Spread L2;true multiplicity;RMS");
1403 for (Int_t i=1; i<=fMvsL1->GetNbinsX(); ++i)
1405 TH1* proj = fMvsL2->ProjectionY("proj", i, i);
1406 spread2->SetPoint(spread2->GetN(), i, proj->GetRMS());
1409 canvas = new TCanvas("SpreadL2", "SpreadL2", 600, 400);
1410 spread2->Draw("A*");
1411 canvas->SaveAs(Form("%s.gif", canvas->GetName()));
1413 spread2->Fit(log, "", "", 1, 150);
1414 log->DrawCopy("SAME");
1416 canvas = new TCanvas("Clusters_L1", "Clusters_L1", 600, 400);
1417 fClvsL1->SetStats(kFALSE);
1418 fClvsL1->DrawCopy("COLZ");
1421 func->SetParameter(0, 400-5*2);
1422 func->DrawCopy("SAME");
1424 canvas->SaveAs("Clusters_L1.gif");
1426 canvas = new TCanvas("Clusters_L2", "Clusters_L2", 600, 400);
1427 fClvsL2->SetStats(kFALSE);
1428 fClvsL2->DrawCopy("COLZ");
1430 func->SetParameter(0, 800-5*4);
1431 func->DrawCopy("SAME");
1432 canvas->SaveAs("Clusters_L2.gif");
1434 canvas = new TCanvas("ChipsFired", "ChipsFired", 600, 400);
1435 //fChipsFired->GetYaxis()->SetRangeUser(0, 150);
1436 fChipsFired->SetStats(kFALSE);
1437 fChipsFired->DrawCopy("COLZ");
1438 canvas->SaveAs("ChipsFired.gif");
1440 /*TH1F* tresholdHistL1 = new TH1F("tresholdHistL1", ";chip treshold;<n>", BINNING_LAYER1);
1441 TH1F* tresholdHistL2 = new TH1F("tresholdHistL2", ";chip treshold;<n>", BINNING_LAYER2);
1443 for (Int_t treshold = 0; treshold < 800; treshold++)
1445 if (fPrimaryL1->Draw("multiplicity>>mult", Form("firedChips>%d", treshold), "goff") > 0)
1447 TH1F* mult = dynamic_cast<TH1F*> (fPrimaryL1->GetHistogram());
1449 tresholdHistL1->Fill(treshold, mult->GetMean());
1451 if (fPrimaryL2->Draw("multiplicity>>mult", Form("firedChips>%d", treshold), "goff") > 0)
1453 TH1F* mult = dynamic_cast<TH1F*> (fPrimaryL2->GetHistogram());
1455 tresholdHistL2->Fill(treshold, mult->GetMean());
1459 canvas = new TCanvas("TresholdL1", "TresholdL1", 600, 400);
1460 tresholdHistL1->Draw();
1461 canvas->SaveAs(Form("%s.gif", canvas->GetName()));
1463 canvas = new TCanvas("TresholdL2", "TresholdL2", 600, 400);
1464 tresholdHistL2->Draw();
1465 canvas->SaveAs(Form("%s.gif", canvas->GetName()));*/
1467 fPrimaryL1->Draw("(chipsByPrimaries/firedChips):multiplicity>>eff1", "", "prof goff");
1468 fPrimaryL2->Draw("(chipsByPrimaries/firedChips):multiplicity>>eff2", "", "prof goff");
1470 canvas = new TCanvas("Efficiency", "Efficiency", 600, 400);
1471 fPrimaryL1->GetHistogram()->SetStats(kFALSE);
1472 fPrimaryL1->GetHistogram()->Draw();
1473 fPrimaryL2->GetHistogram()->SetLineColor(2);
1474 fPrimaryL2->GetHistogram()->SetStats(kFALSE);
1475 fPrimaryL2->GetHistogram()->Draw("SAME");
1476 canvas->SaveAs(Form("%s.gif", canvas->GetName()));
1478 canvas = new TCanvas("ClustersZL1", "ClustersZL1", 600, 400);
1479 fClusterZL1->Rebin(2);
1480 fClusterZL1->Draw();
1481 canvas->SaveAs(Form("%s.gif", canvas->GetName()));
1483 canvas = new TCanvas("ClustersZL2", "ClustersZL2", 600, 400);
1484 fClusterZL2->Draw();
1485 fClusterZL2->Rebin(2);
1486 canvas->SaveAs(Form("%s.gif", canvas->GetName()));
1489 TGraph* AliHighMultiplicitySelector::IntFractRate()
1491 // A plot which shows the fractional rate above any threshold
1492 // as function of threshold (i.e. the integral of dSigma/dN as function of
1493 // N, normalised to 1 for N=0)
1496 gSystem->Load("libANALYSIS");
1497 gSystem->Load("libPWG0base");
1498 .L AliHighMultiplicitySelector.cxx+
1499 x = new AliHighMultiplicitySelector();
1500 x->ReadHistograms("highmult_hijing100k.root");
1505 TFile* file = TFile::Open("crosssectionEx.root");
1510 xSection = dynamic_cast<TH1*> (gFile->Get("xSection2Ex"));
1512 TGraph* result = new TGraph;
1514 for (Int_t threshold = 0; threshold < 300; threshold += 2)
1516 TH1* proj = GetXSectionCut(xSection, fMvsL1, threshold);
1518 //new TCanvas; proj->DrawCopy();
1520 Double_t integral = proj->Integral();
1522 Printf("Cut at %d, integral is %e", threshold, integral);
1524 result->SetPoint(result->GetN(), threshold, integral);
1527 TCanvas* canvas = new TCanvas("IntFractRate", "IntFractRate", 600, 400);
1531 result->GetXaxis()->SetTitle("threshold");
1532 result->GetYaxis()->SetTitle("integrated fractional rate above threshold");
1534 canvas->SaveAs(Form("%s.gif", canvas->GetName()));
1539 void AliHighMultiplicitySelector::MBComparison()
1542 // finds the threshold from which onwards the number of found events above N times the mean
1543 // is higher using a high mult. trigger than just triggering with MB
1548 gSystem->Load("libANALYSIS");
1549 gSystem->Load("libPWG0base");
1550 .L AliHighMultiplicitySelector.cxx+g
1551 x = new AliHighMultiplicitySelector();
1552 x->ReadHistograms("highmult_hijing100k.root");
1558 TFile* file = TFile::Open("crosssectionEx.root");
1563 xSections[0] = dynamic_cast<TH1*> (gFile->Get("xSection2Ex"));
1564 xSections[1] = dynamic_cast<TH1*> (gFile->Get("xSection15Ex"));
1567 // sigma ~ 80 mb (Pythia 14 TeV)
1568 // 10^28 lum --> 8e2 Hz
1569 // 10^31 lum --> 8e5 Hz
1571 Double_t rates[] = { 8e2, 8e3, 8e4, 8e5 };
1573 // threshold in number of fired chips for corresponding rate
1574 //Int_t cuts[] = { 104, 134, 154, 170 }; // values for 20 Hz
1575 Int_t cuts[] = { 82, 124, 147, 164 }; // values for 50 Hz
1577 // bandwidth, fractions (for MB, high mult.)
1578 Float_t bandwidth = 1e3;
1579 Float_t fractionMB = 0.5;
1580 Float_t fractionHM = 0.05;
1582 // different limits to define "interesting events"
1584 Int_t limits[] = { 0, 1, 2, 4, 6, 7, 8, 9, 10 };
1586 // put to 2 for second layer
1587 for (Int_t i=0; i<1; ++i)
1592 TH1* xSection = xSections[i];
1593 TH2* fMvsL = (i == 0) ? fMvsL1: fMvsL2;
1595 // relative x-section, once we have a collision
1596 xSection->Scale(1.0 / xSection->Integral());
1598 xSection->SetStats(kFALSE);
1599 xSection->SetTitle(""); //(i == 0) ? "SPD Layer 1" : "SPD Layer 2");
1600 xSection->GetXaxis()->SetTitle(Form("true multiplicity in |#eta| < %.1f", (i == 0) ? 2.0 : 1.5));
1601 xSection->GetXaxis()->SetRangeUser(0, (i == 0) ? 450 : 350);
1602 xSection->GetYaxis()->SetTitleOffset(1.2);
1604 TCanvas* canvas = new TCanvas("MBComparison", "MBComparison", 1000, 800);
1605 canvas->Divide(3, 3);
1607 for (Int_t currentLimit = 0; currentLimit<nLimits; currentLimit++)
1609 // limit is N times the mean
1610 Int_t limit = (Int_t) (xSection->GetMean() * limits[currentLimit]);
1614 TGraph* graphMB = new TGraph;
1615 graphMB->SetTitle(Form("Events with %d times above <n> (i.e. n >= %d)", limits[currentLimit], limit));
1616 graphMB->SetMarkerStyle(20);
1618 TGraph* graphBoth = new TGraph;
1619 graphBoth->SetMarkerStyle(21);
1621 Float_t min = bandwidth;
1624 for (Int_t current = 0; current<nRates; ++current)
1626 Float_t rate = rates[current];
1627 Int_t cut = cuts[current];
1629 TH1* triggerEff = (TH1*) GetTriggerEfficiency(fMvsL, cut)->Clone("triggerEff");
1630 TH1* proj = GetXSectionCut(xSection, fMvsL, cut);
1632 Float_t downScaleMB1 = rate / bandwidth;
1633 if (downScaleMB1 < 1)
1636 Float_t downScaleMB2 = rate / (bandwidth * fractionMB);
1637 if (downScaleMB2 < 1)
1640 Float_t downScaleHM = rate * proj->Integral(1, xSection->GetNbinsX()) / (bandwidth * fractionHM);
1641 if (downScaleHM < 1)
1644 Float_t rateMB1 = rate / downScaleMB1 * xSection->Integral(limit, xSection->GetNbinsX());
1645 Float_t rateMB2 = rate / downScaleMB2 * xSection->Integral(limit, xSection->GetNbinsX());
1646 Float_t rateHM = rate / downScaleHM * proj->Integral(limit, xSection->GetNbinsX());
1647 Float_t combinedRate = rateMB2 + rateHM;
1649 graphMB->SetPoint(graphMB->GetN(), rate, rateMB1);
1650 graphBoth->SetPoint(graphBoth->GetN(), rate, combinedRate);
1652 min = TMath::Min(min, TMath::Min(rateMB1, combinedRate));
1653 max = TMath::Max(min, TMath::Max(rateMB1, combinedRate));
1655 Printf("The rates for events with %d times above <n> (i.e. n >= %d) at a rate of %.2e Hz is:", limits[currentLimit], limit, rate);
1656 Printf(" %.2e Hz in MB-only mode", rateMB1);
1657 Printf(" %.2e Hz = %.2e Hz + %.2e Hz in MB + high mult. mode", combinedRate, rateMB2, rateHM);
1659 Printf(" The downscale factors are: %.2f %.2f %.2f", downScaleMB1, downScaleMB2, downScaleHM);
1661 Int_t triggerLimit = 0;
1662 for (Int_t bin = 1; bin <= triggerEff->GetNbinsX(); bin++)
1663 if (triggerEff->GetBinContent(bin) < 0.5)
1664 triggerLimit = (Int_t) triggerEff->GetXaxis()->GetBinCenter(bin);
1666 Printf(" Efficiency limit (50%%) is at multiplicity %d", triggerLimit);
1667 Float_t fractionGood = proj->Integral(triggerLimit, proj->GetNbinsX()) / proj->Integral();
1668 Printf(" %.2f %% of the events are above the trigger limit", fractionGood * 100);
1670 if (triggerLimit > limit)
1671 Printf(" WARNING: interesting events also counted inside the trigger limit");
1676 canvas->cd(currentLimit+1)->SetLogx();
1677 canvas->cd(currentLimit+1)->SetLogy();
1679 graphMB->Draw("AP");
1680 graphBoth->Draw("P SAME");
1682 graphMB->GetYaxis()->SetRangeUser(0.5 * min, 2 * max);
1683 graphMB->GetXaxis()->SetTitle("Raw rate in Hz");
1684 graphMB->GetYaxis()->SetTitle("Event rate in Hz");