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"
70 #include "AliMUONDigitizerv1.h"
73 // Defaults parameters for Z positions of chambers
74 // taken from values for "stations" in AliMUON::AliMUON
75 // const Float_t zch[7]={528, 690., 975., 1249., 1449., 1610, 1710.};
76 // and from array "dstation" in AliMUONv1::CreateGeometry
77 // Float_t dstation[5]={20., 20., 20, 20., 20.};
78 // for tracking chambers,
79 // according to (Z1 = zch - dstation) and (Z2 = zch + dstation)
80 // for the first and second chambers in the station, respectively,
81 // and from "DTPLANES" in AliMUONv1::CreateGeometry
82 // const Float_t DTPLANES = 15.;
83 // for trigger chambers,
84 // according to (Z1 = zch) and (Z2 = zch + DTPLANES)
85 // for the first and second chambers in the station, respectively
88 //__________________________________________________________________
91 // Default Constructor
106 //__________________________________________________________________
107 AliMUON::AliMUON(const char *name, const char *title)
108 : AliDetector(name,title)
112 <img src="gif/alimuon.gif">
119 fNCh = AliMUONConstants::NCh();
120 fNTrackingCh = AliMUONConstants::NTrackingCh();
122 SetMarkerColor(kRed);//
124 // Creating List of Chambers
126 fChambers = new TObjArray(AliMUONConstants::NCh());
127 // Loop over stations
128 for (Int_t st = 0; st < AliMUONConstants::NCh() / 2; st++) {
129 // Loop over 2 chambers in the station
130 for (Int_t stCH = 0; stCH < 2; stCH++) {
133 // Default Parameters for Muon Tracking Stations
135 if (ch < AliMUONConstants::NTrackingCh()) {
136 fChambers->AddAt(new AliMUONChamber(ch),ch);
138 fChambers->AddAt(new AliMUONChamberTrigger(ch),ch);
140 AliMUONChamber* chamber = (AliMUONChamber*) fChambers->At(ch);
142 // Default values for Z of chambers
143 chamber->SetZ(AliMUONConstants::DefaultChamberZ(ch));
145 chamber->InitGeo(AliMUONConstants::DefaultChamberZ(ch));
146 // Set chamber inner and outer radius to default
147 chamber->SetRInner(AliMUONConstants::Dmin(st)/2);
148 chamber->SetROuter(AliMUONConstants::Dmax(st)/2);
150 } // Chamber stCH (0, 1) in
151 } // Station st (0...)
153 // Negatives values are ignored by geant3 CONS200 in the calculation of the tracking parameters
166 // cp new design of AliMUONTriggerDecision
167 fTriggerCircuits = new TObjArray(AliMUONConstants::NTriggerCircuit());
168 for (Int_t circ=0; circ<AliMUONConstants::NTriggerCircuit(); circ++) {
169 fTriggerCircuits->AddAt(new AliMUONTriggerCircuit(),circ);
173 //____________________________________________________________________
174 AliMUON::AliMUON(const AliMUON& rMUON):AliDetector(rMUON)
176 // Dummy copy constructor
180 //____________________________________________________________________
184 if(fDebug) printf("%s: Calling AliMUON destructor !!!\n",ClassName());
186 if (fMerger) delete fMerger;
188 //____________________________________________________________________
189 void AliMUON::BuildGeometry()
191 // Geometry for event display
192 for (Int_t i=0; i<7; i++) {
193 for (Int_t j=0; j<2; j++) {
195 this->Chamber(id-1).SegmentationModel(1)->Draw("eventdisplay");
199 //___________________________________________________________________
200 Int_t AliMUON::DistancetoPrimitive(Int_t , Int_t )
204 //__________________________________________________________________
205 void AliMUON::SetTreeAddress()
207 GetMUONData()->SetLoader(fLoader);
208 GetMUONData()->SetTreeAddress("H,D,RC");
209 fHits = GetMUONData()->Hits(); // Added by Ivana to use the methods FisrtHit, NextHit of AliDetector
212 //____________________________________________________________________
213 void AliMUON::SetPadSize(Int_t id, Int_t isec, Float_t p1, Float_t p2)
215 // Set the pad size for chamber id and cathode isec
217 ((AliMUONChamber*) fChambers->At(i)) ->SetPadSize(isec,p1,p2);
218 ((AliMUONChamber*) fChambers->At(i+1))->SetPadSize(isec,p1,p2);
221 //___________________________________________
222 void AliMUON::SetChambersZ(const Float_t *Z)
224 // Set Z values for all chambers (tracking and trigger)
225 // from the array pointed to by "Z"
226 for (Int_t ch = 0; ch < AliMUONConstants::NCh(); ch++)
227 ((AliMUONChamber*) fChambers->At(ch))->SetZ(Z[ch]);
230 //_________________________________________________________________
231 void AliMUON::SetChambersZToDefault()
233 // Set Z values for all chambers (tracking and trigger)
235 SetChambersZ(AliMUONConstants::DefaultChamberZ());
238 //_________________________________________________________________
239 void AliMUON::SetChargeSlope(Int_t id, Float_t p1)
241 // Set the inverse charge slope for chamber id
242 Int_t i=2*(id-1); //PH ((AliMUONChamber*) (*fChambers)[i])->SetSigmaIntegration(p1);
243 //PH ((AliMUONChamber*) (*fChambers)[i+1])->SetSigmaIntegration(p1);
244 ((AliMUONChamber*) fChambers->At(i))->SetChargeSlope(p1);
245 ((AliMUONChamber*) fChambers->At(i+1))->SetChargeSlope(p1);
247 //__________________________________________________________________
248 void AliMUON::SetChargeSpread(Int_t id, Float_t p1, Float_t p2)
250 // Set sigma of charge spread for chamber id
252 ((AliMUONChamber*) fChambers->At(i))->SetChargeSpread(p1,p2);
253 ((AliMUONChamber*) fChambers->At(i+1))->SetChargeSpread(p1,p2);
255 //___________________________________________________________________
256 void AliMUON::SetSigmaIntegration(Int_t id, Float_t p1)
258 // Set integration limits for charge spread
260 ((AliMUONChamber*) fChambers->At(i))->SetSigmaIntegration(p1);
261 ((AliMUONChamber*) fChambers->At(i+1))->SetSigmaIntegration(p1);
264 //__________________________________________________________________
265 void AliMUON::SetMaxAdc(Int_t id, Int_t p1)
267 // Set maximum number for ADCcounts (saturation)
269 ((AliMUONChamber*) fChambers->At(i))->SetMaxAdc(p1);
270 ((AliMUONChamber*) fChambers->At(i+1))->SetMaxAdc(p1);
272 //__________________________________________________________________
273 void AliMUON::SetMaxStepGas(Float_t p1)
275 // Set stepsize in gas
278 //__________________________________________________________________
279 void AliMUON::SetMaxStepAlu(Float_t p1)
281 // Set step size in Alu
284 //__________________________________________________________________
285 void AliMUON::SetMaxDestepGas(Float_t p1)
287 // Set maximum step size in Gas
290 //__________________________________________________________________
291 void AliMUON::SetMaxDestepAlu(Float_t p1)
293 // Set maximum step size in Alu
296 //___________________________________________________________________
297 void AliMUON::SetAcceptance(Bool_t acc, Float_t angmin, Float_t angmax)
299 // Set acceptance cuts
301 fAccMin=angmin*TMath::Pi()/180;
302 fAccMax=angmax*TMath::Pi()/180;
305 for (Int_t st = 0; st < AliMUONConstants::NCh() / 2; st++) {
306 // Loop over 2 chambers in the station
307 for (Int_t stCH = 0; stCH < 2; stCH++) {
309 // Set chamber inner and outer radius according to acceptance cuts
310 Chamber(ch).SetRInner(TMath::Abs(AliMUONConstants::DefaultChamberZ(ch)*TMath::Tan(fAccMin)));
311 Chamber(ch).SetROuter(TMath::Abs(AliMUONConstants::DefaultChamberZ(ch)*TMath::Tan(fAccMax)));
316 //____________________________________________________________________
317 void AliMUON::SetSegmentationModel(Int_t id, Int_t isec, AliSegmentation *segmentation)
319 // Set the segmentation for chamber id cathode isec
320 ((AliMUONChamber*) fChambers->At(id))->SetSegmentationModel(isec, segmentation);
323 //____________________________________________________________________
324 void AliMUON::SetResponseModel(Int_t id, AliMUONResponse *response)
326 // Set the response for chamber id
327 ((AliMUONChamber*) fChambers->At(id))->SetResponseModel(response);
329 //____________________________________________________________________
330 void AliMUON::SetReconstructionModel(Int_t id, AliMUONClusterFinderVS *reconst)
332 // Set ClusterFinder for chamber id
333 ((AliMUONChamber*) fChambers->At(id))->SetReconstructionModel(reconst);
335 //____________________________________________________________________
336 void AliMUON::SetNsec(Int_t id, Int_t nsec)
338 // Set number of segmented cathods for chamber id
339 ((AliMUONChamber*) fChambers->At(id))->SetNsec(nsec);
341 //____________________________________________________________________
342 AliDigitizer* AliMUON::CreateDigitizer(AliRunDigitizer* manager) const
344 return new AliMUONDigitizerv1(manager);
346 //_____________________________________________________________________
347 void AliMUON::SDigits2Digits()
353 if (gAlice->GetDebug()>0) {
354 cerr<<"AliMUON::SDigits2Digits: create default AliMUONMerger "<<endl;
355 cerr<<" no merging, just digitization of 1 event will be done"<<endl;
357 fMerger = new AliMUONMerger();
362 // sprintf(hname,"TreeD%d",fLoader->GetHeader()->GetEvent());
363 fLoader->TreeD()->Write(hname,TObject::kOverwrite);
364 fLoader->TreeD()->Reset();
367 //_______________________________________________________________________
368 AliLoader* AliMUON::MakeLoader(const char* topfoldername)
370 //builds standard getter (AliLoader type)
371 //if detector wants to use castomized getter, it must overload this method
375 "Creating standard getter for detector %s. Top folder is %s.",
376 GetName(),topfoldername);
378 fLoader = new AliLoader(GetName(),topfoldername);
379 fMUONData = new AliMUONData(fLoader,GetName(),GetName());
380 fMUONData->SetSplitLevel(fSplitLevel);
384 //_______________________________________________________________________
385 void AliMUON::Trigger(Int_t nev){
386 // call the Trigger Algorithm and fill TreeR
388 Int_t singlePlus[3] = {0,0,0};
389 Int_t singleMinus[3] = {0,0,0};
390 Int_t singleUndef[3] = {0,0,0};
391 Int_t pairUnlike[3] = {0,0,0};
392 Int_t pairLike[3] = {0,0,0};
395 AliMUONTriggerDecision* decision= new AliMUONTriggerDecision(1);
397 decision->GetGlobalTrigger(singlePlus, singleMinus, singleUndef,
398 pairUnlike, pairLike);
400 // add a local trigger in the list
401 GetMUONData()->AddGlobalTrigger(singlePlus, singleMinus, singleUndef, pairUnlike, pairLike);
404 for (Int_t icirc=0; icirc<AliMUONConstants::NTriggerCircuit(); icirc++) {
405 if(decision->GetITrigger(icirc)==1) {
406 Int_t localtr[7]={0,0,0,0,0,0,0};
407 Int_t loLpt[2]={0,0}; Int_t loHpt[2]={0,0}; Int_t loApt[2]={0,0};
408 decision->GetLutOutput(icirc, loLpt, loHpt, loApt);
410 localtr[1] = decision->GetStripX11(icirc);
411 localtr[2] = decision->GetDev(icirc);
412 localtr[3] = decision->GetStripY11(icirc);
413 for (i=0; i<2; i++) { // convert the Lut output in 1 digit
414 localtr[4] = localtr[4]+Int_t(loLpt[i]*TMath::Power(2,i));
415 localtr[5] = localtr[5]+Int_t(loHpt[i]*TMath::Power(2,i));
416 localtr[6] = localtr[6]+Int_t(loApt[i]*TMath::Power(2,i));
418 GetMUONData()->AddLocalTrigger(localtr); // add a local trigger in the list
424 // fLoader->TreeR()->Fill();
425 GetMUONData()->Fill("GLT"); //Filling Global and Local Trigger GLT
427 // sprintf(hname,"TreeR%d",nev);
428 // fLoader->TreeR()->Write(hname,TObject::kOverwrite);
429 // fLoader->TreeR()->Reset();
430 fLoader->WriteRecPoints("OVERWRITE");
432 printf("\n End of trigger for event %d", nev);
435 //____________________________________________________________________
436 void AliMUON::Digits2Reco()
439 Int_t nev = gAlice->GetHeader()->GetEvent();
440 GetMUONData()->Fill("RC"); //Filling Reconstructed Cluster
441 fLoader->WriteRecPoints("OVERWRITE");
442 GetMUONData()->ResetRawClusters();
443 Info("Digits2Reco","End of cluster finding for event %d", nev);
445 //____________________________________________________________________
446 void AliMUON::FindClusters()
449 // Perform cluster finding
451 TClonesArray *dig1, *dig2;
453 dig1 = new TClonesArray("AliMUONDigit",1000);
454 dig2 = new TClonesArray("AliMUONDigit",1000);
456 // Loop on chambers and on cathode planes
459 TClonesArray * muonDigits;
461 for (Int_t ich = 0; ich < 10; ich++) {
462 //PH AliMUONChamber* iChamber = (AliMUONChamber*) (*fChambers)[ich];
463 AliMUONChamber* iChamber = (AliMUONChamber*) fChambers->At(ich);
464 AliMUONClusterFinderVS* rec = iChamber->ReconstructionModel();
467 GetMUONData()->GetCathode(0);
469 muonDigits = GetMUONData()->Digits(ich);
470 ndig=muonDigits->GetEntriesFast();
471 printf("\n 1 Found %d digits in %p chamber %d", ndig, muonDigits,ich);
472 TClonesArray &lhits1 = *dig1;
474 for (k = 0; k < ndig; k++) {
475 digit = (AliMUONDigit*) muonDigits->UncheckedAt(k);
476 if (rec->TestTrack(digit->Track(0)))
477 new(lhits1[n++]) AliMUONDigit(*digit);
479 GetMUONData()->ResetDigits();
480 GetMUONData()->GetCathode(1);
481 muonDigits = GetMUONData()->Digits(ich);
482 ndig=muonDigits->GetEntriesFast();
483 printf("\n 2 Found %d digits in %p %d", ndig, muonDigits, ich);
484 TClonesArray &lhits2 = *dig2;
487 for (k=0; k<ndig; k++) {
488 digit= (AliMUONDigit*) muonDigits->UncheckedAt(k);
489 if (rec->TestTrack(digit->Track(0)))
490 new(lhits2[n++]) AliMUONDigit(*digit);
494 AliMUONClusterInput::Instance()->SetDigits(ich, dig1, dig2);
495 rec->FindRawClusters();
503 //______________________________________________________________________
505 void AliMUON::Streamer(TBuffer &R__b)_
507 // Stream an object of class AliMUON.
508 AliMUONChamber *iChamber;
509 AliMUONTriggerCircuit *iTriggerCircuit;
510 AliSegmentation *segmentation;
511 AliMUONResponse *response;
512 TClonesArray *digitsaddress;
513 TClonesArray *rawcladdress;
515 if (R__b.IsReading()) {
516 Version_t R__v = R__b.ReadVersion(); if (R__v) { }
517 AliDetector::Streamer(R__b);
519 R__b >> fPadHits; // diff
520 R__b >> fNLocalTrigger;
521 R__b >> fLocalTrigger;
522 R__b >> fNGlobalTrigger;
523 R__b >> fGlobalTrigger;
525 R__b >> fRawClusters;
526 R__b.ReadArray(fNdch);
527 R__b.ReadArray(fNrawch);
532 R__b >> fTriggerCircuits;
533 for (i =0; i<AliMUONConstants::NTriggerCircuit(); i++) {
534 iTriggerCircuit=(AliMUONTriggerCircuit*) (*fTriggerCircuits)[i];
535 iTriggerCircuit->Streamer(R__b);
537 // Stream chamber related information
538 for (i =0; i<AliMUONConstants::NCh(); i++) {
539 iChamber=(AliMUONChamber*) (*fChambers)[i];
540 iChamber->Streamer(R__b);
541 if (iChamber->Nsec()==1) {
542 segmentation=iChamber->SegmentationModel(1);
544 segmentation->Streamer(R__b);
546 segmentation=iChamber->SegmentationModel(1);
548 segmentation->Streamer(R__b);
550 segmentation=iChamber->SegmentationModel(2);
551 segmentation->Streamer(R__b);
553 response=iChamber->ResponseModel();
555 response->Streamer(R__b);
556 digitsaddress=(TClonesArray*) (*fDchambers)[i];
557 digitsaddress->Streamer(R__b);
558 if (i < AliMUONConstants::NTrackingCh()) {
559 rawcladdress=(TClonesArray*) (*fRawClusters)[i];
560 rawcladdress->Streamer(R__b);
565 R__b.WriteVersion(AliMUON::IsA());
566 AliDetector::Streamer(R__b);
568 R__b << fPadHits; // diff
569 R__b << fNLocalTrigger;
570 R__b << fLocalTrigger;
571 R__b << fNGlobalTrigger;
572 R__b << fGlobalTrigger;
574 R__b << fRawClusters;
575 R__b.WriteArray(fNdch, AliMUONConstants::NCh());
576 R__b.WriteArray(fNrawch, AliMUONConstants::NTrackingCh());
583 R__b << fTriggerCircuits;
584 for (i =0; i<AliMUONConstants::NTriggerCircuit(); i++) {
585 iTriggerCircuit=(AliMUONTriggerCircuit*) (*fTriggerCircuits)[i];
586 iTriggerCircuit->Streamer(R__b);
588 for (i =0; i<AliMUONConstants::NCh(); i++) {
589 iChamber=(AliMUONChamber*) (*fChambers)[i];
590 iChamber->Streamer(R__b);
591 if (iChamber->Nsec()==1) {
592 segmentation=iChamber->SegmentationModel(1);
594 segmentation->Streamer(R__b);
596 segmentation=iChamber->SegmentationModel(1);
598 segmentation->Streamer(R__b);
599 segmentation=iChamber->SegmentationModel(2);
601 segmentation->Streamer(R__b);
603 response=iChamber->ResponseModel();
605 response->Streamer(R__b);
606 digitsaddress=(TClonesArray*) (*fDchambers)[i];
607 digitsaddress->Streamer(R__b);
608 if (i < AliMUONConstants::NTrackingCh()) {
609 rawcladdress=(TClonesArray*) (*fRawClusters)[i];
610 rawcladdress->Streamer(R__b);
616 //_______________________________________________________________________
617 AliMUONPadHit* AliMUON::FirstPad(AliMUONHit* hit, TClonesArray *clusters)
620 // Initialise the pad iterator
621 // Return the address of the first padhit for hit
622 TClonesArray *theClusters = clusters;
623 Int_t nclust = theClusters->GetEntriesFast();
624 if (nclust && hit->PHlast() > 0) {
625 AliMUON::fMaxIterPad=hit->PHlast();
626 AliMUON::fCurIterPad=hit->PHfirst();
627 return (AliMUONPadHit*) clusters->UncheckedAt(AliMUON::fCurIterPad-1);
632 //_______________________________________________________________________
633 AliMUONPadHit* AliMUON::NextPad(TClonesArray *clusters)
636 // Get next pad (in iterator)
638 AliMUON::fCurIterPad++;
639 if (AliMUON::fCurIterPad <= AliMUON::fMaxIterPad) {
640 return (AliMUONPadHit*) clusters->UncheckedAt(AliMUON::fCurIterPad-1);
645 //_______________________________________________________________________
647 AliMUONRawCluster *AliMUON::RawCluster(Int_t ichamber, Int_t icathod, Int_t icluster)
650 // Return rawcluster (icluster) for chamber ichamber and cathode icathod
652 TClonesArray *muonRawCluster = GetMUONData()->RawClusters(ichamber);
654 TTree *treeR = fLoader->TreeR();
655 Int_t nent=(Int_t)treeR->GetEntries();
656 treeR->GetEvent(nent-2+icathod-1);
657 //treeR->GetEvent(icathod);
658 //Int_t nrawcl = (Int_t)muonRawCluster->GetEntriesFast();
660 AliMUONRawCluster * mRaw = (AliMUONRawCluster*)muonRawCluster->UncheckedAt(icluster);
661 //printf("RawCluster _ nent nrawcl icluster mRaw %d %d %d%p\n",nent,nrawcl,icluster,mRaw);
665 //________________________________________________________________________
666 void AliMUON::SetMerger(AliMUONMerger* merger)
668 // Set pointer to merger
671 //________________________________________________________________________
672 AliMUONMerger* AliMUON::Merger()
674 // Return pointer to merger
677 //________________________________________________________________________
678 AliMUON& AliMUON::operator = (const AliMUON& /*rhs*/)