New MUON data container AliMUONData implementation
[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;
fe4da5cc 102}
ce3f5e87 103//__________________________________________________________________
fe4da5cc 104AliMUON::AliMUON(const char *name, const char *title)
ce3f5e87 105 : AliDetector(name,title)
fe4da5cc 106{
107//Begin_Html
108/*
a897a37a 109<img src="gif/alimuon.gif">
fe4da5cc 110*/
111//End_Html
ce3f5e87 112 fMUONData = 0x0;
113 fIshunt = 0;
f665c1ea 114
ce3f5e87 115 fNCh = AliMUONConstants::NCh();
116 fNTrackingCh = AliMUONConstants::NTrackingCh();
a897a37a 117
ce3f5e87 118 SetMarkerColor(kRed);//
a9e2aefa 119//
ce3f5e87 120// Creating List of Chambers
a9e2aefa 121 Int_t ch;
f665c1ea 122 fChambers = new TObjArray(AliMUONConstants::NCh());
a9e2aefa 123 // Loop over stations
f665c1ea 124 for (Int_t st = 0; st < AliMUONConstants::NCh() / 2; st++) {
a9e2aefa 125 // Loop over 2 chambers in the station
ce3f5e87 126 for (Int_t stCH = 0; stCH < 2; stCH++) {
127 //
128 //
129 // Default Parameters for Muon Tracking Stations
130 ch = 2 * st + stCH;
131 if (ch < AliMUONConstants::NTrackingCh()) {
132 fChambers->AddAt(new AliMUONChamber(ch),ch);
133 } else {
134 fChambers->AddAt(new AliMUONChamberTrigger(ch),ch);
135 }
136 AliMUONChamber* chamber = (AliMUONChamber*) fChambers->At(ch);
137 chamber->SetGid(0);
138 // Default values for Z of chambers
139 chamber->SetZ(AliMUONConstants::DefaultChamberZ(ch));
140 //
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);
145 //
146 } // Chamber stCH (0, 1) in
a9e2aefa 147 } // Station st (0...)
ce3f5e87 148
a9e2aefa 149 fMaxStepGas=0.01;
150 fMaxStepAlu=0.1;
151 fMaxDestepGas=-1;
152 fMaxDestepAlu=-1;
ce3f5e87 153
154 fMaxIterPad = 0;
155 fCurIterPad = 0;
156
157 fAccMin = 0.;
158 fAccMax = 0.;
159 fAccCut = kFALSE;
160
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);
165 }
166 fMerger = 0;
fe4da5cc 167}
ce3f5e87 168//____________________________________________________________________
50e97f19 169AliMUON::AliMUON(const AliMUON& rMUON):AliDetector(rMUON)
a9e2aefa 170{
171// Dummy copy constructor
172 ;
173
174}
ce3f5e87 175//____________________________________________________________________
fe4da5cc 176AliMUON::~AliMUON()
177{
de05461e 178// Destructor
ce3f5e87 179 if(fDebug) printf("%s: Calling AliMUON destructor !!!\n",ClassName());
180 fIshunt = 0;
181 if (fMerger) delete fMerger;
a897a37a 182}
ce3f5e87 183//____________________________________________________________________
fe4da5cc 184void AliMUON::BuildGeometry()
185{
de05461e 186// Geometry for event display
5fd73042 187 for (Int_t i=0; i<7; i++) {
188 for (Int_t j=0; j<2; j++) {
189 Int_t id=2*i+j+1;
190 this->Chamber(id-1).SegmentationModel(1)->Draw("eventdisplay");
a897a37a 191 }
5fd73042 192 }
fe4da5cc 193}
ce3f5e87 194//___________________________________________________________________
fe4da5cc 195Int_t AliMUON::DistancetoPrimitive(Int_t , Int_t )
196{
ce3f5e87 197 return 9999;
fe4da5cc 198}
ce3f5e87 199//__________________________________________________________________
200void AliMUON::SetTreeAddress()
a897a37a 201{
ce3f5e87 202 GetMUONData()->SetLoader(fLoader);
203 GetMUONData()->SetTreeAddress("H,D,RC");
a9e2aefa 204}
205
ce3f5e87 206//____________________________________________________________________
a9e2aefa 207void AliMUON::SetPadSize(Int_t id, Int_t isec, Float_t p1, Float_t p2)
208{
de05461e 209// Set the pad size for chamber id and cathode isec
a9e2aefa 210 Int_t i=2*(id-1);
2682e810 211 ((AliMUONChamber*) fChambers->At(i)) ->SetPadSize(isec,p1,p2);
212 ((AliMUONChamber*) fChambers->At(i+1))->SetPadSize(isec,p1,p2);
a897a37a 213}
214
fe4da5cc 215//___________________________________________
a9e2aefa 216void AliMUON::SetChambersZ(const Float_t *Z)
217{
218 // Set Z values for all chambers (tracking and trigger)
219 // from the array pointed to by "Z"
f665c1ea 220 for (Int_t ch = 0; ch < AliMUONConstants::NCh(); ch++)
2682e810 221 ((AliMUONChamber*) fChambers->At(ch))->SetZ(Z[ch]);
f665c1ea 222 return;
a9e2aefa 223}
ce3f5e87 224//_________________________________________________________________
a9e2aefa 225void AliMUON::SetChambersZToDefault()
fe4da5cc 226{
a9e2aefa 227 // Set Z values for all chambers (tracking and trigger)
228 // to default values
f665c1ea 229 SetChambersZ(AliMUONConstants::DefaultChamberZ());
a9e2aefa 230 return;
fe4da5cc 231}
ce3f5e87 232//_________________________________________________________________
a897a37a 233void AliMUON::SetChargeSlope(Int_t id, Float_t p1)
fe4da5cc 234{
de05461e 235// Set the inverse charge slope for chamber id
ce3f5e87 236 Int_t i=2*(id-1); //PH ((AliMUONChamber*) (*fChambers)[i])->SetSigmaIntegration(p1);
237 //PH ((AliMUONChamber*) (*fChambers)[i+1])->SetSigmaIntegration(p1);
2682e810 238 ((AliMUONChamber*) fChambers->At(i))->SetChargeSlope(p1);
239 ((AliMUONChamber*) fChambers->At(i+1))->SetChargeSlope(p1);
fe4da5cc 240}
ce3f5e87 241//__________________________________________________________________
a897a37a 242void AliMUON::SetChargeSpread(Int_t id, Float_t p1, Float_t p2)
fe4da5cc 243{
de05461e 244// Set sigma of charge spread for chamber id
fe4da5cc 245 Int_t i=2*(id-1);
2682e810 246 ((AliMUONChamber*) fChambers->At(i))->SetChargeSpread(p1,p2);
247 ((AliMUONChamber*) fChambers->At(i+1))->SetChargeSpread(p1,p2);
fe4da5cc 248}
ce3f5e87 249//___________________________________________________________________
a897a37a 250void AliMUON::SetSigmaIntegration(Int_t id, Float_t p1)
fe4da5cc 251{
de05461e 252// Set integration limits for charge spread
fe4da5cc 253 Int_t i=2*(id-1);
2682e810 254 ((AliMUONChamber*) fChambers->At(i))->SetSigmaIntegration(p1);
255 ((AliMUONChamber*) fChambers->At(i+1))->SetSigmaIntegration(p1);
fe4da5cc 256}
257
ce3f5e87 258//__________________________________________________________________
d09fafb0 259void AliMUON::SetMaxAdc(Int_t id, Int_t p1)
fe4da5cc 260{
de05461e 261// Set maximum number for ADCcounts (saturation)
fe4da5cc 262 Int_t i=2*(id-1);
2682e810 263 ((AliMUONChamber*) fChambers->At(i))->SetMaxAdc(p1);
264 ((AliMUONChamber*) fChambers->At(i+1))->SetMaxAdc(p1);
fe4da5cc 265}
ce3f5e87 266//__________________________________________________________________
a897a37a 267void AliMUON::SetMaxStepGas(Float_t p1)
fe4da5cc 268{
de05461e 269// Set stepsize in gas
ce3f5e87 270 fMaxStepGas=p1;
fe4da5cc 271}
ce3f5e87 272//__________________________________________________________________
a897a37a 273void AliMUON::SetMaxStepAlu(Float_t p1)
fe4da5cc 274{
de05461e 275// Set step size in Alu
fe4da5cc 276 fMaxStepAlu=p1;
277}
ce3f5e87 278//__________________________________________________________________
a897a37a 279void AliMUON::SetMaxDestepGas(Float_t p1)
fe4da5cc 280{
de05461e 281// Set maximum step size in Gas
fe4da5cc 282 fMaxDestepGas=p1;
283}
ce3f5e87 284//__________________________________________________________________
a897a37a 285void AliMUON::SetMaxDestepAlu(Float_t p1)
fe4da5cc 286{
de05461e 287// Set maximum step size in Alu
ce3f5e87 288 fMaxDestepAlu=p1;
fe4da5cc 289}
ce3f5e87 290//___________________________________________________________________
5c1f55c5 291void AliMUON::SetAcceptance(Bool_t acc, Float_t angmin, Float_t angmax)
fe4da5cc 292{
de05461e 293// Set acceptance cuts
ce3f5e87 294 fAccCut=acc;
295 fAccMin=angmin*TMath::Pi()/180;
296 fAccMax=angmax*TMath::Pi()/180;
297 Int_t ch;
298 if (acc) {
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++) {
302 ch = 2 * st + 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));
306 } // chamber loop
307 } // station loop
308 }
fe4da5cc 309}
ce3f5e87 310//____________________________________________________________________
a30a000f 311void AliMUON::SetSegmentationModel(Int_t id, Int_t isec, AliSegmentation *segmentation)
fe4da5cc 312{
de05461e 313// Set the segmentation for chamber id cathode isec
2682e810 314 ((AliMUONChamber*) fChambers->At(id))->SetSegmentationModel(isec, segmentation);
fe4da5cc 315
316}
ce3f5e87 317//____________________________________________________________________
a9e2aefa 318void AliMUON::SetResponseModel(Int_t id, AliMUONResponse *response)
fe4da5cc 319{
de05461e 320// Set the response for chamber id
2682e810 321 ((AliMUONChamber*) fChambers->At(id))->SetResponseModel(response);
fe4da5cc 322}
ce3f5e87 323//____________________________________________________________________
30aaba74 324void AliMUON::SetReconstructionModel(Int_t id, AliMUONClusterFinderVS *reconst)
a897a37a 325{
de05461e 326// Set ClusterFinder for chamber id
2682e810 327 ((AliMUONChamber*) fChambers->At(id))->SetReconstructionModel(reconst);
a897a37a 328}
ce3f5e87 329//____________________________________________________________________
fe4da5cc 330void AliMUON::SetNsec(Int_t id, Int_t nsec)
331{
de05461e 332// Set number of segmented cathods for chamber id
2682e810 333 ((AliMUONChamber*) fChambers->At(id))->SetNsec(nsec);
fe4da5cc 334}
ce3f5e87 335//_____________________________________________________________________
2ab0c725 336void AliMUON::SDigits2Digits()
337{
d963c261 338
339// write TreeD here
340
341 if (!fMerger) {
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;
345 }
346 fMerger = new AliMUONMerger();
2ab0c725 347 }
d963c261 348 fMerger->Init();
349 fMerger->Digitise();
350 char hname[30];
88cb7938 351 // sprintf(hname,"TreeD%d",fLoader->GetHeader()->GetEvent());
352 fLoader->TreeD()->Write(hname,TObject::kOverwrite);
353 fLoader->TreeD()->Reset();
2ab0c725 354}
a9e2aefa 355
ce3f5e87 356//_______________________________________________________________________
3fa6cfdd 357AliLoader* AliMUON::MakeLoader(const char* topfoldername)
358{
359//builds standard getter (AliLoader type)
360//if detector wants to use castomized getter, it must overload this method
361
362 if (GetDebug())
363 Info("MakeLoader",
364 "Creating standard getter for detector %s. Top folder is %s.",
365 GetName(),topfoldername);
366
ce3f5e87 367 fLoader = new AliLoader(GetName(),topfoldername);
368 fMUONData = new AliMUONData(fLoader,GetName(),GetName());
3fa6cfdd 369 return fLoader;
370}
a897a37a 371
ce3f5e87 372//_______________________________________________________________________
a9e2aefa 373void AliMUON::Trigger(Int_t nev){
374// call the Trigger Algorithm and fill TreeR
375
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};
ce3f5e87 381
a9e2aefa 382 ResetTrigger();
a9e2aefa 383 AliMUONTriggerDecision* decision= new AliMUONTriggerDecision(1);
384 decision->Trigger();
385 decision->GetGlobalTrigger(singlePlus, singleMinus, singleUndef,
386 pairUnlike, pairLike);
ce3f5e87 387
388 // add a local trigger in the list
389 GetMUONData()->AddGlobalTrigger(singlePlus, singleMinus, singleUndef, pairUnlike, pairLike);
9ae15266 390 Int_t i;
a9e2aefa 391
f665c1ea 392 for (Int_t icirc=0; icirc<AliMUONConstants::NTriggerCircuit(); icirc++) {
ce3f5e87 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);
397 localtr[0] = icirc;
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));
a897a37a 405 }
ce3f5e87 406 GetMUONData()->AddLocalTrigger(localtr); // add a local trigger in the list
407 }
a9e2aefa 408 }
ce3f5e87 409
a9e2aefa 410 delete decision;
ce3f5e87 411
88cb7938 412 fLoader->TreeR()->Fill();
ce3f5e87 413 // char hname[30];
414 // sprintf(hname,"TreeR%d",nev);
415 // fLoader->TreeR()->Write(hname,TObject::kOverwrite);
416 // fLoader->TreeR()->Reset();
88cb7938 417 fLoader->WriteRecPoints("OVERWRITE");
a9e2aefa 418 ResetTrigger();
88cb7938 419
a9e2aefa 420 printf("\n End of trigger for event %d", nev);
a897a37a 421}
a897a37a 422
ce3f5e87 423//____________________________________________________________________
fe311ef1 424void AliMUON::Digits2Reco()
425{
426 FindClusters();
e365e1ee 427 Int_t nev = gAlice->GetHeader()->GetEvent();
88cb7938 428 fLoader->TreeR()->Fill();
429 // char hname[30];
430 // sprintf(hname,"TreeR%d", nev);
431 //fLoader->TreeR()->Write(hname);
432 //fLoader->TreeR()->Reset();
433 fLoader->WriteRecPoints("OVERWRITE");
ce3f5e87 434 GetMUONData()->ResetRawClusters();
e365e1ee 435 printf("\n End of cluster finding for event %d", nev);
fe311ef1 436}
ce3f5e87 437//____________________________________________________________________
fe311ef1 438void AliMUON::FindClusters()
a9e2aefa 439{
de05461e 440//
441// Perform cluster finding
442//
a9e2aefa 443 TClonesArray *dig1, *dig2;
444 Int_t ndig, k;
445 dig1 = new TClonesArray("AliMUONDigit",1000);
446 dig2 = new TClonesArray("AliMUONDigit",1000);
447 AliMUONDigit *digit;
a9e2aefa 448// Loop on chambers and on cathode planes
a897a37a 449//
fe311ef1 450 ResetRawClusters();
88cb7938 451 TClonesArray * muonDigits;
452
1bd28025 453 for (Int_t ich = 0; ich < 10; ich++) {
2682e810 454 //PH AliMUONChamber* iChamber = (AliMUONChamber*) (*fChambers)[ich];
455 AliMUONChamber* iChamber = (AliMUONChamber*) fChambers->At(ich);
fe311ef1 456 AliMUONClusterFinderVS* rec = iChamber->ReconstructionModel();
457
88cb7938 458 ResetDigits();
459 fLoader->TreeD()->GetEvent(0);
460 //TClonesArray *
ce3f5e87 461 muonDigits = GetMUONData()->Digits(ich,0); // cathode plane not yet operational
a9e2aefa 462 ndig=muonDigits->GetEntriesFast();
88cb7938 463 printf("\n 1 Found %d digits in %p chamber %d", ndig, muonDigits,ich);
a9e2aefa 464 TClonesArray &lhits1 = *dig1;
1bd28025 465 Int_t n = 0;
466 for (k = 0; k < ndig; k++) {
467 digit = (AliMUONDigit*) muonDigits->UncheckedAt(k);
468 if (rec->TestTrack(digit->Track(0)))
a9e2aefa 469 new(lhits1[n++]) AliMUONDigit(*digit);
470 }
88cb7938 471 ResetDigits();
472 fLoader->TreeD()->GetEvent(1);
473 //muonDigits = this->DigitsAddress(ich);
ce3f5e87 474 muonDigits = GetMUONData()->Digits(ich,1); // cathode plane not yet operational
a9e2aefa 475 ndig=muonDigits->GetEntriesFast();
476 printf("\n 2 Found %d digits in %p %d", ndig, muonDigits, ich);
477 TClonesArray &lhits2 = *dig2;
478 n=0;
479
480 for (k=0; k<ndig; k++) {
481 digit= (AliMUONDigit*) muonDigits->UncheckedAt(k);
1bd28025 482 if (rec->TestTrack(digit->Track(0)))
a9e2aefa 483 new(lhits2[n++]) AliMUONDigit(*digit);
a897a37a 484 }
a897a37a 485
9825400f 486 if (rec) {
487 AliMUONClusterInput::Instance()->SetDigits(ich, dig1, dig2);
a9e2aefa 488 rec->FindRawClusters();
489 }
490 dig1->Delete();
491 dig2->Delete();
492 } // for ich
a9e2aefa 493 delete dig1;
494 delete dig2;
a897a37a 495}
ce3f5e87 496//______________________________________________________________________
2ab0c725 497#ifdef never
ce3f5e87 498void AliMUON::Streamer(TBuffer &R__b)_
fe4da5cc 499{
500 // Stream an object of class AliMUON.
a30a000f 501 AliMUONChamber *iChamber;
a9e2aefa 502 AliMUONTriggerCircuit *iTriggerCircuit;
a30a000f 503 AliSegmentation *segmentation;
504 AliMUONResponse *response;
505 TClonesArray *digitsaddress;
506 TClonesArray *rawcladdress;
9ae15266 507 Int_t i;
9ae15266 508 if (R__b.IsReading()) {
509 Version_t R__v = R__b.ReadVersion(); if (R__v) { }
510 AliDetector::Streamer(R__b);
511 R__b >> fNPadHits;
512 R__b >> fPadHits; // diff
513 R__b >> fNLocalTrigger;
514 R__b >> fLocalTrigger;
515 R__b >> fNGlobalTrigger;
516 R__b >> fGlobalTrigger;
517 R__b >> fDchambers;
518 R__b >> fRawClusters;
519 R__b.ReadArray(fNdch);
520 R__b.ReadArray(fNrawch);
521 R__b >> fAccCut;
522 R__b >> fAccMin;
523 R__b >> fAccMax;
524 R__b >> fChambers;
525 R__b >> fTriggerCircuits;
f665c1ea 526 for (i =0; i<AliMUONConstants::NTriggerCircuit(); i++) {
9ae15266 527 iTriggerCircuit=(AliMUONTriggerCircuit*) (*fTriggerCircuits)[i];
528 iTriggerCircuit->Streamer(R__b);
fe4da5cc 529 }
9ae15266 530// Stream chamber related information
f665c1ea 531 for (i =0; i<AliMUONConstants::NCh(); i++) {
9ae15266 532 iChamber=(AliMUONChamber*) (*fChambers)[i];
533 iChamber->Streamer(R__b);
534 if (iChamber->Nsec()==1) {
535 segmentation=iChamber->SegmentationModel(1);
536 if (segmentation)
537 segmentation->Streamer(R__b);
538 } else {
539 segmentation=iChamber->SegmentationModel(1);
540 if (segmentation)
541 segmentation->Streamer(R__b);
542 if (segmentation)
543 segmentation=iChamber->SegmentationModel(2);
544 segmentation->Streamer(R__b);
545 }
546 response=iChamber->ResponseModel();
547 if (response)
548 response->Streamer(R__b);
549 digitsaddress=(TClonesArray*) (*fDchambers)[i];
550 digitsaddress->Streamer(R__b);
f665c1ea 551 if (i < AliMUONConstants::NTrackingCh()) {
9ae15266 552 rawcladdress=(TClonesArray*) (*fRawClusters)[i];
553 rawcladdress->Streamer(R__b);
554 }
a9e2aefa 555 }
9ae15266 556
557 } else {
558 R__b.WriteVersion(AliMUON::IsA());
559 AliDetector::Streamer(R__b);
560 R__b << fNPadHits;
561 R__b << fPadHits; // diff
562 R__b << fNLocalTrigger;
563 R__b << fLocalTrigger;
564 R__b << fNGlobalTrigger;
565 R__b << fGlobalTrigger;
566 R__b << fDchambers;
567 R__b << fRawClusters;
f665c1ea 568 R__b.WriteArray(fNdch, AliMUONConstants::NCh());
569 R__b.WriteArray(fNrawch, AliMUONConstants::NTrackingCh());
9ae15266 570
571 R__b << fAccCut;
572 R__b << fAccMin;
573 R__b << fAccMax;
574
575 R__b << fChambers;
576 R__b << fTriggerCircuits;
f665c1ea 577 for (i =0; i<AliMUONConstants::NTriggerCircuit(); i++) {
9ae15266 578 iTriggerCircuit=(AliMUONTriggerCircuit*) (*fTriggerCircuits)[i];
579 iTriggerCircuit->Streamer(R__b);
fe4da5cc 580 }
f665c1ea 581 for (i =0; i<AliMUONConstants::NCh(); i++) {
9ae15266 582 iChamber=(AliMUONChamber*) (*fChambers)[i];
583 iChamber->Streamer(R__b);
584 if (iChamber->Nsec()==1) {
585 segmentation=iChamber->SegmentationModel(1);
586 if (segmentation)
587 segmentation->Streamer(R__b);
588 } else {
589 segmentation=iChamber->SegmentationModel(1);
590 if (segmentation)
591 segmentation->Streamer(R__b);
592 segmentation=iChamber->SegmentationModel(2);
593 if (segmentation)
594 segmentation->Streamer(R__b);
595 }
596 response=iChamber->ResponseModel();
597 if (response)
598 response->Streamer(R__b);
599 digitsaddress=(TClonesArray*) (*fDchambers)[i];
600 digitsaddress->Streamer(R__b);
f665c1ea 601 if (i < AliMUONConstants::NTrackingCh()) {
9ae15266 602 rawcladdress=(TClonesArray*) (*fRawClusters)[i];
603 rawcladdress->Streamer(R__b);
604 }
a9e2aefa 605 }
fe4da5cc 606 }
fe4da5cc 607}
2ab0c725 608#endif
ce3f5e87 609//_______________________________________________________________________
a9e2aefa 610AliMUONPadHit* AliMUON::FirstPad(AliMUONHit* hit, TClonesArray *clusters)
fe4da5cc 611{
5a35ac13 612// to be removed
fe4da5cc 613 // Initialise the pad iterator
614 // Return the address of the first padhit for hit
a897a37a 615 TClonesArray *theClusters = clusters;
fe4da5cc 616 Int_t nclust = theClusters->GetEntriesFast();
1bd28025 617 if (nclust && hit->PHlast() > 0) {
618 AliMUON::fMaxIterPad=hit->PHlast();
619 AliMUON::fCurIterPad=hit->PHfirst();
a9e2aefa 620 return (AliMUONPadHit*) clusters->UncheckedAt(AliMUON::fCurIterPad-1);
fe4da5cc 621 } else {
622 return 0;
623 }
624}
ce3f5e87 625//_______________________________________________________________________
a9e2aefa 626AliMUONPadHit* AliMUON::NextPad(TClonesArray *clusters)
fe4da5cc 627{
5a35ac13 628 // To be removed
de05461e 629// Get next pad (in iterator)
630//
a9e2aefa 631 AliMUON::fCurIterPad++;
632 if (AliMUON::fCurIterPad <= AliMUON::fMaxIterPad) {
633 return (AliMUONPadHit*) clusters->UncheckedAt(AliMUON::fCurIterPad-1);
fe4da5cc 634 } else {
635 return 0;
636 }
637}
ce3f5e87 638//_______________________________________________________________________
a897a37a 639
640AliMUONRawCluster *AliMUON::RawCluster(Int_t ichamber, Int_t icathod, Int_t icluster)
641{
de05461e 642//
643// Return rawcluster (icluster) for chamber ichamber and cathode icathod
644// Obsolete ??
ce3f5e87 645 TClonesArray *muonRawCluster = GetMUONData()->RawClusters(ichamber);
a897a37a 646 ResetRawClusters();
88cb7938 647 TTree *treeR = fLoader->TreeR();
a9e2aefa 648 Int_t nent=(Int_t)treeR->GetEntries();
649 treeR->GetEvent(nent-2+icathod-1);
650 //treeR->GetEvent(icathod);
651 //Int_t nrawcl = (Int_t)muonRawCluster->GetEntriesFast();
a897a37a 652
a9e2aefa 653 AliMUONRawCluster * mRaw = (AliMUONRawCluster*)muonRawCluster->UncheckedAt(icluster);
a897a37a 654 //printf("RawCluster _ nent nrawcl icluster mRaw %d %d %d%p\n",nent,nrawcl,icluster,mRaw);
655
656 return mRaw;
657}
ce3f5e87 658//________________________________________________________________________
1cae9436 659void AliMUON::SetMerger(AliMUONMerger* merger)
660{
661// Set pointer to merger
662 fMerger = merger;
663}
ce3f5e87 664//________________________________________________________________________
1cae9436 665AliMUONMerger* AliMUON::Merger()
666{
667// Return pointer to merger
668 return fMerger;
669}
ce3f5e87 670//________________________________________________________________________
50e97f19 671AliMUON& AliMUON::operator = (const AliMUON& /*rhs*/)
a897a37a 672{
a9e2aefa 673// copy operator
674// dummy version
675 return *this;
a897a37a 676}
677