]>
Commit | Line | Data |
---|---|---|
e10611f0 | 1 | // |
2 | // This macro performs the matching operation between ESD tracks | |
3 | // and EMCAL clusters (stored as AliESDCaloCluster objects). | |
4 | // Due to the necessity to know the magnetic field, it is supposed that | |
5 | // this macro runs in the directory where event files are stored | |
6 | // (galice.root --> recovery magnetic field), and saves its output in | |
7 | // a directory specified in the argument (default = work directory) | |
8 | // | |
9 | ||
10 | void FindMatches(const char *fileOut = "matchESD.root") | |
11 | { | |
12 | // | |
13 | // Initialize AliRun manager. | |
14 | // | |
15 | if (gAlice) { | |
16 | delete gAlice; | |
17 | gAlice = 0; | |
18 | } | |
19 | ||
20 | // | |
21 | // Initialize AliRunLoader, in order | |
22 | // to read magnetic field from simulation. | |
23 | // | |
24 | AliRunLoader *rl = AliRunLoader::Open("galice.root"); | |
25 | if (!rl) return; | |
26 | rl->LoadgAlice(); | |
27 | gAlice = rl->GetAliRun(); | |
e10611f0 | 28 | |
4642ac4b | 29 | //AliMagF *magf = new AliMagF("Maps","Maps", 1., 1., AliMagF::k5kG); |
30 | AliMagF *magf = new AliMagF("Maps","Maps", 1., 1.); | |
3a2a23e1 | 31 | |
e10611f0 | 32 | // |
33 | // Open ESD file and recoveries TTree of ESD objects. | |
34 | // | |
35 | TFile *esdFile = new TFile("AliESDs.root"); | |
36 | TTree *esdTree = (TTree*)esdFile->Get("esdTree"); | |
3a2a23e1 | 37 | AliESDEvent* esd = new AliESDEvent(); |
38 | esd->ReadFromTree(esdTree); | |
39 | if (!esd) {cerr<<"no AliESDEvent"; return 1;}; | |
40 | ||
e10611f0 | 41 | Long64_t nEvents = esdTree->GetEntries(); |
42 | ||
43 | // | |
44 | // Set this important flag to the tracker. | |
45 | // This example works with and AliESD file already saved | |
46 | // after the tracking procedure done during AliReconstruction::Run(). | |
47 | // All tracks saved in such a file, are already propagated to the vertex, | |
48 | // while EMCAL matching needs to be done using track status in the outermost | |
49 | // available position. | |
50 | // Then, we must use the "outer" parameters in the ESD track, and we must | |
51 | // tell to the track to copy the outer parameters from its AliESDtrack seed. | |
52 | // | |
53 | AliEMCALTrack::SetUseOuterParams(kTRUE); | |
54 | ||
55 | // | |
56 | // Instantiate match finder, and set some cuts. | |
57 | // Distances are in centimeters, angles in degrees. | |
58 | // | |
59 | AliEMCALTracker *mf = new AliEMCALTracker; | |
a0270705 | 60 | mf->SetCutX(50.0); |
61 | mf->SetCutY(50.0); | |
62 | mf->SetCutZ(50.0); | |
e10611f0 | 63 | mf->SetCutAlpha(-50., 50.); // --> i.e. exclude this cut |
a0270705 | 64 | mf->SetCutAngle(10000.); |
65 | mf->SetMaxDistance(50.0); | |
e10611f0 | 66 | |
67 | // | |
68 | // Define how to manage energy loss correction. | |
69 | // Actually, these corrections are exlcluded. | |
70 | // | |
71 | // mf->SetCorrection(0.0604557, 34.5437); // at the moment, we exclude energy loss correction | |
72 | mf->SetTrackCorrectionMode("NONE"); | |
73 | mf->SetNumberOfSteps(0); | |
74 | //TGeoManager::Import("misaligned_geometry.root"); | |
75 | ||
76 | // | |
77 | // Before starting looping on files, the output file is created. | |
78 | // It will be structurally identical to the ESD source tree, with the | |
79 | // only difference that here the "fEMCALindex" datamember of the ESD tracks | |
80 | // will have been set to a meaningful value. | |
81 | // | |
82 | TFile *outFile = TFile::Open(fileOut, "RECREATE"); | |
83 | TTree *outTree = new TTree("esdTree", "ESD with matched clusters"); | |
3a2a23e1 | 84 | //outTree->Branch("ESD", "AliESD", &esd); |
85 | esd->WriteToTree(outTree); | |
e10611f0 | 86 | |
87 | // | |
88 | // Loop on events. | |
89 | // The whole track matching procedure is compiled in the | |
90 | // method "PropagateBack" which accepts and input ESD collection. | |
91 | // This method modifies the passed object then, the same object is linked | |
92 | // to source tree and target tree branch. | |
93 | // | |
94 | Int_t nTracks, nStep1, nStep2, nSaved; | |
95 | for (Long64_t iev = 0; iev < nEvents; iev++) { | |
a0270705 | 96 | //cout << "Finding matches in event " << iev + 1 << "/" << nEvents << endl; |
e10611f0 | 97 | esdTree->GetEntry(iev); |
a0270705 | 98 | mf->Clear("ALL"); |
e10611f0 | 99 | mf->PropagateBack(esd); |
100 | outTree->Fill(); | |
101 | } | |
102 | ||
103 | // | |
104 | // Save processed tree and close output file. | |
105 | // | |
106 | outFile->cd(); | |
107 | outTree->Write("esdTree", TObject::kOverwrite); | |
108 | outFile->Close(); | |
109 | } |