CSidcSetup.C
//-----------------------------------------------------------------------------
// $Header: /asis/offline/ceres/cool/project/RCS/CSidcSetup.C,v 3.16 1997/07/18 10:53:37 messer Exp $
//
// COOL Program Library
// Copyright (C) CERES collaboration, 1996
//
// Implementation of class CSidcSetup.
//
//-----------------------------------------------------------------------------
#include <iostream.h>
#include <iomanip.h>
#include "CSidcSetup.h"
CSidcSetup::CSidcSetup()
{
waferType = noWaferType;
nAnodes = 0;
nTimeBins = 0;
nNim = 0;
calibrationFileName = "default";
drCorrectionFileName = "default";
minRadius = 0;
maxRadius = 0;
maxTimeBinReference = 0;
minTimeBin = 0;
driftVelocity = 0;
driftVelocityReference = 0;
phiOffset = 0;
zPosition = 0;
firstCrate = 0;
isFlipped = False;
minCellAmplitude = 0;
timeOffsetBTDC = 0;
stopPulseThreshold = 0;
singlePulseSigma[0] = 0;
singlePulseSigma[1] = 0;
saturationAmplitude = 0;
maxDeviationForSinglePulse = 0;
timeWindowForHit = 0;
anodeWindowForHit = 0;
minTimeBinsForHit = 0;
lastRequestedRunNumber = 0;
indexOfLastRequestedRunNumber = 0;
numberOfRunsForStopPulseCuts = 0;
runNumbersForStopPulseCuts = 0;
lowerStopPulseCoGCut = 0;
anodePhiOffset = 0;
diffusionConstants[0] = 0;
diffusionConstants[1] = 0;
int i;
for (i=0; i<3; i++)
anodePhiStructure[i] = 0;
for (i=0; i<2; i++)
tiltCorrection[i] = 0;
for (i=0; i<4; i++)
deformationCorrection[i] = 0;
for (i=0; i<4; i++)
ballisticDeficit[i] = 0;
numberOfDeadFADC = 0;
for (i=0; i<360; i++)
listOfDeadFADC[i] = 0;
mcHitLabel = 0;
mcMeanAmplitude = 0;
mcHitWidth = 0;
mcUseNoise = False;
mcZOffset = 0;
mcSigmaRadius = 0;
mcSigmaPhi = 0;
mcSigmaElectronic = 0;
mcDiffusionConst = 0;
mcTimeBin = 0;
mcNoise = 0;
mcGeVToElectrons = 0;
mcElectronsToVolt = 0;
mcPedestal = 0;
mcNoiseScale = 0;
mcThreshhold = 0;
mcCmToRad = 0;
}
double CSidcSetup::getMaxTimeBin() const
{
//
// the return value is calculated with the actual (i.e. after calibration) drift velocity
//
return (maxRadius-minRadius)/driftVelocity + minTimeBin;
}
void CSidcSetup::read(const char* filename)
{
CSetup::_read(filename);
CDetectorSetup::_read(filename);
_read(filename);
}
void CSidcSetup::_read(const char* filename)
{
waferType = CGetDefaultValue(filename, "waferType", waferType);
nAnodes = CGetDefaultValue(filename, "nAnodes", nAnodes);
nTimeBins = CGetDefaultValue(filename, "nTimeBins", nTimeBins);
nNim = CGetDefaultValue(filename, "nNim", nNim);
firstCrate = CGetDefaultValue(filename, "firstCrate", firstCrate);
calibrationFileName = CGetDefaultValue(filename, "calibrationFileName", calibrationFileName);
drCorrectionFileName = CGetDefaultValue(filename, "drCorrectionFileName", drCorrectionFileName);
maxRadius = CGetDefaultValue(filename, "maxRadius", maxRadius);
minRadius = CGetDefaultValue(filename, "minRadius", minRadius);
maxTimeBinReference = CGetDefaultValue(filename, "maxTimeBinReference", maxTimeBinReference);
minTimeBin = CGetDefaultValue(filename, "minTimeBin", minTimeBin);
driftVelocity = CGetDefaultValue(filename, "driftVelocity", driftVelocity);
driftVelocityReference = CGetDefaultValue(filename, "driftVelocityReference", driftVelocityReference);
phiOffset = CGetDefaultValue(filename, "phiOffset", phiOffset);
zPosition = CGetDefaultValue(filename, "zPosition", zPosition);
isFlipped = CGetDefaultValue(filename, "isFlipped", isFlipped);
timeOffsetBTDC = CGetDefaultValue(filename, "timeOffsetBTDC", timeOffsetBTDC);
stopPulseThreshold = CGetDefaultValue(filename, "stopPulseThreshold", stopPulseThreshold);
minCellAmplitude = CGetDefaultValue(filename, "minCellAmplitude", minCellAmplitude);
CGetDefaultValue(filename, "singlePulseSigma", singlePulseSigma, 2);
saturationAmplitude = CGetDefaultValue(filename, "saturationAmplitude", saturationAmplitude);
maxDeviationForSinglePulse = CGetDefaultValue(filename, "maxDeviationForSinglePulse", maxDeviationForSinglePulse);
timeWindowForHit = CGetDefaultValue(filename, "timeWindowForHit", timeWindowForHit);
anodeWindowForHit = CGetDefaultValue(filename, "anodeWindowForHit", anodeWindowForHit);
minTimeBinsForHit = CGetDefaultValue(filename, "minTimeBinsForHit", minTimeBinsForHit);
mcHitLabel = CGetDefaultValue(filename, "mcHitLabel", mcHitLabel);
mcMeanAmplitude = CGetDefaultValue(filename, "mcMeanAmplitude", mcMeanAmplitude);
mcHitWidth = CGetDefaultValue(filename, "mcHitWidth", mcHitWidth);
mcUseNoise = CGetDefaultValue(filename, "mcUseNoise", mcUseNoise);
mcZOffset = CGetDefaultValue(filename, "mcZOffset", mcZOffset);
mcSigmaRadius = CGetDefaultValue(filename, "mcSigmaRadius", mcSigmaRadius);
mcSigmaPhi = CGetDefaultValue(filename, "mcSigmaPhi", mcSigmaPhi);
mcSigmaElectronic = CGetDefaultValue(filename, "mcSigmaElectronic", mcSigmaElectronic);
mcDiffusionConst = CGetDefaultValue(filename, "mcDiffusionConst", mcDiffusionConst);
mcTimeBin = CGetDefaultValue(filename, "mcTimeBin", mcTimeBin);
mcNoise = CGetDefaultValue(filename, "mcNoise", mcNoise);
mcGeVToElectrons = CGetDefaultValue(filename, "mcGeVToElectrons", mcGeVToElectrons);
mcElectronsToVolt = CGetDefaultValue(filename, "mcElectronsToVolt", mcElectronsToVolt);
mcPedestal = CGetDefaultValue(filename, "mcPedestal", mcPedestal);
mcThreshhold = CGetDefaultValue(filename, "mcThreshhold", mcThreshhold);
mcNoiseScale = CGetDefaultValue(filename, "mcNoiseScale", mcNoiseScale);
mcCmToRad = CGetDefaultValue(filename, "mcCmToRad", mcCmToRad);
anodePhiOffset = CGetDefaultValue(filename, "anodePhiOffset", anodePhiOffset);
CGetDefaultValue(filename, "diffusionConstants", diffusionConstants, 2);
CGetDefaultValue(filename, "anodePhiStructure", anodePhiStructure, 3);
numberOfRunsForStopPulseCuts = CGetDefaultValue(filename, "numberOfRunsForStopPulseCuts",
numberOfRunsForStopPulseCuts);
if (numberOfRunsForStopPulseCuts) {
delete [] runNumbersForStopPulseCuts;
runNumbersForStopPulseCuts = new int[numberOfRunsForStopPulseCuts];
CGetDefaultValue(filename, "runNumbersForStopPulseCuts", runNumbersForStopPulseCuts,
numberOfRunsForStopPulseCuts);
delete [] lowerStopPulseCoGCut;
lowerStopPulseCoGCut = new double[numberOfRunsForStopPulseCuts*4];
CGetDefaultValue(filename, "lowerStopPulseCoGCut", lowerStopPulseCoGCut,
numberOfRunsForStopPulseCuts*4);
}
CGetDefaultValue(filename, "tiltCorrection", tiltCorrection, 2);
CGetDefaultValue(filename, "deformationCorrection", deformationCorrection, 4);
CGetDefaultValue(filename, "ballisticDeficit", ballisticDeficit, 4);
numberOfDeadFADC = CGetDefaultValue(filename, "numberOfDeadFADC", numberOfDeadFADC);
CGetDefaultValue(filename, "listOfDeadFADC", listOfDeadFADC, numberOfDeadFADC);
}
void CSidcSetup::list(ostream& ost)
{
CSetup::_list(ost);
CDetectorSetup::_list(ost);
_list(ost);
}
void CSidcSetup::_list(ostream& ost)
{
ost.setf(ios::left);
ost << setw(ListingNameWidth) << "waferType:" << waferType << endl;
ost << setw(ListingNameWidth) << "nAnodes:" << nAnodes << endl;
ost << setw(ListingNameWidth) << "nTimeBins:" << nTimeBins << endl;
ost << setw(ListingNameWidth) << "nNim:" << nNim << endl;
ost << setw(ListingNameWidth) << "firstCrate:" << firstCrate << endl;
ost << setw(ListingNameWidth) << "calibrationFileName:" << calibrationFileName << endl;
ost << setw(ListingNameWidth) << "drCorrectionFileName:" << drCorrectionFileName << endl;
ost << setw(ListingNameWidth) << "maxRadius:" << maxRadius << endl;
ost << setw(ListingNameWidth) << "minRadius:" << minRadius << endl;
ost << setw(ListingNameWidth) << "maxTimeBinReference:" << maxTimeBinReference << endl;
ost << setw(ListingNameWidth) << "minTimeBin:" << minTimeBin << endl;
ost << setw(ListingNameWidth) << "driftVelocity:" << driftVelocity << endl;
ost << setw(ListingNameWidth) << "driftVelocityReference:" << driftVelocityReference << endl;
ost << setw(ListingNameWidth) << "phiOffset:" << phiOffset << endl;
ost << setw(ListingNameWidth) << "zPosition:" << zPosition << endl;
ost << setw(ListingNameWidth) << "isFlipped:" << isFlipped << endl;
ost << setw(ListingNameWidth) << "minCellAmplitude:" << minCellAmplitude << endl;
ost << setw(ListingNameWidth) << "stopPulseThreshold:" << stopPulseThreshold << endl;
ost << setw(ListingNameWidth) << "timeOffsetBTDC:" << timeOffsetBTDC << endl;
ost << setw(ListingNameWidth) << "anodePhiOffset:" << anodePhiOffset << endl;
ost << setw(ListingNameWidth) << "diffusionConstants:";
int i;
for (i = 0; i<2; i++)
ost << diffusionConstants[i] << ' ';
ost << endl;
ost << setw(ListingNameWidth) << "anodePhiStructure:";
for (i = 0; i<3; i++)
ost << anodePhiStructure[i] << ' ';
ost << endl;
ost << setw(ListingNameWidth) << "singlePulseSigma:";
for (i = 0; i<2; i++)
ost << singlePulseSigma[i] << ' ';
ost << endl;
ost << setw(ListingNameWidth) << "saturationAmplitude:" << saturationAmplitude << endl;
ost << setw(ListingNameWidth) << "maxDeviationForSinglePulse:" <<maxDeviationForSinglePulse << endl;
ost << setw(ListingNameWidth) << "timeWindowForHit:" << timeWindowForHit << endl;
ost << setw(ListingNameWidth) << "anodeWindowForHit:" << anodeWindowForHit << endl;
ost << setw(ListingNameWidth) << "minTimeBinsForHit:" << minTimeBinsForHit << endl;
ost << setw(ListingNameWidth) << "numberOfRunsForStopPulseCuts:" << numberOfRunsForStopPulseCuts << endl;
ost << setw(ListingNameWidth) << "runNumbersForStopPulseCuts:";
for (i=0; i<numberOfRunsForStopPulseCuts; i++) {
ost << runNumbersForStopPulseCuts[i] << ' ';
}
ost << endl;
ost << setw(ListingNameWidth) << "lowerStopPulseCoGCut:";
for (int j=0; j<numberOfRunsForStopPulseCuts; j++) {
for (i = 0; i<4; i++) {
ost << lowerStopPulseCoGCut[j*4+i] << ' ';
}
}
ost << endl;
ost << setw(ListingNameWidth) << "tiltCorrection:";
for (i = 0; i<2; i++)
ost << tiltCorrection[i] << ' ';
ost << endl;
ost << setw(ListingNameWidth) << "deformationCorrection:";
for (i = 0; i<4; i++)
ost << deformationCorrection[i] << ' ';
ost << endl;
ost << setw(ListingNameWidth) << "ballisticDeficit:";
for (i = 0; i<4; i++)
ost << ballisticDeficit[i] << ' ';
ost << endl;
ost << setw(ListingNameWidth) << "numberOfDeadFADC:" << numberOfDeadFADC << endl;
ost << setw(ListingNameWidth) << "listOfDeadFADC:";
for (i = 0; i<numberOfDeadFADC; i++)
ost << listOfDeadFADC[i] << ' ';
ost << endl;
ost << setw(ListingNameWidth) << "mcHitLabel:" << mcHitLabel << endl;
ost << setw(ListingNameWidth) << "mcMeanAmplitude:" << mcMeanAmplitude << endl;
ost << setw(ListingNameWidth) << "mcHitWidth:" << mcHitWidth << endl;
ost << setw(ListingNameWidth) << "mcUseNoise:" << mcUseNoise << endl;
ost << setw(ListingNameWidth) << "mcZOffset:" << mcZOffset << endl;
ost << setw(ListingNameWidth) << "mcSigmaRadius:" << mcSigmaRadius << endl;
ost << setw(ListingNameWidth) << "mcSigmaPhi:" << mcSigmaPhi << endl;
ost << setw(ListingNameWidth) << "mcSigmaElectronic:" << mcSigmaElectronic << endl;
ost << setw(ListingNameWidth) << "mcDiffusionConst:" << mcDiffusionConst << endl;
ost << setw(ListingNameWidth) << "mcTimeBin:" << mcTimeBin << endl;
ost << setw(ListingNameWidth) << "mcNoise:" << mcNoise << endl;
ost << setw(ListingNameWidth) << "mcGeVToElectrons:" << mcGeVToElectrons << endl;
ost << setw(ListingNameWidth) << "mcElectronsToVolt:" << mcElectronsToVolt << endl;
ost << setw(ListingNameWidth) << "mcPedestal:" << mcPedestal << endl;
ost << setw(ListingNameWidth) << "mcNoiseScale:" << mcNoiseScale << endl;
ost << setw(ListingNameWidth) << "mcThreshhold:" << mcThreshhold << endl;
ost << setw(ListingNameWidth) << "mcCmToRad:" << mcCmToRad << endl;
ost.unsetf(ios::left);
}