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 ///////////////////////////////////////////////////////////////////////////////
20 // Class providing the calibration parameters by accessing the CDB //
22 // Request an instance with AliTRDcalibDB::Instance() //
23 // If a new event is processed set the event number with SetRun //
24 // Then request the calibration data //
26 ///////////////////////////////////////////////////////////////////////////////
30 #include <AliCDBManager.h>
32 #include "AliTRDcalibDB.h"
33 #include "AliTRDgeometry.h"
34 #include "AliTRDpadPlane.h"
35 #include "AliTRDCommonParam.h"
37 #include "Cal/AliTRDCalROC.h"
39 #include "Cal/AliTRDCalChamberPos.h"
40 #include "Cal/AliTRDCalStackPos.h"
41 #include "Cal/AliTRDCalSuperModulePos.h"
43 #include "Cal/AliTRDCalPad.h"
44 #include "Cal/AliTRDCalDet.h"
45 #include "Cal/AliTRDCalGlobals.h"
46 #include "Cal/AliTRDCalPIDLQ.h"
47 #include "Cal/AliTRDCalMonitoring.h"
49 #include "Cal/AliTRDCalSuperModuleStatus.h"
50 #include "Cal/AliTRDCalChamberStatus.h"
51 #include "Cal/AliTRDCalMCMStatus.h"
52 #include "Cal/AliTRDCalPadStatus.h"
53 #include "Cal/AliTRDCalSingleChamberStatus.h"
55 ClassImp(AliTRDcalibDB)
57 AliTRDcalibDB* AliTRDcalibDB::fgInstance = 0;
58 Bool_t AliTRDcalibDB::fgTerminated = kFALSE;
60 //_ singleton implementation __________________________________________________
61 AliTRDcalibDB* AliTRDcalibDB::Instance()
64 // Singleton implementation
65 // Returns an instance of this class, it is created if neccessary
68 if (fgTerminated != kFALSE)
72 fgInstance = new AliTRDcalibDB();
77 void AliTRDcalibDB::Terminate()
80 // Singleton implementation
81 // Deletes the instance of this class and sets the terminated flag, instances cannot be requested anymore
82 // This function can be called several times.
94 //_____________________________________________________________________________
95 AliTRDcalibDB::AliTRDcalibDB()
101 // TODO Default runnumber is set to 0, this should be changed later to an invalid value (e.g. -1) to prevent
102 // TODO invalid calibration data to be used.
105 fPadResponse.fPRFbin = 0;
106 fPadResponse.fPRFlo = 0.0;
107 fPadResponse.fPRFhi = 0.0;
108 fPadResponse.fPRFwid = 0.0;
109 fPadResponse.fPRFpad = 0;
110 fPadResponse.fPRFsmp = 0;
112 AliCDBManager* manager = AliCDBManager::Instance();
115 std::cout << "AliTRDcalibDB: CRITICAL: Failed to get instance of AliCDBManager." << std::endl;
119 fLocator = manager->GetStorage("local://$ALICE_ROOT");
121 for (Int_t i=0; i<kCDBCacheSize; ++i)
127 // Create the sampled PRF
131 //_____________________________________________________________________________
132 AliTRDcalibDB::~AliTRDcalibDB()
138 if (fPadResponse.fPRFsmp) {
139 delete [] fPadResponse.fPRFsmp;
140 fPadResponse.fPRFsmp = 0;
146 //_caching functions____________________________________________________________
147 const TObject* AliTRDcalibDB::GetCachedCDBObject(Int_t id)
150 // Retrieves a cdb object with the given id. The objects are cached as long as the run number is not changed.
152 // Put together the available objects here by using the lines
153 // a) For usual calibration objects:
154 // ase kID<Name> : return CacheCDBEntry(kID<Name>, "TRD/Calib/<Path>"); break;
155 // See function CacheCDBEntry for details.
157 // b) For calibration data which depends on two objects: One containing a value per detector and one the local fluctuations per pad:
158 // case kID<Name> : return CacheMergeCDBEntry(kID<Name>, "TRD/Calib/<padPath>", "TRD/Calib/<chamberPath>"); break;
159 // See function CacheMergeCDBEntry for details.
164 // parameters defined per pad and chamber
165 case kIDVdriftPad : return CacheCDBEntry(kIDVdriftPad, "TRD/Calib/LocalVdrift"); break;
166 case kIDVdriftChamber : return CacheCDBEntry(kIDVdriftChamber, "TRD/Calib/ChamberVdrift"); break;
168 case kIDT0Pad : return CacheCDBEntry(kIDT0Pad, "TRD/Calib/LocalT0"); break;
169 case kIDT0Chamber : return CacheCDBEntry(kIDT0Chamber, "TRD/Calib/ChamberT0"); break;
171 case kIDGainFactorPad : return CacheCDBEntry(kIDGainFactorPad, "TRD/Calib/LocalGainFactor"); break;
172 case kIDGainFactorChamber : return CacheCDBEntry(kIDGainFactorChamber, "TRD/Calib/ChamberGainFactor"); break;
174 // parameters defined per pad
175 case kIDPRFWidth : return CacheCDBEntry(kIDPRFWidth, "TRD/Calib/PRFWidth"); break;
178 case kIDSuperModuleStatus : return CacheCDBEntry(kIDSuperModuleStatus, "TRD/Calib/SuperModuleStatus"); break;
179 case kIDChamberStatus : return CacheCDBEntry(kIDChamberStatus, "TRD/Calib/ChamberStatus"); break;
180 case kIDMCMStatus : return CacheCDBEntry(kIDMCMStatus, "TRD/Calib/MCMStatus"); break;
181 case kIDPadStatus : return CacheCDBEntry(kIDPadStatus, "TRD/Calib/PadStatus"); break;
184 case kIDMonitoringData : return CacheCDBEntry(kIDMonitoringData, "TRD/Calib/MonitoringData"); break;
185 case kIDGlobals : return CacheCDBEntry(kIDGlobals, "TRD/Calib/Globals"); break;
186 case kIDSuperModulePos : return CacheCDBEntry(kIDSuperModulePos, "TRD/Calib/SuperModulePos"); break;
187 case kIDChamberPos : return CacheCDBEntry(kIDChamberPos, "TRD/Calib/ChamberPos"); break;
188 case kIDStackPos : return CacheCDBEntry(kIDStackPos, "TRD/Calib/StackPos"); break;
189 case kIDPIDLQ : return CacheCDBEntry(kIDPIDLQ, "TRD/Calib/PIDLQ"); break;
194 //_____________________________________________________________________________
195 AliCDBEntry* AliTRDcalibDB::GetCDBEntry(const char* cdbPath)
198 // Retrieves an entry with path <cdbPath> from the CDB.
203 AliFatal("AliTRDcalibDB: Run number not set! Use AliTRDcalibDB::SetRun.");
204 //std::cerr << "AliTRDcalibDB: Run number not set! Use AliTRDcalibDB::SetRun." << std::endl;
209 std::cerr << "AliTRDcalibDB: Storage Locator not available." << std::endl;
212 AliCDBEntry* entry = fLocator->Get(cdbPath, fRun);
215 std::cerr << "AliTRDcalibDB: Failed to get entry: " << cdbPath << std::endl;
219 std::cout << "AliTRDcalibDB: Retrieved object: " << cdbPath << std::endl;
223 //_____________________________________________________________________________
224 const TObject* AliTRDcalibDB::CacheCDBEntry(Int_t id, const char* cdbPath)
227 // Caches the entry <id> with cdb path <cdbPath>
232 fCDBEntries[id] = GetCDBEntry(cdbPath);
234 fCDBCache[id] = fCDBEntries[id]->GetObject();
236 return fCDBCache[id];
239 //_____________________________________________________________________________
240 void AliTRDcalibDB::SetRun(Long64_t run)
243 // Sets current run number. Calibration data is read from the corresponding file.
244 // When the run number changes the caching is invalidated.
254 //_____________________________________________________________________________
255 void AliTRDcalibDB::Invalidate()
258 // Invalidates cache (when run number is changed).
261 for (Int_t i=0; i<kCDBCacheSize; ++i)
265 if (fCDBEntries[i]->IsOwner() == kFALSE && fCDBCache[i])
268 delete fCDBEntries[i];
275 //_____________________________________________________________________________
276 Bool_t AliTRDcalibDB::GetChamberPos(Int_t det, Float_t* xyz)
279 // Returns the deviation of the chamber position from the nominal position.
282 const AliTRDCalChamberPos* chamber = dynamic_cast<const AliTRDCalChamberPos*>(GetCachedCDBObject(kIDChamberPos));
286 const Float_t* kvalues = chamber->GetPos(det);
297 //_____________________________________________________________________________
298 Bool_t AliTRDcalibDB::GetChamberRot(Int_t det, Float_t* xyz)
301 // Returns the rotation of the chamber from the nominal position.
304 const AliTRDCalChamberPos* chamber = dynamic_cast<const AliTRDCalChamberPos*>(GetCachedCDBObject(kIDChamberPos));
308 const Float_t* kvalues = chamber->GetRot(det);
319 //_____________________________________________________________________________
320 Bool_t AliTRDcalibDB::GetStackPos(Int_t chamber, Int_t sector, Float_t* xyz)
323 // Returns the deviation of the stack position from the nominal position.
326 const AliTRDCalStackPos* stack = dynamic_cast<const AliTRDCalStackPos*>(GetCachedCDBObject(kIDStackPos));
330 const Float_t* kvalues = stack->GetPos(chamber, sector);
341 //_____________________________________________________________________________
342 Bool_t AliTRDcalibDB::GetStackRot(Int_t chamber, Int_t sector, Float_t* xyz)
345 // Returns the rotation of the stack from the nominal position.
348 const AliTRDCalStackPos* stack = dynamic_cast<const AliTRDCalStackPos*>(GetCachedCDBObject(kIDStackPos));
352 const Float_t* kvalues = stack->GetRot(chamber, sector);
363 //_____________________________________________________________________________
364 Bool_t AliTRDcalibDB::GetSuperModulePos(Int_t sm, Float_t* xyz)
367 // Returns the deviation of the supermodule position from the nominal position.
370 const AliTRDCalSuperModulePos* smPos = dynamic_cast<const AliTRDCalSuperModulePos*>(GetCachedCDBObject(kIDSuperModulePos));
374 const Float_t* kvalues = smPos->GetPos(sm);
385 //_____________________________________________________________________________
386 Bool_t AliTRDcalibDB::GetSuperModuleRot(Int_t sm, Float_t* xyz)
389 // Returns the rotation of the supermodule from the nominal position.
392 const AliTRDCalSuperModulePos* smPos = dynamic_cast<const AliTRDCalSuperModulePos*>(GetCachedCDBObject(kIDSuperModulePos));
396 const Float_t* kvalues = smPos->GetRot(sm);
407 //_____________________________________________________________________________
408 Float_t AliTRDcalibDB::GetVdrift(Int_t det, Int_t col, Int_t row)
411 // Returns the drift velocity for the given pad.
414 const AliTRDCalPad* calPad = dynamic_cast<const AliTRDCalPad*> (GetCachedCDBObject(kIDVdriftPad));
418 AliTRDCalROC* roc = calPad->GetCalROC(det);
422 const AliTRDCalDet* calChamber = dynamic_cast<const AliTRDCalDet*> (GetCachedCDBObject(kIDVdriftChamber));
426 return calChamber->GetValue(det) * roc->GetValue(col, row);
429 //_____________________________________________________________________________
430 Float_t AliTRDcalibDB::GetVdriftAverage(Int_t det)
433 // Returns the average drift velocity for the given detector
436 const AliTRDCalDet* calDet = dynamic_cast<const AliTRDCalDet*> (GetCachedCDBObject(kIDVdriftChamber));
440 return calDet->GetValue(det);
443 //_____________________________________________________________________________
444 Float_t AliTRDcalibDB::GetT0(Int_t det, Int_t col, Int_t row)
447 // Returns t0 for the given pad.
450 const AliTRDCalPad* calPad = dynamic_cast<const AliTRDCalPad*> (GetCachedCDBObject(kIDT0Pad));
454 AliTRDCalROC* roc = calPad->GetCalROC(det);
458 const AliTRDCalDet* calChamber = dynamic_cast<const AliTRDCalDet*> (GetCachedCDBObject(kIDT0Chamber));
462 return calChamber->GetValue(det) * roc->GetValue(col, row);
465 //_____________________________________________________________________________
466 Float_t AliTRDcalibDB::GetT0Average(Int_t det)
469 // Returns the average t0 for the given detector
472 const AliTRDCalDet* calDet = dynamic_cast<const AliTRDCalDet*> (GetCachedCDBObject(kIDT0Chamber));
476 return calDet->GetValue(det);
479 //_____________________________________________________________________________
480 Float_t AliTRDcalibDB::GetGainFactor(Int_t det, Int_t col, Int_t row)
483 // Returns the gain factor for the given pad.
486 const AliTRDCalPad* calPad = dynamic_cast<const AliTRDCalPad*> (GetCachedCDBObject(kIDGainFactorPad));
490 AliTRDCalROC* roc = calPad->GetCalROC(det);
494 const AliTRDCalDet* calChamber = dynamic_cast<const AliTRDCalDet*> (GetCachedCDBObject(kIDGainFactorChamber));
498 return calChamber->GetValue(det) * roc->GetValue(col, row);
501 //_____________________________________________________________________________
502 Float_t AliTRDcalibDB::GetGainFactorAverage(Int_t det)
505 // Returns the average gain factor for the given detector
508 const AliTRDCalDet* calDet = dynamic_cast<const AliTRDCalDet*> (GetCachedCDBObject(kIDGainFactorChamber));
512 return calDet->GetValue(det);
515 //_____________________________________________________________________________
516 Float_t AliTRDcalibDB::GetPRFWidth(Int_t det, Int_t col, Int_t row)
519 // Returns the PRF width for the given pad.
522 const AliTRDCalPad* calPad = dynamic_cast<const AliTRDCalPad*> (GetCachedCDBObject(kIDPRFWidth));
526 AliTRDCalROC* roc = calPad->GetCalROC(det);
530 return roc->GetValue(col, row);
533 //_____________________________________________________________________________
534 Float_t AliTRDcalibDB::GetSamplingFrequency()
537 // Returns the sampling frequency of the TRD read-out.
540 const AliTRDCalGlobals* calGlobal = dynamic_cast<const AliTRDCalGlobals*> (GetCachedCDBObject(kIDGlobals));
544 return calGlobal->GetSamplingFrequency();
547 //_____________________________________________________________________________
548 Int_t AliTRDcalibDB::GetNumberOfTimeBins()
551 // Returns the number of time bins which are read-out.
554 const AliTRDCalGlobals* calGlobal = dynamic_cast<const AliTRDCalGlobals*> (GetCachedCDBObject(kIDGlobals));
558 return calGlobal->GetNumberOfTimeBins();
561 //_____________________________________________________________________________
562 Char_t AliTRDcalibDB::GetPadStatus(Int_t det, Int_t col, Int_t row)
565 // Returns the status of the given pad
568 const AliTRDCalPadStatus* cal = dynamic_cast<const AliTRDCalPadStatus*> (GetCachedCDBObject(kIDPadStatus));
572 const AliTRDCalSingleChamberStatus* roc = cal->GetCalROC(det);
576 return roc->GetStatus(col, row);
579 //_____________________________________________________________________________
580 Char_t AliTRDcalibDB::GetMCMStatus(Int_t det, Int_t col, Int_t row)
583 // Returns the status of the given MCM
586 const AliTRDCalMCMStatus* cal = dynamic_cast<const AliTRDCalMCMStatus*> (GetCachedCDBObject(kIDMCMStatus));
590 const AliTRDCalSingleChamberStatus* roc = cal->GetCalROC(det);
594 return roc->GetStatus(col, row);
597 //_____________________________________________________________________________
598 Char_t AliTRDcalibDB::GetChamberStatus(Int_t det)
601 // Returns the status of the given chamber
604 const AliTRDCalChamberStatus* cal = dynamic_cast<const AliTRDCalChamberStatus*> (GetCachedCDBObject(kIDChamberStatus));
608 return cal->GetStatus(det);
611 //_____________________________________________________________________________
612 Char_t AliTRDcalibDB::GetSuperModuleStatus(Int_t sm)
615 // Returns the status of the given chamber
618 const AliTRDCalSuperModuleStatus* cal = dynamic_cast<const AliTRDCalSuperModuleStatus*> (GetCachedCDBObject(kIDSuperModuleStatus));
622 return cal->GetStatus(sm);
625 //_____________________________________________________________________________
626 Bool_t AliTRDcalibDB::IsPadMasked(Int_t det, Int_t col, Int_t row)
629 // Returns status, see name of functions for details ;-)
632 const AliTRDCalPadStatus* cal = dynamic_cast<const AliTRDCalPadStatus*> (GetCachedCDBObject(kIDPadStatus));
636 return cal->IsMasked(det, col, row);
639 //_____________________________________________________________________________
640 Bool_t AliTRDcalibDB::IsPadBridgedLeft(Int_t det, Int_t col, Int_t row)
643 // Returns status, see name of functions for details ;-)
646 const AliTRDCalPadStatus* cal = dynamic_cast<const AliTRDCalPadStatus*> (GetCachedCDBObject(kIDPadStatus));
650 return cal->IsBridgedLeft(det, col, row);
653 //_____________________________________________________________________________
654 Bool_t AliTRDcalibDB::IsPadBridgedRight(Int_t det, Int_t col, Int_t row)
657 // Returns status, see name of functions for details ;-)
660 const AliTRDCalPadStatus* cal = dynamic_cast<const AliTRDCalPadStatus*> (GetCachedCDBObject(kIDPadStatus));
664 return cal->IsBridgedRight(det, col, row);
667 //_____________________________________________________________________________
668 Bool_t AliTRDcalibDB::IsMCMMasked(Int_t det, Int_t col, Int_t row)
671 // Returns status, see name of functions for details ;-)
674 const AliTRDCalMCMStatus* cal = dynamic_cast<const AliTRDCalMCMStatus*> (GetCachedCDBObject(kIDMCMStatus));
678 return cal->IsMasked(det, col, row);
681 //_____________________________________________________________________________
682 Bool_t AliTRDcalibDB::IsChamberInstalled(Int_t det)
685 // Returns status, see name of functions for details ;-)
688 const AliTRDCalChamberStatus* cal = dynamic_cast<const AliTRDCalChamberStatus*> (GetCachedCDBObject(kIDChamberStatus));
692 return cal->IsInstalled(det);
695 //_____________________________________________________________________________
696 Bool_t AliTRDcalibDB::IsChamberMasked(Int_t det)
699 // Returns status, see name of functions for details ;-)
702 const AliTRDCalChamberStatus* cal = dynamic_cast<const AliTRDCalChamberStatus*> (GetCachedCDBObject(kIDChamberStatus));
706 return cal->IsMasked(det);
709 //_____________________________________________________________________________
710 Bool_t AliTRDcalibDB::IsSuperModuleInstalled(Int_t det)
713 // Returns status, see name of functions for details ;-)
716 const AliTRDCalSuperModuleStatus* cal = dynamic_cast<const AliTRDCalSuperModuleStatus*> (GetCachedCDBObject(kIDSuperModuleStatus));
720 return cal->IsInstalled(det);
723 //_____________________________________________________________________________
724 Bool_t AliTRDcalibDB::IsSuperModuleMasked(Int_t det)
727 // Returns status, see name of functions for details ;-)
730 const AliTRDCalSuperModuleStatus* cal = dynamic_cast<const AliTRDCalSuperModuleStatus*> (GetCachedCDBObject(kIDSuperModuleStatus));
734 return cal->IsMasked(det);
737 //_____________________________________________________________________________
738 const AliTRDCalPIDLQ* AliTRDcalibDB::GetPIDLQObject()
741 // Returns the object storing the distributions for PID with likelihood
744 return dynamic_cast<const AliTRDCalPIDLQ*> (GetCachedCDBObject(kIDPIDLQ));
747 //_____________________________________________________________________________
748 const AliTRDCalMonitoring* AliTRDcalibDB::GetMonitoringObject()
751 // Returns the object storing the monitoring data
754 return dynamic_cast<const AliTRDCalMonitoring*> (GetCachedCDBObject(kIDMonitoringData));
757 //_____________________________________________________________________________
758 Float_t AliTRDcalibDB::GetOmegaTau(Float_t vdrift)
761 // Returns omega*tau (tan(Lorentz-angle)) for a given drift velocity <vd>
762 // and a B-field <b> for Xe/CO2 (15%).
763 // The values are according to a GARFIELD simulation.
765 // This function basically does not belong to the calibration class. It should be moved somewhere else.
766 // However, currently it is in use by simulation and reconstruction.
769 AliTRDCommonParam* commonParam = AliTRDCommonParam::Instance();
772 Float_t field = commonParam->GetField();
775 Float_t p0[kNb] = { 0.004810, 0.007412, 0.010252, 0.013409, 0.016888 };
776 Float_t p1[kNb] = { 0.054875, 0.081534, 0.107333, 0.131983, 0.155455 };
777 Float_t p2[kNb] = { -0.008682, -0.012896, -0.016987, -0.020880, -0.024623 };
778 Float_t p3[kNb] = { 0.000155, 0.000238, 0.000330, 0.000428, 0.000541 };
780 Int_t ib = ((Int_t) (10 * (field - 0.15)));
781 ib = TMath::Max( 0,ib);
782 ib = TMath::Min(kNb,ib);
784 Float_t alphaL = p0[ib]
786 + p2[ib] * vdrift*vdrift
787 + p3[ib] * vdrift*vdrift*vdrift;
789 return TMath::Tan(alphaL);
792 //_____________________________________________________________________________
793 void AliTRDcalibDB::SamplePRF()
796 // Samples the pad response function
799 const Int_t kPRFbin = 61;
801 Float_t prf[kNplan][kPRFbin] = { {2.9037e-02, 3.3608e-02, 3.9020e-02, 4.5292e-02,
802 5.2694e-02, 6.1362e-02, 7.1461e-02, 8.3362e-02,
803 9.7063e-02, 1.1307e-01, 1.3140e-01, 1.5235e-01,
804 1.7623e-01, 2.0290e-01, 2.3294e-01, 2.6586e-01,
805 3.0177e-01, 3.4028e-01, 3.8077e-01, 4.2267e-01,
806 4.6493e-01, 5.0657e-01, 5.4655e-01, 5.8397e-01,
807 6.1767e-01, 6.4744e-01, 6.7212e-01, 6.9188e-01,
808 7.0627e-01, 7.1499e-01, 7.1851e-01, 7.1499e-01,
809 7.0627e-01, 6.9188e-01, 6.7212e-01, 6.4744e-01,
810 6.1767e-01, 5.8397e-01, 5.4655e-01, 5.0657e-01,
811 4.6493e-01, 4.2267e-01, 3.8077e-01, 3.4028e-01,
812 3.0177e-01, 2.6586e-01, 2.3294e-01, 2.0290e-01,
813 1.7623e-01, 1.5235e-01, 1.3140e-01, 1.1307e-01,
814 9.7063e-02, 8.3362e-02, 7.1461e-02, 6.1362e-02,
815 5.2694e-02, 4.5292e-02, 3.9020e-02, 3.3608e-02,
817 {2.5478e-02, 2.9695e-02, 3.4655e-02, 4.0454e-02,
818 4.7342e-02, 5.5487e-02, 6.5038e-02, 7.6378e-02,
819 8.9696e-02, 1.0516e-01, 1.2327e-01, 1.4415e-01,
820 1.6794e-01, 1.9516e-01, 2.2573e-01, 2.5959e-01,
821 2.9694e-01, 3.3719e-01, 3.7978e-01, 4.2407e-01,
822 4.6889e-01, 5.1322e-01, 5.5569e-01, 5.9535e-01,
823 6.3141e-01, 6.6259e-01, 6.8882e-01, 7.0983e-01,
824 7.2471e-01, 7.3398e-01, 7.3761e-01, 7.3398e-01,
825 7.2471e-01, 7.0983e-01, 6.8882e-01, 6.6259e-01,
826 6.3141e-01, 5.9535e-01, 5.5569e-01, 5.1322e-01,
827 4.6889e-01, 4.2407e-01, 3.7978e-01, 3.3719e-01,
828 2.9694e-01, 2.5959e-01, 2.2573e-01, 1.9516e-01,
829 1.6794e-01, 1.4415e-01, 1.2327e-01, 1.0516e-01,
830 8.9696e-02, 7.6378e-02, 6.5038e-02, 5.5487e-02,
831 4.7342e-02, 4.0454e-02, 3.4655e-02, 2.9695e-02,
833 {2.2363e-02, 2.6233e-02, 3.0782e-02, 3.6140e-02,
834 4.2535e-02, 5.0157e-02, 5.9197e-02, 6.9900e-02,
835 8.2707e-02, 9.7811e-02, 1.1548e-01, 1.3601e-01,
836 1.5998e-01, 1.8739e-01, 2.1840e-01, 2.5318e-01,
837 2.9182e-01, 3.3373e-01, 3.7837e-01, 4.2498e-01,
838 4.7235e-01, 5.1918e-01, 5.6426e-01, 6.0621e-01,
839 6.4399e-01, 6.7700e-01, 7.0472e-01, 7.2637e-01,
840 7.4206e-01, 7.5179e-01, 7.5551e-01, 7.5179e-01,
841 7.4206e-01, 7.2637e-01, 7.0472e-01, 6.7700e-01,
842 6.4399e-01, 6.0621e-01, 5.6426e-01, 5.1918e-01,
843 4.7235e-01, 4.2498e-01, 3.7837e-01, 3.3373e-01,
844 2.9182e-01, 2.5318e-01, 2.1840e-01, 1.8739e-01,
845 1.5998e-01, 1.3601e-01, 1.1548e-01, 9.7811e-02,
846 8.2707e-02, 6.9900e-02, 5.9197e-02, 5.0157e-02,
847 4.2535e-02, 3.6140e-02, 3.0782e-02, 2.6233e-02,
849 {1.9635e-02, 2.3167e-02, 2.7343e-02, 3.2293e-02,
850 3.8224e-02, 4.5335e-02, 5.3849e-02, 6.4039e-02,
851 7.6210e-02, 9.0739e-02, 1.0805e-01, 1.2841e-01,
852 1.5216e-01, 1.7960e-01, 2.1099e-01, 2.4671e-01,
853 2.8647e-01, 3.2996e-01, 3.7660e-01, 4.2547e-01,
854 4.7536e-01, 5.2473e-01, 5.7215e-01, 6.1632e-01,
855 6.5616e-01, 6.9075e-01, 7.1939e-01, 7.4199e-01,
856 7.5838e-01, 7.6848e-01, 7.7227e-01, 7.6848e-01,
857 7.5838e-01, 7.4199e-01, 7.1939e-01, 6.9075e-01,
858 6.5616e-01, 6.1632e-01, 5.7215e-01, 5.2473e-01,
859 4.7536e-01, 4.2547e-01, 3.7660e-01, 3.2996e-01,
860 2.8647e-01, 2.4671e-01, 2.1099e-01, 1.7960e-01,
861 1.5216e-01, 1.2841e-01, 1.0805e-01, 9.0739e-02,
862 7.6210e-02, 6.4039e-02, 5.3849e-02, 4.5335e-02,
863 3.8224e-02, 3.2293e-02, 2.7343e-02, 2.3167e-02,
865 {1.7224e-02, 2.0450e-02, 2.4286e-02, 2.8860e-02,
866 3.4357e-02, 4.0979e-02, 4.8966e-02, 5.8612e-02,
867 7.0253e-02, 8.4257e-02, 1.0102e-01, 1.2094e-01,
868 1.4442e-01, 1.7196e-01, 2.0381e-01, 2.4013e-01,
869 2.8093e-01, 3.2594e-01, 3.7450e-01, 4.2563e-01,
870 4.7796e-01, 5.2991e-01, 5.7974e-01, 6.2599e-01,
871 6.6750e-01, 7.0344e-01, 7.3329e-01, 7.5676e-01,
872 7.7371e-01, 7.8410e-01, 7.8793e-01, 7.8410e-01,
873 7.7371e-01, 7.5676e-01, 7.3329e-01, 7.0344e-01,
874 6.6750e-01, 6.2599e-01, 5.7974e-01, 5.2991e-01,
875 4.7796e-01, 4.2563e-01, 3.7450e-01, 3.2594e-01,
876 2.8093e-01, 2.4013e-01, 2.0381e-01, 1.7196e-01,
877 1.4442e-01, 1.2094e-01, 1.0102e-01, 8.4257e-02,
878 7.0253e-02, 5.8612e-02, 4.8966e-02, 4.0979e-02,
879 3.4357e-02, 2.8860e-02, 2.4286e-02, 2.0450e-02,
881 {1.5096e-02, 1.8041e-02, 2.1566e-02, 2.5793e-02,
882 3.0886e-02, 3.7044e-02, 4.4515e-02, 5.3604e-02,
883 6.4668e-02, 7.8109e-02, 9.4364e-02, 1.1389e-01,
884 1.3716e-01, 1.6461e-01, 1.9663e-01, 2.3350e-01,
885 2.7527e-01, 3.2170e-01, 3.7214e-01, 4.2549e-01,
886 4.8024e-01, 5.3460e-01, 5.8677e-01, 6.3512e-01,
887 6.7838e-01, 7.1569e-01, 7.4655e-01, 7.7071e-01,
888 7.8810e-01, 7.9871e-01, 8.0255e-01, 7.9871e-01,
889 7.8810e-01, 7.7071e-01, 7.4655e-01, 7.1569e-01,
890 6.7838e-01, 6.3512e-01, 5.8677e-01, 5.3460e-01,
891 4.8024e-01, 4.2549e-01, 3.7214e-01, 3.2170e-01,
892 2.7527e-01, 2.3350e-01, 1.9663e-01, 1.6461e-01,
893 1.3716e-01, 1.1389e-01, 9.4364e-02, 7.8109e-02,
894 6.4668e-02, 5.3604e-02, 4.4515e-02, 3.7044e-02,
895 3.0886e-02, 2.5793e-02, 2.1566e-02, 1.8041e-02,
898 // More sampling precision with linear interpolation
899 fPadResponse.fPRFlo = -1.5;
900 fPadResponse.fPRFhi = 1.5;
901 Float_t pad[kPRFbin];
902 Int_t sPRFbin = kPRFbin;
903 Float_t sPRFwid = (fPadResponse.fPRFhi - fPadResponse.fPRFlo) / ((Float_t) sPRFbin);
904 for (Int_t iPad = 0; iPad < sPRFbin; iPad++) {
905 pad[iPad] = ((Float_t) iPad + 0.5) * sPRFwid + fPadResponse.fPRFlo;
907 fPadResponse.fPRFbin = 500;
908 fPadResponse.fPRFwid = (fPadResponse.fPRFhi - fPadResponse.fPRFlo) / ((Float_t) fPadResponse.fPRFbin);
909 fPadResponse.fPRFpad = ((Int_t) (1.0 / fPadResponse.fPRFwid));
911 if (fPadResponse.fPRFsmp) delete [] fPadResponse.fPRFsmp;
912 fPadResponse.fPRFsmp = new Float_t[kNplan*fPadResponse.fPRFbin];
918 for (Int_t iPla = 0; iPla < kNplan; iPla++) {
920 for (Int_t iBin = 0; iBin < fPadResponse.fPRFbin; iBin++) {
922 Float_t bin = (((Float_t) iBin) + 0.5) * fPadResponse.fPRFwid + fPadResponse.fPRFlo;
926 diff = bin - pad[ipos2++];
927 } while ((diff > 0) && (ipos2 < kPRFbin));
928 if (ipos2 == kPRFbin) {
929 fPadResponse.fPRFsmp[iPla*fPadResponse.fPRFbin+iBin] = prf[iPla][ipos2-1];
931 else if (ipos2 == 1) {
932 fPadResponse.fPRFsmp[iPla*fPadResponse.fPRFbin+iBin] = prf[iPla][ipos2-1];
936 if (ipos2 >= kPRFbin) ipos2 = kPRFbin - 1;
938 fPadResponse.fPRFsmp[iPla*fPadResponse.fPRFbin+iBin] = prf[iPla][ipos2]
939 + diff * (prf[iPla][ipos2] - prf[iPla][ipos1])
948 //_____________________________________________________________________________
949 Int_t AliTRDcalibDB::PadResponse(Double_t signal, Double_t dist
950 , Int_t plane, Double_t *pad) const
953 // Applies the pad response
956 Int_t iBin = ((Int_t) (( - dist - fPadResponse.fPRFlo) / fPadResponse.fPRFwid));
957 Int_t iOff = plane * fPadResponse.fPRFbin;
959 Int_t iBin0 = iBin - fPadResponse.fPRFpad + iOff;
960 Int_t iBin1 = iBin + iOff;
961 Int_t iBin2 = iBin + fPadResponse.fPRFpad + iOff;
966 if ((iBin1 >= 0) && (iBin1 < (fPadResponse.fPRFbin*kNplan))) {
969 pad[0] = signal * fPadResponse.fPRFsmp[iBin0];
971 pad[1] = signal * fPadResponse.fPRFsmp[iBin1];
972 if (iBin2 < (fPadResponse.fPRFbin*kNplan)) {
973 pad[2] = signal * fPadResponse.fPRFsmp[iBin2];