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