]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONTrackReconstructor.cxx
Only getters to parameters declared constant.
[u/mrichter/AliRoot.git] / MUON / AliMUONTrackReconstructor.cxx
CommitLineData
a9e2aefa 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15/*
16$Log$
94de3818 17Revision 1.2 2000/06/15 07:58:49 morsch
18Code from MUON-dev joined
19
a9e2aefa 20Revision 1.1.2.7 2000/06/09 22:06:29 morsch
21Some coding rule violations corrected. Will soon be obsolete.
22
23Revision 1.1.2.6 2000/05/02 07:15:29 morsch
24Put back TH1.h and TH2.h includes.
25
26Revision 1.1.2.5 2000/02/17 18:12:43 morsch
27Corrections in trackf_read_spoint causing segmentation violations in previous version (I. Chevrot)
28New histos (I. Chevrot)
29
30Revision 1.1.2.4 2000/02/15 18:01:08 morsch
31Log messages
32
33Revision 1.1.2.3 2000/02/15 17:59:01 morsch
34Log message added
35
36Revision 1.1.2.2 2000/02/15 18:54:56 morsch
37Reference between track contributing to reconstructed hit and particle corrected
38*/
39
40#include "AliCallf77.h"
41#include "AliMUONTrackReconstructor.h"
42#include "AliRun.h"
43#include "AliMUON.h"
44#include "AliMC.h"
45
46#include "AliMUONHit.h"
47#include "AliMUONPadHit.h"
48#include "AliMUONDigit.h"
49#include "AliMUONRawCluster.h"
50#include "AliMUONReconstHit.h"
51
52#include "AliPDG.h"
53
54#include <TRandom.h>
55#include <TFile.h>
56#include <TH1.h>
57#include <TH2.h>
58#include <TTree.h>
59#include <TParticle.h>
60#include <TMinuit.h>
61#include <iostream.h>
62
63#ifndef WIN32
64# define reco_init reco_init_
65# define cutpxz cutpxz_
66# define sigmacut sigmacut_
67# define xpreci xpreci_
68# define ypreci ypreci_
69# define reconstmuon reconstmuon_
70# define reconstmuon2 reconstmuon2_
71# define trackf_read_geant trackf_read_geant_
72# define trackf_read_fit trackf_read_fit_
73# define trackf_read_spoint trackf_read_spoint_
74# define chfill chfill_
75# define chfill2 chfill2_
76# define chf1 chf1_
77# define chfnt chfnt_
78# define hist_create hist_create_
79# define hist_closed hist_closed_
80# define rndm rndm_
81# define fcn fcn_
82# define trackf_fit trackf_fit_
83# define prec_fit prec_fit_
84# define fcnfit fcnfit_
85# define reco_term reco_term_
86#else
87# define reco_init RECO_INIT
88# define cutpxz CUTPXZ
89# define sigmacut SIGMACUT
90# define xpreci XPRECI
91# define ypreci YPRECI
92# define reconstmuon RECONSTMUON
93# define reconstmuon2 RECONSTMUON2
94# define trackf_read_geant TRACKF_READ_GEANT
95# define trackf_read_fit TRACKF_READ_FIT
96# define trackf_read_spoint TRACKF_READ_SPOINT
97# define chfill CHFILL
98# define chfill2 CHFILL2
99# define chf1 CHF1
100# define chfnt CHFNT
101# define hist_create HIST_CREATE
102# define hist_closed HIST_CLOSED
103# define rndm RNDM
104# define fcn FCN
105# define trackf_fit TRACKF_FIT
106# define prec_fit PREC_FIT
107# define fcnfit FCNFIT
108# define reco_term RECO_TERM
109#endif
110
111extern "C"
112{
113void type_of_call reco_init(Double_t &, Double_t &, Double_t &);
114void type_of_call reco_term();
115void type_of_call cutpxz(Double_t &);
116void type_of_call sigmacut(Double_t &);
117void type_of_call xpreci(Double_t &);
118void type_of_call ypreci(Double_t &);
119void type_of_call reconstmuon(Int_t &, Int_t &, Int_t &, Int_t &, Int_t &);
120void type_of_call reconstmuon2(Int_t &, Int_t &, Int_t &);
121void type_of_call trackf_read_fit(Int_t &, Int_t &, Int_t &, Int_t *, Double_t *, Double_t *);
122void type_of_call trackf_read_geant(Int_t *, Double_t *, Double_t *, Double_t *, Int_t *, Int_t *, Double_t *, Double_t *, Double_t *, Double_t *,Int_t &, Double_t *, Double_t *, Double_t *, Int_t &, Int_t &, Double_t *, Double_t *, Double_t *, Double_t *);
123void type_of_call trackf_read_spoint(Int_t *, Double_t *, Double_t *, Double_t *, Int_t *, Int_t *, Double_t *, Double_t *, Double_t *, Double_t *,Int_t &, Double_t *, Double_t *, Double_t *, Int_t &, Int_t &, Double_t *, Double_t *, Double_t *, Double_t *);
124void type_of_call chfill(Int_t &, Float_t &, Float_t &, Float_t &);
125void type_of_call chfill2(Int_t &, Float_t &, Float_t &, Float_t &);
126void type_of_call chf1(Int_t &, Float_t &, Float_t &);
127void type_of_call chfnt(Int_t &, Int_t &, Int_t *, Int_t *, Float_t *, Float_t *, Float_t *, Float_t *, Float_t *, Float_t *, Float_t *, Float_t *);
128void type_of_call hist_create();
129void type_of_call hist_closed();
130void type_of_call fcnf(Int_t &, Double_t *, Double_t &, Double_t *, Int_t);
131void type_of_call fcn(Int_t &, Double_t *, Double_t &, Double_t *, Int_t &, Int_t &);
132void type_of_call trackf_fit(Int_t &, Double_t *, Double_t *, Double_t &, Double_t &, Double_t &, Double_t &, Double_t &);
133void type_of_call prec_fit(Double_t &, Double_t &, Double_t &, Double_t &, Double_t&, Double_t &, Double_t &, Double_t &, Double_t &, Double_t &, Double_t &, Double_t &, Double_t &, Double_t &, Double_t &);
134void type_of_call fcnfitf(Int_t &, Double_t *, Double_t &, Double_t *, Int_t);
135void type_of_call fcnfit(Int_t &, Double_t *, Double_t &, Double_t *, Int_t &, Int_t &);
136Float_t type_of_call rndm() {return gRandom->Rndm();}
137void type_of_call fit_trace(Float_t &, Float_t &, Float_t &, Float_t &, Float_t &, Float_t &, Int_t &, Int_t &, Int_t &, Int_t &);
138}
139
140static TTree *pNtupleGlobal;
141static TFile *pHfileGlobal;
142static TTree *treeK1;
143static TTree *TrH1;
144static TClonesArray *fHits2; //List of hits for one track only
145static TClonesArray *fParticles2; //List of particles in the Kine tree
146
147
148// variables of the tracking ntuple
149struct {
150 Int_t ievr; // number of event
151 Int_t ntrackr; // number of tracks per event
152 Int_t istatr[500]; // 1 = good muon, 2 = ghost, 0 = something else
153 Int_t isignr[500]; // sign of the track
154 Float_t pxr[500]; // x momentum of the reconstructed track
155 Float_t pyr[500]; // y momentum of the reconstructed track
156 Float_t pzr[500]; // z momentum of the reconstructed track
157 Float_t zvr[500]; // z vertex
158 Float_t chi2r[500]; // chi2 of the fit of the track with the field map
159 Float_t pxv[500]; // x momentum at vertex
160 Float_t pyv[500]; // y momentum at vertex
161 Float_t pzv[500]; // z momentum at vertex
162} NtupleSt;
163
164ClassImp(AliMUONTrackReconstructor)
165
166//___________________________________________________
167AliMUONTrackReconstructor::AliMUONTrackReconstructor()
168{
169 fSPxzCut = 3.0;
170 fSSigmaCut = 4.0;
171 fSXPrec = 0.01;
172 fSYPrec = 0.144;
173}
174
175//_____________________________________________________________________________
176void AliMUONTrackReconstructor::Reconst2(Int_t &ifit, Int_t &idebug, Int_t &nev)
177{
178 reconstmuon2(ifit,idebug,nev);
179}
180
181//_____________________________________________________________________________
182void AliMUONTrackReconstructor::Reconst(Int_t &ifit, Int_t &idebug, Int_t bgd_ev, Int_t &nev, Int_t &idres, Int_t &ireadgeant, Option_t *option,Text_t *filename)
183{
184 //
185 // open kine and hits tree of background file for reconstruction of geant hits
186 // call tracking fortran program
187 static Bool_t first=kTRUE;
188 static TFile *pFile;
189 char *addBackground = strstr(option,"Add");
190
191 if (addBackground ) { // only in case of background with geant hits
192 if(first) {
193 fFileName=filename;
194 cout<<"filename "<<fFileName<<endl;
195 pFile=new TFile(fFileName);
196 cout<<"I have opened "<<fFileName<<" file "<<endl;
197 fHits2 = new TClonesArray("AliMUONHit",1000);
198 fParticles2 = new TClonesArray("TParticle",1000);
199 first=kFALSE;
200 }
201 pFile->cd();
202 if(fHits2) fHits2->Clear();
203 if(fParticles2) fParticles2->Clear();
204 if(TrH1) delete TrH1;
205 TrH1=0;
206 if(treeK1) delete treeK1;
207 treeK1=0;
208 // Get Hits Tree header from file
209 char treeName[20];
210 sprintf(treeName,"TreeH%d",bgd_ev);
211 TrH1 = (TTree*)gDirectory->Get(treeName);
212 // printf("TrH1 %p of treename %s for event %d \n",TrH1,treeName,bgd_ev);
213 if (!TrH1) {
214 printf("ERROR: cannot find Hits Tree for event:%d\n",bgd_ev);
215 }
216 // set branch addresses
217 TBranch *branch;
218 char branchname[30];
219 AliMUON *pMUON = (AliMUON*) gAlice->GetModule("MUON");
220 sprintf(branchname,"%s",pMUON->GetName());
221 if (TrH1 && fHits2) {
222 branch = TrH1->GetBranch(branchname);
223 if (branch) branch->SetAddress(&fHits2);
224 }
225 TrH1->GetEntries();
226 // get the Kine tree
227 sprintf(treeName,"TreeK%d",bgd_ev);
228 treeK1 = (TTree*)gDirectory->Get(treeName);
229 if (!treeK1) {
230 printf("ERROR: cannot find Kine Tree for event:%d\n",bgd_ev);
231 }
232 // set branch addresses
233 if (treeK1)
234 treeK1->SetBranchAddress("Particles", &fParticles2);
235 treeK1->GetEvent(0);
236
237 // get back to the first file
238 TTree *treeK = gAlice->TreeK();
239 TFile *file1 = 0;
240 if (treeK) file1 = treeK->GetCurrentFile();
241 file1->cd();
242
243 } // end if addBackground
244
245 // call tracking fortran program
246 reconstmuon(ifit,idebug,nev,idres,ireadgeant);
247}
248
249//________________________________________________________________________________
250void AliMUONTrackReconstructor::Init(Double_t &seff, Double_t &sb0, Double_t &sbl3)
251{
252 //
253 // introduce in fortran program somme parameters and cuts for tracking
254 // create output file "reconst.root" (histos + ntuple)
255 cutpxz(fSPxzCut); // Pxz cut (GeV/c) to begin the track finding
256 sigmacut(fSSigmaCut); // Number of sigmas delimiting the searching areas
257 xpreci(fSXPrec); // Chamber precision in X (cm)
258 ypreci(fSYPrec); // Chamber precision in Y (cm)
259 reco_init(seff,sb0,sbl3);
260}
261
262//__________________________________________
263void AliMUONTrackReconstructor::FinishEvent()
264{
265 TTree *treeK = gAlice->TreeK();
266 TFile *file1 = 0;
267 if (treeK) file1 = treeK->GetCurrentFile();
268 file1->cd();
269}
270
271//_____________________________________
272void AliMUONTrackReconstructor::Close()
273{
274 //
275 // write histos and ntuple to "reconst.root" file
276 reco_term();
277}
278
279//________________________________________________________
280void chfill(Int_t &id, Float_t &x, Float_t &y, Float_t &w)
281{
282 //
283 // fill histo like hfill in fortran
284 char name[5];
285 sprintf(name,"h%d",id);
286 TH1F *h1 = (TH1F*) gDirectory->Get(name);
287 h1->Fill(x);
288}
289
290//_________________________________________________________
291void chfill2(Int_t &id, Float_t &x, Float_t &y, Float_t &w)
292{
293 //
294 // fill histo like hfill2 in fortran
295 char name[5];
296 sprintf(name,"h%d",id);
297 TH2F *h2 = (TH2F*) gDirectory->Get(name);
298 h2->Fill(x,y,w);
299}
300
301//__________________________________________
302void chf1(Int_t &id, Float_t &x, Float_t &w)
303{
304 //
305 // fill histo like hf1 in fortran
306 char name[5];
307 sprintf(name,"h%d",id);
308 TH1F *h1 = (TH1F*) gDirectory->Get(name);
309 h1->Fill(x,w);
310}
311
312//_________________
313void hist_create()
314{
315 //
316 // Create an output file ("reconst.root")
317 // Create some histograms and an ntuple
318
319 pHfileGlobal = new TFile("reconst.root","RECREATE","Ntuple - reconstruction");
320
321 pNtupleGlobal = new TTree("ntuple","Reconst ntuple");
322 pNtupleGlobal->Branch("ievr",&NtupleSt.ievr,"ievr/I");
323 pNtupleGlobal->Branch("ntrackr",&NtupleSt.ntrackr,"ntrackr/I");
324 pNtupleGlobal->Branch("istatr",&NtupleSt.istatr[0],"istatr[500]/I");
325 pNtupleGlobal->Branch("isignr",&NtupleSt.isignr[0],"isignr[500]/I");
326 pNtupleGlobal->Branch("pxr",&NtupleSt.pxr[0],"pxr[500]/F");
327 pNtupleGlobal->Branch("pyr",&NtupleSt.pyr[0],"pyr[500]/F");
328 pNtupleGlobal->Branch("pzr",&NtupleSt.pzr[0],"pzr[500]/F");
329 pNtupleGlobal->Branch("zvr",&NtupleSt.zvr[0],"zvr[500]/F");
330 pNtupleGlobal->Branch("chi2r",&NtupleSt.chi2r[0],"chi2r[500]/F");
331 pNtupleGlobal->Branch("pxv",&NtupleSt.pxv[0],"pxv[500]/F");
332 pNtupleGlobal->Branch("pyv",&NtupleSt.pyv[0],"pyv[500]/F");
333 pNtupleGlobal->Branch("pzv",&NtupleSt.pzv[0],"pzv[500]/F");
334
335 // test aliroot
336
337 new TH1F("h100","particule id du hit geant",20,0.,20.);
338 new TH1F("h101","position en x du hit geant",100,-200.,200.);
339 new TH1F("h102","position en y du hit geant",100,-200.,200.);
340 new TH1F("h103","chambre de tracking concernee",15,0.,14.);
341 new TH1F("h104","moment ptot du hit geant",50,0.,100.);
342 new TH1F("h105","px au vertex",50,0.,20.);
343 new TH1F("h106","py au vertex",50,0.,20.);
344 new TH1F("h107","pz au vertex",50,0.,20.);
345 new TH1F("h108","position zv",50,-15.,15.);
346 new TH1F("h109","position en x du hit reconstruit",100,-300.,300.);
347 new TH1F("h110","position en y du hit reconstruit",100,-300.,300.);
348 new TH1F("h111","delta x station 1",100,-0.3,0.3);
349 new TH1F("h112","delta x station 2",100,-0.3,0.3);
350 new TH1F("h113","delta x station 3",100,-0.3,0.3);
351 new TH1F("h114","delta x station 4",100,-0.5,0.5);
352 new TH1F("h115","delta x station 5",100,-0.5,0.5);
353 new TH1F("h116","delta x station 1",100,-2,2);
354 new TH1F("h117","delta x station 2",100,-2,2);
355 new TH1F("h121","delta y station 1",100,-0.04,0.04);
356 new TH1F("h122","delta y station 2",100,-0.04,0.04);
357 new TH1F("h123","delta y station 3",100,-0.04,0.04);
358 new TH1F("h124","delta y station 4",100,-0.04,0.04);
359 new TH1F("h125","delta y station 5",100,-0.04,0.04);
360
361 /* char hname[30];
362 char hname1[30];
363 for (int i=0;i<10;i++) {
364 sprintf(hname,"deltax%d",i);
365 sprintf(hname1,"h12%d",i);
366 new TH1F(hname1,hname ,100,-0.4,0.4);
367 sprintf(hname,"deltay%d",i);
368 sprintf(hname1,"h13%d",i);
369 new TH1F(hname1,hname ,100,-0.4,0.4);
370 }
371 */
372 new TH2F("h2000","VAR X st. 5",30,3.0,183.0,100,0.,25.);
373 new TH2F("h2001","VAR Y st. 5",30,3.0,183.0,100,0.,25.);
374
375 new TH2F("h2500","P vs X HHIT",30,3.0,183.0,200,0.,200.);
376 new TH2F("h2501","P vs X HHIT**2",30,3.0,183.0,200,0.,5000.);
377 new TH2F("h2502","P vs X EPH2 st. 5",30,3.0,183.0,100,0.,0.000005);
378 new TH2F("h2503","P vs X EAL2 st. 5",30,3.0,183.0,100,0.,0.01);
379 //new TH2F("h2504","P vs X EXM2 st. 5",30,3.0,183.0,100,0.,1.5);
380 new TH2F("h2504","P vs X EXM2 st. 5",30,3.0,183.0,100,0.,0.1);
381 new TH2F("h2505","P vs X EYM2 st. 5",30,3.0,183.0,100,0.,30.);
382
383 new TH2F("h2507","P vs X EPH st. 5",30,3.0,183.0,100,0.,0.003);
384 new TH2F("h2508","P vs X EAL st. 5",30,3.0,183.0,100,0.,0.3);
385 //new TH2F("h2509","P vs X EXM st. 5",30,3.0,183.0,100,0.,1.5);
386 new TH2F("h2509","P vs X EXM st. 5",30,3.0,183.0,100,0.,0.4);
387 new TH2F("h2510","P vs X EYM st. 5",30,3.0,183.0,100,0.,30.);
388
389 new TH2F("h2511","P vs X EPH cut st. 5",30,3.0,183.0,100,0.,0.01);
390 new TH2F("h2512","P vs X EAL cut st. 5",30,3.0,183.0,100,0.,0.3);
391 //new TH2F("h2513","P vs X EXM cut st. 5",30,3.0,183.0,100,0.,1.5);
392 new TH2F("h2513","P vs X EXM cut st. 5",30,3.0,183.0,100,0.,0.4);
393 new TH2F("h2514","P vs X EYM cut st. 5",30,3.0,183.0,100,0.,30.);
394 // 4
395 new TH2F("h2400","P vs X HHIT",30,3.0,183.0,200,0.,200.);
396 new TH2F("h2401","P vs X HHIT**2",30,3.0,183.0,200,0.,5000.);
397 new TH2F("h2402","P vs X EPH2 st. 4",30,3.0,183.0,100,0.,0.000005);
398 new TH2F("h2403","P vs X EAL2 st. 4",30,3.0,183.0,100,0.,0.05);
399 //new TH2F("h2404","P vs X EXM2 st. 4",30,3.0,183.0,100,0.,1.5);
400 new TH2F("h2404","P vs X EXM2 st. 4",30,3.0,183.0,100,0.,0.1);
401 new TH2F("h2405","P vs X EYM2 st. 4",30,3.0,183.0,100,0.,30.);
402
403 new TH2F("h2407","P vs X EPH st. 4",30,3.0,183.0,100,0.,0.003);
404 new TH2F("h2408","P vs X EAL st. 4",30,3.0,183.0,100,0.,0.3);
405 //new TH2F("h2409","P vs X EXM st. 4",30,3.0,183.0,100,0.,1.5);
406 new TH2F("h2409","P vs X EXM st. 4",30,3.0,183.0,100,0.,0.1);
407 new TH2F("h2410","P vs X EYM st. 4",30,3.0,183.0,100,0.,30.);
408
409 new TH2F("h2411","P vs X EPH cut st. 4",30,3.0,183.0,100,0.,0.01);
410 new TH2F("h2412","P vs X EAL cut st. 4",30,3.0,183.0,100,0.,0.3);
411 //new TH2F("h2413","P vs X EXM cut st. 4",30,3.0,183.0,100,0.,1.5);
412 new TH2F("h2413","P vs X EXM cut st. 4",30,3.0,183.0,100,0.,0.1);
413 new TH2F("h2414","P vs X EYM cut st. 4",30,3.0,183.0,100,0.,30.);
414 // 3
415 new TH1F("h2301","P2",30,3.0,183.0);
416 new TH2F("h2302","P2 vs X EPH2 st. 3",30,3.0,183.0,100,0.,0.0006);
417 new TH2F("h2303","P2 vs X EAL2 st. 3",30,3.0,183.0,100,0.,0.0005);
418 //new TH2F("h2304","P2 vs X EXM2 st. 3",30,3.0,183.0,100,0.,1.5);
419 new TH2F("h2304","P2 vs X EXM2 st. 3",30,3.0,183.0,100,0.,2.);
420 new TH2F("h2305","P2 vs X EYM2 st. 3",30,3.0,183.0,100,0.,3.);
421
422 new TH2F("h2307","P vs X EPH2 st. 3",30,3.0,183.0,100,0.,0.0006);
423 new TH2F("h2308","P vs X EAL2 st. 3",30,3.0,183.0,100,0.,0.005);
424 //new TH2F("h2309","P vs X EXM2 st. 3",30,3.0,183.0,100,0.,1.5);
425 new TH2F("h2309","P vs X EXM2 st. 3",30,3.0,183.0,100,0.,2.);
426 new TH2F("h2310","P vs X EYM2 st. 3",30,3.0,183.0,100,0.,3.);
427
428 new TH2F("h2311","P vs X EPH cut st. 3",30,3.0,183.0,100,0.,0.06);
429 new TH2F("h2312","P vs X EAL cut st. 3",30,3.0,183.0,100,0.,0.05);
430 //new TH2F("h2313","P vs X EXM cut st. 3",30,3.0,183.0,100,0.,1.5);
431 new TH2F("h2313","P vs X EXM cut st. 3",30,3.0,183.0,100,0.,6.);
432 new TH2F("h2314","P vs X EYM cut st. 3",30,3.0,183.0,100,0.,7.);
433
434 new TH2F("h2315","P2 vs X EPH cut st. 3",30,3.0,183.0,100,0.,0.06);
435 new TH2F("h2316","P2 vs X EAL cut st. 3",30,3.0,183.0,100,0.,0.05);
436 //new TH2F("h2317","P2 vs X EXM cut st. 3",30,3.0,183.0,100,0.,1.5);
437 new TH2F("h2317","P2 vs X EXM cut st. 3",30,3.0,183.0,100,0.,6.);
438 new TH2F("h2318","P2 vs X EYM cut st. 3",30,3.0,183.0,100,0.,7.);
439
440 // 2
441 new TH1F("h2201","P2",30,3.0,183.0);
442 new TH2F("h2202","P2 vs X EPH2 st. 2",30,3.0,183.0,100,0.,0.0006);
443 new TH2F("h2203","P2 vs X EAL2 st. 2",30,3.0,183.0,100,0.,0.005);
444 //new TH2F("h2204","P2 vs X EXM2 st. 2",30,3.0,183.0,100,0.,1.5);
445 new TH2F("h2204","P2 vs X EXM2 st. 2",30,3.0,183.0,100,0.,7.);
446 new TH2F("h2205","P2 vs X EYM2 st. 2",30,3.0,183.0,100,0.,5.);
447
448 new TH2F("h2207","P vs X EPH2 st. 2",30,3.0,183.0,100,0.,0.0006);
449 new TH2F("h2208","P vs X EAL2 st. 2",30,3.0,183.0,100,0.,0.005);
450 //new TH2F("h2209","P vs X EXM2 st. 2",30,3.0,183.0,100,0.,1.5);
451 new TH2F("h2209","P vs X EXM2 st. 2",30,3.0,183.0,100,0.,7.);
452 new TH2F("h2210","P vs X EYM2 st. 2",30,3.0,183.0,100,0.,5.);
453
454 new TH2F("h2211","P vs X EPH cut st. 2",30,3.0,183.0,100,0.,0.05);
455 new TH2F("h2212","P vs X EAL cut st. 2",30,3.0,183.0,100,0.,0.2);
456 //new TH2F("h2213","P vs X EXM cut st. 2",30,3.0,183.0,100,0.,1.5);
457 new TH2F("h2213","P vs X EXM cut st. 2",30,3.0,183.0,100,0.,11.);
458 new TH2F("h2214","P vs X EYM cut st. 2",30,3.0,183.0,100,0.,10.);
459
460 new TH2F("h2215","P2 vs X EPH cut st. 2",30,3.0,183.0,100,0.,0.05);
461 new TH2F("h2216","P2 vs X EAL cut st. 2",30,3.0,183.0,100,0.,0.2);
462 //new TH2F("h2217","P2 vs X EXM cut st. 2",30,3.0,183.0,100,0.,1.5);
463 new TH2F("h2217","P2 vs X EXM cut st. 2",30,3.0,183.0,100,0.,11.);
464 new TH2F("h2218","P2 vs X EYM cut st. 2",30,3.0,183.0,100,0.,10.);
465
466 // 1
467 new TH2F("h2102","P2 vs X EPH2 st. 2",30,3.0,183.0,100,0.,0.0006);
468 new TH2F("h2103","P2 vs X EAL2 st. 2",30,3.0,183.0,100,0.,0.005);
469 //new TH2F("h2104","P2 vs X EXM2 st. 2",30,3.0,183.0,100,0.,1.5);
470 new TH2F("h2104","P2 vs X EXM2 st. 2",30,3.0,183.0,100,0.,7.);
471 new TH2F("h2105","P2 vs X EYM2 st. 2",30,3.0,183.0,100,0.,7.);
472
473 new TH2F("h2107","P vs X EPH2 st. 2",30,3.0,183.0,100,0.,0.0006);
474 new TH2F("h2108","P vs X EAL2 st. 2",30,3.0,183.0,100,0.,0.005);
475 //new TH2F("h2109","P vs X EXM2 st. 2",30,3.0,183.0,100,0.,1.5);
476 new TH2F("h2109","P vs X EXM2 st. 2",30,3.0,183.0,100,0.,7.);
477 new TH2F("h2110","P vs X EYM2 st. 2",30,3.0,183.0,100,0.,7.);
478
479 new TH2F("h2111","P vs X EPH cut st. 2",30,3.0,183.0,100,0.,0.1);
480 new TH2F("h2112","P vs X EAL cut st. 2",30,3.0,183.0,100,0.,0.2);
481 //new TH2F("h2113","P vs X EXM cut st. 2",30,3.0,183.0,100,0.,1.5);
482 new TH2F("h2113","P vs X EXM cut st. 2",30,3.0,183.0,100,0.,11.);
483 new TH2F("h2114","P vs X EYM cut st. 2",30,3.0,183.0,100,0.,11.);
484
485 new TH2F("h2115","P2 vs X EPH cut st. 2",30,3.0,183.0,100,0.,0.1);
486 new TH2F("h2116","P2 vs X EAL cut st. 2",30,3.0,183.0,100,0.,0.2);
487 //new TH2F("h2117","P2 vs X EXM cut st. 2",30,3.0,183.0,100,0.,1.5);
488 new TH2F("h2117","P2 vs X EXM cut st. 2",30,3.0,183.0,100,0.,11.);
489 new TH2F("h2118","P2 vs X EYM cut st. 2",30,3.0,183.0,100,0.,11.);
490
491 // 2,3,4,5
492 new TH1F("h2701","P2 fit 2",30,3.0,183.0);
493 new TH2F("h2702","P2 vs X EPH2 st. 1 fit 2",30,3.0,183.0,100,0.,0.0006);
494 new TH2F("h2703","P2 vs X EAL2 st. 1 fit 2",30,3.0,183.0,100,0.,0.005);
495 // new TH2F("h2704","P2 vs X EXM2 st. 1 fit 2",30,3.0,183.0,100,0.,1.5);
496 new TH2F("h2704","P2 vs X EXM2 st. 1 fit 2",30,3.0,183.0,100,0.,2.);
497 new TH2F("h2705","P2 vs X EYM2 st. 1 fit 2",30,3.0,183.0,100,0.,3.);
498
499 new TH2F("h2707","P vs X EPH2 st. 1 fit 2",30,3.0,183.0,100,0.,0.0006);
500 new TH2F("h2708","P vs X EAL2 st. 1 fit 2",30,3.0,183.0,100,0.,0.005);
501 //new TH2F("h2709","P vs X EXM2 st. 1 fit 2",30,3.0,183.0,100,0.,1.5);
502 new TH2F("h2709","P vs X EXM2 st. 1 fit 2",30,3.0,183.0,100,0.,2.);
503 new TH2F("h2710","P vs X EYM2 st. 1 fit 2",30,3.0,183.0,100,0.,3.);
504
505 new TH2F("h2711","P vs X EPH cut st. 1 fit 2",30,3.0,183.0,100,0.,0.07);
506 new TH2F("h2712","P vs X EAL cut st. 1 fit 2",30,3.0,183.0,100,0.,0.2);
507 //new TH2F("h2713","P vs X EXM cut st. 1 fit 2",30,3.0,183.0,100,0.,1.5);
508 new TH2F("h2713","P vs X EXM cut st. 1 fit 2",30,3.0,183.0,100,0.,6.);
509 new TH2F("h2714","P vs X EYM cut st. 1 fit 2",30,3.0,183.0,100,0.,7.);
510
511 new TH2F("h2715","P2 vs X EPH cut st. 1 fit 2",30,3.0,183.0,100,0.,0.07);
512 new TH2F("h2716","P2 vs X EAL cut st. 1 fit 2",30,3.0,183.0,100,0.,0.2);
513 //new TH2F("h2717","P2 vs X EXM cut st. 1 fit 2",30,3.0,183.0,100,0.,1.5);
514 new TH2F("h2717","P2 vs X EXM cut st. 1 fit 2",30,3.0,183.0,100,0.,6.);
515 new TH2F("h2718","P2 vs X EYM cut st. 1 fit 2",30,3.0,183.0,100,0.,7.);
516
517 // 1,3,4,5
518 new TH1F("h2801","P2 fit 1",30,3.0,183.0);
519 new TH2F("h2802","P2 vs X EPH2 st. 2 fit 1",30,3.0,183.0,100,0.,0.0006);
520 new TH2F("h2803","P2 vs X EAL2 st. 2 fit 1",30,3.0,183.0,100,0.,0.005);
521 //new TH2F("h2804","P2 vs X EXM2 st. 2 fit 1",30,3.0,183.0,100,0.,1.5);
522 new TH2F("h2804","P2 vs X EXM2 st. 2 fit 1",30,3.0,183.0,100,0.,2.);
523 new TH2F("h2805","P2 vs X EYM2 st. 2 fit 1",30,3.0,183.0,100,0.,3.);
524
525 new TH2F("h2807","P vs X EPH2 st. 2 fit 1",30,3.0,183.0,100,0.,0.0006);
526 new TH2F("h2808","P vs X EAL2 st. 2 fit 1",30,3.0,183.0,100,0.,0.005);
527 //new TH2F("h2809","P vs X EXM2 st. 2 fit 1",30,3.0,183.0,100,0.,1.5);
528 new TH2F("h2809","P vs X EXM2 st. 2 fit 1",30,3.0,183.0,100,0.,2.);
529 new TH2F("h2810","P vs X EYM2 st. 2 fit 1",30,3.0,183.0,100,0.,3.);
530
531 new TH2F("h2811","P vs X EPH cut st. 2 fit 1",30,3.0,183.0,100,0.,0.05);
532 new TH2F("h2812","P vs X EAL cut st. 2 fit 1",30,3.0,183.0,100,0.,0.2);
533 //new TH2F("h2813","P vs X EXM cut st. 2 fit 1",30,3.0,183.0,100,0.,1.5);
534 new TH2F("h2813","P vs X EXM cut st. 2 fit 1",30,3.0,183.0,100,0.,5.);
535 new TH2F("h2814","P vs X EYM cut st. 2 fit 1",30,3.0,183.0,100,0.,7.);
536
537 new TH2F("h2815","P2 vs X EPH cut st. 2 fit 1",30,3.0,183.0,100,0.,0.05);
538 new TH2F("h2816","P2 vs X EAL cut st. 2 fit 1",30,3.0,183.0,100,0.,0.2);
539 //new TH2F("h2817","P2 vs X EXM cut st. 2 fit 1",30,3.0,183.0,100,0.,1.5);
540 new TH2F("h2817","P2 vs X EXM cut st. 2 fit 1",30,3.0,183.0,100,0.,5.);
541 new TH2F("h2818","P2 vs X EYM cut st. 2 fit 1",30,3.0,183.0,100,0.,7.);
542
543
544 new TH2F("h1111","dx vs x station 1",30,-250.,250.,30,-0.5,0.5);
545 new TH2F("h1112","dx vs x station 2",30,-250.,250.,30,-0.5,0.5);
546 new TH2F("h1113","dx vs x station 3",30,-250.,250.,30,-0.5,0.5);
547 new TH2F("h1114","dx vs x station 4",30,-250.,250.,30,-0.5,0.5);
548 new TH2F("h1115","dx vs x station 5",30,-250.,250.,30,-0.5,0.5);
549 new TH2F("h1121","dy vs y station 1",30,-250.,250.,30,-0.04,0.04);
550 new TH2F("h1122","dy vs y station 2",30,-250.,250.,30,-0.04,0.04);
551 new TH2F("h1123","dy vs y station 3",30,-250.,250.,30,-0.04,0.04);
552 new TH2F("h1124","dy vs y station 4",30,-250.,250.,30,-0.04,0.04);
553 new TH2F("h1125","dy vs y station 5",30,-250.,250.,30,-0.04,0.04);
554
555 // fin de test
556
557 new TH1F("h500","Acceptance en H st. 4",500,0.,500.);
558 new TH1F("h600","Acceptance en H st. 5",500,0.,500.);
559 new TH1F("h700","X vertex track found",200,-10.,10.);
560 new TH1F("h701","Y vertex track found",200,-10.,10.);
561 new TH1F("h800","Rap. muon gen.",100,0.,5.);
562 new TH1F("h801","Rap. muon gen. recons.",100,0.,5.);
563 new TH1F("h802","Rap. muon gen. ghost ",100,0.,5.);
564 new TH1F("h900","Pt muon gen.",100,0.,20.);
565 new TH1F("h901","Pt muon gen. recons.",100,0.,20.);
566 new TH1F("h902","Pt muon gen. ghost",100,0.,20.);
567 new TH1F("h910","phi muon gen.",100,-10.,10.);
568 new TH1F("h911","phi muon gen. recons.",100,-10.,10.);
569 new TH1F("h912","phi muon gen. ghost",100,-10.,10.);
570 new TH2F("h1001","Y VS X hit st. 1",300,-300.,300.,300,-300.,300.);
571 new TH2F("h1002","Y VS X hit st. 2",300,-300.,300.,300,-300.,300.);
572 new TH2F("h1003","Y VS X hit st. 3",300,-300.,300.,300,-300.,300.);
573 new TH2F("h1004","Y VS X hit st. 4",300,-300.,300.,300,-300.,300.);
574 new TH2F("h1005","Y VS X hit st. 5",300,-300.,300.,300,-300.,300.);
575 // Histos variance dans 4
576 new TH2F("h11","VAR X st. 4",30,3.0,183.0,100,0.,2.);
577 new TH2F("h12","VAR Y st. 4",30,3.0,183.0,100,0.,600.);
578 new TH2F("h13","VAR PHI st. 4",30,3.0,183.0,100,0.,0.0001);
579 new TH2F("h14","VAR ALM st. 4",30,3.0,183.0,100,0.,0.05);
580 new TH1F("h15","P",30,3.0,183.0);
581 new TH1F("h411","VAR X st. 4",100,-1.42,1.42);
582 new TH1F("h412","VAR Y st. 4",100,-25.,25.);
583 new TH1F("h413","VAR PHI st. 4",100,-0.01,0.01);
584 new TH1F("h414","VAR ALM st. 4",100,-0.23,0.23);
585 // histo2
586 new TH2F("h211","histo2-VAR X st. 4",30,3.0,183.0,100,0.,2.);
587 new TH2F("h212","histo2-VAR Y st. 4",30,3.0,183.0,100,0.,600.);
588 new TH1F("h213","histo2-VAR X st. 4",100,-1.42,1.42);
589 new TH1F("h214","histo2-VAR Y st. 4",100,-25.,25.);
590 new TH1F("h215","histo2-P",30,3.0,183.0);
591
592 // Histos variance dans 2
593 new TH2F("h21","VAR X st. 2",30,3.0,183.0,100,0.,3.);
594 new TH2F("h22","VAR Y st. 2",30,3.0,183.0,100,0.,7.);
595 new TH2F("h23","VAR PHI st. 2",30,3.0,183.0,100,0.,0.006);
596 new TH2F("h24","VAR ALM st. 2",30,3.0,183.0,100,0.,0.005);
597 new TH1F("h25","P",30,3.0,183.0);
598 new TH1F("h421","VAR X st. 2",100,-1.72,1.72);
599 new TH1F("h422","VAR Y st. 2",100,-2.7,2.7);
600 new TH1F("h423","VAR PHI st. 2",100,-0.08,0.08);
601 new TH1F("h424","VAR ALM st. 2",100,-0.072,0.072);
602 // histo2
603 new TH2F("h221","histo2-VAR X st. 2",30,3.0,183.0,100,0.,3.);
604 new TH2F("h222","histo2-VAR Y st. 2",30,3.0,183.0,100,0.,7.);
605 new TH1F("h223","histo2-VAR X st. 2",100,-1.72,1.72);
606 new TH1F("h224","histo2-VAR Y st. 2",100,-2.7,2.7);
607 new TH1F("h225","histo2-P",30,3.0,183.0);
608
609 // Histos variance dans 1
610 new TH2F("h31","VAR X st. 1",30,3.0,183.0,100,0.,2.);
611 new TH2F("h32","VAR Y st. 1",30,3.0,183.0,100,0.,0.5);
612 new TH2F("h33","VAR PHI st. 1",30,3.0,183.0,100,0.,0.006);
613 new TH2F("h34","VAR ALM st. 1",30,3.0,183.0,100,0.,0.005);
614 new TH1F("h35","P",30,3.0,183.0);
615 new TH1F("h431","VAR X st. 1",100,-1.42,1.42);
616 new TH1F("h432","VAR Y st. 1",100,-0.72,0.72);
617 new TH1F("h433","VAR PHI st. 1",100,-0.08,0.08);
618 new TH1F("h434","VAR ALM st. 1",100,-0.072,0.072);
619 // Histos variance dans 1
620 new TH2F("h41","VAR X st. 1 fit 5,4,3,2,V",30,3.0,183.0,100,0.,4.);
621 new TH2F("h42","VAR Y st. 1 fit 5,4,3,2,V",30,3.0,183.0,100,0.,20.);
622 new TH2F("h43","VAR PHI st. 1 fit 5,4,3,2,V",30,3.0,183.0,100,0.,0.005);
623 new TH2F("h44","VAR ALM st. 1 fit 5,4,3,2,V",30,3.0,183.0,100,0.,0.005);
624 new TH1F("h45","P",30,3.0,183.0);
625 new TH1F("h441","VAR X st. 1 fit 5,4,3,2,V",100,-2.,2.);
626 new TH1F("h442","VAR Y st. 1 fit 5,4,3,2,V",100,-4.5,4.5);
627 new TH1F("h443","VAR PHI st. 1 fit 5,4,3,2,V",100,-0.072,0.072);
628 new TH1F("h444","VAR ALM st. 1 fit 5,4,3,2,V",100,-0.072,0.072);
629 // histo2
630 new TH2F("h241","histo2-VAR X st. 1 fit 5,4,3,2,V",30,3.0,183.0,100,0.,4.);
631 new TH2F("h242","histo2-VAR Y st. 1 fit 5,4,3,2,V",30,3.0,183.0,100,0.,20.);
632 new TH1F("h243","histo2-VAR X st. 1 fit 5,4,3,2,V",100,-2.,2.);
633 new TH1F("h244","histo2-VAR Y st. 1 fit 5,4,3,2,V",100,-4.5,4.5);
634 new TH1F("h245","histo2-P",30,3.0,183.0);
635
636 // Histos variance dans 2
637 new TH2F("h51","VAR X st. 2 fit 5,4,3,1,V",30,3.0,183.0,100,0.,0.5);
638 new TH2F("h52","VAR Y st. 2 fit 5,4,3,1,V",30,3.0,183.0,100,0.,2.);
639 new TH2F("h53","VAR PHI st. 2 fit 5,4,3,1,V",30,3.0,183.0,100,0.,0.005);
640 new TH2F("h54","VAR ALM st. 2 fit 5,4,3,1,V",30,3.0,183.0,100,0.,0.01);
641 new TH1F("h55","P",30,3.0,183.0);
642 new TH1F("h451","VAR X st. 2 fit 5,4,3,1,V",100,-0.72,0.72);
643 new TH1F("h452","VAR Y st. 2 fit 5,4,3,1,V",100,-1.42,1.42);
644 new TH1F("h453","VAR PHI st. 2 fit 5,4,3,1,V",100,-0.072,0.072);
645 new TH1F("h454","VAR ALM st. 2 fit 5,4,3,1,V",100,-0.1,0.1);
646 new TH1F("h999","PTOT",30,3.0,183.0);
647 // histo2
648 new TH2F("h251","histo2-VAR X st. 2 fit 5,4,3,1,V",30,3.0,183.0,100,0.,0.5);
649 new TH2F("h252","histo2-VAR Y st. 2 fit 5,4,3,1,V",30,3.0,183.0,100,0.,2.);
650 new TH1F("h253","histo2-VAR X st. 2 fit 5,4,3,1,V",100,-0.72,0.72);
651 new TH1F("h254","histo2-VAR Y st. 2 fit 5,4,3,1,V",100,-1.42,1.42);
652 new TH1F("h255","histo2-P",30,3.0,183.0);
653 // Histos variance dans 3
654 new TH2F("h61","VAR X st. 3 fit 4,5,V",30,3.0,183.0,100,0.,5.);
655 new TH2F("h62","VAR Y st. 3 fit 4,5,V",30,3.0,183.0,100,0.,2.);
656 new TH2F("h63","VAR PHI st. 3 fit 4,5,V",30,3.0,183.0,100,0.,0.0006);
657 new TH2F("h64","VAR ALM st. 3 fit 4,5,V",30,3.0,183.0,100,0.,0.0006);
658 new TH1F("h65","P",30,3.0,183.0);
659 new TH1F("h461","VAR X st. 3 fit 4,5,V",100,-2.25,2.25);
660 new TH1F("h462","VAR Y st. 3 fit 4,5,V",100,-1.42,1.42);
661 new TH1F("h463","VAR PHI st. 3 fit 4,5,V",100,-0.024,0.024);
662 new TH1F("h464","VAR ALM st. 3 fit 4,5,V",100,-0.024,0.024);
663 // histo2
664 new TH2F("h261","histo2-VAR X st. 3 fit 4,5,V",30,3.0,183.0,100,0.,5.);
665 new TH2F("h262","histo2-VAR Y st. 3 fit 4,5,V",30,3.0,183.0,100,0.,2.);
666 new TH1F("h263","histo2-VAR X st. 3 fit 4,5,V",100,-2.25,2.25);
667 new TH1F("h264","histo2-VAR Y st. 3 fit 4,5,V",100,-1.42,1.42);
668 new TH1F("h265","Phisto2-",30,3.0,183.0);
669 // Histos dx,dy distribution between chambers inside stations
670 new TH1F("h71","DX in st. ID-70",100,-5.,5.);
671 new TH1F("h81","DY in st. ID-80",100,-5.,5.);
672 new TH1F("h72","DX in st. ID-70",100,-5.,5.);
673 new TH1F("h82","DY in st. ID-80",100,-5.,5.);
674 new TH1F("h73","DX in st. ID-70",100,-5.,5.);
675 new TH1F("h83","DY in st. ID-80",100,-5.,5.);
676 new TH1F("h74","DX in st. ID-70",100,-5.,5.);
677 new TH1F("h84","DY in st. ID-80",100,-5.,5.);
678 new TH1F("h75","DX in st. ID-70",100,-5.,5.);
679 new TH1F("h85","DY in st. ID-80",100,-5.,5.);
680}
681
682//_____________________________________________________________________________
683void chfnt(Int_t &ievr, Int_t &ntrackr, Int_t *istatr, Int_t *isignr, Float_t *pxr, Float_t *pyr, Float_t *pzr, Float_t *zvr, Float_t *chi2r, Float_t *pxv, Float_t *pyv, Float_t *pzv)
684{
685 //
686 // fill the ntuple
687 NtupleSt.ievr = ievr;
688 NtupleSt.ntrackr = ntrackr;
689 for (Int_t i=0; i<500; i++) {
690 NtupleSt.istatr[i] = istatr[i];
691 NtupleSt.isignr[i] = isignr[i];
692 NtupleSt.pxr[i] = pxr[i];
693 NtupleSt.pyr[i] = pyr[i];
694 NtupleSt.pzr[i] = pzr[i];
695 NtupleSt.zvr[i] = zvr[i];
696 NtupleSt.chi2r[i] = chi2r[i];
697 NtupleSt.pxv[i] = pxv[i];
698 NtupleSt.pyv[i] = pyv[i];
699 NtupleSt.pzv[i] = pzv[i];
700 }
701 pNtupleGlobal->Fill();
702}
703
704//________________
705void hist_closed()
706{
707 //
708 // write histos and ntuple to "reconst.root" file
709 pHfileGlobal->Write();
710}
711
712//________________________________________________________________________
713void trackf_read_fit(Int_t &ievr, Int_t &nev, Int_t &nhittot1, Int_t *izch, Double_t *xgeant, Double_t *ygeant)
714{
715
716 // introduce aliroot variables in fortran common
717 // tracking study from geant hits
718 //
719
720 AliMUON *pMUON = (AliMUON*) gAlice->GetModule("MUON");
721 TTree *treeH = gAlice->TreeH();
722 Int_t ntracks = (Int_t)treeH->GetEntries();
723 cout<<"ntrack="<<ntracks<<endl;
724
725 nhittot1 = 0;
726
727// Loop over tracks
728 for (Int_t track=0; track<ntracks;track++) {
729 gAlice->ResetHits();
730 treeH->GetEvent(track);
731
732 if (pMUON) {
733
734// Loop over hits
735 for(AliMUONHit* mHit=(AliMUONHit*)pMUON->FirstHit(-1);
736 mHit;
737 mHit=(AliMUONHit*)pMUON->NextHit())
738 {
739 if (mHit->fChamber > 10) continue;
740 TClonesArray *fPartArray = gAlice->Particles();
94de3818 741 Int_t ftrack = mHit->Track();
a9e2aefa 742 Int_t id = ((TParticle*) fPartArray->UncheckedAt(ftrack))->GetPdgCode();
743
744 if (id==kMuonPlus||id==kMuonMinus) {
94de3818 745 xgeant[nhittot1] = mHit->Y();
746 ygeant[nhittot1] = mHit->X();
a9e2aefa 747 izch[nhittot1] = mHit->fChamber;
748// printf("id %d ch %d x %f y %f\n",id,izch[nhittot1],xgeant[nhittot1],ygeant[nhittot1]);
749 nhittot1++;
750 }
751 } // hit loop
752 } // if pMUON
753 } // track loop
754
755 ievr=nev;
756 pHfileGlobal->cd();
757}
758
759//______________________________________________________________________________
760void trackf_read_geant(Int_t *itypg, Double_t *xtrg, Double_t *ytrg, Double_t *ptotg, Int_t *idg, Int_t *izch, Double_t *pvert1g, Double_t *pvert2g, Double_t *pvert3g, Double_t *zvertg, Int_t &nhittot1, Double_t *cx, Double_t *cy, Double_t *cz, Int_t &ievr,Int_t &nev,Double_t *xgeant, Double_t *ygeant, Double_t *clsize1, Double_t *clsize2)
761{
762 //
763 // introduce aliroot variables in fortran common
764 // tracking study from geant hits
765 //
766
767 AliMUON *pMUON = (AliMUON*) gAlice->GetModule("MUON");
768
769 // TTree *treeK = gAlice->TreeK();
770 TTree *treeH = gAlice->TreeH();
771 Int_t ntracks = (Int_t)treeH->GetEntries();
772 cout<<"ntrack="<<ntracks<<endl;
773
774 Int_t maxidg = 0;
775 Int_t nres=0;
776
777//
778// Loop over tracks
779//
780
781 for (Int_t track=0; track<ntracks;track++) {
782 gAlice->ResetHits();
783 treeH->GetEvent(track);
784
785 if (pMUON) {
786//
787// Loop over hits
788//
789 for(AliMUONHit* mHit=(AliMUONHit*)pMUON->FirstHit(-1);
790 mHit;
791 mHit=(AliMUONHit*)pMUON->NextHit())
792 {
793 if (maxidg<=20000) {
794
795 if (mHit->fChamber > 10) continue;
796 TClonesArray *fPartArray = gAlice->Particles();
797 TParticle *particle;
94de3818 798 Int_t ftrack = mHit->Track();
a9e2aefa 799 Int_t id = ((TParticle*) fPartArray->UncheckedAt(ftrack))->GetPdgCode();
800
801// if (id==kMuonPlus||id==kMuonMinus) {
802
803 // inversion de x et y car le champ est inverse dans le programme tracking
804 xtrg[maxidg] = 0;
805 ytrg[maxidg] = 0;
94de3818 806 xgeant[maxidg] = mHit->Y(); // x-pos of hit
807 ygeant[maxidg] = mHit->X(); // y-pos of hit
a9e2aefa 808 clsize1[maxidg] = 0; // cluster size on 1-st cathode
809 clsize2[maxidg] = 0; // cluster size on 2-nd cathode
810 cx[maxidg] = mHit->fCyHit; // Px/P of hit
811 cy[maxidg] = mHit->fCxHit; // Py/P of hit
812 cz[maxidg] = mHit->fCzHit; // Pz/P of hit
813 izch[maxidg] = mHit->fChamber;
814 /*
815 Int_t pdgtype = Int_t(mHit->fParticle); // particle number
816 itypg[maxidg] = gMC->IdFromPDG(pdgtype);
817
818 */
819 itypg[maxidg] = 0;
820 if (id==kMuonPlus) itypg[maxidg] = 5;
821 if (id==kMuonMinus) itypg[maxidg] = 6;
822
823 //printf("ich, itypg[maxidg] %d %d\n",izch[maxidg],itypg[maxidg]);
824
825 ptotg[maxidg] = mHit->fPTot; // P of hit
826
827 particle = (TParticle*) fPartArray->UncheckedAt(ftrack);
828 Float_t thet = particle->Theta();
829 thet = thet*180./3.1416;
830
831 //cout<<"chambre "<<izch[maxidg]<<" ptot="<<ptotg[maxidg]<<" theta="<<thet<<" phi="<<mHit->fPhi<<" z="<<zz<<endl;
832
833 Int_t iparent = particle->GetFirstMother();
834 if (iparent >= 0) {
835 Int_t ip;
836 while(1) {
837 ip=((TParticle*) fPartArray->UncheckedAt(iparent))->GetFirstMother();
838 if (ip < 0) {
839 break;
840 } else {
841 iparent = ip;
842 }
843 }
844 }
845 //printf("iparent - %d\n",iparent);
846 Int_t id1 = ftrack; // numero de la particule generee au vertex
847 Int_t idum = track+1;
848 Int_t id2 = ((TParticle*) fPartArray->UncheckedAt(iparent))->GetPdgCode();
849
850 if (id2==443) id2=114;
851 else id2=116;
852
853 if (id2==116) {
854 nres++;
855 }
856 //printf("id2 %d\n",id2);
857 idg[maxidg] = 30000*id1+10000*idum+id2;
858
859 pvert1g[maxidg] = particle->Py(); // Px vertex
860 pvert2g[maxidg] = particle->Px(); // Py vertex
861 pvert3g[maxidg] = particle->Pz(); // Pz vertex
862 zvertg[maxidg] = particle->Vz(); // z vertex
863
864 // cout<<"x="<<xgeant[maxidg]<<endl;
865 //cout<<"y="<<ygeant[maxidg]<<endl;
866 //cout<<"typ="<<itypg[maxidg]<<endl;
867
868 maxidg ++;
869
870 }
871 }
872 } // hit loop
873// } // if pMUON
874 } // track loop first file
875
876 if (TrH1 && fHits2 ) { // if background file
877 ntracks =(Int_t)TrH1->GetEntries();
878 printf("Trackf_read - 2-nd file - ntracks %d\n",ntracks);
879
880 // Loop over tracks
881 for (Int_t track=0; track<ntracks; track++) {
882
883 if (fHits2) fHits2->Clear();
884 TrH1->GetEvent(track);
885
886 // Loop over hits
887 AliMUONHit *mHit;
888 for (int i=0;i<fHits2->GetEntriesFast();i++)
889 {
890 mHit=(AliMUONHit*) (*fHits2)[i];
891 if (mHit->fChamber > 10) continue;
892 if (maxidg<=20000) {
893
894 // inversion de x et y car le champ est inverse dans le programme tracking !!!!
895 xtrg[maxidg] = 0; // only for reconstructed point
896 ytrg[maxidg] = 0; // only for reconstructed point
94de3818 897 xgeant[maxidg] = mHit->Y(); // x-pos of hit
898 ygeant[maxidg] = mHit->X(); // y-pos of hit
a9e2aefa 899 clsize1[maxidg] = 0; // cluster size on 1-st cathode
900 clsize2[maxidg] = 0; // cluster size on 2-nd cathode
901 cx[maxidg] = mHit->fCyHit; // Px/P of hit
902 cy[maxidg] = mHit->fCxHit; // Py/P of hit
903 cz[maxidg] = mHit->fCzHit; // Pz/P of hit
904 izch[maxidg] = mHit->fChamber; // chamber number
905 ptotg[maxidg] = mHit->fPTot; // P of hit
906
94de3818 907 Int_t ftrack = mHit->Track();
a9e2aefa 908 Int_t id1 = ftrack; // track number
909 Int_t idum = track+1;
910
911 TClonesArray *fPartArray = fParticles2;
912// TParticle *Part=NULL;
913 Int_t id = ((TParticle*) fPartArray->UncheckedAt(ftrack))->GetPdgCode();
914 if (id==kMuonPlus||id==kMuonMinus) {
915 if (id==kMuonPlus) itypg[maxidg] = 5;
916 else itypg[maxidg] = 6;
917 } else itypg[maxidg]=0;
918
919 Int_t id2=0; // set parent to 0 for background !!
920 idg[maxidg] = 30000*id1+10000*idum+id2;
921
922
923 pvert1g[maxidg] = 0; // Px vertex
924 pvert2g[maxidg] = 0; // Py vertex
925 pvert3g[maxidg] = 0; // Pz vertex
926 zvertg[maxidg] = 0; // z vertex
927 maxidg ++;
928
929 } // check limits (maxidg)
930 } // hit loop
931 } // track loop
932 } // if TrH1
933
934 ievr = nev;
935 nhittot1 = maxidg ;
936 cout<<"nhittot1="<<nhittot1<<endl;
937
938 static Int_t nbres=0;
939 if (nres>=19) nbres++;
940 printf("nres, nbres %d %d \n",nres,nbres);
941
942 pHfileGlobal->cd();
943
944}
945
946//________________________________________________________________________
947void trackf_read_spoint(Int_t *itypg, Double_t *xtrg, Double_t *ytrg, Double_t *ptotg, Int_t *idg, Int_t *izch, Double_t *pvert1g, Double_t *pvert2g, Double_t *pvert3g, Double_t *zvertg, Int_t &nhittot1, Double_t *cx, Double_t *cy, Double_t *cz, Int_t &ievr,Int_t &nev,Double_t *xgeant, Double_t *ygeant,Double_t *clsize1, Double_t *clsize2)
948
949{
950 //
951 // introduce aliroot variables in fortran common
952 // tracking study from reconstructed points
953 //
954 AliMUON *pMUON = (AliMUON*) gAlice->GetModule("MUON");
955
956 cout<<"numero de l'evenement "<<nev<<endl;
957
958 TTree *treeR = gAlice->TreeR();
959 Int_t nent=(Int_t)treeR->GetEntries();
960 if (nev < 10)
961 printf("Found %d entries in the tree (must be one per cathode per event! + 1empty)\n",
962 nent);
963//
964
965 Int_t mult1, mult2;
966
967 if (pMUON) {
968 Int_t mpoi=0;
969 for (Int_t ich=0;ich<10;ich++) {
970 printf("chambre %d\n",ich+1);
971 TClonesArray *reconstPoints = pMUON->RawClustAddress(ich);
972
973 pMUON->ResetRawClusters();
974 treeR->GetEvent(nent-1);
975 Int_t npoints = (Int_t) reconstPoints->GetEntries();
976 if (!npoints) continue;
977 printf("\n ch %d npoints = %d\n",ich+1,npoints);
978 // Loop over reconstruted points
979 for (Int_t ipoi=0; ipoi<npoints; ipoi++) {
980 printf(" point %d\n",ipoi);
981 AliMUONRawCluster* point =
982 (AliMUONRawCluster*) reconstPoints->UncheckedAt(ipoi);
983
984 mult1=point->fMultiplicity[0];
985 mult2=point->fMultiplicity[1];
986 xtrg[mpoi]=(Double_t) point->fY[0];
987 ytrg[mpoi]=(Double_t) point->fX[0];
988 izch[mpoi]=ich+1;
989 Int_t itrack = point->fTracks[1];
990 Int_t ihit = point->fTracks[0];
991 xgeant[mpoi] = 0;
992 ygeant[mpoi] = 0;
993 clsize1[mpoi] = mult1;
994 clsize2[mpoi] = mult2;
995 Int_t id1, id2, idum;
996 id1=id2=idum=-1;
997 itypg[mpoi]=0;
998 ihit = ihit-1;
999 if (ihit >=0 && itrack >=0) {
1000 TClonesArray *fPartArray = gAlice->Particles();
1001 gAlice->ResetHits();
1002 gAlice->TreeH()->GetEvent(itrack);
1003 TClonesArray *pMUONhits = pMUON->Hits();
1004 AliMUONHit* mHit;
1005 mHit=(AliMUONHit*) (pMUONhits->UncheckedAt(ihit));
1006 Int_t id = (Int_t) mHit->fParticle;
94de3818 1007 xgeant[mpoi] = mHit->Y();
1008 ygeant[mpoi] = mHit->X();
a9e2aefa 1009 if (id == kMuonPlus) itypg[mpoi]=5;
1010 if (id == kMuonMinus) itypg[mpoi]=6;
1011 TParticle *particle;
1012 particle = (TParticle*)
94de3818 1013 (fPartArray->UncheckedAt(mHit->Track()));
a9e2aefa 1014 TParticle* particleM=(TParticle*)
1015 (fPartArray->UncheckedAt(particle->GetFirstMother()));
1016 Int_t iparent=particleM->GetPdgCode();
1017 printf("\n Particle Id:%d %d \n", id, iparent);
1018 if (iparent == 443) id2=114;
1019 if (iparent == 553) id2=116;
1020 }
1021 id1=itrack;
1022 idum=itrack+1;
1023 idg[mpoi] = 30000*id1+10000*idum+id2;
1024 mpoi++;
1025 } // loop over points
1026 } // loop over chamber
1027 ievr = nev;
1028 cout<<"evenement "<<ievr<<endl;
1029 nhittot1 = mpoi;
1030 cout<<"nhittot1="<<nhittot1<<endl;
1031
1032 treeR->Reset();
1033
1034 pHfileGlobal->cd();
1035
1036 } // if pMUON
1037}
1038
1039//____________________________________________________________________________
1040void trackf_fit(Int_t &ivertex, Double_t *pest, Double_t *pstep, Double_t &pxzinv, Double_t &tphi, Double_t &talam, Double_t &xvert, Double_t &yvert)
1041{
1042 //
1043 // Fit a track candidate with the following input parameters:
1044 // INPUT : IVERTEX : vertex flag, if IVERTEX=1 (XVERT,YVERT) are free paramaters
1045 // if IVERTEX=1 (XVERT,YVERT)=(0.,0.)
1046 // PEST(5) : starting value of parameters (minuit)
1047 // PSTEP(5) : step size for parameters (minuit)
1048 // OUTPUT : PXZINV,TPHI,TALAM,XVERT,YVERT : fitted value of the parameters
1049
1050 static Double_t arglist[10];
1051 static Double_t c[5] = {0.4, 0.45, 0.45, 90., 90.};
1052 static Double_t b1, b2, epxz, efi, exs, exvert, eyvert;
1053 TString chname;
1054 Int_t ierflg = 0;
1055
1056 TMinuit *gMinuit = new TMinuit(5);
1057 gMinuit->mninit(5,10,7);
1058 gMinuit->SetFCN(fcnf); // constant m.f.
1059
1060 arglist[0] = -1;
1061
1062 gMinuit->mnexcm("SET PRINT", arglist, 1, ierflg);
1063 // gMinuit->mnseti('track fitting');
1064
1065 gMinuit->mnparm(0, "invmom", pest[0], pstep[0], -c[0], c[0], ierflg);
1066 gMinuit->mnparm(1, "azimuth", pest[1], pstep[1], -c[1], c[1], ierflg);
1067 gMinuit->mnparm(2, "deep", pest[2], pstep[2], -c[2], c[2], ierflg);
1068 if (ivertex==1) {
1069 gMinuit->mnparm(3, "x ", pest[3], pstep[3], -c[3], c[3], ierflg);
1070 gMinuit->mnparm(4, "y ", pest[4], pstep[4], -c[4], c[4], ierflg);
1071 }
1072
1073 gMinuit->mnexcm("SET NOGR", arglist, 0, ierflg);
1074 gMinuit->mnexcm("MINIMIZE", arglist, 0, ierflg);
1075 gMinuit->mnexcm("EXIT" , arglist, 0, ierflg);
1076
1077 gMinuit->mnpout(0, chname, pxzinv, epxz, b1, b2, ierflg);
1078 gMinuit->mnpout(1, chname, tphi, efi, b1, b2, ierflg);
1079 gMinuit->mnpout(2, chname, talam, exs, b1, b2, ierflg);
1080 if (ivertex==1) {
1081 gMinuit->mnpout(3, chname, xvert, exvert, b1, b2, ierflg);
1082 gMinuit->mnpout(4, chname, yvert, eyvert, b1, b2, ierflg);
1083 }
1084
1085 delete gMinuit;
1086}
1087
1088//________________________________________________________________________________
1089void fcnf(Int_t &npar, Double_t *grad, Double_t &fval, Double_t *pest, Int_t iflag)
1090{
1091 //
1092 // function called by trackf_fit
1093 Int_t futil = 0;
1094 fcn(npar,grad,fval,pest,iflag,futil);
1095}
1096
1097//____________________________________________________________________________
1098void prec_fit(Double_t &pxzinv, Double_t &fis, Double_t &alams, Double_t &xvert, Double_t &yvert, Double_t &pxzinvf, Double_t &fif, Double_t &alf, Double_t &xvertf, Double_t &yvertf, Double_t &epxzinv, Double_t &efi, Double_t &exs, Double_t &exvert, Double_t &eyvert)
1099{
1100 //
1101 // minuit fits for tracking finding
1102
1103 static Double_t arglist[10];
1104 static Double_t c1[5] = {0.001, 0.001, 0.001, 1., 1.};
1105 static Double_t c2[5] = {0.5, 0.5, 0.5, 120., 120.};
1106 static Double_t emat[9];
1107 static Double_t b1, b2;
1108 Double_t fmin, fedm, errdef;
1109 Int_t npari, nparx, istat;
1110
1111 TString chname;
1112 Int_t ierflg = 0;
1113
1114 TMinuit *gMinuit = new TMinuit(5);
1115 gMinuit->mninit(5,10,7);
1116 gMinuit->SetFCN(fcnfitf);
1117
1118 arglist[0] = -1.;
1119 gMinuit->mnexcm("SET PRINT", arglist, 1, ierflg);
1120
1121 // gMinuit->mnseti('track fitting');
1122
1123 gMinuit->mnparm(0,"invmom", pxzinv, c1[0], -c2[0], c2[0], ierflg); // 0.003, 0.5
1124 gMinuit->mnparm(1,"azimuth ", fis, c1[1], -c2[1], c2[1], ierflg);
1125 gMinuit->mnparm(2,"deep ", alams, c1[2], -c2[2], c2[2], ierflg);
1126 gMinuit->mnparm(3,"xvert", xvert, c1[3], -c2[3], c2[3], ierflg);
1127 gMinuit->mnparm(4,"yvert", yvert, c1[4], -c2[4], c2[4], ierflg);
1128
1129 gMinuit->mnexcm("SET NOGR", arglist, 0, ierflg);
1130 arglist[0] = 2.;
1131 gMinuit->mnexcm("MINIMIZE", arglist, 0, ierflg);
1132 gMinuit->mnexcm("EXIT", arglist, 0, ierflg);
1133
1134 gMinuit->mnpout(0, chname, pxzinvf, epxzinv, b1, b2, ierflg);
1135 gMinuit->mnpout(1, chname, fif, efi, b1, b2, ierflg);
1136 gMinuit->mnpout(2, chname, alf, exs, b1, b2, ierflg);
1137 gMinuit->mnpout(3, chname, xvertf, exvert, b1, b2, ierflg);
1138 gMinuit->mnpout(4, chname, yvertf, eyvert, b1, b2, ierflg);
1139
1140 gMinuit->mnemat(emat, 3);
1141 gMinuit->mnstat(fmin, fedm, errdef, npari, nparx, istat);
1142
1143 delete gMinuit;
1144}
1145
1146//____________________________________________________________________
1147void fcnfitf(Int_t &npar, Double_t *grad, Double_t &fval, Double_t *xval, Int_t iflag)
1148{
1149 //
1150 // function called by prec_fit
1151 Int_t futil = 0;
1152 fcnfit(npar,grad,fval,xval,iflag,futil);
1153}