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 **************************************************************************/
18 ///////////////////////////////////////////////////////////////////////
19 // Manager and of geomety classes for set: TPC //
21 // !sectors are numbered from 0 //
22 // !pad rows are numbered from 0 //
24 // 12.6. changed z relative
25 // Origin: Marian Ivanov, Uni. of Bratislava, ivanov@fmph.uniba.sk //
27 ///////////////////////////////////////////////////////////////////////
31 #include <AliTPCParam.h>
33 #include <TGeoManager.h>
34 #include <TGeoPhysicalNode.h>
35 #include "AliAlignObj.h"
36 #include "AliAlignObjParams.h"
42 //___________________________________________
43 AliTPCParam::AliTPCParam()
67 fNInnerWiresPerPad(0),
74 fNOuter1WiresPerPad(0),
75 fNOuter2WiresPerPad(0),
81 fInnerPadPitchLength(0.),
82 fInnerPadPitchWidth(0.),
85 fOuter1PadPitchLength(0.),
86 fOuter2PadPitchLength(0.),
87 fOuterPadPitchWidth(0.),
91 fBMWPCReadout(kFALSE),
119 fResponseThreshold(0.),
129 //constructor sets the default parameters
132 SetTitle("75x40_100x60_150x60");
136 AliTPCParam::~AliTPCParam()
139 //destructor deletes some dynamicaly alocated variables
142 if (fResponseBin!=0) delete [] fResponseBin;
143 if (fResponseWeight!=0) delete [] fResponseWeight;
144 if (fRotAngle !=0) delete [] fRotAngle;
146 if (fTrackingMatrix) {
147 for(Int_t i = 0; i < fNSector; i++)
148 delete fTrackingMatrix[i];
149 delete [] fTrackingMatrix;
152 if (fClusterMatrix) {
153 for(Int_t i = 0; i < fNSector; i++)
154 delete fClusterMatrix[i];
155 delete [] fClusterMatrix;
159 for(Int_t i = 0; i < fNSector; i++)
160 delete fGlobalMatrix[i];
161 delete [] fGlobalMatrix;
169 Int_t AliTPCParam::Transform0to1(Float_t *xyz, Int_t * index) const
172 // calculates sector number (index[1], undefined on input)
178 Float_t r = TMath::Sqrt(xyz[0]*xyz[0]+xyz[1]*xyz[1]);
179 if ((xyz[0]==0)&&(xyz[1]==0)) angle = 0.;
182 angle =TMath::ASin(xyz[1]/r);
183 if (xyz[0]<0) angle=TMath::Pi()-angle;
184 if ( (xyz[0]>0) && (xyz[1]<0) ) angle=2*TMath::Pi()+angle;
187 sector=Int_t(TMath::Nint((angle-fInnerAngleShift)/fInnerAngle));
190 AdjustCosSin(sector,cos,sin);
191 x1=xyz[0]*cos + xyz[1]*sin;
193 if (x1>fOuterRadiusLow)
195 sector=Int_t(TMath::Nint((angle-fOuterAngleShift)/fOuterAngle))+fNInnerSector;
196 if (xyz[2]<0) sector+=(fNOuterSector>>1);
199 if (xyz[2]<0) sector+=(fNInnerSector>>1);
200 index[1]=sector; // calculated sector number
201 index[0]=1; // indicates system after transformation
205 Bool_t AliTPCParam::Transform(Float_t */*xyz*/, Int_t *index, Int_t* /*oindex*/)
207 //transformation from input coodination system to output coordination system
217 Int_t AliTPCParam::GetPadRow(Float_t *xyz, Int_t *index) const
220 //calculates pad row of point xyz - transformation to system 8 (digit system)
222 Int_t system = index[0];
224 Transform0to1(xyz,index);
228 Transform1to2(xyz,index);
232 if (fGeometryType==0){ //straight row
234 Transform2to3(xyz,index);
238 Transform3to4(xyz,index);
242 Transform4to8(xyz,index);
251 if (fGeometryType==1){ //cylindrical geometry
253 Transform2to5(xyz,index);
257 Transform2to3(xyz,index);
261 Transform3to4(xyz,index);
270 return -1; //if no reasonable system
273 void AliTPCParam::SetSectorAngles(Float_t innerangle, Float_t innershift, Float_t outerangle,
277 // set opening angles
278 static const Float_t kDegtoRad = 0.01745329251994;
279 fInnerAngle = innerangle; //opening angle of Inner sector
280 fInnerAngleShift = innershift; //shift of first inner sector center to the 0
281 fOuterAngle = outerangle; //opening angle of outer sector
282 fOuterAngleShift = outershift; //shift of first sector center to the 0
283 fInnerAngle *=kDegtoRad;
284 fInnerAngleShift *=kDegtoRad;
285 fOuterAngle *=kDegtoRad;
286 fOuterAngleShift *=kDegtoRad;
289 Float_t AliTPCParam::GetInnerAngle() const
296 Float_t AliTPCParam::GetInnerAngleShift() const
299 return fInnerAngleShift;
301 Float_t AliTPCParam::GetOuterAngle() const
306 Float_t AliTPCParam::GetOuterAngleShift() const
310 return fOuterAngleShift;
314 Int_t AliTPCParam::GetIndex(Int_t sector, Int_t row) const
317 //give index of the given sector and pad row
318 //no control if the sectors and rows are reasonable !!!
320 if (sector<fNInnerSector) return sector*fNRowLow+row;
321 return (fNInnerSector*fNRowLow)+(sector-fNInnerSector)*fNRowUp+row;
324 Bool_t AliTPCParam::AdjustSectorRow(Int_t index, Int_t & sector, Int_t &row) const
327 //return sector and padrow for given index
328 //if index is reasonable returns true else return false
330 if ( (index<0) || (index>fNtRows)) return kFALSE;
331 Int_t outindex = fNInnerSector*fNRowLow;
332 if (index<outindex) {
333 sector = index/fNRowLow;
334 row = index - sector*fNRowLow;
338 sector = index/fNRowUp;
339 row = index - sector*fNRowUp;
340 sector += fNInnerSector;
344 void AliTPCParam::SetDefault()
347 //set default parameters
349 //const static Int_t kMaxRows=600;
351 //sector default parameters
353 static const Float_t kInnerRadiusLow = 83.65;
354 static const Float_t kInnerRadiusUp = 133.3;
355 static const Float_t kOuterRadiusLow = 133.5;
356 static const Float_t kOuterRadiusUp = 247.7;
357 static const Float_t kInnerAngle = 20; // 20 degrees
358 static const Float_t kInnerAngleShift = 10;
359 static const Float_t kOuterAngle = 20; // 20 degrees
360 static const Float_t kOuterAngleShift = 10;
361 static const Float_t kInnerFrameSpace = 1.5;
362 static const Float_t kOuterFrameSpace = 1.5;
363 static const Float_t kInnerWireMount = 1.2;
364 static const Float_t kOuterWireMount = 1.4;
365 static const Float_t kZLength =250.;
366 static const Int_t kGeometryType = 0; //straight rows
367 static const Int_t kNRowLow = 63;
368 static const Int_t kNRowUp1 = 64;
369 static const Int_t kNRowUp2 = 32;
370 static const Int_t kNRowUp = 96;
372 //wires default parameters
374 static const Int_t kNInnerWiresPerPad = 3;
375 static const Int_t kInnerDummyWire = 2;
376 static const Float_t kInnerWWPitch = 0.25;
377 static const Float_t kRInnerFirstWire = 84.475;
378 static const Float_t kRInnerLastWire = 132.475;
379 static const Float_t kInnerOffWire = 0.5;
380 static const Int_t kNOuter1WiresPerPad = 4;
381 static const Int_t kNOuter2WiresPerPad = 6;
382 static const Float_t kOuterWWPitch = 0.25;
383 static const Float_t kROuterFirstWire = 134.225;
384 static const Float_t kROuterLastWire = 246.975;
385 static const Int_t kOuterDummyWire = 2;
386 static const Float_t kOuterOffWire = 0.5;
388 //pad default parameters
390 static const Float_t kInnerPadPitchLength = 0.75;
391 static const Float_t kInnerPadPitchWidth = 0.40;
392 static const Float_t kInnerPadLength = 0.75;
393 static const Float_t kInnerPadWidth = 0.40;
394 static const Float_t kOuter1PadPitchLength = 1.0;
395 static const Float_t kOuterPadPitchWidth = 0.6;
396 static const Float_t kOuter1PadLength = 1.0;
397 static const Float_t kOuterPadWidth = 0.6;
398 static const Float_t kOuter2PadPitchLength = 1.5;
399 static const Float_t kOuter2PadLength = 1.5;
401 static const Bool_t kBMWPCReadout = kTRUE; //MWPC readout - another possibility GEM
402 static const Int_t kNCrossRows = 1; //number of rows to cross-talk
405 //gas default parameters
407 static const Float_t kDiffT = 2.2e-2;
408 static const Float_t kDiffL = 2.2e-2;
409 static const Float_t kGasGain = 2.e4;
410 static const Float_t kDriftV =2.83e6;
411 static const Float_t kOmegaTau = 0.145;
412 static const Float_t kAttCoef = 250.;
413 static const Float_t kOxyCont = 5.e-6;
415 //electronic default parameters
417 static const Float_t kPadCoupling=0.5;
418 static const Int_t kZeroSup=2;
419 static const Float_t kNoise = 1000;
420 static const Float_t kChipGain = 12;
421 static const Float_t kChipNorm = 0.4;
422 static const Float_t kTSample = 2.e-7;
423 static const Float_t kTFWHM = 1.9e-7; //fwhm of charge distribution
424 static const Int_t kMaxTBin =445;
425 static const Int_t kADCSat =1024;
426 static const Float_t kADCDynRange =2000.;
430 static const Int_t kNResponseMax=100;
431 static const Float_t kResponseThreshold=0.01;
433 // static const Float_t kGateDelay=6.1e-6; //In s
434 static const Float_t kGateDelay=0.; //For the moment no gating
435 // static const Float_t kL1Delay=6.5e-6; //In s
436 static const Float_t kL1Delay=0.; //For the moment no delay
437 // static const UShort_t kNTBinsBeforeL1=14;
438 static const UShort_t kNTBinsBeforeL1=0; //For the moment no shift
441 //set sector parameters
443 SetInnerRadiusLow(kInnerRadiusLow);
444 SetOuterRadiusLow(kOuterRadiusLow);
445 SetInnerRadiusUp(kInnerRadiusUp);
446 SetOuterRadiusUp(kOuterRadiusUp);
447 SetInnerFrameSpace(kInnerFrameSpace);
448 SetOuterFrameSpace(kOuterFrameSpace);
449 SetInnerWireMount(kInnerWireMount);
450 SetOuterWireMount(kOuterWireMount);
451 SetSectorAngles(kInnerAngle,kInnerAngleShift,kOuterAngle,kOuterAngleShift);
452 SetZLength(kZLength);
453 SetGeometryType(kGeometryType);
454 SetRowNLow(kNRowLow);
455 SetRowNUp1 (kNRowUp1);
456 SetRowNUp2(kNRowUp2);
459 //set wire parameters
461 SetInnerNWires(kNInnerWiresPerPad);
462 SetInnerDummyWire(kInnerDummyWire);
463 SetInnerOffWire(kInnerOffWire);
464 SetOuter1NWires(kNOuter1WiresPerPad);
465 SetOuter2NWire(kNOuter2WiresPerPad);
466 SetOuterDummyWire(kOuterDummyWire);
467 SetOuterOffWire(kOuterOffWire);
468 SetInnerWWPitch(kInnerWWPitch);
469 SetRInnerFirstWire(kRInnerFirstWire);
470 SetRInnerLastWire(kRInnerLastWire);
471 SetOuterWWPitch(kOuterWWPitch);
472 SetROuterFirstWire(kROuterFirstWire);
473 SetROuterLastWire(kROuterLastWire);
477 SetInnerPadPitchLength(kInnerPadPitchLength);
478 SetInnerPadPitchWidth(kInnerPadPitchWidth);
479 SetInnerPadLength(kInnerPadLength);
480 SetInnerPadWidth(kInnerPadWidth);
481 SetOuter1PadPitchLength(kOuter1PadPitchLength);
482 SetOuter2PadPitchLength(kOuter2PadPitchLength);
483 SetOuterPadPitchWidth(kOuterPadPitchWidth);
484 SetOuter1PadLength(kOuter1PadLength);
485 SetOuter2PadLength(kOuter2PadLength);
486 SetOuterPadWidth(kOuterPadWidth);
487 SetMWPCReadout(kBMWPCReadout);
488 SetNCrossRows(kNCrossRows);
494 SetGasGain(kGasGain);
496 SetOmegaTau(kOmegaTau);
497 SetAttCoef(kAttCoef);
498 SetOxyCont(kOxyCont);
500 //set electronivc parameters
502 SetPadCoupling(kPadCoupling);
503 SetZeroSup(kZeroSup);
505 SetChipGain(kChipGain);
506 SetChipNorm(kChipNorm);
507 SetTSample(kTSample);
509 SetMaxTBin(kMaxTBin);
511 SetADCDynRange(kADCDynRange);
512 // //set magnetic field
513 // SetBField(kBField);
514 // SetNPrimLoss(kNPrimLoss);
515 // SetNTotalLoss(kNTotalLoss);
517 //set response parameters
519 SetNResponseMax(kNResponseMax);
520 SetResponseThreshold(static_cast<int>(kResponseThreshold));
522 SetGateDelay(kGateDelay);
523 SetL1Delay(kL1Delay);
524 SetNTBinsBeforeL1(kNTBinsBeforeL1);
528 Bool_t AliTPCParam::Update()
531 // update some calculated parameter which must be updated after changing "base"
533 // for example we can change size of pads and according this recalculate number
534 // of pad rows, number of of pads in given row ....
536 const Float_t kQel = 1.602e-19; // elementary charge
539 Int_t i,j; //loop variables because HP
540 //-----------------Sector section------------------------------------------
541 //calclulate number of sectors
542 fNInnerSector = Int_t(4*TMath::Pi()/fInnerAngle+0.2);
543 // number of inner sectors - factor 0.2 to don't be influnced by inprecision
544 if (fNInnerSector%2) return kFALSE;
545 fNOuterSector = Int_t(4*TMath::Pi()/fOuterAngle+0.2);
546 if (fNOuterSector%2) return kFALSE;
547 fNSector = fNInnerSector+fNOuterSector;
549 if (fRotAngle!=0) delete [] fRotAngle;
550 fRotAngle = new Float_t[4*fNSector];
551 //calculate sin and cosine of rotations angle
552 //sectors angles numbering from 0
555 Float_t angle = fInnerAngleShift;
556 for (i=0; j<fNInnerSector*4; i+=4, j+=4 , angle +=fInnerAngle){
557 fRotAngle[i]=TMath::Cos(angle);
558 fRotAngle[i+1]=TMath::Sin(angle);
559 fRotAngle[j] = fRotAngle[i];
560 fRotAngle[j+1] = fRotAngle[i+1];
561 fRotAngle[i+2] =angle;
562 fRotAngle[j+2] =angle;
564 angle = fOuterAngleShift;
565 j=(fNInnerSector+fNOuterSector/2)*4;
566 for (i=fNInnerSector*4; j<fNSector*4; i+=4,j+=4, angle +=fOuterAngle){
567 fRotAngle[i]=TMath::Cos(angle);
568 fRotAngle[i+1]=TMath::Sin(angle);
569 fRotAngle[j] = fRotAngle[i];
570 fRotAngle[j+1] = fRotAngle[i+1];
571 fRotAngle[i+2] =angle;
572 fRotAngle[j+2] =angle;
575 fZWidth = fTSample*fDriftV;
576 fTotalNormFac = fPadCoupling*fChipNorm*kQel*1.e15*fChipGain*fADCSat/fADCDynRange;
577 fNoiseNormFac = kQel*1.e15*fChipGain*fADCSat/fADCDynRange;
580 Float_t wspace; //available space for wire
581 Float_t dummyspace; //dummyspace for wire
583 wspace =fInnerRadiusUp-fInnerRadiusLow-2*fInnerOffWire;
584 nwire = Int_t(wspace/fInnerWWPitch);
585 wspace = Float_t(nwire)*fInnerWWPitch;
586 dummyspace =(fInnerRadiusUp-fInnerRadiusLow-wspace)/2.;
587 wspace =fOuterRadiusUp-fOuterRadiusLow-2*fOuterOffWire;
588 nwire = Int_t(wspace/fOuterWWPitch);
589 wspace = Float_t(nwire)*fOuterWWPitch;
590 dummyspace =(fOuterRadiusUp-fOuterRadiusLow-wspace)/2.;
591 fROuterFirstWire = fOuterRadiusLow+dummyspace;
592 fROuterLastWire = fROuterFirstWire+fOuterWWPitch*(Float_t)(nwire);
598 if (fResponseBin) delete [] fResponseBin;
599 if (fResponseWeight) delete [] fResponseWeight;
600 fResponseBin = new Int_t[3*fNResponseMax];
601 fResponseWeight = new Float_t[fNResponseMax];
604 fNTBinsL1 = fL1Delay/fTSample - (Float_t)fNTBinsBeforeL1;
611 Bool_t AliTPCParam::ReadGeoMatrices(){
616 AliFatal("Geo manager not initialized\n");
620 if (fTrackingMatrix) delete [] fTrackingMatrix;
621 fTrackingMatrix = new TGeoHMatrix*[fNSector];
622 if (fClusterMatrix) delete [] fClusterMatrix;
623 fClusterMatrix = new TGeoHMatrix*[fNSector];
624 if (fGlobalMatrix) delete [] fGlobalMatrix;
625 fGlobalMatrix = new TGeoHMatrix*[fNSector];
627 for (Int_t isec=0; isec<fNSector; isec++) {
628 fGlobalMatrix[isec] = 0;
629 fClusterMatrix[isec]= 0;
630 fTrackingMatrix[isec]=0;
631 AliGeomManager::ELayerID iLayer;
634 if(isec<fNInnerSector) {
635 iLayer = AliGeomManager::kTPC1;
639 iLayer = AliGeomManager::kTPC2;
640 iModule = isec - fNInnerSector;
643 UShort_t volid = AliGeomManager::LayerToVolUID(iLayer,iModule);
644 const char *symname = AliGeomManager::SymName(volid);
645 TGeoPNEntry* pne = gGeoManager->GetAlignableEntry(symname);
646 const char *path = symname;
647 if(pne) path=pne->GetTitle();
648 if (!gGeoManager->cd(path)) return kFALSE;
649 TGeoHMatrix *m = gGeoManager->GetCurrentMatrix();
652 TGeoRotation mchange;
653 mchange.RotateY(90); mchange.RotateX(90);
654 Float_t ROCcenter[3];
655 GetChamberCenter(isec,ROCcenter);
657 // Convert to global coordinate system
659 fGlobalMatrix[isec] = new TGeoHMatrix(*m);
660 fGlobalMatrix[isec]->Multiply(&(mchange.Inverse()));
661 TGeoTranslation center("center",-ROCcenter[0],-ROCcenter[1],-ROCcenter[2]);
662 fGlobalMatrix[isec]->Multiply(¢er);
664 // cluster correction matrix
666 fClusterMatrix[isec] = new TGeoHMatrix;
667 Double_t sectorAngle = 20.*(isec%18)+10;
668 TGeoHMatrix rotMatrix;
669 rotMatrix.RotateZ(sectorAngle);
670 if (GetGlobalMatrix(isec)->GetTranslation()[2]>0){
674 TGeoRotation mirrorZ;
675 mirrorZ.SetAngles(90,0,90,90,180,0);
676 fClusterMatrix[isec]->Multiply(&mirrorZ);
678 TGeoTranslation trans(0,0,GetZLength(isec));
679 fClusterMatrix[isec]->MultiplyLeft(&trans);
680 fClusterMatrix[isec]->MultiplyLeft((GetGlobalMatrix(isec)));
681 fClusterMatrix[isec]->MultiplyLeft(&(rotMatrix.Inverse()));
686 TGeoHMatrix * AliTPCParam::Tracking2LocalMatrix(const TGeoHMatrix * geoMatrix, Int_t sector) const{
688 // make local to tracking matrix
690 Double_t sectorAngle = 20.*(sector%18)+10;
691 TGeoHMatrix *newMatrix = new TGeoHMatrix();
692 newMatrix->RotateZ(sectorAngle);
693 newMatrix->MultiplyLeft(&(geoMatrix->Inverse()));
700 Bool_t AliTPCParam::GetStatus() const
702 //get information about object consistency
706 Int_t AliTPCParam::GetNRowLow() const
708 //get the number of pad rows in low sector
711 Int_t AliTPCParam::GetNRowUp() const
713 //get the number of pad rows in up sector
716 Int_t AliTPCParam::GetNRowUp1() const
718 //get the number of pad rows in up1 sector
721 Int_t AliTPCParam::GetNRowUp2() const
723 //get the number of pad rows in up2 sector
726 Float_t AliTPCParam::GetPadRowRadiiLow(Int_t irow) const
728 //get the pad row (irow) radii
729 if ( !(irow<0) && (irow<fNRowLow) )
730 return fPadRowLow[irow];
735 Float_t AliTPCParam::GetPadRowRadiiUp(Int_t irow) const
737 //get the pad row (irow) radii
738 if ( !(irow<0) && (irow<fNRowUp) )
739 return fPadRowUp[irow];
744 Int_t AliTPCParam::GetNPadsLow(Int_t irow) const
746 //get the number of pads in row irow
747 if ( !(irow<0) && (irow<fNRowLow) )
748 return fNPadsLow[irow];
754 Int_t AliTPCParam::GetNPadsUp(Int_t irow) const
756 //get the number of pads in row irow
757 if ( !(irow<0) && (irow<fNRowUp) )
758 return fNPadsUp[irow];
762 Float_t AliTPCParam::GetYInner(Int_t irow) const
764 return fYInner[irow];
768 Float_t AliTPCParam::GetYOuter(Int_t irow) const
770 return fYOuter[irow];
773 Int_t AliTPCParam::GetSectorIndex(Float_t angle, Int_t row, Float_t z) const
775 // returns the sector index
776 // takes as input the angle, index of the pad row and z position
779 if (angle > 2.*TMath::Pi()) angle -= 2.*TMath::Pi();
780 if (angle < 0. ) angle += 2.*TMath::Pi();
784 sector=Int_t(TMath::Nint((angle-fInnerAngleShift)/fInnerAngle));
785 if (z<0) sector += (fNInnerSector>>1);
788 sector=Int_t(TMath::Nint((angle-fOuterAngleShift)/fOuterAngle))+fNInnerSector;
789 if (z<0) sector += (fNOuterSector>>1);
795 Float_t AliTPCParam::GetChamberCenter(Int_t isec, Float_t * center) const
797 // returns the default radial position
798 // of the readout chambers
800 const Float_t kROCcenterIn = 110.2;
801 const Float_t kROCcenterOut = 188.45;
803 if (isec<fNInnerSector){
805 center[0] = kROCcenterIn;
807 center[2] = -5.51-0.08;
813 center[0] = kROCcenterOut;
815 center[2] = -5.61-0.08;
817 return kROCcenterOut;