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