]>
Commit | Line | Data |
---|---|---|
990f8c6b | 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 | /* $Id$ */ | |
17 | ||
18 | /// \class AliMUONSimData | |
19 | /// | |
20 | /// Class containing MUON data: hits, digits, rawclusters, globaltrigger, localtrigger, etc .. | |
21 | /// The classe makes the lik between the MUON data lists and the event trees from loaders | |
22 | /// | |
23 | /// \author Gines Martinez, Subatech, September 2003 | |
24 | /// | |
25 | ||
26 | #include "AliMUONSimData.h" | |
27 | #include "AliMUONDataIterator.h" | |
28 | #include "AliMUONConstants.h" | |
29 | #include "AliMUONHit.h" | |
30 | #include "AliMUONDigit.h" | |
31 | #include "AliMUONGlobalTrigger.h" | |
32 | #include "AliMUONLocalTrigger.h" | |
33 | #include "AliMUONRegionalTrigger.h" | |
34 | #include "AliMUONTriggerCrateStore.h" | |
35 | #include "AliMUONTriggerCircuit.h" | |
36 | #include "AliMUONGeometryTransformer.h" | |
37 | #include "AliMUONRawCluster.h" | |
38 | ||
39 | // This is from rec, classes in base should not depend on rec !!! | |
40 | //#include "AliMUONTrack.h" | |
41 | //#include "AliMUONTriggerTrack.h" | |
42 | ||
43 | #include "AliRunLoader.h" | |
44 | #include "AliStack.h" | |
45 | #include "AliLog.h" | |
46 | ||
47 | #include <TString.h> | |
48 | #include <TParticle.h> | |
49 | #include <TNtuple.h> | |
50 | #include <Riostream.h> | |
51 | #include <TFile.h> | |
52 | ||
53 | /// \cond CLASSIMP | |
54 | ClassImp(AliMUONSimData) | |
55 | /// \endcond | |
56 | ||
57 | //_____________________________________________________________________________ | |
58 | AliMUONSimData::AliMUONSimData() | |
59 | : AliMUONData(), | |
60 | fHits(0x0), | |
61 | //fSDigits(0x0), | |
62 | fNhits(0) | |
63 | //fNSdigits(0x0) | |
64 | { | |
65 | /// Default constructor | |
66 | } | |
67 | //_____________________________________________________________________________ | |
68 | AliMUONSimData::AliMUONSimData(AliLoader * loader, const char* name, const char* title) | |
69 | : AliMUONData(loader, name, title), | |
70 | fHits(0x0), | |
71 | //fSDigits(0x0), | |
72 | fNhits(0) | |
73 | //fNSdigits(0x0) | |
74 | { | |
75 | /// Standard constructor | |
76 | } | |
77 | ||
78 | //_____________________________________________________________________________ | |
79 | AliMUONSimData::AliMUONSimData(const char* galiceFile) | |
80 | : AliMUONData(galiceFile, "MUONFolderSim"), | |
81 | fHits(0x0), | |
82 | //fSDigits(0x0), | |
83 | fNhits(0) | |
84 | //fNSdigits(0x0) | |
85 | { | |
86 | /// Constructor for loading data from gAlice file | |
87 | } | |
88 | ||
89 | //_____________________________________________________________________________ | |
90 | AliMUONSimData::~AliMUONSimData() | |
91 | { | |
92 | /// Destructor for AliMUONSimData | |
93 | if (fHits) { | |
94 | fHits->Delete(); | |
95 | delete fHits; | |
96 | } | |
97 | /* | |
98 | if (fSDigits) { | |
99 | fSDigits->Delete(); | |
100 | delete fSDigits; | |
101 | } | |
102 | */ | |
103 | } | |
104 | //____________________________________________________________________________ | |
105 | void AliMUONSimData::AddHit(Int_t fIshunt, Int_t track, Int_t detElemId, | |
106 | Int_t idpart, Float_t X, Float_t Y, Float_t Z, | |
107 | Float_t tof, Float_t momentum, Float_t theta, | |
108 | Float_t phi, Float_t length, Float_t destep, | |
109 | Float_t Xref,Float_t Yref,Float_t Zref) | |
110 | { | |
111 | /// Add new hit to the hit list | |
112 | ||
113 | TClonesArray &lhits = *fHits; | |
114 | new(lhits[fNhits++]) AliMUONHit(fIshunt, track, detElemId, | |
115 | idpart, X, Y, Z, | |
116 | tof, momentum, theta, | |
117 | phi, length, destep, | |
118 | Xref,Yref,Zref); | |
119 | } | |
120 | /* | |
121 | //_____________________________________________________________________________ | |
122 | void AliMUONSimData::AddSDigit(Int_t id, const AliMUONDigit& Sdigit) | |
123 | { | |
124 | /// Add a MUON Sdigit to the list of SDigits of the detection plane id | |
125 | ||
126 | TClonesArray &lSdigits = * SDigits(id) ; | |
127 | new(lSdigits[fNSdigits[id]++]) AliMUONDigit(Sdigit); | |
128 | } | |
129 | ||
130 | //____________________________________________________________________________ | |
131 | TClonesArray* AliMUONSimData::SDigits(Int_t DetectionPlane) const | |
132 | { | |
133 | /// Getting List of SDigits | |
134 | ||
135 | if (fSDigits) | |
136 | return ( (TClonesArray*) fSDigits->At(DetectionPlane) ); | |
137 | else | |
138 | return NULL; | |
139 | } | |
140 | */ | |
141 | //____________________________________________________________________________ | |
142 | void AliMUONSimData::FillOwn(Option_t* option) | |
143 | { | |
144 | /// Method to fill the trees | |
145 | ||
146 | const char *cH = strstr(option,"H"); | |
147 | //const char *cS = strstr(option,"S"); // SDigits branches in TreeS | |
148 | ||
149 | //const char *cRP = strstr(option,"RP"); // Reconstructed Particle in TreeP | |
150 | ||
151 | // Filling TreeH | |
152 | if ( TreeH() && cH ) | |
153 | { | |
154 | TreeH()->Fill(); | |
155 | } | |
156 | /* | |
157 | // Filling TreeS | |
158 | if ( TreeS() && cS) | |
159 | { | |
160 | TreeS()->Fill(); | |
161 | } | |
162 | */ | |
163 | } | |
164 | ||
165 | //_____________________________________________________________________________ | |
166 | void AliMUONSimData::MakeOwnBranch(Option_t* option) | |
167 | { | |
168 | /// Create Tree branches for the MUON. | |
169 | ||
170 | const Int_t kBufferSize = 4000; | |
171 | char branchname[30]; | |
172 | ||
173 | //Setting Data Container | |
174 | SetDataContainer(option); | |
175 | ||
176 | const char *cH = strstr(option,"H"); | |
177 | //const char *cS = strstr(option,"S"); // Digits branches in TreeS | |
178 | ||
179 | TBranch * branch = 0x0; | |
180 | ||
181 | // Creating Branches for Hits | |
182 | if (TreeH() && cH) { | |
183 | sprintf(branchname,"%sHits",GetName()); | |
184 | branch = TreeH()->GetBranch(branchname); | |
185 | if (branch) { | |
186 | AliInfo(Form("MakeBranch","Branch %s is already in tree.",branchname)); | |
187 | return ; | |
188 | } | |
189 | branch = TreeH()->Branch(branchname,&fHits,kBufferSize); | |
190 | //Info("MakeBranch","Making Branch %s for hits \n",branchname); | |
191 | } | |
192 | /* | |
193 | //Creating Branches for SDigits | |
194 | if (TreeS() && cS ) { | |
195 | // one branch for Sdigits per chamber | |
196 | for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++) { | |
197 | sprintf(branchname,"%sSDigits%d",GetName(),iDetectionPlane+1); | |
198 | branch = 0x0; | |
199 | branch = TreeS()->GetBranch(branchname); | |
200 | if (branch) { | |
201 | AliInfo(Form("Branch %s is already in tree.",branchname)); | |
202 | return; | |
203 | } | |
204 | TClonesArray * sdigits = SDigits(iDetectionPlane); | |
205 | branch = TreeS()->Branch(branchname, &sdigits, kBufferSize,1); | |
206 | //Info("MakeBranch","Making Branch %s for sdigits in detection plane %d\n",branchname,iDetectionPlane+1); | |
207 | } | |
208 | } | |
209 | */ | |
210 | } | |
211 | ||
212 | //____________________________________________________________________________ | |
213 | void AliMUONSimData::SetOwnDataContainer(Option_t* option) | |
214 | { | |
215 | /// Setting data containers of muon data | |
216 | ||
217 | const char *cH = strstr(option,"H"); | |
218 | //const char *cS = strstr(option,"S"); // SDigits | |
219 | //const char *cRP = strstr(option,"RP"); // Reconstructed Particles | |
220 | AliDebug(1,Form("option=%s",option)); | |
221 | // | |
222 | // Clones array for hits | |
223 | if ( cH ) { | |
224 | if (fHits == 0x0) { | |
225 | fHits = new TClonesArray("AliMUONHit",1000); | |
226 | } | |
227 | ResetHits(); | |
228 | } | |
229 | /* | |
230 | // | |
231 | // Container for Sdigits | |
232 | if (cS) { | |
233 | if (fSDigits == 0x0) { | |
234 | AliDebug(1,"Creating fSDigits TObjArray"); | |
235 | fSDigits = new TObjArray(AliMUONConstants::NCh()); | |
236 | fNSdigits= new Int_t[AliMUONConstants::NCh()]; | |
237 | for (Int_t i=0; i<AliMUONConstants::NCh() ;i++) { | |
238 | TClonesArray* a = new TClonesArray("AliMUONDigit",10000); | |
239 | a->SetOwner(); | |
240 | fSDigits->AddAt(a,i); | |
241 | AliDebug(1,Form("fSDigits[%d]=%p",i,a)); | |
242 | fNSdigits[i]=0; | |
243 | } | |
244 | } | |
245 | else { | |
246 | AliDebug(1,Form("fSDigits already there = %p",fSDigits)); | |
247 | } | |
248 | ResetSDigits(); | |
249 | } | |
250 | */ | |
251 | } | |
252 | ||
253 | //____________________________________________________________________________ | |
254 | void AliMUONSimData::SetOwnTreeAddress(Option_t* option) | |
255 | { | |
256 | // Setting Data containers | |
257 | SetOwnDataContainer(option); | |
258 | ||
259 | /// Setting Addresses to the events trees | |
260 | ||
261 | const char *cH = strstr(option,"H"); | |
262 | //const char *cS = strstr(option,"S"); // SDigits branches in TreeS | |
263 | ||
264 | // Set branch address for the Hits, Digits, RawClusters, GlobalTrigger and LocalTrigger Tree. | |
265 | char branchname[30]; | |
266 | TBranch * branch = 0x0; | |
267 | ||
268 | AliDebug(1,Form("option=%s",option)); | |
269 | // | |
270 | // Branch address for hit tree | |
271 | if (TreeH() && fHits && cH) { | |
272 | sprintf(branchname,"%sHits",GetName()); | |
273 | branch = TreeH()->GetBranch(branchname); | |
274 | if (branch) { | |
275 | // Info("SetTreeAddress","(%s) Setting for Hits",GetName()); | |
276 | branch->SetAddress(&fHits); | |
277 | } | |
278 | else { //can be invoked before branch creation | |
279 | //AliWarning(Form("(%s) Failed for Hits. Can not find branch in tree.",GetName())); | |
280 | } | |
281 | } | |
282 | /* | |
283 | // | |
284 | // Branch address for Sdigit tree | |
285 | if (TreeS() && fSDigits && cS) { | |
286 | AliDebug(1,"Setting branch addresses"); | |
287 | for (int i=0; i<AliMUONConstants::NCh(); i++) { | |
288 | sprintf(branchname,"%sSDigits%d",GetName(),i+1); | |
289 | if (fSDigits) { | |
290 | AliDebug(1,Form("TreeS=%p for ich=%d branchname=%s", | |
291 | TreeS(),i,branchname)); | |
292 | branch = TreeS()->GetBranch(branchname); | |
293 | TClonesArray * sdigits = SDigits(i); | |
294 | if (branch) branch->SetAddress( &sdigits ); | |
295 | else AliWarning(Form("(%s) Failed for SDigits Detection plane %d. Can not find branch in tree.",GetName(),i)); | |
296 | } | |
297 | } | |
298 | } | |
299 | */ | |
300 | } | |
301 | ||
302 | //____________________________________________________________________________ | |
303 | void AliMUONSimData::Fill(Option_t* option) | |
304 | { | |
305 | /// Method to fill the trees | |
306 | ||
307 | AliMUONData::Fill(option); | |
308 | FillOwn(option); | |
309 | } | |
310 | ||
311 | //_____________________________________________________________________________ | |
312 | void AliMUONSimData::MakeBranch(Option_t* option) | |
313 | { | |
314 | /// Create Tree branches for the MUON. | |
315 | ||
316 | AliMUONData::MakeBranch(option); | |
317 | MakeOwnBranch(option); | |
318 | } | |
319 | ||
320 | //____________________________________________________________________________ | |
321 | void AliMUONSimData::SetDataContainer(Option_t* option) | |
322 | { | |
323 | /// Setting data containers of muon data | |
324 | ||
325 | AliMUONData::SetDataContainer(option); | |
326 | SetOwnDataContainer(option); | |
327 | } | |
328 | ||
329 | //____________________________________________________________________________ | |
330 | void AliMUONSimData::SetTreeAddress(Option_t* option) | |
331 | { | |
332 | // Setting Data containers | |
333 | SetDataContainer(option); | |
334 | ||
335 | AliMUONData::SetTreeAddress(option); | |
336 | SetOwnTreeAddress(option); | |
337 | } | |
338 | ||
339 | //____________________________________________________________________________ | |
340 | Int_t | |
341 | AliMUONSimData::GetNtracks() const | |
342 | { | |
343 | /// Get number of entries in hits three | |
344 | ||
345 | Int_t ntrk = 0; | |
346 | if (fLoader && fLoader->TreeH()) | |
347 | ntrk = (Int_t) fLoader->TreeH()->GetEntries(); | |
348 | return ntrk; | |
349 | } | |
350 | /* | |
351 | //____________________________________________________________________________ | |
352 | void AliMUONSimData::ResetSDigits() | |
353 | { | |
354 | /// Reset number of Sdigits and the Sdigits array for this detector | |
355 | ||
356 | if (fSDigits == 0x0) return; | |
357 | for ( int i=0;i<AliMUONConstants::NCh();i++ ) { | |
358 | if ((*fSDigits)[i]) ((TClonesArray*)fSDigits->At(i))->Clear(); | |
359 | if (fNSdigits) fNSdigits[i]=0; | |
360 | } | |
361 | } | |
362 | */ | |
363 | //______________________________________________________________________________ | |
364 | void AliMUONSimData::ResetHits() | |
365 | { | |
366 | /// Reset number of clusters and the cluster array for this detector | |
367 | ||
368 | fNhits = 0; | |
369 | if (fHits) fHits->Clear(); | |
370 | } | |
371 | ||
372 | //_____________________________________________________________________________ | |
373 | void | |
374 | AliMUONSimData::DumpKine(Int_t event2Check) | |
375 | { | |
376 | /// Dump kinematics | |
377 | ||
378 | fRunLoader->LoadKinematics("READ"); | |
379 | ||
380 | Int_t nevents = fRunLoader->GetNumberOfEvents(); | |
381 | for (Int_t ievent=0; ievent<nevents; ievent++) { // Event loop | |
382 | if ( event2Check != 0 ) ievent=event2Check; | |
383 | ||
384 | // Getting event ievent | |
385 | fRunLoader->GetEvent(ievent); | |
386 | ||
387 | // Stack of particle for this event | |
388 | AliStack* stack = fRunLoader->Stack(); | |
389 | ||
390 | Int_t nparticles = (Int_t) fRunLoader->Stack()->GetNtrack(); | |
391 | printf(">>> Event %d, Number of particles is %d \n", ievent, nparticles); | |
392 | ||
393 | for (Int_t iparticle=0; iparticle<nparticles; iparticle++) { | |
394 | stack->Particle(iparticle)->Print(""); | |
395 | } | |
396 | if (event2Check!=0) ievent=nevents; | |
397 | } | |
398 | fRunLoader->UnloadKinematics(); | |
399 | } | |
400 | ||
401 | ||
402 | //_____________________________________________________________________________ | |
403 | void | |
404 | AliMUONSimData::DumpHits(Int_t event2Check, Option_t* opt) | |
405 | { | |
406 | /// Dump hits | |
407 | ||
408 | fLoader->LoadHits("READ"); | |
409 | ||
410 | // Event loop | |
411 | Int_t nevents = fRunLoader->GetNumberOfEvents(); | |
412 | for (Int_t ievent=0; ievent<nevents; ievent++) { | |
413 | if (event2Check!=0) ievent=event2Check; | |
414 | printf(">>> Event %d \n",ievent); | |
415 | ||
416 | // Getting event ievent | |
417 | fRunLoader->GetEvent(ievent); | |
418 | SetTreeAddress("H"); | |
419 | ||
420 | // Track loop | |
421 | Int_t ntracks = (Int_t) GetNtracks(); | |
422 | for (Int_t itrack=0; itrack<ntracks; itrack++) { | |
423 | //Getting List of Hits of Track itrack | |
424 | GetTrack(itrack); | |
425 | ||
426 | Int_t nhits = (Int_t) Hits()->GetEntriesFast(); | |
427 | printf(">>> Track %d, Number of hits %d \n",itrack,nhits); | |
428 | for (Int_t ihit=0; ihit<nhits; ihit++) { | |
429 | AliMUONHit* mHit = static_cast<AliMUONHit*>(Hits()->At(ihit)); | |
430 | mHit->Print(opt); | |
431 | } | |
432 | ResetHits(); | |
433 | } | |
434 | if (event2Check!=0) ievent=nevents; | |
435 | } | |
436 | fLoader->UnloadHits(); | |
437 | } | |
438 | /* | |
439 | //_____________________________________________________________________________ | |
440 | void | |
441 | AliMUONSimData::DumpSDigits(Int_t event2Check, Option_t* opt) | |
442 | { | |
443 | /// Dump SDigits | |
444 | ||
445 | fLoader->LoadSDigits("READ"); | |
446 | ||
447 | // Event loop | |
448 | Int_t nevents = fRunLoader->GetNumberOfEvents(); | |
449 | for (Int_t ievent=0; ievent<nevents; ievent++) { | |
450 | if (event2Check!=0) ievent=event2Check; | |
451 | printf(">>> Event %d \n",ievent); | |
452 | ||
453 | // Getting event ievent | |
454 | fRunLoader->GetEvent(ievent); | |
455 | SetTreeAddress("S"); | |
456 | GetSDigits(); | |
457 | ||
458 | // Loop on chambers | |
459 | Int_t nchambers = AliMUONConstants::NCh(); ; | |
460 | for (Int_t ichamber=0; ichamber<nchambers; ichamber++) { | |
461 | TClonesArray* digits = SDigits(ichamber); | |
462 | ||
463 | // Loop on Sdigits | |
464 | Int_t ndigits = (Int_t)digits->GetEntriesFast(); | |
465 | for (Int_t idigit=0; idigit<ndigits; idigit++) { | |
466 | AliMUONDigit* mDigit = static_cast<AliMUONDigit*>(digits->At(idigit)); | |
467 | mDigit->Print(opt); | |
468 | } | |
469 | } | |
470 | ResetSDigits(); | |
471 | if (event2Check!=0) ievent=nevents; | |
472 | } | |
473 | fLoader->UnloadSDigits(); | |
474 | } | |
475 | */ |