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
103 //__________________________________________________________________
104 AliMUON::AliMUON(const char *name, const char *title)
105 : AliDetector(name,title)
109 <img src="gif/alimuon.gif">
115 fNCh = AliMUONConstants::NCh();
116 fNTrackingCh = AliMUONConstants::NTrackingCh();
118 SetMarkerColor(kRed);//
120 // Creating List of Chambers
122 fChambers = new TObjArray(AliMUONConstants::NCh());
123 // Loop over stations
124 for (Int_t st = 0; st < AliMUONConstants::NCh() / 2; st++) {
125 // Loop over 2 chambers in the station
126 for (Int_t stCH = 0; stCH < 2; stCH++) {
129 // Default Parameters for Muon Tracking Stations
131 if (ch < AliMUONConstants::NTrackingCh()) {
132 fChambers->AddAt(new AliMUONChamber(ch),ch);
134 fChambers->AddAt(new AliMUONChamberTrigger(ch),ch);
136 AliMUONChamber* chamber = (AliMUONChamber*) fChambers->At(ch);
138 // Default values for Z of chambers
139 chamber->SetZ(AliMUONConstants::DefaultChamberZ(ch));
141 chamber->InitGeo(AliMUONConstants::DefaultChamberZ(ch));
142 // Set chamber inner and outer radius to default
143 chamber->SetRInner(AliMUONConstants::Dmin(st)/2);
144 chamber->SetROuter(AliMUONConstants::Dmax(st)/2);
146 } // Chamber stCH (0, 1) in
147 } // Station st (0...)
161 // cp new design of AliMUONTriggerDecision
162 fTriggerCircuits = new TObjArray(AliMUONConstants::NTriggerCircuit());
163 for (Int_t circ=0; circ<AliMUONConstants::NTriggerCircuit(); circ++) {
164 fTriggerCircuits->AddAt(new AliMUONTriggerCircuit(),circ);
168 //____________________________________________________________________
169 AliMUON::AliMUON(const AliMUON& rMUON):AliDetector(rMUON)
171 // Dummy copy constructor
175 //____________________________________________________________________
179 if(fDebug) printf("%s: Calling AliMUON destructor !!!\n",ClassName());
181 if (fMerger) delete fMerger;
183 //____________________________________________________________________
184 void AliMUON::BuildGeometry()
186 // Geometry for event display
187 for (Int_t i=0; i<7; i++) {
188 for (Int_t j=0; j<2; j++) {
190 this->Chamber(id-1).SegmentationModel(1)->Draw("eventdisplay");
194 //___________________________________________________________________
195 Int_t AliMUON::DistancetoPrimitive(Int_t , Int_t )
199 //__________________________________________________________________
200 void AliMUON::SetTreeAddress()
202 GetMUONData()->SetLoader(fLoader);
203 GetMUONData()->SetTreeAddress("H,D,RC");
206 //____________________________________________________________________
207 void AliMUON::SetPadSize(Int_t id, Int_t isec, Float_t p1, Float_t p2)
209 // Set the pad size for chamber id and cathode isec
211 ((AliMUONChamber*) fChambers->At(i)) ->SetPadSize(isec,p1,p2);
212 ((AliMUONChamber*) fChambers->At(i+1))->SetPadSize(isec,p1,p2);
215 //___________________________________________
216 void AliMUON::SetChambersZ(const Float_t *Z)
218 // Set Z values for all chambers (tracking and trigger)
219 // from the array pointed to by "Z"
220 for (Int_t ch = 0; ch < AliMUONConstants::NCh(); ch++)
221 ((AliMUONChamber*) fChambers->At(ch))->SetZ(Z[ch]);
224 //_________________________________________________________________
225 void AliMUON::SetChambersZToDefault()
227 // Set Z values for all chambers (tracking and trigger)
229 SetChambersZ(AliMUONConstants::DefaultChamberZ());
232 //_________________________________________________________________
233 void AliMUON::SetChargeSlope(Int_t id, Float_t p1)
235 // Set the inverse charge slope for chamber id
236 Int_t i=2*(id-1); //PH ((AliMUONChamber*) (*fChambers)[i])->SetSigmaIntegration(p1);
237 //PH ((AliMUONChamber*) (*fChambers)[i+1])->SetSigmaIntegration(p1);
238 ((AliMUONChamber*) fChambers->At(i))->SetChargeSlope(p1);
239 ((AliMUONChamber*) fChambers->At(i+1))->SetChargeSlope(p1);
241 //__________________________________________________________________
242 void AliMUON::SetChargeSpread(Int_t id, Float_t p1, Float_t p2)
244 // Set sigma of charge spread for chamber id
246 ((AliMUONChamber*) fChambers->At(i))->SetChargeSpread(p1,p2);
247 ((AliMUONChamber*) fChambers->At(i+1))->SetChargeSpread(p1,p2);
249 //___________________________________________________________________
250 void AliMUON::SetSigmaIntegration(Int_t id, Float_t p1)
252 // Set integration limits for charge spread
254 ((AliMUONChamber*) fChambers->At(i))->SetSigmaIntegration(p1);
255 ((AliMUONChamber*) fChambers->At(i+1))->SetSigmaIntegration(p1);
258 //__________________________________________________________________
259 void AliMUON::SetMaxAdc(Int_t id, Int_t p1)
261 // Set maximum number for ADCcounts (saturation)
263 ((AliMUONChamber*) fChambers->At(i))->SetMaxAdc(p1);
264 ((AliMUONChamber*) fChambers->At(i+1))->SetMaxAdc(p1);
266 //__________________________________________________________________
267 void AliMUON::SetMaxStepGas(Float_t p1)
269 // Set stepsize in gas
272 //__________________________________________________________________
273 void AliMUON::SetMaxStepAlu(Float_t p1)
275 // Set step size in Alu
278 //__________________________________________________________________
279 void AliMUON::SetMaxDestepGas(Float_t p1)
281 // Set maximum step size in Gas
284 //__________________________________________________________________
285 void AliMUON::SetMaxDestepAlu(Float_t p1)
287 // Set maximum step size in Alu
290 //___________________________________________________________________
291 void AliMUON::SetAcceptance(Bool_t acc, Float_t angmin, Float_t angmax)
293 // Set acceptance cuts
295 fAccMin=angmin*TMath::Pi()/180;
296 fAccMax=angmax*TMath::Pi()/180;
299 for (Int_t st = 0; st < AliMUONConstants::NCh() / 2; st++) {
300 // Loop over 2 chambers in the station
301 for (Int_t stCH = 0; stCH < 2; stCH++) {
303 // Set chamber inner and outer radius according to acceptance cuts
304 Chamber(ch).SetRInner(AliMUONConstants::DefaultChamberZ(ch)*TMath::Tan(fAccMin));
305 Chamber(ch).SetROuter(AliMUONConstants::DefaultChamberZ(ch)*TMath::Tan(fAccMax));
310 //____________________________________________________________________
311 void AliMUON::SetSegmentationModel(Int_t id, Int_t isec, AliSegmentation *segmentation)
313 // Set the segmentation for chamber id cathode isec
314 ((AliMUONChamber*) fChambers->At(id))->SetSegmentationModel(isec, segmentation);
317 //____________________________________________________________________
318 void AliMUON::SetResponseModel(Int_t id, AliMUONResponse *response)
320 // Set the response for chamber id
321 ((AliMUONChamber*) fChambers->At(id))->SetResponseModel(response);
323 //____________________________________________________________________
324 void AliMUON::SetReconstructionModel(Int_t id, AliMUONClusterFinderVS *reconst)
326 // Set ClusterFinder for chamber id
327 ((AliMUONChamber*) fChambers->At(id))->SetReconstructionModel(reconst);
329 //____________________________________________________________________
330 void AliMUON::SetNsec(Int_t id, Int_t nsec)
332 // Set number of segmented cathods for chamber id
333 ((AliMUONChamber*) fChambers->At(id))->SetNsec(nsec);
335 //_____________________________________________________________________
336 void AliMUON::SDigits2Digits()
342 if (gAlice->GetDebug()>0) {
343 cerr<<"AliMUON::SDigits2Digits: create default AliMUONMerger "<<endl;
344 cerr<<" no merging, just digitization of 1 event will be done"<<endl;
346 fMerger = new AliMUONMerger();
351 // sprintf(hname,"TreeD%d",fLoader->GetHeader()->GetEvent());
352 fLoader->TreeD()->Write(hname,TObject::kOverwrite);
353 fLoader->TreeD()->Reset();
356 //_______________________________________________________________________
357 AliLoader* AliMUON::MakeLoader(const char* topfoldername)
359 //builds standard getter (AliLoader type)
360 //if detector wants to use castomized getter, it must overload this method
364 "Creating standard getter for detector %s. Top folder is %s.",
365 GetName(),topfoldername);
367 fLoader = new AliLoader(GetName(),topfoldername);
368 fMUONData = new AliMUONData(fLoader,GetName(),GetName());
372 //_______________________________________________________________________
373 void AliMUON::Trigger(Int_t nev){
374 // call the Trigger Algorithm and fill TreeR
376 Int_t singlePlus[3] = {0,0,0};
377 Int_t singleMinus[3] = {0,0,0};
378 Int_t singleUndef[3] = {0,0,0};
379 Int_t pairUnlike[3] = {0,0,0};
380 Int_t pairLike[3] = {0,0,0};
383 AliMUONTriggerDecision* decision= new AliMUONTriggerDecision(1);
385 decision->GetGlobalTrigger(singlePlus, singleMinus, singleUndef,
386 pairUnlike, pairLike);
388 // add a local trigger in the list
389 GetMUONData()->AddGlobalTrigger(singlePlus, singleMinus, singleUndef, pairUnlike, pairLike);
392 for (Int_t icirc=0; icirc<AliMUONConstants::NTriggerCircuit(); icirc++) {
393 if(decision->GetITrigger(icirc)==1) {
394 Int_t localtr[7]={0,0,0,0,0,0,0};
395 Int_t loLpt[2]={0,0}; Int_t loHpt[2]={0,0}; Int_t loApt[2]={0,0};
396 decision->GetLutOutput(icirc, loLpt, loHpt, loApt);
398 localtr[1] = decision->GetStripX11(icirc);
399 localtr[2] = decision->GetDev(icirc);
400 localtr[3] = decision->GetStripY11(icirc);
401 for (i=0; i<2; i++) { // convert the Lut output in 1 digit
402 localtr[4] = localtr[4]+Int_t(loLpt[i]*TMath::Power(2,i));
403 localtr[5] = localtr[5]+Int_t(loHpt[i]*TMath::Power(2,i));
404 localtr[6] = localtr[6]+Int_t(loApt[i]*TMath::Power(2,i));
406 GetMUONData()->AddLocalTrigger(localtr); // add a local trigger in the list
412 // fLoader->TreeR()->Fill();
413 GetMUONData()->Fill("GLT"); //Filling Global and Local Trigger GLT
415 // sprintf(hname,"TreeR%d",nev);
416 // fLoader->TreeR()->Write(hname,TObject::kOverwrite);
417 // fLoader->TreeR()->Reset();
418 fLoader->WriteRecPoints("OVERWRITE");
420 printf("\n End of trigger for event %d", nev);
423 //____________________________________________________________________
424 void AliMUON::Digits2Reco()
427 Int_t nev = gAlice->GetHeader()->GetEvent();
428 GetMUONData()->Fill("RC"); //Filling Reconstructed Cluster
429 fLoader->WriteRecPoints("OVERWRITE");
430 GetMUONData()->ResetRawClusters();
431 Info("Digits2Reco","End of cluster finding for event %d", nev);
433 //____________________________________________________________________
434 void AliMUON::FindClusters()
437 // Perform cluster finding
439 TClonesArray *dig1, *dig2;
441 dig1 = new TClonesArray("AliMUONDigit",1000);
442 dig2 = new TClonesArray("AliMUONDigit",1000);
444 // Loop on chambers and on cathode planes
447 TClonesArray * muonDigits;
449 for (Int_t ich = 0; ich < 10; ich++) {
450 //PH AliMUONChamber* iChamber = (AliMUONChamber*) (*fChambers)[ich];
451 AliMUONChamber* iChamber = (AliMUONChamber*) fChambers->At(ich);
452 AliMUONClusterFinderVS* rec = iChamber->ReconstructionModel();
455 GetMUONData()->GetCathode(0);
457 muonDigits = GetMUONData()->Digits(ich);
458 ndig=muonDigits->GetEntriesFast();
459 printf("\n 1 Found %d digits in %p chamber %d", ndig, muonDigits,ich);
460 TClonesArray &lhits1 = *dig1;
462 for (k = 0; k < ndig; k++) {
463 digit = (AliMUONDigit*) muonDigits->UncheckedAt(k);
464 if (rec->TestTrack(digit->Track(0)))
465 new(lhits1[n++]) AliMUONDigit(*digit);
467 GetMUONData()->ResetDigits();
468 GetMUONData()->GetCathode(1);
469 muonDigits = GetMUONData()->Digits(ich);
470 ndig=muonDigits->GetEntriesFast();
471 printf("\n 2 Found %d digits in %p %d", ndig, muonDigits, ich);
472 TClonesArray &lhits2 = *dig2;
475 for (k=0; k<ndig; k++) {
476 digit= (AliMUONDigit*) muonDigits->UncheckedAt(k);
477 if (rec->TestTrack(digit->Track(0)))
478 new(lhits2[n++]) AliMUONDigit(*digit);
482 AliMUONClusterInput::Instance()->SetDigits(ich, dig1, dig2);
483 rec->FindRawClusters();
491 //______________________________________________________________________
493 void AliMUON::Streamer(TBuffer &R__b)_
495 // Stream an object of class AliMUON.
496 AliMUONChamber *iChamber;
497 AliMUONTriggerCircuit *iTriggerCircuit;
498 AliSegmentation *segmentation;
499 AliMUONResponse *response;
500 TClonesArray *digitsaddress;
501 TClonesArray *rawcladdress;
503 if (R__b.IsReading()) {
504 Version_t R__v = R__b.ReadVersion(); if (R__v) { }
505 AliDetector::Streamer(R__b);
507 R__b >> fPadHits; // diff
508 R__b >> fNLocalTrigger;
509 R__b >> fLocalTrigger;
510 R__b >> fNGlobalTrigger;
511 R__b >> fGlobalTrigger;
513 R__b >> fRawClusters;
514 R__b.ReadArray(fNdch);
515 R__b.ReadArray(fNrawch);
520 R__b >> fTriggerCircuits;
521 for (i =0; i<AliMUONConstants::NTriggerCircuit(); i++) {
522 iTriggerCircuit=(AliMUONTriggerCircuit*) (*fTriggerCircuits)[i];
523 iTriggerCircuit->Streamer(R__b);
525 // Stream chamber related information
526 for (i =0; i<AliMUONConstants::NCh(); i++) {
527 iChamber=(AliMUONChamber*) (*fChambers)[i];
528 iChamber->Streamer(R__b);
529 if (iChamber->Nsec()==1) {
530 segmentation=iChamber->SegmentationModel(1);
532 segmentation->Streamer(R__b);
534 segmentation=iChamber->SegmentationModel(1);
536 segmentation->Streamer(R__b);
538 segmentation=iChamber->SegmentationModel(2);
539 segmentation->Streamer(R__b);
541 response=iChamber->ResponseModel();
543 response->Streamer(R__b);
544 digitsaddress=(TClonesArray*) (*fDchambers)[i];
545 digitsaddress->Streamer(R__b);
546 if (i < AliMUONConstants::NTrackingCh()) {
547 rawcladdress=(TClonesArray*) (*fRawClusters)[i];
548 rawcladdress->Streamer(R__b);
553 R__b.WriteVersion(AliMUON::IsA());
554 AliDetector::Streamer(R__b);
556 R__b << fPadHits; // diff
557 R__b << fNLocalTrigger;
558 R__b << fLocalTrigger;
559 R__b << fNGlobalTrigger;
560 R__b << fGlobalTrigger;
562 R__b << fRawClusters;
563 R__b.WriteArray(fNdch, AliMUONConstants::NCh());
564 R__b.WriteArray(fNrawch, AliMUONConstants::NTrackingCh());
571 R__b << fTriggerCircuits;
572 for (i =0; i<AliMUONConstants::NTriggerCircuit(); i++) {
573 iTriggerCircuit=(AliMUONTriggerCircuit*) (*fTriggerCircuits)[i];
574 iTriggerCircuit->Streamer(R__b);
576 for (i =0; i<AliMUONConstants::NCh(); i++) {
577 iChamber=(AliMUONChamber*) (*fChambers)[i];
578 iChamber->Streamer(R__b);
579 if (iChamber->Nsec()==1) {
580 segmentation=iChamber->SegmentationModel(1);
582 segmentation->Streamer(R__b);
584 segmentation=iChamber->SegmentationModel(1);
586 segmentation->Streamer(R__b);
587 segmentation=iChamber->SegmentationModel(2);
589 segmentation->Streamer(R__b);
591 response=iChamber->ResponseModel();
593 response->Streamer(R__b);
594 digitsaddress=(TClonesArray*) (*fDchambers)[i];
595 digitsaddress->Streamer(R__b);
596 if (i < AliMUONConstants::NTrackingCh()) {
597 rawcladdress=(TClonesArray*) (*fRawClusters)[i];
598 rawcladdress->Streamer(R__b);
604 //_______________________________________________________________________
605 AliMUONPadHit* AliMUON::FirstPad(AliMUONHit* hit, TClonesArray *clusters)
608 // Initialise the pad iterator
609 // Return the address of the first padhit for hit
610 TClonesArray *theClusters = clusters;
611 Int_t nclust = theClusters->GetEntriesFast();
612 if (nclust && hit->PHlast() > 0) {
613 AliMUON::fMaxIterPad=hit->PHlast();
614 AliMUON::fCurIterPad=hit->PHfirst();
615 return (AliMUONPadHit*) clusters->UncheckedAt(AliMUON::fCurIterPad-1);
620 //_______________________________________________________________________
621 AliMUONPadHit* AliMUON::NextPad(TClonesArray *clusters)
624 // Get next pad (in iterator)
626 AliMUON::fCurIterPad++;
627 if (AliMUON::fCurIterPad <= AliMUON::fMaxIterPad) {
628 return (AliMUONPadHit*) clusters->UncheckedAt(AliMUON::fCurIterPad-1);
633 //_______________________________________________________________________
635 AliMUONRawCluster *AliMUON::RawCluster(Int_t ichamber, Int_t icathod, Int_t icluster)
638 // Return rawcluster (icluster) for chamber ichamber and cathode icathod
640 TClonesArray *muonRawCluster = GetMUONData()->RawClusters(ichamber);
642 TTree *treeR = fLoader->TreeR();
643 Int_t nent=(Int_t)treeR->GetEntries();
644 treeR->GetEvent(nent-2+icathod-1);
645 //treeR->GetEvent(icathod);
646 //Int_t nrawcl = (Int_t)muonRawCluster->GetEntriesFast();
648 AliMUONRawCluster * mRaw = (AliMUONRawCluster*)muonRawCluster->UncheckedAt(icluster);
649 //printf("RawCluster _ nent nrawcl icluster mRaw %d %d %d%p\n",nent,nrawcl,icluster,mRaw);
653 //________________________________________________________________________
654 void AliMUON::SetMerger(AliMUONMerger* merger)
656 // Set pointer to merger
659 //________________________________________________________________________
660 AliMUONMerger* AliMUON::Merger()
662 // Return pointer to merger
665 //________________________________________________________________________
666 AliMUON& AliMUON::operator = (const AliMUON& /*rhs*/)