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.56.6.2 2002/07/24 10:07:20 alibrary
20 Revision 1.56.6.1 2002/06/10 15:10:14 hristov
23 Revision 1.56 2001/11/22 11:26:28 jchudoba
24 Proper deletion of arrays, deletion of unused variables (thanks to Rene Brun)
26 Revision 1.55 2001/09/07 08:38:30 hristov
27 Pointers initialised to 0 in the default constructors
29 Revision 1.54 2001/08/30 09:52:12 hristov
30 The operator[] is replaced by At() or AddAt() in case of TObjArray.
32 Revision 1.53 2001/07/20 10:03:13 morsch
33 Changes needed to work with Root 3.01 (substitute lhs [] operator). (Jiri Chudoba)
35 Revision 1.52 2001/06/14 13:49:22 hristov
36 Write a TreeD in SDigits2Digits method (needed to be compatible with alirun script)
38 Revision 1.51 2001/05/31 10:19:52 morsch
39 Fix for new AliRun::RunReco().
41 Revision 1.50 2001/05/16 14:57:17 alibrary
42 New files for folders and Stack
44 Revision 1.49 2001/03/12 17:45:48 hristov
45 Changes needed on Sun with CC 5.0
47 Revision 1.48 2001/03/06 00:01:36 morsch
48 Add Digits2Reco() and FindClusters()
49 Adapt call of cluster finder to new STEER.
51 Revision 1.47 2001/03/05 08:38:36 morsch
52 Digitization related methods moved to AliMUONMerger.
54 Revision 1.46 2001/01/26 21:34:59 morsch
55 Use access functions for AliMUONHit, AliMUONDigit and AliMUONPadHit data members.
57 Revision 1.45 2001/01/26 20:00:49 hristov
58 Major upgrade of AliRoot code
60 Revision 1.44 2001/01/25 17:39:09 morsch
61 Pass size of fNdch and fNrawch to CINT.
63 Revision 1.43 2001/01/23 18:58:19 hristov
64 Initialisation of some pointers
66 Revision 1.42 2001/01/17 20:53:40 hristov
67 Destructors corrected to avoid memory leaks
69 Revision 1.41 2000/12/21 22:12:40 morsch
70 Clean-up of coding rule violations,
72 Revision 1.40 2000/11/29 20:32:26 gosset
74 1. correction for array index out of bounds
75 2. one printout commented
77 Revision 1.39 2000/11/12 17:17:03 pcrochet
78 BuildGeometry of AliMUON for trigger chambers delegated to AliMUONSegmentationTriggerX (same strategy as for tracking chambers)
80 Revision 1.38 2000/11/06 09:20:43 morsch
81 AliMUON delegates part of BuildGeometry() to AliMUONSegmentation using the
82 Draw() method. This avoids code and parameter replication.
84 Revision 1.37 2000/10/26 09:53:37 pcrochet
85 put back trigger chambers in the display (there was a problem in buildgeometry)
87 Revision 1.36 2000/10/25 19:51:18 morsch
88 Correct x-position of chambers.
90 Revision 1.35 2000/10/24 19:46:21 morsch
91 BuildGeometry updated for slats in station 3-4.
93 Revision 1.34 2000/10/18 11:42:06 morsch
94 - AliMUONRawCluster contains z-position.
95 - Some clean-up of useless print statements during initialisations.
97 Revision 1.33 2000/10/09 14:01:57 morsch
98 Unused variables removed.
100 Revision 1.32 2000/10/06 09:08:10 morsch
101 Built geometry includes slat geometry for event display.
103 Revision 1.31 2000/10/02 21:28:08 fca
104 Removal of useless dependecies via forward declarations
106 Revision 1.30 2000/10/02 16:58:29 egangler
107 Cleaning of the code :
108 -> coding conventions
110 -> some useless includes removed or replaced by "class" statement
112 Revision 1.29 2000/07/28 13:49:38 morsch
113 SetAcceptance defines inner and outer chamber radii according to angular acceptance.
114 Can be used for simple acceptance studies.
116 Revision 1.28 2000/07/22 16:43:15 morsch
117 Same comment as before, but now done correctly I hope (sorry it's Saturday evening)
119 Revision 1.27 2000/07/22 16:36:50 morsch
120 Change order of indices in creation (new) of xhit and yhit
122 Revision 1.26 2000/07/03 11:54:57 morsch
123 AliMUONSegmentation and AliMUONHitMap have been replaced by AliSegmentation and AliHitMap in STEER
124 The methods GetPadIxy and GetPadXxy of AliMUONSegmentation have changed name to GetPadI and GetPadC.
126 Revision 1.25 2000/06/29 12:34:09 morsch
127 AliMUONSegmentation class has been made independent of AliMUONChamber. This makes
128 it usable with any other geometry class. The link to the object to which it belongs is
129 established via an index. This assumes that there exists a global geometry manager
130 from which the pointer to the parent object can be obtained (in our case gAlice).
132 Revision 1.24 2000/06/28 15:16:35 morsch
133 (1) Client code adapted to new method signatures in AliMUONSegmentation (see comments there)
134 to allow development of slat-muon chamber simulation and reconstruction code in the MUON
135 framework. The changes should have no side effects (mostly dummy arguments).
136 (2) Hit disintegration uses 3-dim hit coordinates to allow simulation
137 of chambers with overlapping modules (MakePadHits, Disintegration).
139 Revision 1.23 2000/06/28 12:19:17 morsch
140 More consequent seperation of global input data services (AliMUONClusterInput singleton) and the
141 cluster and hit reconstruction algorithms in AliMUONClusterFindRawinderVS.
142 AliMUONClusterFinderVS becomes the base class for clustering and hit reconstruction.
143 It requires two cathode planes. Small modifications in the code will make it usable for
144 one cathode plane and, hence, more general (for test beam data).
145 AliMUONClusterFinder is now obsolete.
147 Revision 1.22 2000/06/28 08:06:10 morsch
148 Avoid global variables in AliMUONClusterFinderVS by seperating the input data for the fit from the
149 algorithmic part of the class. Input data resides inside the AliMUONClusterInput singleton.
150 It also naturally takes care of the TMinuit instance.
152 Revision 1.21 2000/06/27 08:54:41 morsch
153 Problems with on constant array sizes (in hitMap, nmuon, xhit, yhit) corrected.
155 Revision 1.20 2000/06/26 14:02:38 morsch
156 Add class AliMUONConstants with MUON specific constants using static memeber data and access methods.
158 Revision 1.19 2000/06/22 13:40:51 morsch
159 scope problem on HP, "i" declared once
160 pow changed to TMath::Power (PH, AM)
162 Revision 1.18 2000/06/15 07:58:48 morsch
163 Code from MUON-dev joined
165 Revision 1.14.4.17 2000/06/14 14:36:46 morsch
166 - add TriggerCircuit (PC)
167 - add GlobalTrigger and LocalTrigger and specific methods (PC)
169 Revision 1.14.4.16 2000/06/09 21:20:28 morsch
170 Most coding rule violations corrected
172 Revision 1.14.4.15 2000/05/02 09:54:32 morsch
173 RULE RN17 violations corrected
175 Revision 1.14.4.12 2000/04/26 12:25:02 morsch
176 Code 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)
182 Revision 1.14.4.11 2000/04/19 19:42:08 morsch
183 Some changes of variable names curing viols and methods concerning
184 correlated clusters removed.
186 Revision 1.14.4.10 2000/03/22 16:44:07 gosset
187 Memory leak suppressed in function Digitise:
188 p_adr->Delete() instead of Clear (I.Chevrot and A.Baldisseri)
190 Revision 1.14.4.9 2000/03/20 18:15:25 morsch
191 Positions of trigger chambers corrected (P.C.)
193 Revision 1.14.4.8 2000/02/21 15:38:01 morsch
194 Call to AddHitList introduced to make this version compatible with head.
196 Revision 1.14.4.7 2000/02/20 07:45:53 morsch
197 Bugs in Trigger part of BuildGeomemetry corrected (P.C)
199 Revision 1.14.4.6 2000/02/17 14:28:54 morsch
200 Trigger included into initialization and digitization
202 Revision 1.14.4.5 2000/02/15 10:02:58 morsch
203 Log messages of previous revisions added
205 Revision 1.14.4.2 2000/02/04 10:57:34 gosset
206 Z position of the chambers:
207 it was the Z position of the stations;
208 it 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"
214 Revision 1.14.4.3 2000/02/04 16:19:04 gosset
215 Correction for mis-spelling of NCH
217 Revision 1.14.4.4 2000/02/15 09:43:38 morsch
223 ///////////////////////////////////////////////
224 // Manager and hits classes for set:MUON //
225 ////////////////////////////////////////////////
229 #include <TRotMatrix.h>
230 #include <TGeometry.h>
236 #include <TObjArray.h>
238 #include <TParticle.h>
244 #include <TDirectory.h>
245 #include <TObjectTable.h>
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"
257 #include "AliMUONTriggerCircuit.h"
258 #include "AliHitMap.h"
259 #include "AliMUONHitMapA1.h"
260 #include "AliMUONChamberTrigger.h"
261 #include "AliMUONConstants.h"
262 #include "AliMUONClusterFinderVS.h"
263 #include "AliMUONTriggerDecision.h"
265 #include "AliHeader.h"
267 #include "AliMUONClusterInput.h"
268 #include "AliMUONMerger.h"
269 #include "iostream.h"
270 #include "AliConst.h"
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
287 //___________________________________________
290 // Default Constructor
299 fTriggerCircuits = 0;
314 //___________________________________________
315 AliMUON::AliMUON(const char *name, const char *title)
316 : AliDetector(name,title)
320 <img src="gif/alimuon.gif">
324 fHits = new TClonesArray("AliMUONHit",1000);
325 gAlice->AddHitList(fHits);
326 fPadHits = new TClonesArray("AliMUONPadHit",10000);
330 fNCh = AliMUONConstants::NCh();
331 fNTrackingCh = AliMUONConstants::NTrackingCh();
332 fNdch = new Int_t[fNCh];
334 fDchambers = new TObjArray(AliMUONConstants::NCh());
338 for (i=0; i<AliMUONConstants::NCh() ;i++) {
339 fDchambers->AddAt(new TClonesArray("AliMUONDigit",10000),i);
343 fNrawch = new Int_t[fNTrackingCh];
345 fRawClusters = new TObjArray(AliMUONConstants::NTrackingCh());
347 for (i=0; i<AliMUONConstants::NTrackingCh();i++) {
348 fRawClusters->AddAt(new TClonesArray("AliMUONRawCluster",10000),i);
352 fGlobalTrigger = new TClonesArray("AliMUONGlobalTrigger",1);
354 fLocalTrigger = new TClonesArray("AliMUONLocalTrigger",234);
357 SetMarkerColor(kRed);
365 fChambers = new TObjArray(AliMUONConstants::NCh());
367 // Loop over stations
368 for (Int_t st = 0; st < AliMUONConstants::NCh() / 2; st++) {
369 // Loop over 2 chambers in the station
370 for (Int_t stCH = 0; stCH < 2; stCH++) {
373 // Default Parameters for Muon Tracking Stations
378 if (ch < AliMUONConstants::NTrackingCh()) {
379 fChambers->AddAt(new AliMUONChamber(ch),ch);
381 fChambers->AddAt(new AliMUONChamberTrigger(ch),ch);
384 //PH AliMUONChamber* chamber = (AliMUONChamber*) (*fChambers)[ch];
385 AliMUONChamber* chamber = (AliMUONChamber*) fChambers->At(ch);
388 // Default values for Z of chambers
389 chamber->SetZ(AliMUONConstants::DefaultChamberZ(ch));
391 chamber->InitGeo(AliMUONConstants::DefaultChamberZ(ch));
392 // Set chamber inner and outer radius to default
393 chamber->SetRInner(AliMUONConstants::Dmin(st)/2);
394 chamber->SetROuter(AliMUONConstants::Dmax(st)/2);
396 } // Chamber stCH (0, 1) in
397 } // Station st (0...)
398 // fChambers->SetLast(AliMUONConstants::NCh());
411 // cp new design of AliMUONTriggerDecision
412 fTriggerCircuits = new TObjArray(AliMUONConstants::NTriggerCircuit());
413 for (Int_t circ=0; circ<AliMUONConstants::NTriggerCircuit(); circ++) {
414 fTriggerCircuits->AddAt(new AliMUONTriggerCircuit(),circ);
420 //___________________________________________
421 AliMUON::AliMUON(const AliMUON& rMUON)
423 // Dummy copy constructor
431 if(fDebug) printf("%s: Calling AliMUON destructor !!!\n",ClassName());
443 if (fTriggerCircuits){
444 fTriggerCircuits->Delete();
445 delete fTriggerCircuits;
449 fDchambers->Delete();
454 fRawClusters->Delete();
458 if (fNrawch) delete [] fNrawch;
460 // Delete TClonesArrays
468 fGlobalTrigger->Delete();
469 delete fGlobalTrigger;
474 fLocalTrigger->Delete();
475 delete fLocalTrigger;
484 if (fMerger) delete fMerger;
485 if (fNdch) delete [] fNdch;
489 //___________________________________________
490 void AliMUON::AddHit(Int_t track, Int_t *vol, Float_t *hits)
492 TClonesArray &lhits = *fHits;
493 new(lhits[fNhits++]) AliMUONHit(fIshunt,track,vol,hits);
495 //___________________________________________
496 void AliMUON::AddPadHit(Int_t *clhits)
498 TClonesArray &lclusters = *fPadHits;
499 new(lclusters[fNPadHits++]) AliMUONPadHit(clhits);
501 //_____________________________________________________________________________
502 void AliMUON::AddDigits(Int_t id, Int_t *tracks, Int_t *charges, Int_t *digits)
505 // Add a MUON digit to the list
508 //PH TClonesArray &ldigits = *((TClonesArray*)(*fDchambers)[id]);
509 TClonesArray &ldigits = *((TClonesArray*)fDchambers->At(id));
510 new(ldigits[fNdch[id]++]) AliMUONDigit(tracks,charges,digits);
513 //_____________________________________________________________________________
514 void AliMUON::AddRawCluster(Int_t id, const AliMUONRawCluster& c)
517 // Add a MUON digit to the list
520 //PH TClonesArray &lrawcl = *((TClonesArray*)(*fRawClusters)[id]);
521 TClonesArray &lrawcl = *((TClonesArray*)fRawClusters->At(id));
522 new(lrawcl[fNrawch[id]++]) AliMUONRawCluster(c);
525 //___________________________________________
526 void AliMUON::AddGlobalTrigger(Int_t *singlePlus, Int_t *singleMinus,
528 Int_t *pairUnlike, Int_t *pairLike)
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,
536 //___________________________________________
537 void AliMUON::AddLocalTrigger(Int_t *localtr)
539 // add a MUON Local Trigger to the list
540 TClonesArray &localTrigger = *fLocalTrigger;
541 new(localTrigger[fNLocalTrigger++]) AliMUONLocalTrigger(localtr);
544 //___________________________________________
545 void AliMUON::BuildGeometry()
547 // Geometry for event display
548 for (Int_t i=0; i<7; i++) {
549 for (Int_t j=0; j<2; j++) {
551 this->Chamber(id-1).SegmentationModel(1)->Draw("eventdisplay");
556 //___________________________________________
557 Int_t AliMUON::DistancetoPrimitive(Int_t , Int_t )
562 //___________________________________________
563 void AliMUON::MakeBranch(Option_t* option, const char *file)
566 // Create Tree branches for the MUON.
568 const Int_t kBufferSize = 4000;
570 sprintf(branchname,"%sCluster",GetName());
572 AliDetector::MakeBranch(option,file);
574 const char *cD = strstr(option,"D");
575 const char *cR = strstr(option,"R");
576 const char *cH = strstr(option,"H");
578 if (fPadHits && gAlice->TreeH() && cH) {
579 MakeBranchInTree(gAlice->TreeH(),
580 branchname, &fPadHits, kBufferSize, file);
585 // one branch for digits per chamber
589 for (i=0; i<AliMUONConstants::NCh() ;i++) {
590 sprintf(branchname,"%sDigits%d",GetName(),i+1);
591 if (fDchambers && gAlice->TreeD()) {
592 MakeBranchInTree(gAlice->TreeD(),
593 branchname, &((*fDchambers)[i]), kBufferSize, file);
594 printf("Making Branch %s for digits in chamber %d\n",branchname,i+1);
601 // one branch for raw clusters per chamber
603 printf("Make Branch - TreeR address %p\n",gAlice->TreeR());
607 for (i=0; i<AliMUONConstants::NTrackingCh() ;i++) {
608 sprintf(branchname,"%sRawClusters%d",GetName(),i+1);
609 if (fRawClusters && gAlice->TreeR()) {
610 MakeBranchInTree(gAlice->TreeR(),
611 branchname, &((*fRawClusters)[i]), kBufferSize, file);
612 printf("Making Branch %s for raw clusters in chamber %d\n",branchname,i+1);
616 // one branch for global trigger
618 sprintf(branchname,"%sGlobalTrigger",GetName());
619 if (fGlobalTrigger && gAlice->TreeR()) {
620 MakeBranchInTree(gAlice->TreeR(),
621 branchname, &fGlobalTrigger, kBufferSize, file);
622 printf("Making Branch %s for Global Trigger\n",branchname);
625 // one branch for local trigger
627 sprintf(branchname,"%sLocalTrigger",GetName());
628 if (fLocalTrigger && gAlice->TreeR()) {
629 MakeBranchInTree(gAlice->TreeR(),
630 branchname, &fLocalTrigger, kBufferSize, file);
631 printf("Making Branch %s for Local Trigger\n",branchname);
636 //___________________________________________
637 void AliMUON::SetTreeAddress()
639 // Set branch address for the Hits and Digits Tree.
641 AliDetector::SetTreeAddress();
644 TTree *treeH = gAlice->TreeH();
645 TTree *treeD = gAlice->TreeD();
646 TTree *treeR = gAlice->TreeR();
650 branch = treeH->GetBranch("MUONCluster");
651 if (branch) branch->SetAddress(&fPadHits);
656 for (int i=0; i<AliMUONConstants::NCh(); i++) {
657 sprintf(branchname,"%sDigits%d",GetName(),i+1);
659 branch = treeD->GetBranch(branchname);
660 if (branch) branch->SetAddress(&((*fDchambers)[i]));
665 // printf("SetTreeAddress --- treeR address %p \n",treeR);
668 for (int i=0; i<AliMUONConstants::NTrackingCh(); i++) {
669 sprintf(branchname,"%sRawClusters%d",GetName(),i+1);
671 branch = treeR->GetBranch(branchname);
672 if (branch) branch->SetAddress(&((*fRawClusters)[i]));
677 branch = treeR->GetBranch("MUONLocalTrigger");
678 if (branch) branch->SetAddress(&fLocalTrigger);
680 if (fGlobalTrigger) {
681 branch = treeR->GetBranch("MUONGlobalTrigger");
682 if (branch) branch->SetAddress(&fGlobalTrigger);
686 //___________________________________________
687 void AliMUON::ResetHits()
689 // Reset number of clusters and the cluster array for this detector
690 AliDetector::ResetHits();
692 if (fPadHits) fPadHits->Clear();
695 //____________________________________________
696 void AliMUON::ResetDigits()
699 // Reset number of digits and the digits array for this detector
701 for ( int i=0;i<AliMUONConstants::NCh();i++ ) {
702 //PH if ((*fDchambers)[i]) ((TClonesArray*)(*fDchambers)[i])->Clear();
703 if ((*fDchambers)[i]) ((TClonesArray*)fDchambers->At(i))->Clear();
704 if (fNdch) fNdch[i]=0;
707 //____________________________________________
708 void AliMUON::ResetRawClusters()
711 // Reset number of raw clusters and the raw clust array for this detector
713 for ( int i=0;i<AliMUONConstants::NTrackingCh();i++ ) {
714 //PH if ((*fRawClusters)[i]) ((TClonesArray*)(*fRawClusters)[i])->Clear();
715 if ((*fRawClusters)[i]) ((TClonesArray*)fRawClusters->At(i))->Clear();
716 if (fNrawch) fNrawch[i]=0;
720 //____________________________________________
721 void AliMUON::ResetTrigger()
723 // Reset Local and Global Trigger
725 if (fGlobalTrigger) fGlobalTrigger->Clear();
727 if (fLocalTrigger) fLocalTrigger->Clear();
730 //____________________________________________
731 void AliMUON::SetPadSize(Int_t id, Int_t isec, Float_t p1, Float_t p2)
733 // Set the pad size for chamber id and cathode isec
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);
741 //___________________________________________
742 void AliMUON::SetChambersZ(const Float_t *Z)
744 // Set Z values for all chambers (tracking and trigger)
745 // from the array pointed to by "Z"
746 for (Int_t ch = 0; ch < AliMUONConstants::NCh(); ch++)
747 //PH ((AliMUONChamber*) ((*fChambers)[ch]))->SetZ(Z[ch]);
748 ((AliMUONChamber*) fChambers->At(ch))->SetZ(Z[ch]);
752 //___________________________________________
753 void AliMUON::SetChambersZToDefault()
755 // Set Z values for all chambers (tracking and trigger)
757 SetChambersZ(AliMUONConstants::DefaultChamberZ());
761 //___________________________________________
762 void AliMUON::SetChargeSlope(Int_t id, Float_t p1)
764 // Set the inverse charge slope for chamber id
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);
772 //___________________________________________
773 void AliMUON::SetChargeSpread(Int_t id, Float_t p1, Float_t p2)
775 // Set sigma of charge spread for chamber id
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);
783 //___________________________________________
784 void AliMUON::SetSigmaIntegration(Int_t id, Float_t p1)
786 // Set integration limits for charge spread
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);
794 //___________________________________________
795 void AliMUON::SetMaxAdc(Int_t id, Int_t p1)
797 // Set maximum number for ADCcounts (saturation)
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);
805 //___________________________________________
806 void AliMUON::SetMaxStepGas(Float_t p1)
808 // Set stepsize in gas
812 //___________________________________________
813 void AliMUON::SetMaxStepAlu(Float_t p1)
815 // Set step size in Alu
819 //___________________________________________
820 void AliMUON::SetMaxDestepGas(Float_t p1)
822 // Set maximum step size in Gas
826 //___________________________________________
827 void AliMUON::SetMaxDestepAlu(Float_t p1)
829 // Set maximum step size in Alu
832 //___________________________________________
833 void AliMUON::SetAcceptance(Bool_t acc, Float_t angmin, Float_t angmax)
835 // Set acceptance cuts
837 fAccMin=angmin*TMath::Pi()/180;
838 fAccMax=angmax*TMath::Pi()/180;
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++) {
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));
852 //___________________________________________
853 void AliMUON::SetSegmentationModel(Int_t id, Int_t isec, AliSegmentation *segmentation)
855 // Set the segmentation for chamber id cathode isec
856 //PH ((AliMUONChamber*) (*fChambers)[id])->SetSegmentationModel(isec, segmentation);
857 ((AliMUONChamber*) fChambers->At(id))->SetSegmentationModel(isec, segmentation);
860 //___________________________________________
861 void AliMUON::SetResponseModel(Int_t id, AliMUONResponse *response)
863 // Set the response for chamber id
864 //PH ((AliMUONChamber*) (*fChambers)[id])->SetResponseModel(response);
865 ((AliMUONChamber*) fChambers->At(id))->SetResponseModel(response);
868 void AliMUON::SetReconstructionModel(Int_t id, AliMUONClusterFinderVS *reconst)
870 // Set ClusterFinder for chamber id
871 //PH ((AliMUONChamber*) (*fChambers)[id])->SetReconstructionModel(reconst);
872 ((AliMUONChamber*) fChambers->At(id))->SetReconstructionModel(reconst);
875 void AliMUON::SetNsec(Int_t id, Int_t nsec)
877 // Set number of segmented cathods for chamber id
878 //PH ((AliMUONChamber*) (*fChambers)[id])->SetNsec(nsec);
879 ((AliMUONChamber*) fChambers->At(id))->SetNsec(nsec);
882 //___________________________________________
883 void AliMUON::SDigits2Digits()
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;
893 fMerger = new AliMUONMerger();
898 sprintf(hname,"TreeD%d",gAlice->GetHeader()->GetEvent());
899 gAlice->TreeD()->Write(hname,TObject::kOverwrite);
900 gAlice->TreeD()->Reset();
903 //___________________________________________
904 void AliMUON::MakePadHits(Float_t xhit,Float_t yhit, Float_t zhit,
905 Float_t eloss, Float_t tof, Int_t idvol)
908 // Calls the charge disintegration method of the current chamber and adds
909 // the simulated cluster to the root treee
912 Float_t newclust[6][500];
917 // Integrated pulse height on chamber
923 // if (idvol == 6) printf("\n ->Disintegration %f %f %f", xhit, yhit, eloss );
926 //PH ((AliMUONChamber*) (*fChambers)[idvol])
927 ((AliMUONChamber*) fChambers->At(idvol))
928 ->DisIntegration(eloss, tof, xhit, yhit, zhit, nnew, newclust);
930 // if (idvol == 6) printf("\n nnew %d \n", nnew);
933 for (Int_t i=0; i<nnew; i++) {
934 if (Int_t(newclust[3][i]) > 0) {
937 clhits[1] = Int_t(newclust[5][i]);
939 clhits[2] = Int_t(newclust[0][i]);
941 clhits[3] = Int_t(newclust[1][i]);
943 clhits[4] = Int_t(newclust[2][i]);
945 clhits[5] = Int_t(newclust[3][i]);
946 // Pad: chamber sector
947 clhits[6] = Int_t(newclust[4][i]);
954 //___________________________________________
955 void AliMUON::Trigger(Int_t nev){
956 // call the Trigger Algorithm and fill TreeR
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};
965 AliMUONTriggerDecision* decision= new AliMUONTriggerDecision(1);
967 decision->GetGlobalTrigger(singlePlus, singleMinus, singleUndef,
968 pairUnlike, pairLike);
969 // add a local trigger in the list
970 AddGlobalTrigger(singlePlus, singleMinus, singleUndef, pairUnlike, pairLike);
973 for (Int_t icirc=0; icirc<AliMUONConstants::NTriggerCircuit(); icirc++) {
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);
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));
987 AddLocalTrigger(localtr); // add a local trigger in the list
992 gAlice->TreeR()->Fill();
995 sprintf(hname,"TreeR%d",nev);
996 gAlice->TreeR()->Write(hname,TObject::kOverwrite);
997 gAlice->TreeR()->Reset();
998 printf("\n End of trigger for event %d", nev);
1002 //____________________________________________
1003 void AliMUON::Digits2Reco()
1006 Int_t nev = gAlice->GetHeader()->GetEvent();
1007 gAlice->TreeR()->Fill();
1009 sprintf(hname,"TreeR%d", nev);
1010 gAlice->TreeR()->Write(hname);
1011 gAlice->TreeR()->Reset();
1013 printf("\n End of cluster finding for event %d", nev);
1016 void AliMUON::FindClusters()
1019 // Perform cluster finding
1021 TClonesArray *dig1, *dig2;
1023 dig1 = new TClonesArray("AliMUONDigit",1000);
1024 dig2 = new TClonesArray("AliMUONDigit",1000);
1025 AliMUONDigit *digit;
1027 // Loop on chambers and on cathode planes
1030 for (Int_t ich = 0; ich < 10; ich++) {
1031 //PH AliMUONChamber* iChamber = (AliMUONChamber*) (*fChambers)[ich];
1032 AliMUONChamber* iChamber = (AliMUONChamber*) fChambers->At(ich);
1033 AliMUONClusterFinderVS* rec = iChamber->ReconstructionModel();
1035 gAlice->ResetDigits();
1036 gAlice->TreeD()->GetEvent(0);
1037 TClonesArray *muonDigits = this->DigitsAddress(ich);
1038 ndig=muonDigits->GetEntriesFast();
1039 printf("\n 1 Found %d digits in %p %d", ndig, muonDigits,ich);
1040 TClonesArray &lhits1 = *dig1;
1042 for (k = 0; k < ndig; k++) {
1043 digit = (AliMUONDigit*) muonDigits->UncheckedAt(k);
1044 if (rec->TestTrack(digit->Track(0)))
1045 new(lhits1[n++]) AliMUONDigit(*digit);
1047 gAlice->ResetDigits();
1048 gAlice->TreeD()->GetEvent(1);
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;
1055 for (k=0; k<ndig; k++) {
1056 digit= (AliMUONDigit*) muonDigits->UncheckedAt(k);
1057 if (rec->TestTrack(digit->Track(0)))
1058 new(lhits2[n++]) AliMUONDigit(*digit);
1062 AliMUONClusterInput::Instance()->SetDigits(ich, dig1, dig2);
1063 rec->FindRawClusters();
1073 void AliMUON::Streamer(TBuffer &R__b)
1075 // Stream an object of class AliMUON.
1076 AliMUONChamber *iChamber;
1077 AliMUONTriggerCircuit *iTriggerCircuit;
1078 AliSegmentation *segmentation;
1079 AliMUONResponse *response;
1080 TClonesArray *digitsaddress;
1081 TClonesArray *rawcladdress;
1083 if (R__b.IsReading()) {
1084 Version_t R__v = R__b.ReadVersion(); if (R__v) { }
1085 AliDetector::Streamer(R__b);
1087 R__b >> fPadHits; // diff
1088 R__b >> fNLocalTrigger;
1089 R__b >> fLocalTrigger;
1090 R__b >> fNGlobalTrigger;
1091 R__b >> fGlobalTrigger;
1093 R__b >> fRawClusters;
1094 R__b.ReadArray(fNdch);
1095 R__b.ReadArray(fNrawch);
1100 R__b >> fTriggerCircuits;
1101 for (i =0; i<AliMUONConstants::NTriggerCircuit(); i++) {
1102 iTriggerCircuit=(AliMUONTriggerCircuit*) (*fTriggerCircuits)[i];
1103 iTriggerCircuit->Streamer(R__b);
1105 // Stream chamber related information
1106 for (i =0; i<AliMUONConstants::NCh(); i++) {
1107 iChamber=(AliMUONChamber*) (*fChambers)[i];
1108 iChamber->Streamer(R__b);
1109 if (iChamber->Nsec()==1) {
1110 segmentation=iChamber->SegmentationModel(1);
1112 segmentation->Streamer(R__b);
1114 segmentation=iChamber->SegmentationModel(1);
1116 segmentation->Streamer(R__b);
1118 segmentation=iChamber->SegmentationModel(2);
1119 segmentation->Streamer(R__b);
1121 response=iChamber->ResponseModel();
1123 response->Streamer(R__b);
1124 digitsaddress=(TClonesArray*) (*fDchambers)[i];
1125 digitsaddress->Streamer(R__b);
1126 if (i < AliMUONConstants::NTrackingCh()) {
1127 rawcladdress=(TClonesArray*) (*fRawClusters)[i];
1128 rawcladdress->Streamer(R__b);
1133 R__b.WriteVersion(AliMUON::IsA());
1134 AliDetector::Streamer(R__b);
1136 R__b << fPadHits; // diff
1137 R__b << fNLocalTrigger;
1138 R__b << fLocalTrigger;
1139 R__b << fNGlobalTrigger;
1140 R__b << fGlobalTrigger;
1142 R__b << fRawClusters;
1143 R__b.WriteArray(fNdch, AliMUONConstants::NCh());
1144 R__b.WriteArray(fNrawch, AliMUONConstants::NTrackingCh());
1151 R__b << fTriggerCircuits;
1152 for (i =0; i<AliMUONConstants::NTriggerCircuit(); i++) {
1153 iTriggerCircuit=(AliMUONTriggerCircuit*) (*fTriggerCircuits)[i];
1154 iTriggerCircuit->Streamer(R__b);
1156 for (i =0; i<AliMUONConstants::NCh(); i++) {
1157 iChamber=(AliMUONChamber*) (*fChambers)[i];
1158 iChamber->Streamer(R__b);
1159 if (iChamber->Nsec()==1) {
1160 segmentation=iChamber->SegmentationModel(1);
1162 segmentation->Streamer(R__b);
1164 segmentation=iChamber->SegmentationModel(1);
1166 segmentation->Streamer(R__b);
1167 segmentation=iChamber->SegmentationModel(2);
1169 segmentation->Streamer(R__b);
1171 response=iChamber->ResponseModel();
1173 response->Streamer(R__b);
1174 digitsaddress=(TClonesArray*) (*fDchambers)[i];
1175 digitsaddress->Streamer(R__b);
1176 if (i < AliMUONConstants::NTrackingCh()) {
1177 rawcladdress=(TClonesArray*) (*fRawClusters)[i];
1178 rawcladdress->Streamer(R__b);
1185 AliMUONPadHit* AliMUON::FirstPad(AliMUONHit* hit, TClonesArray *clusters)
1188 // Initialise the pad iterator
1189 // Return the address of the first padhit for hit
1190 TClonesArray *theClusters = clusters;
1191 Int_t nclust = theClusters->GetEntriesFast();
1192 if (nclust && hit->PHlast() > 0) {
1193 AliMUON::fMaxIterPad=hit->PHlast();
1194 AliMUON::fCurIterPad=hit->PHfirst();
1195 return (AliMUONPadHit*) clusters->UncheckedAt(AliMUON::fCurIterPad-1);
1201 AliMUONPadHit* AliMUON::NextPad(TClonesArray *clusters)
1203 // Get next pad (in iterator)
1205 AliMUON::fCurIterPad++;
1206 if (AliMUON::fCurIterPad <= AliMUON::fMaxIterPad) {
1207 return (AliMUONPadHit*) clusters->UncheckedAt(AliMUON::fCurIterPad-1);
1214 AliMUONRawCluster *AliMUON::RawCluster(Int_t ichamber, Int_t icathod, Int_t icluster)
1217 // Return rawcluster (icluster) for chamber ichamber and cathode icathod
1219 TClonesArray *muonRawCluster = RawClustAddress(ichamber);
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();
1227 AliMUONRawCluster * mRaw = (AliMUONRawCluster*)muonRawCluster->UncheckedAt(icluster);
1228 //printf("RawCluster _ nent nrawcl icluster mRaw %d %d %d%p\n",nent,nrawcl,icluster,mRaw);
1233 void AliMUON::SetMerger(AliMUONMerger* merger)
1235 // Set pointer to merger
1239 AliMUONMerger* AliMUON::Merger()
1241 // Return pointer to merger
1247 AliMUON& AliMUON::operator = (const AliMUON& rhs)
1254 ////////////////////////////////////////////////////////////////////////
1255 void AliMUON::MakeBranchInTreeD(TTree *treeD, const char *file)
1258 // Create TreeD branches for the MUON.
1261 const Int_t kBufferSize = 4000;
1262 char branchname[30];
1265 // one branch for digits per chamber
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);
1272 // printf("Making Branch %s for digits in chamber %d\n",branchname,i+1);
1277 //___________________________________________