1 #if !defined(__CINT__) || defined(__MAKECINT__)
8 #include "AliESDEvent.h"
9 #include "AliESDMuonTrack.h"
10 #include "AliHLTSystem.h"
11 #include "AliHLTConfiguration.h"
12 #include "AliHLTTriggerDecision.h"
16 void CreateTrack(AliESDMuonTrack& track, Double_t minPt, Double_t maxPt, Double_t charge)
19 Double_t pt = gRandom->Rndm() * (maxPt - minPt) + minPt;
20 Double_t angle = gRandom->Rndm() * 2 * TMath::Pi();
21 Double_t px = pt * TMath::Cos(angle);
22 Double_t py = pt * TMath::Sin(angle);
23 track.SetThetaX(TMath::ATan2(px, pz));
24 track.SetThetaY(TMath::ATan2(py, pz));
25 Double_t invP = 1. / TMath::Sqrt(py*py + pz*pz) * charge;
26 track.SetInverseBendingMomentum(invP);
29 TParticle CreateParticle(Double_t minPt, Double_t maxPt)
31 Double_t mass = 0.1056583699; // [GeV/c] muon mass.
33 Double_t pt = gRandom->Rndm() * (maxPt - minPt) + minPt;
34 Double_t angle = gRandom->Rndm() * 2 * TMath::Pi();
35 // Double_t angle = 270*TMath::DegToRad();
36 Double_t px = pt * TMath::Cos(angle);
37 Double_t py = pt * TMath::Sin(angle);
38 Double_t etot = TMath::Sqrt(pt*pt + pz*pz + mass*mass);
39 return TParticle(13, 0, 0, 0, 0, 0, px, py, pz, etot, 0, 0, 0, 0);
44 Int_t numOfBarrelTracks, Double_t minBarrelPt, Double_t maxBarrelPt,
45 Int_t numOfMuonTracks, Double_t minMuonPt, Double_t maxMuonPt
48 TFile* file = new TFile(filename, "RECREATE");
50 event.CreateStdContent();
51 for (int i = 0; i < numOfBarrelTracks; i++)
53 TParticle p = CreateParticle(minBarrelPt, maxBarrelPt);
54 AliESDtrack track(&p);
55 event.AddTrack(&track);
57 for (int i = 0; i < numOfMuonTracks; i++)
59 AliESDMuonTrack *mutrack = event.NewMuonTrack();
60 CreateTrack(*mutrack, minMuonPt, maxMuonPt, (i%2==0) ? -1 : 1);
66 bool CheckIfOutputIsOk()
68 const char* filename = "FullTriggerTestOutput.root";
69 TFile file(filename, "READ");
70 int expectedResult[4] = {0, 1, 0, 1};
71 AliHLTTriggerDecision* decision[4];
72 for (int i = 0; i < 4; i++)
75 sprintf(name, "HLTGlobalTrigger;%d", i+1);
76 decision[i] = dynamic_cast<AliHLTTriggerDecision*>(file.Get(name));
77 if (decision[i] == NULL)
79 cerr << "ERROR: '" << name << "' AliHLTTriggerDecision object not found in file " << filename << endl;
82 cout << "===============================================================================" << endl;
83 cout << "============================== Global Decision " << i+1 << " ==============================" << endl;
84 cout << "===============================================================================" << endl;
86 if (decision[i]->Result() != expectedResult[i])
88 cout << "FAILED result check. Expected a result of " << expectedResult[i]
89 << " for trigger decision " << i+1
90 << " but received: " << decision[i]->Result()
98 bool testGeomTrigger()
100 gRandom->SetSeed(123);
101 gSystem->Load("libAliHLTTrigger");
102 CreateInput("FullTriggerTestInput1.root", 5, 0.1, 1.9, 0, 0.1, 0.9);
103 CreateInput("FullTriggerTestInput2.root", 3, 2.1, 4.0, 0, 0.1, 0.9);
104 CreateInput("FullTriggerTestInput3.root", 6, 0.1, 1.9, 0, 1.1, 2.0);
105 CreateInput("FullTriggerTestInput4.root", 2, 2.1, 4.0, 0, 1.1, 2.0);
107 sys.LoadComponentLibraries("libAliHLTUtil.so");
108 sys.LoadComponentLibraries("libAliHLTTrigger.so");
109 const char* cmdline = " -datatype ROOTTOBJ 'HLT ' -datafile FullTriggerTestInput1.root"
110 " -nextevent -datafile FullTriggerTestInput2.root"
111 " -nextevent -datafile FullTriggerTestInput3.root"
112 " -nextevent -datafile FullTriggerTestInput4.root";
113 AliHLTConfiguration pub("pub", "ROOTFilePublisher", NULL, cmdline);
114 AliHLTConfiguration trg1("trg1", "BarrelGeomMultiplicityTrigger", "pub", "-triggername PHOSgeomtrigger -geomfile PHOSgeomtrigger.root");
115 AliHLTConfiguration glob("global", "HLTGlobalTrigger", "trg1", "-config testGeomTriggerConfig.C");
116 AliHLTConfiguration sink("sink", "ROOTFileWriter", "global", "-datafile FullTriggerTestOutput.root -concatenate-events");
117 sys.BuildTaskList("sink");
119 return CheckIfOutputIsOk();