1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
17 Revision 1.58 2002/10/21 09:01:33 alibrary
18 Getting rid of unused variable
20 Revision 1.57 2002/10/14 14:57:29 hristov
21 Merging the VirtualMC branch to the main development branch (HEAD)
23 Revision 1.56.6.2 2002/07/24 10:07:20 alibrary
26 Revision 1.56.6.1 2002/06/10 15:10:14 hristov
29 Revision 1.56 2001/11/22 11:26:28 jchudoba
30 Proper deletion of arrays, deletion of unused variables (thanks to Rene Brun)
32 Revision 1.55 2001/09/07 08:38:30 hristov
33 Pointers initialised to 0 in the default constructors
35 Revision 1.54 2001/08/30 09:52:12 hristov
36 The operator[] is replaced by At() or AddAt() in case of TObjArray.
38 Revision 1.53 2001/07/20 10:03:13 morsch
39 Changes needed to work with Root 3.01 (substitute lhs [] operator). (Jiri Chudoba)
41 Revision 1.52 2001/06/14 13:49:22 hristov
42 Write a TreeD in SDigits2Digits method (needed to be compatible with alirun script)
44 Revision 1.51 2001/05/31 10:19:52 morsch
45 Fix for new AliRun::RunReco().
47 Revision 1.50 2001/05/16 14:57:17 alibrary
48 New files for folders and Stack
50 Revision 1.49 2001/03/12 17:45:48 hristov
51 Changes needed on Sun with CC 5.0
53 Revision 1.48 2001/03/06 00:01:36 morsch
54 Add Digits2Reco() and FindClusters()
55 Adapt call of cluster finder to new STEER.
57 Revision 1.47 2001/03/05 08:38:36 morsch
58 Digitization related methods moved to AliMUONMerger.
60 Revision 1.46 2001/01/26 21:34:59 morsch
61 Use access functions for AliMUONHit, AliMUONDigit and AliMUONPadHit data members.
63 Revision 1.45 2001/01/26 20:00:49 hristov
64 Major upgrade of AliRoot code
66 Revision 1.44 2001/01/25 17:39:09 morsch
67 Pass size of fNdch and fNrawch to CINT.
69 Revision 1.43 2001/01/23 18:58:19 hristov
70 Initialisation of some pointers
72 Revision 1.42 2001/01/17 20:53:40 hristov
73 Destructors corrected to avoid memory leaks
75 Revision 1.41 2000/12/21 22:12:40 morsch
76 Clean-up of coding rule violations,
78 Revision 1.40 2000/11/29 20:32:26 gosset
80 1. correction for array index out of bounds
81 2. one printout commented
83 Revision 1.39 2000/11/12 17:17:03 pcrochet
84 BuildGeometry of AliMUON for trigger chambers delegated to AliMUONSegmentationTriggerX (same strategy as for tracking chambers)
86 Revision 1.38 2000/11/06 09:20:43 morsch
87 AliMUON delegates part of BuildGeometry() to AliMUONSegmentation using the
88 Draw() method. This avoids code and parameter replication.
90 Revision 1.37 2000/10/26 09:53:37 pcrochet
91 put back trigger chambers in the display (there was a problem in buildgeometry)
93 Revision 1.36 2000/10/25 19:51:18 morsch
94 Correct x-position of chambers.
96 Revision 1.35 2000/10/24 19:46:21 morsch
97 BuildGeometry updated for slats in station 3-4.
99 Revision 1.34 2000/10/18 11:42:06 morsch
100 - AliMUONRawCluster contains z-position.
101 - Some clean-up of useless print statements during initialisations.
103 Revision 1.33 2000/10/09 14:01:57 morsch
104 Unused variables removed.
106 Revision 1.32 2000/10/06 09:08:10 morsch
107 Built geometry includes slat geometry for event display.
109 Revision 1.31 2000/10/02 21:28:08 fca
110 Removal of useless dependecies via forward declarations
112 Revision 1.30 2000/10/02 16:58:29 egangler
113 Cleaning of the code :
114 -> coding conventions
116 -> some useless includes removed or replaced by "class" statement
118 Revision 1.29 2000/07/28 13:49:38 morsch
119 SetAcceptance defines inner and outer chamber radii according to angular acceptance.
120 Can be used for simple acceptance studies.
122 Revision 1.28 2000/07/22 16:43:15 morsch
123 Same comment as before, but now done correctly I hope (sorry it's Saturday evening)
125 Revision 1.27 2000/07/22 16:36:50 morsch
126 Change order of indices in creation (new) of xhit and yhit
128 Revision 1.26 2000/07/03 11:54:57 morsch
129 AliMUONSegmentation and AliMUONHitMap have been replaced by AliSegmentation and AliHitMap in STEER
130 The methods GetPadIxy and GetPadXxy of AliMUONSegmentation have changed name to GetPadI and GetPadC.
132 Revision 1.25 2000/06/29 12:34:09 morsch
133 AliMUONSegmentation class has been made independent of AliMUONChamber. This makes
134 it usable with any other geometry class. The link to the object to which it belongs is
135 established via an index. This assumes that there exists a global geometry manager
136 from which the pointer to the parent object can be obtained (in our case gAlice).
138 Revision 1.24 2000/06/28 15:16:35 morsch
139 (1) Client code adapted to new method signatures in AliMUONSegmentation (see comments there)
140 to allow development of slat-muon chamber simulation and reconstruction code in the MUON
141 framework. The changes should have no side effects (mostly dummy arguments).
142 (2) Hit disintegration uses 3-dim hit coordinates to allow simulation
143 of chambers with overlapping modules (MakePadHits, Disintegration).
145 Revision 1.23 2000/06/28 12:19:17 morsch
146 More consequent seperation of global input data services (AliMUONClusterInput singleton) and the
147 cluster and hit reconstruction algorithms in AliMUONClusterFindRawinderVS.
148 AliMUONClusterFinderVS becomes the base class for clustering and hit reconstruction.
149 It requires two cathode planes. Small modifications in the code will make it usable for
150 one cathode plane and, hence, more general (for test beam data).
151 AliMUONClusterFinder is now obsolete.
153 Revision 1.22 2000/06/28 08:06:10 morsch
154 Avoid global variables in AliMUONClusterFinderVS by seperating the input data for the fit from the
155 algorithmic part of the class. Input data resides inside the AliMUONClusterInput singleton.
156 It also naturally takes care of the TMinuit instance.
158 Revision 1.21 2000/06/27 08:54:41 morsch
159 Problems with on constant array sizes (in hitMap, nmuon, xhit, yhit) corrected.
161 Revision 1.20 2000/06/26 14:02:38 morsch
162 Add class AliMUONConstants with MUON specific constants using static memeber data and access methods.
164 Revision 1.19 2000/06/22 13:40:51 morsch
165 scope problem on HP, "i" declared once
166 pow changed to TMath::Power (PH, AM)
168 Revision 1.18 2000/06/15 07:58:48 morsch
169 Code from MUON-dev joined
171 Revision 1.14.4.17 2000/06/14 14:36:46 morsch
172 - add TriggerCircuit (PC)
173 - add GlobalTrigger and LocalTrigger and specific methods (PC)
175 Revision 1.14.4.16 2000/06/09 21:20:28 morsch
176 Most coding rule violations corrected
178 Revision 1.14.4.15 2000/05/02 09:54:32 morsch
179 RULE RN17 violations corrected
181 Revision 1.14.4.12 2000/04/26 12:25:02 morsch
182 Code revised by P. Crochet:
183 - Z position of TriggerChamber changed according to A.Tournaire Priv.Comm.
184 - ToF included in the method MakePadHits
185 - inner radius of flange between beam shielding and trigger corrected
186 - Trigger global volume updated (according to the new geometry)
188 Revision 1.14.4.11 2000/04/19 19:42:08 morsch
189 Some changes of variable names curing viols and methods concerning
190 correlated clusters removed.
192 Revision 1.14.4.10 2000/03/22 16:44:07 gosset
193 Memory leak suppressed in function Digitise:
194 p_adr->Delete() instead of Clear (I.Chevrot and A.Baldisseri)
196 Revision 1.14.4.9 2000/03/20 18:15:25 morsch
197 Positions of trigger chambers corrected (P.C.)
199 Revision 1.14.4.8 2000/02/21 15:38:01 morsch
200 Call to AddHitList introduced to make this version compatible with head.
202 Revision 1.14.4.7 2000/02/20 07:45:53 morsch
203 Bugs in Trigger part of BuildGeomemetry corrected (P.C)
205 Revision 1.14.4.6 2000/02/17 14:28:54 morsch
206 Trigger included into initialization and digitization
208 Revision 1.14.4.5 2000/02/15 10:02:58 morsch
209 Log messages of previous revisions added
211 Revision 1.14.4.2 2000/02/04 10:57:34 gosset
212 Z position of the chambers:
213 it was the Z position of the stations;
214 it is now really the Z position of the chambers.
215 !!!! WARNING: THE CALLS TO "AliMUONChamber::SetZPOS"
216 !!!! AND "AliMUONChamber::ZPosition"
217 !!!! HAVE TO BE CHANGED TO "AliMUONChamber::"SetZ"
218 !!!! AND "AliMUONChamber::Z"
220 Revision 1.14.4.3 2000/02/04 16:19:04 gosset
221 Correction for mis-spelling of NCH
223 Revision 1.14.4.4 2000/02/15 09:43:38 morsch
229 ///////////////////////////////////////////////
230 // Manager and hits classes for set:MUON //
231 ////////////////////////////////////////////////
235 #include <TRotMatrix.h>
236 #include <TGeometry.h>
242 #include <TObjArray.h>
244 #include <TParticle.h>
250 #include <TDirectory.h>
251 #include <TObjectTable.h>
256 #include "AliMUONHit.h"
257 #include "AliMUONPadHit.h"
258 #include "AliMUONDigit.h"
259 #include "AliMUONTransientDigit.h"
260 #include "AliMUONRawCluster.h"
261 #include "AliMUONLocalTrigger.h"
262 #include "AliMUONGlobalTrigger.h"
263 #include "AliMUONTriggerCircuit.h"
264 #include "AliHitMap.h"
265 #include "AliMUONHitMapA1.h"
266 #include "AliMUONChamberTrigger.h"
267 #include "AliMUONConstants.h"
268 #include "AliMUONClusterFinderVS.h"
269 #include "AliMUONTriggerDecision.h"
271 #include "AliHeader.h"
272 #include "AliMUONClusterInput.h"
273 #include "AliMUONMerger.h"
274 #include "Riostream.h"
275 #include "AliConst.h"
277 // Defaults parameters for Z positions of chambers
278 // taken from values for "stations" in AliMUON::AliMUON
279 // const Float_t zch[7]={528, 690., 975., 1249., 1449., 1610, 1710.};
280 // and from array "dstation" in AliMUONv1::CreateGeometry
281 // Float_t dstation[5]={20., 20., 20, 20., 20.};
282 // for tracking chambers,
283 // according to (Z1 = zch - dstation) and (Z2 = zch + dstation)
284 // for the first and second chambers in the station, respectively,
285 // and from "DTPLANES" in AliMUONv1::CreateGeometry
286 // const Float_t DTPLANES = 15.;
287 // for trigger chambers,
288 // according to (Z1 = zch) and (Z2 = zch + DTPLANES)
289 // for the first and second chambers in the station, respectively
292 //___________________________________________
295 // Default Constructor
304 fTriggerCircuits = 0;
319 //___________________________________________
320 AliMUON::AliMUON(const char *name, const char *title)
321 : AliDetector(name,title)
325 <img src="gif/alimuon.gif">
329 fHits = new TClonesArray("AliMUONHit",1000);
330 gAlice->AddHitList(fHits);
331 fPadHits = new TClonesArray("AliMUONPadHit",10000);
335 fNCh = AliMUONConstants::NCh();
336 fNTrackingCh = AliMUONConstants::NTrackingCh();
337 fNdch = new Int_t[fNCh];
339 fDchambers = new TObjArray(AliMUONConstants::NCh());
343 for (i=0; i<AliMUONConstants::NCh() ;i++) {
344 fDchambers->AddAt(new TClonesArray("AliMUONDigit",10000),i);
348 fNrawch = new Int_t[fNTrackingCh];
350 fRawClusters = new TObjArray(AliMUONConstants::NTrackingCh());
352 for (i=0; i<AliMUONConstants::NTrackingCh();i++) {
353 fRawClusters->AddAt(new TClonesArray("AliMUONRawCluster",10000),i);
357 fGlobalTrigger = new TClonesArray("AliMUONGlobalTrigger",1);
359 fLocalTrigger = new TClonesArray("AliMUONLocalTrigger",234);
362 SetMarkerColor(kRed);
370 fChambers = new TObjArray(AliMUONConstants::NCh());
372 // Loop over stations
373 for (Int_t st = 0; st < AliMUONConstants::NCh() / 2; st++) {
374 // Loop over 2 chambers in the station
375 for (Int_t stCH = 0; stCH < 2; stCH++) {
378 // Default Parameters for Muon Tracking Stations
383 if (ch < AliMUONConstants::NTrackingCh()) {
384 fChambers->AddAt(new AliMUONChamber(ch),ch);
386 fChambers->AddAt(new AliMUONChamberTrigger(ch),ch);
389 //PH AliMUONChamber* chamber = (AliMUONChamber*) (*fChambers)[ch];
390 AliMUONChamber* chamber = (AliMUONChamber*) fChambers->At(ch);
393 // Default values for Z of chambers
394 chamber->SetZ(AliMUONConstants::DefaultChamberZ(ch));
396 chamber->InitGeo(AliMUONConstants::DefaultChamberZ(ch));
397 // Set chamber inner and outer radius to default
398 chamber->SetRInner(AliMUONConstants::Dmin(st)/2);
399 chamber->SetROuter(AliMUONConstants::Dmax(st)/2);
401 } // Chamber stCH (0, 1) in
402 } // Station st (0...)
403 // fChambers->SetLast(AliMUONConstants::NCh());
416 // cp new design of AliMUONTriggerDecision
417 fTriggerCircuits = new TObjArray(AliMUONConstants::NTriggerCircuit());
418 for (Int_t circ=0; circ<AliMUONConstants::NTriggerCircuit(); circ++) {
419 fTriggerCircuits->AddAt(new AliMUONTriggerCircuit(),circ);
425 //___________________________________________
426 AliMUON::AliMUON(const AliMUON& rMUON)
428 // Dummy copy constructor
436 if(fDebug) printf("%s: Calling AliMUON destructor !!!\n",ClassName());
447 if (fTriggerCircuits){
448 fTriggerCircuits->Delete();
449 delete fTriggerCircuits;
453 fDchambers->Delete();
458 fRawClusters->Delete();
462 if (fNrawch) delete [] fNrawch;
464 // Delete TClonesArrays
472 fGlobalTrigger->Delete();
473 delete fGlobalTrigger;
478 fLocalTrigger->Delete();
479 delete fLocalTrigger;
488 if (fMerger) delete fMerger;
489 if (fNdch) delete [] fNdch;
493 //___________________________________________
494 void AliMUON::AddHit(Int_t track, Int_t *vol, Float_t *hits)
496 TClonesArray &lhits = *fHits;
497 new(lhits[fNhits++]) AliMUONHit(fIshunt,track,vol,hits);
499 //___________________________________________
500 void AliMUON::AddPadHit(Int_t *clhits)
502 TClonesArray &lclusters = *fPadHits;
503 new(lclusters[fNPadHits++]) AliMUONPadHit(clhits);
505 //_____________________________________________________________________________
506 void AliMUON::AddDigits(Int_t id, Int_t *tracks, Int_t *charges, Int_t *digits)
509 // Add a MUON digit to the list
512 //PH TClonesArray &ldigits = *((TClonesArray*)(*fDchambers)[id]);
513 TClonesArray &ldigits = *((TClonesArray*)fDchambers->At(id));
514 new(ldigits[fNdch[id]++]) AliMUONDigit(tracks,charges,digits);
517 //_____________________________________________________________________________
518 void AliMUON::AddRawCluster(Int_t id, const AliMUONRawCluster& c)
521 // Add a MUON digit to the list
524 //PH TClonesArray &lrawcl = *((TClonesArray*)(*fRawClusters)[id]);
525 TClonesArray &lrawcl = *((TClonesArray*)fRawClusters->At(id));
526 new(lrawcl[fNrawch[id]++]) AliMUONRawCluster(c);
529 //___________________________________________
530 void AliMUON::AddGlobalTrigger(Int_t *singlePlus, Int_t *singleMinus,
532 Int_t *pairUnlike, Int_t *pairLike)
534 // add a MUON Global Trigger to the list (only one GlobalTrigger per event !)
535 TClonesArray &globalTrigger = *fGlobalTrigger;
536 new(globalTrigger[fNGlobalTrigger++])
537 AliMUONGlobalTrigger(singlePlus, singleMinus, singleUndef, pairUnlike,
540 //___________________________________________
541 void AliMUON::AddLocalTrigger(Int_t *localtr)
543 // add a MUON Local Trigger to the list
544 TClonesArray &localTrigger = *fLocalTrigger;
545 new(localTrigger[fNLocalTrigger++]) AliMUONLocalTrigger(localtr);
548 //___________________________________________
549 void AliMUON::BuildGeometry()
551 // Geometry for event display
552 for (Int_t i=0; i<7; i++) {
553 for (Int_t j=0; j<2; j++) {
555 this->Chamber(id-1).SegmentationModel(1)->Draw("eventdisplay");
560 //___________________________________________
561 Int_t AliMUON::DistancetoPrimitive(Int_t , Int_t )
566 //___________________________________________
567 void AliMUON::MakeBranch(Option_t* option, const char *file)
570 // Create Tree branches for the MUON.
572 const Int_t kBufferSize = 4000;
574 sprintf(branchname,"%sCluster",GetName());
576 AliDetector::MakeBranch(option,file);
578 const char *cD = strstr(option,"D");
579 const char *cR = strstr(option,"R");
580 const char *cH = strstr(option,"H");
582 if (fPadHits && gAlice->TreeH() && cH) {
583 MakeBranchInTree(gAlice->TreeH(),
584 branchname, &fPadHits, kBufferSize, file);
589 // one branch for digits per chamber
593 for (i=0; i<AliMUONConstants::NCh() ;i++) {
594 sprintf(branchname,"%sDigits%d",GetName(),i+1);
595 if (fDchambers && gAlice->TreeD()) {
596 MakeBranchInTree(gAlice->TreeD(),
597 branchname, &((*fDchambers)[i]), kBufferSize, file);
598 printf("Making Branch %s for digits in chamber %d\n",branchname,i+1);
605 // one branch for raw clusters per chamber
607 printf("Make Branch - TreeR address %p\n",gAlice->TreeR());
611 for (i=0; i<AliMUONConstants::NTrackingCh() ;i++) {
612 sprintf(branchname,"%sRawClusters%d",GetName(),i+1);
613 if (fRawClusters && gAlice->TreeR()) {
614 MakeBranchInTree(gAlice->TreeR(),
615 branchname, &((*fRawClusters)[i]), kBufferSize, file);
616 printf("Making Branch %s for raw clusters in chamber %d\n",branchname,i+1);
620 // one branch for global trigger
622 sprintf(branchname,"%sGlobalTrigger",GetName());
623 if (fGlobalTrigger && gAlice->TreeR()) {
624 MakeBranchInTree(gAlice->TreeR(),
625 branchname, &fGlobalTrigger, kBufferSize, file);
626 printf("Making Branch %s for Global Trigger\n",branchname);
629 // one branch for local trigger
631 sprintf(branchname,"%sLocalTrigger",GetName());
632 if (fLocalTrigger && gAlice->TreeR()) {
633 MakeBranchInTree(gAlice->TreeR(),
634 branchname, &fLocalTrigger, kBufferSize, file);
635 printf("Making Branch %s for Local Trigger\n",branchname);
640 //___________________________________________
641 void AliMUON::SetTreeAddress()
643 // Set branch address for the Hits and Digits Tree.
645 AliDetector::SetTreeAddress();
648 TTree *treeH = gAlice->TreeH();
649 TTree *treeD = gAlice->TreeD();
650 TTree *treeR = gAlice->TreeR();
654 branch = treeH->GetBranch("MUONCluster");
655 if (branch) branch->SetAddress(&fPadHits);
660 for (int i=0; i<AliMUONConstants::NCh(); i++) {
661 sprintf(branchname,"%sDigits%d",GetName(),i+1);
663 branch = treeD->GetBranch(branchname);
664 if (branch) branch->SetAddress(&((*fDchambers)[i]));
669 // printf("SetTreeAddress --- treeR address %p \n",treeR);
672 for (int i=0; i<AliMUONConstants::NTrackingCh(); i++) {
673 sprintf(branchname,"%sRawClusters%d",GetName(),i+1);
675 branch = treeR->GetBranch(branchname);
676 if (branch) branch->SetAddress(&((*fRawClusters)[i]));
681 branch = treeR->GetBranch("MUONLocalTrigger");
682 if (branch) branch->SetAddress(&fLocalTrigger);
684 if (fGlobalTrigger) {
685 branch = treeR->GetBranch("MUONGlobalTrigger");
686 if (branch) branch->SetAddress(&fGlobalTrigger);
690 //___________________________________________
691 void AliMUON::ResetHits()
693 // Reset number of clusters and the cluster array for this detector
694 AliDetector::ResetHits();
696 if (fPadHits) fPadHits->Clear();
699 //____________________________________________
700 void AliMUON::ResetDigits()
703 // Reset number of digits and the digits array for this detector
705 for ( int i=0;i<AliMUONConstants::NCh();i++ ) {
706 //PH if ((*fDchambers)[i]) ((TClonesArray*)(*fDchambers)[i])->Clear();
707 if ((*fDchambers)[i]) ((TClonesArray*)fDchambers->At(i))->Clear();
708 if (fNdch) fNdch[i]=0;
711 //____________________________________________
712 void AliMUON::ResetRawClusters()
715 // Reset number of raw clusters and the raw clust array for this detector
717 for ( int i=0;i<AliMUONConstants::NTrackingCh();i++ ) {
718 //PH if ((*fRawClusters)[i]) ((TClonesArray*)(*fRawClusters)[i])->Clear();
719 if ((*fRawClusters)[i]) ((TClonesArray*)fRawClusters->At(i))->Clear();
720 if (fNrawch) fNrawch[i]=0;
724 //____________________________________________
725 void AliMUON::ResetTrigger()
727 // Reset Local and Global Trigger
729 if (fGlobalTrigger) fGlobalTrigger->Clear();
731 if (fLocalTrigger) fLocalTrigger->Clear();
734 //____________________________________________
735 void AliMUON::SetPadSize(Int_t id, Int_t isec, Float_t p1, Float_t p2)
737 // Set the pad size for chamber id and cathode isec
739 //PH ((AliMUONChamber*) (*fChambers)[i]) ->SetPadSize(isec,p1,p2);
740 //PH ((AliMUONChamber*) (*fChambers)[i+1])->SetPadSize(isec,p1,p2);
741 ((AliMUONChamber*) fChambers->At(i)) ->SetPadSize(isec,p1,p2);
742 ((AliMUONChamber*) fChambers->At(i+1))->SetPadSize(isec,p1,p2);
745 //___________________________________________
746 void AliMUON::SetChambersZ(const Float_t *Z)
748 // Set Z values for all chambers (tracking and trigger)
749 // from the array pointed to by "Z"
750 for (Int_t ch = 0; ch < AliMUONConstants::NCh(); ch++)
751 //PH ((AliMUONChamber*) ((*fChambers)[ch]))->SetZ(Z[ch]);
752 ((AliMUONChamber*) fChambers->At(ch))->SetZ(Z[ch]);
756 //___________________________________________
757 void AliMUON::SetChambersZToDefault()
759 // Set Z values for all chambers (tracking and trigger)
761 SetChambersZ(AliMUONConstants::DefaultChamberZ());
765 //___________________________________________
766 void AliMUON::SetChargeSlope(Int_t id, Float_t p1)
768 // Set the inverse charge slope for chamber id
770 //PH ((AliMUONChamber*) (*fChambers)[i])->SetChargeSlope(p1);
771 //PH ((AliMUONChamber*) (*fChambers)[i+1])->SetChargeSlope(p1);
772 ((AliMUONChamber*) fChambers->At(i))->SetChargeSlope(p1);
773 ((AliMUONChamber*) fChambers->At(i+1))->SetChargeSlope(p1);
776 //___________________________________________
777 void AliMUON::SetChargeSpread(Int_t id, Float_t p1, Float_t p2)
779 // Set sigma of charge spread for chamber id
781 //PH ((AliMUONChamber*) fChambers->At(i))->SetChargeSpread(p1,p2);
782 //PH ((AliMUONChamber*) fChambers->Ati+1])->SetChargeSpread(p1,p2);
783 ((AliMUONChamber*) fChambers->At(i))->SetChargeSpread(p1,p2);
784 ((AliMUONChamber*) fChambers->At(i+1))->SetChargeSpread(p1,p2);
787 //___________________________________________
788 void AliMUON::SetSigmaIntegration(Int_t id, Float_t p1)
790 // Set integration limits for charge spread
792 //PH ((AliMUONChamber*) (*fChambers)[i])->SetSigmaIntegration(p1);
793 //PH ((AliMUONChamber*) (*fChambers)[i+1])->SetSigmaIntegration(p1);
794 ((AliMUONChamber*) fChambers->At(i))->SetSigmaIntegration(p1);
795 ((AliMUONChamber*) fChambers->At(i+1))->SetSigmaIntegration(p1);
798 //___________________________________________
799 void AliMUON::SetMaxAdc(Int_t id, Int_t p1)
801 // Set maximum number for ADCcounts (saturation)
803 //PH ((AliMUONChamber*) (*fChambers)[i])->SetMaxAdc(p1);
804 //PH ((AliMUONChamber*) (*fChambers)[i+1])->SetMaxAdc(p1);
805 ((AliMUONChamber*) fChambers->At(i))->SetMaxAdc(p1);
806 ((AliMUONChamber*) fChambers->At(i+1))->SetMaxAdc(p1);
809 //___________________________________________
810 void AliMUON::SetMaxStepGas(Float_t p1)
812 // Set stepsize in gas
816 //___________________________________________
817 void AliMUON::SetMaxStepAlu(Float_t p1)
819 // Set step size in Alu
823 //___________________________________________
824 void AliMUON::SetMaxDestepGas(Float_t p1)
826 // Set maximum step size in Gas
830 //___________________________________________
831 void AliMUON::SetMaxDestepAlu(Float_t p1)
833 // Set maximum step size in Alu
836 //___________________________________________
837 void AliMUON::SetAcceptance(Bool_t acc, Float_t angmin, Float_t angmax)
839 // Set acceptance cuts
841 fAccMin=angmin*TMath::Pi()/180;
842 fAccMax=angmax*TMath::Pi()/180;
845 for (Int_t st = 0; st < AliMUONConstants::NCh() / 2; st++) {
846 // Loop over 2 chambers in the station
847 for (Int_t stCH = 0; stCH < 2; stCH++) {
849 // Set chamber inner and outer radius according to acceptance cuts
850 Chamber(ch).SetRInner(AliMUONConstants::DefaultChamberZ(ch)*TMath::Tan(fAccMin));
851 Chamber(ch).SetROuter(AliMUONConstants::DefaultChamberZ(ch)*TMath::Tan(fAccMax));
856 //___________________________________________
857 void AliMUON::SetSegmentationModel(Int_t id, Int_t isec, AliSegmentation *segmentation)
859 // Set the segmentation for chamber id cathode isec
860 //PH ((AliMUONChamber*) (*fChambers)[id])->SetSegmentationModel(isec, segmentation);
861 ((AliMUONChamber*) fChambers->At(id))->SetSegmentationModel(isec, segmentation);
864 //___________________________________________
865 void AliMUON::SetResponseModel(Int_t id, AliMUONResponse *response)
867 // Set the response for chamber id
868 //PH ((AliMUONChamber*) (*fChambers)[id])->SetResponseModel(response);
869 ((AliMUONChamber*) fChambers->At(id))->SetResponseModel(response);
872 void AliMUON::SetReconstructionModel(Int_t id, AliMUONClusterFinderVS *reconst)
874 // Set ClusterFinder for chamber id
875 //PH ((AliMUONChamber*) (*fChambers)[id])->SetReconstructionModel(reconst);
876 ((AliMUONChamber*) fChambers->At(id))->SetReconstructionModel(reconst);
879 void AliMUON::SetNsec(Int_t id, Int_t nsec)
881 // Set number of segmented cathods for chamber id
882 //PH ((AliMUONChamber*) (*fChambers)[id])->SetNsec(nsec);
883 ((AliMUONChamber*) fChambers->At(id))->SetNsec(nsec);
886 //___________________________________________
887 void AliMUON::SDigits2Digits()
893 if (gAlice->GetDebug()>0) {
894 cerr<<"AliMUON::SDigits2Digits: create default AliMUONMerger "<<endl;
895 cerr<<" no merging, just digitization of 1 event will be done"<<endl;
897 fMerger = new AliMUONMerger();
902 sprintf(hname,"TreeD%d",gAlice->GetHeader()->GetEvent());
903 gAlice->TreeD()->Write(hname,TObject::kOverwrite);
904 gAlice->TreeD()->Reset();
907 //___________________________________________
908 void AliMUON::MakePadHits(Float_t xhit,Float_t yhit, Float_t zhit,
909 Float_t eloss, Float_t tof, Int_t idvol)
912 // Calls the charge disintegration method of the current chamber and adds
913 // the simulated cluster to the root treee
916 Float_t newclust[6][500];
921 // Integrated pulse height on chamber
927 // if (idvol == 6) printf("\n ->Disintegration %f %f %f", xhit, yhit, eloss );
930 //PH ((AliMUONChamber*) (*fChambers)[idvol])
931 ((AliMUONChamber*) fChambers->At(idvol))
932 ->DisIntegration(eloss, tof, xhit, yhit, zhit, nnew, newclust);
934 // if (idvol == 6) printf("\n nnew %d \n", nnew);
937 for (Int_t i=0; i<nnew; i++) {
938 if (Int_t(newclust[3][i]) > 0) {
941 clhits[1] = Int_t(newclust[5][i]);
943 clhits[2] = Int_t(newclust[0][i]);
945 clhits[3] = Int_t(newclust[1][i]);
947 clhits[4] = Int_t(newclust[2][i]);
949 clhits[5] = Int_t(newclust[3][i]);
950 // Pad: chamber sector
951 clhits[6] = Int_t(newclust[4][i]);
958 //___________________________________________
959 void AliMUON::Trigger(Int_t nev){
960 // call the Trigger Algorithm and fill TreeR
962 Int_t singlePlus[3] = {0,0,0};
963 Int_t singleMinus[3] = {0,0,0};
964 Int_t singleUndef[3] = {0,0,0};
965 Int_t pairUnlike[3] = {0,0,0};
966 Int_t pairLike[3] = {0,0,0};
969 AliMUONTriggerDecision* decision= new AliMUONTriggerDecision(1);
971 decision->GetGlobalTrigger(singlePlus, singleMinus, singleUndef,
972 pairUnlike, pairLike);
973 // add a local trigger in the list
974 AddGlobalTrigger(singlePlus, singleMinus, singleUndef, pairUnlike, pairLike);
977 for (Int_t icirc=0; icirc<AliMUONConstants::NTriggerCircuit(); icirc++) {
978 if(decision->GetITrigger(icirc)==1) {
979 Int_t localtr[7]={0,0,0,0,0,0,0};
980 Int_t loLpt[2]={0,0}; Int_t loHpt[2]={0,0}; Int_t loApt[2]={0,0};
981 decision->GetLutOutput(icirc, loLpt, loHpt, loApt);
983 localtr[1] = decision->GetStripX11(icirc);
984 localtr[2] = decision->GetDev(icirc);
985 localtr[3] = decision->GetStripY11(icirc);
986 for (i=0; i<2; i++) { // convert the Lut output in 1 digit
987 localtr[4] = localtr[4]+Int_t(loLpt[i]*TMath::Power(2,i));
988 localtr[5] = localtr[5]+Int_t(loHpt[i]*TMath::Power(2,i));
989 localtr[6] = localtr[6]+Int_t(loApt[i]*TMath::Power(2,i));
991 AddLocalTrigger(localtr); // add a local trigger in the list
996 gAlice->TreeR()->Fill();
999 sprintf(hname,"TreeR%d",nev);
1000 gAlice->TreeR()->Write(hname,TObject::kOverwrite);
1001 gAlice->TreeR()->Reset();
1002 printf("\n End of trigger for event %d", nev);
1006 //____________________________________________
1007 void AliMUON::Digits2Reco()
1010 Int_t nev = gAlice->GetHeader()->GetEvent();
1011 gAlice->TreeR()->Fill();
1013 sprintf(hname,"TreeR%d", nev);
1014 gAlice->TreeR()->Write(hname);
1015 gAlice->TreeR()->Reset();
1017 printf("\n End of cluster finding for event %d", nev);
1020 void AliMUON::FindClusters()
1023 // Perform cluster finding
1025 TClonesArray *dig1, *dig2;
1027 dig1 = new TClonesArray("AliMUONDigit",1000);
1028 dig2 = new TClonesArray("AliMUONDigit",1000);
1029 AliMUONDigit *digit;
1031 // Loop on chambers and on cathode planes
1034 for (Int_t ich = 0; ich < 10; ich++) {
1035 //PH AliMUONChamber* iChamber = (AliMUONChamber*) (*fChambers)[ich];
1036 AliMUONChamber* iChamber = (AliMUONChamber*) fChambers->At(ich);
1037 AliMUONClusterFinderVS* rec = iChamber->ReconstructionModel();
1039 gAlice->ResetDigits();
1040 gAlice->TreeD()->GetEvent(0);
1041 TClonesArray *muonDigits = this->DigitsAddress(ich);
1042 ndig=muonDigits->GetEntriesFast();
1043 printf("\n 1 Found %d digits in %p %d", ndig, muonDigits,ich);
1044 TClonesArray &lhits1 = *dig1;
1046 for (k = 0; k < ndig; k++) {
1047 digit = (AliMUONDigit*) muonDigits->UncheckedAt(k);
1048 if (rec->TestTrack(digit->Track(0)))
1049 new(lhits1[n++]) AliMUONDigit(*digit);
1051 gAlice->ResetDigits();
1052 gAlice->TreeD()->GetEvent(1);
1053 muonDigits = this->DigitsAddress(ich);
1054 ndig=muonDigits->GetEntriesFast();
1055 printf("\n 2 Found %d digits in %p %d", ndig, muonDigits, ich);
1056 TClonesArray &lhits2 = *dig2;
1059 for (k=0; k<ndig; k++) {
1060 digit= (AliMUONDigit*) muonDigits->UncheckedAt(k);
1061 if (rec->TestTrack(digit->Track(0)))
1062 new(lhits2[n++]) AliMUONDigit(*digit);
1066 AliMUONClusterInput::Instance()->SetDigits(ich, dig1, dig2);
1067 rec->FindRawClusters();
1077 void AliMUON::Streamer(TBuffer &R__b)
1079 // Stream an object of class AliMUON.
1080 AliMUONChamber *iChamber;
1081 AliMUONTriggerCircuit *iTriggerCircuit;
1082 AliSegmentation *segmentation;
1083 AliMUONResponse *response;
1084 TClonesArray *digitsaddress;
1085 TClonesArray *rawcladdress;
1087 if (R__b.IsReading()) {
1088 Version_t R__v = R__b.ReadVersion(); if (R__v) { }
1089 AliDetector::Streamer(R__b);
1091 R__b >> fPadHits; // diff
1092 R__b >> fNLocalTrigger;
1093 R__b >> fLocalTrigger;
1094 R__b >> fNGlobalTrigger;
1095 R__b >> fGlobalTrigger;
1097 R__b >> fRawClusters;
1098 R__b.ReadArray(fNdch);
1099 R__b.ReadArray(fNrawch);
1104 R__b >> fTriggerCircuits;
1105 for (i =0; i<AliMUONConstants::NTriggerCircuit(); i++) {
1106 iTriggerCircuit=(AliMUONTriggerCircuit*) (*fTriggerCircuits)[i];
1107 iTriggerCircuit->Streamer(R__b);
1109 // Stream chamber related information
1110 for (i =0; i<AliMUONConstants::NCh(); i++) {
1111 iChamber=(AliMUONChamber*) (*fChambers)[i];
1112 iChamber->Streamer(R__b);
1113 if (iChamber->Nsec()==1) {
1114 segmentation=iChamber->SegmentationModel(1);
1116 segmentation->Streamer(R__b);
1118 segmentation=iChamber->SegmentationModel(1);
1120 segmentation->Streamer(R__b);
1122 segmentation=iChamber->SegmentationModel(2);
1123 segmentation->Streamer(R__b);
1125 response=iChamber->ResponseModel();
1127 response->Streamer(R__b);
1128 digitsaddress=(TClonesArray*) (*fDchambers)[i];
1129 digitsaddress->Streamer(R__b);
1130 if (i < AliMUONConstants::NTrackingCh()) {
1131 rawcladdress=(TClonesArray*) (*fRawClusters)[i];
1132 rawcladdress->Streamer(R__b);
1137 R__b.WriteVersion(AliMUON::IsA());
1138 AliDetector::Streamer(R__b);
1140 R__b << fPadHits; // diff
1141 R__b << fNLocalTrigger;
1142 R__b << fLocalTrigger;
1143 R__b << fNGlobalTrigger;
1144 R__b << fGlobalTrigger;
1146 R__b << fRawClusters;
1147 R__b.WriteArray(fNdch, AliMUONConstants::NCh());
1148 R__b.WriteArray(fNrawch, AliMUONConstants::NTrackingCh());
1155 R__b << fTriggerCircuits;
1156 for (i =0; i<AliMUONConstants::NTriggerCircuit(); i++) {
1157 iTriggerCircuit=(AliMUONTriggerCircuit*) (*fTriggerCircuits)[i];
1158 iTriggerCircuit->Streamer(R__b);
1160 for (i =0; i<AliMUONConstants::NCh(); i++) {
1161 iChamber=(AliMUONChamber*) (*fChambers)[i];
1162 iChamber->Streamer(R__b);
1163 if (iChamber->Nsec()==1) {
1164 segmentation=iChamber->SegmentationModel(1);
1166 segmentation->Streamer(R__b);
1168 segmentation=iChamber->SegmentationModel(1);
1170 segmentation->Streamer(R__b);
1171 segmentation=iChamber->SegmentationModel(2);
1173 segmentation->Streamer(R__b);
1175 response=iChamber->ResponseModel();
1177 response->Streamer(R__b);
1178 digitsaddress=(TClonesArray*) (*fDchambers)[i];
1179 digitsaddress->Streamer(R__b);
1180 if (i < AliMUONConstants::NTrackingCh()) {
1181 rawcladdress=(TClonesArray*) (*fRawClusters)[i];
1182 rawcladdress->Streamer(R__b);
1189 AliMUONPadHit* AliMUON::FirstPad(AliMUONHit* hit, TClonesArray *clusters)
1192 // Initialise the pad iterator
1193 // Return the address of the first padhit for hit
1194 TClonesArray *theClusters = clusters;
1195 Int_t nclust = theClusters->GetEntriesFast();
1196 if (nclust && hit->PHlast() > 0) {
1197 AliMUON::fMaxIterPad=hit->PHlast();
1198 AliMUON::fCurIterPad=hit->PHfirst();
1199 return (AliMUONPadHit*) clusters->UncheckedAt(AliMUON::fCurIterPad-1);
1205 AliMUONPadHit* AliMUON::NextPad(TClonesArray *clusters)
1207 // Get next pad (in iterator)
1209 AliMUON::fCurIterPad++;
1210 if (AliMUON::fCurIterPad <= AliMUON::fMaxIterPad) {
1211 return (AliMUONPadHit*) clusters->UncheckedAt(AliMUON::fCurIterPad-1);
1218 AliMUONRawCluster *AliMUON::RawCluster(Int_t ichamber, Int_t icathod, Int_t icluster)
1221 // Return rawcluster (icluster) for chamber ichamber and cathode icathod
1223 TClonesArray *muonRawCluster = RawClustAddress(ichamber);
1225 TTree *treeR = gAlice->TreeR();
1226 Int_t nent=(Int_t)treeR->GetEntries();
1227 treeR->GetEvent(nent-2+icathod-1);
1228 //treeR->GetEvent(icathod);
1229 //Int_t nrawcl = (Int_t)muonRawCluster->GetEntriesFast();
1231 AliMUONRawCluster * mRaw = (AliMUONRawCluster*)muonRawCluster->UncheckedAt(icluster);
1232 //printf("RawCluster _ nent nrawcl icluster mRaw %d %d %d%p\n",nent,nrawcl,icluster,mRaw);
1237 void AliMUON::SetMerger(AliMUONMerger* merger)
1239 // Set pointer to merger
1243 AliMUONMerger* AliMUON::Merger()
1245 // Return pointer to merger
1251 AliMUON& AliMUON::operator = (const AliMUON& rhs)
1258 ////////////////////////////////////////////////////////////////////////
1259 void AliMUON::MakeBranchInTreeD(TTree *treeD, const char *file)
1262 // Create TreeD branches for the MUON.
1265 const Int_t kBufferSize = 4000;
1266 char branchname[30];
1269 // one branch for digits per chamber
1271 for (Int_t i=0; i<AliMUONConstants::NCh() ;i++) {
1272 sprintf(branchname,"%sDigits%d",GetName(),i+1);
1273 if (fDchambers && treeD) {
1274 MakeBranchInTree(treeD,
1275 branchname, &((*fDchambers)[i]), kBufferSize, file);
1276 // printf("Making Branch %s for digits in chamber %d\n",branchname,i+1);
1281 //___________________________________________