121 #include "StEvent/StEvent.h"
122 #include "StEvent/StBTofCollection.h"
123 #include "StEvent/StBTofHit.h"
124 #include "StEvent/StBTofHeader.h"
125 #include "StEvent/StBTofPidTraits.h"
126 #include "StEvent/StEventTypes.h"
128 #include "StThreeVectorD.hh"
129 #include "StHelix.hh"
130 #include "StEvent/StTrackGeometry.h"
131 #include "StEvent/StTrackPidTraits.h"
132 #include "StEventUtilities/StuRefMult.hh"
133 #include "PhysicalConstants.h"
134 #include "StPhysicalHelixD.hh"
135 #include "tables/St_tofTOffset_Table.h"
136 #include "tables/St_tofTotbCorr_Table.h"
137 #include "tables/St_tofZbCorr_Table.h"
139 #include "tables/St_vertexSeed_Table.h"
141 #include "StBTofUtil/tofPathLength.hh"
142 #include "StBTofUtil/StBTofHitCollection.h"
143 #include "StBTofUtil/StBTofGeometry.h"
144 #include "StMuDSTMaker/COMMON/StMuDstMaker.h"
145 #include "StMuDSTMaker/COMMON/StMuDst.h"
146 #include "StMuDSTMaker/COMMON/StMuBTofHit.h"
147 #include "StMuDSTMaker/COMMON/StMuTrack.h"
148 #include "StMuDSTMaker/COMMON/StMuPrimaryVertex.h"
149 #include "StMuDSTMaker/COMMON/StMuBTofPidTraits.h"
151 #include "StBTofCalibMaker.h"
152 #include "StVpdCalibMaker/StVpdCalibMaker.h"
153 #include "StBTofUtil/StBTofSimResParams.h"
154 #include "StBTofUtil/StVpdSimConfig.h"
156 #include "TProfile.h"
159 const Double_t StBTofCalibMaker::VHRBIN2PS = 24.4140625;
161 const Double_t StBTofCalibMaker::HRBIN2PS = 97.65625;
163 const Double_t StBTofCalibMaker::TMAX = 51200.;
165 const Double_t StBTofCalibMaker::VZDIFFCUT=6.;
167 const Double_t StBTofCalibMaker::DCARCUT=1.;
168 const Double_t StBTofCalibMaker::mC_Light = C_C_LIGHT/1.e9;
170 const Float_t StBTofCalibMaker::BTHBLCHCNST = 8.;
173 const Float_t StBTofCalibMaker::DEDXTCORR[2] = {0.033, 0.013};
189 mZCalibType = NOTSET;
190 mTotCalibType = NOTSET;
192 mSlewingCorr = kTRUE;
194 mUseVpdStart = kTRUE;
195 mForceTStartZero =
false;
200 mPPPAPionSel = kFALSE;
201 mPPPAOutlierRej = kFALSE;
202 mNSigmaTofMode = kFALSE;
204 mPPPAModeHist = kFALSE;
210 mInitFromFile = kFALSE;
213 setCalibFileTot(
"/star/institutions/rice/calib/default/totCali_4DB.dat");
214 setCalibFileZhit(
"/star/institutions/rice/calib/default/zCali_4DB.dat");
215 setCalibFileT0(
"/star/institutions/rice/calib/default/t0_4DB.dat");
230 void StBTofCalibMaker::resetPars()
232 memset(mTofTotEdge, 0,
sizeof(mTofTotEdge));
233 memset(mTofTotCorr, 0,
sizeof(mTofTotCorr));
234 memset(mTofZEdge, 0,
sizeof(mTofZEdge) );
235 memset(mTofZCorr, 0,
sizeof(mTofZCorr) );
236 memset(mTofTZero, 0,
sizeof(mTofTZero) );
240 void StBTofCalibMaker::resetVpd()
242 memset(mVPDLeTime, 0,
sizeof(mVPDLeTime));
247 mVPDHitPatternEast = 0;
248 mVPDHitPatternWest = 0;
251 mValidStartTime = kFALSE;
262 mEarliestVpdEHit = 99999.;
263 mEarliestVpdWHit = 99999.;
264 mClosestVpdEHit = 99999.;
265 mClosestVpdWHit = 99999.;
266 mLatestVpdEHit = -99999.;
267 mLatestVpdWHit = -99999.;
271 Int_t StBTofCalibMaker::Init()
277 if (IAttr(
"btofFXT")){
279 LOG_INFO <<
"btofFXT mode is on." << endm;
283 if (IAttr(
"pppAMode")) {
286 LOG_INFO <<
"pppAMode is on." << endm;
289 if (IAttr(
"setPPPAOutlierRej")) mPPPAOutlierRej = kTRUE;
291 mUseEventVertex = ! IAttr(
"UseProjectedVertex");
292 if (mUseEventVertex) {
293 LOG_INFO <<
"Use event vertex position." << endm;
295 LOG_INFO <<
"Use projected vertex position." << endm;
307 LOG_INFO <<
"Histograms are booked" << endm;
308 if (mHistoFileName!=
"") {
309 LOG_INFO <<
"Histograms will be stored in " << mHistoFileName.c_str() << endm;
314 bookPPPAHistograms();
315 LOG_INFO <<
"pppAMode Histograms are booked!" << endm;
327 Int_t val = initParameters(runnumber);
329 mValidCalibPar = kTRUE;
330 LOG_DEBUG <<
"Initialized valid calibration parameters." << endm;
332 mValidCalibPar = kFALSE;
333 LOG_WARN <<
"No valid calibration parameters! " << endm;
342 mVpdRes = mVpdResConfig->getParams();
350 if (mUseVpdStart) {LOG_INFO <<
"Found VPD Calibration Maker: use vpd for start timing" << endm;}
351 else {LOG_INFO <<
"Found VPD Calibration Maker: vpd **NOT** used for start timing" << endm;}
353 mUseVpdStart = kFALSE;
354 LOG_INFO <<
"NO VPD Calibration Maker found: vpd **NOT** used for start timing" << endm;
358 if(runnumber>=14350003 && runnumber<=17315001) {
366 if(!mUseVpdStart && !mUseEventVertex) {
367 LOG_WARN <<
" Try to run calibration without VPD as the start time and DON'T use the event vertex! Wrong command! Exit!" << endm;
378 Int_t StBTofCalibMaker::initParameters(
int runnumber)
384 LOG_INFO <<
"Initializing calibration parameters from files" << endm;
388 LOG_INFO <<
" - ToT : " << mCalibFileTot << endm;
389 inData.open(mCalibFileTot.c_str());
390 unsigned int trayId, moduleId, cellId, boardId;
393 inData >> iCalibType;
397 mTotCalibType = calibtype(iCalibType);
400 switch(mTotCalibType) {
404 for(
int i=0;i<mNTray;i++) {
405 for(
int j=0;j<mNModule;j++) {
406 for(
int l=0;l<mNCell;l++){
407 inData>>trayId>>moduleId>>cellId;
412 if ( trayId - 1 >= mNTray || moduleId - 1 >= mNModule || cellId - 1 >= mNCell ){
413 LOG_ERROR <<
"OUT OF BOUNDS, trayId = " << trayId <<
", moduleId = " << moduleId <<
", cellId = " << cellId << endl;
416 if ( nbin >= mNBinMax || nbin < 0){
417 LOG_ERROR <<
"OUT OF BOUNDS, # of TOT bins = " << nbin << endl;
421 for(
int k=0; k <= nbin; k++ ) {
422 inData >> mTofTotEdge[trayId-1][moduleId-1][cellId-1][k];
425 for(
int k=0;k <= nbin;k++) {
426 inData >> mTofTotCorr[trayId-1][moduleId-1][cellId-1][k];
428 if(k%10==0&&Debug()) {
429 LOG_DEBUG <<
" ijlk= " << i <<
" " << j <<
" " << l <<
" " << k <<
" tot " << mTofTotEdge[trayId-1][moduleId-1][cellId-1][k] <<
" corr " << mTofTotCorr[trayId-1][moduleId-1][cellId-1][k] << endm;
439 for(
int i=0;i<mNTray;i++) {
440 for(
int j=0;j<mNModule;j++) {
441 inData>>trayId>>moduleId;
448 if ( trayId - 1 >= mNTray || moduleId - 1 >= mNModule || cellId - 1 >= mNCell ){
449 LOG_ERROR <<
"OUT OF BOUNDS, trayId = " << trayId <<
", moduleId = " << moduleId <<
", cellId = " << cellId << endl;
452 if ( nbin >= mNBinMax || nbin < 0){
453 LOG_ERROR <<
"OUT OF BOUNDS, # of TOT bins = " << nbin << endl;
457 for(
int k=0;k<=nbin;k++){
458 inData>>mTofTotEdge[trayId-1][moduleId-1][cellId-1][k];
461 for(
int l=0; l < mNCell; l++){
462 mTofTotEdge[trayId-1][moduleId-1][l][k] = mTofTotEdge[trayId-1][moduleId-1][cellId-1][k];
465 for(
int k=0;k<=nbin;k++) {
466 inData>>mTofTotCorr[trayId-1][moduleId-1][cellId-1][k];
468 for(
int l=0;l<mNCell;l++){
469 mTofTotCorr[trayId-1][moduleId-1][l][k] = mTofTotCorr[trayId-1][moduleId-1][cellId-1][k];
472 if(k%10==0&&Debug()) {
473 LOG_DEBUG <<
" ijlk= " << i <<
" " << j <<
" " << 0 <<
" " << k <<
" tot " << mTofTotEdge[trayId-1][moduleId-1][0][k] <<
" corr " << mTofTotCorr[trayId-1][moduleId-1][0][k] << endm;
484 for(
int i=0;i<mNTray;i++) {
485 for(
int j=0;j<mNTDIG;j++) {
486 inData>>trayId>>boardId;
488 moduleId = (boardId-1)*4;
495 if ( trayId - 1 >= mNTray || moduleId >= mNModule || cellId - 1 >= mNCell || moduleId + 3 >= mNModule ){
496 LOG_ERROR <<
"OUT OF BOUNDS, trayId = " << trayId <<
", moduleId = " << moduleId <<
", cellId = " << cellId << endl;
499 if ( nbin >= mNBinMax || nbin < 0){
500 LOG_ERROR <<
"OUT OF BOUNDS, # of TOT bins = " << nbin << endl;
504 for(
int k=0;k<=nbin;k++){
505 inData>>mTofTotEdge[trayId-1][moduleId][cellId-1][k];
507 for(
int m=0;m<4;m++){
508 for(
int l=0;l<mNCell;l++){
509 mTofTotEdge[trayId-1][moduleId+m][l][k] = mTofTotEdge[trayId-1][moduleId][cellId-1][k];
514 for(
int k=0;k<=nbin;k++) {
516 inData>>mTofTotCorr[trayId-1][moduleId][cellId-1][k];
518 for(
int m=0;m<4;m++){
519 for(
int l=0;l<mNCell;l++){
520 mTofTotCorr[trayId-1][moduleId+m][l][k] = mTofTotCorr[trayId-1][moduleId][cellId-1][k];
524 if(k%10==0&&Debug()) {
525 LOG_DEBUG <<
" ijlk= " << i <<
" " << j*4 <<
" " << 0 <<
" " << k <<
" tot " << mTofTotEdge[trayId-1][moduleId][cellId][k] <<
" corr " << mTofTotCorr[trayId-1][moduleId][cellId][k] << endm;
533 LOG_WARN <<
"Please check the top of your TOT.dat file for the Calibration format. 9=cell,8=module,7=tdig. Your's is : " << mTotCalibType << endl;
542 LOG_INFO <<
" - Zhit : " << mCalibFileZhit << endm;
543 inData.open(mCalibFileZhit.c_str());
546 mZCalibType = calibtype(iCalibType);
550 for(
int i=0;i<mNTray;i++) {
551 for(
int j=0;j<mNModule;j++) {
552 for(
int l=0;l<mNCell;l++){
553 inData>>trayId>>moduleId>>cellId;
558 if ( trayId - 1 >= mNTray || moduleId - 1 >= mNModule || cellId - 1 >= mNCell ){
559 LOG_ERROR <<
"OUT OF BOUNDS, trayId = " << trayId <<
", moduleId = " << moduleId <<
", cellId = " << cellId << endl;
562 if ( nbin >= mNBinMax || nbin < 0){
563 LOG_ERROR <<
"OUT OF BOUNDS, # of TOT bins = " << nbin << endl;
567 for(
int k=0;k<=nbin;k++) inData>>mTofZEdge[trayId-1][moduleId-1][cellId-1][k];
569 for(
int k=0;k<=nbin;k++) {
570 inData>>mTofZCorr[trayId-1][moduleId-1][cellId-1][k];
571 if(k%10==0&&Debug()) {
572 LOG_DEBUG <<
" ijlk= " << i <<
" " << j <<
" " << l <<
" " << k <<
" zEdge " << mTofZEdge[trayId-1][moduleId-1][cellId-1][k] <<
" corr " << mTofZCorr[trayId-1][moduleId-1][cellId-1][k] << endm;
582 for(
int i=0;i<mNTray;i++) {
583 for(
int j=0;j<mNModule;j++) {
584 inData>>trayId>>moduleId;
590 if ( trayId - 1 >= mNTray || moduleId - 1 >= mNModule || cellId - 1 >= mNCell ){
591 LOG_ERROR <<
"OUT OF BOUNDS, trayId = " << trayId <<
", moduleId = " << moduleId <<
", cellId = " << cellId << endl;
594 if ( nbin >= mNBinMax || nbin < 0){
595 LOG_ERROR <<
"OUT OF BOUNDS, # of TOT bins = " << nbin << endl;
599 for(
int k=0;k<=nbin;k++){
600 inData>>mTofZEdge[trayId-1][moduleId-1][cellId-1][k];
601 for(
int l=0;l<mNCell;l++){
602 mTofZEdge[trayId-1][moduleId-1][l][k]=mTofZEdge[trayId-1][moduleId-1][cellId-1][k];
605 for(
int k=0;k<=nbin;k++) {
606 inData>>mTofZCorr[trayId-1][moduleId-1][cellId-1][k];
607 for(
int l=0;l<mNCell;l++){
608 mTofZCorr[trayId-1][moduleId-1][l][k]=mTofZCorr[trayId-1][moduleId-1][cellId-1][k];
610 if(k%10==0&&Debug()) {
611 LOG_DEBUG <<
" ijlk= " << i <<
" " << j <<
" " << cellId-1 <<
" " << k <<
" zEdge " << mTofZEdge[trayId-1][moduleId-1][cellId][k] <<
" corr " << mTofZCorr[trayId-1][moduleId-1][cellId][k] << endm;
619 for(
int i=0;i<mNTray;i++) {
620 for(
int j=0;j<mNTDIG;j++) {
621 inData>>trayId>>boardId;
623 moduleId = (boardId-1)*4;
630 if ( trayId - 1 >= mNTray || moduleId >= mNModule || cellId - 1 >= mNCell || moduleId + 3 >= mNModule ){
631 LOG_ERROR <<
"OUT OF BOUNDS, trayId = " << trayId <<
", moduleId = " << moduleId <<
", cellId = " << cellId << endl;
634 if ( nbin >= mNBinMax || nbin < 0){
635 LOG_ERROR <<
"OUT OF BOUNDS, # of TOT bins = " << nbin << endl;
639 for(
int k=0;k<=nbin;k++){
640 inData>>mTofZEdge[trayId-1][moduleId][cellId-1][k];
641 for(
int m=0;m<4;m++){
643 for(
int l=0;l<mNCell;l++){
644 mTofZEdge[trayId-1][moduleId+m][l][k] = mTofZEdge[trayId-1][moduleId][cellId-1][k];
649 for(
int k=0;k<=nbin;k++) {
650 inData>>mTofZCorr[trayId-1][moduleId][cellId-1][k];
651 for(
int m=0;m<4;m++){
652 for(
int l=0;l<mNCell;l++){
653 mTofZCorr[trayId-1][moduleId+m][l][k] = mTofZCorr[trayId-1][moduleId][cellId-1][k];
657 if(k%10==0&&Debug()) {
658 LOG_DEBUG <<
" ijlk= " << i <<
" " << moduleId <<
" " << cellId-1 <<
" " << k <<
" tot " << mTofZEdge[trayId-1][moduleId][cellId][k] <<
" corr " << mTofZCorr[trayId-1][moduleId][cellId][k] << endm;
667 LOG_WARN <<
"Please check the top of your Zhit.dat file for the Calibration format. 9=cell,8=module,7=tdig. Your's is : " << mZCalibType << endl;
673 LOG_INFO <<
" - T0 : " << mCalibFileT0 << endm;
674 inData.open(mCalibFileT0.c_str());
676 for(
int i=0;i<mNTray;i++) {
677 for(
int j=0;j<mNModule;j++) {
678 for(
int k=0;k<mNCell;k++) {
679 inData>>trayId>>moduleId>>cellId;
683 if ( trayId - 1 >= mNTray || moduleId - 1 >= mNModule || cellId - 1 >= mNCell ){
684 LOG_ERROR <<
"OUT OF BOUNDS, trayId = " << trayId <<
", moduleId = " << moduleId <<
", cellId = " << cellId << endl;
688 inData>>mTofTZero[trayId-1][moduleId-1][cellId-1];
689 int index = i*mNModule*mNCell+j*mNCell+k;
691 if(index%100==0&&Debug()) {
692 LOG_DEBUG <<
" ijk= " << i <<
" " << j <<
" " << k <<
" t0 " << mTofTZero[trayId-1][moduleId-1][cellId-1] << endm;
703 LOG_INFO <<
"Initializing calibration parameters from database" << endm;
706 TDataSet *mDbDataSet = GetDataBase(
"Calibrations/tof/tofTotbCorr");
707 St_tofTotbCorr* tofTotCorr =
static_cast<St_tofTotbCorr*
>(mDbDataSet->
Find(
"tofTotbCorr"));
709 LOG_ERROR <<
"unable to get tof TotbCorr table parameters" << endm;
713 tofTotbCorr_st* totCorr =
static_cast<tofTotbCorr_st*
>(tofTotCorr->GetArray());
714 Int_t numRows = tofTotCorr->GetNRows();
716 if(numRows!=mNTray*mNTDIG && numRows!=mNTray*mNModule*mNCell && numRows!=mNTray*mNModule) {
717 LOG_WARN <<
" Mis-matched number of rows in tofTotbCorr table! " << numRows
718 <<
" (exp:" << mNTray*mNTDIG <<
" or " << mNTray*mNModule*mNCell <<
" or "<< mNTray*mNModule <<
")" << endm;
721 LOG_INFO <<
" Number of rows read in: " << numRows <<
" for ToT correction" << endm;
724 mTotCalibType = calibtype(numRows);
726 switch(mTotCalibType){
728 for (Int_t i=0;i<numRows;i++) {
729 short trayId = totCorr[i].trayId;
730 short moduleId = totCorr[i].moduleId;
731 short cellId = totCorr[i].cellId;
734 LOG_DEBUG <<
" tray " << trayId <<
" module " << moduleId <<
" cell " << cellId << endm;
735 for(Int_t j=0;j<mNBinMax;j++) {
736 if(trayId>0&&trayId<=mNTray&&moduleId>0&&moduleId<=mNModule&&cellId>0&&cellId<=mNCell){
737 mTofTotEdge[trayId-1][moduleId-1][cellId-1][j] = totCorr[i].tot[j];
738 mTofTotCorr[trayId-1][moduleId-1][cellId-1][j] = totCorr[i].corr[j];
739 if(Debug()&&j%10==0) { LOG_DEBUG <<
" j=" << j <<
" tot " << mTofTotEdge[trayId-1][moduleId-1][cellId-1][j] <<
" corr " << mTofTotCorr[trayId-1][moduleId-1][cellId-1][j] << endm; }
746 for (Int_t i=0;i<numRows;i++) {
747 short trayId = totCorr[i].trayId;
748 short moduleId = totCorr[i].moduleId;
749 short cellId = totCorr[i].cellId;
752 LOG_DEBUG <<
" tray " << trayId <<
" module " << moduleId <<
" cell " << cellId << endm;
753 for(Int_t j=0;j<mNBinMax;j++) {
754 if(trayId>0&&trayId<=mNTray&&moduleId>0&&moduleId<=mNModule){
755 for(Int_t k=0;k<mNCell;k++){
756 mTofTotEdge[trayId-1][moduleId-1][cellId-1+k][j] = totCorr[i].tot[j];
757 mTofTotCorr[trayId-1][moduleId-1][cellId-1+k][j] = totCorr[i].corr[j];
758 if(Debug()&&j%10==0) { LOG_DEBUG <<
" j=" << j <<
" tot " << mTofTotEdge[trayId-1][moduleId-1][cellId-1+k][j] <<
" corr " << mTofTotCorr[trayId-1][moduleId-1][cellId-1+k][j] << endm; }
766 for (Int_t i=0;i<numRows;i++) {
767 short trayId = totCorr[i].trayId;
768 short moduleId = totCorr[i].moduleId;
769 short cellId = totCorr[i].cellId;
770 short boardId = (moduleId-1)/4+1;
772 LOG_DEBUG <<
" tray " << trayId <<
" module " << moduleId <<
" cell " << cellId << endm;
773 for(Int_t j=0;j<mNBinMax;j++) {
774 if(trayId>0&&trayId<=mNTray&&boardId>0&&boardId<=mNTDIG){
775 for(Int_t k=0; k<4;k++){
776 for(Int_t l=0;l<mNCell;l++){
777 mTofTotEdge[trayId-1][moduleId-1+k][cellId-1+l][j] = totCorr[i].tot[j];
778 mTofTotCorr[trayId-1][moduleId-1+k][cellId-1+l][j] = totCorr[i].corr[j];
779 if(Debug()&&j%10==0) { LOG_DEBUG <<
" j=" << j <<
" tot " << mTofTotEdge[trayId-1][moduleId-1+k][cellId-1+l][j] <<
" corr " << mTofTotCorr[trayId-1][moduleId-1+k][cellId-1+l][j] << endm; }
788 LOG_WARN <<
"Number of rows in tofTotbCorr table mis-matched. "<<endl;
793 mDbDataSet = GetDataBase(
"Calibrations/tof/tofZbCorr");
794 St_tofZbCorr* tofZCorr =
static_cast<St_tofZbCorr*
>(mDbDataSet->
Find(
"tofZbCorr"));
796 LOG_ERROR <<
"unable to get tof ZbCorr table parameters" << endm;
800 tofZbCorr_st* zCorr =
static_cast<tofZbCorr_st*
>(tofZCorr->GetArray());
801 numRows = tofZCorr->GetNRows();
803 if(numRows!=mNTray*mNTDIG && numRows!=mNTray*mNModule*mNCell && numRows !=mNTray*mNModule) {
804 LOG_WARN <<
" Mis-matched number of rows in tofZbCorr table! " << numRows
805 <<
" (exp:" << mNTray*mNTDIG <<
" or " << mNTray*mNModule*mNCell <<
" or "<< mNTray*mNModule <<
")" << endm;
807 LOG_INFO <<
" Number of rows read in: " << numRows <<
" for Z correction" << endm;
810 mZCalibType = calibtype(numRows);
814 for (Int_t i=0;i<numRows;i++) {
815 short trayId = totCorr[i].trayId;
816 short moduleId = totCorr[i].moduleId;
817 short cellId = totCorr[i].cellId;
820 LOG_DEBUG <<
" tray " << trayId <<
" module " << moduleId <<
" cell " << cellId << endm;
821 for(Int_t j=0;j<mNBinMax;j++) {
822 if(trayId>0&&trayId<=mNTray&&moduleId>0&&moduleId<=mNModule&&cellId>0&&cellId<=mNCell) {
823 mTofZEdge[trayId-1][moduleId-1][cellId-1][j] = zCorr[i].z[j];
824 mTofZCorr[trayId-1][moduleId-1][cellId-1][j] = zCorr[i].corr[j];
825 if(Debug()&&j%10==0) { LOG_DEBUG <<
" j=" << j <<
" tot " << mTofZEdge[trayId-1][moduleId-1][cellId-1][j] <<
" corr " << mTofZCorr[trayId-1][moduleId-1][cellId-1][j] << endm; }
832 for (Int_t i=0;i<numRows;i++) {
833 short trayId = totCorr[i].trayId;
834 short moduleId = totCorr[i].moduleId;
835 short cellId = totCorr[i].cellId;
836 short boardId = (moduleId-1)/4+1;
838 LOG_DEBUG <<
" tray " << trayId <<
" module " << moduleId <<
" cell " << cellId << endm;
839 for(Int_t j=0;j<mNBinMax;j++) {
840 if(trayId>0&&trayId<=mNTray&&boardId>0&&moduleId<=mNModule) {
841 for(Int_t k=0;k<mNCell;k++){
842 mTofZEdge[trayId-1][moduleId-1][cellId-1+k][j] = zCorr[i].z[j];
843 mTofZCorr[trayId-1][moduleId-1][cellId-1+k][j] = zCorr[i].corr[j];
844 if(Debug()&&j%10==0) { LOG_DEBUG <<
" j=" << j <<
" tot " << mTofZEdge[trayId-1][moduleId-1][cellId-1+k][j] <<
" corr " << mTofZCorr[trayId-1][moduleId-1][cellId-1+k][j] << endm; }
852 for (Int_t i=0;i<numRows;i++) {
853 short trayId = totCorr[i].trayId;
854 short moduleId = totCorr[i].moduleId;
855 short cellId = totCorr[i].cellId;
856 short boardId = (moduleId-1)/4+1;
858 LOG_DEBUG <<
" tray " << trayId <<
" module " << moduleId <<
" cell " << cellId << endm;
859 for(Int_t j=0;j<mNBinMax;j++) {
860 if(trayId>0&&trayId<=mNTray&&boardId>0&&boardId<=mNTDIG) {
861 for(Int_t k=0;k<4;k++){
862 for(Int_t l=0;l<mNCell;l++){
863 mTofZEdge[trayId-1][moduleId-1+k][cellId-1+l][j] = zCorr[i].z[j];
864 mTofZCorr[trayId-1][moduleId-1+k][cellId-1+l][j] = zCorr[i].corr[j];
865 if(Debug()&&j%10==0) { LOG_DEBUG <<
" j=" << j <<
" tot " << mTofZEdge[trayId-1][moduleId-1+k][cellId-1+l][j] <<
" corr " << mTofZCorr[trayId-1][moduleId-1+k][cellId-1+l][j] << endm; }
874 LOG_WARN <<
"Number of rows in tofZbCorr table mis-matched. "<<endl;
877 mDbDataSet = GetDataBase(
"Calibrations/tof/tofTOffset");
878 St_tofTOffset* tofTOffset =
static_cast<St_tofTOffset*
>(mDbDataSet->
Find(
"tofTOffset"));
880 LOG_ERROR <<
"unable to get tof TOffset table parameters" << endm;
884 tofTOffset_st* tZero =
static_cast<tofTOffset_st*
>(tofTOffset->GetArray());
885 numRows = tofTOffset->GetNRows();
887 LOG_DEBUG <<
" Number of rows read in: " << numRows <<
" for TOffset correction" << endm;
889 if(numRows!=mNTray) {
890 LOG_WARN <<
" Mis-matched number of rows in tofTOffset table! " << numRows
891 <<
" (exp:" << mNTray <<
")" << endm;
894 for (Int_t i=0;i<numRows;i++) {
895 short trayId = tZero[i].trayId;
896 LOG_DEBUG <<
" tray " << trayId << endm;
898 if(trayId>0&&trayId<=mNTray) {
899 for(
int j=0;j<mNTOF;j++) {
900 mTofTZero[trayId-1][j/6][j%6] = tZero[i].T0[j];
901 if(Debug()&&j%10==0) { LOG_DEBUG <<
" j=" << j <<
" T0 " << mTofTZero[trayId-1][j/6][j%6] << endm; }
915 TDataSet* dbDataSet = this->GetDataBase(
"Calibrations/rhic/vertexSeed");
918 vertexSeed_st* vSeed = ((St_vertexSeed*) (dbDataSet->FindObject(
"vertexSeed")))->GetTable();
926 LOG_WARN <<
"No database for beamline (Calibrations/rhic/vertexSeed)" << endm;
929 LOG_INFO <<
"BeamLine Constraint: " << endm;
930 LOG_INFO <<
"x(z) = " << x0 <<
" + " << dxdz <<
" * z" << endm;
931 LOG_INFO <<
"y(z) = " << y0 <<
" + " << dydz <<
" * z" << endm;
939 double pt = 88889999;
940 double nxy=::sqrt(dxdz*dxdz + dydz*dydz);
942 LOG_WARN <<
"Beam line must be tilted!" << endm;
950 if(mBeamHelix)
delete mBeamHelix;
958 Int_t StBTofCalibMaker::FinishRun(
int runnumber)
960 if(mBeamHelix)
delete mBeamHelix;
963 if (mBTofRes){
delete mBTofRes; mBTofRes = 0;}
964 if (mVpdResConfig) {
delete mVpdResConfig; mVpdResConfig = 0;}
972 if (mHistoFileName!=
"") writeHistograms();
973 if (mPPPAModeHist) writePPPAHistograms();
980 LOG_DEBUG <<
"StBTofCalibMaker::Maker: starting ..." << endm;
981 if(!mValidCalibPar) {
982 LOG_WARN <<
"No valid calibration parameters. Skip ... " << endm;
992 if(!mMuDstIn) processStEvent();
1002 void StBTofCalibMaker::processStEvent()
1006 if( !mEvent ) {LOG_WARN <<
"No StEvent" << endm;
return;}
1007 if (!mEvent->btofCollection()) {LOG_WARN <<
"No BTOFCollection" << endm;
return;}
1008 if (!mEvent->btofCollection()->hitsPresent()) {LOG_WARN <<
"No hits present" << endm;
return;}
1011 StSPtrVecBTofHit &tofHits = theTof->tofHits();
1012 Int_t nhits = tofHits.size();
1013 LOG_INFO <<
" Fired TOF cells + upVPD tubes : " << nhits << endm;
1019 float dcaRmin = 9999.;
1022 if(mUseEventVertex) {
1042 mEvtVtxZ = pVtx->position().z();
1045 LOG_WARN <<
"No (default) primary vertex information for this (st-) event" << endm;
1048 tstart(mEvtVtxZ, &mTStart, &mTDiff);
1054 for(
int i=0;i<nhits;i++) {
1057 int trayId = aHit->tray();
1058 if(trayId>0&&trayId<=mNTray) {
1060 if(!gTrack)
continue;
1067 LOG_DEBUG<<
" tofPos(x,y,z) = "<<tofPos.x()<<
","<<tofPos.y()<<
","<<tofPos.z()<<endm;
1068 LOG_DEBUG<<
"beamPos(x,y,z) = "<<beamPos.x()<<
","<<beamPos.y()<<
","<<beamPos.z()<<endm;
1069 LOG_DEBUG<<
" dca (x,y,z) = "<<dcatof.x()<<
","<<dcatof.y()<<
","<<dcatof.z()<<endm;
1070 LOG_DEBUG<<
" 2D dca = "<<sqrt(pow(dcatof.x(),2)+pow(dcatof.y(),2))<<endm;
1071 LOG_DEBUG<<
" 2D signed dca = "<<theTrackGeometry->helix().geometricSignedDistance(beamPos.x(),beamPos.y())<<endm;
1074 if(fabs(tofPos.z()-mVPDVtxZ)>VZDIFFCUT)
continue;
1076 if(dcaRmin>dcatof.perp()) {
1077 mProjVtxZ = tofPos.z();
1078 dcaRmin = dcatof.perp();
1083 if(dcaRmin>DCARCUT) mProjVtxZ = -9999.;
1084 tstart(mProjVtxZ, &mTStart, &mTDiff);
1092 int nPrimaryVertices = mEvent->numberOfPrimaryVertices();
1093 for(
int iVtx=0; iVtx<nPrimaryVertices; iVtx++){
1094 pVtx = mEvent->primaryVertex(iVtx);
1095 if(pVtx->position().z() > 198. && pVtx->position().z() < 202.)
break;
1096 else if(iVtx == nPrimaryVertices - 1){
1097 LOG_WARN <<
" No FXT primary vertex within target ... bye-bye" << endm;
1103 LOG_WARN <<
" No primary vertex ... bye-bye" << endm;
1106 mEvtVtxZ = pVtx->position().z();
1108 tstart_NoVpd(theTof, pVtx, &mTStart);
1112 LOG_INFO <<
"primVz = " << mEvtVtxZ <<
" projVz = " << mProjVtxZ <<
" vpdVz = " << mVPDVtxZ << endm;
1113 LOG_INFO <<
"Tstart = " << mTStart <<
" Tdiff = " << mTDiff <<
" NTzero = " << mNTzero << endm;
1114 LOG_INFO <<
"NWest = " << mNWest <<
" NEast = " << mNEast <<
" TdcSum West = " << mTSumWest <<
" East = " << mTSumEast << endm;
1117 if(mTStart<-1000.) {
1118 LOG_INFO <<
"No valid start time for this event. Skip ..." << endm;
1119 mValidStartTime = kFALSE;
1122 mValidStartTime = kTRUE;
1130 int nohitfound(0), ismchit(0),trayoutofbounds(0),notrack(0),
1131 gnopidtraits(0),gtraitisfalse(0), pidtoffalse(0),calibfailed(0),
1132 pgnopidtraits(0), ptraitisfalse(0),tofisset(0), num_doPID(0);
1134 for(
int i=0;i<nhits;i++) {
1138 LOG_DEBUG <<
"No hit found in the BTof Calibration." << endm;
1139 nohitfound++;
continue;
1143 if ( aHit->qaTruth() == 1 ) {
1144 isMcFlag = kTRUE; ismchit++;
1145 LOG_DEBUG <<
"Simulated hit." << endm;
1148 int trayId = aHit->tray();
1149 if(trayId<=0 || trayId>mNTray) {
1150 LOG_DEBUG <<
"Tray out of bounds." << endm;
1151 trayoutofbounds++;
continue;
1156 LOG_DEBUG <<
" No associated Track with this hit." << endm;
1157 notrack++;
continue;
1159 else LOG_DEBUG <<
"Track found" << endm;
1161 const StPtrVecTrackPidTraits& theTofPidTraits = gTrack->pidTraits(kTofId);
1162 if(!theTofPidTraits.size()) {
1163 LOG_DEBUG <<
"Tof Pid Traits not populated." << endm;
1164 gnopidtraits++;
continue;
1167 StTrackPidTraits *theSelectedTrait = theTofPidTraits[theTofPidTraits.size()-1];
1168 if(!theSelectedTrait) {
1169 LOG_DEBUG <<
"The Selected Trait is false." << endm;
1170 gtraitisfalse++;
continue;
1175 LOG_DEBUG <<
"PID Tof reports false" << endm;
1176 pidtoffalse++;
continue;
1179 double tot = aHit->tot();
1180 double tdc = aHit->leadingEdgeTime();
1181 double tof = tdc - mTStart;
1182 Double_t zhit = pidTof->zLocal();
1184 int moduleChan = (aHit->module()-1)*6 + (aHit->cell()-1);
1185 Double_t tofcorr = tof;
1187 tofcorr = tofAllCorr(tof, tot, zhit, trayId, moduleChan);
1190 calibfailed++;
continue;
1194 pidTof->setTimeOfFlight((Float_t)tofcorr);
1200 const StPtrVecTrackPidTraits& pTofPidTraits = pTrack->pidTraits(kTofId);
1201 if(!pTofPidTraits.size()) {
1202 LOG_DEBUG <<
"pTofPidTraits is false." << endm;
1203 pgnopidtraits++;
continue;
1207 if(!pSelectedTrait) {
1208 LOG_DEBUG <<
"pSelectedTrait is false." << endm;
1209 ptraitisfalse++;
continue;
1214 if(ppidTof && mUseEventVertex) {
1215 ppidTof->setTimeOfFlight((Float_t)tofcorr);
1216 tofisset++; LOG_DEBUG <<
"Time of Flight set." << endm;
1221 Double_t L = -9999.;
1222 Double_t ptot = -9999.;
1223 Bool_t doPID = kFALSE;
1224 if(mUseEventVertex) {
1226 LOG_DEBUG <<
" The associated track is not a primary one. Skip PID calculation! " << endm;
1229 const StVertex *thisVertex = pTrack->vertex();
1231 LOG_DEBUG <<
" The associated track is not coming from any vertex. Skip PID calculation! " << endm;
1234 L = tofPathLength(&primPos, &pidTof->position(), theTrackGeometry->helix().curvature());
1235 ptot = pTrack->geometry()->momentum().mag();
1237 LOG_DEBUG <<
"Pathlength and ptot set." << endm;
1246 if(dcatof.perp()>DCARCUT) {
1247 LOG_DEBUG <<
" The projected position is far from beam line. Skip PID calculation! " << endm;
1248 }
else if(fabs(tofPos.z()-mVPDVtxZ)>VZDIFFCUT) {
1249 LOG_DEBUG <<
" This track is not coming from the same VPD vertex! Skip PID calculation! " << endm;
1251 L = tofPathLength(&tofPos, &pidTof->position(), theTrackGeometry->helix().curvature());
1252 ptot = gTrack->geometry()->momentum().mag();
1253 if(gTrack->dcaGeometry()) {
1254 ptot = gTrack->dcaGeometry()->momentum().mag();
1261 if(!doPID)
continue;
1264 Double_t beta = L/(tofcorr*(C_C_LIGHT/1.e9));
1266 Double_t b_e = ptot/sqrt(ptot*ptot+M_ELECTRON*M_ELECTRON);
1267 Double_t b_pi = ptot/sqrt(ptot*ptot+M_PION_PLUS*M_PION_PLUS);
1268 Double_t b_k = ptot/sqrt(ptot*ptot+M_KAON_PLUS*M_KAON_PLUS);
1269 Double_t b_p = ptot/sqrt(ptot*ptot+M_PROTON*M_PROTON);
1271 float sigmae = -9999.;
1272 float sigmapi = -9999.;
1273 float sigmak = -9999.;
1274 float sigmap = -9999.;
1276 float res = tofCellResolution(trayId, moduleChan);
1277 float res_c = res * (C_C_LIGHT/1.e9);
1279 if(fabs(res)>1.e-5) {
1280 sigmae = (Float_t)(L*(1./beta-1./b_e)/res_c);
1281 sigmapi = (Float_t)(L*(1./beta-1./b_pi)/res_c);
1282 sigmak = (Float_t)(L*(1./beta-1./b_k)/res_c);
1283 sigmap = (Float_t)(L*(1./beta-1./b_p)/res_c);
1286 pidTof->setPathLength((Float_t)L);
1287 pidTof->setBeta((Float_t)beta);
1288 pidTof->setSigmaElectron(sigmae);
1289 pidTof->setSigmaPion(sigmapi);
1290 pidTof->setSigmaKaon(sigmak);
1291 pidTof->setSigmaProton(sigmap);
1293 LOG_DEBUG <<
" storing BTofPidTraits for the global track" << endm;
1295 if(mUseEventVertex) {
1299 ppidTof->setPathLength((Float_t)L);
1300 ppidTof->setBeta((Float_t)beta);
1301 ppidTof->setSigmaElectron(sigmae);
1302 ppidTof->setSigmaPion(sigmapi);
1303 ppidTof->setSigmaKaon(sigmak);
1304 ppidTof->setSigmaProton(sigmap);
1306 LOG_DEBUG <<
" storing BTofPidTraits for the primary track" << endm;
1312 LOG_INFO <<
"nohitfound:"<< nohitfound <<
" ismchit:" <<ismchit <<
" trayoutofbounds:" << trayoutofbounds <<
" notrack:" << notrack << endm;
1313 LOG_INFO <<
" gnopidtraits:" << gnopidtraits <<
" gtraitisfalse:" << gtraitisfalse <<
" pidtoffalse:"<< pidtoffalse <<
" calibfailed:"<< calibfailed << endm;
1314 LOG_INFO <<
" pgnopidtraits:"<< pgnopidtraits <<
" ptraitisfalse:" << ptraitisfalse <<
" tofisset:"<< tofisset <<
" doPID:" << num_doPID << endm;
1320 void StBTofCalibMaker::processMuDst()
1323 LOG_WARN <<
" No MuDst ... bye-bye" << endm;
1329 Int_t nhits = mMuDst->numberOfBTofHit();
1330 LOG_INFO <<
" Fired TOF cells + upVPD tubes : " << nhits << endm;
1336 float dcaRmin = 9999.;
1339 if(mUseEventVertex) {
1358 mEvtVtxZ = pVtx->position().z();
1361 LOG_WARN <<
"No (default) primary vertex information for this (mudst) event" << endm;
1364 tstart(mEvtVtxZ, &mTStart, &mTDiff);
1370 for(
int i=0;i<nhits;i++) {
1373 int trayId = aHit->tray();
1374 if(trayId>0&&trayId<=mNTray) {
1375 StMuTrack *gTrack = aHit->globalTrack();
1376 if(!gTrack)
continue;
1384 if(fabs(tofPos.z()-mVPDVtxZ)>VZDIFFCUT)
continue;
1386 if(dcaRmin>dcatof.perp()) {
1387 mProjVtxZ = tofPos.z();
1388 dcaRmin = dcatof.perp();
1393 if(dcaRmin>DCARCUT) mProjVtxZ = -9999.;
1394 tstart(mProjVtxZ, &mTStart, &mTDiff);
1401 int nPrimaryVertices = mMuDst->numberOfPrimaryVertices();
1402 for(
int iVtx=0; iVtx<nPrimaryVertices; iVtx++){
1404 if(pVtx->position().z() > 198. && pVtx->position().z() < 202.)
break;
1405 else if(iVtx == nPrimaryVertices - 1){
1406 LOG_WARN <<
" No FXT primary vertex within target ... bye-bye" <<endm;
1412 LOG_WARN <<
" No primary vertex ... bye-bye" << endm;
1415 mEvtVtxZ = pVtx->position().z();
1417 tstart_NoVpd(mMuDst, pVtx, &mTStart);
1420 LOG_INFO <<
"primVz = " << mEvtVtxZ <<
" projVz = " << mProjVtxZ <<
" vpdVz = " << mVPDVtxZ << endm;
1421 LOG_INFO <<
"Tstart = " << mTStart <<
" Tdiff = " << mTDiff <<
" NTzero = " << mNTzero << endm;
1422 LOG_INFO <<
"NWest = " << mNWest <<
" NEast = " << mNEast <<
" TdcSum West = " << mTSumWest <<
" East = " << mTSumEast << endm;
1425 if(mTStart<-1000.) {
1426 LOG_INFO <<
" No valid start time for this event. Skip ..." << endm;
1427 mValidStartTime = kFALSE;
1430 mValidStartTime = kTRUE;
1438 int nohitfound(0), ismchit(0),trayoutofbounds(0),notrack(0),
1439 gnopidtraits(0),gtraitisfalse(0), pidtoffalse(0),calibfailed(0),
1440 pgnopidtraits(0), ptraitisfalse(0),tofisset(0), num_doPID(0);
1442 for(
int i=0;i<nhits;i++) {
1444 if(!aHit) {nohitfound++;
continue;}
1445 int trayId = aHit->tray();
1446 if(trayId<=0 || trayId>mNTray) {trayoutofbounds++;
continue;}
1448 StMuTrack *gTrack = aHit->globalTrack();
1450 LOG_DEBUG <<
" No associated Track with this hit." << endm;
1451 notrack++;
continue;
1455 if ( aHit->qaTruth() == 1 ) {
1456 isMcFlag = kTRUE; ismchit++;
1457 LOG_DEBUG <<
"Simulated hit." << endm;
1462 double tot = aHit->tot();
1463 double tdc = aHit->leadingEdgeTime();
1464 while(tdc>TMAX) tdc -= TMAX;
1465 double tof = tdc - mTStart;
1466 Double_t zhit = pidTof.zLocal();
1468 int moduleChan = (aHit->module()-1)*6 + (aHit->cell()-1);
1470 Double_t tofcorr = tof;
1472 tofcorr = tofAllCorr(tof, tot, zhit, trayId, moduleChan);
1475 calibfailed++;
continue;
1480 pidTof.setTimeOfFlight((Float_t)tofcorr);
1483 StMuTrack *pTrack = aHit->primaryTrack();
1486 ppidTof = pTrack->btofPidTraits();
1487 if(mUseEventVertex) ppidTof.setTimeOfFlight((Float_t)tofcorr);
1491 Double_t L = -9999.;
1492 Double_t ptot = -9999.;
1493 Bool_t doPID = kFALSE;
1494 if(mUseEventVertex) {
1496 LOG_DEBUG <<
" The associated track is not a primary one. Skip PID calculation! " << endm;
1501 LOG_DEBUG <<
" The associated track is not coming from any vertex. Skip PID calculation! " << endm;
1505 L = tofPathLength(&primPos, &pidTof.position(), thisHelix.curvature());
1516 if(dcatof.perp()>DCARCUT) {
1517 LOG_DEBUG <<
" The projected position is far from beam line. Skip PID calculation! " << endm;
1518 }
else if(fabs(tofPos.z()-mVPDVtxZ)>VZDIFFCUT) {
1519 LOG_DEBUG <<
" This track is not coming from the same VPD vertex! Skip PID calculation! " << endm;
1521 L = tofPathLength(&tofPos, &pidTof.position(), gHelix.curvature());
1529 Double_t beta = L/(tofcorr*(C_C_LIGHT/1.e9));
1531 Double_t b_e = ptot/sqrt(ptot*ptot+M_ELECTRON*M_ELECTRON);
1532 Double_t b_pi = ptot/sqrt(ptot*ptot+M_PION_PLUS*M_PION_PLUS);
1533 Double_t b_k = ptot/sqrt(ptot*ptot+M_KAON_PLUS*M_KAON_PLUS);
1534 Double_t b_p = ptot/sqrt(ptot*ptot+M_PROTON*M_PROTON);
1536 float sigmae = -9999.;
1537 float sigmapi = -9999.;
1538 float sigmak = -9999.;
1539 float sigmap = -9999.;
1541 float res = tofCellResolution(trayId, moduleChan);
1542 float res_c = res * (C_C_LIGHT/1.e9);
1544 if(fabs(res)>1.e-5) {
1545 sigmae = (Float_t)(L*(1./beta-1./b_e)/res_c);
1546 sigmapi = (Float_t)(L*(1./beta-1./b_pi)/res_c);
1547 sigmak = (Float_t)(L*(1./beta-1./b_k)/res_c);
1548 sigmap = (Float_t)(L*(1./beta-1./b_p)/res_c);
1551 pidTof.setPathLength((Float_t)L);
1552 pidTof.setBeta((Float_t)beta);
1553 pidTof.setSigmaElectron(sigmae);
1554 pidTof.setSigmaPion(sigmapi);
1555 pidTof.setSigmaKaon(sigmak);
1556 pidTof.setSigmaProton(sigmap);
1558 if(mUseEventVertex && pTrack) {
1560 ppidTof.setPathLength((Float_t)L);
1561 ppidTof.setBeta((Float_t)beta);
1562 ppidTof.setSigmaElectron(sigmae);
1563 ppidTof.setSigmaPion(sigmapi);
1564 ppidTof.setSigmaKaon(sigmak);
1565 ppidTof.setSigmaProton(sigmap);
1569 gTrack->setBTofPidTraits(pidTof);
1570 LOG_DEBUG <<
" storing BTofPidTraits for the global track" << endm;
1572 if(mUseEventVertex && pTrack) {
1573 pTrack->setBTofPidTraits(ppidTof);
1574 LOG_DEBUG <<
" storing BTofPidTraits for the primary track" << endm;
1578 LOG_INFO <<
"nohitfound:"<< nohitfound <<
" ismchit:" <<ismchit <<
" trayoutofbounds:" << trayoutofbounds <<
" notrack:" << notrack << endm;
1579 LOG_INFO <<
" gnopidtraits:" << gnopidtraits <<
" gtraitisfalse:" << gtraitisfalse <<
" pidtoffalse:"<< pidtoffalse <<
" calibfailed:"<< calibfailed << endm;
1580 LOG_INFO <<
" pgnopidtraits:"<< pgnopidtraits <<
" ptraitisfalse:" << ptraitisfalse <<
" tofisset:"<< tofisset <<
" doPID:" << num_doPID << endm;
1587 void StBTofCalibMaker::cleanCalibMuDst()
1591 Int_t nPrimary = mMuDst->numberOfPrimaryTracks();
1592 Int_t nGlobal = mMuDst->numberOfGlobalTracks();
1593 for(
int i=0;i<nPrimary;i++) {
1595 if(!pTrack)
continue;
1598 pTrack->setBTofPidTraits(pid);
1600 for(
int i=0;i<nGlobal;i++) {
1602 if(!gTrack)
continue;
1605 gTrack->setBTofPidTraits(pid);
1613 pid.setTimeOfFlight(-999.);
1614 pid.setPathLength(-999.);
1616 pid.setSigmaElectron(-999.);
1617 pid.setSigmaPion(-999.);
1618 pid.setSigmaKaon(-999.);
1619 pid.setSigmaProton(-999.);
1620 pid.setProbElectron(-999.);
1621 pid.setProbPion(-999.);
1622 pid.setProbKaon(-999.);
1623 pid.setProbProton(-999.);
1628 void StBTofCalibMaker::initEvent()
1633 LOG_WARN <<
" No MuDstMaker ... bye-bye" << endm;
1636 mMuDst = mMuDstMaker->
muDst();
1638 LOG_WARN <<
" No MuDst ... bye-bye" << endm;
1644 mEvent = (
StEvent *) GetInputDS(
"StEvent");
1648 if(!btofColl)
return;
1649 mBTofHeader = btofColl->tofHeader();
1656 void StBTofCalibMaker::loadVpdData()
1658 if(!mBTofHeader)
return;
1664 mVPDHitPatternWest = mBTofHeader->vpdHitPattern(west);
1665 mVPDHitPatternEast = mBTofHeader->vpdHitPattern(east);
1666 mNWest = mBTofHeader->numberOfVpdHits(west);
1667 mNEast = mBTofHeader->numberOfVpdHits(east);
1668 mVPDVtxZ = mBTofHeader->vpdVz();
1670 for(
int i=0;i<mNVPD;i++) {
1671 mVPDLeTime[i] = mBTofHeader->vpdTime(west, i+1);
1672 if(mVPDLeTime[i]>0.) {
1673 mTSumWest += mVPDLeTime[i];
1677 LOG_DEBUG <<
" loading VPD West tubeId = " << i+1 <<
" time = " << mVPDLeTime[i] << endm;
1681 for(
int i=0;i<mNVPD;i++) {
1682 mVPDLeTime[i+mNVPD] = mBTofHeader->vpdTime(east, i+1);
1683 if(mVPDLeTime[i+mNVPD]>0.) mTSumEast += mVPDLeTime[i+mNVPD];
1685 LOG_DEBUG <<
" loading VPD East tubeId = " << i+1 <<
" time = " << mVPDLeTime[i+mNVPD] << endm;
1693 void StBTofCalibMaker::writeStartTime()
1696 mBTofHeader->setTStart(mTStart);
1697 mBTofHeader->setTDiff(mTDiff);
1698 mBTofHeader->setNTzero(mNTzero);
1700 mBTofHeader->setNTzeroCan(mNTzeroCan);
1701 mBTofHeader->setTCanFirst(mTCanFirst);
1702 mBTofHeader->setTCanLast(mTCanLast);
1704 mBTofHeader->setVpdEHits(mVpdEHits);
1705 mBTofHeader->setVpdWHits(mVpdWHits);
1706 mBTofHeader->setVpdEGoodHits(mVpdEGoodHits);
1707 mBTofHeader->setVpdWGoodHits(mVpdWGoodHits);
1708 mBTofHeader->setEarliestVpdEHit(mEarliestVpdEHit);
1709 mBTofHeader->setEarliestVpdWHit(mEarliestVpdWHit);
1710 mBTofHeader->setClosestVpdEHit(mClosestVpdEHit);
1711 mBTofHeader->setClosestVpdWHit(mClosestVpdWHit);
1712 mBTofHeader->setLatestVpdEHit(mLatestVpdEHit);
1713 mBTofHeader->setLatestVpdWHit(mLatestVpdWHit);
1720 Double_t StBTofCalibMaker::tofAllCorr(
const Double_t tof,
const Double_t tot,
const Double_t z,
const Int_t iTray,
const Int_t iModuleChan)
1723 int module = iModuleChan/6 + 1;
1724 int cell = iModuleChan%6 + 1;
1726 LOG_DEBUG <<
"\nStBTofCalibMaker::btofAllCorr: BTof calibrating...\n"
1727 <<
"\tDoing Calibration in BTOF Tray " << tray <<
" Module " << module <<
" Cell " << cell
1728 <<
"\n\tinput tof = " << tof
1729 <<
" TOT = " << tot <<
" Zlocal = " << z << endm;
1731 Double_t tofcorr = tof;
1733 tofcorr -= mTofTZero[tray-1][module-1][cell-1];
1735 LOG_DEBUG <<
"T0 correction: "<<mTofTZero[tray-1][module-1][cell-1]<<endm;
1739 for(
int i=0;i<mNBinMax-1;i++) {
1740 if(tot>=mTofTotEdge[tray-1][module-1][cell-1][i] && tot<mTofTotEdge[tray-1][module-1][cell-1][i+1]) {
1745 if(iTotBin>=0&&iTotBin<mNBinMax) {
1746 double x1 = mTofTotEdge[tray-1][module-1][cell-1][iTotBin];
1747 double x2 = mTofTotEdge[tray-1][module-1][cell-1][iTotBin+1];
1748 double y1 = mTofTotCorr[tray-1][module-1][cell-1][iTotBin];
1749 double y2 = mTofTotCorr[tray-1][module-1][cell-1][iTotBin+1];
1750 double dcorr = y1 + (tot-x1)*(y2-y1)/(x2-x1);
1751 LOG_DEBUG <<
"TOT correction: "<<dcorr<<endm;
1755 LOG_DEBUG <<
" TOT out of range! EXIT! " << endm;
1760 for(
int i=0;i<mNBinMax-1;i++) {
1761 if(z>=mTofZEdge[tray-1][module-1][cell-1][i] && z<mTofZEdge[tray-1][module-1][cell-1][i+1]) {
1766 if(iZBin>=0&&iZBin<mNBinMax) {
1767 double x1 = mTofZEdge[tray-1][module-1][cell-1][iZBin];
1768 double x2 = mTofZEdge[tray-1][module-1][cell-1][iZBin+1];
1769 double y1 = mTofZCorr[tray-1][module-1][cell-1][iZBin];
1770 double y2 = mTofZCorr[tray-1][module-1][cell-1][iZBin+1];
1771 double dcorr = y1 + (z-x1)*(y2-y1)/(x2-x1);
1774 LOG_DEBUG <<
"zHit correction: "<<dcorr<<endm;
1777 LOG_DEBUG <<
" Z out of range! EXIT! " << endm;
1783 LOG_DEBUG <<
" Corrected tof: tofcorr = " << tofcorr << endm;
1786 const double SLEWCORR = 0.19;
1787 if(mRun15Slew && tot<15.) {
1789 tofcorr -= SLEWCORR;
1792 tofcorr -= (SLEWCORR/4.)*(15.-tot)*(15.-tot);
1796 if(mRun15Slew && tot>19. && tot<26.) {
1797 double delta = (22.5-tot)/3.5;
1798 tofcorr += .110*(1.0-delta*delta);
1801 if (mRun15Slew) LOG_DEBUG <<
" Corrected tof (Run15Slew): tofcorr = " << tofcorr << endm;
1808 void StBTofCalibMaker::tstart(
const Double_t vz, Double_t *tstart, Double_t *tdiff)
1810 if ( mForceTStartZero ){
1817 if(fabs(vz)>200.) {LOG_INFO <<
"tstart: vz too big" << endm;
return;}
1819 Double_t TSum = mTSumEast + mTSumWest;
1821 if(mNEast+mNWest>0) {
1822 *tstart = (TSum-(mNEast-mNWest)*vz/(C_C_LIGHT/1.e9))/(mNEast+mNWest);
1824 if ( mNEast>=mVPDEastHitsCut && mNWest>=mVPDWestHitsCut ) {
1825 *tdiff = (mTSumEast/mNEast - mTSumWest/mNWest)/2. - vz/(C_C_LIGHT/1.e9);
1834 if ( mForceTStartZero ){
1840 if(!btofColl)
return;
1842 const StSPtrVecBTofHit &tofHits = btofColl->tofHits();
1846 Double_t tCanFirst = 99999.;
1847 Double_t tCanLast = -99999.;
1849 memset(t0, 0.,
sizeof(t0));
1850 for(
size_t i=0;i<tofHits.size();i++) {
1855 if ( aHit->qaTruth() == 1 ) {
1859 int trayId = aHit->tray();
1860 if(trayId>0&&trayId<=mNTray) {
1862 if(!gTrack)
continue;
1864 if(!pTrack)
continue;
1865 if(pTrack->vertex() != pVtx)
continue;
1867 double ptot = mom.mag();
1868 int q = pTrack->geometry()->charge();
1871 static StPionPlus* Pion = StPionPlus::instance();
1872 static StProton* Proton = StProton::instance();
1873 static StKaonPlus* Kaon = StKaonPlus::instance();
1874 static StElectron* Electron = StElectron::instance();
1877 double nSigPi = -999.;
1878 double nSigP = -999.;
1879 double nSigKaon = -999.;
1880 double nSigElectron = -999.;
1881 float nHitsDedx = 0.;
1884 nSigPi = PidAlgorithm.numberOfSigma(Pion);
1885 nSigP = PidAlgorithm.numberOfSigma(Proton);
1886 nSigKaon = PidAlgorithm.numberOfSigma(Kaon);
1887 nSigElectron = PidAlgorithm.numberOfSigma(Electron);
1889 nHitsDedx = PidAlgorithm.traits()->numberOfPoints();
1892 float nHitsFit = pTrack->fitTraits().numberOfFitPoints();
1893 float nHitsPoss = pTrack->numberOfPossiblePoints();
1895 double pT = mom.perp();
1896 double eta = mom.pseudoRapidity();
1897 double zVtx = pVtx->position().z();
1899 const StPtrVecTrackPidTraits& theTofPidTraits = pTrack->pidTraits(kTofId);
1900 if(!theTofPidTraits.size())
continue;
1902 StTrackPidTraits *theSelectedTrait = theTofPidTraits[theTofPidTraits.size()-1];
1903 if(!theSelectedTrait)
continue;
1906 if(!pidTof)
continue;
1908 double tot = aHit->tot();
1909 double tof = aHit->leadingEdgeTime();
1910 double zhit = pidTof->zLocal();
1912 int moduleChan = (aHit->module()-1)*6 + (aHit->cell()-1);
1913 Double_t tofcorr = tof;
1915 tofcorr = tofAllCorr(tof, tot, zhit, trayId, moduleChan);
1917 if(tofcorr<0.)
continue;
1921 double L = tofPathLength(&primPos, &pidTof->position(), helix.curvature());
1922 double tofPi = L*sqrt(M_PION_PLUS*M_PION_PLUS+ptot*ptot)/(ptot*(C_C_LIGHT/1.e9));
1923 double tofP = L*sqrt(M_PROTON*M_PROTON+ptot*ptot)/(ptot*(C_C_LIGHT/1.e9));
1928 if(( (q<0 && ptot>0.2) || (q>0 && ptot>0.2 && ptot<1.0)) && fabs(nSigPi)<2.0)
1930 tSum += tofcorr - tofPi;
1931 t0[nCan] = tofcorr - tofPi;
1934 else if(q>0 && fabs(nSigP)<2.0)
1936 tSum += tofcorr - tofP;
1937 t0[nCan] = tofcorr - tofP;
1941 else if(mPPPAMode || mPPPAPionSel)
1945 if(!dcaGeometry)
continue;
1946 Double_t vtx[3] = {primPos[0], primPos[1], primPos[2]};
1948 thelix.
Move(thelix.Path(vtx));
1949 const Double_t *pos = thelix.Pos();
1951 double gDcaMag = gDca.mag();
1955 if(ptot>0.2 && ptot<0.7 && fabs(nSigPi)< 2.0
1957 && nHitsFit>0.51*nHitsPoss
1958 && nHitsDedx>0.5*nHitsFit
1959 && fabs(gDcaMag)<2.0
1961 && nSigElectron<-3.0
1965 double FDGCNST = fudgeFactor(eta, zVtx);
1966 double nvrsBeta = sqrt(1.+(M_PION_PLUS/ptot)*(M_PION_PLUS/ptot));
1967 double bthBlchFrml = nvrsBeta*nvrsBeta*(BTHBLCHCNST+2.*log(ptot/M_PION_PLUS));
1968 double dTofPi = FDGCNST*L*L*((M_PION_PLUS/ptot)*(M_PION_PLUS/ptot)*(1./ptot)*bthBlchFrml);
1969 Double_t tofCorrPi = tofcorr - tofPi - dTofPi;
1970 if(tofCorrPi < tCanFirst) {
1971 tCanFirst = tofCorrPi;
1973 if(tofCorrPi > tCanLast) {
1974 tCanLast = tofCorrPi;
1977 t0[nCan] = tofCorrPi;
1983 if(ptot>0.2 && ptot<0.6 && fabs(nSigPi)< 2.0)
1985 tSum += tofcorr - tofPi;
1986 t0[nCan] = tofcorr - tofPi;
1995 mTCanFirst = tCanFirst;
1996 mTCanLast = tCanLast;
2003 Int_t nTzero = nCan;
2005 if(mPPPAMode || mPPPAOutlierRej || mFXTMode)
2007 const float outlierCut = 2.5 * 0.086;
2011 double DtiMax = 0.0;
2012 for(
int i=0;i<nTzero;i++) {
2013 double tdiff = fabs(t0[i] - (tSum-t0[i])/(nTzero-1));
2019 if(DtiMax>sqrt(1.0+1.0/(nTzero-1))*outlierCut) {
2021 t0[iMax] = t0[nTzero-1];
2029 if(fabs(t0[0]-t0[1])>sqrt(2.0)*outlierCut) {
2033 float vpdTDiffCut = 0.25;
2035 double vpdStartTime = 0.;
2036 Double_t vz = pVtx->position().z();
2037 vpdTStartForBTofComparison(vz, &vpdStartTime);
2038 if(fabs(t0[0]-vpdStartTime)<vpdTDiffCut && fabs(t0[1]-vpdStartTime)<vpdTDiffCut) {
2039 if(fabs(t0[0]-vpdStartTime) < fabs(t0[1]-vpdStartTime)) {
2049 else if(fabs(t0[0]-vpdStartTime)<vpdTDiffCut) {
2053 else if(fabs(fabs(t0[1]-vpdStartTime)<vpdTDiffCut)) {
2065 else if(mFXTMode && nCan == 1){
2072 for(
int i=0;i<nCan;i++) {
2073 double tdiff = t0[i] - (tSum-t0[i])/(nTzero-1);
2074 if(fabs(tdiff)>5.0) {
2084 *tstart = nTzero>0 ? tSum / nTzero : -9999.;
2092 if ( mForceTStartZero ){
2099 Int_t nBTofHits = muDst->numberOfBTofHit();
2104 Double_t tCanFirst = 99999.;
2105 Double_t tCanLast = -99999.;
2106 Double_t gDCA[5000];
2107 Double_t ptotSave[5000];
2108 Double_t etaSave[5000];
2110 memset(t0, 0.,
sizeof(t0));
2112 for(
int i=0;i<nBTofHits;i++) {
2119 if ( aHit->qaTruth() == 1 ) {
2123 int trayId = aHit->tray();
2124 if(trayId>0&&trayId<=mNTray) {
2125 StMuTrack *gTrack = aHit->globalTrack();
2126 if(!gTrack)
continue;
2127 StMuTrack *pTrack = aHit->primaryTrack();
2128 if(!pTrack)
continue;
2130 if(aVtx != pVtx)
continue;
2132 double ptot = mom.mag();
2133 int q = pTrack->
charge();
2138 float nHitsFit = pTrack->
nHitsFit();
2142 double pT = pTrack->
pt();
2145 double gDcaMag = pTrack->
dcaGlobal().mag();
2146 double eta = pTrack->
eta();
2147 double zVtx = pVtx->position().z();
2151 double tot = aHit->tot();
2152 double tof = aHit->leadingEdgeTime();
2153 double zhit = pidTof.zLocal();
2155 int moduleChan = (aHit->module()-1)*6 + (aHit->cell()-1);
2157 Double_t tofcorr = tof;
2159 tofcorr = tofAllCorr(tof, tot, zhit, trayId, moduleChan);
2162 calibfailed++;
continue;
2165 if(tofcorr<0.)
continue;
2169 double L = tofPathLength(&primPos, &pidTof.position(), helix.curvature());
2170 double tofPi = L*sqrt(M_PION_PLUS*M_PION_PLUS+ptot*ptot)/(ptot*(C_C_LIGHT/1.e9));
2171 double tofP = L*sqrt(M_PROTON*M_PROTON+ptot*ptot)/(ptot*(C_C_LIGHT/1.e9));
2176 if(( (q<0 && ptot>0.2) || (q>0 && ptot>0.2 && ptot<1.0)) && fabs(nSigPi)<2.0)
2178 tSum += tofcorr - tofPi;
2179 t0[nCan] = tofcorr - tofPi;
2182 else if(q>0 && fabs(nSigP)<2.0)
2184 tSum += tofcorr - tofP;
2185 t0[nCan] = tofcorr - tofP;
2191 else if(mPPPAMode || mPPPAPionSel)
2196 if(ptot>0.2 && ptot<0.7 && fabs(nSigPi)< 2.0
2198 && nHitsFit>0.51*nHitsPoss
2199 && nHitsDedx>0.5*nHitsFit
2200 && fabs(gDcaMag)<2.0
2202 && nSigElectron<-3.0
2205 double FDGCNST = fudgeFactor(eta, zVtx);
2206 double nvrsBeta = sqrt(1.+(M_PION_PLUS/ptot)*(M_PION_PLUS/ptot));
2207 double bthBlchFrml = nvrsBeta*nvrsBeta*(BTHBLCHCNST+2.*log(ptot/M_PION_PLUS));
2208 double dTofPi = FDGCNST*L*L*((M_PION_PLUS/ptot)*(M_PION_PLUS/ptot)*(1./ptot)*bthBlchFrml);
2209 Double_t tofCorrPi = tofcorr - tofPi - dTofPi;
2210 if(tofCorrPi < tCanFirst) {
2211 tCanFirst = tofCorrPi;
2213 if(tofCorrPi > tCanLast) {
2214 tCanLast = tofCorrPi;
2217 t0[nCan] = tofCorrPi;
2218 gDCA[nCan] = gDcaMag;
2219 ptotSave[nCan] = ptot;
2220 etaSave[nCan] = eta;
2226 if(ptot>0.2 && ptot<0.6 && fabs(nSigPi)< 2.0)
2228 tSum += tofcorr - tofPi;
2229 t0[nCan] = tofcorr - tofPi;
2237 if (calibfailed) LOG_WARN <<
"tstart_NoVpd calibrations failures: " << calibfailed <<
" (out of "<< nBTofHits <<
"BTOF hits)"<< endm;
2240 mTCanFirst = tCanFirst;
2241 mTCanLast = tCanLast;
2249 Int_t nTzero = nCan;
2252 if(mPPPAMode || mPPPAOutlierRej || mFXTMode)
2256 hGDcaArray[0]->Fill(fabs(gDCA[0]));
2259 for(
int i=0;i<nCan;i++) {
2260 hGDcaArray[1]->Fill(fabs(gDCA[i]));
2264 for(
int i=0;i<nCan;i++) {
2265 hGDcaArray[2]->Fill(fabs(gDCA[i]));
2269 const float outlierCut = 2.5 * 0.086;
2273 double DtiMax = 0.0;
2274 for(
int i=0;i<nTzero;i++) {
2275 double tdiff = fabs(t0[i] - (tSum-t0[i])/(nTzero-1));
2281 if(DtiMax>sqrt(1.0+1.0/(nTzero-1))*outlierCut) {
2283 t0[iMax] = t0[nTzero-1];
2284 gDCA[iMax] = gDCA[nTzero-1];
2285 ptotSave[iMax] = ptotSave[nTzero-1];
2286 etaSave[iMax] = etaSave[nTzero-1];
2294 if(fabs(t0[0]-t0[1])>sqrt(2.0)*outlierCut) {
2298 float vpdTDiffCut = 0.25;
2300 double vpdStartTime = 0.;
2301 Double_t vz = pVtx->position().z();
2302 vpdTStartForBTofComparison(vz, &vpdStartTime);
2303 if(fabs(t0[0]-vpdStartTime)<vpdTDiffCut && fabs(t0[1]-vpdStartTime)<vpdTDiffCut) {
2304 if(fabs(t0[0]-vpdStartTime) < fabs(t0[1]-vpdStartTime)) {
2312 ptotSave[0] = ptotSave[1];
2313 etaSave[0] = etaSave[1];
2317 else if(fabs(t0[0]-vpdStartTime)<vpdTDiffCut) {
2321 else if(fabs(fabs(t0[1]-vpdStartTime)<vpdTDiffCut)) {
2325 ptotSave[0] = ptotSave[1];
2326 etaSave[0] = etaSave[1];
2336 else if(mFXTMode && nCan == 1){
2343 for(
int i=0;i<nCan;i++) {
2344 double tdiff = t0[i] - (tSum-t0[i])/(nTzero-1);
2345 if(fabs(tdiff)>5.0) {
2355 *tstart = nTzero>0 ? tSum / nTzero : -9999.;
2359 for(
int i=0;i<nTzero; i++) {
2360 double Dti = t0[i] - (tSum-t0[i])/(nTzero-1);
2362 hDtiArray[9]->Fill(Dti);
2365 hDtiArray[nTzero-2]->Fill(Dti);
2373 double rVtx = pVtx->position().perp();
2374 double zVtx = pVtx->position().z();
2375 if(nTzero>4 && (fabs(rVtx)<1. || (fabs(zVtx-200.)<3. && fabs(rVtx)<3.))) {
2376 fillDtiVsPtotProfiles(etaSave[i], zVtx, ptotSave[i], Dti);
2381 for(
int i=0;i<nTzero;i++) {
2382 hGDcaArray[3]->Fill(fabs(gDCA[i]));
2386 for(
int i=0;i<nTzero;i++) {
2387 hGDcaArray[4]->Fill(fabs(gDCA[i]));
2397 void StBTofCalibMaker::vpdTStartForBTofComparison(Double_t vz, Double_t *vpdStartTime)
2400 *vpdStartTime = -9999.0;
2403 double vzNs = vz/mC_Light;
2406 Double_t vpdHitTStart[38];
2409 int nVpdTotCandHits = 0;
2412 for(
int i=0; i<19; i++) {
2413 double vpdTime = mBTofHeader->vpdTime(west,i+1);
2418 vpdHitTStart[nVpdTotCandHits] = vpdTime + vzNs - DEDXTCORR[iYr];
2420 tSum += vpdHitTStart[nVpdTotCandHits];
2425 for(
int i=0; i<19; i++) {
2426 double vpdTime = mBTofHeader->vpdTime(east,i+1);
2431 vpdHitTStart[nVpdTotCandHits] = vpdTime - vzNs - DEDXTCORR[iYr];
2433 tSum += vpdHitTStart[nVpdTotCandHits];
2438 if(nVpdTotCandHits<1) {
2442 *vpdStartTime = -9999.0;
2446 Int_t nVpdTzero = nVpdTotCandHits;
2448 const float vpdTStartOulierCut = 2.5*0.130;
2450 if(nVpdTotCandHits>1) {
2451 while(nVpdTzero>2) {
2453 double vpdDtiMax = 0.;
2454 for(
int i=0; i<nVpdTzero; i++) {
2455 double vpdTdiff = fabs(vpdHitTStart[i] - (tSum-vpdHitTStart[i])/(nVpdTzero-1));
2456 if(vpdTdiff>vpdDtiMax) {
2458 vpdDtiMax = vpdTdiff;
2461 if(vpdDtiMax > sqrt(1.0+1.0/(nVpdTzero-1))*vpdTStartOulierCut) {
2462 tSum -= vpdHitTStart[iVpdMax];
2463 vpdHitTStart[iVpdMax] = vpdHitTStart[nVpdTzero-1];
2472 if(fabs(vpdHitTStart[0]-vpdHitTStart[1]) > sqrt(2.0)*vpdTStartOulierCut) {
2478 *vpdStartTime = nVpdTzero>0 ? tSum/nVpdTzero : -9999.;
2482 double StBTofCalibMaker::fudgeFactor(
double eta,
double zVtx)
2484 double ffArr[2][22] = {
2485 {6.1e-8, 6.95e-8, 7.9e-8, 11.2e-8, 14.7e-8, 13.2e-8, 10.7e-8, 8.8e-8, 8.21e-8, 8.31e-8, 9.01e-8, 8.31e-8, 7.2e-8, 9.e-8, 8.8e-8, 12.e-8, 8.9e-8, 6.e-8, 5.1e-8, 4.7e-8, 5.9e-8, 3.3e-8},
2486 {4.0e-8, 3.25e-8, 4.45e-8, 4.75e-8, 4.1e-8, 3.6e-8, 3.8e-8, 3.7e-8, 3.6e-8, 3.5e-8, 3.8e-8, 3.7e-8, 3.5e-8, 3.8e-8, 3.3e-8, 4.0e-8, 4.4e-8, 4.5e-8, 2.7e-8, 3.5e-8, 4.83e-8, 3.3e-8}
2493 else if(zVtx<-50.) {
2496 else if(zVtx<-30.) {
2499 else if(zVtx<-10.) {
2506 FF = ffArr[iYr][10];
2509 FF = ffArr[iYr][12];
2512 FF = ffArr[iYr][14];
2515 FF = ffArr[iYr][16];
2518 FF = ffArr[iYr][18];
2522 FF = ffArr[iYr][20];
2525 FF = ffArr[iYr][21];
2533 else if(zVtx<-50.) {
2536 else if(zVtx<-30.) {
2539 else if(zVtx<-10.) {
2546 FF = ffArr[iYr][11];
2549 FF = ffArr[iYr][13];
2552 FF = ffArr[iYr][15];
2555 FF = ffArr[iYr][17];
2558 FF = ffArr[iYr][19];
2561 FF = ffArr[iYr][21];
2568 void StBTofCalibMaker::fillDtiVsPtotProfiles(
double eta,
double zVtx,
double ptot,
double Dti)
2576 else if(zVtx<-50.) {
2579 else if(zVtx<-30.) {
2582 else if(zVtx<-10.) {
2600 else if(fabs(zVtx-200.)<3.){
2624 hDtiVsPtot[zIdx][etaIdx]->Fill(ptot, Dti);
2628 void StBTofCalibMaker::archiveVpdHitInfo()
2630 if(!mBTofHeader)
return;
2631 if(mEvtVtxZ<-999.)
return;
2633 const double SIGMA = 0.13;
2636 double vzNs = mEvtVtxZ/mC_Light;
2643 double wEarlHit = 99999.;
2644 double eEarlHit = 99999.;
2646 double wClosestHit = 99999.;
2647 double wClosestDiff = 99999.;
2648 double eClosestHit = 99999.;
2649 double eClosestDiff = 99999.;
2651 double wLateHit = -99999.;
2652 double eLateHit = -99999.;
2654 for(
int i=0; i<mNVPD; i++) {
2655 double wHitTime = mBTofHeader->vpdTime(west,i+1);
2656 if(wHitTime<1.e-4) {
2660 double wHitTimeCorr = wHitTime + vzNs - DEDXTCORR[iYr];
2661 if(wHitTimeCorr<wEarlHit) {
2662 wEarlHit = wHitTimeCorr;
2664 if(wHitTimeCorr>wLateHit) {
2665 wLateHit = wHitTimeCorr;
2667 if(mTStart>-1000.) {
2668 double wHitTDiff = wHitTimeCorr - mTStart;
2669 if(fabs(wHitTDiff)<dist*SIGMA) {
2672 if(fabs(wHitTDiff)<fabs(wClosestDiff)) {
2673 wClosestDiff = wHitTDiff;
2674 wClosestHit = wHitTimeCorr;
2679 for(
int i=0; i<mNVPD; i++) {
2680 double eHitTime = mBTofHeader->vpdTime(east,i+1);
2681 if(eHitTime<1.e-4) {
2685 double eHitTimeCorr = eHitTime - vzNs - DEDXTCORR[iYr];
2686 if(eHitTimeCorr<eEarlHit) {
2687 eEarlHit = eHitTimeCorr;
2689 if(eHitTimeCorr>eLateHit) {
2690 eLateHit = eHitTimeCorr;
2692 if(mTStart>-1000.) {
2693 double eHitTDiff = eHitTimeCorr - mTStart;
2694 if(fabs(eHitTDiff)<dist*SIGMA) {
2697 if(fabs(eHitTDiff)<fabs(eClosestDiff)) {
2698 eClosestDiff = eHitTDiff;
2699 eClosestHit = eHitTimeCorr;
2704 mEarliestVpdEHit = eEarlHit;
2705 mClosestVpdEHit = eClosestHit;
2706 mLatestVpdEHit = eLateHit;
2708 mEarliestVpdWHit = wEarlHit;
2709 mClosestVpdWHit = wClosestHit;
2710 mLatestVpdWHit = wLateHit;
2712 mVpdEGoodHits = goodEHits;
2713 mVpdWGoodHits = goodWHits;
2714 mVpdEHits = eHitCan;
2715 mVpdWHits = wHitCan;
2721 void StBTofCalibMaker::bookHistograms()
2723 hEventCounter =
new TH1D(
"eventCounter",
"eventCounter",20,0,20);
2727 void StBTofCalibMaker::writeHistograms()
2730 TFile *theHistoFile =
new TFile(mHistoFileName.c_str(),
"RECREATE");
2731 LOG_INFO <<
"StBTofCalibMaker::writeHistograms()"
2732 <<
" histogram file " << mHistoFileName << endm;
2737 hEventCounter->Write();
2743 void StBTofCalibMaker::bookPPPAHistograms()
2745 for(
int i=0;i<10;i++) {
2746 ostringstream histogramName;
2747 ostringstream histogramTitle;
2751 histogramName <<
"DtiDistFornTzeroGreater10";
2752 histogramTitle <<
"Dti Dist. For nTzero > 10";
2756 histogramName <<
"DtiDistFornTzero" << i+2;
2757 histogramTitle <<
"Dti Dist. for nTzero " << i+2;
2759 hDtiArray[i] =
new TH1D(histogramName.str().c_str(), histogramTitle.str().c_str(), 200, -1.0, 1.0);
2762 for(
int i=0;i<5;i++) {
2763 ostringstream histogramName;
2764 ostringstream histogramTitle;
2767 histogramName <<
"gDCABeforeOutlierRejectionForNCan" << i+1;
2768 histogramTitle <<
"|gDCA| Before Outlier Rejection For nCan = " << i+1;
2771 histogramName <<
"gDCABeforeOutlierRejectionForNCanGreater2";
2772 histogramTitle <<
"|gDCA| Before Outlier Rejection For nCan > 2";
2775 histogramName <<
"gDCAAfterOutlierRejectionForNCan2";
2776 histogramTitle <<
"|gDCA| After Outlier Rejection For nCan = 2";
2779 histogramName <<
"gDCAAfterOutlierRejectionForNCanGreater2";
2780 histogramTitle <<
"|gDCA| After Outlier Rejection Ror nCan > 2";
2782 hGDcaArray[i] =
new TH1D(histogramName.str().c_str(), histogramTitle.str().c_str(), 200, 0., 2.5);
2785 string zVertLocation[11] = {
"z_{vtx}#LT-75",
"-75#leqz_{vtx}#LT-50",
"-50#leqz_{vtx}#LT-30",
"-30#leqz_{vtx}#LT-10",
"-10#leqz_{vtx}#LT0",
"0#leqz_{vtx}#LT10",
"10#leqz_{vtx}#LT30",
"30#leqz_{vtx}#LT50",
"50#leqz_{vtx}#LT75",
"z_{vtx}#geq75 (excluding |z_{vtx}-200|<3)",
"|z_{vtx}-200|<3"};
2786 string trkEta[4] = {
"#eta#leq0",
"#eta>0",
"#eta#LT-1",
"#eta#geq-1"};
2787 for(
int i=0; i<11; i++) {
2788 for(
int j=0; j<2; j++) {
2789 ostringstream histogramName;
2790 ostringstream histogramTitle;
2793 histogramName <<
"hDtiVsPtot_" << i << j;
2794 histogramTitle <<
"Dti vs. pTot " << zVertLocation[i] <<
" " << trkEta[2];
2796 else if(i==10 && j==1) {
2797 histogramName <<
"hDtiVsPtot_" << i << j;
2798 histogramTitle <<
"Dti vs. pTot " << zVertLocation[i] <<
" " << trkEta[3];
2801 histogramName <<
"hDtiVsPtot_" << i << j;
2802 histogramTitle <<
"Dti vs. pTot " << zVertLocation[i] <<
" " << trkEta[j];
2805 hDtiVsPtot[i][j] =
new TProfile(histogramName.str().c_str(), histogramTitle.str().c_str(), 50, 0.2, 0.7, -1.0, 1.0);
2811 void StBTofCalibMaker::writePPPAHistograms()
2814 TFile *thePPPAHistoFile =
new TFile(mPPPAModeHistoFileName.c_str(),
"RECREATE");
2816 thePPPAHistoFile->cd();
2819 for(
int i=0;i<10;i++) {
2820 hDtiArray[i]->Write();
2822 for(
int i=0;i<5;i++) {
2823 hGDcaArray[i]->Write();
2825 for(
int i=0; i<11; i++) {
2826 for(
int j=0; j<2; j++) {
2827 hDtiVsPtot[i][j]->Write();
2836 float StBTofCalibMaker::tofCellResolution(
const Int_t itray,
const Int_t iModuleChan)
2838 float resolution(0.013);
2839 if (itray<0){
return resolution;}
2841 int module = iModuleChan/6 + 1;
2842 int cell = iModuleChan%6 + 1;
2844 float stop_resolution = mBTofRes->
timeres_tof(itray, module, cell)/1000.;
2846 float start_resolution = 0.0;
2848 start_resolution = mVpdResConfig->
singleTubeRes(mVPDHitPatternEast, mVPDHitPatternWest)/1000.;
2850 start_resolution = mBTofRes->average_timeres_tof()/sqrt(mNTzero)/1000.;
2851 resolution = sqrt(stop_resolution*stop_resolution + start_resolution*start_resolution);
static StMuPrimaryVertex * primaryVertex()
return pointer to current primary vertex
void setVPDHitsCut(const Int_t, const Int_t)
switch to set the VPD # of hits cut
static StMuBTofHit * btofHit(int i)
returns pointer to the i-th muBTofHit
static TObjArray * globalTracks()
returns pointer to the global tracks list
double timeres_tof(unsigned int itray, unsigned int imodule, unsigned int icell)
Int_t vertexIndex() const
Returns index of associated primary vertex.
virtual Int_t InitRun(int)
pair< double, double > pathLengths(const StHelix &, double minStepSize=10 *micrometer, double minRange=10 *centimeter) const
path lengths at dca between two helices
Double_t pt() const
Returns pT at point of dca to primary vertex.
UShort_t nHitsDedx() const
Return number of hits used for dEdx.
void setHistoFileName(const Char_t *)
set histogram output file name
Bool_t useVpdStart() const
function for tofCalibMaker to know whether to use VPD as the start or not
void setOuterGeometry(const bool val=kTRUE)
switch to select the Helix Geometry
StPhysicalHelixD helix() const
Returns inner helix (first measured point)
UShort_t nHitsFit() const
Return total number of hits used in fit.
void loadParams(const int runNumber=20076002)
Loads BTOF Sim Params from database.
Short_t charge() const
Returns charge.
Double_t nSigmaPion() const
Returns Craig's distance to the calculated dE/dx band for pions in units of sigma.
Double_t eta() const
Returns pseudo rapidity at point of dca to primary vertex.
static TObjArray * primaryTracks()
returns pointer to a list of tracks belonging to the selected primary vertex
StBTofCalibMaker(const char *name="btofCalib")
Default constructor.
Double_t nSigmaElectron() const
Returns Craig's distance to the calculated dE/dx band for electrons in units of sigma.
UShort_t nHitsPoss() const
Return number of possible hits on track.
const StThreeVectorF & momentum() const
Returns 3-momentum at dca to primary vertex.
virtual ~StBTofCalibMaker()
Destructor.
static StBTofHeader * btofHeader()
returns pointer to the btofHeader - dongx
Double_t nSigmaProton() const
Returns Craig's distance to the calculated dE/dx band for protons in units of sigma.
StThreeVectorF dcaGlobal(Int_t vtx_id=-1) const
Returns 3D distance of closest approach to primary vertex of associated global track.
Double_t nSigmaKaon() const
Returns Craig's distance to the calculated dE/dx band for kaons in units of sigma.
double Move(double step)
Move along helix.
void loadVpdSimParams(const int date=20160913, const int time=175725, const char *Default_time="2016-09-13 17:57:25")
Loads Vpd Sim Params from database.
double singleTubeRes(UInt_t mVPDHitPatternEast, UInt_t mVPDHitPatternWest)
Calculate correct resolution based on those tubes that were used.
void setCreateHistoFlag(Bool_t histos=kTRUE)
enable QA histogram filling
virtual TDataSet * Find(const char *path) const