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