CSidc2.C
//-----------------------------------------------------------------------------
// $Header: /asis/offline/ceres/cool/project/RCS/CSidc2.C,v 3.4 1997/06/30 14:49:38 lenkeit Exp $
//
// COOL Program Library
// Copyright (C) CERES collaboration, 1996
//
// Implementation of class CSidc2
//
//-----------------------------------------------------------------------------
#include <iostream.h>
#include "CSidc2.h"
#include "CSidcDeltaR.h"
#include "CMCDigiHit.h"
CSidc2::CSidc2(const char* setupFile)
{
//
// Initialize members inherited from CDetector
//
id = SiDC2;
name = "SiDC2";
//
// May be I should comment on this:
// The reason for this massacre is that there exist nothing
// like virtual data member. Each of the defined setup pointers
// has is own scope. With other words there's an ambiguity
// which can only be resolved by either using always the proper
// scope operator or by hacking the code below. I know it looks
// somehow unusual but eases further programming.
//
CDetector::setup = CSidc::setup = new CSidcSetup;
if (setupFile == 0) {
CString setupName = CString(C_DEFAULT_SETUP_PATH)+
CString(C_SETUPFILE_SIDC2);
setup->read(setupName.data());
}
else
setup->read(setupFile);
// the local delta-R correction.
CString deltaRFileName = CString(C_DEFAULT_SETUP_PATH)+
CString("drsd2.vec");
CSidc::deltaRcorrection = new CSidcDeltaR(deltaRFileName.data());
//
// Set the proper size of the collections
// anode [0-359], time bin [0-255], nnim [0-23]
//
cells.resize(setup->getNAnodes(), setup->getNTimeBins());
nims.resize(setup->getNNim(), setup->getNTimeBins());
//
// read fallback values for pedestals and
// anodewise t0 corrections from file
//
CString fileName = CString(C_DEFAULT_SETUP_PATH)+
CString(C_CALIBRATION_FILE_SIDC2);
readLookupItemsFromFile(fileName.data());
}
CSidc2::~CSidc2() { delete setup; }
CSidc2::CSidc2(const CSidc2 &) {}
CSidc2 & CSidc2::operator = (const CSidc2 &) { return *this; }
//
//Calculation of the amplitude for each anode for MCHits, needed for function digitize
//
double CSidc2::calculateAmplitude(double anodeNumber, double hitAnode, double sigAnode,
double dEdx){
//
// Calculation of the amplitude for each anode for MCHits,
// needed for function digitize
// for anode structure see dipl. thesis Marc Hemberger S.55
//
const double normFactor = 1.4142135624 * sigAnode; // normalization factor for gauss function
double amplitude = 0;
double amplitude_part = 0;
double hitDistToEdge = hitAnode - int(hitAnode) + 0.5; // distance of hit to lower edge of anode
double distLowerEdge = anodeNumber - 0.25 - hitDistToEdge; // a11:outside anode. width=61um
double distUpperEdge = anodeNumber - 0.1667 - hitDistToEdge;
amplitude_part = 0.5 * (erf(distUpperEdge/normFactor) -
erf(distLowerEdge/normFactor));
amplitude += amplitude_part;
distLowerEdge = anodeNumber - hitDistToEdge; // a22:inside anode. width=122um
distUpperEdge = anodeNumber + 0.167 - hitDistToEdge;
amplitude_part = 0.5 * (erf(distUpperEdge/normFactor) -
erf(distLowerEdge/normFactor));
amplitude += amplitude_part;
distLowerEdge = anodeNumber + 0.25 - hitDistToEdge; // a0:central anode. width=366um
distUpperEdge = anodeNumber + 0.75 - hitDistToEdge;
amplitude_part = 0.5 * (erf(distUpperEdge/normFactor) -
erf(distLowerEdge/normFactor));
amplitude += amplitude_part;
distLowerEdge = anodeNumber + 0.833 - hitDistToEdge; // a21:inside anode. width=122um
distUpperEdge = anodeNumber + 1 - hitDistToEdge;
amplitude_part = 0.5 * (erf(distUpperEdge/normFactor) -
erf(distLowerEdge/normFactor));
amplitude += amplitude_part;
distLowerEdge = anodeNumber + 1.1667 - hitDistToEdge; // a12:outside anode. width=61um
distUpperEdge = anodeNumber + 1.25 - hitDistToEdge;
amplitude_part = 0.5 * (erf(distUpperEdge/normFactor) -
erf(distLowerEdge/normFactor));
amplitude += amplitude_part;
amplitude = dEdx * amplitude;
return amplitude;
}