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;
60 CreateTrack(mutrack, minMuonPt, maxMuonPt, (i%2==0) ? -1 : 1);
61 event.AddMuonTrack(&mutrack);
67 bool CheckIfOutputIsOk()
69 const char* filename = "FullTriggerTestOutput.root";
70 TFile file(filename, "READ");
71 int expectedResult[4] = {0, 1, 0, 1};
72 AliHLTTriggerDecision* decision[4];
73 for (int i = 0; i < 4; i++)
76 sprintf(name, "HLTGlobalTrigger;%d", i+1);
77 decision[i] = dynamic_cast<AliHLTTriggerDecision*>(file.Get(name));
78 if (decision[i] == NULL)
80 cerr << "ERROR: '" << name << "' AliHLTTriggerDecision object not found in file " << filename << endl;
83 cout << "===============================================================================" << endl;
84 cout << "============================== Global Decision " << i+1 << " ==============================" << endl;
85 cout << "===============================================================================" << endl;
87 if (decision[i]->Result() != expectedResult[i])
89 cout << "FAILED result check. Expected a result of " << expectedResult[i]
90 << " for trigger decision " << i+1
91 << " but received: " << decision[i]->Result()
99 bool testGeomTrigger()
101 gRandom->SetSeed(123);
102 gSystem->Load("libAliHLTTrigger.so");
103 CreateInput("FullTriggerTestInput1.root", 5, 0.1, 1.9, 0, 0.1, 0.9);
104 CreateInput("FullTriggerTestInput2.root", 3, 2.1, 4.0, 0, 0.1, 0.9);
105 CreateInput("FullTriggerTestInput3.root", 6, 0.1, 1.9, 0, 1.1, 2.0);
106 CreateInput("FullTriggerTestInput4.root", 2, 2.1, 4.0, 0, 1.1, 2.0);
108 sys.LoadComponentLibraries("libAliHLTUtil.so");
109 sys.LoadComponentLibraries("libAliHLTTrigger.so");
110 const char* cmdline = " -datatype ROOTTOBJ 'HLT ' -datafile FullTriggerTestInput1.root"
111 " -nextevent -datafile FullTriggerTestInput2.root"
112 " -nextevent -datafile FullTriggerTestInput3.root"
113 " -nextevent -datafile FullTriggerTestInput4.root";
114 AliHLTConfiguration pub("pub", "ROOTFilePublisher", NULL, cmdline);
115 AliHLTConfiguration trg1("trg1", "BarrelGeomMultiplicityTrigger", "pub", "-triggername PHOSgeomtrigger -geomfile PHOSgeomtrigger.root");
116 AliHLTConfiguration glob("global", "HLTGlobalTrigger", "trg1", "-config testGeomTriggerConfig.C");
117 AliHLTConfiguration sink("sink", "ROOTFileWriter", "global", "-datafile FullTriggerTestOutput.root -concatenate-events");
118 sys.BuildTaskList("sink");
120 return CheckIfOutputIsOk();