Bug on max theta (Jean Pierre)
[u/mrichter/AliRoot.git] / MUON / AliMUON.cxx
CommitLineData
4c039060 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
4c039060 15
88cb7938 16/* $Id$ */
17
a9e2aefa 18
19///////////////////////////////////////////////
fe4da5cc 20// Manager and hits classes for set:MUON //
21////////////////////////////////////////////////
22
88cb7938 23#include "Riostream.h"
24
25#include <AliPDG.h>
a897a37a 26#include <TBRIK.h>
88cb7938 27#include <TCanvas.h>
28#include <TDirectory.h>
29#include <TFile.h>
94de3818 30#include <TGeometry.h>
88cb7938 31#include <TMinuit.h>
fe4da5cc 32#include <TNode.h>
88cb7938 33#include <TNtuple.h>
fe4da5cc 34#include <TObjArray.h>
88cb7938 35#include <TObject.h>
36#include <TObjectTable.h>
37#include <TPad.h>
a897a37a 38#include <TParticle.h>
39#include <TROOT.h>
88cb7938 40#include <TRandom.h>
41#include <TRotMatrix.h>
42#include <TTUBE.h>
a9e2aefa 43#include <TTUBE.h>
88cb7938 44#include <TTree.h>
45#include <TVector.h>
46#include <TVirtualMC.h>
fe4da5cc 47
88cb7938 48#include "AliConst.h"
49#include "AliHeader.h"
50#include "AliHitMap.h"
51#include "AliLoader.h"
3fa6cfdd 52#include "AliMUONLoader.h"
fe4da5cc 53#include "AliMUON.h"
88cb7938 54#include "AliMUONChamberTrigger.h"
55#include "AliMUONClusterFinderVS.h"
56#include "AliMUONClusterInput.h"
57#include "AliMUONConstants.h"
58#include "AliMUONDigit.h"
59#include "AliMUONGlobalTrigger.h"
a9e2aefa 60#include "AliMUONHit.h"
88cb7938 61#include "AliMUONHitMapA1.h"
62#include "AliMUONLocalTrigger.h"
63#include "AliMUONMerger.h"
a9e2aefa 64#include "AliMUONPadHit.h"
a9e2aefa 65#include "AliMUONRawCluster.h"
88cb7938 66#include "AliMUONTransientDigit.h"
ecfa008b 67#include "AliMUONTriggerCircuit.h"
a9e2aefa 68#include "AliMUONTriggerDecision.h"
88cb7938 69#include "AliRun.h"
70
a9e2aefa 71
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
fe4da5cc 85
fe4da5cc 86ClassImp(AliMUON)
ce3f5e87 87//__________________________________________________________________
fe4da5cc 88AliMUON::AliMUON()
89{
de05461e 90// Default Constructor
91//
1bd28025 92 fNCh = 0;
93 fNTrackingCh = 0;
1bd26093 94 fIshunt = 0;
1bd28025 95 fChambers = 0;
ce3f5e87 96 fTriggerCircuits = 0;
1bd26093 97 fAccMin = 0.;
98 fAccMax = 0.;
99 fAccCut = kFALSE;
1cae9436 100 fMerger = 0;
edf34242 101 fFileName = 0;
aecb8bcd 102 fMUONData = 0;
fe4da5cc 103}
ce3f5e87 104//__________________________________________________________________
fe4da5cc 105AliMUON::AliMUON(const char *name, const char *title)
ce3f5e87 106 : AliDetector(name,title)
fe4da5cc 107{
108//Begin_Html
109/*
a897a37a 110<img src="gif/alimuon.gif">
fe4da5cc 111*/
112//End_Html
ce3f5e87 113 fMUONData = 0x0;
114 fIshunt = 0;
f665c1ea 115
ce3f5e87 116 fNCh = AliMUONConstants::NCh();
117 fNTrackingCh = AliMUONConstants::NTrackingCh();
a897a37a 118
ce3f5e87 119 SetMarkerColor(kRed);//
a9e2aefa 120//
ce3f5e87 121// Creating List of Chambers
a9e2aefa 122 Int_t ch;
f665c1ea 123 fChambers = new TObjArray(AliMUONConstants::NCh());
a9e2aefa 124 // Loop over stations
f665c1ea 125 for (Int_t st = 0; st < AliMUONConstants::NCh() / 2; st++) {
a9e2aefa 126 // Loop over 2 chambers in the station
ce3f5e87 127 for (Int_t stCH = 0; stCH < 2; stCH++) {
128 //
129 //
130 // Default Parameters for Muon Tracking Stations
131 ch = 2 * st + stCH;
132 if (ch < AliMUONConstants::NTrackingCh()) {
133 fChambers->AddAt(new AliMUONChamber(ch),ch);
134 } else {
135 fChambers->AddAt(new AliMUONChamberTrigger(ch),ch);
136 }
137 AliMUONChamber* chamber = (AliMUONChamber*) fChambers->At(ch);
138 chamber->SetGid(0);
139 // Default values for Z of chambers
140 chamber->SetZ(AliMUONConstants::DefaultChamberZ(ch));
141 //
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);
146 //
147 } // Chamber stCH (0, 1) in
a9e2aefa 148 } // Station st (0...)
ce3f5e87 149
1391e633 150 // Negatives values are ignored by geant3 CONS200 in the calculation of the tracking parameters
151 fMaxStepGas=0.1;
152 fMaxStepAlu=0.1;
a9e2aefa 153 fMaxDestepGas=-1;
154 fMaxDestepAlu=-1;
ce3f5e87 155
156 fMaxIterPad = 0;
157 fCurIterPad = 0;
158
159 fAccMin = 0.;
160 fAccMax = 0.;
161 fAccCut = kFALSE;
162
163 // cp new design of AliMUONTriggerDecision
164 fTriggerCircuits = new TObjArray(AliMUONConstants::NTriggerCircuit());
165 for (Int_t circ=0; circ<AliMUONConstants::NTriggerCircuit(); circ++) {
166 fTriggerCircuits->AddAt(new AliMUONTriggerCircuit(),circ);
167 }
168 fMerger = 0;
fe4da5cc 169}
ce3f5e87 170//____________________________________________________________________
50e97f19 171AliMUON::AliMUON(const AliMUON& rMUON):AliDetector(rMUON)
a9e2aefa 172{
173// Dummy copy constructor
174 ;
175
176}
ce3f5e87 177//____________________________________________________________________
fe4da5cc 178AliMUON::~AliMUON()
179{
de05461e 180// Destructor
ce3f5e87 181 if(fDebug) printf("%s: Calling AliMUON destructor !!!\n",ClassName());
182 fIshunt = 0;
183 if (fMerger) delete fMerger;
a897a37a 184}
ce3f5e87 185//____________________________________________________________________
fe4da5cc 186void AliMUON::BuildGeometry()
187{
de05461e 188// Geometry for event display
5fd73042 189 for (Int_t i=0; i<7; i++) {
190 for (Int_t j=0; j<2; j++) {
191 Int_t id=2*i+j+1;
192 this->Chamber(id-1).SegmentationModel(1)->Draw("eventdisplay");
a897a37a 193 }
5fd73042 194 }
fe4da5cc 195}
ce3f5e87 196//___________________________________________________________________
fe4da5cc 197Int_t AliMUON::DistancetoPrimitive(Int_t , Int_t )
198{
ce3f5e87 199 return 9999;
fe4da5cc 200}
ce3f5e87 201//__________________________________________________________________
202void AliMUON::SetTreeAddress()
a897a37a 203{
ce3f5e87 204 GetMUONData()->SetLoader(fLoader);
205 GetMUONData()->SetTreeAddress("H,D,RC");
a9e2aefa 206}
207
ce3f5e87 208//____________________________________________________________________
a9e2aefa 209void AliMUON::SetPadSize(Int_t id, Int_t isec, Float_t p1, Float_t p2)
210{
de05461e 211// Set the pad size for chamber id and cathode isec
a9e2aefa 212 Int_t i=2*(id-1);
2682e810 213 ((AliMUONChamber*) fChambers->At(i)) ->SetPadSize(isec,p1,p2);
214 ((AliMUONChamber*) fChambers->At(i+1))->SetPadSize(isec,p1,p2);
a897a37a 215}
216
fe4da5cc 217//___________________________________________
a9e2aefa 218void AliMUON::SetChambersZ(const Float_t *Z)
219{
220 // Set Z values for all chambers (tracking and trigger)
221 // from the array pointed to by "Z"
f665c1ea 222 for (Int_t ch = 0; ch < AliMUONConstants::NCh(); ch++)
2682e810 223 ((AliMUONChamber*) fChambers->At(ch))->SetZ(Z[ch]);
f665c1ea 224 return;
a9e2aefa 225}
ce3f5e87 226//_________________________________________________________________
a9e2aefa 227void AliMUON::SetChambersZToDefault()
fe4da5cc 228{
a9e2aefa 229 // Set Z values for all chambers (tracking and trigger)
230 // to default values
f665c1ea 231 SetChambersZ(AliMUONConstants::DefaultChamberZ());
a9e2aefa 232 return;
fe4da5cc 233}
ce3f5e87 234//_________________________________________________________________
a897a37a 235void AliMUON::SetChargeSlope(Int_t id, Float_t p1)
fe4da5cc 236{
de05461e 237// Set the inverse charge slope for chamber id
ce3f5e87 238 Int_t i=2*(id-1); //PH ((AliMUONChamber*) (*fChambers)[i])->SetSigmaIntegration(p1);
239 //PH ((AliMUONChamber*) (*fChambers)[i+1])->SetSigmaIntegration(p1);
2682e810 240 ((AliMUONChamber*) fChambers->At(i))->SetChargeSlope(p1);
241 ((AliMUONChamber*) fChambers->At(i+1))->SetChargeSlope(p1);
fe4da5cc 242}
ce3f5e87 243//__________________________________________________________________
a897a37a 244void AliMUON::SetChargeSpread(Int_t id, Float_t p1, Float_t p2)
fe4da5cc 245{
de05461e 246// Set sigma of charge spread for chamber id
fe4da5cc 247 Int_t i=2*(id-1);
2682e810 248 ((AliMUONChamber*) fChambers->At(i))->SetChargeSpread(p1,p2);
249 ((AliMUONChamber*) fChambers->At(i+1))->SetChargeSpread(p1,p2);
fe4da5cc 250}
ce3f5e87 251//___________________________________________________________________
a897a37a 252void AliMUON::SetSigmaIntegration(Int_t id, Float_t p1)
fe4da5cc 253{
de05461e 254// Set integration limits for charge spread
fe4da5cc 255 Int_t i=2*(id-1);
2682e810 256 ((AliMUONChamber*) fChambers->At(i))->SetSigmaIntegration(p1);
257 ((AliMUONChamber*) fChambers->At(i+1))->SetSigmaIntegration(p1);
fe4da5cc 258}
259
ce3f5e87 260//__________________________________________________________________
d09fafb0 261void AliMUON::SetMaxAdc(Int_t id, Int_t p1)
fe4da5cc 262{
de05461e 263// Set maximum number for ADCcounts (saturation)
fe4da5cc 264 Int_t i=2*(id-1);
2682e810 265 ((AliMUONChamber*) fChambers->At(i))->SetMaxAdc(p1);
266 ((AliMUONChamber*) fChambers->At(i+1))->SetMaxAdc(p1);
fe4da5cc 267}
ce3f5e87 268//__________________________________________________________________
a897a37a 269void AliMUON::SetMaxStepGas(Float_t p1)
fe4da5cc 270{
de05461e 271// Set stepsize in gas
ce3f5e87 272 fMaxStepGas=p1;
fe4da5cc 273}
ce3f5e87 274//__________________________________________________________________
a897a37a 275void AliMUON::SetMaxStepAlu(Float_t p1)
fe4da5cc 276{
de05461e 277// Set step size in Alu
fe4da5cc 278 fMaxStepAlu=p1;
279}
ce3f5e87 280//__________________________________________________________________
a897a37a 281void AliMUON::SetMaxDestepGas(Float_t p1)
fe4da5cc 282{
de05461e 283// Set maximum step size in Gas
fe4da5cc 284 fMaxDestepGas=p1;
285}
ce3f5e87 286//__________________________________________________________________
a897a37a 287void AliMUON::SetMaxDestepAlu(Float_t p1)
fe4da5cc 288{
de05461e 289// Set maximum step size in Alu
ce3f5e87 290 fMaxDestepAlu=p1;
fe4da5cc 291}
ce3f5e87 292//___________________________________________________________________
5c1f55c5 293void AliMUON::SetAcceptance(Bool_t acc, Float_t angmin, Float_t angmax)
fe4da5cc 294{
de05461e 295// Set acceptance cuts
ce3f5e87 296 fAccCut=acc;
297 fAccMin=angmin*TMath::Pi()/180;
298 fAccMax=angmax*TMath::Pi()/180;
299 Int_t ch;
300 if (acc) {
301 for (Int_t st = 0; st < AliMUONConstants::NCh() / 2; st++) {
302 // Loop over 2 chambers in the station
303 for (Int_t stCH = 0; stCH < 2; stCH++) {
304 ch = 2 * st + stCH;
305 // Set chamber inner and outer radius according to acceptance cuts
b13a15bc 306 Chamber(ch).SetRInner(TMath::Abs(AliMUONConstants::DefaultChamberZ(ch)*TMath::Tan(fAccMin)));
307 Chamber(ch).SetROuter(TMath::Abs(AliMUONConstants::DefaultChamberZ(ch)*TMath::Tan(fAccMax)));
ce3f5e87 308 } // chamber loop
309 } // station loop
310 }
fe4da5cc 311}
ce3f5e87 312//____________________________________________________________________
a30a000f 313void AliMUON::SetSegmentationModel(Int_t id, Int_t isec, AliSegmentation *segmentation)
fe4da5cc 314{
de05461e 315// Set the segmentation for chamber id cathode isec
2682e810 316 ((AliMUONChamber*) fChambers->At(id))->SetSegmentationModel(isec, segmentation);
fe4da5cc 317
318}
ce3f5e87 319//____________________________________________________________________
a9e2aefa 320void AliMUON::SetResponseModel(Int_t id, AliMUONResponse *response)
fe4da5cc 321{
de05461e 322// Set the response for chamber id
2682e810 323 ((AliMUONChamber*) fChambers->At(id))->SetResponseModel(response);
fe4da5cc 324}
ce3f5e87 325//____________________________________________________________________
30aaba74 326void AliMUON::SetReconstructionModel(Int_t id, AliMUONClusterFinderVS *reconst)
a897a37a 327{
de05461e 328// Set ClusterFinder for chamber id
2682e810 329 ((AliMUONChamber*) fChambers->At(id))->SetReconstructionModel(reconst);
a897a37a 330}
ce3f5e87 331//____________________________________________________________________
fe4da5cc 332void AliMUON::SetNsec(Int_t id, Int_t nsec)
333{
de05461e 334// Set number of segmented cathods for chamber id
2682e810 335 ((AliMUONChamber*) fChambers->At(id))->SetNsec(nsec);
fe4da5cc 336}
ce3f5e87 337//_____________________________________________________________________
2ab0c725 338void AliMUON::SDigits2Digits()
339{
d963c261 340
341// write TreeD here
342
343 if (!fMerger) {
344 if (gAlice->GetDebug()>0) {
345 cerr<<"AliMUON::SDigits2Digits: create default AliMUONMerger "<<endl;
346 cerr<<" no merging, just digitization of 1 event will be done"<<endl;
347 }
348 fMerger = new AliMUONMerger();
2ab0c725 349 }
d963c261 350 fMerger->Init();
351 fMerger->Digitise();
352 char hname[30];
88cb7938 353 // sprintf(hname,"TreeD%d",fLoader->GetHeader()->GetEvent());
354 fLoader->TreeD()->Write(hname,TObject::kOverwrite);
355 fLoader->TreeD()->Reset();
2ab0c725 356}
a9e2aefa 357
ce3f5e87 358//_______________________________________________________________________
3fa6cfdd 359AliLoader* AliMUON::MakeLoader(const char* topfoldername)
360{
361//builds standard getter (AliLoader type)
362//if detector wants to use castomized getter, it must overload this method
363
364 if (GetDebug())
365 Info("MakeLoader",
366 "Creating standard getter for detector %s. Top folder is %s.",
367 GetName(),topfoldername);
368
128843d9 369 fLoader = new AliLoader(GetName(),topfoldername);
ce3f5e87 370 fMUONData = new AliMUONData(fLoader,GetName(),GetName());
3fa6cfdd 371 return fLoader;
372}
a897a37a 373
ce3f5e87 374//_______________________________________________________________________
a9e2aefa 375void AliMUON::Trigger(Int_t nev){
376// call the Trigger Algorithm and fill TreeR
377
378 Int_t singlePlus[3] = {0,0,0};
379 Int_t singleMinus[3] = {0,0,0};
380 Int_t singleUndef[3] = {0,0,0};
381 Int_t pairUnlike[3] = {0,0,0};
382 Int_t pairLike[3] = {0,0,0};
ce3f5e87 383
a9e2aefa 384 ResetTrigger();
a9e2aefa 385 AliMUONTriggerDecision* decision= new AliMUONTriggerDecision(1);
386 decision->Trigger();
387 decision->GetGlobalTrigger(singlePlus, singleMinus, singleUndef,
388 pairUnlike, pairLike);
ce3f5e87 389
390 // add a local trigger in the list
391 GetMUONData()->AddGlobalTrigger(singlePlus, singleMinus, singleUndef, pairUnlike, pairLike);
9ae15266 392 Int_t i;
a9e2aefa 393
f665c1ea 394 for (Int_t icirc=0; icirc<AliMUONConstants::NTriggerCircuit(); icirc++) {
ce3f5e87 395 if(decision->GetITrigger(icirc)==1) {
396 Int_t localtr[7]={0,0,0,0,0,0,0};
397 Int_t loLpt[2]={0,0}; Int_t loHpt[2]={0,0}; Int_t loApt[2]={0,0};
398 decision->GetLutOutput(icirc, loLpt, loHpt, loApt);
399 localtr[0] = icirc;
400 localtr[1] = decision->GetStripX11(icirc);
401 localtr[2] = decision->GetDev(icirc);
402 localtr[3] = decision->GetStripY11(icirc);
403 for (i=0; i<2; i++) { // convert the Lut output in 1 digit
404 localtr[4] = localtr[4]+Int_t(loLpt[i]*TMath::Power(2,i));
405 localtr[5] = localtr[5]+Int_t(loHpt[i]*TMath::Power(2,i));
406 localtr[6] = localtr[6]+Int_t(loApt[i]*TMath::Power(2,i));
a897a37a 407 }
ce3f5e87 408 GetMUONData()->AddLocalTrigger(localtr); // add a local trigger in the list
409 }
a9e2aefa 410 }
ce3f5e87 411
a9e2aefa 412 delete decision;
bf17dbfd 413
ba9436c6 414 // fLoader->TreeR()->Fill();
1a1cdff8 415 GetMUONData()->Fill("GLT"); //Filling Global and Local Trigger GLT
ce3f5e87 416 // char hname[30];
417 // sprintf(hname,"TreeR%d",nev);
418 // fLoader->TreeR()->Write(hname,TObject::kOverwrite);
bf17dbfd 419 // fLoader->TreeR()->Reset();
88cb7938 420 fLoader->WriteRecPoints("OVERWRITE");
88cb7938 421
a9e2aefa 422 printf("\n End of trigger for event %d", nev);
a897a37a 423}
a897a37a 424
ce3f5e87 425//____________________________________________________________________
fe311ef1 426void AliMUON::Digits2Reco()
427{
428 FindClusters();
e365e1ee 429 Int_t nev = gAlice->GetHeader()->GetEvent();
1a1cdff8 430 GetMUONData()->Fill("RC"); //Filling Reconstructed Cluster
88cb7938 431 fLoader->WriteRecPoints("OVERWRITE");
ce3f5e87 432 GetMUONData()->ResetRawClusters();
1a1cdff8 433 Info("Digits2Reco","End of cluster finding for event %d", nev);
fe311ef1 434}
ce3f5e87 435//____________________________________________________________________
fe311ef1 436void AliMUON::FindClusters()
a9e2aefa 437{
de05461e 438//
439// Perform cluster finding
440//
a9e2aefa 441 TClonesArray *dig1, *dig2;
442 Int_t ndig, k;
443 dig1 = new TClonesArray("AliMUONDigit",1000);
444 dig2 = new TClonesArray("AliMUONDigit",1000);
445 AliMUONDigit *digit;
a9e2aefa 446// Loop on chambers and on cathode planes
a897a37a 447//
fe311ef1 448 ResetRawClusters();
88cb7938 449 TClonesArray * muonDigits;
450
1bd28025 451 for (Int_t ich = 0; ich < 10; ich++) {
2682e810 452 //PH AliMUONChamber* iChamber = (AliMUONChamber*) (*fChambers)[ich];
453 AliMUONChamber* iChamber = (AliMUONChamber*) fChambers->At(ich);
fe311ef1 454 AliMUONClusterFinderVS* rec = iChamber->ReconstructionModel();
455
88cb7938 456 ResetDigits();
1a1cdff8 457 GetMUONData()->GetCathode(0);
88cb7938 458 //TClonesArray *
1a1cdff8 459 muonDigits = GetMUONData()->Digits(ich);
a9e2aefa 460 ndig=muonDigits->GetEntriesFast();
88cb7938 461 printf("\n 1 Found %d digits in %p chamber %d", ndig, muonDigits,ich);
a9e2aefa 462 TClonesArray &lhits1 = *dig1;
1bd28025 463 Int_t n = 0;
464 for (k = 0; k < ndig; k++) {
465 digit = (AliMUONDigit*) muonDigits->UncheckedAt(k);
466 if (rec->TestTrack(digit->Track(0)))
a9e2aefa 467 new(lhits1[n++]) AliMUONDigit(*digit);
468 }
1a1cdff8 469 GetMUONData()->ResetDigits();
470 GetMUONData()->GetCathode(1);
471 muonDigits = GetMUONData()->Digits(ich);
a9e2aefa 472 ndig=muonDigits->GetEntriesFast();
473 printf("\n 2 Found %d digits in %p %d", ndig, muonDigits, ich);
474 TClonesArray &lhits2 = *dig2;
475 n=0;
476
477 for (k=0; k<ndig; k++) {
478 digit= (AliMUONDigit*) muonDigits->UncheckedAt(k);
1bd28025 479 if (rec->TestTrack(digit->Track(0)))
a9e2aefa 480 new(lhits2[n++]) AliMUONDigit(*digit);
a897a37a 481 }
a897a37a 482
9825400f 483 if (rec) {
484 AliMUONClusterInput::Instance()->SetDigits(ich, dig1, dig2);
a9e2aefa 485 rec->FindRawClusters();
486 }
487 dig1->Delete();
488 dig2->Delete();
489 } // for ich
a9e2aefa 490 delete dig1;
491 delete dig2;
a897a37a 492}
ce3f5e87 493//______________________________________________________________________
2ab0c725 494#ifdef never
ce3f5e87 495void AliMUON::Streamer(TBuffer &R__b)_
fe4da5cc 496{
497 // Stream an object of class AliMUON.
a30a000f 498 AliMUONChamber *iChamber;
a9e2aefa 499 AliMUONTriggerCircuit *iTriggerCircuit;
a30a000f 500 AliSegmentation *segmentation;
501 AliMUONResponse *response;
502 TClonesArray *digitsaddress;
503 TClonesArray *rawcladdress;
9ae15266 504 Int_t i;
9ae15266 505 if (R__b.IsReading()) {
506 Version_t R__v = R__b.ReadVersion(); if (R__v) { }
507 AliDetector::Streamer(R__b);
508 R__b >> fNPadHits;
509 R__b >> fPadHits; // diff
510 R__b >> fNLocalTrigger;
511 R__b >> fLocalTrigger;
512 R__b >> fNGlobalTrigger;
513 R__b >> fGlobalTrigger;
514 R__b >> fDchambers;
515 R__b >> fRawClusters;
516 R__b.ReadArray(fNdch);
517 R__b.ReadArray(fNrawch);
518 R__b >> fAccCut;
519 R__b >> fAccMin;
520 R__b >> fAccMax;
521 R__b >> fChambers;
522 R__b >> fTriggerCircuits;
f665c1ea 523 for (i =0; i<AliMUONConstants::NTriggerCircuit(); i++) {
9ae15266 524 iTriggerCircuit=(AliMUONTriggerCircuit*) (*fTriggerCircuits)[i];
525 iTriggerCircuit->Streamer(R__b);
fe4da5cc 526 }
9ae15266 527// Stream chamber related information
f665c1ea 528 for (i =0; i<AliMUONConstants::NCh(); i++) {
9ae15266 529 iChamber=(AliMUONChamber*) (*fChambers)[i];
530 iChamber->Streamer(R__b);
531 if (iChamber->Nsec()==1) {
532 segmentation=iChamber->SegmentationModel(1);
533 if (segmentation)
534 segmentation->Streamer(R__b);
535 } else {
536 segmentation=iChamber->SegmentationModel(1);
537 if (segmentation)
538 segmentation->Streamer(R__b);
539 if (segmentation)
540 segmentation=iChamber->SegmentationModel(2);
541 segmentation->Streamer(R__b);
542 }
543 response=iChamber->ResponseModel();
544 if (response)
545 response->Streamer(R__b);
546 digitsaddress=(TClonesArray*) (*fDchambers)[i];
547 digitsaddress->Streamer(R__b);
f665c1ea 548 if (i < AliMUONConstants::NTrackingCh()) {
9ae15266 549 rawcladdress=(TClonesArray*) (*fRawClusters)[i];
550 rawcladdress->Streamer(R__b);
551 }
a9e2aefa 552 }
9ae15266 553
554 } else {
555 R__b.WriteVersion(AliMUON::IsA());
556 AliDetector::Streamer(R__b);
557 R__b << fNPadHits;
558 R__b << fPadHits; // diff
559 R__b << fNLocalTrigger;
560 R__b << fLocalTrigger;
561 R__b << fNGlobalTrigger;
562 R__b << fGlobalTrigger;
563 R__b << fDchambers;
564 R__b << fRawClusters;
f665c1ea 565 R__b.WriteArray(fNdch, AliMUONConstants::NCh());
566 R__b.WriteArray(fNrawch, AliMUONConstants::NTrackingCh());
9ae15266 567
568 R__b << fAccCut;
569 R__b << fAccMin;
570 R__b << fAccMax;
571
572 R__b << fChambers;
573 R__b << fTriggerCircuits;
f665c1ea 574 for (i =0; i<AliMUONConstants::NTriggerCircuit(); i++) {
9ae15266 575 iTriggerCircuit=(AliMUONTriggerCircuit*) (*fTriggerCircuits)[i];
576 iTriggerCircuit->Streamer(R__b);
fe4da5cc 577 }
f665c1ea 578 for (i =0; i<AliMUONConstants::NCh(); i++) {
9ae15266 579 iChamber=(AliMUONChamber*) (*fChambers)[i];
580 iChamber->Streamer(R__b);
581 if (iChamber->Nsec()==1) {
582 segmentation=iChamber->SegmentationModel(1);
583 if (segmentation)
584 segmentation->Streamer(R__b);
585 } else {
586 segmentation=iChamber->SegmentationModel(1);
587 if (segmentation)
588 segmentation->Streamer(R__b);
589 segmentation=iChamber->SegmentationModel(2);
590 if (segmentation)
591 segmentation->Streamer(R__b);
592 }
593 response=iChamber->ResponseModel();
594 if (response)
595 response->Streamer(R__b);
596 digitsaddress=(TClonesArray*) (*fDchambers)[i];
597 digitsaddress->Streamer(R__b);
f665c1ea 598 if (i < AliMUONConstants::NTrackingCh()) {
9ae15266 599 rawcladdress=(TClonesArray*) (*fRawClusters)[i];
600 rawcladdress->Streamer(R__b);
601 }
a9e2aefa 602 }
fe4da5cc 603 }
fe4da5cc 604}
2ab0c725 605#endif
ce3f5e87 606//_______________________________________________________________________
a9e2aefa 607AliMUONPadHit* AliMUON::FirstPad(AliMUONHit* hit, TClonesArray *clusters)
fe4da5cc 608{
5a35ac13 609// to be removed
fe4da5cc 610 // Initialise the pad iterator
611 // Return the address of the first padhit for hit
a897a37a 612 TClonesArray *theClusters = clusters;
fe4da5cc 613 Int_t nclust = theClusters->GetEntriesFast();
1bd28025 614 if (nclust && hit->PHlast() > 0) {
615 AliMUON::fMaxIterPad=hit->PHlast();
616 AliMUON::fCurIterPad=hit->PHfirst();
a9e2aefa 617 return (AliMUONPadHit*) clusters->UncheckedAt(AliMUON::fCurIterPad-1);
fe4da5cc 618 } else {
619 return 0;
620 }
621}
ce3f5e87 622//_______________________________________________________________________
a9e2aefa 623AliMUONPadHit* AliMUON::NextPad(TClonesArray *clusters)
fe4da5cc 624{
5a35ac13 625 // To be removed
de05461e 626// Get next pad (in iterator)
627//
a9e2aefa 628 AliMUON::fCurIterPad++;
629 if (AliMUON::fCurIterPad <= AliMUON::fMaxIterPad) {
630 return (AliMUONPadHit*) clusters->UncheckedAt(AliMUON::fCurIterPad-1);
fe4da5cc 631 } else {
632 return 0;
633 }
634}
ce3f5e87 635//_______________________________________________________________________
a897a37a 636
637AliMUONRawCluster *AliMUON::RawCluster(Int_t ichamber, Int_t icathod, Int_t icluster)
638{
de05461e 639//
640// Return rawcluster (icluster) for chamber ichamber and cathode icathod
641// Obsolete ??
ce3f5e87 642 TClonesArray *muonRawCluster = GetMUONData()->RawClusters(ichamber);
a897a37a 643 ResetRawClusters();
88cb7938 644 TTree *treeR = fLoader->TreeR();
a9e2aefa 645 Int_t nent=(Int_t)treeR->GetEntries();
646 treeR->GetEvent(nent-2+icathod-1);
647 //treeR->GetEvent(icathod);
648 //Int_t nrawcl = (Int_t)muonRawCluster->GetEntriesFast();
a897a37a 649
a9e2aefa 650 AliMUONRawCluster * mRaw = (AliMUONRawCluster*)muonRawCluster->UncheckedAt(icluster);
a897a37a 651 //printf("RawCluster _ nent nrawcl icluster mRaw %d %d %d%p\n",nent,nrawcl,icluster,mRaw);
652
653 return mRaw;
654}
ce3f5e87 655//________________________________________________________________________
1cae9436 656void AliMUON::SetMerger(AliMUONMerger* merger)
657{
658// Set pointer to merger
659 fMerger = merger;
660}
ce3f5e87 661//________________________________________________________________________
1cae9436 662AliMUONMerger* AliMUON::Merger()
663{
664// Return pointer to merger
665 return fMerger;
666}
ce3f5e87 667//________________________________________________________________________
50e97f19 668AliMUON& AliMUON::operator = (const AliMUON& /*rhs*/)
a897a37a 669{
a9e2aefa 670// copy operator
671// dummy version
672 return *this;
a897a37a 673}
674