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