]>
Commit | Line | Data |
---|---|---|
1183ee65 | 1 | #if !defined(__CINT__) || defined(__MAKECINT__) |
2 | #include "Riostream.h" | |
3 | #include "TFile.h" | |
4 | #include "TSystem.h" | |
5 | #include "TRandom3.h" | |
6 | #include "TMath.h" | |
7 | #include "TParticle.h" | |
8 | #include "AliESDEvent.h" | |
9 | #include "AliESDMuonTrack.h" | |
10 | #include "AliHLTSystem.h" | |
11 | #include "AliHLTConfiguration.h" | |
12 | #include "AliHLTTriggerDecision.h" | |
13 | ||
14 | #endif | |
15 | ||
16 | void CreateTrack(AliESDMuonTrack& track, Double_t minPt, Double_t maxPt, Double_t charge) | |
17 | { | |
18 | Double_t pz = -100; | |
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); | |
27 | } | |
28 | ||
29 | TParticle CreateParticle(Double_t minPt, Double_t maxPt) | |
30 | { | |
31 | Double_t mass = 0.1056583699; // [GeV/c] muon mass. | |
32 | Double_t pz = 0; | |
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); | |
40 | } | |
41 | ||
42 | void CreateInput( | |
43 | const char* filename, | |
44 | Int_t numOfBarrelTracks, Double_t minBarrelPt, Double_t maxBarrelPt, | |
45 | Int_t numOfMuonTracks, Double_t minMuonPt, Double_t maxMuonPt | |
46 | ) | |
47 | { | |
48 | TFile* file = new TFile(filename, "RECREATE"); | |
49 | AliESDEvent event; | |
50 | event.CreateStdContent(); | |
51 | for (int i = 0; i < numOfBarrelTracks; i++) | |
52 | { | |
53 | TParticle p = CreateParticle(minBarrelPt, maxBarrelPt); | |
54 | AliESDtrack track(&p); | |
55 | event.AddTrack(&track); | |
56 | } | |
57 | for (int i = 0; i < numOfMuonTracks; i++) | |
58 | { | |
fe0324de | 59 | AliESDMuonTrack *mutrack = event.NewMuonTrack(); |
60 | CreateTrack(*mutrack, minMuonPt, maxMuonPt, (i%2==0) ? -1 : 1); | |
1183ee65 | 61 | } |
62 | event.Write(); | |
63 | delete file; | |
64 | } | |
65 | ||
66 | bool CheckIfOutputIsOk() | |
67 | { | |
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++) | |
73 | { | |
74 | char name[1024]; | |
75 | sprintf(name, "HLTGlobalTrigger;%d", i+1); | |
76 | decision[i] = dynamic_cast<AliHLTTriggerDecision*>(file.Get(name)); | |
77 | if (decision[i] == NULL) | |
78 | { | |
79 | cerr << "ERROR: '" << name << "' AliHLTTriggerDecision object not found in file " << filename << endl; | |
80 | return false; | |
81 | } | |
82 | cout << "===============================================================================" << endl; | |
83 | cout << "============================== Global Decision " << i+1 << " ==============================" << endl; | |
84 | cout << "===============================================================================" << endl; | |
85 | decision[i]->Print(); | |
86 | if (decision[i]->Result() != expectedResult[i]) | |
87 | { | |
88 | cout << "FAILED result check. Expected a result of " << expectedResult[i] | |
89 | << " for trigger decision " << i+1 | |
90 | << " but received: " << decision[i]->Result() | |
91 | << endl; | |
92 | return false; | |
93 | } | |
94 | } | |
95 | return true; | |
96 | } | |
97 | ||
98 | bool testGeomTrigger() | |
99 | { | |
100 | gRandom->SetSeed(123); | |
4070f709 | 101 | gSystem->Load("libAliHLTTrigger"); |
1183ee65 | 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); | |
106 | AliHLTSystem sys; | |
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"); | |
118 | sys.Run(4); | |
119 | return CheckIfOutputIsOk(); | |
120 | } |