18 #include "StEvent/StFstConsts.h"
19 #include "StIOMaker/StIOMaker.h"
20 #include "StFstCalibrationMaker.h"
21 #include "StRoot/StFstUtil/StFstCollection.h"
22 #include "StRoot/StFstUtil/StFstRawHitCollection.h"
23 #include "StEvent/StFstRawHit.h"
24 #include "StRoot/StFstDbMaker/StFstDb.h"
26 #include "tables/St_fstMapping_Table.h"
27 #include "tables/St_fstControl_Table.h"
32 const string StFstCalibrationMaker::sectionLabel[72]={
"1I",
"1O",
"2I",
"2O",
"3I",
"3O",
"4I",
"4O",
"5I",
"5O",
"6I",
"6O",
"7I",
"7O",
"8I",
"8O",
"9I",
"9O",
"10I",
"10O",
"11I",
"11O",
"12I",
"12O",
"13I",
"13O",
"14I",
"14O",
"15I",
"15O",
"16I",
"16O",
"17I",
"17O",
"18I",
"18O",
"19I",
"19O",
"20I",
"20O",
"21I",
"21O",
"22I",
"22O",
"23I",
"23O",
"24I",
"24O",
"25I",
"25O",
"26I",
"26O",
"27I",
"27O",
"28I",
"28O",
"29I",
"29O",
"30I",
"30O",
"31I",
"31O",
"32I",
"32O",
"33I",
"33O",
"34I",
"34O",
"35I",
"35O",
"36I",
"36O"};
35 StFstCalibrationMaker::StFstCalibrationMaker(
const char* name ) :
StMaker( name ), mTimeBinMask(0xFF), mRunHist(true), mDoPedCut(true), evtIdx(0), mHasFinished(0), mFstDb(0), mDoOutput(false) {
36 for(
unsigned char iTb=0; iTb<kFstNumTimeBins; iTb++) {
37 hist_meanPed[iTb] = NULL;
38 hist_rmsPed[iTb] = NULL;
39 hist_cmNoise[iTb] = NULL;
40 hist_ranNoise[iTb] = NULL;
41 hist_sumPed[iTb] = NULL;
42 hist_sumRms[iTb] = NULL;
43 hist_sumCmn[iTb] = NULL;
44 hist_sumRan[iTb] = NULL;
45 hist_adcSpectrum[iTb] = NULL;
48 mPedVec1stLoop.resize(kFstNumTimeBins*kFstNumElecIds);
49 mRmsVec1stLoop.resize(kFstNumTimeBins*kFstNumElecIds);
50 mRanVec1stLoop.resize(kFstNumTimeBins*kFstNumElecIds);
52 mMathPedVec.resize(kFstNumTimeBins*kFstNumElecIds);
53 mMathRmsVec.resize(kFstNumTimeBins*kFstNumElecIds);
54 mMathCouVec.resize(kFstNumTimeBins*kFstNumElecIds);
56 mMathRanVec.resize(kFstNumTimeBins*kFstNumElecIds);
57 mMathPedRanVec.resize(kFstNumTimeBins*kFstNumElecIds);
58 mMathRmsRanVec.resize(kFstNumTimeBins*kFstNumElecIds);
59 mMathCouRanVec.resize(kFstNumTimeBins*kFstNumElecIds);
63 mHistPedVec.assign( kFstNumTimeBins*kFstNumElecIds, (TH1S*)0 );
64 mHistRanVec.assign( kFstNumTimeBins*kFstNumElecIds, (TH1F*)0 );
67 mHistCmnVec.assign( kFstNumTimeBins*kFstNumApvs*kFstNumRStripsPerSensor, (TH1F*)0 );
68 mPedVec.resize( kFstNumTimeBins*kFstNumElecIds );
69 mCmnVec.resize( kFstNumTimeBins*kFstNumApvs*kFstNumRStripsPerSensor );
71 mMappingVec.resize( kFstNumElecIds );
75 StFstCalibrationMaker::~StFstCalibrationMaker()
77 mPedVec1stLoop.clear();
78 mRmsVec1stLoop.clear();
79 mRanVec1stLoop.clear();
86 mMathPedRanVec.clear();
87 mMathRmsRanVec.clear();
88 mMathCouRanVec.clear();
92 while (!mHistPedVec.empty())
delete mHistPedVec.back(), mHistPedVec.pop_back();
93 while (!mHistRanVec.empty())
delete mHistRanVec.back(), mHistRanVec.pop_back();
96 while (!mHistCmnVec.empty())
delete mHistCmnVec.back(), mHistCmnVec.pop_back();
104 Int_t StFstCalibrationMaker::Init()
109 for(
unsigned char iTB=0; iTB<kFstNumTimeBins; iTB++) {
110 sprintf(buffer,
"hist_meanPedestal_TimeBin%d",iTB);
111 hist_meanPed[iTB] =
new TH1F(buffer, buffer, kFstNumElecIds, 0, kFstNumElecIds);
112 hist_meanPed[iTB]->SetStats(
false);
113 hist_meanPed[iTB]->GetXaxis()->SetTitle(
"Channel Geometry Index");
114 hist_meanPed[iTB]->GetXaxis()->SetNdivisions(-72,
false);
115 hist_meanPed[iTB]->GetYaxis()->SetTitle(
"ADC count");
117 sprintf(buffer,
"hist_rmsPedestal_TimeBin%d",iTB);
118 hist_rmsPed[iTB] =
new TH1F(buffer, buffer, kFstNumElecIds, 0, kFstNumElecIds);
119 hist_rmsPed[iTB]->SetStats(
false);
120 hist_rmsPed[iTB]->GetXaxis()->SetTitle(
"Channel Geometry Index");
121 hist_rmsPed[iTB]->GetXaxis()->SetNdivisions(-72,
false);
122 hist_rmsPed[iTB]->GetYaxis()->SetTitle(
"ADC count");
124 sprintf(buffer,
"hist_cmNoise_TimeBin%d",iTB);
125 hist_cmNoise[iTB] =
new TH1F(buffer, buffer, kFstNumApvs*kFstNumRStripsPerSensor, 0, kFstNumApvs*kFstNumRStripsPerSensor);
126 hist_cmNoise[iTB]->SetStats(
false);
127 hist_cmNoise[iTB]->GetXaxis()->SetTitle(
"APV Geometry Index");
128 hist_cmNoise[iTB]->GetXaxis()->SetNdivisions(-72,
false);
129 hist_cmNoise[iTB]->GetYaxis()->SetTitle(
"ADC count");
131 sprintf(buffer,
"hist_ranNoise_TimeBin%d",iTB);
132 hist_ranNoise[iTB] =
new TH1F(buffer, buffer, kFstNumElecIds, 0, kFstNumElecIds);
133 hist_ranNoise[iTB]->SetStats(
false);
134 hist_ranNoise[iTB]->GetXaxis()->SetTitle(
"Channel Geometry Index");
135 hist_ranNoise[iTB]->GetXaxis()->SetNdivisions(-72,
false);
136 hist_ranNoise[iTB]->GetYaxis()->SetTitle(
"ADC count");
138 for(
int i=0; i<72; i++) {
139 TString binBuffer =
"";
140 binBuffer = sectionLabel[i];
141 hist_meanPed[iTB]->GetXaxis()->SetBinLabel(i*512+256, binBuffer);
142 hist_rmsPed[iTB]->GetXaxis()->SetBinLabel(i*512+256, binBuffer);
143 hist_cmNoise[iTB]->GetXaxis()->SetBinLabel(i*4+4, binBuffer);
144 hist_ranNoise[iTB]->GetXaxis()->SetBinLabel(i*512+256, binBuffer);
147 sprintf(buffer,
"hist_sumPedestal_TimeBin%d",iTB);
148 hist_sumPed[iTB] =
new TH1F(buffer, buffer, 128, 0, 4096);
149 hist_sumPed[iTB]->SetStats(kTRUE);
150 hist_sumPed[iTB]->GetXaxis()->SetTitle(
"Pedestal [ADC counts]");
151 hist_sumPed[iTB]->GetYaxis()->SetTitle(
"Counts");
153 sprintf(buffer,
"hist_sumRmsNoise_TimeBin%d",iTB);
154 hist_sumRms[iTB] =
new TH1F(buffer, buffer, 128, 0, 256);
155 hist_sumRms[iTB]->SetStats(kTRUE);
156 hist_sumRms[iTB]->GetXaxis()->SetTitle(
"RMS Noise [ADC counts]");
157 hist_sumRms[iTB]->GetYaxis()->SetTitle(
"Counts");
159 sprintf(buffer,
"hist_sumCmNoise_TimeBin%d",iTB);
160 hist_sumCmn[iTB] =
new TH1F(buffer, buffer, 128, 0, 256);
161 hist_sumCmn[iTB]->SetStats(kTRUE);
162 hist_sumCmn[iTB]->GetXaxis()->SetTitle(
"CM Noise [ADC counts]");
163 hist_sumCmn[iTB]->GetYaxis()->SetTitle(
"Counts");
165 sprintf(buffer,
"hist_sumRanNoise_TimeBin%d",iTB);
166 hist_sumRan[iTB] =
new TH1F(buffer, buffer, 128, 0, 256);
167 hist_sumRan[iTB]->SetStats(kTRUE);
168 hist_sumRan[iTB]->GetXaxis()->SetTitle(
"RAN Noise [ADC counts]");
169 hist_sumRan[iTB]->GetYaxis()->SetTitle(
"Counts");
171 sprintf(buffer,
"hist_adcSpectrum_TimeBin%d",iTB);
172 hist_adcSpectrum[iTB] =
new TH2S(buffer, buffer, kFstNumElecIds, 0, kFstNumElecIds, 512, 0, 4096);
173 hist_adcSpectrum[iTB]->SetStats(
false);
174 hist_adcSpectrum[iTB]->GetXaxis()->SetTitle(
"Channel Electronics Index");
175 hist_adcSpectrum[iTB]->GetYaxis()->SetTitle(
"ADC counts");
180 TString infile =
"fstPedNoiseTable.dat";
181 std::ifstream in(infile);
184 LOG_WARN <<
"Could not find fstPedNoiseTable.dat! Set mDoPedCut to false" << endm;
186 LOG_INFO <<
"Read Pedestal and RMS from fstPedNoiseTable.dat!"<< endm;
187 int chElecId, rdo, arm, apv, chan, chTimeBin, chCode;
188 float chPed, chRms, chRan;
190 in >> chElecId >> rdo >> arm >> apv >> chan >> chTimeBin >> chPed >> chRms >> chRan;
192 chCode = kFstNumTimeBins * chElecId + chTimeBin;
193 mPedVec1stLoop[chCode] = chPed;
194 mRmsVec1stLoop[chCode] = chRms;
195 mRanVec1stLoop[chCode] = chRan;
204 Int_t StFstCalibrationMaker::InitRun(Int_t runnumber)
214 LOG_ERROR <<
"InitRun : no fstDb" << endm;
219 const fstControl_st *fstControlTable = mFstDb->getControl();
220 if (!fstControlTable) {
221 LOG_ERROR <<
"Pointer to FST control table is null" << endm;
225 mPedCut = fstControlTable[0].kFstPedCutDefault;
228 const fstMapping_st *gM = mFstDb->getMapping();
230 LOG_ERROR <<
"Pointer to FST mapping table is null" << endm;
234 for(
int i=0; i<kFstNumElecIds; i++) {
235 LOG_DEBUG<<Form(
" Print entry %d : geoId=%d ",i,gM[0].mapping[i])<<endm;
236 mMappingVec[i] = gM[0].mapping[i];
249 LOG_WARN <<
"Make() - there is no fstDataSet (raw hits container) " << endm;
254 if(!fstCollectionPtr) {
255 LOG_WARN <<
"Make() - no fstCollection."<<endm;
261 cout <<
"event index: " << evtIdx << endl;
263 std::stringstream ss, sc;
264 int sumAdcPerEvent[kFstApvsPerWedge][kFstNumRStripsPerSensor][kFstNumTimeBins];
265 int channelCountsPerEvent[kFstApvsPerWedge][kFstNumRStripsPerSensor][kFstNumTimeBins];
266 double cmNoisePerEvent[kFstApvsPerWedge][kFstNumRStripsPerSensor][kFstNumTimeBins];
268 for(
unsigned char wedgeIdx=0; wedgeIdx<kFstNumWedges; ++wedgeIdx ){
271 for(
int i=0; i<kFstApvsPerWedge; i++) {
272 for(
int j=0; j<kFstNumRStripsPerSensor; j++) {
273 for(
int k=0; k<kFstNumTimeBins; k++) {
274 sumAdcPerEvent[i][j][k] = 0;
275 channelCountsPerEvent[i][j][k] = 0;
276 cmNoisePerEvent[i][j][k] = 0.;
281 if( rawHitCollectionPtr ){
282 std::vector<StFstRawHit*>& rawHitVec = rawHitCollectionPtr->getRawHitVec();
283 std::vector< StFstRawHit* >::iterator rawHitIter;
285 for( rawHitIter = rawHitVec.begin(); rawHitIter != rawHitVec.end(); ++rawHitIter ){
286 int elecId = (*rawHitIter)->getChannelId();
287 int geoId = (*rawHitIter)->getGeoId();
288 int apvId = elecId/kFstNumApvChannels;
289 int ChPerRdo = kFstNumArmsPerRdo*kFstNumChanPerArm;
290 int rdoIdx = elecId/ChPerRdo + 1;
291 int armIdx = (elecId - (rdoIdx-1)*ChPerRdo)/kFstNumChanPerArm;
292 int refElecChanId = elecId - (rdoIdx-1)*ChPerRdo - armIdx*kFstNumChanPerArm;
293 int refApvIdx = refElecChanId/kFstNumApvChannels;
294 int portIdx = refApvIdx/8;
295 int lclApvIdx = refApvIdx-portIdx*8;
297 if(elecId >= kFstNumElecIds || geoId >= kFstNumElecIds || apvId >= kFstNumApvs)
300 for(
unsigned char timeBin = 0; timeBin < kFstNumTimeBins; ++timeBin ){
301 Int_t adc = (*rawHitIter)->getCharge( timeBin );
303 int t = (int)timeBin;
304 if(mTimeBinMask==0) t=0;
305 int code = kFstNumTimeBins * elecId + t;
311 pass = (adc < (mPedVec1stLoop[code]+mPedCut*mRmsVec1stLoop[code]));
312 hist_adcSpectrum[t]->Fill(elecId, adc);
316 mMathPedVec[code] += adc;
317 mMathRmsVec[code] += adc*adc;
318 mMathCouVec[code] ++;
321 TH1S* histPed = mHistPedVec[ code ];
325 ss <<
"hist_Pedestal_Ch" << code / kFstNumTimeBins <<
"_TB" << code % kFstNumTimeBins;
326 histPed =
new TH1S( ss.str().data(),
"", 512, 0, kFstMaxAdc );
327 mHistPedVec[ code ] = histPed;
329 histPed->Fill( adc );
333 int rstrip = (geoId % (kFstNumInnerSensorsPerWedge * kFstNumStripsPerInnerSensor + kFstNumOuterSensorsPerWedge * kFstNumStripsPerOuterSensor))/kFstNumPhiSegPerWedge;
334 if(rstrip > 3) rstrip = rstrip-4;
335 sumAdcPerEvent[lclApvIdx][rstrip][t] += adc - mPedVec1stLoop[code];
336 channelCountsPerEvent[lclApvIdx][rstrip][t] ++;
344 for(
int i=0; i<kFstApvsPerWedge; i++) {
345 for(
int j=0; j<kFstNumRStripsPerSensor; j++) {
346 for(
int k=0; k<kFstNumTimeBins; k++) {
347 if( channelCountsPerEvent[i][j][k] ) {
348 cmNoisePerEvent[i][j][k] = (double)sumAdcPerEvent[i][j][k] / channelCountsPerEvent[i][j][k];
350 int apvId = wedgeIdx*kFstApvsPerWedge + i;
351 int groupId = apvId*kFstNumRStripsPerSensor + j;
352 int code = groupId*kFstNumTimeBins + k;
354 TH1F* histCmn = mHistCmnVec[ code ];
359 sc <<
"hist_CMNoise_APV" << apvId <<
"_R" << j <<
"_TB" << k;
360 histCmn =
new TH1F( sc.str().data(),
"", -1024, -kFstMaxAdc, kFstMaxAdc);
361 mHistCmnVec[ code ] = histCmn;
363 histCmn->Fill( cmNoisePerEvent[i][j][k] );
369 for( rawHitIter = rawHitVec.begin(); rawHitIter != rawHitVec.end(); ++rawHitIter ){
370 int elecId = (*rawHitIter)->getChannelId();
371 int geoId = (*rawHitIter)->getGeoId();
372 int apvId = elecId/kFstNumApvChannels;
373 int ChPerRdo = kFstNumArmsPerRdo*kFstNumChanPerArm;
374 int rdoIdx = elecId/ChPerRdo + 1;
375 int armIdx = (elecId - (rdoIdx-1)*ChPerRdo)/kFstNumChanPerArm;
376 int refElecChanId = elecId - (rdoIdx-1)*ChPerRdo - armIdx*kFstNumChanPerArm;
377 int refApvIdx = refElecChanId/kFstNumApvChannels;
378 int portIdx = refApvIdx/8;
379 int lclApvIdx = refApvIdx-portIdx*8;
381 if(elecId >= kFstNumElecIds || geoId >= kFstNumElecIds || apvId >= kFstNumApvs)
384 for(
unsigned char timeBin = 0; timeBin < kFstNumTimeBins; ++timeBin ){
385 Int_t adc = (*rawHitIter)->getCharge( timeBin );
387 int t = (int)timeBin;
388 if(mTimeBinMask==0) t=0;
389 int code = kFstNumTimeBins * elecId + t;
392 bool pass = (adc < (mPedVec1stLoop[code]+mPedCut*mRmsVec1stLoop[code]));
395 int rstrip = (geoId % (kFstNumInnerSensorsPerWedge * kFstNumStripsPerInnerSensor + kFstNumOuterSensorsPerWedge * kFstNumStripsPerOuterSensor))/kFstNumPhiSegPerWedge;
396 if(rstrip > 3) rstrip = rstrip-4;
398 mMathPedRanVec[code] += adc-mPedVec1stLoop[code]-cmNoisePerEvent[lclApvIdx][rstrip][t];
399 mMathRmsRanVec[code] += (adc-mPedVec1stLoop[code]-cmNoisePerEvent[lclApvIdx][rstrip][t])*(adc-mPedVec1stLoop[code]-cmNoisePerEvent[lclApvIdx][rstrip][t]);
400 mMathCouRanVec[code] ++;
403 TH1F* histRan = mHistRanVec[ code ];
407 ss <<
"hist_RanNoise_Ch" << code / kFstNumTimeBins <<
"_TB" << code % kFstNumTimeBins;
408 histRan =
new TH1F( ss.str().data(),
"", 1024, -kFstMaxAdc, kFstMaxAdc );
409 mHistRanVec[ code ] = histRan;
411 histRan->Fill( adc-mPedVec1stLoop[code]-cmNoisePerEvent[lclApvIdx][rstrip][t] );
419 while (!rawHitVec.empty())
delete rawHitVec.back(), rawHitVec.pop_back();
435 cout <<
"StFstCalibrationMaker::Finish()" << endl;
438 for(
int i=0; i<kFstNumTimeBins*kFstNumElecIds; i++) {
439 double mathPed, mathRms;
440 if(mMathCouVec[i] < 1) {
445 mathPed = mMathPedVec[i]/mMathCouVec[i];
446 mathRms = mMathRmsVec[i]/mMathCouVec[i];
449 double variance = mathRms - mathPed*mathPed;
451 mathRms = sqrt( variance );
455 mMathPedVec[i] = mathPed;
456 mMathRmsVec[i] = mathRms;
460 for(
int i=0; i<kFstNumTimeBins*kFstNumElecIds; i++) {
461 double mathPedRan, mathRmsRan;
462 if(mMathCouRanVec[i] < 1) {
467 mathPedRan = mMathPedRanVec[i]/mMathCouRanVec[i];
468 mathRmsRan = mMathRmsRanVec[i]/mMathCouRanVec[i];
471 double variance = mathRmsRan - mathPedRan*mathPedRan;
473 mathRmsRan = sqrt( variance );
477 mMathRanVec[i] = mathRmsRan;
482 std::vector< TH1S* >::iterator mHistPedVecIter;
485 for( mHistPedVecIter = mHistPedVec.begin(); mHistPedVecIter != mHistPedVec.end(); ++mHistPedVecIter ){
486 TH1S *histPed = *mHistPedVecIter;
487 elecIdx = std::distance( mHistPedVec.begin(), mHistPedVecIter );
488 short timebin = elecIdx % kFstNumTimeBins;
489 int chanIdx = elecIdx / kFstNumTimeBins;
491 int entries = histPed->GetEntries();
492 float meanPed = histPed->GetMean();
493 float rmsPed = histPed->GetRMS();
506 int geomIdx = mMappingVec[chanIdx];
507 hist_meanPed[timebin]->SetBinContent(geomIdx+1, meanPed);
508 hist_meanPed[timebin]->SetBinError(geomIdx+1, 0.);
509 hist_rmsPed[timebin]->SetBinContent(geomIdx+1, rmsPed);
510 hist_rmsPed[timebin]->SetBinError(geomIdx+1, 0.);
511 hist_sumPed[timebin]->Fill( meanPed );
512 hist_sumRms[timebin]->Fill( rmsPed );
520 std::vector< TH1F* >::iterator mHistRanVecIter;
523 for( mHistRanVecIter = mHistRanVec.begin(); mHistRanVecIter != mHistRanVec.end(); ++mHistRanVecIter ){
524 TH1F *histRan = *mHistRanVecIter;
525 elecIdx = std::distance( mHistRanVec.begin(), mHistRanVecIter );
526 short timebin = elecIdx % kFstNumTimeBins;
527 int chanIdx = elecIdx / kFstNumTimeBins;
529 int entries = histRan->GetEntries();
530 float rmsRan = histRan->GetRMS();
540 int geomIdx = mMappingVec[chanIdx];
541 hist_ranNoise[timebin]->SetBinContent(geomIdx+1, rmsRan);
542 hist_ranNoise[timebin]->SetBinError(geomIdx+1, 0.);
543 hist_sumRan[timebin]->Fill( rmsRan );
549 std::vector< TH1F* >::iterator mHistCmnVecIter;
551 for( mHistCmnVecIter = mHistCmnVec.begin(); mHistCmnVecIter != mHistCmnVec.end(); ++mHistCmnVecIter ){
552 TH1F *histCmn = *mHistCmnVecIter;
553 groupIdx = std::distance( mHistCmnVec.begin(), mHistCmnVecIter );
555 short timebin = groupIdx % kFstNumTimeBins;
556 int gouIdx = groupIdx / kFstNumTimeBins;
559 int entries = histCmn->GetEntries();
560 float cmNoise = histCmn->GetRMS();
571 hist_cmNoise[timebin]->SetBinContent(gouIdx+1, cmNoise);
572 hist_cmNoise[timebin]->SetBinError(gouIdx+1, 0.);
573 hist_sumCmn[timebin]->Fill(cmNoise);
585 Int_t StFstCalibrationMaker::saveToFile()
594 LOG_WARN <<
"StFstCalibrationMaker::Init(): No StIOMaker" << endm;
597 TString filename = TString(ioMaker->GetFile());
598 int found = filename.Last(
'/');
600 filename.Replace(0, found + 1,
"");
602 found = filename.First(
".");
603 if(found == 0) found = filename.Length();
605 TString mRootFilename = filename.Data();
606 TString mPedNoiseFilename_hist = filename.Data();
607 TString mCmNoiseFilename = filename.Data();
608 TString mPedNoiseFilename_math = filename.Data();
610 mRootFilename.Replace(found, mRootFilename.Length() - found,
".fstCaliQa.root");
611 LOG_INFO <<
"FST Calibration QA File Name: " << mRootFilename << endm;
614 TFile *myRootFile =
new TFile(mRootFilename.Data(),
"RECREATE");
616 LOG_WARN <<
"Error recreating file '" << mRootFilename <<
"'" << endl;
620 for(
unsigned char iTB=0; iTB<kFstNumTimeBins; iTB++) {
621 myRootFile->WriteTObject(hist_meanPed[iTB]);
622 myRootFile->WriteTObject(hist_rmsPed[iTB]);
623 myRootFile->WriteTObject(hist_cmNoise[iTB]);
624 myRootFile->WriteTObject(hist_ranNoise[iTB]);
625 myRootFile->WriteTObject(hist_sumPed[iTB]);
626 myRootFile->WriteTObject(hist_sumRms[iTB]);
627 myRootFile->WriteTObject(hist_sumCmn[iTB]);
628 myRootFile->WriteTObject(hist_sumRan[iTB]);
629 myRootFile->WriteTObject(hist_adcSpectrum[iTB]);
634 mPedNoiseFilename_math.Replace(found, mPedNoiseFilename_math.Length() - found,
".fstPedNoise_math.dat");
635 LOG_INFO <<
"FST Pedestal and RMS File Name using math method: " << mPedNoiseFilename_math << endm;
637 std::ofstream fout_ped_math( mPedNoiseFilename_math.Data(), std::ios_base::out & std::ios_base::trunc );
638 if( !fout_ped_math ){
639 LOG_ERROR <<
"Error opening file '" << mPedNoiseFilename_math <<
"'" << endm;
642 fout_ped_math.setf(std::ios::fixed, std::ios::floatfield);
643 fout_ped_math.precision(5);
645 for(
int i=0; i<kFstNumTimeBins*kFstNumElecIds; i++) {
647 int rdo = 0, arm = -1, apv = -1, chan = -1;
648 short timebin = i % kFstNumTimeBins;
649 int elecId = i / kFstNumTimeBins;
650 rdo = 1 + elecId/(kFstNumArmsPerRdo*kFstNumChanPerArm);
651 arm = (elecId%(kFstNumArmsPerRdo*kFstNumChanPerArm))/kFstNumChanPerArm;
652 apv = ((elecId%(kFstNumArmsPerRdo*kFstNumChanPerArm))%kFstNumChanPerArm)/kFstNumApvChannels;
653 chan = ((elecId%(kFstNumArmsPerRdo*kFstNumChanPerArm))%kFstNumChanPerArm)%kFstNumApvChannels;
655 fout_ped_math << elecId <<
' ' << rdo <<
' ' << arm <<
' ' << apv <<
' ' << chan <<
' ' << timebin <<
' ' << mMathPedVec[i] <<
' ' << mMathRmsVec[i] <<
' ' << mMathRanVec[i] << endl;
657 fout_ped_math.close();
662 sprintf(cmd,
"/bin/ln -f -s %s fstPedNoiseTable.dat", mPedNoiseFilename_math.Data());
668 mPedNoiseFilename_hist.Replace(found, mPedNoiseFilename_hist.Length() - found,
".fstPedNoise_hist.dat");
669 LOG_INFO <<
"FST Pedestal and RMS File Name using histogram method: " << mPedNoiseFilename_hist << endm;
671 std::ofstream fout_ped_hist( mPedNoiseFilename_hist.Data(), std::ios_base::out & std::ios_base::trunc );
672 if( !fout_ped_hist ){
673 LOG_ERROR <<
"Error opening file '" << mPedNoiseFilename_hist <<
"'" << endm;
676 fout_ped_hist.setf(std::ios::fixed, std::ios::floatfield);
677 fout_ped_hist.precision(5);
679 pedNoiseDataVec_t::iterator pedDataVecIter;
681 for( pedDataVecIter = mPedVec.begin(); pedDataVecIter != mPedVec.end() && !ierr; ++pedDataVecIter, ++idx ){
683 int rdo = 0, arm = -1, apv = -1, chan = -1;
684 short timebin = idx % kFstNumTimeBins;
685 int elecId = idx / kFstNumTimeBins;
686 rdo = 1 + elecId/(kFstNumArmsPerRdo*kFstNumChanPerArm);
687 arm = (elecId%(kFstNumArmsPerRdo*kFstNumChanPerArm))/kFstNumChanPerArm;
688 apv = ((elecId%(kFstNumArmsPerRdo*kFstNumChanPerArm))%kFstNumChanPerArm)/kFstNumApvChannels;
689 chan = ((elecId%(kFstNumArmsPerRdo*kFstNumChanPerArm))%kFstNumChanPerArm)%kFstNumApvChannels;
691 fout_ped_hist << elecId <<
' ' << rdo <<
' ' << arm <<
' ' << apv <<
' ' << chan <<
' ' << timebin <<
' ' << pedDataVecIter->ped <<
' ' << pedDataVecIter->rms <<
' ' << pedDataVecIter->ran << endl;
693 fout_ped_hist.close();
697 mCmNoiseFilename.Replace(found, mCmNoiseFilename.Length() - found,
".fstCmNoise.dat");
698 LOG_INFO <<
"FST Common Mode Noise File Name: " << mCmNoiseFilename << endm;
700 std::ofstream fout_cmn( mCmNoiseFilename.Data(), std::ios_base::out & std::ios_base::trunc );
702 LOG_ERROR <<
"Error opening file '" << mCmNoiseFilename <<
"'" << endm;
705 fout_cmn.setf(std::ios::fixed, std::ios::floatfield);
706 fout_cmn.precision(5);
708 cmNoiseDataVec_t::iterator cmnDataVecIter;
710 for( cmnDataVecIter = mCmnVec.begin(); cmnDataVecIter != mCmnVec.end() && !ierr; ++cmnDataVecIter, ++idx ){
711 short timebin = idx % kFstNumTimeBins;
712 int groupId = idx / kFstNumTimeBins;
713 int rId = groupId % kFstNumRStripsPerSensor;
714 int apvId = groupId / kFstNumRStripsPerSensor;
715 int wedgeGeomId = 1 + apvId/kFstApvsPerWedge;
716 int rdo = (wedgeGeomId-1)/kFstNumWedsPerRdo + 1;
717 int arm = ((wedgeGeomId-1)%kFstNumWedsPerRdo)/kFstNumWedsPerArm;
719 int apv = apvId%kFstNumApvsPerArm;
721 fout_cmn << apvId <<
' ' << rdo <<
' ' << arm <<
' '<< apv <<
' ' << rId <<
' ' << timebin <<
' ' << cmnDataVecIter->cmn << endl;
virtual TObject * GetObject() const
The depricated method (left here for the sake of the backward compatibility)