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>
36 #include "AliAlignObj.h"
37 #include "AliAlignObjParams.h"
43 //___________________________________________
44 AliTPCParam::AliTPCParam()
68 fNInnerWiresPerPad(0),
75 fNOuter1WiresPerPad(0),
76 fNOuter2WiresPerPad(0),
82 fInnerPadPitchLength(0.),
83 fInnerPadPitchWidth(0.),
86 fOuter1PadPitchLength(0.),
87 fOuter2PadPitchLength(0.),
88 fOuterPadPitchWidth(0.),
92 fBMWPCReadout(kFALSE),
121 fResponseThreshold(0.),
131 //constructor sets the default parameters
134 SetTitle("75x40_100x60_150x60");
138 AliTPCParam::~AliTPCParam()
141 //destructor deletes some dynamicaly alocated variables
144 if (fResponseBin!=0) delete [] fResponseBin;
145 if (fResponseWeight!=0) delete [] fResponseWeight;
146 if (fRotAngle !=0) delete [] fRotAngle;
152 Int_t AliTPCParam::Transform0to1(Float_t *xyz, Int_t * index) const
155 // calculates sector number (index[1], undefined on input)
161 Float_t r = TMath::Sqrt(xyz[0]*xyz[0]+xyz[1]*xyz[1]);
162 if ((xyz[0]==0)&&(xyz[1]==0)) angle = 0.;
165 angle =TMath::ASin(xyz[1]/r);
166 if (xyz[0]<0) angle=TMath::Pi()-angle;
167 if ( (xyz[0]>0) && (xyz[1]<0) ) angle=2*TMath::Pi()+angle;
170 sector=Int_t(TMath::Nint((angle-fInnerAngleShift)/fInnerAngle));
173 AdjustCosSin(sector,cos,sin);
174 x1=xyz[0]*cos + xyz[1]*sin;
176 if (x1>fOuterRadiusLow)
178 sector=Int_t(TMath::Nint((angle-fOuterAngleShift)/fOuterAngle))+fNInnerSector;
179 if (xyz[2]<0) sector+=(fNOuterSector>>1);
182 if (xyz[2]<0) sector+=(fNInnerSector>>1);
183 if (sector<0 || sector>=fNSector) AliError(Form("Wrong sector %d",sector));
184 index[1]=sector; // calculated sector number
185 index[0]=1; // indicates system after transformation
189 Bool_t AliTPCParam::Transform(Float_t */*xyz*/, Int_t *index, Int_t* /*oindex*/)
191 //transformation from input coodination system to output coordination system
201 Int_t AliTPCParam::GetPadRow(Float_t *xyz, Int_t *index) const
204 //calculates pad row of point xyz - transformation to system 8 (digit system)
206 Int_t system = index[0];
208 Transform0to1(xyz,index);
212 Transform1to2(xyz,index);
216 if (fGeometryType==0){ //straight row
218 Transform2to3(xyz,index);
222 Transform3to4(xyz,index);
226 Transform4to8(xyz,index);
235 if (fGeometryType==1){ //cylindrical geometry
237 Transform2to5(xyz,index);
241 Transform2to3(xyz,index);
245 Transform3to4(xyz,index);
254 return -1; //if no reasonable system
257 void AliTPCParam::SetSectorAngles(Float_t innerangle, Float_t innershift, Float_t outerangle,
261 // set opening angles
262 static const Float_t kDegtoRad = 0.01745329251994;
263 fInnerAngle = innerangle; //opening angle of Inner sector
264 fInnerAngleShift = innershift; //shift of first inner sector center to the 0
265 fOuterAngle = outerangle; //opening angle of outer sector
266 fOuterAngleShift = outershift; //shift of first sector center to the 0
267 fInnerAngle *=kDegtoRad;
268 fInnerAngleShift *=kDegtoRad;
269 fOuterAngle *=kDegtoRad;
270 fOuterAngleShift *=kDegtoRad;
273 Float_t AliTPCParam::GetInnerAngle() const
280 Float_t AliTPCParam::GetInnerAngleShift() const
283 return fInnerAngleShift;
285 Float_t AliTPCParam::GetOuterAngle() const
290 Float_t AliTPCParam::GetOuterAngleShift() const
294 return fOuterAngleShift;
298 Int_t AliTPCParam::GetIndex(Int_t sector, Int_t row) const
301 //give index of the given sector and pad row
302 //no control if the sectors and rows are reasonable !!!
304 if (sector<fNInnerSector) return sector*fNRowLow+row;
305 return (fNInnerSector*fNRowLow)+(sector-fNInnerSector)*fNRowUp+row;
308 Bool_t AliTPCParam::AdjustSectorRow(Int_t index, Int_t & sector, Int_t &row) const
311 //return sector and padrow for given index
312 //if index is reasonable returns true else return false
314 if ( (index<0) || (index>fNtRows)) return kFALSE;
315 Int_t outindex = fNInnerSector*fNRowLow;
316 if (index<outindex) {
317 sector = index/fNRowLow;
318 row = index - sector*fNRowLow;
322 sector = index/fNRowUp;
323 row = index - sector*fNRowUp;
324 sector += fNInnerSector;
328 void AliTPCParam::SetDefault()
331 //set default parameters
333 //const static Int_t kMaxRows=600;
335 //sector default parameters
337 static const Float_t kInnerRadiusLow = 83.65;
338 static const Float_t kInnerRadiusUp = 133.3;
339 static const Float_t kOuterRadiusLow = 133.5;
340 static const Float_t kOuterRadiusUp = 247.7;
341 static const Float_t kInnerAngle = 20; // 20 degrees
342 static const Float_t kInnerAngleShift = 10;
343 static const Float_t kOuterAngle = 20; // 20 degrees
344 static const Float_t kOuterAngleShift = 10;
345 static const Float_t kInnerFrameSpace = 1.5;
346 static const Float_t kOuterFrameSpace = 1.5;
347 static const Float_t kInnerWireMount = 1.2;
348 static const Float_t kOuterWireMount = 1.4;
349 static const Float_t kZLength =250.;
350 static const Int_t kGeometryType = 0; //straight rows
351 static const Int_t kNRowLow = 63;
352 static const Int_t kNRowUp1 = 64;
353 static const Int_t kNRowUp2 = 32;
354 static const Int_t kNRowUp = 96;
356 //wires default parameters
358 static const Int_t kNInnerWiresPerPad = 3;
359 static const Int_t kInnerDummyWire = 2;
360 static const Float_t kInnerWWPitch = 0.25;
361 static const Float_t kRInnerFirstWire = 84.475;
362 static const Float_t kRInnerLastWire = 132.475;
363 static const Float_t kInnerOffWire = 0.5;
364 static const Int_t kNOuter1WiresPerPad = 4;
365 static const Int_t kNOuter2WiresPerPad = 6;
366 static const Float_t kOuterWWPitch = 0.25;
367 static const Float_t kROuterFirstWire = 134.225;
368 static const Float_t kROuterLastWire = 246.975;
369 static const Int_t kOuterDummyWire = 2;
370 static const Float_t kOuterOffWire = 0.5;
372 //pad default parameters
374 static const Float_t kInnerPadPitchLength = 0.75;
375 static const Float_t kInnerPadPitchWidth = 0.40;
376 static const Float_t kInnerPadLength = 0.75;
377 static const Float_t kInnerPadWidth = 0.40;
378 static const Float_t kOuter1PadPitchLength = 1.0;
379 static const Float_t kOuterPadPitchWidth = 0.6;
380 static const Float_t kOuter1PadLength = 1.0;
381 static const Float_t kOuterPadWidth = 0.6;
382 static const Float_t kOuter2PadPitchLength = 1.5;
383 static const Float_t kOuter2PadLength = 1.5;
385 static const Bool_t kBMWPCReadout = kTRUE; //MWPC readout - another possibility GEM
386 static const Int_t kNCrossRows = 1; //number of rows to cross-talk
389 //gas default parameters
391 static const Float_t kDiffT = 2.2e-2;
392 static const Float_t kDiffL = 2.2e-2;
393 static const Float_t kGasGain = 2.e4;
394 static const Float_t kDriftV =2.83e6;
395 static const Float_t kOmegaTau = 0.145;
396 static const Float_t kAttCoef = 250.;
397 static const Float_t kOxyCont = 5.e-6;
399 //electronic default parameters
401 static const Float_t kPadCoupling=0.5;
402 static const Int_t kZeroSup=2;
403 static const Float_t kNoise = 1000;
404 static const Float_t kChipGain = 12;
405 static const Float_t kChipNorm = 0.4;
406 static const Float_t kTSample = 2.e-7;
407 static const Float_t kTFWHM = 1.9e-7; //fwhm of charge distribution
408 static const Int_t kMaxTBin =445;
409 static const Int_t kADCSat =1024;
410 static const Float_t kADCDynRange =2000.;
414 static const Int_t kNResponseMax=100;
415 static const Float_t kResponseThreshold=0.01;
417 // static const Float_t kGateDelay=6.1e-6; //In s
418 static const Float_t kGateDelay=0.; //For the moment no gating
419 // static const Float_t kL1Delay=6.5e-6; //In s
420 static const Float_t kL1Delay=0.; //For the moment no delay
421 // static const UShort_t kNTBinsBeforeL1=14;
422 static const UShort_t kNTBinsBeforeL1=0; //For the moment no shift
425 //set sector parameters
427 SetInnerRadiusLow(kInnerRadiusLow);
428 SetOuterRadiusLow(kOuterRadiusLow);
429 SetInnerRadiusUp(kInnerRadiusUp);
430 SetOuterRadiusUp(kOuterRadiusUp);
431 SetInnerFrameSpace(kInnerFrameSpace);
432 SetOuterFrameSpace(kOuterFrameSpace);
433 SetInnerWireMount(kInnerWireMount);
434 SetOuterWireMount(kOuterWireMount);
435 SetSectorAngles(kInnerAngle,kInnerAngleShift,kOuterAngle,kOuterAngleShift);
436 SetZLength(kZLength);
437 SetGeometryType(kGeometryType);
438 SetRowNLow(kNRowLow);
439 SetRowNUp1 (kNRowUp1);
440 SetRowNUp2(kNRowUp2);
443 //set wire parameters
445 SetInnerNWires(kNInnerWiresPerPad);
446 SetInnerDummyWire(kInnerDummyWire);
447 SetInnerOffWire(kInnerOffWire);
448 SetOuter1NWires(kNOuter1WiresPerPad);
449 SetOuter2NWire(kNOuter2WiresPerPad);
450 SetOuterDummyWire(kOuterDummyWire);
451 SetOuterOffWire(kOuterOffWire);
452 SetInnerWWPitch(kInnerWWPitch);
453 SetRInnerFirstWire(kRInnerFirstWire);
454 SetRInnerLastWire(kRInnerLastWire);
455 SetOuterWWPitch(kOuterWWPitch);
456 SetROuterFirstWire(kROuterFirstWire);
457 SetROuterLastWire(kROuterLastWire);
461 SetInnerPadPitchLength(kInnerPadPitchLength);
462 SetInnerPadPitchWidth(kInnerPadPitchWidth);
463 SetInnerPadLength(kInnerPadLength);
464 SetInnerPadWidth(kInnerPadWidth);
465 SetOuter1PadPitchLength(kOuter1PadPitchLength);
466 SetOuter2PadPitchLength(kOuter2PadPitchLength);
467 SetOuterPadPitchWidth(kOuterPadPitchWidth);
468 SetOuter1PadLength(kOuter1PadLength);
469 SetOuter2PadLength(kOuter2PadLength);
470 SetOuterPadWidth(kOuterPadWidth);
471 SetMWPCReadout(kBMWPCReadout);
472 SetNCrossRows(kNCrossRows);
478 SetGasGain(kGasGain);
480 SetOmegaTau(kOmegaTau);
481 SetAttCoef(kAttCoef);
482 SetOxyCont(kOxyCont);
484 //set electronivc parameters
486 SetPadCoupling(kPadCoupling);
487 SetZeroSup(kZeroSup);
489 SetChipGain(kChipGain);
490 SetChipNorm(kChipNorm);
491 SetTSample(kTSample);
493 SetMaxTBin(kMaxTBin);
495 SetADCDynRange(kADCDynRange);
496 for (UInt_t i=0; i<36; i++)
498 SetNominalVoltage(1196.0, i);
500 for (UInt_t i=36; i<72; i++)
502 SetNominalVoltage(1417.0, i);
504 // //set magnetic field
505 // SetBField(kBField);
506 // SetNPrimLoss(kNPrimLoss);
507 // SetNTotalLoss(kNTotalLoss);
509 //set response parameters
511 SetNResponseMax(kNResponseMax);
512 SetResponseThreshold(static_cast<int>(kResponseThreshold));
514 SetGateDelay(kGateDelay);
515 SetL1Delay(kL1Delay);
516 SetNTBinsBeforeL1(kNTBinsBeforeL1);
520 Bool_t AliTPCParam::Update()
523 // update some calculated parameter which must be updated after changing "base"
525 // for example we can change size of pads and according this recalculate number
526 // of pad rows, number of of pads in given row ....
528 const Float_t kQel = 1.602e-19; // elementary charge
531 Int_t i,j; //loop variables because HP
532 //-----------------Sector section------------------------------------------
533 //calclulate number of sectors
534 fNInnerSector = Int_t(4*TMath::Pi()/fInnerAngle+0.2);
535 // number of inner sectors - factor 0.2 to don't be influnced by inprecision
536 if (fNInnerSector%2) return kFALSE;
537 fNOuterSector = Int_t(4*TMath::Pi()/fOuterAngle+0.2);
538 if (fNOuterSector%2) return kFALSE;
539 fNSector = fNInnerSector+fNOuterSector;
541 if (fRotAngle!=0) delete [] fRotAngle;
542 fRotAngle = new Float_t[4*fNSector];
543 //calculate sin and cosine of rotations angle
544 //sectors angles numbering from 0
547 Float_t angle = fInnerAngleShift;
548 for (i=0; j<fNInnerSector*4; i+=4, j+=4 , angle +=fInnerAngle){
549 fRotAngle[i]=TMath::Cos(angle);
550 fRotAngle[i+1]=TMath::Sin(angle);
551 fRotAngle[j] = fRotAngle[i];
552 fRotAngle[j+1] = fRotAngle[i+1];
553 fRotAngle[i+2] =angle;
554 fRotAngle[j+2] =angle;
556 angle = fOuterAngleShift;
557 j=(fNInnerSector+fNOuterSector/2)*4;
558 for (i=fNInnerSector*4; j<fNSector*4; i+=4,j+=4, angle +=fOuterAngle){
559 fRotAngle[i]=TMath::Cos(angle);
560 fRotAngle[i+1]=TMath::Sin(angle);
561 fRotAngle[j] = fRotAngle[i];
562 fRotAngle[j+1] = fRotAngle[i+1];
563 fRotAngle[i+2] =angle;
564 fRotAngle[j+2] =angle;
567 fZWidth = fTSample*fDriftV;
568 fTotalNormFac = fPadCoupling*fChipNorm*kQel*1.e15*fChipGain*fADCSat/fADCDynRange;
569 fNoiseNormFac = kQel*1.e15*fChipGain*fADCSat/fADCDynRange;
572 Float_t wspace; //available space for wire
573 Float_t dummyspace; //dummyspace for wire
575 wspace =fInnerRadiusUp-fInnerRadiusLow-2*fInnerOffWire;
576 nwire = Int_t(wspace/fInnerWWPitch);
577 wspace = Float_t(nwire)*fInnerWWPitch;
578 dummyspace =(fInnerRadiusUp-fInnerRadiusLow-wspace)/2.;
579 wspace =fOuterRadiusUp-fOuterRadiusLow-2*fOuterOffWire;
580 nwire = Int_t(wspace/fOuterWWPitch);
581 wspace = Float_t(nwire)*fOuterWWPitch;
582 dummyspace =(fOuterRadiusUp-fOuterRadiusLow-wspace)/2.;
583 fROuterFirstWire = fOuterRadiusLow+dummyspace;
584 fROuterLastWire = fROuterFirstWire+fOuterWWPitch*(Float_t)(nwire);
590 if (fResponseBin) delete [] fResponseBin;
591 if (fResponseWeight) delete [] fResponseWeight;
592 fResponseBin = new Int_t[3*fNResponseMax];
593 fResponseWeight = new Float_t[fNResponseMax];
596 fNTBinsL1 = fL1Delay/fTSample - (Float_t)fNTBinsBeforeL1;
601 void AliTPCParam::CleanGeoMatrices(){
603 // clean geo matrices
606 if (fTrackingMatrix) {
607 for(Int_t i = 0; i < fNSector; i++)
608 delete fTrackingMatrix[i];
609 delete [] fTrackingMatrix;
612 if (fClusterMatrix) {
613 for(Int_t i = 0; i < fNSector; i++)
614 delete fClusterMatrix[i];
615 delete [] fClusterMatrix;
619 for(Int_t i = 0; i < fNSector; i++)
620 delete fGlobalMatrix[i];
621 delete [] fGlobalMatrix;
627 Bool_t AliTPCParam::ReadGeoMatrices(){
632 AliFatal("Geo manager not initialized\n");
637 // clean geo matrices
640 // create new geo matrices
641 fTrackingMatrix = new TGeoHMatrix*[fNSector];
642 fClusterMatrix = new TGeoHMatrix*[fNSector];
643 fGlobalMatrix = new TGeoHMatrix*[fNSector];
644 for (Int_t isec=0; isec<fNSector; isec++) {
645 fGlobalMatrix[isec] = 0;
646 fClusterMatrix[isec]= 0;
647 fTrackingMatrix[isec]=0;
650 for (Int_t isec=0; isec<fNSector; isec++) {
651 fGlobalMatrix[isec] = 0;
652 fClusterMatrix[isec]= 0;
653 fTrackingMatrix[isec]=0;
654 AliGeomManager::ELayerID iLayer;
657 if(isec<fNInnerSector) {
658 iLayer = AliGeomManager::kTPC1;
662 iLayer = AliGeomManager::kTPC2;
663 iModule = isec - fNInnerSector;
666 UShort_t volid = AliGeomManager::LayerToVolUID(iLayer,iModule);
667 TGeoPNEntry* pne = gGeoManager->GetAlignableEntryByUID(volid);
670 AliError(Form("Alignable entry for volume ID %d not in geometry. Exiting!",volid));
673 const char *path = pne->GetTitle();
674 if (!gGeoManager->cd(path)) return kFALSE;
675 TGeoHMatrix *m = gGeoManager->GetCurrentMatrix();
676 // Since GEANT4 does not allow reflections, in this case the reflection
677 // component if the matrix is embedded by TGeo inside TGeoScaledShape
678 if (gGeoManager->GetCurrentVolume()->GetShape()->IsReflected())
679 m->ReflectZ(kFALSE, kTRUE);
681 TGeoRotation mchange;
682 mchange.RotateY(90); mchange.RotateX(90);
683 Float_t ROCcenter[3];
684 GetChamberCenter(isec,ROCcenter);
686 // Convert to global coordinate system
688 fGlobalMatrix[isec] = new TGeoHMatrix(*m);
689 fGlobalMatrix[isec]->Multiply(&(mchange.Inverse()));
690 TGeoTranslation center("center",-ROCcenter[0],-ROCcenter[1],-ROCcenter[2]);
691 fGlobalMatrix[isec]->Multiply(¢er);
693 // cluster correction matrix
695 fClusterMatrix[isec] = new TGeoHMatrix;
696 Double_t sectorAngle = 20.*(isec%18)+10;
697 TGeoHMatrix rotMatrix;
698 rotMatrix.RotateZ(sectorAngle);
699 if (GetGlobalMatrix(isec)->GetTranslation()[2]>0){
703 TGeoRotation mirrorZ;
704 mirrorZ.SetAngles(90,0,90,90,180,0);
705 fClusterMatrix[isec]->Multiply(&mirrorZ);
707 TGeoTranslation trans(0,0,GetZLength(isec));
708 fClusterMatrix[isec]->MultiplyLeft(&trans);
709 fClusterMatrix[isec]->MultiplyLeft((GetGlobalMatrix(isec)));
710 fClusterMatrix[isec]->MultiplyLeft(&(rotMatrix.Inverse()));
715 TGeoHMatrix * AliTPCParam::Tracking2LocalMatrix(const TGeoHMatrix * geoMatrix, Int_t sector) const{
717 // make local to tracking matrix
719 Double_t sectorAngle = 20.*(sector%18)+10;
720 TGeoHMatrix *newMatrix = new TGeoHMatrix();
721 newMatrix->RotateZ(sectorAngle);
722 newMatrix->MultiplyLeft(&(geoMatrix->Inverse()));
729 Bool_t AliTPCParam::GetStatus() const
731 //get information about object consistency
735 Int_t AliTPCParam::GetNRowLow() const
737 //get the number of pad rows in low sector
740 Int_t AliTPCParam::GetNRowUp() const
742 //get the number of pad rows in up sector
745 Int_t AliTPCParam::GetNRowUp1() const
747 //get the number of pad rows in up1 sector
750 Int_t AliTPCParam::GetNRowUp2() const
752 //get the number of pad rows in up2 sector
755 Float_t AliTPCParam::GetPadRowRadiiLow(Int_t irow) const
757 //get the pad row (irow) radii
758 if ( !(irow<0) && (irow<fNRowLow) )
759 return fPadRowLow[irow];
764 Float_t AliTPCParam::GetPadRowRadiiUp(Int_t irow) const
766 //get the pad row (irow) radii
767 if ( !(irow<0) && (irow<fNRowUp) )
768 return fPadRowUp[irow];
773 Int_t AliTPCParam::GetNPadsLow(Int_t irow) const
775 //get the number of pads in row irow
776 if ( !(irow<0) && (irow<fNRowLow) )
777 return fNPadsLow[irow];
783 Int_t AliTPCParam::GetNPadsUp(Int_t irow) const
785 //get the number of pads in row irow
786 if ( !(irow<0) && (irow<fNRowUp) )
787 return fNPadsUp[irow];
791 Float_t AliTPCParam::GetYInner(Int_t irow) const
793 return fYInner[irow];
797 Float_t AliTPCParam::GetYOuter(Int_t irow) const
799 return fYOuter[irow];
802 Int_t AliTPCParam::GetSectorIndex(Float_t angle, Int_t row, Float_t z) const
804 // returns the sector index
805 // takes as input the angle, index of the pad row and z position
808 if (angle > 2.*TMath::Pi()) angle -= 2.*TMath::Pi();
809 if (angle < 0. ) angle += 2.*TMath::Pi();
813 sector=Int_t(TMath::Nint((angle-fInnerAngleShift)/fInnerAngle));
814 if (z<0) sector += (fNInnerSector>>1);
817 sector=Int_t(TMath::Nint((angle-fOuterAngleShift)/fOuterAngle))+fNInnerSector;
818 if (z<0) sector += (fNOuterSector>>1);
824 Float_t AliTPCParam::GetChamberCenter(Int_t isec, Float_t * center) const
826 // returns the default radial position
827 // of the readout chambers
829 const Float_t kROCcenterIn = 110.2;
830 const Float_t kROCcenterOut = 188.45;
832 if (isec<fNInnerSector){
834 center[0] = kROCcenterIn;
836 center[2] = -5.51-0.08;
842 center[0] = kROCcenterOut;
844 center[2] = -5.61-0.08;
846 return kROCcenterOut;