StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StFttHitCalibMaker.cxx
1 #include "StFttHitCalibMaker.h"
2 
3 // #include "StFttRawHitMaker/StFttRawHitMaker.h"
4 
5 #include "StEvent/StFttRawHit.h"
6 #include "StEvent/StEvent.h"
7 #include "StEvent/StFttCollection.h"
8 
9 #include "StEvent/StFttCluster.h"
10 
11 #include "StFttDbMaker/StFttDb.h"
12 
13 #include "TFile.h"
14 #include "TCanvas.h"
15 
16 #include <set>
17 //_____________________________________________________________
19 StMaker("fttHitCalib",name), mHelper(nullptr)
20 {
21  LOG_DEBUG << "StFttHitCalibMaker::ctor" << endm;
22  mHelper = new HitCalibHelper();
23 }
24 //_____________________________________________________________
25 StFttHitCalibMaker::~StFttHitCalibMaker()
26 {
27  if(mHelper) delete mHelper;
28  mHelper = nullptr;
29 }
30 
31 //_____________________________________________________________
32 Int_t StFttHitCalibMaker::Init()
33 {
34  LOG_INFO << "StFttHitCalibMaker::Init" << endm;
35  return kStOk;
36 }
37 //_____________________________________________________________
38 Int_t StFttHitCalibMaker::InitRun(Int_t runnumber)
39 {
40  mHelper->clear();
41  return kStOk;
42 }
43 
44 //_____________________________________________________________
45 Int_t StFttHitCalibMaker::FinishRun(Int_t runnumber)
46 {
47  return kStOk;
48 }
49 
50 //-------------------------------------------------------------
52 {
53  LOG_INFO << "StFttHitCalibMaker::Finish()" << endm;
54 
55  if (this->mCalibMode == StFttHitCalibMaker::CalibMode::Calibration) {
56  LOG_INFO << "Writing StFttHitCalib parameters to plaintext: " << endm;
57  WriteCalibrationToPlainText();
58  }
59 
60  return kStOk;
61 }
62 
63 
64 void StFttHitCalibMaker::WriteCalibrationToPlainText() {
65 
66  ofstream outf( "fttRawHitTime.dat" );
67  for ( int uuid = 0; uuid <= 400; uuid++ ){
68  Short_t anchor = mHelper->anchor( uuid );
69  auto hist = mHelper->histFor( uuid );
70  size_t counts = hist.size();
71  size_t samples = mHelper->samples( uuid );
72  outf << TString::Format( "%d\t%d\t%lu\t%lu", uuid, (int) anchor, counts, samples ) << endl;
73  }
74  outf.close();
75 
76 }
77 
78 //_____________________________________________________________
80 {
81  LOG_INFO << "StFttHitCalibMaker::Make()" << endm;
82 
83  mEvent = (StEvent*)GetInputDS("StEvent");
84  if(mEvent) {
85  LOG_DEBUG<<"Found StEvent"<<endm;
86  } else {
87  return kStOk;
88  }
89  mFttCollection=mEvent->fttCollection();
90  if(!mFttCollection) {
91  return kStOk;
92  } else {
93  LOG_DEBUG <<"Found StFttCollection"<<endm;
94  }
95 
96  mFttDb = static_cast<StFttDb*>(GetDataSet("fttDb"));
97 
98 
99  for ( auto rawHit : mFttCollection->rawHits() ) {
100 
101  UShort_t fob = (UShort_t)mFttDb->fob( rawHit );
102  UShort_t uuid = rawHit->vmm() + ( StFttDb::nVMMPerFob * fob );
103 
104  mHelper->fill( uuid, rawHit->dbcid() );
105 
106  if ( mHelper->ready( uuid ) ){
107  rawHit->setTime( mHelper->time( uuid, rawHit->dbcid()) );
108  } else {
109  rawHit->setTime( -4097 );
110  }
111  }
112 
113  return kStOk;
114 }
StFttHitCalibMaker(const char *name="fttHitCalib")
Default constructor.
Definition: Stypes.h:41