]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUON.cxx
Pointers initialised to 0 in the default constructors
[u/mrichter/AliRoot.git] / MUON / AliMUON.cxx
CommitLineData
4c039060 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 **************************************************************************/
4c039060 15/*
16$Log$
edf34242 17Revision 1.54 2001/08/30 09:52:12 hristov
18The operator[] is replaced by At() or AddAt() in case of TObjArray.
19
2682e810 20Revision 1.53 2001/07/20 10:03:13 morsch
21Changes needed to work with Root 3.01 (substitute lhs [] operator). (Jiri Chudoba)
22
cd4df77b 23Revision 1.52 2001/06/14 13:49:22 hristov
24Write a TreeD in SDigits2Digits method (needed to be compatible with alirun script)
25
d963c261 26Revision 1.51 2001/05/31 10:19:52 morsch
27Fix for new AliRun::RunReco().
28
e365e1ee 29Revision 1.50 2001/05/16 14:57:17 alibrary
30New files for folders and Stack
31
9e1a0ddb 32Revision 1.49 2001/03/12 17:45:48 hristov
33Changes needed on Sun with CC 5.0
34
5cf7bbad 35Revision 1.48 2001/03/06 00:01:36 morsch
36Add Digits2Reco() and FindClusters()
37Adapt call of cluster finder to new STEER.
38
fe311ef1 39Revision 1.47 2001/03/05 08:38:36 morsch
40Digitization related methods moved to AliMUONMerger.
41
1cae9436 42Revision 1.46 2001/01/26 21:34:59 morsch
43Use access functions for AliMUONHit, AliMUONDigit and AliMUONPadHit data members.
44
1bd28025 45Revision 1.45 2001/01/26 20:00:49 hristov
46Major upgrade of AliRoot code
47
2ab0c725 48Revision 1.44 2001/01/25 17:39:09 morsch
49Pass size of fNdch and fNrawch to CINT.
50
1bd26093 51Revision 1.43 2001/01/23 18:58:19 hristov
52Initialisation of some pointers
53
3f5cf0b3 54Revision 1.42 2001/01/17 20:53:40 hristov
55Destructors corrected to avoid memory leaks
56
c2c0190f 57Revision 1.41 2000/12/21 22:12:40 morsch
58Clean-up of coding rule violations,
59
de05461e 60Revision 1.40 2000/11/29 20:32:26 gosset
61Digitize:
621. correction for array index out of bounds
632. one printout commented
64
48030acd 65Revision 1.39 2000/11/12 17:17:03 pcrochet
66BuildGeometry of AliMUON for trigger chambers delegated to AliMUONSegmentationTriggerX (same strategy as for tracking chambers)
67
5fd73042 68Revision 1.38 2000/11/06 09:20:43 morsch
69AliMUON delegates part of BuildGeometry() to AliMUONSegmentation using the
70Draw() method. This avoids code and parameter replication.
71
aaf4addd 72Revision 1.37 2000/10/26 09:53:37 pcrochet
73put back trigger chambers in the display (there was a problem in buildgeometry)
74
43b96d92 75Revision 1.36 2000/10/25 19:51:18 morsch
76Correct x-position of chambers.
77
6bc66d8f 78Revision 1.35 2000/10/24 19:46:21 morsch
79BuildGeometry updated for slats in station 3-4.
80
e4fa3d7e 81Revision 1.34 2000/10/18 11:42:06 morsch
82- AliMUONRawCluster contains z-position.
83- Some clean-up of useless print statements during initialisations.
84
3e1872ed 85Revision 1.33 2000/10/09 14:01:57 morsch
86Unused variables removed.
87
0234695f 88Revision 1.32 2000/10/06 09:08:10 morsch
89Built geometry includes slat geometry for event display.
90
7ab910ae 91Revision 1.31 2000/10/02 21:28:08 fca
92Removal of useless dependecies via forward declarations
93
94de3818 94Revision 1.30 2000/10/02 16:58:29 egangler
95Cleaning of the code :
96-> coding conventions
97-> void Streamers
98-> some useless includes removed or replaced by "class" statement
99
ecfa008b 100Revision 1.29 2000/07/28 13:49:38 morsch
101SetAcceptance defines inner and outer chamber radii according to angular acceptance.
102Can be used for simple acceptance studies.
103
5c1f55c5 104Revision 1.28 2000/07/22 16:43:15 morsch
105Same comment as before, but now done correctly I hope (sorry it's Saturday evening)
106
45085cb9 107Revision 1.27 2000/07/22 16:36:50 morsch
108Change order of indices in creation (new) of xhit and yhit
109
6b18d06a 110Revision 1.26 2000/07/03 11:54:57 morsch
111AliMUONSegmentation and AliMUONHitMap have been replaced by AliSegmentation and AliHitMap in STEER
112The methods GetPadIxy and GetPadXxy of AliMUONSegmentation have changed name to GetPadI and GetPadC.
113
a30a000f 114Revision 1.25 2000/06/29 12:34:09 morsch
115AliMUONSegmentation class has been made independent of AliMUONChamber. This makes
116it usable with any other geometry class. The link to the object to which it belongs is
117established via an index. This assumes that there exists a global geometry manager
118from which the pointer to the parent object can be obtained (in our case gAlice).
119
d81db581 120Revision 1.24 2000/06/28 15:16:35 morsch
121(1) Client code adapted to new method signatures in AliMUONSegmentation (see comments there)
122to allow development of slat-muon chamber simulation and reconstruction code in the MUON
123framework. The changes should have no side effects (mostly dummy arguments).
124(2) Hit disintegration uses 3-dim hit coordinates to allow simulation
125of chambers with overlapping modules (MakePadHits, Disintegration).
126
802a864d 127Revision 1.23 2000/06/28 12:19:17 morsch
128More consequent seperation of global input data services (AliMUONClusterInput singleton) and the
fe311ef1 129cluster and hit reconstruction algorithms in AliMUONClusterFindRawinderVS.
802a864d 130AliMUONClusterFinderVS becomes the base class for clustering and hit reconstruction.
131It requires two cathode planes. Small modifications in the code will make it usable for
132one cathode plane and, hence, more general (for test beam data).
133AliMUONClusterFinder is now obsolete.
134
30aaba74 135Revision 1.22 2000/06/28 08:06:10 morsch
136Avoid global variables in AliMUONClusterFinderVS by seperating the input data for the fit from the
137algorithmic part of the class. Input data resides inside the AliMUONClusterInput singleton.
138It also naturally takes care of the TMinuit instance.
139
9825400f 140Revision 1.21 2000/06/27 08:54:41 morsch
141Problems with on constant array sizes (in hitMap, nmuon, xhit, yhit) corrected.
142
d09fafb0 143Revision 1.20 2000/06/26 14:02:38 morsch
144Add class AliMUONConstants with MUON specific constants using static memeber data and access methods.
145
f665c1ea 146Revision 1.19 2000/06/22 13:40:51 morsch
147scope problem on HP, "i" declared once
148pow changed to TMath::Power (PH, AM)
149
9ae15266 150Revision 1.18 2000/06/15 07:58:48 morsch
151Code from MUON-dev joined
152
a9e2aefa 153Revision 1.14.4.17 2000/06/14 14:36:46 morsch
154- add TriggerCircuit (PC)
155- add GlobalTrigger and LocalTrigger and specific methods (PC)
156
157Revision 1.14.4.16 2000/06/09 21:20:28 morsch
158Most coding rule violations corrected
159
160Revision 1.14.4.15 2000/05/02 09:54:32 morsch
161RULE RN17 violations corrected
162
163Revision 1.14.4.12 2000/04/26 12:25:02 morsch
164Code revised by P. Crochet:
165- Z position of TriggerChamber changed according to A.Tournaire Priv.Comm.
166- ToF included in the method MakePadHits
167- inner radius of flange between beam shielding and trigger corrected
168- Trigger global volume updated (according to the new geometry)
169
170Revision 1.14.4.11 2000/04/19 19:42:08 morsch
171Some changes of variable names curing viols and methods concerning
172correlated clusters removed.
173
174Revision 1.14.4.10 2000/03/22 16:44:07 gosset
175Memory leak suppressed in function Digitise:
176p_adr->Delete() instead of Clear (I.Chevrot and A.Baldisseri)
177
178Revision 1.14.4.9 2000/03/20 18:15:25 morsch
179Positions of trigger chambers corrected (P.C.)
dbe37a89 180
a9e2aefa 181Revision 1.14.4.8 2000/02/21 15:38:01 morsch
182Call to AddHitList introduced to make this version compatible with head.
dffd31ef 183
a9e2aefa 184Revision 1.14.4.7 2000/02/20 07:45:53 morsch
185Bugs in Trigger part of BuildGeomemetry corrected (P.C)
1cedd08a 186
a9e2aefa 187Revision 1.14.4.6 2000/02/17 14:28:54 morsch
188Trigger included into initialization and digitization
6a935c13 189
a9e2aefa 190Revision 1.14.4.5 2000/02/15 10:02:58 morsch
191Log messages of previous revisions added
5d84196c 192
a9e2aefa 193Revision 1.14.4.2 2000/02/04 10:57:34 gosset
194Z position of the chambers:
195it was the Z position of the stations;
196it is now really the Z position of the chambers.
197 !!!! WARNING: THE CALLS TO "AliMUONChamber::SetZPOS"
198 !!!! AND "AliMUONChamber::ZPosition"
199 !!!! HAVE TO BE CHANGED TO "AliMUONChamber::"SetZ"
200 !!!! AND "AliMUONChamber::Z"
50f986db 201
a9e2aefa 202Revision 1.14.4.3 2000/02/04 16:19:04 gosset
203Correction for mis-spelling of NCH
0b34885d 204
a9e2aefa 205Revision 1.14.4.4 2000/02/15 09:43:38 morsch
206Log message added
2b86633d 207
4c039060 208*/
209
a9e2aefa 210
211///////////////////////////////////////////////
fe4da5cc 212// Manager and hits classes for set:MUON //
213////////////////////////////////////////////////
214
215#include <TTUBE.h>
a897a37a 216#include <TBRIK.h>
217#include <TRotMatrix.h>
94de3818 218#include <TGeometry.h>
fe4da5cc 219#include <TNode.h>
a897a37a 220#include <TTree.h>
fe4da5cc 221#include <TRandom.h>
222#include <TObject.h>
223#include <TVector.h>
224#include <TObjArray.h>
a897a37a 225#include <TMinuit.h>
226#include <TParticle.h>
227#include <TROOT.h>
228#include <TFile.h>
229#include <TNtuple.h>
230#include <TCanvas.h>
231#include <TPad.h>
232#include <TDirectory.h>
233#include <TObjectTable.h>
234#include <AliPDG.h>
a9e2aefa 235#include <TTUBE.h>
fe4da5cc 236
237#include "AliMUON.h"
a9e2aefa 238#include "AliMUONHit.h"
239#include "AliMUONPadHit.h"
240#include "AliMUONDigit.h"
241#include "AliMUONTransientDigit.h"
242#include "AliMUONRawCluster.h"
243#include "AliMUONLocalTrigger.h"
244#include "AliMUONGlobalTrigger.h"
ecfa008b 245#include "AliMUONTriggerCircuit.h"
a30a000f 246#include "AliHitMap.h"
a9e2aefa 247#include "AliMUONHitMapA1.h"
248#include "AliMUONChamberTrigger.h"
f665c1ea 249#include "AliMUONConstants.h"
30aaba74 250#include "AliMUONClusterFinderVS.h"
a9e2aefa 251#include "AliMUONTriggerDecision.h"
fe4da5cc 252#include "AliRun.h"
e365e1ee 253#include "AliHeader.h"
fe4da5cc 254#include "AliMC.h"
9825400f 255#include "AliMUONClusterInput.h"
1cae9436 256#include "AliMUONMerger.h"
fe4da5cc 257#include "iostream.h"
258#include "AliCallf77.h"
a9e2aefa 259#include "AliConst.h"
260
261// Defaults parameters for Z positions of chambers
262// taken from values for "stations" in AliMUON::AliMUON
263// const Float_t zch[7]={528, 690., 975., 1249., 1449., 1610, 1710.};
264// and from array "dstation" in AliMUONv1::CreateGeometry
265// Float_t dstation[5]={20., 20., 20, 20., 20.};
266// for tracking chambers,
267// according to (Z1 = zch - dstation) and (Z2 = zch + dstation)
268// for the first and second chambers in the station, respectively,
269// and from "DTPLANES" in AliMUONv1::CreateGeometry
270// const Float_t DTPLANES = 15.;
271// for trigger chambers,
272// according to (Z1 = zch) and (Z2 = zch + DTPLANES)
273// for the first and second chambers in the station, respectively
fe4da5cc 274
fe4da5cc 275ClassImp(AliMUON)
fe4da5cc 276//___________________________________________
277AliMUON::AliMUON()
278{
de05461e 279// Default Constructor
280//
1bd28025 281 fNCh = 0;
282 fNTrackingCh = 0;
1bd26093 283 fIshunt = 0;
284 fHits = 0;
285 fPadHits = 0;
286 fNPadHits = 0;
1bd28025 287 fChambers = 0;
1bd26093 288 fDchambers = 0;
1bd28025 289 fTriggerCircuits = 0;
1bd26093 290 fNdch = 0;
291 fRawClusters = 0;
292 fNrawch = 0;
293 fGlobalTrigger = 0;
294 fNLocalTrigger = 0;
295 fLocalTrigger = 0;
296 fNLocalTrigger = 0;
297 fAccMin = 0.;
298 fAccMax = 0.;
299 fAccCut = kFALSE;
1cae9436 300 fMerger = 0;
edf34242 301 fFileName = 0;
302 fTrH1 = 0;
303 fHits2 = 0;
304 fPadHits2 = 0;
fe4da5cc 305}
306
307//___________________________________________
308AliMUON::AliMUON(const char *name, const char *title)
309 : AliDetector(name,title)
310{
311//Begin_Html
312/*
a897a37a 313<img src="gif/alimuon.gif">
fe4da5cc 314*/
315//End_Html
f665c1ea 316
a9e2aefa 317 fHits = new TClonesArray("AliMUONHit",1000);
1cedd08a 318 gAlice->AddHitList(fHits);
a9e2aefa 319 fPadHits = new TClonesArray("AliMUONPadHit",10000);
320 fNPadHits = 0;
fe4da5cc 321 fIshunt = 0;
322
1bd28025 323 fNCh = AliMUONConstants::NCh();
1bd26093 324 fNTrackingCh = AliMUONConstants::NTrackingCh();
1bd28025 325 fNdch = new Int_t[fNCh];
fe4da5cc 326
f665c1ea 327 fDchambers = new TObjArray(AliMUONConstants::NCh());
fe4da5cc 328
329 Int_t i;
330
f665c1ea 331 for (i=0; i<AliMUONConstants::NCh() ;i++) {
cd4df77b 332 fDchambers->AddAt(new TClonesArray("AliMUONDigit",10000),i);
fe4da5cc 333 fNdch[i]=0;
334 }
335
1bd28025 336 fNrawch = new Int_t[fNTrackingCh];
a897a37a 337
f665c1ea 338 fRawClusters = new TObjArray(AliMUONConstants::NTrackingCh());
a897a37a 339
f665c1ea 340 for (i=0; i<AliMUONConstants::NTrackingCh();i++) {
cd4df77b 341 fRawClusters->AddAt(new TClonesArray("AliMUONRawCluster",10000),i);
a897a37a 342 fNrawch[i]=0;
343 }
344
a9e2aefa 345 fGlobalTrigger = new TClonesArray("AliMUONGlobalTrigger",1);
346 fNGlobalTrigger = 0;
347 fLocalTrigger = new TClonesArray("AliMUONLocalTrigger",234);
348 fNLocalTrigger = 0;
fe4da5cc 349
fe4da5cc 350 SetMarkerColor(kRed);
a9e2aefa 351//
352//
353//
354//
f665c1ea 355
a9e2aefa 356 Int_t ch;
357
f665c1ea 358 fChambers = new TObjArray(AliMUONConstants::NCh());
a9e2aefa 359
360 // Loop over stations
f665c1ea 361 for (Int_t st = 0; st < AliMUONConstants::NCh() / 2; st++) {
a9e2aefa 362 // Loop over 2 chambers in the station
363 for (Int_t stCH = 0; stCH < 2; stCH++) {
364//
365//
366// Default Parameters for Muon Tracking Stations
367
368
369 ch = 2 * st + stCH;
370//
f665c1ea 371 if (ch < AliMUONConstants::NTrackingCh()) {
cd4df77b 372 fChambers->AddAt(new AliMUONChamber(ch),ch);
a9e2aefa 373 } else {
cd4df77b 374 fChambers->AddAt(new AliMUONChamberTrigger(ch),ch);
a9e2aefa 375 }
376
2682e810 377 //PH AliMUONChamber* chamber = (AliMUONChamber*) (*fChambers)[ch];
378 AliMUONChamber* chamber = (AliMUONChamber*) fChambers->At(ch);
a9e2aefa 379
380 chamber->SetGid(0);
381 // Default values for Z of chambers
f665c1ea 382 chamber->SetZ(AliMUONConstants::DefaultChamberZ(ch));
a9e2aefa 383//
f665c1ea 384 chamber->InitGeo(AliMUONConstants::DefaultChamberZ(ch));
5c1f55c5 385// Set chamber inner and outer radius to default
f665c1ea 386 chamber->SetRInner(AliMUONConstants::Dmin(st)/2);
387 chamber->SetROuter(AliMUONConstants::Dmax(st)/2);
a9e2aefa 388//
389 } // Chamber stCH (0, 1) in
390 } // Station st (0...)
cd4df77b 391// fChambers->SetLast(AliMUONConstants::NCh());
a9e2aefa 392 fMaxStepGas=0.01;
393 fMaxStepAlu=0.1;
394 fMaxDestepGas=-1;
395 fMaxDestepAlu=-1;
396//
397 fMaxIterPad = 0;
398 fCurIterPad = 0;
5c1f55c5 399//
400 fAccMin = 0.;
401 fAccMax = 0.;
402 fAccCut = kFALSE;
a9e2aefa 403
404 // cp new design of AliMUONTriggerDecision
f665c1ea 405 fTriggerCircuits = new TObjArray(AliMUONConstants::NTriggerCircuit());
406 for (Int_t circ=0; circ<AliMUONConstants::NTriggerCircuit(); circ++) {
cd4df77b 407 fTriggerCircuits->AddAt(new AliMUONTriggerCircuit(),circ);
a9e2aefa 408
1cae9436 409 }
410 fMerger = 0;
fe4da5cc 411}
412
413//___________________________________________
a9e2aefa 414AliMUON::AliMUON(const AliMUON& rMUON)
415{
416// Dummy copy constructor
417 ;
418
419}
420
fe4da5cc 421AliMUON::~AliMUON()
422{
de05461e 423// Destructor
9e1a0ddb 424 if(fDebug) printf("%s: Calling AliMUON destructor !!!\n",ClassName());
a897a37a 425
f665c1ea 426 Int_t i;
427 fIshunt = 0;
c2c0190f 428
429 // Delete TObjArrays
430
431 if (fChambers){
432 fChambers->Delete();
433 delete fChambers;
434 }
435
436 if (fTriggerCircuits){
437 fTriggerCircuits->Delete();
438 delete fTriggerCircuits;
439 }
440
441 if (fDchambers){
442 fDchambers->Delete();
443 delete fDchambers;
444 }
445
446 if (fRawClusters){
447 fRawClusters->Delete();
448 delete fRawClusters;
449 }
450 for (i=0;i<AliMUONConstants::NTrackingCh();i++) {
451 fNrawch[i]=0;
452 }
453
454 // Delete TClonesArrays
455
456 if (fPadHits){
457 fPadHits->Delete();
458 delete fPadHits;
459 }
460
461 if (fGlobalTrigger){
462 fGlobalTrigger->Delete();
463 delete fGlobalTrigger;
464 }
f665c1ea 465 fNGlobalTrigger = 0;
466
c2c0190f 467 if (fLocalTrigger){
468 fLocalTrigger->Delete();
469 delete fLocalTrigger;
470 }
f665c1ea 471 fNLocalTrigger = 0;
a897a37a 472
c2c0190f 473 if (fHits2){
474 fHits2->Delete();
475 delete fHits2;
f665c1ea 476 }
c2c0190f 477
478 if (fPadHits2){
479 fPadHits2->Delete();
480 delete fPadHits2;
f665c1ea 481 }
c2c0190f 482
483 if (fHits) {
484 fHits->Delete();
485 delete fHits;
486 }
487
488 // Delete hits tree for background event
489
490 if (fTrH1) {
491 fTrH1->Delete();
492 delete fTrH1;
f665c1ea 493 }
1cae9436 494
495 if (fMerger) delete fMerger;
fe4da5cc 496}
497
498//___________________________________________
499void AliMUON::AddHit(Int_t track, Int_t *vol, Float_t *hits)
500{
501 TClonesArray &lhits = *fHits;
a9e2aefa 502 new(lhits[fNhits++]) AliMUONHit(fIshunt,track,vol,hits);
fe4da5cc 503}
504//___________________________________________
a9e2aefa 505void AliMUON::AddPadHit(Int_t *clhits)
fe4da5cc 506{
a9e2aefa 507 TClonesArray &lclusters = *fPadHits;
508 new(lclusters[fNPadHits++]) AliMUONPadHit(clhits);
fe4da5cc 509}
510//_____________________________________________________________________________
511void AliMUON::AddDigits(Int_t id, Int_t *tracks, Int_t *charges, Int_t *digits)
512{
513 //
514 // Add a MUON digit to the list
515 //
516
2682e810 517 //PH TClonesArray &ldigits = *((TClonesArray*)(*fDchambers)[id]);
518 TClonesArray &ldigits = *((TClonesArray*)fDchambers->At(id));
a9e2aefa 519 new(ldigits[fNdch[id]++]) AliMUONDigit(tracks,charges,digits);
fe4da5cc 520}
521
a897a37a 522//_____________________________________________________________________________
523void AliMUON::AddRawCluster(Int_t id, const AliMUONRawCluster& c)
524{
525 //
526 // Add a MUON digit to the list
527 //
528
2682e810 529 //PH TClonesArray &lrawcl = *((TClonesArray*)(*fRawClusters)[id]);
530 TClonesArray &lrawcl = *((TClonesArray*)fRawClusters->At(id));
a897a37a 531 new(lrawcl[fNrawch[id]++]) AliMUONRawCluster(c);
532}
a897a37a 533
a9e2aefa 534//___________________________________________
535void AliMUON::AddGlobalTrigger(Int_t *singlePlus, Int_t *singleMinus,
536 Int_t *singleUndef,
537 Int_t *pairUnlike, Int_t *pairLike)
538{
539// add a MUON Global Trigger to the list (only one GlobalTrigger per event !)
540 TClonesArray &globalTrigger = *fGlobalTrigger;
541 new(globalTrigger[fNGlobalTrigger++])
542 AliMUONGlobalTrigger(singlePlus, singleMinus, singleUndef, pairUnlike,
543 pairLike);
544}
545//___________________________________________
546void AliMUON::AddLocalTrigger(Int_t *localtr)
547{
548// add a MUON Local Trigger to the list
549 TClonesArray &localTrigger = *fLocalTrigger;
550 new(localTrigger[fNLocalTrigger++]) AliMUONLocalTrigger(localtr);
a897a37a 551}
552
fe4da5cc 553//___________________________________________
554void AliMUON::BuildGeometry()
555{
de05461e 556// Geometry for event display
5fd73042 557 for (Int_t i=0; i<7; i++) {
558 for (Int_t j=0; j<2; j++) {
559 Int_t id=2*i+j+1;
560 this->Chamber(id-1).SegmentationModel(1)->Draw("eventdisplay");
a897a37a 561 }
5fd73042 562 }
fe4da5cc 563}
564
565//___________________________________________
566Int_t AliMUON::DistancetoPrimitive(Int_t , Int_t )
567{
568 return 9999;
569}
570
571//___________________________________________
9e1a0ddb 572void AliMUON::MakeBranch(Option_t* option, const char *file)
fe4da5cc 573{
2ab0c725 574 //
f665c1ea 575 // Create Tree branches for the MUON.
2ab0c725 576 //
f665c1ea 577 const Int_t kBufferSize = 4000;
578 char branchname[30];
579 sprintf(branchname,"%sCluster",GetName());
580
2ab0c725 581 AliDetector::MakeBranch(option,file);
f665c1ea 582
5cf7bbad 583 const char *cD = strstr(option,"D");
584 const char *cR = strstr(option,"R");
585 const char *cH = strstr(option,"H");
2ab0c725 586
587 if (fPadHits && gAlice->TreeH() && cH) {
9e1a0ddb 588 MakeBranchInTree(gAlice->TreeH(),
589 branchname, &fPadHits, kBufferSize, file);
f665c1ea 590 }
591
2ab0c725 592 if (cD) {
593 //
594 // one branch for digits per chamber
595 //
596 Int_t i;
f665c1ea 597
2ab0c725 598 for (i=0; i<AliMUONConstants::NCh() ;i++) {
599 sprintf(branchname,"%sDigits%d",GetName(),i+1);
600 if (fDchambers && gAlice->TreeD()) {
9e1a0ddb 601 MakeBranchInTree(gAlice->TreeD(),
602 branchname, &((*fDchambers)[i]), kBufferSize, file);
2ab0c725 603 printf("Making Branch %s for digits in chamber %d\n",branchname,i+1);
604 }
605 }
f665c1ea 606 }
607
2ab0c725 608 if (cR) {
609 //
610 // one branch for raw clusters per chamber
611 //
612 printf("Make Branch - TreeR address %p\n",gAlice->TreeR());
613
614 Int_t i;
615
616 for (i=0; i<AliMUONConstants::NTrackingCh() ;i++) {
617 sprintf(branchname,"%sRawClusters%d",GetName(),i+1);
618 if (fRawClusters && gAlice->TreeR()) {
9e1a0ddb 619 MakeBranchInTree(gAlice->TreeR(),
620 branchname, &((*fRawClusters)[i]), kBufferSize, file);
2ab0c725 621 printf("Making Branch %s for raw clusters in chamber %d\n",branchname,i+1);
622 }
623 }
624 //
625 // one branch for global trigger
626 //
627 sprintf(branchname,"%sGlobalTrigger",GetName());
628 if (fGlobalTrigger && gAlice->TreeR()) {
9e1a0ddb 629 MakeBranchInTree(gAlice->TreeR(),
630 branchname, &fGlobalTrigger, kBufferSize, file);
2ab0c725 631 printf("Making Branch %s for Global Trigger\n",branchname);
632 }
633 //
634 // one branch for local trigger
635 //
636 sprintf(branchname,"%sLocalTrigger",GetName());
637 if (fLocalTrigger && gAlice->TreeR()) {
9e1a0ddb 638 MakeBranchInTree(gAlice->TreeR(),
639 branchname, &fLocalTrigger, kBufferSize, file);
2ab0c725 640 printf("Making Branch %s for Local Trigger\n",branchname);
641 }
642 }
fe4da5cc 643}
644
645//___________________________________________
646void AliMUON::SetTreeAddress()
647{
648 // Set branch address for the Hits and Digits Tree.
a897a37a 649 char branchname[30];
fe4da5cc 650 AliDetector::SetTreeAddress();
651
652 TBranch *branch;
653 TTree *treeH = gAlice->TreeH();
654 TTree *treeD = gAlice->TreeD();
a897a37a 655 TTree *treeR = gAlice->TreeR();
fe4da5cc 656
657 if (treeH) {
a9e2aefa 658 if (fPadHits) {
fe4da5cc 659 branch = treeH->GetBranch("MUONCluster");
a9e2aefa 660 if (branch) branch->SetAddress(&fPadHits);
fe4da5cc 661 }
662 }
663
664 if (treeD) {
f665c1ea 665 for (int i=0; i<AliMUONConstants::NCh(); i++) {
fe4da5cc 666 sprintf(branchname,"%sDigits%d",GetName(),i+1);
667 if (fDchambers) {
668 branch = treeD->GetBranch(branchname);
669 if (branch) branch->SetAddress(&((*fDchambers)[i]));
670 }
671 }
672 }
a897a37a 673
674 // printf("SetTreeAddress --- treeR address %p \n",treeR);
675
676 if (treeR) {
f665c1ea 677 for (int i=0; i<AliMUONConstants::NTrackingCh(); i++) {
a897a37a 678 sprintf(branchname,"%sRawClusters%d",GetName(),i+1);
679 if (fRawClusters) {
680 branch = treeR->GetBranch(branchname);
681 if (branch) branch->SetAddress(&((*fRawClusters)[i]));
682 }
683 }
a897a37a 684
a9e2aefa 685 if (fLocalTrigger) {
686 branch = treeR->GetBranch("MUONLocalTrigger");
687 if (branch) branch->SetAddress(&fLocalTrigger);
688 }
689 if (fGlobalTrigger) {
690 branch = treeR->GetBranch("MUONGlobalTrigger");
691 if (branch) branch->SetAddress(&fGlobalTrigger);
692 }
693 }
fe4da5cc 694}
695//___________________________________________
696void AliMUON::ResetHits()
697{
698 // Reset number of clusters and the cluster array for this detector
699 AliDetector::ResetHits();
a9e2aefa 700 fNPadHits = 0;
701 if (fPadHits) fPadHits->Clear();
fe4da5cc 702}
703
704//____________________________________________
705void AliMUON::ResetDigits()
706{
707 //
708 // Reset number of digits and the digits array for this detector
709 //
f665c1ea 710 for ( int i=0;i<AliMUONConstants::NCh();i++ ) {
2682e810 711 //PH if ((*fDchambers)[i]) ((TClonesArray*)(*fDchambers)[i])->Clear();
712 if ((*fDchambers)[i]) ((TClonesArray*)fDchambers->At(i))->Clear();
fe4da5cc 713 if (fNdch) fNdch[i]=0;
714 }
715}
a897a37a 716//____________________________________________
717void AliMUON::ResetRawClusters()
718{
719 //
720 // Reset number of raw clusters and the raw clust array for this detector
721 //
f665c1ea 722 for ( int i=0;i<AliMUONConstants::NTrackingCh();i++ ) {
2682e810 723 //PH if ((*fRawClusters)[i]) ((TClonesArray*)(*fRawClusters)[i])->Clear();
724 if ((*fRawClusters)[i]) ((TClonesArray*)fRawClusters->At(i))->Clear();
a897a37a 725 if (fNrawch) fNrawch[i]=0;
726 }
727}
a9e2aefa 728
a897a37a 729//____________________________________________
a9e2aefa 730void AliMUON::ResetTrigger()
a897a37a 731{
a9e2aefa 732 // Reset Local and Global Trigger
733 fNGlobalTrigger = 0;
734 if (fGlobalTrigger) fGlobalTrigger->Clear();
735 fNLocalTrigger = 0;
736 if (fLocalTrigger) fLocalTrigger->Clear();
737}
738
739//____________________________________________
740void AliMUON::SetPadSize(Int_t id, Int_t isec, Float_t p1, Float_t p2)
741{
de05461e 742// Set the pad size for chamber id and cathode isec
a9e2aefa 743 Int_t i=2*(id-1);
2682e810 744 //PH ((AliMUONChamber*) (*fChambers)[i]) ->SetPadSize(isec,p1,p2);
745 //PH ((AliMUONChamber*) (*fChambers)[i+1])->SetPadSize(isec,p1,p2);
746 ((AliMUONChamber*) fChambers->At(i)) ->SetPadSize(isec,p1,p2);
747 ((AliMUONChamber*) fChambers->At(i+1))->SetPadSize(isec,p1,p2);
a897a37a 748}
749
fe4da5cc 750//___________________________________________
a9e2aefa 751void AliMUON::SetChambersZ(const Float_t *Z)
752{
753 // Set Z values for all chambers (tracking and trigger)
754 // from the array pointed to by "Z"
f665c1ea 755 for (Int_t ch = 0; ch < AliMUONConstants::NCh(); ch++)
2682e810 756 //PH ((AliMUONChamber*) ((*fChambers)[ch]))->SetZ(Z[ch]);
757 ((AliMUONChamber*) fChambers->At(ch))->SetZ(Z[ch]);
f665c1ea 758 return;
a9e2aefa 759}
fe4da5cc 760
a9e2aefa 761//___________________________________________
762void AliMUON::SetChambersZToDefault()
fe4da5cc 763{
a9e2aefa 764 // Set Z values for all chambers (tracking and trigger)
765 // to default values
f665c1ea 766 SetChambersZ(AliMUONConstants::DefaultChamberZ());
a9e2aefa 767 return;
fe4da5cc 768}
769
770//___________________________________________
a897a37a 771void AliMUON::SetChargeSlope(Int_t id, Float_t p1)
fe4da5cc 772{
de05461e 773// Set the inverse charge slope for chamber id
fe4da5cc 774 Int_t i=2*(id-1);
2682e810 775 //PH ((AliMUONChamber*) (*fChambers)[i])->SetChargeSlope(p1);
776 //PH ((AliMUONChamber*) (*fChambers)[i+1])->SetChargeSlope(p1);
777 ((AliMUONChamber*) fChambers->At(i))->SetChargeSlope(p1);
778 ((AliMUONChamber*) fChambers->At(i+1))->SetChargeSlope(p1);
fe4da5cc 779}
780
781//___________________________________________
a897a37a 782void AliMUON::SetChargeSpread(Int_t id, Float_t p1, Float_t p2)
fe4da5cc 783{
de05461e 784// Set sigma of charge spread for chamber id
fe4da5cc 785 Int_t i=2*(id-1);
2682e810 786 //PH ((AliMUONChamber*) fChambers->At(i))->SetChargeSpread(p1,p2);
787 //PH ((AliMUONChamber*) fChambers->Ati+1])->SetChargeSpread(p1,p2);
788 ((AliMUONChamber*) fChambers->At(i))->SetChargeSpread(p1,p2);
789 ((AliMUONChamber*) fChambers->At(i+1))->SetChargeSpread(p1,p2);
fe4da5cc 790}
791
792//___________________________________________
a897a37a 793void AliMUON::SetSigmaIntegration(Int_t id, Float_t p1)
fe4da5cc 794{
de05461e 795// Set integration limits for charge spread
fe4da5cc 796 Int_t i=2*(id-1);
2682e810 797 //PH ((AliMUONChamber*) (*fChambers)[i])->SetSigmaIntegration(p1);
798 //PH ((AliMUONChamber*) (*fChambers)[i+1])->SetSigmaIntegration(p1);
799 ((AliMUONChamber*) fChambers->At(i))->SetSigmaIntegration(p1);
800 ((AliMUONChamber*) fChambers->At(i+1))->SetSigmaIntegration(p1);
fe4da5cc 801}
802
803//___________________________________________
d09fafb0 804void AliMUON::SetMaxAdc(Int_t id, Int_t p1)
fe4da5cc 805{
de05461e 806// Set maximum number for ADCcounts (saturation)
fe4da5cc 807 Int_t i=2*(id-1);
2682e810 808 //PH ((AliMUONChamber*) (*fChambers)[i])->SetMaxAdc(p1);
809 //PH ((AliMUONChamber*) (*fChambers)[i+1])->SetMaxAdc(p1);
810 ((AliMUONChamber*) fChambers->At(i))->SetMaxAdc(p1);
811 ((AliMUONChamber*) fChambers->At(i+1))->SetMaxAdc(p1);
fe4da5cc 812}
813
814//___________________________________________
a897a37a 815void AliMUON::SetMaxStepGas(Float_t p1)
fe4da5cc 816{
de05461e 817// Set stepsize in gas
fe4da5cc 818 fMaxStepGas=p1;
819}
820
821//___________________________________________
a897a37a 822void AliMUON::SetMaxStepAlu(Float_t p1)
fe4da5cc 823{
de05461e 824// Set step size in Alu
fe4da5cc 825 fMaxStepAlu=p1;
826}
827
828//___________________________________________
a897a37a 829void AliMUON::SetMaxDestepGas(Float_t p1)
fe4da5cc 830{
de05461e 831// Set maximum step size in Gas
fe4da5cc 832 fMaxDestepGas=p1;
833}
834
835//___________________________________________
a897a37a 836void AliMUON::SetMaxDestepAlu(Float_t p1)
fe4da5cc 837{
de05461e 838// Set maximum step size in Alu
fe4da5cc 839 fMaxDestepAlu=p1;
840}
841//___________________________________________
5c1f55c5 842void AliMUON::SetAcceptance(Bool_t acc, Float_t angmin, Float_t angmax)
fe4da5cc 843{
de05461e 844// Set acceptance cuts
fe4da5cc 845 fAccCut=acc;
5c1f55c5 846 fAccMin=angmin*TMath::Pi()/180;
847 fAccMax=angmax*TMath::Pi()/180;
848 Int_t ch;
849 if (acc) {
850 for (Int_t st = 0; st < AliMUONConstants::NCh() / 2; st++) {
851 // Loop over 2 chambers in the station
852 for (Int_t stCH = 0; stCH < 2; stCH++) {
853 ch = 2 * st + stCH;
854// Set chamber inner and outer radius according to acceptance cuts
855 Chamber(ch).SetRInner(AliMUONConstants::DefaultChamberZ(ch)*TMath::Tan(fAccMin));
856 Chamber(ch).SetROuter(AliMUONConstants::DefaultChamberZ(ch)*TMath::Tan(fAccMax));
857 } // chamber loop
858 } // station loop
859 }
fe4da5cc 860}
861//___________________________________________
a30a000f 862void AliMUON::SetSegmentationModel(Int_t id, Int_t isec, AliSegmentation *segmentation)
fe4da5cc 863{
de05461e 864// Set the segmentation for chamber id cathode isec
2682e810 865 //PH ((AliMUONChamber*) (*fChambers)[id])->SetSegmentationModel(isec, segmentation);
866 ((AliMUONChamber*) fChambers->At(id))->SetSegmentationModel(isec, segmentation);
fe4da5cc 867
868}
869//___________________________________________
a9e2aefa 870void AliMUON::SetResponseModel(Int_t id, AliMUONResponse *response)
fe4da5cc 871{
de05461e 872// Set the response for chamber id
2682e810 873 //PH ((AliMUONChamber*) (*fChambers)[id])->SetResponseModel(response);
874 ((AliMUONChamber*) fChambers->At(id))->SetResponseModel(response);
fe4da5cc 875}
876
30aaba74 877void AliMUON::SetReconstructionModel(Int_t id, AliMUONClusterFinderVS *reconst)
a897a37a 878{
de05461e 879// Set ClusterFinder for chamber id
2682e810 880 //PH ((AliMUONChamber*) (*fChambers)[id])->SetReconstructionModel(reconst);
881 ((AliMUONChamber*) fChambers->At(id))->SetReconstructionModel(reconst);
a897a37a 882}
883
fe4da5cc 884void AliMUON::SetNsec(Int_t id, Int_t nsec)
885{
de05461e 886// Set number of segmented cathods for chamber id
2682e810 887 //PH ((AliMUONChamber*) (*fChambers)[id])->SetNsec(nsec);
888 ((AliMUONChamber*) fChambers->At(id))->SetNsec(nsec);
fe4da5cc 889}
890
fe4da5cc 891//___________________________________________
2ab0c725 892void AliMUON::SDigits2Digits()
893{
d963c261 894
895// write TreeD here
896
897 if (!fMerger) {
898 if (gAlice->GetDebug()>0) {
899 cerr<<"AliMUON::SDigits2Digits: create default AliMUONMerger "<<endl;
900 cerr<<" no merging, just digitization of 1 event will be done"<<endl;
901 }
902 fMerger = new AliMUONMerger();
2ab0c725 903 }
d963c261 904 fMerger->Init();
905 fMerger->Digitise();
906 char hname[30];
907 sprintf(hname,"TreeD%d",gAlice->GetHeader()->GetEvent());
908 gAlice->TreeD()->Write(hname,TObject::kOverwrite);
909 gAlice->TreeD()->Reset();
2ab0c725 910}
a9e2aefa 911
2ab0c725 912//___________________________________________
802a864d 913void AliMUON::MakePadHits(Float_t xhit,Float_t yhit, Float_t zhit,
a9e2aefa 914 Float_t eloss, Float_t tof, Int_t idvol)
fe4da5cc 915{
916//
a897a37a 917// Calls the charge disintegration method of the current chamber and adds
918// the simulated cluster to the root treee
fe4da5cc 919//
a897a37a 920 Int_t clhits[7];
921 Float_t newclust[6][500];
922 Int_t nnew;
923
924
fe4da5cc 925//
a897a37a 926// Integrated pulse height on chamber
927
928
929 clhits[0]=fNhits+1;
fe4da5cc 930//
a897a37a 931//
7ab910ae 932// if (idvol == 6) printf("\n ->Disintegration %f %f %f", xhit, yhit, eloss );
933
934
2682e810 935 //PH ((AliMUONChamber*) (*fChambers)[idvol])
936 ((AliMUONChamber*) fChambers->At(idvol))
802a864d 937 ->DisIntegration(eloss, tof, xhit, yhit, zhit, nnew, newclust);
a897a37a 938 Int_t ic=0;
7ab910ae 939// if (idvol == 6) printf("\n nnew %d \n", nnew);
a897a37a 940//
941// Add new clusters
942 for (Int_t i=0; i<nnew; i++) {
943 if (Int_t(newclust[3][i]) > 0) {
944 ic++;
945// Cathode plane
946 clhits[1] = Int_t(newclust[5][i]);
947// Cluster Charge
948 clhits[2] = Int_t(newclust[0][i]);
949// Pad: ix
950 clhits[3] = Int_t(newclust[1][i]);
951// Pad: iy
952 clhits[4] = Int_t(newclust[2][i]);
953// Pad: charge
954 clhits[5] = Int_t(newclust[3][i]);
955// Pad: chamber sector
956 clhits[6] = Int_t(newclust[4][i]);
957
a9e2aefa 958 AddPadHit(clhits);
a897a37a 959 }
960 }
a897a37a 961}
962
a9e2aefa 963//___________________________________________
964void AliMUON::Trigger(Int_t nev){
965// call the Trigger Algorithm and fill TreeR
966
967 Int_t singlePlus[3] = {0,0,0};
968 Int_t singleMinus[3] = {0,0,0};
969 Int_t singleUndef[3] = {0,0,0};
970 Int_t pairUnlike[3] = {0,0,0};
971 Int_t pairLike[3] = {0,0,0};
972
973 ResetTrigger();
a9e2aefa 974 AliMUONTriggerDecision* decision= new AliMUONTriggerDecision(1);
975 decision->Trigger();
976 decision->GetGlobalTrigger(singlePlus, singleMinus, singleUndef,
977 pairUnlike, pairLike);
978// add a local trigger in the list
979 AddGlobalTrigger(singlePlus, singleMinus, singleUndef, pairUnlike, pairLike);
9ae15266 980 Int_t i;
a9e2aefa 981
f665c1ea 982 for (Int_t icirc=0; icirc<AliMUONConstants::NTriggerCircuit(); icirc++) {
9ae15266 983 if(decision->GetITrigger(icirc)==1) {
984 Int_t localtr[7]={0,0,0,0,0,0,0};
985 Int_t loLpt[2]={0,0}; Int_t loHpt[2]={0,0}; Int_t loApt[2]={0,0};
986 decision->GetLutOutput(icirc, loLpt, loHpt, loApt);
987 localtr[0] = icirc;
988 localtr[1] = decision->GetStripX11(icirc);
989 localtr[2] = decision->GetDev(icirc);
990 localtr[3] = decision->GetStripY11(icirc);
991 for (i=0; i<2; i++) { // convert the Lut output in 1 digit
992 localtr[4] = localtr[4]+Int_t(loLpt[i]*TMath::Power(2,i));
993 localtr[5] = localtr[5]+Int_t(loHpt[i]*TMath::Power(2,i));
994 localtr[6] = localtr[6]+Int_t(loApt[i]*TMath::Power(2,i));
995 }
996 AddLocalTrigger(localtr); // add a local trigger in the list
a897a37a 997 }
a9e2aefa 998 }
999 delete decision;
a897a37a 1000
a9e2aefa 1001 gAlice->TreeR()->Fill();
1002 ResetTrigger();
a897a37a 1003 char hname[30];
1004 sprintf(hname,"TreeR%d",nev);
2ab0c725 1005 gAlice->TreeR()->Write(hname,TObject::kOverwrite);
a897a37a 1006 gAlice->TreeR()->Reset();
a9e2aefa 1007 printf("\n End of trigger for event %d", nev);
a897a37a 1008}
a897a37a 1009
a897a37a 1010
a9e2aefa 1011//____________________________________________
fe311ef1 1012void AliMUON::Digits2Reco()
1013{
1014 FindClusters();
e365e1ee 1015 Int_t nev = gAlice->GetHeader()->GetEvent();
1016 gAlice->TreeR()->Fill();
1017 char hname[30];
1018 sprintf(hname,"TreeR%d", nev);
1019 gAlice->TreeR()->Write(hname);
1020 gAlice->TreeR()->Reset();
1021 ResetRawClusters();
1022 printf("\n End of cluster finding for event %d", nev);
fe311ef1 1023}
1024
1025void AliMUON::FindClusters()
a9e2aefa 1026{
de05461e 1027//
1028// Perform cluster finding
1029//
a9e2aefa 1030 TClonesArray *dig1, *dig2;
1031 Int_t ndig, k;
1032 dig1 = new TClonesArray("AliMUONDigit",1000);
1033 dig2 = new TClonesArray("AliMUONDigit",1000);
1034 AliMUONDigit *digit;
a897a37a 1035//
a9e2aefa 1036// Loop on chambers and on cathode planes
a897a37a 1037//
fe311ef1 1038 ResetRawClusters();
1bd28025 1039 for (Int_t ich = 0; ich < 10; ich++) {
2682e810 1040 //PH AliMUONChamber* iChamber = (AliMUONChamber*) (*fChambers)[ich];
1041 AliMUONChamber* iChamber = (AliMUONChamber*) fChambers->At(ich);
fe311ef1 1042 AliMUONClusterFinderVS* rec = iChamber->ReconstructionModel();
1043
a9e2aefa 1044 gAlice->ResetDigits();
fe311ef1 1045 gAlice->TreeD()->GetEvent(0);
1bd28025 1046 TClonesArray *muonDigits = this->DigitsAddress(ich);
a9e2aefa 1047 ndig=muonDigits->GetEntriesFast();
1048 printf("\n 1 Found %d digits in %p %d", ndig, muonDigits,ich);
1049 TClonesArray &lhits1 = *dig1;
1bd28025 1050 Int_t n = 0;
1051 for (k = 0; k < ndig; k++) {
1052 digit = (AliMUONDigit*) muonDigits->UncheckedAt(k);
1053 if (rec->TestTrack(digit->Track(0)))
a9e2aefa 1054 new(lhits1[n++]) AliMUONDigit(*digit);
1055 }
1056 gAlice->ResetDigits();
fe311ef1 1057 gAlice->TreeD()->GetEvent(1);
a9e2aefa 1058 muonDigits = this->DigitsAddress(ich);
1059 ndig=muonDigits->GetEntriesFast();
1060 printf("\n 2 Found %d digits in %p %d", ndig, muonDigits, ich);
1061 TClonesArray &lhits2 = *dig2;
1062 n=0;
1063
1064 for (k=0; k<ndig; k++) {
1065 digit= (AliMUONDigit*) muonDigits->UncheckedAt(k);
1bd28025 1066 if (rec->TestTrack(digit->Track(0)))
a9e2aefa 1067 new(lhits2[n++]) AliMUONDigit(*digit);
a897a37a 1068 }
a897a37a 1069
9825400f 1070 if (rec) {
1071 AliMUONClusterInput::Instance()->SetDigits(ich, dig1, dig2);
a9e2aefa 1072 rec->FindRawClusters();
1073 }
1074 dig1->Delete();
1075 dig2->Delete();
1076 } // for ich
a9e2aefa 1077 delete dig1;
1078 delete dig2;
a897a37a 1079}
a9e2aefa 1080
2ab0c725 1081#ifdef never
fe4da5cc 1082void AliMUON::Streamer(TBuffer &R__b)
1083{
1084 // Stream an object of class AliMUON.
a30a000f 1085 AliMUONChamber *iChamber;
a9e2aefa 1086 AliMUONTriggerCircuit *iTriggerCircuit;
a30a000f 1087 AliSegmentation *segmentation;
1088 AliMUONResponse *response;
1089 TClonesArray *digitsaddress;
1090 TClonesArray *rawcladdress;
9ae15266 1091 Int_t i;
9ae15266 1092 if (R__b.IsReading()) {
1093 Version_t R__v = R__b.ReadVersion(); if (R__v) { }
1094 AliDetector::Streamer(R__b);
1095 R__b >> fNPadHits;
1096 R__b >> fPadHits; // diff
1097 R__b >> fNLocalTrigger;
1098 R__b >> fLocalTrigger;
1099 R__b >> fNGlobalTrigger;
1100 R__b >> fGlobalTrigger;
1101 R__b >> fDchambers;
1102 R__b >> fRawClusters;
1103 R__b.ReadArray(fNdch);
1104 R__b.ReadArray(fNrawch);
1105 R__b >> fAccCut;
1106 R__b >> fAccMin;
1107 R__b >> fAccMax;
1108 R__b >> fChambers;
1109 R__b >> fTriggerCircuits;
f665c1ea 1110 for (i =0; i<AliMUONConstants::NTriggerCircuit(); i++) {
9ae15266 1111 iTriggerCircuit=(AliMUONTriggerCircuit*) (*fTriggerCircuits)[i];
1112 iTriggerCircuit->Streamer(R__b);
fe4da5cc 1113 }
9ae15266 1114// Stream chamber related information
f665c1ea 1115 for (i =0; i<AliMUONConstants::NCh(); i++) {
9ae15266 1116 iChamber=(AliMUONChamber*) (*fChambers)[i];
1117 iChamber->Streamer(R__b);
1118 if (iChamber->Nsec()==1) {
1119 segmentation=iChamber->SegmentationModel(1);
1120 if (segmentation)
1121 segmentation->Streamer(R__b);
1122 } else {
1123 segmentation=iChamber->SegmentationModel(1);
1124 if (segmentation)
1125 segmentation->Streamer(R__b);
1126 if (segmentation)
1127 segmentation=iChamber->SegmentationModel(2);
1128 segmentation->Streamer(R__b);
1129 }
1130 response=iChamber->ResponseModel();
1131 if (response)
1132 response->Streamer(R__b);
1133 digitsaddress=(TClonesArray*) (*fDchambers)[i];
1134 digitsaddress->Streamer(R__b);
f665c1ea 1135 if (i < AliMUONConstants::NTrackingCh()) {
9ae15266 1136 rawcladdress=(TClonesArray*) (*fRawClusters)[i];
1137 rawcladdress->Streamer(R__b);
1138 }
a9e2aefa 1139 }
9ae15266 1140
1141 } else {
1142 R__b.WriteVersion(AliMUON::IsA());
1143 AliDetector::Streamer(R__b);
1144 R__b << fNPadHits;
1145 R__b << fPadHits; // diff
1146 R__b << fNLocalTrigger;
1147 R__b << fLocalTrigger;
1148 R__b << fNGlobalTrigger;
1149 R__b << fGlobalTrigger;
1150 R__b << fDchambers;
1151 R__b << fRawClusters;
f665c1ea 1152 R__b.WriteArray(fNdch, AliMUONConstants::NCh());
1153 R__b.WriteArray(fNrawch, AliMUONConstants::NTrackingCh());
9ae15266 1154
1155 R__b << fAccCut;
1156 R__b << fAccMin;
1157 R__b << fAccMax;
1158
1159 R__b << fChambers;
1160 R__b << fTriggerCircuits;
f665c1ea 1161 for (i =0; i<AliMUONConstants::NTriggerCircuit(); i++) {
9ae15266 1162 iTriggerCircuit=(AliMUONTriggerCircuit*) (*fTriggerCircuits)[i];
1163 iTriggerCircuit->Streamer(R__b);
fe4da5cc 1164 }
f665c1ea 1165 for (i =0; i<AliMUONConstants::NCh(); i++) {
9ae15266 1166 iChamber=(AliMUONChamber*) (*fChambers)[i];
1167 iChamber->Streamer(R__b);
1168 if (iChamber->Nsec()==1) {
1169 segmentation=iChamber->SegmentationModel(1);
1170 if (segmentation)
1171 segmentation->Streamer(R__b);
1172 } else {
1173 segmentation=iChamber->SegmentationModel(1);
1174 if (segmentation)
1175 segmentation->Streamer(R__b);
1176 segmentation=iChamber->SegmentationModel(2);
1177 if (segmentation)
1178 segmentation->Streamer(R__b);
1179 }
1180 response=iChamber->ResponseModel();
1181 if (response)
1182 response->Streamer(R__b);
1183 digitsaddress=(TClonesArray*) (*fDchambers)[i];
1184 digitsaddress->Streamer(R__b);
f665c1ea 1185 if (i < AliMUONConstants::NTrackingCh()) {
9ae15266 1186 rawcladdress=(TClonesArray*) (*fRawClusters)[i];
1187 rawcladdress->Streamer(R__b);
1188 }
a9e2aefa 1189 }
fe4da5cc 1190 }
fe4da5cc 1191}
2ab0c725 1192#endif
1193
a9e2aefa 1194AliMUONPadHit* AliMUON::FirstPad(AliMUONHit* hit, TClonesArray *clusters)
fe4da5cc 1195{
1196//
1197 // Initialise the pad iterator
1198 // Return the address of the first padhit for hit
a897a37a 1199 TClonesArray *theClusters = clusters;
fe4da5cc 1200 Int_t nclust = theClusters->GetEntriesFast();
1bd28025 1201 if (nclust && hit->PHlast() > 0) {
1202 AliMUON::fMaxIterPad=hit->PHlast();
1203 AliMUON::fCurIterPad=hit->PHfirst();
a9e2aefa 1204 return (AliMUONPadHit*) clusters->UncheckedAt(AliMUON::fCurIterPad-1);
fe4da5cc 1205 } else {
1206 return 0;
1207 }
1208}
1209
a9e2aefa 1210AliMUONPadHit* AliMUON::NextPad(TClonesArray *clusters)
fe4da5cc 1211{
de05461e 1212// Get next pad (in iterator)
1213//
a9e2aefa 1214 AliMUON::fCurIterPad++;
1215 if (AliMUON::fCurIterPad <= AliMUON::fMaxIterPad) {
1216 return (AliMUONPadHit*) clusters->UncheckedAt(AliMUON::fCurIterPad-1);
fe4da5cc 1217 } else {
1218 return 0;
1219 }
1220}
1221
a897a37a 1222
1223AliMUONRawCluster *AliMUON::RawCluster(Int_t ichamber, Int_t icathod, Int_t icluster)
1224{
de05461e 1225//
1226// Return rawcluster (icluster) for chamber ichamber and cathode icathod
1227// Obsolete ??
a9e2aefa 1228 TClonesArray *muonRawCluster = RawClustAddress(ichamber);
a897a37a 1229 ResetRawClusters();
a9e2aefa 1230 TTree *treeR = gAlice->TreeR();
1231 Int_t nent=(Int_t)treeR->GetEntries();
1232 treeR->GetEvent(nent-2+icathod-1);
1233 //treeR->GetEvent(icathod);
1234 //Int_t nrawcl = (Int_t)muonRawCluster->GetEntriesFast();
a897a37a 1235
a9e2aefa 1236 AliMUONRawCluster * mRaw = (AliMUONRawCluster*)muonRawCluster->UncheckedAt(icluster);
a897a37a 1237 //printf("RawCluster _ nent nrawcl icluster mRaw %d %d %d%p\n",nent,nrawcl,icluster,mRaw);
1238
1239 return mRaw;
1240}
1cae9436 1241
1242void AliMUON::SetMerger(AliMUONMerger* merger)
1243{
1244// Set pointer to merger
1245 fMerger = merger;
1246}
1247
1248AliMUONMerger* AliMUON::Merger()
1249{
1250// Return pointer to merger
1251 return fMerger;
1252}
1253
1254
a897a37a 1255
a9e2aefa 1256AliMUON& AliMUON::operator = (const AliMUON& rhs)
a897a37a 1257{
a9e2aefa 1258// copy operator
1259// dummy version
1260 return *this;
a897a37a 1261}
1262
cd4df77b 1263////////////////////////////////////////////////////////////////////////
1264void AliMUON::MakeBranchInTreeD(TTree *treeD, const char *file)
1265{
1266 //
1267 // Create TreeD branches for the MUON.
1268 //
a897a37a 1269
cd4df77b 1270 const Int_t kBufferSize = 4000;
1271 char branchname[30];
1272
1273 //
1274 // one branch for digits per chamber
1275 //
1276 for (Int_t i=0; i<AliMUONConstants::NCh() ;i++) {
1277 sprintf(branchname,"%sDigits%d",GetName(),i+1);
1278 if (fDchambers && treeD) {
1279 MakeBranchInTree(treeD,
1280 branchname, &((*fDchambers)[i]), kBufferSize, file);
1281 printf("Making Branch %s for digits in chamber %d\n",branchname,i+1);
1282 }
1283 }
1284}
a897a37a 1285
cd4df77b 1286//___________________________________________
fe4da5cc 1287