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