5 #include "CLHEP/Random/RandGaussT.h" 6 #include "CLHEP/Units/PhysicalConstants.h" 10 #include <CCDB/Calibration.h> 11 #include <CCDB/Model/Assignment.h> 12 #include <CCDB/CalibrationGenerator.h> 16 #include "Randomize.hh" 26 if(runno == -1)
return dcc;
33 dcc.
date =
"2016-03-15";
34 if(getenv (
"CCDB_CONNECTION") != NULL)
35 dcc.
connection = (string) getenv(
"CCDB_CONNECTION");
37 dcc.
connection =
"mysql://clas12reader@clasdb.jlab.org/clas12";
40 auto_ptr<Calibration> calib(CalibrationGenerator::CreateCalibration(dcc.
connection));
44 string database =
"/calibration/dc/signal_generation/intrinsic_inefficiency";
45 vector<vector<double> > data;
46 calib->GetCalib(data, database);
47 for(
unsigned row = 0; row < data.size(); row++)
49 int sl = data[row][0] - 1;
50 dcc.
P1[sl] = data[row][1];
51 dcc.
P2[sl] = data[row][2];
52 dcc.
P3[sl] = data[row][3];
53 dcc.
P4[sl] = data[row][4];
54 dcc.
iScale[sl] = data[row][5];
58 database =
"/calibration/dc/signal_generation/dc_resolution";
60 calib->GetCalib(data, database);
61 for(
unsigned row = 0; row < data.size(); row++)
63 int sec = data[row][0] - 1;
64 int sl = data[row][1] - 1;
65 dcc.
smearP1[sec][sl] = data[row][2];
66 dcc.
smearP2[sec][sl] = data[row][3];
67 dcc.
smearP3[sec][sl] = data[row][4];
68 dcc.
smearP4[sec][sl] = data[row][5];
73 cout <<
" !!!! DC Warning: the smearing parameter is greater than one for sector " << sec <<
" sl " << sl
74 <<
". That means that the DC response in GEMC will have" 75 <<
" worse resoultion than the data. " << endl;
82 database =
"/geometry/dc/superlayer";
83 auto_ptr<Assignment> dcCoreModel(calib->GetAssignment(database));
84 for(
size_t rowI = 0; rowI < dcCoreModel->GetRowsCount(); rowI++)
85 dcc.
dLayer[rowI] = dcCoreModel->GetValueDouble(rowI, 6);
91 for(
int l=0; l<6; l++)
101 map<string, double> dgtz;
102 vector<identifier> identity = aHit->
GetId();
104 int SECI = identity[0].id - 1;
105 int SLI = identity[1].id - 1;
106 int nwire = identity[3].id;
110 double deltay = 2.0*ylength/dcc.
NWIRES;
111 double WIRE_Y = nwire*deltay + dcc.
miniStagger[SLI];
113 vector<int> stepTrackId = aHit->
GetTIds();
114 vector<double> stepTime = aHit->
GetTime();
115 vector<G4double> Edep = aHit->
GetEdep();
116 vector<G4ThreeVector> pos = aHit->
GetPos();
117 vector<G4ThreeVector> Lpos = aHit->
GetLPos();
119 unsigned nsteps = Edep.size();
125 double minTime = 10000;
128 for(
unsigned int s=0; s<nsteps; s++)
130 G4ThreeVector DOCA(0, Lpos[s].y() + ylength - WIRE_Y, Lpos[s].z());
131 signal_t = stepTime[s]/ns + DOCA.mag()/dcc.
driftVelocity[SLI];
134 if(signal_t < minTime)
136 trackIdw = stepTrackId[s];
141 trackIds = stepTrackId[s];
155 for(
unsigned int s=0; s<nsteps; s++)
157 G4ThreeVector DOCA(0, Lpos[s].y() + ylength - WIRE_Y, Lpos[s].z());
159 if(DOCA.mag() <= doca && stepTrackId[s] == trackIds )
162 if(DOCA.y() >=0 ) LR = 1;
168 double X = (doca/cm) / (2*dcc.
dLayer[SLI]);
174 double sdoca = fabs(CLHEP::RandGauss::shoot(doca, smearF*dcc.
smearScale[SECI][SLI]));
177 double ddEff = dcc.
iScale[SLI]*(dcc.
P1[SLI]/pow(X*X + dcc.
P2[SLI], 2) + dcc.
P3[SLI]/pow( (1-X) + dcc.
P4[SLI], 2));
178 double random = G4UniformRand();
181 if(random < ddEff || X > 1) ineff = -1;
185 dgtz[
"sector"] = identity[0].id;
186 dgtz[
"superlayer"] = SLI+1;
187 dgtz[
"layer"] = identity[2].id;
188 dgtz[
"wire"] = nwire;
191 dgtz[
"sdoca"] = sdoca;
201 vector<identifier> yid = id;
202 int SLI = yid[1].id - 1;
204 G4StepPoint *prestep = aStep->GetPreStepPoint();
205 G4StepPoint *poststep = aStep->GetPostStepPoint();
207 G4ThreeVector xyz = poststep->GetPosition();
208 G4ThreeVector Lxyz = prestep->GetTouchableHandle()->GetHistory()
209 ->GetTopTransform().TransformPoint(xyz);
213 double deltay = 2.0*ylength/dcc.
NWIRES;
214 double loc_y = Lxyz.y() + ylength - dcc.
miniStagger[SLI];
216 int nwire = (int) floor(loc_y/deltay);
219 if(nwire <= 0 ) nwire = 1;
220 if(nwire == 113) nwire = 112;
226 if(fabs( (nwire+1)*deltay - loc_y ) < fabs( nwire*deltay - loc_y ) && nwire != 112 )
227 yid[3].
id = nwire + 1;
230 yid[3].id_sharing = 1;
235 void dc_HitProcess::initWithRunNumber(
int runno)
237 if(dcc.
runNo != runno)
239 cout <<
" > Initializing " << HCname <<
" digitization for run number " << runno << endl;
240 dcc = initializeDCConstants(runno);
248 map< string, vector <int> > MH;
254 dcConstants dc_HitProcess::dcc = initializeDCConstants(1);
map< string, double > integrateDgt(MHit *, int)
vector< identifier > GetId()
vector< G4ThreeVector > GetLPos()
vector< G4ThreeVector > GetPos()
vector< double > GetTime()
map< string, vector< int > > multiDgt(MHit *, int)
vector< double > dimensions
vector of dimensions. Size, units depends on solid type
vector< identifier > processID(vector< identifier >, G4Step *, detector)
vector< double > GetEdep()