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"
52 #include "AliMUONLoader.h"
54 #include "AliMUONChamberTrigger.h"
55 #include "AliMUONClusterFinderVS.h"
56 #include "AliMUONClusterInput.h"
57 #include "AliMUONConstants.h"
58 #include "AliMUONDigit.h"
59 #include "AliMUONGlobalTrigger.h"
60 #include "AliMUONHit.h"
61 #include "AliMUONHitMapA1.h"
62 #include "AliMUONLocalTrigger.h"
63 #include "AliMUONMerger.h"
64 #include "AliMUONPadHit.h"
65 #include "AliMUONRawCluster.h"
66 #include "AliMUONTransientDigit.h"
67 #include "AliMUONTriggerCircuit.h"
68 #include "AliMUONTriggerDecision.h"
72 // Defaults parameters for Z positions of chambers
73 // taken from values for "stations" in AliMUON::AliMUON
74 // const Float_t zch[7]={528, 690., 975., 1249., 1449., 1610, 1710.};
75 // and from array "dstation" in AliMUONv1::CreateGeometry
76 // Float_t dstation[5]={20., 20., 20, 20., 20.};
77 // for tracking chambers,
78 // according to (Z1 = zch - dstation) and (Z2 = zch + dstation)
79 // for the first and second chambers in the station, respectively,
80 // and from "DTPLANES" in AliMUONv1::CreateGeometry
81 // const Float_t DTPLANES = 15.;
82 // for trigger chambers,
83 // according to (Z1 = zch) and (Z2 = zch + DTPLANES)
84 // for the first and second chambers in the station, respectively
87 //___________________________________________
90 // Default Constructor
114 //___________________________________________
115 AliMUON::AliMUON(const char *name, const char *title)
116 : AliDetector(name,title)
120 <img src="gif/alimuon.gif">
124 fHits = new TClonesArray("AliMUONHit",1000);
125 gAlice->AddHitList(fHits);
126 fPadHits = new TClonesArray("AliMUONPadHit",10000);
130 fNCh = AliMUONConstants::NCh();
131 fNTrackingCh = AliMUONConstants::NTrackingCh();
132 fNdch = new Int_t[fNCh];
134 fDchambers = new TObjArray(AliMUONConstants::NCh());
138 for (i=0; i<AliMUONConstants::NCh() ;i++) {
139 fDchambers->AddAt(new TClonesArray("AliMUONDigit",10000),i);
143 fNrawch = new Int_t[fNTrackingCh];
145 fRawClusters = new TObjArray(AliMUONConstants::NTrackingCh());
147 for (i=0; i<AliMUONConstants::NTrackingCh();i++) {
148 fRawClusters->AddAt(new TClonesArray("AliMUONRawCluster",10000),i);
152 fGlobalTrigger = new TClonesArray("AliMUONGlobalTrigger",1);
154 fLocalTrigger = new TClonesArray("AliMUONLocalTrigger",234);
157 SetMarkerColor(kRed);
165 fChambers = new TObjArray(AliMUONConstants::NCh());
167 // Loop over stations
168 for (Int_t st = 0; st < AliMUONConstants::NCh() / 2; st++) {
169 // Loop over 2 chambers in the station
170 for (Int_t stCH = 0; stCH < 2; stCH++) {
173 // Default Parameters for Muon Tracking Stations
178 if (ch < AliMUONConstants::NTrackingCh()) {
179 fChambers->AddAt(new AliMUONChamber(ch),ch);
181 fChambers->AddAt(new AliMUONChamberTrigger(ch),ch);
184 //PH AliMUONChamber* chamber = (AliMUONChamber*) (*fChambers)[ch];
185 AliMUONChamber* chamber = (AliMUONChamber*) fChambers->At(ch);
188 // Default values for Z of chambers
189 chamber->SetZ(AliMUONConstants::DefaultChamberZ(ch));
191 chamber->InitGeo(AliMUONConstants::DefaultChamberZ(ch));
192 // Set chamber inner and outer radius to default
193 chamber->SetRInner(AliMUONConstants::Dmin(st)/2);
194 chamber->SetROuter(AliMUONConstants::Dmax(st)/2);
196 } // Chamber stCH (0, 1) in
197 } // Station st (0...)
198 // fChambers->SetLast(AliMUONConstants::NCh());
211 // cp new design of AliMUONTriggerDecision
212 fTriggerCircuits = new TObjArray(AliMUONConstants::NTriggerCircuit());
213 for (Int_t circ=0; circ<AliMUONConstants::NTriggerCircuit(); circ++) {
214 fTriggerCircuits->AddAt(new AliMUONTriggerCircuit(),circ);
220 //___________________________________________
221 AliMUON::AliMUON(const AliMUON& rMUON):AliDetector(rMUON)
223 // Dummy copy constructor
231 if(fDebug) printf("%s: Calling AliMUON destructor !!!\n",ClassName());
242 if (fTriggerCircuits){
243 fTriggerCircuits->Delete();
244 delete fTriggerCircuits;
248 fDchambers->Delete();
253 fRawClusters->Delete();
257 if (fNrawch) delete [] fNrawch;
259 // Delete TClonesArrays
267 fGlobalTrigger->Delete();
268 delete fGlobalTrigger;
273 fLocalTrigger->Delete();
274 delete fLocalTrigger;
283 if (fMerger) delete fMerger;
284 if (fNdch) delete [] fNdch;
288 //___________________________________________
289 void AliMUON::AddHit(Int_t track, Int_t *vol, Float_t *hits)
291 TClonesArray &lhits = *fHits;
292 new(lhits[fNhits++]) AliMUONHit(fIshunt,track,vol,hits);
294 //___________________________________________
295 void AliMUON::AddHit(Int_t fIshunt, Int_t track, Int_t iChamber,
296 Int_t idpart, Float_t X, Float_t Y, Float_t Z,
297 Float_t tof, Float_t momentum, Float_t theta,
298 Float_t phi, Float_t length, Float_t destep)
300 TClonesArray &lhits = *fHits;
301 new(lhits[fNhits++]) AliMUONHit(fIshunt, track, iChamber,
303 tof, momentum, theta,
304 phi, length, destep);
306 //___________________________________________
307 void AliMUON::AddPadHit(Int_t *clhits) // To be removed
309 TClonesArray &lclusters = *fPadHits;
310 new(lclusters[fNPadHits++]) AliMUONPadHit(clhits);
312 //_____________________________________________________________________________
313 void AliMUON::AddDigits(Int_t id, Int_t *tracks, Int_t *charges, Int_t *digits)
316 // Add a MUON digit to the list
319 //PH TClonesArray &ldigits = * ((TClonesArray*)(*fDchambers)[id]);
320 TClonesArray &ldigits = * ( (TClonesArray*) fDchambers->At(id) );
321 new(ldigits[fNdch[id]++]) AliMUONDigit(tracks,charges,digits);
324 //_____________________________________________________________________________
325 void AliMUON::AddRawCluster(Int_t id, const AliMUONRawCluster& c)
328 // Add a MUON digit to the list
331 //PH TClonesArray &lrawcl = *((TClonesArray*)(*fRawClusters)[id]);
332 TClonesArray &lrawcl = *((TClonesArray*)fRawClusters->At(id));
333 new(lrawcl[fNrawch[id]++]) AliMUONRawCluster(c);
336 //___________________________________________
337 void AliMUON::AddGlobalTrigger(Int_t *singlePlus, Int_t *singleMinus,
339 Int_t *pairUnlike, Int_t *pairLike)
341 // add a MUON Global Trigger to the list (only one GlobalTrigger per event !)
342 TClonesArray &globalTrigger = *fGlobalTrigger;
343 new(globalTrigger[fNGlobalTrigger++])
344 AliMUONGlobalTrigger(singlePlus, singleMinus, singleUndef, pairUnlike,
347 //___________________________________________
348 void AliMUON::AddLocalTrigger(Int_t *localtr)
350 // add a MUON Local Trigger to the list
351 TClonesArray &localTrigger = *fLocalTrigger;
352 new(localTrigger[fNLocalTrigger++]) AliMUONLocalTrigger(localtr);
355 //___________________________________________
356 void AliMUON::BuildGeometry()
358 // Geometry for event display
359 for (Int_t i=0; i<7; i++) {
360 for (Int_t j=0; j<2; j++) {
362 this->Chamber(id-1).SegmentationModel(1)->Draw("eventdisplay");
367 //___________________________________________
368 Int_t AliMUON::DistancetoPrimitive(Int_t , Int_t )
373 //___________________________________________
374 void AliMUON::MakeBranch(Option_t* option)
377 // Create Tree branches for the MUON.
379 const Int_t kBufferSize = 4000;
381 sprintf(branchname,"%sCluster",GetName());
384 const char *cD = strstr(option,"D");
385 const char *cR = strstr(option,"R");
386 const char *cH = strstr(option,"H");
390 if (fPadHits == 0x0) fPadHits = new TClonesArray("AliMUONPadHit",10000);
391 MakeBranchInTree(TreeH(), branchname, &fPadHits, kBufferSize, 0);
392 if (fHits == 0x0) fHits = new TClonesArray("AliMUONHit",1000);
394 //it must be under fHits creation
395 AliDetector::MakeBranch(option);
397 if (cD && fLoader->TreeD()) {
399 // one branch for digits per chamber
402 if (fDchambers == 0x0)
404 fDchambers = new TObjArray(AliMUONConstants::NCh());
405 for (Int_t i=0; i<AliMUONConstants::NCh() ;i++) {
406 fDchambers->AddAt(new TClonesArray("AliMUONDigit",10000),i);
410 for (i=0; i<AliMUONConstants::NCh() ;i++)
412 sprintf(branchname,"%sDigits%d",GetName(),i+1);
413 MakeBranchInTree(fLoader->TreeD(), branchname, &((*fDchambers)[i]), kBufferSize, 0);
414 printf("Making Branch %s for digits in chamber %d\n",branchname,i+1);
418 if (cR && fLoader->TreeR()) {
420 // one branch for raw clusters per chamber
422 printf("Make Branch - TreeR address %p\n",fLoader->TreeR());
425 if (fRawClusters == 0x0)
427 fRawClusters = new TObjArray(AliMUONConstants::NTrackingCh());
428 for (Int_t i=0; i<AliMUONConstants::NTrackingCh();i++) {
429 fRawClusters->AddAt(new TClonesArray("AliMUONRawCluster",10000),i);
433 for (i=0; i<AliMUONConstants::NTrackingCh() ;i++)
435 sprintf(branchname,"%sRawClusters%d",GetName(),i+1);
436 MakeBranchInTree(fLoader->TreeR(), branchname, &((*fRawClusters)[i]), kBufferSize, 0);
437 printf("Making Branch %s for raw clusters in chamber %d\n",branchname,i+1);
440 // one branch for global trigger
442 sprintf(branchname,"%sGlobalTrigger",GetName());
444 if (fGlobalTrigger == 0x0) {
445 fGlobalTrigger = new TClonesArray("AliMUONGlobalTrigger",1);
447 MakeBranchInTree(fLoader->TreeR(), branchname, &fGlobalTrigger, kBufferSize, 0);
448 printf("Making Branch %s for Global Trigger\n",branchname);
450 // one branch for local trigger
452 sprintf(branchname,"%sLocalTrigger",GetName());
454 if (fLocalTrigger == 0x0) {
455 fLocalTrigger = new TClonesArray("AliMUONLocalTrigger",234);
458 MakeBranchInTree(fLoader->TreeR(), branchname, &fLocalTrigger, kBufferSize, 0);
459 printf("Making Branch %s for Local Trigger\n",branchname);
463 //___________________________________________
464 void AliMUON::SetTreeAddress()
466 // Set branch address for the Hits and Digits Tree.
470 TTree *treeH = fLoader->TreeH();
471 TTree *treeD = fLoader->TreeD();
472 TTree *treeR = fLoader->TreeR();
475 if (fPadHits == 0x0) fPadHits = new TClonesArray("AliMUONPadHit",10000);
477 branch = treeH->GetBranch("MUONCluster");
478 if (branch) branch->SetAddress(&fPadHits);
480 if (fHits == 0x0) fHits = new TClonesArray("AliMUONHit",1000);
482 //it must be under fHits creation
483 AliDetector::SetTreeAddress();
486 if (fDchambers == 0x0)
488 fDchambers = new TObjArray(AliMUONConstants::NCh());
489 for (Int_t i=0; i<AliMUONConstants::NCh() ;i++) {
490 fDchambers->AddAt(new TClonesArray("AliMUONDigit",10000),i);
493 for (int i=0; i<AliMUONConstants::NCh(); i++) {
494 sprintf(branchname,"%sDigits%d",GetName(),i+1);
497 branch = treeD->GetBranch(branchname);
498 if (branch) branch->SetAddress(&((*fDchambers)[i]));
503 // printf("SetTreeAddress --- treeR address %p \n",treeR);
506 if (fRawClusters == 0x0)
508 fRawClusters = new TObjArray(AliMUONConstants::NTrackingCh());
509 for (Int_t i=0; i<AliMUONConstants::NTrackingCh();i++) {
510 fRawClusters->AddAt(new TClonesArray("AliMUONRawCluster",10000),i);
514 for (int i=0; i<AliMUONConstants::NTrackingCh(); i++) {
515 sprintf(branchname,"%sRawClusters%d",GetName(),i+1);
517 branch = treeR->GetBranch(branchname);
518 if (branch) branch->SetAddress(&((*fRawClusters)[i]));
522 if (fLocalTrigger == 0x0) {
523 fLocalTrigger = new TClonesArray("AliMUONLocalTrigger",234);
527 branch = treeR->GetBranch("MUONLocalTrigger");
528 if (branch) branch->SetAddress(&fLocalTrigger);
531 if (fGlobalTrigger == 0x0) {
532 fGlobalTrigger = new TClonesArray("AliMUONGlobalTrigger",1);
535 if (fGlobalTrigger) {
536 branch = treeR->GetBranch("MUONGlobalTrigger");
537 if (branch) branch->SetAddress(&fGlobalTrigger);
541 //___________________________________________
542 void AliMUON::ResetHits()
544 // Reset number of clusters and the cluster array for this detector
545 AliDetector::ResetHits();
547 if (fPadHits) fPadHits->Clear();
550 //____________________________________________
551 void AliMUON::ResetDigits()
554 // Reset number of digits and the digits array for this detector
556 if (fDchambers == 0x0) return;
557 for ( int i=0;i<AliMUONConstants::NCh();i++ ) {
558 //PH if ((*fDchambers)[i]) ((TClonesArray*)(*fDchambers)[i])->Clear();
559 if ((*fDchambers)[i]) ((TClonesArray*)fDchambers->At(i))->Clear();
560 if (fNdch) fNdch[i]=0;
563 //____________________________________________
564 void AliMUON::ResetRawClusters()
567 // Reset number of raw clusters and the raw clust array for this detector
569 for ( int i=0;i<AliMUONConstants::NTrackingCh();i++ ) {
570 //PH if ((*fRawClusters)[i]) ((TClonesArray*)(*fRawClusters)[i])->Clear();
571 if ((*fRawClusters)[i]) ((TClonesArray*)fRawClusters->At(i))->Clear();
572 if (fNrawch) fNrawch[i]=0;
576 //____________________________________________
577 void AliMUON::ResetTrigger()
579 // Reset Local and Global Trigger
581 if (fGlobalTrigger) fGlobalTrigger->Clear();
583 if (fLocalTrigger) fLocalTrigger->Clear();
586 //____________________________________________
587 void AliMUON::SetPadSize(Int_t id, Int_t isec, Float_t p1, Float_t p2)
589 // Set the pad size for chamber id and cathode isec
591 //PH ((AliMUONChamber*) (*fChambers)[i]) ->SetPadSize(isec,p1,p2);
592 //PH ((AliMUONChamber*) (*fChambers)[i+1])->SetPadSize(isec,p1,p2);
593 ((AliMUONChamber*) fChambers->At(i)) ->SetPadSize(isec,p1,p2);
594 ((AliMUONChamber*) fChambers->At(i+1))->SetPadSize(isec,p1,p2);
597 //___________________________________________
598 void AliMUON::SetChambersZ(const Float_t *Z)
600 // Set Z values for all chambers (tracking and trigger)
601 // from the array pointed to by "Z"
602 for (Int_t ch = 0; ch < AliMUONConstants::NCh(); ch++)
603 //PH ((AliMUONChamber*) ((*fChambers)[ch]))->SetZ(Z[ch]);
604 ((AliMUONChamber*) fChambers->At(ch))->SetZ(Z[ch]);
608 //___________________________________________
609 void AliMUON::SetChambersZToDefault()
611 // Set Z values for all chambers (tracking and trigger)
613 SetChambersZ(AliMUONConstants::DefaultChamberZ());
617 //___________________________________________
618 void AliMUON::SetChargeSlope(Int_t id, Float_t p1)
620 // Set the inverse charge slope for chamber id
622 //PH ((AliMUONChamber*) (*fChambers)[i])->SetChargeSlope(p1);
623 //PH ((AliMUONChamber*) (*fChambers)[i+1])->SetChargeSlope(p1);
624 ((AliMUONChamber*) fChambers->At(i))->SetChargeSlope(p1);
625 ((AliMUONChamber*) fChambers->At(i+1))->SetChargeSlope(p1);
628 //___________________________________________
629 void AliMUON::SetChargeSpread(Int_t id, Float_t p1, Float_t p2)
631 // Set sigma of charge spread for chamber id
633 //PH ((AliMUONChamber*) fChambers->At(i))->SetChargeSpread(p1,p2);
634 //PH ((AliMUONChamber*) fChambers->Ati+1])->SetChargeSpread(p1,p2);
635 ((AliMUONChamber*) fChambers->At(i))->SetChargeSpread(p1,p2);
636 ((AliMUONChamber*) fChambers->At(i+1))->SetChargeSpread(p1,p2);
639 //___________________________________________
640 void AliMUON::SetSigmaIntegration(Int_t id, Float_t p1)
642 // Set integration limits for charge spread
644 //PH ((AliMUONChamber*) (*fChambers)[i])->SetSigmaIntegration(p1);
645 //PH ((AliMUONChamber*) (*fChambers)[i+1])->SetSigmaIntegration(p1);
646 ((AliMUONChamber*) fChambers->At(i))->SetSigmaIntegration(p1);
647 ((AliMUONChamber*) fChambers->At(i+1))->SetSigmaIntegration(p1);
650 //___________________________________________
651 void AliMUON::SetMaxAdc(Int_t id, Int_t p1)
653 // Set maximum number for ADCcounts (saturation)
655 //PH ((AliMUONChamber*) (*fChambers)[i])->SetMaxAdc(p1);
656 //PH ((AliMUONChamber*) (*fChambers)[i+1])->SetMaxAdc(p1);
657 ((AliMUONChamber*) fChambers->At(i))->SetMaxAdc(p1);
658 ((AliMUONChamber*) fChambers->At(i+1))->SetMaxAdc(p1);
661 //___________________________________________
662 void AliMUON::SetMaxStepGas(Float_t p1)
664 // Set stepsize in gas
668 //___________________________________________
669 void AliMUON::SetMaxStepAlu(Float_t p1)
671 // Set step size in Alu
675 //___________________________________________
676 void AliMUON::SetMaxDestepGas(Float_t p1)
678 // Set maximum step size in Gas
682 //___________________________________________
683 void AliMUON::SetMaxDestepAlu(Float_t p1)
685 // Set maximum step size in Alu
688 //___________________________________________
689 void AliMUON::SetAcceptance(Bool_t acc, Float_t angmin, Float_t angmax)
691 // Set acceptance cuts
693 fAccMin=angmin*TMath::Pi()/180;
694 fAccMax=angmax*TMath::Pi()/180;
697 for (Int_t st = 0; st < AliMUONConstants::NCh() / 2; st++) {
698 // Loop over 2 chambers in the station
699 for (Int_t stCH = 0; stCH < 2; stCH++) {
701 // Set chamber inner and outer radius according to acceptance cuts
702 Chamber(ch).SetRInner(AliMUONConstants::DefaultChamberZ(ch)*TMath::Tan(fAccMin));
703 Chamber(ch).SetROuter(AliMUONConstants::DefaultChamberZ(ch)*TMath::Tan(fAccMax));
708 //___________________________________________
709 void AliMUON::SetSegmentationModel(Int_t id, Int_t isec, AliSegmentation *segmentation)
711 // Set the segmentation for chamber id cathode isec
712 //PH ((AliMUONChamber*) (*fChambers)[id])->SetSegmentationModel(isec, segmentation);
713 ((AliMUONChamber*) fChambers->At(id))->SetSegmentationModel(isec, segmentation);
716 //___________________________________________
717 void AliMUON::SetResponseModel(Int_t id, AliMUONResponse *response)
719 // Set the response for chamber id
720 //PH ((AliMUONChamber*) (*fChambers)[id])->SetResponseModel(response);
721 ((AliMUONChamber*) fChambers->At(id))->SetResponseModel(response);
724 void AliMUON::SetReconstructionModel(Int_t id, AliMUONClusterFinderVS *reconst)
726 // Set ClusterFinder for chamber id
727 //PH ((AliMUONChamber*) (*fChambers)[id])->SetReconstructionModel(reconst);
728 ((AliMUONChamber*) fChambers->At(id))->SetReconstructionModel(reconst);
731 void AliMUON::SetNsec(Int_t id, Int_t nsec)
733 // Set number of segmented cathods for chamber id
734 //PH ((AliMUONChamber*) (*fChambers)[id])->SetNsec(nsec);
735 ((AliMUONChamber*) fChambers->At(id))->SetNsec(nsec);
738 //___________________________________________
739 void AliMUON::SDigits2Digits()
745 if (gAlice->GetDebug()>0) {
746 cerr<<"AliMUON::SDigits2Digits: create default AliMUONMerger "<<endl;
747 cerr<<" no merging, just digitization of 1 event will be done"<<endl;
749 fMerger = new AliMUONMerger();
754 // sprintf(hname,"TreeD%d",fLoader->GetHeader()->GetEvent());
755 fLoader->TreeD()->Write(hname,TObject::kOverwrite);
756 fLoader->TreeD()->Reset();
760 //__________________________________________________________________________
761 AliLoader* AliMUON::MakeLoader(const char* topfoldername)
763 //builds standard getter (AliLoader type)
764 //if detector wants to use castomized getter, it must overload this method
768 "Creating standard getter for detector %s. Top folder is %s.",
769 GetName(),topfoldername);
771 fLoader = new AliMUONLoader(GetName(),topfoldername);
774 //__________________________________________________________________________
776 void AliMUON::MakePadHits(Float_t xhit,Float_t yhit, Float_t zhit,
777 Float_t eloss, Float_t tof, Int_t idvol)
780 // Calls the charge disintegration method of the current chamber and adds
781 // the simulated cluster to the root treee
784 Float_t newclust[6][500];
789 // Integrated pulse height on chamber
795 // if (idvol == 6) printf("\n ->Disintegration %f %f %f", xhit, yhit, eloss );
798 //PH ((AliMUONChamber*) (*fChambers)[idvol])
799 ((AliMUONChamber*) fChambers->At(idvol))
800 ->DisIntegration(eloss, tof, xhit, yhit, zhit, nnew, newclust);
802 // if (idvol == 6) printf("\n nnew %d \n", nnew);
805 for (Int_t i=0; i<nnew; i++) {
806 if (Int_t(newclust[3][i]) > 0) {
809 clhits[1] = Int_t(newclust[5][i]);
811 clhits[2] = Int_t(newclust[0][i]);
813 clhits[3] = Int_t(newclust[1][i]);
815 clhits[4] = Int_t(newclust[2][i]);
817 clhits[5] = Int_t(newclust[3][i]);
818 // Pad: chamber sector
819 clhits[6] = Int_t(newclust[4][i]);
826 //___________________________________________
827 void AliMUON::Trigger(Int_t nev){
828 // call the Trigger Algorithm and fill TreeR
830 Int_t singlePlus[3] = {0,0,0};
831 Int_t singleMinus[3] = {0,0,0};
832 Int_t singleUndef[3] = {0,0,0};
833 Int_t pairUnlike[3] = {0,0,0};
834 Int_t pairLike[3] = {0,0,0};
837 AliMUONTriggerDecision* decision= new AliMUONTriggerDecision(1);
839 decision->GetGlobalTrigger(singlePlus, singleMinus, singleUndef,
840 pairUnlike, pairLike);
842 // add a local trigger in the list
843 AddGlobalTrigger(singlePlus, singleMinus, singleUndef, pairUnlike, pairLike);
846 for (Int_t icirc=0; icirc<AliMUONConstants::NTriggerCircuit(); icirc++) {
847 if(decision->GetITrigger(icirc)==1) {
848 Int_t localtr[7]={0,0,0,0,0,0,0};
849 Int_t loLpt[2]={0,0}; Int_t loHpt[2]={0,0}; Int_t loApt[2]={0,0};
850 decision->GetLutOutput(icirc, loLpt, loHpt, loApt);
852 localtr[1] = decision->GetStripX11(icirc);
853 localtr[2] = decision->GetDev(icirc);
854 localtr[3] = decision->GetStripY11(icirc);
855 for (i=0; i<2; i++) { // convert the Lut output in 1 digit
856 localtr[4] = localtr[4]+Int_t(loLpt[i]*TMath::Power(2,i));
857 localtr[5] = localtr[5]+Int_t(loHpt[i]*TMath::Power(2,i));
858 localtr[6] = localtr[6]+Int_t(loApt[i]*TMath::Power(2,i));
860 AddLocalTrigger(localtr); // add a local trigger in the list
866 fLoader->TreeR()->Fill();
868 // sprintf(hname,"TreeR%d",nev);
869 // fLoader->TreeR()->Write(hname,TObject::kOverwrite);
870 // fLoader->TreeR()->Reset();
871 fLoader->WriteRecPoints("OVERWRITE");
874 printf("\n End of trigger for event %d", nev);
878 //____________________________________________
879 void AliMUON::Digits2Reco()
882 Int_t nev = gAlice->GetHeader()->GetEvent();
883 fLoader->TreeR()->Fill();
885 // sprintf(hname,"TreeR%d", nev);
886 //fLoader->TreeR()->Write(hname);
887 //fLoader->TreeR()->Reset();
888 fLoader->WriteRecPoints("OVERWRITE");
890 printf("\n End of cluster finding for event %d", nev);
893 void AliMUON::FindClusters()
896 // Perform cluster finding
898 TClonesArray *dig1, *dig2;
900 dig1 = new TClonesArray("AliMUONDigit",1000);
901 dig2 = new TClonesArray("AliMUONDigit",1000);
903 // Loop on chambers and on cathode planes
906 TClonesArray * muonDigits;
908 for (Int_t ich = 0; ich < 10; ich++) {
909 //PH AliMUONChamber* iChamber = (AliMUONChamber*) (*fChambers)[ich];
910 AliMUONChamber* iChamber = (AliMUONChamber*) fChambers->At(ich);
911 AliMUONClusterFinderVS* rec = iChamber->ReconstructionModel();
914 fLoader->TreeD()->GetEvent(0);
916 muonDigits = (TClonesArray *) Dchambers()->At(ich);
917 ndig=muonDigits->GetEntriesFast();
918 printf("\n 1 Found %d digits in %p chamber %d", ndig, muonDigits,ich);
919 TClonesArray &lhits1 = *dig1;
921 for (k = 0; k < ndig; k++) {
922 digit = (AliMUONDigit*) muonDigits->UncheckedAt(k);
923 if (rec->TestTrack(digit->Track(0)))
924 new(lhits1[n++]) AliMUONDigit(*digit);
927 fLoader->TreeD()->GetEvent(1);
928 //muonDigits = this->DigitsAddress(ich);
929 muonDigits = (TClonesArray *) Dchambers()->At(ich);
930 ndig=muonDigits->GetEntriesFast();
931 printf("\n 2 Found %d digits in %p %d", ndig, muonDigits, ich);
932 TClonesArray &lhits2 = *dig2;
935 for (k=0; k<ndig; k++) {
936 digit= (AliMUONDigit*) muonDigits->UncheckedAt(k);
937 if (rec->TestTrack(digit->Track(0)))
938 new(lhits2[n++]) AliMUONDigit(*digit);
942 AliMUONClusterInput::Instance()->SetDigits(ich, dig1, dig2);
943 rec->FindRawClusters();
953 void AliMUON::Streamer(TBuffer &R__b)
955 // Stream an object of class AliMUON.
956 AliMUONChamber *iChamber;
957 AliMUONTriggerCircuit *iTriggerCircuit;
958 AliSegmentation *segmentation;
959 AliMUONResponse *response;
960 TClonesArray *digitsaddress;
961 TClonesArray *rawcladdress;
963 if (R__b.IsReading()) {
964 Version_t R__v = R__b.ReadVersion(); if (R__v) { }
965 AliDetector::Streamer(R__b);
967 R__b >> fPadHits; // diff
968 R__b >> fNLocalTrigger;
969 R__b >> fLocalTrigger;
970 R__b >> fNGlobalTrigger;
971 R__b >> fGlobalTrigger;
973 R__b >> fRawClusters;
974 R__b.ReadArray(fNdch);
975 R__b.ReadArray(fNrawch);
980 R__b >> fTriggerCircuits;
981 for (i =0; i<AliMUONConstants::NTriggerCircuit(); i++) {
982 iTriggerCircuit=(AliMUONTriggerCircuit*) (*fTriggerCircuits)[i];
983 iTriggerCircuit->Streamer(R__b);
985 // Stream chamber related information
986 for (i =0; i<AliMUONConstants::NCh(); i++) {
987 iChamber=(AliMUONChamber*) (*fChambers)[i];
988 iChamber->Streamer(R__b);
989 if (iChamber->Nsec()==1) {
990 segmentation=iChamber->SegmentationModel(1);
992 segmentation->Streamer(R__b);
994 segmentation=iChamber->SegmentationModel(1);
996 segmentation->Streamer(R__b);
998 segmentation=iChamber->SegmentationModel(2);
999 segmentation->Streamer(R__b);
1001 response=iChamber->ResponseModel();
1003 response->Streamer(R__b);
1004 digitsaddress=(TClonesArray*) (*fDchambers)[i];
1005 digitsaddress->Streamer(R__b);
1006 if (i < AliMUONConstants::NTrackingCh()) {
1007 rawcladdress=(TClonesArray*) (*fRawClusters)[i];
1008 rawcladdress->Streamer(R__b);
1013 R__b.WriteVersion(AliMUON::IsA());
1014 AliDetector::Streamer(R__b);
1016 R__b << fPadHits; // diff
1017 R__b << fNLocalTrigger;
1018 R__b << fLocalTrigger;
1019 R__b << fNGlobalTrigger;
1020 R__b << fGlobalTrigger;
1022 R__b << fRawClusters;
1023 R__b.WriteArray(fNdch, AliMUONConstants::NCh());
1024 R__b.WriteArray(fNrawch, AliMUONConstants::NTrackingCh());
1031 R__b << fTriggerCircuits;
1032 for (i =0; i<AliMUONConstants::NTriggerCircuit(); i++) {
1033 iTriggerCircuit=(AliMUONTriggerCircuit*) (*fTriggerCircuits)[i];
1034 iTriggerCircuit->Streamer(R__b);
1036 for (i =0; i<AliMUONConstants::NCh(); i++) {
1037 iChamber=(AliMUONChamber*) (*fChambers)[i];
1038 iChamber->Streamer(R__b);
1039 if (iChamber->Nsec()==1) {
1040 segmentation=iChamber->SegmentationModel(1);
1042 segmentation->Streamer(R__b);
1044 segmentation=iChamber->SegmentationModel(1);
1046 segmentation->Streamer(R__b);
1047 segmentation=iChamber->SegmentationModel(2);
1049 segmentation->Streamer(R__b);
1051 response=iChamber->ResponseModel();
1053 response->Streamer(R__b);
1054 digitsaddress=(TClonesArray*) (*fDchambers)[i];
1055 digitsaddress->Streamer(R__b);
1056 if (i < AliMUONConstants::NTrackingCh()) {
1057 rawcladdress=(TClonesArray*) (*fRawClusters)[i];
1058 rawcladdress->Streamer(R__b);
1065 AliMUONPadHit* AliMUON::FirstPad(AliMUONHit* hit, TClonesArray *clusters)
1068 // Initialise the pad iterator
1069 // Return the address of the first padhit for hit
1070 TClonesArray *theClusters = clusters;
1071 Int_t nclust = theClusters->GetEntriesFast();
1072 if (nclust && hit->PHlast() > 0) {
1073 AliMUON::fMaxIterPad=hit->PHlast();
1074 AliMUON::fCurIterPad=hit->PHfirst();
1075 return (AliMUONPadHit*) clusters->UncheckedAt(AliMUON::fCurIterPad-1);
1081 AliMUONPadHit* AliMUON::NextPad(TClonesArray *clusters)
1084 // Get next pad (in iterator)
1086 AliMUON::fCurIterPad++;
1087 if (AliMUON::fCurIterPad <= AliMUON::fMaxIterPad) {
1088 return (AliMUONPadHit*) clusters->UncheckedAt(AliMUON::fCurIterPad-1);
1095 AliMUONRawCluster *AliMUON::RawCluster(Int_t ichamber, Int_t icathod, Int_t icluster)
1098 // Return rawcluster (icluster) for chamber ichamber and cathode icathod
1100 TClonesArray *muonRawCluster = RawClustAddress(ichamber);
1102 TTree *treeR = fLoader->TreeR();
1103 Int_t nent=(Int_t)treeR->GetEntries();
1104 treeR->GetEvent(nent-2+icathod-1);
1105 //treeR->GetEvent(icathod);
1106 //Int_t nrawcl = (Int_t)muonRawCluster->GetEntriesFast();
1108 AliMUONRawCluster * mRaw = (AliMUONRawCluster*)muonRawCluster->UncheckedAt(icluster);
1109 //printf("RawCluster _ nent nrawcl icluster mRaw %d %d %d%p\n",nent,nrawcl,icluster,mRaw);
1114 void AliMUON::SetMerger(AliMUONMerger* merger)
1116 // Set pointer to merger
1120 AliMUONMerger* AliMUON::Merger()
1122 // Return pointer to merger
1128 AliMUON& AliMUON::operator = (const AliMUON& /*rhs*/)
1135 ////////////////////////////////////////////////////////////////////////
1136 void AliMUON::MakeBranchInTreeD(TTree *treeD, const char *file)
1139 // Create TreeD branches for the MUON.
1142 const Int_t kBufferSize = 4000;
1143 char branchname[30];
1145 if (fDchambers == 0x0) {
1146 fDchambers = new TObjArray(AliMUONConstants::NCh());
1147 for (Int_t i=0; i<AliMUONConstants::NCh() ;i++) {
1148 fDchambers->AddAt(new TClonesArray("AliMUONDigit",10000),i);
1152 // one branch for digits per chamber
1154 for (Int_t i=0; i<AliMUONConstants::NCh() ;i++) {
1155 sprintf(branchname,"%sDigits%d",GetName(),i+1);
1156 if (fDchambers && treeD) {
1157 MakeBranchInTree(treeD,
1158 branchname, &((*fDchambers)[i]), kBufferSize, file);
1159 // printf("Making Branch %s for digits in chamber %d\n",branchname,i+1);
1164 //___________________________________________