]>
Commit | Line | Data |
---|---|---|
65fb704d | 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 | /* | |
17 | $Log$ | |
18 | */ | |
19 | ||
20 | /////////////////////////////////////////////////////////////////////////////// | |
21 | // // | |
22 | // // | |
23 | /////////////////////////////////////////////////////////////////////////////// | |
24 | ||
25 | #include <strings.h> | |
26 | ||
27 | #include "TObjArray.h" | |
28 | #include "TH1.h" | |
29 | #include "TList.h" | |
30 | #include "TROOT.h" | |
31 | #include "TBrowser.h" | |
32 | #include "TMath.h" | |
33 | #include "TLorentzVector.h" | |
34 | #include "TDatabasePDG.h" | |
35 | #include "TMath.h" | |
36 | ||
37 | #include "AliMCQA.h" | |
38 | #include "AliRun.h" | |
39 | #include "AliModule.h" | |
40 | #include "AliMC.h" | |
41 | ||
42 | ClassImp(AliMCQA) | |
43 | ||
44 | ||
45 | //_____________________________________________________________________________ | |
46 | AliMCQA::AliMCQA(Int_t ndets): fNdets(ndets) | |
47 | { | |
48 | // | |
49 | // Constructor, creates the list of lists of histograms | |
50 | // | |
51 | TList *list; | |
52 | ||
53 | fQAList = new TObjArray(ndets); | |
54 | TObjArray &hist = *fQAList; | |
55 | ||
56 | char title[100]; | |
57 | // | |
58 | TObjArray &mods = *(gAlice->Modules()); | |
59 | AliModule *mod; | |
60 | TList *dir = gDirectory->GetList(); | |
61 | for (Int_t i=0; i<ndets; i++) { | |
62 | hist[i] = list = new TList(); | |
63 | mod = (AliModule *) mods[i]; | |
64 | ||
65 | // Energy Spectrum | |
66 | sprintf(title,"Spectrum entering: %s ",mod->GetName()); | |
67 | list->Add(new TH1F("hEnIn",strcat(title,mod->GetTitle()),100,-4,2)); | |
68 | dir->Remove(dir->FindObject("hEnIn")); | |
69 | ||
70 | sprintf(title,"Spectrum exiting: %s ",mod->GetName()); | |
71 | list->Add(new TH1F("hEnOut",strcat(title,mod->GetTitle()),100,-4,2)); | |
72 | dir->Remove(dir->FindObject("hEnOut")); | |
73 | ||
74 | // Z position | |
75 | sprintf(title,"Z coordinate entering: %s ",mod->GetName()); | |
76 | list->Add(new TH1F("hZIn",strcat(title,mod->GetTitle()),100, | |
77 | mod->ZMin(),mod->ZMax())); | |
78 | dir->Remove(dir->FindObject("hZIn")); | |
79 | ||
80 | sprintf(title,"Z coordinate exiting: %s ",mod->GetName()); | |
81 | list->Add(new TH1F("hZOut",strcat(title,mod->GetTitle()),100, | |
82 | mod->ZMin(),mod->ZMax())); | |
83 | dir->Remove(dir->FindObject("hZOut")); | |
84 | } | |
85 | // | |
86 | gROOT->GetListOfBrowsables()->Add(this,"AliMCQA"); | |
87 | ||
88 | fDetDone = new Int_t[fNdets]; | |
89 | } | |
90 | ||
91 | //_____________________________________________________________________________ | |
92 | void AliMCQA::Browse(TBrowser *b) | |
93 | { | |
94 | // | |
95 | // Called when the item "Run" is clicked on the left pane | |
96 | // of the Root browser. | |
97 | // It displays the Root Trees and all detectors. | |
98 | // | |
99 | ||
100 | TIter next(fQAList); | |
101 | TList *histos; | |
102 | TH1 *hist; | |
103 | while((histos = (TList*)next())) { | |
104 | TIter next1(histos); | |
105 | while((hist = (TH1*)next1())) { | |
106 | b->Add(hist,hist->GetTitle()); | |
107 | } | |
108 | } | |
109 | } | |
110 | ||
111 | //_____________________________________________________________________________ | |
112 | void AliMCQA::PreTrack() | |
113 | { | |
114 | fOldId=-1; | |
115 | for(Int_t i=0; i<fNdets; i++) fDetDone[i]=0; | |
116 | } | |
117 | ||
118 | //_____________________________________________________________________________ | |
119 | void AliMCQA::StepManager(Int_t id) | |
120 | { | |
121 | if(fOldId != id) { | |
122 | TH1F *hist; | |
123 | TLorentzVector p, x; | |
124 | gMC->TrackMomentum(p); | |
125 | gMC->TrackPosition(x); | |
126 | Double_t energy = TMath::Max( | |
127 | p[3]-gAlice->PDGDB()->GetParticle(gMC->TrackPid())->Mass(),1.e-12); | |
128 | if(fOldId > -1) { | |
129 | if(!fDetDone[fOldId] && !gMC->IsNewTrack()) { | |
130 | TList *histold = (TList*) (*fQAList)[fOldId]; | |
131 | hist = (TH1F*) histold->FindObject("hEnOut"); | |
132 | hist->Fill(TMath::Log10(energy)); | |
133 | hist = (TH1F*) histold->FindObject("hZOut"); | |
134 | hist->Fill(x[2]); | |
135 | fDetDone[fOldId]=1; | |
136 | } | |
137 | } | |
138 | if(!fDetDone[id] && !gMC->IsNewTrack()) { | |
139 | TList *histnew = (TList*) (*fQAList)[id]; | |
140 | hist = (TH1F*) histnew->FindObject("hEnIn"); | |
141 | hist->Fill(TMath::Log10(energy)); | |
142 | hist = (TH1F*) histnew->FindObject("hZIn"); | |
143 | hist->Fill(x[2]); | |
144 | } | |
145 | fOldId=id; | |
146 | } | |
147 | } |