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 **************************************************************************/
19 ///////////////////////////////////////////////
20 // Manager and hits classes for set:MUON //
21 ////////////////////////////////////////////////
23 #include "Riostream.h"
28 #include <TDirectory.h>
30 #include <TGeometry.h>
34 #include <TObjArray.h>
36 #include <TObjectTable.h>
38 #include <TParticle.h>
41 #include <TRotMatrix.h>
46 #include <TVirtualMC.h>
49 #include "AliHeader.h"
50 #include "AliHitMap.h"
51 #include "AliLoader.h"
53 #include "AliMUONChamberTrigger.h"
54 #include "AliMUONClusterFinderVS.h"
55 #include "AliMUONClusterInput.h"
56 #include "AliMUONConstants.h"
57 #include "AliMUONDigit.h"
58 #include "AliMUONGlobalTrigger.h"
59 #include "AliMUONHit.h"
60 #include "AliMUONHitMapA1.h"
61 #include "AliMUONLocalTrigger.h"
62 #include "AliMUONMerger.h"
63 #include "AliMUONPadHit.h"
64 #include "AliMUONRawCluster.h"
65 #include "AliMUONTransientDigit.h"
66 #include "AliMUONTriggerCircuit.h"
67 #include "AliMUONTriggerDecision.h"
71 // Defaults parameters for Z positions of chambers
72 // taken from values for "stations" in AliMUON::AliMUON
73 // const Float_t zch[7]={528, 690., 975., 1249., 1449., 1610, 1710.};
74 // and from array "dstation" in AliMUONv1::CreateGeometry
75 // Float_t dstation[5]={20., 20., 20, 20., 20.};
76 // for tracking chambers,
77 // according to (Z1 = zch - dstation) and (Z2 = zch + dstation)
78 // for the first and second chambers in the station, respectively,
79 // and from "DTPLANES" in AliMUONv1::CreateGeometry
80 // const Float_t DTPLANES = 15.;
81 // for trigger chambers,
82 // according to (Z1 = zch) and (Z2 = zch + DTPLANES)
83 // for the first and second chambers in the station, respectively
86 //___________________________________________
89 // Default Constructor
113 //___________________________________________
114 AliMUON::AliMUON(const char *name, const char *title)
115 : AliDetector(name,title)
119 <img src="gif/alimuon.gif">
123 fHits = new TClonesArray("AliMUONHit",1000);
124 gAlice->AddHitList(fHits);
125 fPadHits = new TClonesArray("AliMUONPadHit",10000);
129 fNCh = AliMUONConstants::NCh();
130 fNTrackingCh = AliMUONConstants::NTrackingCh();
131 fNdch = new Int_t[fNCh];
133 fDchambers = new TObjArray(AliMUONConstants::NCh());
137 for (i=0; i<AliMUONConstants::NCh() ;i++) {
138 fDchambers->AddAt(new TClonesArray("AliMUONDigit",10000),i);
142 fNrawch = new Int_t[fNTrackingCh];
144 fRawClusters = new TObjArray(AliMUONConstants::NTrackingCh());
146 for (i=0; i<AliMUONConstants::NTrackingCh();i++) {
147 fRawClusters->AddAt(new TClonesArray("AliMUONRawCluster",10000),i);
151 fGlobalTrigger = new TClonesArray("AliMUONGlobalTrigger",1);
153 fLocalTrigger = new TClonesArray("AliMUONLocalTrigger",234);
156 SetMarkerColor(kRed);
164 fChambers = new TObjArray(AliMUONConstants::NCh());
166 // Loop over stations
167 for (Int_t st = 0; st < AliMUONConstants::NCh() / 2; st++) {
168 // Loop over 2 chambers in the station
169 for (Int_t stCH = 0; stCH < 2; stCH++) {
172 // Default Parameters for Muon Tracking Stations
177 if (ch < AliMUONConstants::NTrackingCh()) {
178 fChambers->AddAt(new AliMUONChamber(ch),ch);
180 fChambers->AddAt(new AliMUONChamberTrigger(ch),ch);
183 //PH AliMUONChamber* chamber = (AliMUONChamber*) (*fChambers)[ch];
184 AliMUONChamber* chamber = (AliMUONChamber*) fChambers->At(ch);
187 // Default values for Z of chambers
188 chamber->SetZ(AliMUONConstants::DefaultChamberZ(ch));
190 chamber->InitGeo(AliMUONConstants::DefaultChamberZ(ch));
191 // Set chamber inner and outer radius to default
192 chamber->SetRInner(AliMUONConstants::Dmin(st)/2);
193 chamber->SetROuter(AliMUONConstants::Dmax(st)/2);
195 } // Chamber stCH (0, 1) in
196 } // Station st (0...)
197 // fChambers->SetLast(AliMUONConstants::NCh());
210 // cp new design of AliMUONTriggerDecision
211 fTriggerCircuits = new TObjArray(AliMUONConstants::NTriggerCircuit());
212 for (Int_t circ=0; circ<AliMUONConstants::NTriggerCircuit(); circ++) {
213 fTriggerCircuits->AddAt(new AliMUONTriggerCircuit(),circ);
219 //___________________________________________
220 AliMUON::AliMUON(const AliMUON& rMUON):AliDetector(rMUON)
222 // Dummy copy constructor
230 if(fDebug) printf("%s: Calling AliMUON destructor !!!\n",ClassName());
241 if (fTriggerCircuits){
242 fTriggerCircuits->Delete();
243 delete fTriggerCircuits;
247 fDchambers->Delete();
252 fRawClusters->Delete();
256 if (fNrawch) delete [] fNrawch;
258 // Delete TClonesArrays
266 fGlobalTrigger->Delete();
267 delete fGlobalTrigger;
272 fLocalTrigger->Delete();
273 delete fLocalTrigger;
282 if (fMerger) delete fMerger;
283 if (fNdch) delete [] fNdch;
287 //___________________________________________
288 void AliMUON::AddHit(Int_t track, Int_t *vol, Float_t *hits)
290 TClonesArray &lhits = *fHits;
291 new(lhits[fNhits++]) AliMUONHit(fIshunt,track,vol,hits);
293 //___________________________________________
294 void AliMUON::AddHit(Int_t fIshunt, Int_t track, Int_t iChamber,
295 Int_t idpart, Float_t X, Float_t Y, Float_t Z,
296 Float_t tof, Float_t momentum, Float_t theta,
297 Float_t phi, Float_t length, Float_t destep)
299 TClonesArray &lhits = *fHits;
300 new(lhits[fNhits++]) AliMUONHit(fIshunt, track, iChamber,
302 tof, momentum, theta,
303 phi, length, destep);
305 //___________________________________________
306 void AliMUON::AddPadHit(Int_t *clhits) // To be removed
308 TClonesArray &lclusters = *fPadHits;
309 new(lclusters[fNPadHits++]) AliMUONPadHit(clhits);
311 //_____________________________________________________________________________
312 void AliMUON::AddDigits(Int_t id, Int_t *tracks, Int_t *charges, Int_t *digits)
315 // Add a MUON digit to the list
318 //PH TClonesArray &ldigits = * ((TClonesArray*)(*fDchambers)[id]);
319 TClonesArray &ldigits = * ( (TClonesArray*) fDchambers->At(id) );
320 new(ldigits[fNdch[id]++]) AliMUONDigit(tracks,charges,digits);
323 //_____________________________________________________________________________
324 void AliMUON::AddRawCluster(Int_t id, const AliMUONRawCluster& c)
327 // Add a MUON digit to the list
330 //PH TClonesArray &lrawcl = *((TClonesArray*)(*fRawClusters)[id]);
331 TClonesArray &lrawcl = *((TClonesArray*)fRawClusters->At(id));
332 new(lrawcl[fNrawch[id]++]) AliMUONRawCluster(c);
335 //___________________________________________
336 void AliMUON::AddGlobalTrigger(Int_t *singlePlus, Int_t *singleMinus,
338 Int_t *pairUnlike, Int_t *pairLike)
340 // add a MUON Global Trigger to the list (only one GlobalTrigger per event !)
341 TClonesArray &globalTrigger = *fGlobalTrigger;
342 new(globalTrigger[fNGlobalTrigger++])
343 AliMUONGlobalTrigger(singlePlus, singleMinus, singleUndef, pairUnlike,
346 //___________________________________________
347 void AliMUON::AddLocalTrigger(Int_t *localtr)
349 // add a MUON Local Trigger to the list
350 TClonesArray &localTrigger = *fLocalTrigger;
351 new(localTrigger[fNLocalTrigger++]) AliMUONLocalTrigger(localtr);
354 //___________________________________________
355 void AliMUON::BuildGeometry()
357 // Geometry for event display
358 for (Int_t i=0; i<7; i++) {
359 for (Int_t j=0; j<2; j++) {
361 this->Chamber(id-1).SegmentationModel(1)->Draw("eventdisplay");
366 //___________________________________________
367 Int_t AliMUON::DistancetoPrimitive(Int_t , Int_t )
372 //___________________________________________
373 void AliMUON::MakeBranch(Option_t* option)
376 // Create Tree branches for the MUON.
378 const Int_t kBufferSize = 4000;
380 sprintf(branchname,"%sCluster",GetName());
383 const char *cD = strstr(option,"D");
384 const char *cR = strstr(option,"R");
385 const char *cH = strstr(option,"H");
389 if (fPadHits == 0x0) fPadHits = new TClonesArray("AliMUONPadHit",10000);
390 MakeBranchInTree(TreeH(), branchname, &fPadHits, kBufferSize, 0);
391 if (fHits == 0x0) fHits = new TClonesArray("AliMUONHit",1000);
393 //it must be under fHits creation
394 AliDetector::MakeBranch(option);
396 if (cD && fLoader->TreeD()) {
398 // one branch for digits per chamber
401 if (fDchambers == 0x0)
403 fDchambers = new TObjArray(AliMUONConstants::NCh());
404 for (Int_t i=0; i<AliMUONConstants::NCh() ;i++) {
405 fDchambers->AddAt(new TClonesArray("AliMUONDigit",10000),i);
409 for (i=0; i<AliMUONConstants::NCh() ;i++)
411 sprintf(branchname,"%sDigits%d",GetName(),i+1);
412 MakeBranchInTree(fLoader->TreeD(), branchname, &((*fDchambers)[i]), kBufferSize, 0);
413 printf("Making Branch %s for digits in chamber %d\n",branchname,i+1);
417 if (cR && fLoader->TreeR()) {
419 // one branch for raw clusters per chamber
421 printf("Make Branch - TreeR address %p\n",fLoader->TreeR());
424 if (fRawClusters == 0x0)
426 fRawClusters = new TObjArray(AliMUONConstants::NTrackingCh());
427 for (Int_t i=0; i<AliMUONConstants::NTrackingCh();i++) {
428 fRawClusters->AddAt(new TClonesArray("AliMUONRawCluster",10000),i);
432 for (i=0; i<AliMUONConstants::NTrackingCh() ;i++)
434 sprintf(branchname,"%sRawClusters%d",GetName(),i+1);
435 MakeBranchInTree(fLoader->TreeR(), branchname, &((*fRawClusters)[i]), kBufferSize, 0);
436 printf("Making Branch %s for raw clusters in chamber %d\n",branchname,i+1);
439 // one branch for global trigger
441 sprintf(branchname,"%sGlobalTrigger",GetName());
443 if (fGlobalTrigger == 0x0) {
444 fGlobalTrigger = new TClonesArray("AliMUONGlobalTrigger",1);
446 MakeBranchInTree(fLoader->TreeR(), branchname, &fGlobalTrigger, kBufferSize, 0);
447 printf("Making Branch %s for Global Trigger\n",branchname);
449 // one branch for local trigger
451 sprintf(branchname,"%sLocalTrigger",GetName());
453 if (fLocalTrigger == 0x0) {
454 fLocalTrigger = new TClonesArray("AliMUONLocalTrigger",234);
457 MakeBranchInTree(fLoader->TreeR(), branchname, &fLocalTrigger, kBufferSize, 0);
458 printf("Making Branch %s for Local Trigger\n",branchname);
462 //___________________________________________
463 void AliMUON::SetTreeAddress()
465 // Set branch address for the Hits and Digits Tree.
469 TTree *treeH = fLoader->TreeH();
470 TTree *treeD = fLoader->TreeD();
471 TTree *treeR = fLoader->TreeR();
474 if (fPadHits == 0x0) fPadHits = new TClonesArray("AliMUONPadHit",10000);
476 branch = treeH->GetBranch("MUONCluster");
477 if (branch) branch->SetAddress(&fPadHits);
479 if (fHits == 0x0) fHits = new TClonesArray("AliMUONHit",1000);
481 //it must be under fHits creation
482 AliDetector::SetTreeAddress();
485 if (fDchambers == 0x0)
487 fDchambers = new TObjArray(AliMUONConstants::NCh());
488 for (Int_t i=0; i<AliMUONConstants::NCh() ;i++) {
489 fDchambers->AddAt(new TClonesArray("AliMUONDigit",10000),i);
492 for (int i=0; i<AliMUONConstants::NCh(); i++) {
493 sprintf(branchname,"%sDigits%d",GetName(),i+1);
496 branch = treeD->GetBranch(branchname);
497 if (branch) branch->SetAddress(&((*fDchambers)[i]));
502 // printf("SetTreeAddress --- treeR address %p \n",treeR);
505 if (fRawClusters == 0x0)
507 fRawClusters = new TObjArray(AliMUONConstants::NTrackingCh());
508 for (Int_t i=0; i<AliMUONConstants::NTrackingCh();i++) {
509 fRawClusters->AddAt(new TClonesArray("AliMUONRawCluster",10000),i);
513 for (int i=0; i<AliMUONConstants::NTrackingCh(); i++) {
514 sprintf(branchname,"%sRawClusters%d",GetName(),i+1);
516 branch = treeR->GetBranch(branchname);
517 if (branch) branch->SetAddress(&((*fRawClusters)[i]));
521 if (fLocalTrigger == 0x0) {
522 fLocalTrigger = new TClonesArray("AliMUONLocalTrigger",234);
526 branch = treeR->GetBranch("MUONLocalTrigger");
527 if (branch) branch->SetAddress(&fLocalTrigger);
530 if (fGlobalTrigger == 0x0) {
531 fGlobalTrigger = new TClonesArray("AliMUONGlobalTrigger",1);
534 if (fGlobalTrigger) {
535 branch = treeR->GetBranch("MUONGlobalTrigger");
536 if (branch) branch->SetAddress(&fGlobalTrigger);
540 //___________________________________________
541 void AliMUON::ResetHits()
543 // Reset number of clusters and the cluster array for this detector
544 AliDetector::ResetHits();
546 if (fPadHits) fPadHits->Clear();
549 //____________________________________________
550 void AliMUON::ResetDigits()
553 // Reset number of digits and the digits array for this detector
555 if (fDchambers == 0x0) return;
556 for ( int i=0;i<AliMUONConstants::NCh();i++ ) {
557 //PH if ((*fDchambers)[i]) ((TClonesArray*)(*fDchambers)[i])->Clear();
558 if ((*fDchambers)[i]) ((TClonesArray*)fDchambers->At(i))->Clear();
559 if (fNdch) fNdch[i]=0;
562 //____________________________________________
563 void AliMUON::ResetRawClusters()
566 // Reset number of raw clusters and the raw clust array for this detector
568 for ( int i=0;i<AliMUONConstants::NTrackingCh();i++ ) {
569 //PH if ((*fRawClusters)[i]) ((TClonesArray*)(*fRawClusters)[i])->Clear();
570 if ((*fRawClusters)[i]) ((TClonesArray*)fRawClusters->At(i))->Clear();
571 if (fNrawch) fNrawch[i]=0;
575 //____________________________________________
576 void AliMUON::ResetTrigger()
578 // Reset Local and Global Trigger
580 if (fGlobalTrigger) fGlobalTrigger->Clear();
582 if (fLocalTrigger) fLocalTrigger->Clear();
585 //____________________________________________
586 void AliMUON::SetPadSize(Int_t id, Int_t isec, Float_t p1, Float_t p2)
588 // Set the pad size for chamber id and cathode isec
590 //PH ((AliMUONChamber*) (*fChambers)[i]) ->SetPadSize(isec,p1,p2);
591 //PH ((AliMUONChamber*) (*fChambers)[i+1])->SetPadSize(isec,p1,p2);
592 ((AliMUONChamber*) fChambers->At(i)) ->SetPadSize(isec,p1,p2);
593 ((AliMUONChamber*) fChambers->At(i+1))->SetPadSize(isec,p1,p2);
596 //___________________________________________
597 void AliMUON::SetChambersZ(const Float_t *Z)
599 // Set Z values for all chambers (tracking and trigger)
600 // from the array pointed to by "Z"
601 for (Int_t ch = 0; ch < AliMUONConstants::NCh(); ch++)
602 //PH ((AliMUONChamber*) ((*fChambers)[ch]))->SetZ(Z[ch]);
603 ((AliMUONChamber*) fChambers->At(ch))->SetZ(Z[ch]);
607 //___________________________________________
608 void AliMUON::SetChambersZToDefault()
610 // Set Z values for all chambers (tracking and trigger)
612 SetChambersZ(AliMUONConstants::DefaultChamberZ());
616 //___________________________________________
617 void AliMUON::SetChargeSlope(Int_t id, Float_t p1)
619 // Set the inverse charge slope for chamber id
621 //PH ((AliMUONChamber*) (*fChambers)[i])->SetChargeSlope(p1);
622 //PH ((AliMUONChamber*) (*fChambers)[i+1])->SetChargeSlope(p1);
623 ((AliMUONChamber*) fChambers->At(i))->SetChargeSlope(p1);
624 ((AliMUONChamber*) fChambers->At(i+1))->SetChargeSlope(p1);
627 //___________________________________________
628 void AliMUON::SetChargeSpread(Int_t id, Float_t p1, Float_t p2)
630 // Set sigma of charge spread for chamber id
632 //PH ((AliMUONChamber*) fChambers->At(i))->SetChargeSpread(p1,p2);
633 //PH ((AliMUONChamber*) fChambers->Ati+1])->SetChargeSpread(p1,p2);
634 ((AliMUONChamber*) fChambers->At(i))->SetChargeSpread(p1,p2);
635 ((AliMUONChamber*) fChambers->At(i+1))->SetChargeSpread(p1,p2);
638 //___________________________________________
639 void AliMUON::SetSigmaIntegration(Int_t id, Float_t p1)
641 // Set integration limits for charge spread
643 //PH ((AliMUONChamber*) (*fChambers)[i])->SetSigmaIntegration(p1);
644 //PH ((AliMUONChamber*) (*fChambers)[i+1])->SetSigmaIntegration(p1);
645 ((AliMUONChamber*) fChambers->At(i))->SetSigmaIntegration(p1);
646 ((AliMUONChamber*) fChambers->At(i+1))->SetSigmaIntegration(p1);
649 //___________________________________________
650 void AliMUON::SetMaxAdc(Int_t id, Int_t p1)
652 // Set maximum number for ADCcounts (saturation)
654 //PH ((AliMUONChamber*) (*fChambers)[i])->SetMaxAdc(p1);
655 //PH ((AliMUONChamber*) (*fChambers)[i+1])->SetMaxAdc(p1);
656 ((AliMUONChamber*) fChambers->At(i))->SetMaxAdc(p1);
657 ((AliMUONChamber*) fChambers->At(i+1))->SetMaxAdc(p1);
660 //___________________________________________
661 void AliMUON::SetMaxStepGas(Float_t p1)
663 // Set stepsize in gas
667 //___________________________________________
668 void AliMUON::SetMaxStepAlu(Float_t p1)
670 // Set step size in Alu
674 //___________________________________________
675 void AliMUON::SetMaxDestepGas(Float_t p1)
677 // Set maximum step size in Gas
681 //___________________________________________
682 void AliMUON::SetMaxDestepAlu(Float_t p1)
684 // Set maximum step size in Alu
687 //___________________________________________
688 void AliMUON::SetAcceptance(Bool_t acc, Float_t angmin, Float_t angmax)
690 // Set acceptance cuts
692 fAccMin=angmin*TMath::Pi()/180;
693 fAccMax=angmax*TMath::Pi()/180;
696 for (Int_t st = 0; st < AliMUONConstants::NCh() / 2; st++) {
697 // Loop over 2 chambers in the station
698 for (Int_t stCH = 0; stCH < 2; stCH++) {
700 // Set chamber inner and outer radius according to acceptance cuts
701 Chamber(ch).SetRInner(AliMUONConstants::DefaultChamberZ(ch)*TMath::Tan(fAccMin));
702 Chamber(ch).SetROuter(AliMUONConstants::DefaultChamberZ(ch)*TMath::Tan(fAccMax));
707 //___________________________________________
708 void AliMUON::SetSegmentationModel(Int_t id, Int_t isec, AliSegmentation *segmentation)
710 // Set the segmentation for chamber id cathode isec
711 //PH ((AliMUONChamber*) (*fChambers)[id])->SetSegmentationModel(isec, segmentation);
712 ((AliMUONChamber*) fChambers->At(id))->SetSegmentationModel(isec, segmentation);
715 //___________________________________________
716 void AliMUON::SetResponseModel(Int_t id, AliMUONResponse *response)
718 // Set the response for chamber id
719 //PH ((AliMUONChamber*) (*fChambers)[id])->SetResponseModel(response);
720 ((AliMUONChamber*) fChambers->At(id))->SetResponseModel(response);
723 void AliMUON::SetReconstructionModel(Int_t id, AliMUONClusterFinderVS *reconst)
725 // Set ClusterFinder for chamber id
726 //PH ((AliMUONChamber*) (*fChambers)[id])->SetReconstructionModel(reconst);
727 ((AliMUONChamber*) fChambers->At(id))->SetReconstructionModel(reconst);
730 void AliMUON::SetNsec(Int_t id, Int_t nsec)
732 // Set number of segmented cathods for chamber id
733 //PH ((AliMUONChamber*) (*fChambers)[id])->SetNsec(nsec);
734 ((AliMUONChamber*) fChambers->At(id))->SetNsec(nsec);
737 //___________________________________________
738 void AliMUON::SDigits2Digits()
744 if (gAlice->GetDebug()>0) {
745 cerr<<"AliMUON::SDigits2Digits: create default AliMUONMerger "<<endl;
746 cerr<<" no merging, just digitization of 1 event will be done"<<endl;
748 fMerger = new AliMUONMerger();
753 // sprintf(hname,"TreeD%d",fLoader->GetHeader()->GetEvent());
754 fLoader->TreeD()->Write(hname,TObject::kOverwrite);
755 fLoader->TreeD()->Reset();
758 //___________________________________________
760 void AliMUON::MakePadHits(Float_t xhit,Float_t yhit, Float_t zhit,
761 Float_t eloss, Float_t tof, Int_t idvol)
764 // Calls the charge disintegration method of the current chamber and adds
765 // the simulated cluster to the root treee
768 Float_t newclust[6][500];
773 // Integrated pulse height on chamber
779 // if (idvol == 6) printf("\n ->Disintegration %f %f %f", xhit, yhit, eloss );
782 //PH ((AliMUONChamber*) (*fChambers)[idvol])
783 ((AliMUONChamber*) fChambers->At(idvol))
784 ->DisIntegration(eloss, tof, xhit, yhit, zhit, nnew, newclust);
786 // if (idvol == 6) printf("\n nnew %d \n", nnew);
789 for (Int_t i=0; i<nnew; i++) {
790 if (Int_t(newclust[3][i]) > 0) {
793 clhits[1] = Int_t(newclust[5][i]);
795 clhits[2] = Int_t(newclust[0][i]);
797 clhits[3] = Int_t(newclust[1][i]);
799 clhits[4] = Int_t(newclust[2][i]);
801 clhits[5] = Int_t(newclust[3][i]);
802 // Pad: chamber sector
803 clhits[6] = Int_t(newclust[4][i]);
810 //___________________________________________
811 void AliMUON::Trigger(Int_t nev){
812 // call the Trigger Algorithm and fill TreeR
814 Int_t singlePlus[3] = {0,0,0};
815 Int_t singleMinus[3] = {0,0,0};
816 Int_t singleUndef[3] = {0,0,0};
817 Int_t pairUnlike[3] = {0,0,0};
818 Int_t pairLike[3] = {0,0,0};
821 AliMUONTriggerDecision* decision= new AliMUONTriggerDecision(1);
823 decision->GetGlobalTrigger(singlePlus, singleMinus, singleUndef,
824 pairUnlike, pairLike);
826 // add a local trigger in the list
827 AddGlobalTrigger(singlePlus, singleMinus, singleUndef, pairUnlike, pairLike);
830 for (Int_t icirc=0; icirc<AliMUONConstants::NTriggerCircuit(); icirc++) {
831 if(decision->GetITrigger(icirc)==1) {
832 Int_t localtr[7]={0,0,0,0,0,0,0};
833 Int_t loLpt[2]={0,0}; Int_t loHpt[2]={0,0}; Int_t loApt[2]={0,0};
834 decision->GetLutOutput(icirc, loLpt, loHpt, loApt);
836 localtr[1] = decision->GetStripX11(icirc);
837 localtr[2] = decision->GetDev(icirc);
838 localtr[3] = decision->GetStripY11(icirc);
839 for (i=0; i<2; i++) { // convert the Lut output in 1 digit
840 localtr[4] = localtr[4]+Int_t(loLpt[i]*TMath::Power(2,i));
841 localtr[5] = localtr[5]+Int_t(loHpt[i]*TMath::Power(2,i));
842 localtr[6] = localtr[6]+Int_t(loApt[i]*TMath::Power(2,i));
844 AddLocalTrigger(localtr); // add a local trigger in the list
850 fLoader->TreeR()->Fill();
852 // sprintf(hname,"TreeR%d",nev);
853 // fLoader->TreeR()->Write(hname,TObject::kOverwrite);
854 // fLoader->TreeR()->Reset();
855 fLoader->WriteRecPoints("OVERWRITE");
858 printf("\n End of trigger for event %d", nev);
862 //____________________________________________
863 void AliMUON::Digits2Reco()
866 Int_t nev = gAlice->GetHeader()->GetEvent();
867 fLoader->TreeR()->Fill();
869 // sprintf(hname,"TreeR%d", nev);
870 //fLoader->TreeR()->Write(hname);
871 //fLoader->TreeR()->Reset();
872 fLoader->WriteRecPoints("OVERWRITE");
874 printf("\n End of cluster finding for event %d", nev);
877 void AliMUON::FindClusters()
880 // Perform cluster finding
882 TClonesArray *dig1, *dig2;
884 dig1 = new TClonesArray("AliMUONDigit",1000);
885 dig2 = new TClonesArray("AliMUONDigit",1000);
887 // Loop on chambers and on cathode planes
890 TClonesArray * muonDigits;
892 for (Int_t ich = 0; ich < 10; ich++) {
893 //PH AliMUONChamber* iChamber = (AliMUONChamber*) (*fChambers)[ich];
894 AliMUONChamber* iChamber = (AliMUONChamber*) fChambers->At(ich);
895 AliMUONClusterFinderVS* rec = iChamber->ReconstructionModel();
898 fLoader->TreeD()->GetEvent(0);
900 muonDigits = (TClonesArray *) Dchambers()->At(ich);
901 ndig=muonDigits->GetEntriesFast();
902 printf("\n 1 Found %d digits in %p chamber %d", ndig, muonDigits,ich);
903 TClonesArray &lhits1 = *dig1;
905 for (k = 0; k < ndig; k++) {
906 digit = (AliMUONDigit*) muonDigits->UncheckedAt(k);
907 if (rec->TestTrack(digit->Track(0)))
908 new(lhits1[n++]) AliMUONDigit(*digit);
911 fLoader->TreeD()->GetEvent(1);
912 //muonDigits = this->DigitsAddress(ich);
913 muonDigits = (TClonesArray *) Dchambers()->At(ich);
914 ndig=muonDigits->GetEntriesFast();
915 printf("\n 2 Found %d digits in %p %d", ndig, muonDigits, ich);
916 TClonesArray &lhits2 = *dig2;
919 for (k=0; k<ndig; k++) {
920 digit= (AliMUONDigit*) muonDigits->UncheckedAt(k);
921 if (rec->TestTrack(digit->Track(0)))
922 new(lhits2[n++]) AliMUONDigit(*digit);
926 AliMUONClusterInput::Instance()->SetDigits(ich, dig1, dig2);
927 rec->FindRawClusters();
937 void AliMUON::Streamer(TBuffer &R__b)
939 // Stream an object of class AliMUON.
940 AliMUONChamber *iChamber;
941 AliMUONTriggerCircuit *iTriggerCircuit;
942 AliSegmentation *segmentation;
943 AliMUONResponse *response;
944 TClonesArray *digitsaddress;
945 TClonesArray *rawcladdress;
947 if (R__b.IsReading()) {
948 Version_t R__v = R__b.ReadVersion(); if (R__v) { }
949 AliDetector::Streamer(R__b);
951 R__b >> fPadHits; // diff
952 R__b >> fNLocalTrigger;
953 R__b >> fLocalTrigger;
954 R__b >> fNGlobalTrigger;
955 R__b >> fGlobalTrigger;
957 R__b >> fRawClusters;
958 R__b.ReadArray(fNdch);
959 R__b.ReadArray(fNrawch);
964 R__b >> fTriggerCircuits;
965 for (i =0; i<AliMUONConstants::NTriggerCircuit(); i++) {
966 iTriggerCircuit=(AliMUONTriggerCircuit*) (*fTriggerCircuits)[i];
967 iTriggerCircuit->Streamer(R__b);
969 // Stream chamber related information
970 for (i =0; i<AliMUONConstants::NCh(); i++) {
971 iChamber=(AliMUONChamber*) (*fChambers)[i];
972 iChamber->Streamer(R__b);
973 if (iChamber->Nsec()==1) {
974 segmentation=iChamber->SegmentationModel(1);
976 segmentation->Streamer(R__b);
978 segmentation=iChamber->SegmentationModel(1);
980 segmentation->Streamer(R__b);
982 segmentation=iChamber->SegmentationModel(2);
983 segmentation->Streamer(R__b);
985 response=iChamber->ResponseModel();
987 response->Streamer(R__b);
988 digitsaddress=(TClonesArray*) (*fDchambers)[i];
989 digitsaddress->Streamer(R__b);
990 if (i < AliMUONConstants::NTrackingCh()) {
991 rawcladdress=(TClonesArray*) (*fRawClusters)[i];
992 rawcladdress->Streamer(R__b);
997 R__b.WriteVersion(AliMUON::IsA());
998 AliDetector::Streamer(R__b);
1000 R__b << fPadHits; // diff
1001 R__b << fNLocalTrigger;
1002 R__b << fLocalTrigger;
1003 R__b << fNGlobalTrigger;
1004 R__b << fGlobalTrigger;
1006 R__b << fRawClusters;
1007 R__b.WriteArray(fNdch, AliMUONConstants::NCh());
1008 R__b.WriteArray(fNrawch, AliMUONConstants::NTrackingCh());
1015 R__b << fTriggerCircuits;
1016 for (i =0; i<AliMUONConstants::NTriggerCircuit(); i++) {
1017 iTriggerCircuit=(AliMUONTriggerCircuit*) (*fTriggerCircuits)[i];
1018 iTriggerCircuit->Streamer(R__b);
1020 for (i =0; i<AliMUONConstants::NCh(); i++) {
1021 iChamber=(AliMUONChamber*) (*fChambers)[i];
1022 iChamber->Streamer(R__b);
1023 if (iChamber->Nsec()==1) {
1024 segmentation=iChamber->SegmentationModel(1);
1026 segmentation->Streamer(R__b);
1028 segmentation=iChamber->SegmentationModel(1);
1030 segmentation->Streamer(R__b);
1031 segmentation=iChamber->SegmentationModel(2);
1033 segmentation->Streamer(R__b);
1035 response=iChamber->ResponseModel();
1037 response->Streamer(R__b);
1038 digitsaddress=(TClonesArray*) (*fDchambers)[i];
1039 digitsaddress->Streamer(R__b);
1040 if (i < AliMUONConstants::NTrackingCh()) {
1041 rawcladdress=(TClonesArray*) (*fRawClusters)[i];
1042 rawcladdress->Streamer(R__b);
1049 AliMUONPadHit* AliMUON::FirstPad(AliMUONHit* hit, TClonesArray *clusters)
1052 // Initialise the pad iterator
1053 // Return the address of the first padhit for hit
1054 TClonesArray *theClusters = clusters;
1055 Int_t nclust = theClusters->GetEntriesFast();
1056 if (nclust && hit->PHlast() > 0) {
1057 AliMUON::fMaxIterPad=hit->PHlast();
1058 AliMUON::fCurIterPad=hit->PHfirst();
1059 return (AliMUONPadHit*) clusters->UncheckedAt(AliMUON::fCurIterPad-1);
1065 AliMUONPadHit* AliMUON::NextPad(TClonesArray *clusters)
1068 // Get next pad (in iterator)
1070 AliMUON::fCurIterPad++;
1071 if (AliMUON::fCurIterPad <= AliMUON::fMaxIterPad) {
1072 return (AliMUONPadHit*) clusters->UncheckedAt(AliMUON::fCurIterPad-1);
1079 AliMUONRawCluster *AliMUON::RawCluster(Int_t ichamber, Int_t icathod, Int_t icluster)
1082 // Return rawcluster (icluster) for chamber ichamber and cathode icathod
1084 TClonesArray *muonRawCluster = RawClustAddress(ichamber);
1086 TTree *treeR = fLoader->TreeR();
1087 Int_t nent=(Int_t)treeR->GetEntries();
1088 treeR->GetEvent(nent-2+icathod-1);
1089 //treeR->GetEvent(icathod);
1090 //Int_t nrawcl = (Int_t)muonRawCluster->GetEntriesFast();
1092 AliMUONRawCluster * mRaw = (AliMUONRawCluster*)muonRawCluster->UncheckedAt(icluster);
1093 //printf("RawCluster _ nent nrawcl icluster mRaw %d %d %d%p\n",nent,nrawcl,icluster,mRaw);
1098 void AliMUON::SetMerger(AliMUONMerger* merger)
1100 // Set pointer to merger
1104 AliMUONMerger* AliMUON::Merger()
1106 // Return pointer to merger
1112 AliMUON& AliMUON::operator = (const AliMUON& /*rhs*/)
1119 ////////////////////////////////////////////////////////////////////////
1120 void AliMUON::MakeBranchInTreeD(TTree *treeD, const char *file)
1123 // Create TreeD branches for the MUON.
1126 const Int_t kBufferSize = 4000;
1127 char branchname[30];
1129 if (fDchambers == 0x0) {
1130 fDchambers = new TObjArray(AliMUONConstants::NCh());
1131 for (Int_t i=0; i<AliMUONConstants::NCh() ;i++) {
1132 fDchambers->AddAt(new TClonesArray("AliMUONDigit",10000),i);
1136 // one branch for digits per chamber
1138 for (Int_t i=0; i<AliMUONConstants::NCh() ;i++) {
1139 sprintf(branchname,"%sDigits%d",GetName(),i+1);
1140 if (fDchambers && treeD) {
1141 MakeBranchInTree(treeD,
1142 branchname, &((*fDchambers)[i]), kBufferSize, file);
1143 // printf("Making Branch %s for digits in chamber %d\n",branchname,i+1);
1148 //___________________________________________