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
104 //__________________________________________________________________
105 AliMUON::AliMUON(const char *name, const char *title)
106 : AliDetector(name,title)
110 <img src="gif/alimuon.gif">
116 fNCh = AliMUONConstants::NCh();
117 fNTrackingCh = AliMUONConstants::NTrackingCh();
119 SetMarkerColor(kRed);//
121 // Creating List of Chambers
123 fChambers = new TObjArray(AliMUONConstants::NCh());
124 // Loop over stations
125 for (Int_t st = 0; st < AliMUONConstants::NCh() / 2; st++) {
126 // Loop over 2 chambers in the station
127 for (Int_t stCH = 0; stCH < 2; stCH++) {
130 // Default Parameters for Muon Tracking Stations
132 if (ch < AliMUONConstants::NTrackingCh()) {
133 fChambers->AddAt(new AliMUONChamber(ch),ch);
135 fChambers->AddAt(new AliMUONChamberTrigger(ch),ch);
137 AliMUONChamber* chamber = (AliMUONChamber*) fChambers->At(ch);
139 // Default values for Z of chambers
140 chamber->SetZ(AliMUONConstants::DefaultChamberZ(ch));
142 chamber->InitGeo(AliMUONConstants::DefaultChamberZ(ch));
143 // Set chamber inner and outer radius to default
144 chamber->SetRInner(AliMUONConstants::Dmin(st)/2);
145 chamber->SetROuter(AliMUONConstants::Dmax(st)/2);
147 } // Chamber stCH (0, 1) in
148 } // Station st (0...)
162 // cp new design of AliMUONTriggerDecision
163 fTriggerCircuits = new TObjArray(AliMUONConstants::NTriggerCircuit());
164 for (Int_t circ=0; circ<AliMUONConstants::NTriggerCircuit(); circ++) {
165 fTriggerCircuits->AddAt(new AliMUONTriggerCircuit(),circ);
169 //____________________________________________________________________
170 AliMUON::AliMUON(const AliMUON& rMUON):AliDetector(rMUON)
172 // Dummy copy constructor
176 //____________________________________________________________________
180 if(fDebug) printf("%s: Calling AliMUON destructor !!!\n",ClassName());
182 if (fMerger) delete fMerger;
184 //____________________________________________________________________
185 void AliMUON::BuildGeometry()
187 // Geometry for event display
188 for (Int_t i=0; i<7; i++) {
189 for (Int_t j=0; j<2; j++) {
191 this->Chamber(id-1).SegmentationModel(1)->Draw("eventdisplay");
195 //___________________________________________________________________
196 Int_t AliMUON::DistancetoPrimitive(Int_t , Int_t )
200 //__________________________________________________________________
201 void AliMUON::SetTreeAddress()
203 GetMUONData()->SetLoader(fLoader);
204 GetMUONData()->SetTreeAddress("H,D,RC");
207 //____________________________________________________________________
208 void AliMUON::SetPadSize(Int_t id, Int_t isec, Float_t p1, Float_t p2)
210 // Set the pad size for chamber id and cathode isec
212 ((AliMUONChamber*) fChambers->At(i)) ->SetPadSize(isec,p1,p2);
213 ((AliMUONChamber*) fChambers->At(i+1))->SetPadSize(isec,p1,p2);
216 //___________________________________________
217 void AliMUON::SetChambersZ(const Float_t *Z)
219 // Set Z values for all chambers (tracking and trigger)
220 // from the array pointed to by "Z"
221 for (Int_t ch = 0; ch < AliMUONConstants::NCh(); ch++)
222 ((AliMUONChamber*) fChambers->At(ch))->SetZ(Z[ch]);
225 //_________________________________________________________________
226 void AliMUON::SetChambersZToDefault()
228 // Set Z values for all chambers (tracking and trigger)
230 SetChambersZ(AliMUONConstants::DefaultChamberZ());
233 //_________________________________________________________________
234 void AliMUON::SetChargeSlope(Int_t id, Float_t p1)
236 // Set the inverse charge slope for chamber id
237 Int_t i=2*(id-1); //PH ((AliMUONChamber*) (*fChambers)[i])->SetSigmaIntegration(p1);
238 //PH ((AliMUONChamber*) (*fChambers)[i+1])->SetSigmaIntegration(p1);
239 ((AliMUONChamber*) fChambers->At(i))->SetChargeSlope(p1);
240 ((AliMUONChamber*) fChambers->At(i+1))->SetChargeSlope(p1);
242 //__________________________________________________________________
243 void AliMUON::SetChargeSpread(Int_t id, Float_t p1, Float_t p2)
245 // Set sigma of charge spread for chamber id
247 ((AliMUONChamber*) fChambers->At(i))->SetChargeSpread(p1,p2);
248 ((AliMUONChamber*) fChambers->At(i+1))->SetChargeSpread(p1,p2);
250 //___________________________________________________________________
251 void AliMUON::SetSigmaIntegration(Int_t id, Float_t p1)
253 // Set integration limits for charge spread
255 ((AliMUONChamber*) fChambers->At(i))->SetSigmaIntegration(p1);
256 ((AliMUONChamber*) fChambers->At(i+1))->SetSigmaIntegration(p1);
259 //__________________________________________________________________
260 void AliMUON::SetMaxAdc(Int_t id, Int_t p1)
262 // Set maximum number for ADCcounts (saturation)
264 ((AliMUONChamber*) fChambers->At(i))->SetMaxAdc(p1);
265 ((AliMUONChamber*) fChambers->At(i+1))->SetMaxAdc(p1);
267 //__________________________________________________________________
268 void AliMUON::SetMaxStepGas(Float_t p1)
270 // Set stepsize in gas
273 //__________________________________________________________________
274 void AliMUON::SetMaxStepAlu(Float_t p1)
276 // Set step size in Alu
279 //__________________________________________________________________
280 void AliMUON::SetMaxDestepGas(Float_t p1)
282 // Set maximum step size in Gas
285 //__________________________________________________________________
286 void AliMUON::SetMaxDestepAlu(Float_t p1)
288 // Set maximum step size in Alu
291 //___________________________________________________________________
292 void AliMUON::SetAcceptance(Bool_t acc, Float_t angmin, Float_t angmax)
294 // Set acceptance cuts
296 fAccMin=angmin*TMath::Pi()/180;
297 fAccMax=angmax*TMath::Pi()/180;
300 for (Int_t st = 0; st < AliMUONConstants::NCh() / 2; st++) {
301 // Loop over 2 chambers in the station
302 for (Int_t stCH = 0; stCH < 2; stCH++) {
304 // Set chamber inner and outer radius according to acceptance cuts
305 Chamber(ch).SetRInner(TMath::Abs(AliMUONConstants::DefaultChamberZ(ch)*TMath::Tan(fAccMin)));
306 Chamber(ch).SetROuter(TMath::Abs(AliMUONConstants::DefaultChamberZ(ch)*TMath::Tan(fAccMax)));
311 //____________________________________________________________________
312 void AliMUON::SetSegmentationModel(Int_t id, Int_t isec, AliSegmentation *segmentation)
314 // Set the segmentation for chamber id cathode isec
315 ((AliMUONChamber*) fChambers->At(id))->SetSegmentationModel(isec, segmentation);
318 //____________________________________________________________________
319 void AliMUON::SetResponseModel(Int_t id, AliMUONResponse *response)
321 // Set the response for chamber id
322 ((AliMUONChamber*) fChambers->At(id))->SetResponseModel(response);
324 //____________________________________________________________________
325 void AliMUON::SetReconstructionModel(Int_t id, AliMUONClusterFinderVS *reconst)
327 // Set ClusterFinder for chamber id
328 ((AliMUONChamber*) fChambers->At(id))->SetReconstructionModel(reconst);
330 //____________________________________________________________________
331 void AliMUON::SetNsec(Int_t id, Int_t nsec)
333 // Set number of segmented cathods for chamber id
334 ((AliMUONChamber*) fChambers->At(id))->SetNsec(nsec);
336 //_____________________________________________________________________
337 void AliMUON::SDigits2Digits()
343 if (gAlice->GetDebug()>0) {
344 cerr<<"AliMUON::SDigits2Digits: create default AliMUONMerger "<<endl;
345 cerr<<" no merging, just digitization of 1 event will be done"<<endl;
347 fMerger = new AliMUONMerger();
352 // sprintf(hname,"TreeD%d",fLoader->GetHeader()->GetEvent());
353 fLoader->TreeD()->Write(hname,TObject::kOverwrite);
354 fLoader->TreeD()->Reset();
357 //_______________________________________________________________________
358 AliLoader* AliMUON::MakeLoader(const char* topfoldername)
360 //builds standard getter (AliLoader type)
361 //if detector wants to use castomized getter, it must overload this method
365 "Creating standard getter for detector %s. Top folder is %s.",
366 GetName(),topfoldername);
368 fLoader = new AliLoader(GetName(),topfoldername);
369 fMUONData = new AliMUONData(fLoader,GetName(),GetName());
373 //_______________________________________________________________________
374 void AliMUON::Trigger(Int_t nev){
375 // call the Trigger Algorithm and fill TreeR
377 Int_t singlePlus[3] = {0,0,0};
378 Int_t singleMinus[3] = {0,0,0};
379 Int_t singleUndef[3] = {0,0,0};
380 Int_t pairUnlike[3] = {0,0,0};
381 Int_t pairLike[3] = {0,0,0};
384 AliMUONTriggerDecision* decision= new AliMUONTriggerDecision(1);
386 decision->GetGlobalTrigger(singlePlus, singleMinus, singleUndef,
387 pairUnlike, pairLike);
389 // add a local trigger in the list
390 GetMUONData()->AddGlobalTrigger(singlePlus, singleMinus, singleUndef, pairUnlike, pairLike);
393 for (Int_t icirc=0; icirc<AliMUONConstants::NTriggerCircuit(); icirc++) {
394 if(decision->GetITrigger(icirc)==1) {
395 Int_t localtr[7]={0,0,0,0,0,0,0};
396 Int_t loLpt[2]={0,0}; Int_t loHpt[2]={0,0}; Int_t loApt[2]={0,0};
397 decision->GetLutOutput(icirc, loLpt, loHpt, loApt);
399 localtr[1] = decision->GetStripX11(icirc);
400 localtr[2] = decision->GetDev(icirc);
401 localtr[3] = decision->GetStripY11(icirc);
402 for (i=0; i<2; i++) { // convert the Lut output in 1 digit
403 localtr[4] = localtr[4]+Int_t(loLpt[i]*TMath::Power(2,i));
404 localtr[5] = localtr[5]+Int_t(loHpt[i]*TMath::Power(2,i));
405 localtr[6] = localtr[6]+Int_t(loApt[i]*TMath::Power(2,i));
407 GetMUONData()->AddLocalTrigger(localtr); // add a local trigger in the list
413 // fLoader->TreeR()->Fill();
414 GetMUONData()->Fill("GLT"); //Filling Global and Local Trigger GLT
416 // sprintf(hname,"TreeR%d",nev);
417 // fLoader->TreeR()->Write(hname,TObject::kOverwrite);
418 // fLoader->TreeR()->Reset();
419 fLoader->WriteRecPoints("OVERWRITE");
421 printf("\n End of trigger for event %d", nev);
424 //____________________________________________________________________
425 void AliMUON::Digits2Reco()
428 Int_t nev = gAlice->GetHeader()->GetEvent();
429 GetMUONData()->Fill("RC"); //Filling Reconstructed Cluster
430 fLoader->WriteRecPoints("OVERWRITE");
431 GetMUONData()->ResetRawClusters();
432 Info("Digits2Reco","End of cluster finding for event %d", nev);
434 //____________________________________________________________________
435 void AliMUON::FindClusters()
438 // Perform cluster finding
440 TClonesArray *dig1, *dig2;
442 dig1 = new TClonesArray("AliMUONDigit",1000);
443 dig2 = new TClonesArray("AliMUONDigit",1000);
445 // Loop on chambers and on cathode planes
448 TClonesArray * muonDigits;
450 for (Int_t ich = 0; ich < 10; ich++) {
451 //PH AliMUONChamber* iChamber = (AliMUONChamber*) (*fChambers)[ich];
452 AliMUONChamber* iChamber = (AliMUONChamber*) fChambers->At(ich);
453 AliMUONClusterFinderVS* rec = iChamber->ReconstructionModel();
456 GetMUONData()->GetCathode(0);
458 muonDigits = GetMUONData()->Digits(ich);
459 ndig=muonDigits->GetEntriesFast();
460 printf("\n 1 Found %d digits in %p chamber %d", ndig, muonDigits,ich);
461 TClonesArray &lhits1 = *dig1;
463 for (k = 0; k < ndig; k++) {
464 digit = (AliMUONDigit*) muonDigits->UncheckedAt(k);
465 if (rec->TestTrack(digit->Track(0)))
466 new(lhits1[n++]) AliMUONDigit(*digit);
468 GetMUONData()->ResetDigits();
469 GetMUONData()->GetCathode(1);
470 muonDigits = GetMUONData()->Digits(ich);
471 ndig=muonDigits->GetEntriesFast();
472 printf("\n 2 Found %d digits in %p %d", ndig, muonDigits, ich);
473 TClonesArray &lhits2 = *dig2;
476 for (k=0; k<ndig; k++) {
477 digit= (AliMUONDigit*) muonDigits->UncheckedAt(k);
478 if (rec->TestTrack(digit->Track(0)))
479 new(lhits2[n++]) AliMUONDigit(*digit);
483 AliMUONClusterInput::Instance()->SetDigits(ich, dig1, dig2);
484 rec->FindRawClusters();
492 //______________________________________________________________________
494 void AliMUON::Streamer(TBuffer &R__b)_
496 // Stream an object of class AliMUON.
497 AliMUONChamber *iChamber;
498 AliMUONTriggerCircuit *iTriggerCircuit;
499 AliSegmentation *segmentation;
500 AliMUONResponse *response;
501 TClonesArray *digitsaddress;
502 TClonesArray *rawcladdress;
504 if (R__b.IsReading()) {
505 Version_t R__v = R__b.ReadVersion(); if (R__v) { }
506 AliDetector::Streamer(R__b);
508 R__b >> fPadHits; // diff
509 R__b >> fNLocalTrigger;
510 R__b >> fLocalTrigger;
511 R__b >> fNGlobalTrigger;
512 R__b >> fGlobalTrigger;
514 R__b >> fRawClusters;
515 R__b.ReadArray(fNdch);
516 R__b.ReadArray(fNrawch);
521 R__b >> fTriggerCircuits;
522 for (i =0; i<AliMUONConstants::NTriggerCircuit(); i++) {
523 iTriggerCircuit=(AliMUONTriggerCircuit*) (*fTriggerCircuits)[i];
524 iTriggerCircuit->Streamer(R__b);
526 // Stream chamber related information
527 for (i =0; i<AliMUONConstants::NCh(); i++) {
528 iChamber=(AliMUONChamber*) (*fChambers)[i];
529 iChamber->Streamer(R__b);
530 if (iChamber->Nsec()==1) {
531 segmentation=iChamber->SegmentationModel(1);
533 segmentation->Streamer(R__b);
535 segmentation=iChamber->SegmentationModel(1);
537 segmentation->Streamer(R__b);
539 segmentation=iChamber->SegmentationModel(2);
540 segmentation->Streamer(R__b);
542 response=iChamber->ResponseModel();
544 response->Streamer(R__b);
545 digitsaddress=(TClonesArray*) (*fDchambers)[i];
546 digitsaddress->Streamer(R__b);
547 if (i < AliMUONConstants::NTrackingCh()) {
548 rawcladdress=(TClonesArray*) (*fRawClusters)[i];
549 rawcladdress->Streamer(R__b);
554 R__b.WriteVersion(AliMUON::IsA());
555 AliDetector::Streamer(R__b);
557 R__b << fPadHits; // diff
558 R__b << fNLocalTrigger;
559 R__b << fLocalTrigger;
560 R__b << fNGlobalTrigger;
561 R__b << fGlobalTrigger;
563 R__b << fRawClusters;
564 R__b.WriteArray(fNdch, AliMUONConstants::NCh());
565 R__b.WriteArray(fNrawch, AliMUONConstants::NTrackingCh());
572 R__b << fTriggerCircuits;
573 for (i =0; i<AliMUONConstants::NTriggerCircuit(); i++) {
574 iTriggerCircuit=(AliMUONTriggerCircuit*) (*fTriggerCircuits)[i];
575 iTriggerCircuit->Streamer(R__b);
577 for (i =0; i<AliMUONConstants::NCh(); i++) {
578 iChamber=(AliMUONChamber*) (*fChambers)[i];
579 iChamber->Streamer(R__b);
580 if (iChamber->Nsec()==1) {
581 segmentation=iChamber->SegmentationModel(1);
583 segmentation->Streamer(R__b);
585 segmentation=iChamber->SegmentationModel(1);
587 segmentation->Streamer(R__b);
588 segmentation=iChamber->SegmentationModel(2);
590 segmentation->Streamer(R__b);
592 response=iChamber->ResponseModel();
594 response->Streamer(R__b);
595 digitsaddress=(TClonesArray*) (*fDchambers)[i];
596 digitsaddress->Streamer(R__b);
597 if (i < AliMUONConstants::NTrackingCh()) {
598 rawcladdress=(TClonesArray*) (*fRawClusters)[i];
599 rawcladdress->Streamer(R__b);
605 //_______________________________________________________________________
606 AliMUONPadHit* AliMUON::FirstPad(AliMUONHit* hit, TClonesArray *clusters)
609 // Initialise the pad iterator
610 // Return the address of the first padhit for hit
611 TClonesArray *theClusters = clusters;
612 Int_t nclust = theClusters->GetEntriesFast();
613 if (nclust && hit->PHlast() > 0) {
614 AliMUON::fMaxIterPad=hit->PHlast();
615 AliMUON::fCurIterPad=hit->PHfirst();
616 return (AliMUONPadHit*) clusters->UncheckedAt(AliMUON::fCurIterPad-1);
621 //_______________________________________________________________________
622 AliMUONPadHit* AliMUON::NextPad(TClonesArray *clusters)
625 // Get next pad (in iterator)
627 AliMUON::fCurIterPad++;
628 if (AliMUON::fCurIterPad <= AliMUON::fMaxIterPad) {
629 return (AliMUONPadHit*) clusters->UncheckedAt(AliMUON::fCurIterPad-1);
634 //_______________________________________________________________________
636 AliMUONRawCluster *AliMUON::RawCluster(Int_t ichamber, Int_t icathod, Int_t icluster)
639 // Return rawcluster (icluster) for chamber ichamber and cathode icathod
641 TClonesArray *muonRawCluster = GetMUONData()->RawClusters(ichamber);
643 TTree *treeR = fLoader->TreeR();
644 Int_t nent=(Int_t)treeR->GetEntries();
645 treeR->GetEvent(nent-2+icathod-1);
646 //treeR->GetEvent(icathod);
647 //Int_t nrawcl = (Int_t)muonRawCluster->GetEntriesFast();
649 AliMUONRawCluster * mRaw = (AliMUONRawCluster*)muonRawCluster->UncheckedAt(icluster);
650 //printf("RawCluster _ nent nrawcl icluster mRaw %d %d %d%p\n",nent,nrawcl,icluster,mRaw);
654 //________________________________________________________________________
655 void AliMUON::SetMerger(AliMUONMerger* merger)
657 // Set pointer to merger
660 //________________________________________________________________________
661 AliMUONMerger* AliMUON::Merger()
663 // Return pointer to merger
666 //________________________________________________________________________
667 AliMUON& AliMUON::operator = (const AliMUON& /*rhs*/)