]>
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 AliMUONRecData | |
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 "AliMUONRecData.h" | |
27 | #include "AliMUONDataIterator.h" | |
28 | #include "AliMUONConstants.h" | |
29 | #include "AliMUONDigit.h" | |
30 | #include "AliMUONGlobalTrigger.h" | |
31 | #include "AliMUONLocalTrigger.h" | |
32 | #include "AliMUONRegionalTrigger.h" | |
33 | #include "AliMUONTriggerCrateStore.h" | |
34 | #include "AliMUONTriggerCircuit.h" | |
35 | #include "AliMUONGeometryTransformer.h" | |
36 | #include "AliMUONRawCluster.h" | |
37 | #include "AliMUONTrack.h" | |
38 | #include "AliMUONTriggerTrack.h" | |
39 | ||
40 | #include "AliRunLoader.h" | |
41 | #include "AliStack.h" | |
42 | #include "AliLog.h" | |
43 | ||
44 | #include <TString.h> | |
45 | #include <TParticle.h> | |
46 | #include <TNtuple.h> | |
47 | #include <Riostream.h> | |
48 | #include <TFile.h> | |
49 | ||
50 | /// \cond CLASSIMP | |
51 | ClassImp(AliMUONRecData) | |
52 | /// \endcond | |
53 | ||
54 | //_____________________________________________________________________________ | |
55 | AliMUONRecData::AliMUONRecData() | |
56 | : AliMUONData(), | |
57 | fRawClusters(0x0), | |
58 | fRecTracks(0x0), | |
59 | fRecTriggerTracks(0x0), | |
60 | fNrawclusters(0x0), | |
61 | fNrectracks(0), | |
62 | fNrectriggertracks(0) | |
63 | { | |
64 | /// Default constructor | |
65 | } | |
66 | //_____________________________________________________________________________ | |
67 | AliMUONRecData::AliMUONRecData(AliLoader * loader, const char* name, const char* title) | |
68 | : AliMUONData(loader, name, title), | |
69 | fRawClusters(0x0), | |
70 | fRecTracks(0x0), | |
71 | fRecTriggerTracks(0x0), | |
72 | fNrawclusters(0x0), | |
73 | fNrectracks(0), | |
74 | fNrectriggertracks(0) | |
75 | { | |
76 | /// Standard constructor | |
77 | } | |
78 | ||
79 | //_____________________________________________________________________________ | |
80 | AliMUONRecData::AliMUONRecData(const char* galiceFile) | |
81 | : AliMUONData(galiceFile, "MUONFolder"), | |
82 | fRawClusters(0x0), | |
83 | fRecTracks(0x0), | |
84 | fRecTriggerTracks(0x0), | |
85 | fNrawclusters(0x0), | |
86 | fNrectracks(0), | |
87 | fNrectriggertracks(0) | |
88 | { | |
89 | /// Constructor for loading data from gAlice file | |
90 | } | |
91 | ||
92 | //_____________________________________________________________________________ | |
93 | AliMUONRecData::~AliMUONRecData() | |
94 | { | |
95 | /// Destructor for AliMUONRecData | |
96 | ||
97 | if (fRawClusters) { | |
98 | fRawClusters->Delete(); | |
99 | delete fRawClusters; | |
100 | } | |
101 | if (fRecTracks){ | |
102 | fRecTracks->Delete(); | |
103 | delete fRecTracks; | |
104 | } | |
105 | if (fRecTriggerTracks){ | |
106 | fRecTriggerTracks->Delete(); | |
107 | delete fRecTriggerTracks; | |
108 | } | |
109 | } | |
110 | //_____________________________________________________________________________ | |
111 | void AliMUONRecData::AddRawCluster(Int_t id, const AliMUONRawCluster& c) | |
112 | { | |
113 | /// Add a MUON rawcluster to the list in the detection plane id | |
114 | ||
115 | TClonesArray &lrawcl = *((TClonesArray*) fRawClusters->At(id)); | |
116 | new(lrawcl[fNrawclusters[id]++]) AliMUONRawCluster(c); | |
117 | } | |
118 | //_____________________________________________________________________________ | |
119 | void AliMUONRecData::AddRecTrack(const AliMUONTrack& track) | |
120 | { | |
121 | /// Add a MUON rectrack | |
122 | ||
123 | TClonesArray &lrectracks = *fRecTracks; | |
124 | new(lrectracks[fNrectracks++]) AliMUONTrack(track); | |
125 | } | |
126 | //_____________________________________________________________________________ | |
127 | void AliMUONRecData::AddRecTriggerTrack(const AliMUONTriggerTrack& triggertrack) | |
128 | { | |
129 | /// Add a MUON triggerrectrack | |
130 | ||
131 | TClonesArray &lrectriggertracks = *fRecTriggerTracks; | |
132 | new(lrectriggertracks[fNrectriggertracks++]) AliMUONTriggerTrack(triggertrack); | |
133 | } | |
134 | //____________________________________________________________________________ | |
135 | Bool_t AliMUONRecData::IsRawClusterBranchesInTree() | |
136 | { | |
137 | /// Checking if there are RawCluster Branches In TreeR | |
138 | ||
139 | if (TreeR()==0x0) { | |
140 | AliError("No treeR in memory"); | |
141 | return kFALSE; | |
142 | } | |
143 | else { | |
144 | char branchname[30]; | |
145 | sprintf(branchname,"%sRawClusters1",GetName()); | |
146 | TBranch * branch = 0x0; | |
147 | branch = TreeR()->GetBranch(branchname); | |
148 | if (branch) return kTRUE; | |
149 | else return kFALSE; | |
150 | } | |
151 | } | |
152 | //____________________________________________________________________________ | |
153 | Bool_t AliMUONRecData::IsTrackBranchesInTree() | |
154 | { | |
155 | /// Checking if there are Track Branches In TreeT | |
156 | if (TreeT()==0x0) { | |
157 | AliError("No treeT in memory"); | |
158 | return kFALSE; | |
159 | } | |
160 | else { | |
161 | char branchname[30]; | |
162 | sprintf(branchname,"%sTrack",GetName()); | |
163 | TBranch * branch = 0x0; | |
164 | branch = TreeT()->GetBranch(branchname); | |
165 | if (branch) return kTRUE; | |
166 | else return kFALSE; | |
167 | } | |
168 | } | |
169 | //____________________________________________________________________________ | |
170 | Bool_t AliMUONRecData::IsTriggerBranchesInTree() | |
171 | { | |
172 | /// Checking if there are Trigger Branches In TreeR | |
173 | if (TreeR()==0x0) { | |
174 | AliError("No treeR in memory"); | |
175 | return kFALSE; | |
176 | } | |
177 | else { | |
178 | char branchname[30]; | |
179 | sprintf(branchname,"%sLocalTrigger",GetName()); | |
180 | TBranch * branch = 0x0; | |
181 | branch = TreeR()->GetBranch(branchname); | |
182 | if (branch) return kTRUE; | |
183 | else return kFALSE; | |
184 | } | |
185 | } | |
186 | //____________________________________________________________________________ | |
187 | Bool_t AliMUONRecData::IsTriggerTrackBranchesInTree() | |
188 | { | |
189 | /// Checking if there are TriggerTrack Branches In TreeT | |
190 | if (TreeT()==0x0) { | |
191 | AliError("No treeT in memory"); | |
192 | return kFALSE; | |
193 | } | |
194 | else { | |
195 | char branchname[30]; | |
196 | sprintf(branchname,"%sTriggerTrack",GetName()); | |
197 | TBranch * branch = 0x0; | |
198 | branch = TreeT()->GetBranch(branchname); | |
199 | if (branch) return kTRUE; | |
200 | else return kFALSE; | |
201 | } | |
202 | } | |
203 | //____________________________________________________________________________ | |
204 | void AliMUONRecData::FillOwn(Option_t* option) | |
205 | { | |
206 | /// Method to fill the trees | |
207 | ||
208 | const char *cRC = strstr(option,"RC"); // RawCluster branches in TreeR | |
209 | const char *cRT = strstr(option,"RT"); // Reconstructed Track in TreeT | |
210 | const char *cRL = strstr(option,"RL"); // Reconstructed Trigger Track in TreeT | |
211 | const char *cTC = strstr(option,"TC"); // global and local Trigger branches Copy in TreeR | |
212 | ||
213 | char branchname[30]; | |
214 | TBranch * branch = 0x0; | |
215 | ||
216 | // Filling TreeR | |
217 | ||
218 | if ( TreeR() && cRC && cTC ) | |
219 | { | |
220 | TreeR()->Fill(); | |
221 | } | |
222 | else | |
223 | { | |
224 | if ( TreeR() && cRC ) | |
225 | { | |
226 | if ( IsTriggerBranchesInTree() ) | |
227 | { | |
228 | // Branch per branch filling | |
229 | for (int i=0; i<AliMUONConstants::NTrackingCh(); i++) | |
230 | { | |
231 | sprintf(branchname,"%sRawClusters%d",GetName(),i+1); | |
232 | branch = TreeR()->GetBranch(branchname); | |
233 | branch->Fill(); | |
234 | } | |
235 | } | |
236 | else | |
237 | { | |
238 | TreeR()->Fill(); | |
239 | } | |
240 | } | |
241 | ||
242 | if ( TreeR() && cTC) | |
243 | { | |
244 | if (IsRawClusterBranchesInTree()) | |
245 | { | |
246 | // Branch per branch filling | |
247 | sprintf(branchname,"%sLocalTrigger",GetName()); | |
248 | branch = TreeR()->GetBranch(branchname); | |
249 | branch->Fill(); | |
250 | sprintf(branchname,"%sRegionalTrigger",GetName()); | |
251 | branch = TreeR()->GetBranch(branchname); | |
252 | branch->Fill(); | |
253 | sprintf(branchname,"%sGlobalTrigger",GetName()); | |
254 | branch = TreeR()->GetBranch(branchname); | |
255 | branch->Fill(); | |
256 | } | |
257 | else | |
258 | { | |
259 | TreeR()->Fill(); | |
260 | } | |
261 | } | |
262 | } | |
263 | ||
264 | // Filling TreeT | |
265 | ||
266 | if ( TreeT() && cRT && cRL ) | |
267 | { | |
268 | TreeT()->Fill(); | |
269 | } | |
270 | else | |
271 | { | |
272 | if ( TreeT() && cRT ) | |
273 | { | |
274 | if (IsTriggerTrackBranchesInTree()) | |
275 | { | |
276 | sprintf(branchname,"%sTrack",GetName()); | |
277 | branch = TreeT()->GetBranch(branchname); | |
278 | branch->Fill(); | |
279 | } | |
280 | else | |
281 | { | |
282 | TreeT()->Fill(); | |
283 | } | |
284 | } | |
285 | ||
286 | if ( TreeT() && cRL ) | |
287 | { | |
288 | if (IsTrackBranchesInTree()) | |
289 | { | |
290 | sprintf(branchname,"%sTriggerTrack",GetName()); | |
291 | branch = TreeT()->GetBranch(branchname); | |
292 | branch->Fill(); | |
293 | } | |
294 | else | |
295 | { | |
296 | TreeT()->Fill(); | |
297 | } | |
298 | } | |
299 | } | |
300 | } | |
301 | ||
302 | //_____________________________________________________________________________ | |
303 | void AliMUONRecData::MakeOwnBranch(Option_t* option) | |
304 | { | |
305 | /// Create Tree branches for the MUON. | |
306 | ||
307 | const Int_t kBufferSize = 4000; | |
308 | char branchname[30]; | |
309 | ||
310 | //Setting Data Container | |
311 | SetDataContainer(option); | |
312 | ||
313 | const char *cRC = strstr(option,"RC"); // RawCluster branches in TreeR | |
314 | const char *cRT = strstr(option,"RT"); // Reconstructed Track in TreeT | |
315 | const char *cRL = strstr(option,"RL"); // Reconstructed Trigger Track in TreeT | |
316 | //const char *cRP = strstr(option,"RP"); // Reconstructed Particle in TreeP | |
317 | const char *cTC = strstr(option,"TC"); // global and local Trigger branches Copy in TreeR | |
318 | ||
319 | TBranch * branch = 0x0; | |
320 | ||
321 | if (TreeR() && cRC ) { | |
322 | // one branch for raw clusters per tracking detection plane | |
323 | // | |
324 | Int_t i; | |
325 | for (i=0; i<AliMUONConstants::NTrackingCh() ;i++) { | |
326 | sprintf(branchname,"%sRawClusters%d",GetName(),i+1); | |
327 | branch = 0x0; | |
328 | branch = TreeR()->GetBranch(branchname); | |
329 | if (branch) { | |
330 | AliInfo(Form("Branch %s is already in tree.",branchname)); | |
331 | return; | |
332 | } | |
333 | branch = TreeR()->Branch(branchname, &((*fRawClusters)[i]),kBufferSize); | |
334 | //Info("MakeBranch","Making Branch %s for rawcluster in detection plane %d\n",branchname,i+1); | |
335 | } | |
336 | } | |
337 | ||
338 | if (TreeR() && cTC ) { | |
339 | // | |
340 | // one branch for global trigger | |
341 | // | |
342 | sprintf(branchname,"%sGlobalTrigger",GetName()); | |
343 | branch = 0x0; | |
344 | branch = TreeR()->GetBranch(branchname); | |
345 | if (branch) { | |
346 | AliInfo(Form("Branch GlobalTrigger is already in treeR.")); | |
347 | return ; | |
348 | } | |
349 | branch = TreeR()->Branch(branchname, &fGlobalTrigger, kBufferSize); | |
350 | //Info("MakeBranch", "Making Branch %s for Global Trigger\n",branchname); | |
351 | ||
352 | // | |
353 | // one branch for regional trigger | |
354 | // | |
355 | sprintf(branchname,"%sRegionalTrigger",GetName()); | |
356 | branch = 0x0; | |
357 | branch = TreeR()->GetBranch(branchname); | |
358 | if (branch) { | |
359 | AliInfo(Form("Branch RegionalTrigger is already in treeR.")); | |
360 | return; | |
361 | } | |
362 | branch = TreeR()->Branch(branchname, &fRegionalTrigger, kBufferSize); | |
363 | ||
364 | // | |
365 | // one branch for local trigger | |
366 | // | |
367 | sprintf(branchname,"%sLocalTrigger",GetName()); | |
368 | branch = 0x0; | |
369 | branch = TreeR()->GetBranch(branchname); | |
370 | if (branch) { | |
371 | AliInfo(Form("Branch LocalTrigger is already in treeR.")); | |
372 | return; | |
373 | } | |
374 | branch = TreeR()->Branch(branchname, &fLocalTrigger, kBufferSize); | |
375 | //Info("MakeBranch", "Making Branch %s for Global Trigger\n",branchname); | |
376 | } | |
377 | ||
378 | if (TreeT() && cRT ) { | |
379 | sprintf(branchname,"%sTrack",GetName()); | |
380 | branch = TreeT()->GetBranch(branchname); | |
381 | if (branch) { | |
382 | AliInfo(Form("Branch %s is already in tree.",GetName())); | |
383 | return ; | |
384 | } | |
385 | branch = TreeT()->Branch(branchname,&fRecTracks,kBufferSize); | |
386 | //Info("MakeBranch","Making Branch %s for tracks \n",branchname); | |
387 | } | |
388 | // trigger tracks | |
389 | if (TreeT() && cRL ) { | |
390 | sprintf(branchname,"%sTriggerTrack",GetName()); | |
391 | branch = TreeT()->GetBranch(branchname); | |
392 | if (branch) { | |
393 | AliInfo(Form("Branch %s is already in tree.",GetName())); | |
394 | return ; | |
395 | } | |
396 | branch = TreeT()->Branch(branchname,&fRecTriggerTracks,kBufferSize); | |
397 | //Info("MakeBranch","Making Branch %s for trigger tracks \n",branchname); | |
398 | } | |
399 | } | |
400 | //____________________________________________________________________________ | |
401 | void AliMUONRecData::SetOwnDataContainer(Option_t* option) | |
402 | { | |
403 | /// Setting data containers of muon data | |
404 | ||
405 | const char *cRC = strstr(option,"RC"); // RawCluster | |
406 | const char *cRT = strstr(option,"RT"); // Reconstructed Tracks | |
407 | const char *cRL = strstr(option,"RL"); // Reconstructed Trigger Tracks | |
408 | //const char *cRP = strstr(option,"RP"); // Reconstructed Particles | |
409 | const char *cTC = strstr(option,"TC"); // global and local Trigger branches Copy in TreeR | |
410 | ||
411 | AliDebug(1,Form("option=%s",option)); | |
412 | ||
413 | // | |
414 | // Containers for rawclusters, globaltrigger and local trigger tree | |
415 | if (cRC ) { | |
416 | if (fRawClusters == 0x0) { | |
417 | fRawClusters = new TObjArray(AliMUONConstants::NTrackingCh()); | |
418 | fNrawclusters= new Int_t[AliMUONConstants::NTrackingCh()]; | |
419 | for (Int_t i=0; i<AliMUONConstants::NTrackingCh();i++) { | |
420 | TClonesArray* tca = new TClonesArray("AliMUONRawCluster",10000); | |
421 | tca->SetOwner(); | |
422 | fRawClusters->AddAt(tca,i); | |
423 | fNrawclusters[i]=0; | |
424 | } | |
425 | } | |
426 | // ResetRawClusters(); | |
427 | // It breaks the correct functioning of the combined reconstruction (AZ) | |
428 | ||
429 | } | |
430 | if (cTC ) { | |
431 | if (fLocalTrigger == 0x0) { | |
432 | fLocalTrigger = new TClonesArray("AliMUONLocalTrigger",234); | |
433 | } | |
434 | if (fRegionalTrigger == 0x0) { | |
435 | fRegionalTrigger = new TClonesArray("AliMUONRegionalTrigger",16); | |
436 | } | |
437 | if (fGlobalTrigger== 0x0) { | |
438 | fGlobalTrigger = new TClonesArray("AliMUONGlobalTrigger",1); | |
439 | } | |
440 | // ResetTrigger(); | |
441 | // This is not necessary here since trigger info ins copied from digits info on flight to RecPoint output | |
442 | } | |
443 | ||
444 | // | |
445 | // Containers for rectracks and rectrigger tracks | |
446 | if ( cRT ) { | |
447 | if (fRecTracks == 0x0) { | |
448 | fRecTracks = new TClonesArray("AliMUONTrack",100); | |
449 | } | |
450 | ResetRecTracks(); | |
451 | } | |
452 | if (cRL) { | |
453 | if (fRecTriggerTracks == 0x0 && cRL) { | |
454 | fRecTriggerTracks = new TClonesArray("AliMUONTriggerTrack",100); | |
455 | } | |
456 | ResetRecTriggerTracks(); | |
457 | } | |
458 | } | |
459 | ||
460 | //____________________________________________________________________________ | |
461 | void AliMUONRecData::SetOwnTreeAddress(Option_t* option) | |
462 | { | |
463 | // Setting Data containers | |
464 | SetOwnDataContainer(option); | |
465 | ||
466 | /// Setting Addresses to the events trees | |
467 | ||
468 | const char *cRC = strstr(option,"RC"); // RawCluster branches in TreeR | |
469 | const char *cRT = strstr(option,"RT"); // Reconstructed Track in TreeT | |
470 | const char *cRL = strstr(option,"RL"); // Reconstructed Trigger Track in TreeT | |
471 | //const char *cRP = strstr(option,"RP"); // Reconstructed Particle in TreeP | |
472 | const char *cTC = strstr(option,"TC"); // global and local Trigger branches Copy in TreeR | |
473 | ||
474 | // Set branch address for the Hits, Digits, RawClusters, GlobalTrigger and LocalTrigger Tree. | |
475 | char branchname[30]; | |
476 | TBranch * branch = 0x0; | |
477 | ||
478 | AliDebug(1,Form("option=%s",option)); | |
479 | ||
480 | // | |
481 | // Branch address for rawclusters, globaltrigger and local trigger tree | |
482 | if ( TreeR() && fRawClusters && cRC && !strstr(cRC,"RCC")) { | |
483 | for (int i=0; i<AliMUONConstants::NTrackingCh(); i++) { | |
484 | sprintf(branchname,"%sRawClusters%d",GetName(),i+1); | |
485 | if (fRawClusters) { | |
486 | branch = TreeR()->GetBranch(branchname); | |
487 | if (branch) branch->SetAddress( &((*fRawClusters)[i]) ); | |
488 | else AliWarning(Form("(%s) Failed for RawClusters Detection plane %d. Can not find branch in tree.",GetName(),i)); | |
489 | } | |
490 | } | |
491 | } | |
492 | if ( TreeR() && fLocalTrigger && cTC) { | |
493 | sprintf(branchname,"%sLocalTrigger",GetName()); | |
494 | branch = TreeR()->GetBranch(branchname); | |
495 | if (branch) branch->SetAddress(&fLocalTrigger); | |
496 | else AliWarning(Form("(%s) Failed for LocalTrigger. Can not find branch in treeR.",GetName())); | |
497 | } | |
498 | if ( TreeR() && fRegionalTrigger && cTC) { | |
499 | sprintf(branchname,"%sRegionalTrigger",GetName()); | |
500 | branch = TreeR()->GetBranch(branchname); | |
501 | if (branch) branch->SetAddress(&fRegionalTrigger); | |
502 | else AliWarning(Form("(%s) Failed for RegionalTrigger. Can not find branch in treeR.",GetName())); | |
503 | } | |
504 | if ( TreeR() && fGlobalTrigger && cTC) { | |
505 | sprintf(branchname,"%sGlobalTrigger",GetName()); | |
506 | branch = TreeR()->GetBranch(branchname); | |
507 | if (branch) branch->SetAddress(&fGlobalTrigger); | |
508 | else AliWarning(Form("(%s) Failed for GlobalTrigger. Can not find branch in treeR.",GetName())); | |
509 | } | |
510 | ||
511 | // Rec Trakcs | |
512 | if ( TreeT() && fRecTracks && cRT ) { | |
513 | sprintf(branchname,"%sTrack",GetName()); | |
514 | branch = TreeT()->GetBranch(branchname); | |
515 | if (branch) branch->SetAddress(&fRecTracks); | |
516 | else AliWarning(Form("(%s) Failed for Tracks. Can not find branch in tree.",GetName())); | |
517 | } | |
518 | // Trigger tracks | |
519 | if ( TreeT() && fRecTriggerTracks && cRL ) { | |
520 | sprintf(branchname,"%sTriggerTrack",GetName()); | |
521 | branch = TreeT()->GetBranch(branchname); | |
522 | if (branch) branch->SetAddress(&fRecTriggerTracks); | |
523 | else AliWarning(Form("(%s) Failed for Trigger Tracks. Can not find branch in tree.",GetName())); | |
524 | } | |
525 | } | |
526 | ||
527 | //____________________________________________________________________________ | |
528 | void AliMUONRecData::Fill(Option_t* option) | |
529 | { | |
530 | /// Method to fill the trees | |
531 | ||
532 | AliMUONData::Fill(option); | |
533 | FillOwn(option); | |
534 | } | |
535 | ||
536 | //_____________________________________________________________________________ | |
537 | void AliMUONRecData::MakeBranch(Option_t* option) | |
538 | { | |
539 | /// Create Tree branches for the MUON. | |
540 | ||
541 | AliMUONData::MakeBranch(option); | |
542 | MakeOwnBranch(option); | |
543 | } | |
544 | ||
545 | //____________________________________________________________________________ | |
546 | void AliMUONRecData::SetDataContainer(Option_t* option) | |
547 | { | |
548 | /// Setting data containers of muon data | |
549 | AliMUONData::SetDataContainer(option); | |
550 | SetOwnDataContainer(option); | |
551 | } | |
552 | ||
553 | //____________________________________________________________________________ | |
554 | void AliMUONRecData::SetTreeAddress(Option_t* option) | |
555 | { | |
07547aa3 | 556 | /// Setting Addresses to the events trees |
557 | ||
990f8c6b | 558 | AliMUONData::SetTreeAddress(option); |
559 | SetOwnTreeAddress(option); | |
560 | } | |
561 | ||
562 | //____________________________________________________________________________ | |
563 | TClonesArray* AliMUONRecData::RawClusters(Int_t DetectionPlane) | |
564 | { | |
565 | /// Getting Raw Clusters | |
566 | ||
567 | if (fRawClusters) | |
568 | return ( (TClonesArray*) fRawClusters->At(DetectionPlane) ); | |
569 | else | |
570 | return NULL; | |
571 | } | |
572 | ||
573 | //_______________________________________________________________________________ | |
574 | void AliMUONRecData::ResetRawClusters() | |
575 | { | |
576 | /// Reset number of raw clusters and the raw clust array for this detector | |
577 | ||
578 | for ( int i=0;i<AliMUONConstants::NTrackingCh();i++ ) { | |
579 | if ((*fRawClusters)[i]) ((TClonesArray*)fRawClusters->At(i))->Clear(); | |
580 | if (fNrawclusters) fNrawclusters[i]=0; | |
581 | } | |
582 | } | |
583 | ||
584 | //____________________________________________________________________________ | |
585 | void AliMUONRecData::ResetRecTracks() | |
586 | { | |
587 | /// Reset tracks information | |
588 | ||
589 | fNrectracks = 0; | |
590 | if (fRecTracks) fRecTracks->Delete(); // necessary to delete in case of memory allocation | |
591 | } | |
592 | ||
593 | //____________________________________________________________________________ | |
594 | void AliMUONRecData::ResetRecTriggerTracks() | |
595 | { | |
596 | /// Reset tracks information | |
597 | ||
598 | fNrectriggertracks = 0; | |
599 | if (fRecTriggerTracks) fRecTriggerTracks->Delete(); // necessary to delete in case of memory allocation | |
600 | } | |
601 | ||
602 | //_____________________________________________________________________________ | |
603 | void | |
604 | AliMUONRecData::DumpRecPoints(Int_t event2Check, Option_t* opt) | |
605 | { | |
606 | /// Dump rec points | |
607 | ||
608 | fLoader->LoadRecPoints("READ"); | |
609 | ||
610 | // Event loop | |
611 | Int_t nevents = fRunLoader->GetNumberOfEvents(); | |
612 | for (Int_t ievent=0; ievent<nevents; ievent++) { | |
613 | if (event2Check!=0) ievent=event2Check; | |
614 | printf(">>> Event %d \n",ievent); | |
615 | ||
616 | // Getting event ievent | |
617 | fRunLoader->GetEvent(ievent); | |
618 | Int_t nchambers = AliMUONConstants::NTrackingCh(); | |
619 | SetTreeAddress("RC,TC"); | |
620 | GetRawClusters(); | |
621 | ||
622 | // Loop on chambers | |
623 | for (Int_t ichamber=0; ichamber<nchambers; ichamber++) { | |
624 | char branchname[30]; | |
625 | sprintf(branchname,"MUONRawClusters%d",ichamber+1); | |
626 | //printf(">>> branchname %s\n",branchname); | |
627 | ||
628 | // Loop on rec points | |
629 | Int_t nrecpoints = (Int_t) RawClusters(ichamber)->GetEntriesFast(); | |
630 | // printf(">>> Chamber %2d, Number of recpoints = %6d \n",ichamber+1, nrecpoints); | |
631 | for (Int_t irecpoint=0; irecpoint<nrecpoints; irecpoint++) { | |
632 | AliMUONRawCluster* mRecPoint = static_cast<AliMUONRawCluster*>(RawClusters(ichamber)->At(irecpoint)); | |
633 | mRecPoint->Print(opt); | |
634 | } | |
635 | } | |
636 | ResetRawClusters(); | |
637 | if (event2Check!=0) ievent=nevents; | |
638 | } | |
639 | fLoader->UnloadRecPoints(); | |
640 | } | |
641 | ||
c6461770 | 642 | //_____________________________________________________________________________ |
643 | void | |
644 | AliMUONRecData::DumpTracks(Int_t event2Check, Option_t* opt) | |
645 | { | |
646 | /// Dump tracks | |
647 | ||
648 | fLoader->LoadTracks("READ"); | |
649 | ||
650 | // Event loop | |
651 | Int_t nevents = fRunLoader->GetNumberOfEvents(); | |
652 | ||
653 | for (Int_t ievent=0; ievent<nevents; ievent++) | |
654 | { | |
655 | if (event2Check!=0) ievent=event2Check; | |
656 | ||
657 | printf(">>> Event %d \n",ievent); | |
658 | ||
659 | // Getting event ievent | |
660 | fRunLoader->GetEvent(ievent); | |
661 | ||
c6461770 | 662 | SetTreeAddress("RT"); |
663 | GetRecTracks(); | |
664 | ||
0164b17a | 665 | // Loop on tracks |
666 | TClonesArray* tracks = RecTracks(); | |
667 | Int_t ntracks = (Int_t) tracks->GetEntriesFast(); | |
c6461770 | 668 | |
0164b17a | 669 | for (Int_t i=0; i<ntracks; ++i) |
670 | { | |
671 | AliMUONTrack* mTrack = static_cast<AliMUONTrack*>(tracks->At(i)); | |
672 | mTrack->Print(opt); | |
c6461770 | 673 | } |
674 | ResetRecTracks(); | |
675 | if (event2Check!=0) ievent=nevents; | |
676 | } | |
677 | fLoader->UnloadTracks(); | |
678 | } | |
990f8c6b | 679 | |
680 | //_____________________________________________________________________________ | |
681 | void | |
682 | AliMUONRecData::DumpRecTrigger(Int_t event2Check, | |
683 | Int_t write, Bool_t readFromRP) | |
684 | { | |
685 | /// Reads and dumps trigger objects from MUON.RecPoints.root | |
686 | ||
687 | TClonesArray * globalTrigger; | |
688 | TClonesArray * localTrigger; | |
689 | ||
690 | // Do NOT print out all the info if the loop runs over all events | |
691 | Int_t printout = (event2Check == 0 ) ? 0 : 1 ; | |
692 | ||
693 | // Book a ntuple for more detailled studies | |
694 | TNtuple *tupleGlo = new TNtuple("TgtupleGlo","Global Trigger Ntuple","ev:global:slpt:shpt:uplpt:uphpt:lplpt:lplpt"); | |
695 | TNtuple *tupleLoc = new TNtuple("TgtupleLoc","Local Trigger Ntuple","ev:LoCircuit:LoStripX:LoDev:StripY:LoLpt:LoHpt:y11:y21:x11"); | |
696 | ||
697 | // counters | |
698 | Int_t sLowpt=0,sHighpt=0; | |
699 | Int_t uSLowpt=0,uSHighpt=0; | |
700 | Int_t lSLowpt=0,lSHighpt=0; | |
701 | ||
702 | AliMUONTriggerCrateStore* crateManager = new AliMUONTriggerCrateStore(); | |
703 | crateManager->ReadFromFile(); | |
704 | ||
705 | AliMUONGeometryTransformer* transformer = new AliMUONGeometryTransformer(kFALSE); | |
706 | transformer->ReadGeometryData("volpath.dat", "geometry.root"); | |
707 | ||
708 | TClonesArray* triggerCircuit = new TClonesArray("AliMUONTriggerCircuit", 234); | |
709 | ||
710 | for (Int_t i = 0; i < AliMUONConstants::NTriggerCircuit(); i++) { | |
711 | AliMUONTriggerCircuit* c = new AliMUONTriggerCircuit(); | |
712 | c->SetTransformer(transformer); | |
713 | c->Init(i,*crateManager); | |
714 | TClonesArray& circuit = *triggerCircuit; | |
715 | new(circuit[circuit.GetEntriesFast()])AliMUONTriggerCircuit(*c); | |
716 | delete c; | |
717 | } | |
718 | ||
719 | Char_t fileName[30]; | |
720 | if (!readFromRP) { | |
721 | AliInfoStream() << " reading from digits \n"; | |
722 | fLoader->LoadDigits("READ"); | |
723 | sprintf(fileName,"TriggerCheckFromDigits.root"); | |
724 | } else { | |
725 | AliInfoStream() << " reading from RecPoints \n"; | |
726 | fLoader->LoadRecPoints("READ"); | |
727 | sprintf(fileName,"TriggerCheckFromRP.root"); | |
728 | } | |
729 | ||
730 | ||
731 | AliMUONGlobalTrigger *gloTrg(0x0); | |
732 | AliMUONLocalTrigger *locTrg(0x0); | |
733 | ||
734 | Int_t nevents = fRunLoader->GetNumberOfEvents(); | |
735 | for (Int_t ievent=0; ievent<nevents; ievent++) { | |
736 | if (event2Check!=0) ievent=event2Check; | |
737 | if (ievent%100==0 || event2Check) | |
738 | AliInfoStream() << "Processing event " << ievent << endl; | |
739 | fRunLoader->GetEvent(ievent); | |
740 | ||
741 | if (!readFromRP) { | |
742 | SetTreeAddress("D,GLT"); | |
743 | GetTriggerD(); | |
744 | } else { | |
745 | SetTreeAddress("RC,TC"); | |
746 | GetTrigger(); | |
747 | } | |
748 | ||
749 | globalTrigger = GlobalTrigger(); | |
750 | localTrigger = LocalTrigger(); | |
751 | ||
752 | Int_t nglobals = (Int_t) globalTrigger->GetEntriesFast(); // should be 1 | |
753 | Int_t nlocals = (Int_t) localTrigger->GetEntriesFast(); // up to 234 | |
754 | if (printout) printf("###################################################\n"); | |
755 | if (printout) printf("event %d nglobal %d nlocal %d \n",ievent,nglobals,nlocals); | |
756 | ||
757 | for (Int_t iglobal=0; iglobal<nglobals; iglobal++) { // Global Trigger | |
758 | gloTrg = static_cast<AliMUONGlobalTrigger*>(globalTrigger->At(iglobal)); | |
759 | ||
760 | sLowpt+=gloTrg->SingleLpt() ; | |
761 | sHighpt+=gloTrg->SingleHpt() ; | |
762 | uSLowpt+=gloTrg->PairUnlikeLpt(); | |
763 | uSHighpt+=gloTrg->PairUnlikeHpt(); | |
764 | lSLowpt+=gloTrg->PairLikeLpt(); | |
765 | lSHighpt+=gloTrg->PairLikeHpt(); | |
766 | ||
767 | if (printout) gloTrg->Print("full"); | |
768 | ||
769 | } // end of loop on Global Trigger | |
770 | ||
771 | for (Int_t ilocal=0; ilocal<nlocals; ilocal++) { // Local Trigger | |
772 | locTrg = static_cast<AliMUONLocalTrigger*>(localTrigger->At(ilocal)); | |
773 | ||
774 | Bool_t xTrig=kFALSE; | |
775 | Bool_t yTrig=kFALSE; | |
776 | ||
777 | if ( locTrg->LoSdev()==1 && locTrg->LoDev()==0 && | |
778 | locTrg->LoStripX()==0) xTrig=kFALSE; // no trigger in X | |
779 | else xTrig=kTRUE; // trigger in X | |
780 | if (locTrg->LoTrigY()==1 && | |
781 | locTrg->LoStripY()==15 ) yTrig = kFALSE; // no trigger in Y | |
782 | else yTrig = kTRUE; // trigger in Y | |
783 | ||
784 | if (xTrig && yTrig) { // make Trigger Track if trigger in X and Y | |
785 | ||
786 | if (printout) locTrg->Print("full"); | |
787 | ||
788 | AliMUONTriggerCircuit* circuit = (AliMUONTriggerCircuit*)triggerCircuit->At(locTrg->LoCircuit()-1); | |
789 | ||
790 | tupleLoc->Fill(ievent,locTrg->LoCircuit(),locTrg->LoStripX(),locTrg->LoDev(),locTrg->LoStripY(),locTrg->LoLpt(),locTrg->LoHpt(),circuit->GetY11Pos(locTrg->LoStripX()),circuit->GetY21Pos(locTrg->LoStripX()+locTrg->LoDev()+1),circuit->GetX11Pos(locTrg->LoStripY())); | |
791 | } | |
792 | ||
793 | } // end of loop on Local Trigger | |
794 | ||
795 | // fill ntuple | |
796 | tupleGlo->Fill(ievent,nglobals,gloTrg->SingleLpt(),gloTrg->SingleHpt(),gloTrg->PairUnlikeLpt(),gloTrg->PairUnlikeHpt(),gloTrg->PairLikeLpt(),gloTrg->PairLikeHpt()); | |
797 | ||
798 | ResetTrigger(); | |
799 | if (event2Check!=0) ievent=nevents; | |
800 | } // end loop on event | |
801 | ||
802 | // Print out summary if loop ran over all event | |
803 | if (!event2Check){ | |
804 | ||
805 | printf("\n"); | |
806 | printf("=============================================\n"); | |
807 | printf("================ SUMMARY ==================\n"); | |
808 | printf("\n"); | |
809 | printf("Total number of events processed %d \n", (event2Check==0) ? nevents : 1); | |
810 | printf("\n"); | |
811 | printf(" Global Trigger output Low pt High pt\n"); | |
812 | printf(" number of Single :\t"); | |
813 | printf("%i\t%i\t",sLowpt,sHighpt); | |
814 | printf("\n"); | |
815 | printf(" number of UnlikeSign pair :\t"); | |
816 | printf("%i\t%i\t",uSLowpt,uSHighpt); | |
817 | printf("\n"); | |
818 | printf(" number of LikeSign pair :\t"); | |
819 | printf("%i\t%i\t",lSLowpt,lSHighpt); | |
820 | printf("\n"); | |
821 | printf("=============================================\n"); | |
822 | fflush(stdout); | |
823 | } | |
824 | ||
825 | if (write){ | |
826 | TFile *myFile = new TFile(fileName, "RECREATE"); | |
827 | tupleGlo->Write(); | |
828 | tupleLoc->Write(); | |
829 | myFile->Close(); | |
830 | } | |
831 | ||
832 | fLoader->UnloadRecPoints(); | |
833 | ||
834 | delete crateManager; | |
835 | delete transformer; | |
836 | delete triggerCircuit; | |
837 | ||
838 | } |