#include <Calibrator.h>
Public Member Functions | |
| Calibrator () | |
| TTimeStamp | GetTimeStamp () const |
| rawdata::det_id_ | GetDetector () const |
| void | MakeCellHit (const RawDigit *rawdigit, CellHit *cellhit) |
| float | GetPE (const RawDigit *rawdigit) |
| float | GetPECorrFactor (const RawDigit *rawdigit) |
| float | GetTNS (const RawDigit *rawdigit) |
| void | MakeRecoHit (const CellHit *cellhit, RecoHit *recohit, float w) |
| float | GetT (const CellHit *cellhit, float dist_to_readout) |
| float | GetPEAtt (const CellHit *cellhit, float dist_to_readout) |
| float | GetMIPScale (const CellHit *cellhit) |
| float | GetGeVScale (const CellHit *cellhit) |
Static Public Member Functions | |
| Calibrator & | Instance (TTimeStamp timestamp, rawdata::det_id_ detector, const geo::Geometry &geometry) |
Public Attributes | |
| float | fPEACperMIP |
| float | fPEACperMIPErr |
| std::vector< float > | fMIPtoGeV |
| std::vector< float > | fMIPtoGeVErr |
| std::map< int, float > | fADCtoPE |
| std::map< int, float > | fPEtoSigCor |
| std::map< int, attlen > | fSCtoPEAC |
| std::vector< float > | fFTDistNDX |
| std::vector< float > | fFTDistNDY |
| std::vector< float > | fFTDistFDX |
| std::vector< float > | fFTDistFDY |
Private Member Functions | |
| void | SetContext (TTimeStamp timestamp, rawdata::det_id_ detector, const geo::Geometry &geometry) |
| void | GetXYZD (const CellHit *cellhit, float w, double *xyzd) |
| bool | LoadADCtoPE () |
| bool | LoadPEtoSigCor () |
| bool | LoadSCtoPEAC () |
| bool | LoadPEACtoMIP () |
| bool | LoadMIPtoGeV () |
| bool | LoadFineTimeDistros () |
Private Attributes | |
| TTimeStamp | fCurrTimeStamp |
| rawdata::det_id_ | fCurrDetector |
| const geo::Geometry * | fCurrGeo |
| bool | fLoadedFineTimeDistros |
Static Private Attributes | |
| Calibrator * | fInstance = 0 |
|
|
Definition at line 26 of file Calibrator.cxx. References fADCtoPE, fFTDistFDX, fFTDistFDY, fFTDistNDX, fFTDistNDY, fMIPtoGeV, fMIPtoGeVErr, and rawdata::kNear. 00026 : 00027 fCurrTimeStamp(0), 00028 fCurrDetector(rawdata::kNear), 00029 fCurrGeo(0), 00030 fPEACperMIP(0), fPEACperMIPErr(0), 00031 fLoadedFineTimeDistros(0) 00032 { 00033 fADCtoPE.clear(); 00034 fMIPtoGeV.clear(); 00035 fMIPtoGeVErr.clear(); 00036 fFTDistNDX.clear(); 00037 fFTDistNDY.clear(); 00038 fFTDistFDX.clear(); 00039 fFTDistFDY.clear(); 00040 }
|
|
|
Definition at line 50 of file Calibrator.h. 00050 { return fCurrDetector; }
|
|
|
Definition at line 526 of file Calibrator.cxx. Referenced by MakeRecoHit(). 00526 {
00527 // This needs to be calibrated and put in the DB, obviously!
00528 // Super-rough number based on 1 MIP = ~2 MeV/cm.
00529 return 0.013;
00530 }
|
|
|
Definition at line 520 of file Calibrator.cxx. Referenced by MakeRecoHit(). 00520 {
00521 // This needs to be calibrated and put in the DB, obviously!
00522 return 0.033;
00523 }
|
|
|
Definition at line 355 of file Calibrator.cxx. References rawdata::RawDigit::ADC(). Referenced by MakeCellHit(). 00355 {
00356 // Look up gain from DB. For now, must hard code the
00357 // number. (This should not be put in any XML file.
00358 // That'll just confuse the issue.)
00359 float gain = 1.43;
00360 return rawdigit->ADC(0)/gain;
00361 }
|
|
||||||||||||
|
Definition at line 504 of file Calibrator.cxx. References recobase::CellHit::PECorr(). Referenced by MakeRecoHit(). 00504 {
00505
00506 // These constants belong in the DB. Don't put them in an XML file
00507 // in the meantime, as this will just confuse the issue...
00508 Double_t F0 = 5.744; // P. Shanahan tuning from old CalHit.xml
00509 Double_t L0 = 315.3; // .
00510 Double_t F1 = 1.546; // .
00511 Double_t L1 = 3329.; // .
00512
00513 Double_t attenuation = F0*TMath::Exp(-dist_to_readout/L0) +
00514 F1*TMath::Exp(-dist_to_readout/L1);
00515
00516 return cellhit->PECorr() / attenuation;
00517 }
|
|
|
Definition at line 364 of file Calibrator.cxx. Referenced by MakeCellHit(). 00364 {
00365 // Look up channel-to-channel correction factors in DB.
00366 // For now, must hard code the factor.
00367 return 1.0;
00368 }
|
|
||||||||||||
|
Definition at line 494 of file Calibrator.cxx. References recobase::CellHit::TNS(). Referenced by MakeRecoHit(). 00494 {
00495 // This needs to be calibrated and put in a DB table
00496 Double_t speedOfFiberTransport = 15.3; // cm/ns, "first principles" calib.
00497 // Differs from c/n due to zigzag
00498 // paths down fiber. But, this
00499 // value may be way off (10%? 30%?).
00500 return (cellhit->TNS()-dist_to_readout/speedOfFiberTransport);
00501 }
|
|
|
Definition at line 49 of file Calibrator.h. 00049 { return fCurrTimeStamp; }
|
|
|
Definition at line 371 of file Calibrator.cxx. References rawdata::RawDigit::ADC(), fCurrDetector, rawdata::RawDigit::NADC(), and rawdata::RawDigit::TDC(). Referenced by MakeCellHit(). 00371 {
00372 // You'd think this would be a simple function... Not anymore!
00373 // The new readout scheme allows for super time resolution, and
00374 // this is the code that gets it.
00375
00376 Double_t t = 0;
00377
00378 // First, see if we're using the new-style readout. This
00379 // condition should be unnecessary in the future.
00380
00381 if (rawdigit->NADC()<=1) {
00382
00383 // Old style readout. Return old style answer:
00384 t = rawdigit->TDC(0)*62.5;
00385
00386 }
00387 else {
00388
00389 // New style readout. Use ADC info to determine fine timing.
00390 // See doc-???? for details.
00391
00392 // ADC readings before and after peak, scaled to peak,
00393 // yield "x" and "y":
00394 Double_t peakadc = rawdigit->ADC(0);
00395 Double_t x = (rawdigit->ADC(1))/peakadc;
00396 Double_t y = (rawdigit->ADC(2))/peakadc;
00397
00398 // These constants belong in the the DB. For now, hard code them.
00399 // Tuned up by RBP, 2009-10-07
00400 Double_t Xa = 0.0;
00401 Double_t Ya = 1.0;
00402 Double_t Xb = 0.0;
00403 Double_t Yb = (fCurrDetector==rawdata::kNear?0.90:0.885);
00404 Double_t Xc = 1.0;
00405 Double_t Yc = 0.800;
00406
00407 // These could be evaluated offline and stuck in the DB.
00408 // For now, I'll evaluate them explicitly here so the math
00409 // isn't lost:
00410 Double_t L1 = sqrt((Yb-Ya)*(Yb-Ya)+(Xb-Xa)*(Xb-Xa));
00411 Double_t L2 = sqrt((Yc-Yb)*(Yc-Yb)+(Xc-Xb)*(Xc-Xb));
00412
00413 // distance to first line segment:
00414 Double_t U1 = ((x-Xa)*(Xb-Xa)+(y-Ya)*(Yb-Ya))/L1/L1;
00415 if (U1<0) U1=0;
00416 if (U1>0.99999) U1=0.99999;
00417 Double_t PX1 = Xa + U1*(Xb-Xa);
00418 Double_t PY1 = Ya + U1*(Yb-Ya);
00419 Double_t D1 = sqrt((PX1-x)*(PX1-x)+(PY1-y)*(PY1-y));
00420
00421 // distance to second line segment:
00422 Double_t U2 = ((x-Xb)*(Xc-Xb)+(y-Yb)*(Yc-Yb))/L2/L2;
00423 if (U2<0) U2=0;
00424 if (U2>0.99999) U2=0.99999;
00425 Double_t PX2 = Xb + U2*(Xc-Xb);
00426 Double_t PY2 = Yb + U2*(Yc-Yb);
00427 Double_t D2 = sqrt((PX2-x)*(PX2-x)+(PY2-y)*(PY2-y));
00428
00429 // get the better of the two
00430 Double_t U;
00431 if (D1<D2) U = U1*L1/(L1+L2);
00432 else U = (L1+U2*L2)/(L1+L2);
00433
00434 // map best U value to a fine time:
00435 vector<float>& ftx = fFTDistNDX;
00436 vector<float>& fty = fFTDistNDY;
00437 if (fCurrDetector == rawdata::kFar) {
00438 ftx = fFTDistFDX;
00439 fty = fFTDistFDY;
00440 }
00441
00442 unsigned int bin=1;
00443 if (U < ftx[0])
00444 bin = 0;
00445 else
00446 for (; bin<ftx.size()-1; ++bin) {
00447 if (U >= ftx[bin-1] && U < ftx[bin]) break;
00448 }
00449 if (bin == ftx.size()) {
00450 // should never get in here
00451 std::cout << "In GetTNS(): bin=" << bin << " u=" << U << std::endl;
00452 bin=ftx.size()-1;
00453 }
00454 Double_t timefrac = 0.5*( fty[bin] + fty[bin-1]);
00455
00456 // Gap between digitizations
00457 Double_t gap = (fCurrDetector==rawdata::kNear?125.0:500.0);
00458
00459 t = rawdigit->TDC(0)*62.5 - timefrac*gap;
00460 }
00461
00462 return t;
00463 }
|
|
||||||||||||||||
|
Definition at line 533 of file Calibrator.cxx. References geo::PlaneGeo::Cell(), recobase::CellHit::Cell(), geo::CellGeo::DistToReadOut(), fCurrGeo, geo::CellGeo::GetCenter(), geo::PlaneGeo::Ncells(), geo::Geometry::NPlanes(), geo::Geometry::Plane(), recobase::CellHit::Plane(), recobase::CellHit::View(), and geo::CellGeo::WorldToLocal(). Referenced by MakeRecoHit(). 00533 {
00534 // Return (via 'xyzd' argument) position of deposition in world
00535 // coordinates and the distance to the readout, assuming deposition
00536 // has cell-local-z position = w.
00537
00538 UInt_t plane = cellhit->Plane();
00539 UInt_t cell = cellhit->Cell();
00540 if (plane>=fCurrGeo->NPlanes()) {
00541 throw geo::Exception(__FILE__,__LINE__,geo::Exception::BAD_PLANE_NUMBER);
00542 }
00543 const geo::PlaneGeo& p = fCurrGeo->Plane(plane);
00544 if (cell>=p.Ncells()) {
00545 throw geo::Exception(__FILE__,__LINE__,geo::Exception::BAD_CELL_NUMBER);
00546 }
00547 const geo::CellGeo& c = p.Cell(cell);
00548
00549 // Should be replaced with alignment tables or whatnot. Okay for now.
00550
00551 // w is not localZ, which makes this a lot messier than just
00552 // c.GetCenter(xyzd,w) and c.DistToReadOut(w)
00553 c.GetCenter(xyzd);
00554 if (cellhit->View()==geo::kX)
00555 xyzd[1] = w;
00556 else
00557 xyzd[0] = w;
00558 Double_t localxyz[3];
00559 c.WorldToLocal(xyzd,localxyz);
00560 xyzd[3] = c.DistToReadOut(localxyz[2]);
00561 }
|
|
||||||||||||||||
|
Definition at line 63 of file Calibrator.cxx. References fInstance, and SetContext(). Referenced by util::EDMUtils::GetCalibrator(), and main(). 00065 {
00066 if (!fInstance)
00067 fInstance = new Calibrator;
00068 fInstance->SetContext(timestamp, detector, geometry);
00069 return *fInstance;
00070 }
|
|
|
Definition at line 76 of file Calibrator.cxx. References db::Table::Connect(), db::Table::Disconnect(), fADCtoPE, fCurrTimeStamp, and db::Table::Init(). 00077 {
00078 fADCtoPE.clear();
00079
00080 std::string dbFile = "ADCtoPE.xml";
00081
00082 db::Table* table = new db::Table(dbFile);
00083
00084 if (!table) return false;
00085
00086 if (table->Connect()) {
00087 table->Init(fCurrTimeStamp.GetSec());
00088
00089 if (table->empty()) return false;
00090
00091 table->Disconnect();
00092 }
00093
00094 // now fill STL map...
00095 std::string str1 = "Channel";
00096 std::string str2 = "PEperADC";
00097 int chan;
00098 float val;
00099 for (unsigned int i=0; i<table->size(); ++i) {
00100 (*table)[i].Get(str1,chan);
00101 (*table)[i].Get(str2,val);
00102 fADCtoPE[chan] = val;
00103 }
00104
00105 delete table;
00106
00107 return true;
00108 }
|
|
|
Definition at line 270 of file Calibrator.cxx. References db::Table::Connect(), db::Table::Disconnect(), fCurrTimeStamp, fFTDistFDX, fFTDistFDY, fFTDistNDX, fFTDistNDY, fLoadedFineTimeDistros, and db::Table::Init(). Referenced by SetContext(). 00271 {
00272 fFTDistNDX.clear();
00273 fFTDistNDY.clear();
00274 fFTDistFDX.clear();
00275 fFTDistFDY.clear();
00276
00277 // get values for ND first
00278 std::string dbFile = "FTDistroND.xml";
00279
00280 db::Table* table = new db::Table(dbFile);
00281
00282 if (!table) return false;
00283
00284 if (table->Connect()) {
00285 table->Init(fCurrTimeStamp.GetSec());
00286
00287 if (table->empty()) return false;
00288
00289 table->Disconnect();
00290 }
00291
00292 float x,y;
00293 std::string strx = "x";
00294 std::string stry = "y";
00295 for (unsigned int i=0; i<table->size(); ++i) {
00296 (*table)[i].Get(strx,x);
00297 (*table)[i].Get(stry,y);
00298 fFTDistNDX.push_back(x);
00299 fFTDistNDY.push_back(y);
00300 }
00301
00302 delete table;
00303
00304 // now get values for FD
00305 dbFile = "FTDistroFD.xml";
00306
00307 table = new db::Table(dbFile);
00308
00309 if (!table) return false;
00310
00311 if (table->Connect()) {
00312 table->Init(fCurrTimeStamp.GetSec());
00313
00314 if (table->empty()) return false;
00315
00316 table->Disconnect();
00317 }
00318
00319 for (unsigned int i=0; i<table->size(); ++i) {
00320 (*table)[i].Get(strx,x);
00321 (*table)[i].Get(stry,y);
00322 fFTDistFDX.push_back(x);
00323 fFTDistFDY.push_back(y);
00324 }
00325
00326 delete table;
00327
00328 fLoadedFineTimeDistros = 1;
00329
00330 return true;
00331 }
|
|
|
Definition at line 231 of file Calibrator.cxx. References db::Table::Connect(), db::Table::Disconnect(), fCurrTimeStamp, fMIPtoGeV, and db::Table::Init(). 00232 {
00233 fMIPtoGeV.clear();
00234
00235 std::string dbFile = "MIPtoGeV.xml";
00236
00237 db::Table* table = new db::Table(dbFile);
00238
00239 if (!table) return false;
00240
00241 if (table->Connect()) {
00242 table->Init(fCurrTimeStamp.GetSec());
00243
00244 if (table->empty()) return false;
00245
00246 table->Disconnect();
00247 }
00248
00249 float val;
00250 char buf[20];
00251 std::string str1;
00252 for (int i=0; i<5; ++i) {
00253 sprintf(buf,"par%d",i);
00254 str1 = buf;
00255 (*table)[0].Get(str1,val);
00256 fMIPtoGeV.push_back(val);
00257 }
00258
00259 delete table;
00260
00261 if (fMIPtoGeV.empty()) return false;
00262
00263 return true;
00264 }
|
|
|
Definition at line 201 of file Calibrator.cxx. References db::Table::Connect(), db::Table::Disconnect(), fCurrTimeStamp, fPEACperMIP, and db::Table::Init(). 00202 {
00203 fPEACperMIP = 1.;
00204
00205 std::string dbFile = "PEACtoMIP.xml";
00206
00207 db::Table* table = new db::Table(dbFile);
00208
00209 if (!table) return false;
00210
00211 if (table->Connect()) {
00212 table->Init(fCurrTimeStamp.GetSec());
00213
00214 if (table->empty()) return false;
00215
00216 table->Disconnect();
00217 }
00218
00219 std::string str1 = "PEACperMIP";
00220 (*table)[0].Get(str1,fPEACperMIP);
00221
00222 delete table;
00223
00224 return true;
00225 }
|
|
|
Definition at line 114 of file Calibrator.cxx. References db::Table::Connect(), db::Table::Disconnect(), fCurrTimeStamp, fPEtoSigCor, and db::Table::Init(). 00115 {
00116 fPEtoSigCor.clear();
00117
00118 std::string dbFile = "PEtoSigCor.xml";
00119
00120 db::Table* table = new db::Table(dbFile);
00121
00122 if (!table) return false;
00123
00124 if (table->Connect()) {
00125 table->Init(fCurrTimeStamp.GetSec());
00126
00127 if (table->empty()) return false;
00128
00129 table->Disconnect();
00130 }
00131
00132 // now fill STL map...
00133 std::string str1 = "Channel";
00134 std::string str2 = "SCperPE";
00135 int chan;
00136 float val;
00137 for (unsigned int i=0; i<table->size(); ++i) {
00138 (*table)[i].Get(str1,chan);
00139 (*table)[i].Get(str2,val);
00140 fPEtoSigCor[chan] = val;
00141 }
00142
00143 delete table;
00144
00145 return true;
00146 }
|
|
|
Definition at line 152 of file Calibrator.cxx. References calib::attlen::a1, calib::attlen::a1sig, calib::attlen::a2, calib::attlen::a2sig, db::Table::Connect(), db::Table::Disconnect(), fCurrTimeStamp, fSCtoPEAC, db::Table::Init(), calib::attlen::l1, calib::attlen::l1sig, calib::attlen::l2, and calib::attlen::l2sig. 00153 {
00154 fSCtoPEAC.clear();
00155
00156 std::string dbFile = "SigCortoPEAC.xml";
00157
00158 db::Table* table = new db::Table(dbFile);
00159
00160 if (!table) return false;
00161
00162 if (table->Connect()) {
00163 table->Init(fCurrTimeStamp.GetSec());
00164
00165 if (table->empty()) return false;
00166
00167 table->Disconnect();
00168 }
00169
00170 // now fill STL map...
00171 std::string str1 = "Channel";
00172 std::string str2 = "A1";
00173 std::string str3 = "A2";
00174 std::string str4 = "L1";
00175 std::string str5 = "L2";
00176 int chan;
00177 for (unsigned int i=0; i<table->size(); ++i) {
00178 attlen a;
00179 (*table)[i].Get(str1,chan);
00180 (*table)[i].Get(str2,a.a1);
00181 (*table)[i].Get(str2+"Err",a.a1sig);
00182 (*table)[i].Get(str3,a.a2);
00183 (*table)[i].Get(str3+"Err",a.a2sig);
00184 (*table)[i].Get(str4,a.l1);
00185 (*table)[i].Get(str4+"Err",a.l1sig);
00186 (*table)[i].Get(str5,a.l2);
00187 (*table)[i].Get(str5+"Err",a.l2sig);
00188
00189 fSCtoPEAC[chan] = a;
00190 }
00191
00192 delete table;
00193
00194 return true;
00195 }
|
|
||||||||||||
|
||||||||||||||||
|
Definition at line 470 of file Calibrator.cxx. References GetGeVScale(), GetMIPScale(), GetPEAtt(), GetT(), GetXYZD(), recobase::RecoHit::MIP(), recobase::RecoHit::PEAtt(), recobase::RecoHit::SetGeV(), recobase::RecoHit::SetMIP(), recobase::RecoHit::SetPEAtt(), recobase::RecoHit::SetT(), recobase::RecoHit::SetW(), recobase::RecoHit::SetX(), recobase::RecoHit::SetY(), and recobase::RecoHit::SetZ(). Referenced by calhit::CalHit::RoughReco(). 00470 {
00471
00472 // copy inherited data members
00473 (*((CellHit*)recohit)) = (*cellhit);
00474
00475 // new info:
00476 recohit->SetW(w);
00477
00478 // Need position info to continue...
00479 Double_t xyzd[4];
00480 GetXYZD(cellhit,w,xyzd);
00481
00482 recohit->SetX (xyzd[0]);
00483 recohit->SetY (xyzd[1]);
00484 recohit->SetZ (xyzd[2]);
00485
00486 recohit->SetT (GetT (cellhit,xyzd[3]));
00487 recohit->SetPEAtt(GetPEAtt(cellhit,xyzd[3]));
00488
00489 recohit->SetMIP (recohit->PEAtt() * GetMIPScale(cellhit));
00490 recohit->SetGeV (recohit->MIP() * GetGeVScale(cellhit));
00491 }
|
|
||||||||||||||||
|
Definition at line 45 of file Calibrator.cxx. References fCurrDetector, fCurrGeo, fCurrTimeStamp, and LoadFineTimeDistros(). Referenced by Instance(). 00047 {
00048 fCurrTimeStamp = timestamp;
00049 fCurrDetector = detector;
00050 fCurrGeo = &geometry;
00051 LoadFineTimeDistros();
00052 /*
00053 LoadADCtoPE();
00054 LoadPEtoSigCor();
00055 LoadSCtoPEAC();
00056 LoadPEACtoMIP();
00057 LoadMIPtoGeV();
00058 */
00059 }
|
|
|
Definition at line 95 of file Calibrator.h. Referenced by Calibrator(), and LoadADCtoPE(). |
|
|
Definition at line 60 of file Calibrator.h. Referenced by GetTNS(), MakeCellHit(), and SetContext(). |
|
|
Definition at line 61 of file Calibrator.h. Referenced by GetXYZD(), MakeCellHit(), and SetContext(). |
|
|
Definition at line 59 of file Calibrator.h. Referenced by LoadADCtoPE(), LoadFineTimeDistros(), LoadMIPtoGeV(), LoadPEACtoMIP(), LoadPEtoSigCor(), LoadSCtoPEAC(), MakeCellHit(), and SetContext(). |
|
|
Definition at line 100 of file Calibrator.h. Referenced by Calibrator(), and LoadFineTimeDistros(). |
|
|
Definition at line 101 of file Calibrator.h. Referenced by Calibrator(), and LoadFineTimeDistros(). |
|
|
Definition at line 98 of file Calibrator.h. Referenced by Calibrator(), LoadFineTimeDistros(), and main(). |
|
|
Definition at line 99 of file Calibrator.h. Referenced by Calibrator(), LoadFineTimeDistros(), and main(). |
|
|
Definition at line 22 of file Calibrator.cxx. Referenced by Instance(). |
|
|
Definition at line 104 of file Calibrator.h. Referenced by LoadFineTimeDistros(). |
|
|
Definition at line 93 of file Calibrator.h. Referenced by Calibrator(), and LoadMIPtoGeV(). |
|
|
Definition at line 94 of file Calibrator.h. Referenced by Calibrator(). |
|
|
Definition at line 91 of file Calibrator.h. Referenced by LoadPEACtoMIP(). |
|
|
Definition at line 92 of file Calibrator.h. |
|
|
Definition at line 96 of file Calibrator.h. Referenced by LoadPEtoSigCor(). |
|
|
Definition at line 97 of file Calibrator.h. Referenced by LoadSCtoPEAC(). |
1.3.9.1