2 #include "G4Poisson.hh" 3 #include "Randomize.hh" 5 #include <CCDB/Calibration.h> 6 #include <CCDB/Model/Assignment.h> 7 #include <CCDB/CalibrationGenerator.h> 19 if(runno == -1)
return ecc;
25 ecc.
date =
"2015-11-29";
26 if(getenv (
"CCDB_CONNECTION") != NULL)
27 ecc.
connection = (string) getenv(
"CCDB_CONNECTION");
29 ecc.
connection =
"mysql://clas12reader@clasdb.jlab.org/clas12";
47 vector<vector<double> > data;
48 auto_ptr<Calibration> calib(CalibrationGenerator::CreateCalibration(ecc.
connection));
50 sprintf(ecc.
database,
"/calibration/ec/attenuation:%d",ecc.
runNo);
51 data.clear(); calib->GetCalib(data,ecc.
database);
53 for(
unsigned row = 0; row < data.size(); row++)
55 isec = data[row][0]; ilay = data[row][1]; istr = data[row][2];
56 ecc.
attlen[isec-1][ilay-1][0].push_back(data[row][3]);
57 ecc.
attlen[isec-1][ilay-1][1].push_back(data[row][4]);
58 ecc.
attlen[isec-1][ilay-1][2].push_back(data[row][5]);
66 if(ecc.
runNo != runno)
68 cout <<
" > Initializing " << HCname <<
" digitization for run number " << runno << endl;
69 ecc = initializeECConstants(runno);
78 map<string, double> dgtz;
79 vector<identifier> identity = aHit->
GetId();
82 int sector = identity[0].id;
83 int stack = identity[1].id;
84 int view = identity[2].id;
85 int strip = identity[3].id;
86 int layer = (stack-1)*3+view+3;
93 double BA = sqrt(4*pow(pDy1,2) + pow(pDx2,2)) ;
95 vector<G4ThreeVector> pos = aHit->
GetPos();
96 vector<G4ThreeVector> Lpos = aHit->
GetLPos();
103 vector<G4double> Edep = aHit->
GetEdep();
107 double A = ecc.
attlen[sector-1][layer-1][0][strip-1];
108 double B = ecc.
attlen[sector-1][layer-1][1][strip-1]*10.;
109 double C = ecc.
attlen[sector-1][layer-1][2][strip-1];
111 for(
unsigned int s=0; s<tInfos.
nsteps; s++)
115 double xlocal = Lpos[s].x();
116 double ylocal = Lpos[s].y();
117 if(view==1) latt = xlocal+(pDx2/(2.*pDy1))*(ylocal+pDy1);
118 if(view==2) latt = BA*(pDy1-ylocal)/2./pDy1;
119 if(view==3) latt = BA*(ylocal+pDy1-xlocal*2*pDy1/pDx2)/4/pDy1;
120 att = A*exp(-latt/B)+C;
121 Etota = Etota + Edep[s]*att;
122 Ttota = Ttota + latt/ecc.
veff;
127 Etota = Etota + Edep[s];
138 double EC_npe = G4Poisson(Etota*ecc.
pmtPEYld);
140 double sigma = ecc.
pmtFactor/sqrt(EC_npe);
153 dgtz[
"sector"] = sector;
154 dgtz[
"stack"] = stack;
156 dgtz[
"strip"] = strip;
165 vector<identifier> yid = id;
167 int view = yid[2].id;
169 G4StepPoint *prestep = aStep->GetPreStepPoint();
170 G4StepPoint *poststep = aStep->GetPostStepPoint();
172 G4ThreeVector xyz = poststep->GetPosition();
173 G4ThreeVector Lxyz = prestep->GetTouchableHandle()->GetHistory()
174 ->GetTopTransform().TransformPoint(xyz);
176 double xlocal = Lxyz.x();
177 double ylocal = Lxyz.y();
208 double BA = sqrt(4*pow(pDy1,2) + pow(pDx2,2)) ;
217 strip = (int) floor((ylocal + pDy1)*ecc.
NSTRIPS/(2*pDy1)) + 1;
222 double BHtop = (xlocal + pDx2)*(-2*pDy1) + (ylocal - pDy1)*(pDx2);
223 double BH = abs(BHtop/BA);
225 double BGtop = 4*pDx2*pDy1;
226 double BG = abs(BGtop/BA);
228 strip = (int) floor(BH*ecc.
NSTRIPS/BG)+1 ;
233 double CFtop = (xlocal - pDx2)*2*pDy1 + (ylocal - pDy1)*pDx2;
234 double CF = abs(CFtop/BA);
236 double CDtop = -4*pDx2*pDy1;
237 double CD = abs(CDtop/BA);
239 strip = (int) floor(CF*ecc.
NSTRIPS/CD)+1 ;
244 cout <<
" EC Hit Process WARNING: No view found." << endl;
248 if (strip <=0 ) strip = 1;
249 if (strip >=36) strip = 36;
252 yid[3].id_sharing = 1;
261 map< string, vector <int> > MH;
map< string, double > integrateDgt(MHit *, int)
void initWithRunNumber(int runno)
vector< identifier > GetId()
vector< G4ThreeVector > GetLPos()
vector< double > attlen[6][9][3]
vector< G4ThreeVector > GetPos()
vector< identifier > processID(vector< identifier >, G4Step *, detector)
vector< double > dimensions
vector of dimensions. Size, units depends on solid type
vector< double > GetEdep()
map< string, vector< int > > multiDgt(MHit *, int)