13 #include <JANA/JApplication.h>
14 #include <JANA/JFactory.h>
52 gDirectory->mkdir(
"CDC_TimeToDistance");
53 gDirectory->cd(
"CDC_TimeToDistance");
56 HistCurrentConstants =
new TProfile(
"CDC_TD_Constants",
"CDC T/D constants", 125 ,0.5, 125.5);
62 gPARMS->SetDefaultParameter(
"KALMAN:RING_TO_SKIP",UNBIASED_RING);
63 gPARMS->SetDefaultParameter(
"CDCCOSMIC:EXCLUDERING", UNBIASED_RING);
75 dMagneticField = dapp->
GetBfield(runnumber);
76 JCalibration *jcalib = dapp->GetJCalibration(runnumber);
79 unsigned int numstraws[28]={42,42,54,54,66,66,80,80,93,93,106,106,123,123,
80 135,135,146,146,158,158,170,170,182,182,197,197,
83 sag_phi_offset.clear();
84 vector< map<string, double> > tvals;
85 unsigned int straw_count=0,ring_count=0;
86 if (jcalib->Get(
"CDC/sag_parameters", tvals)==
false){
87 vector<double>
temp,temp2;
88 for(
unsigned int i=0; i<tvals.size(); i++){
89 map<string, double> &row = tvals[i];
91 temp.push_back(row[
"offset"]);
92 temp2.push_back(row[
"phi"]);
95 if (straw_count==numstraws[ring_count]){
96 max_sag.push_back(temp);
97 sag_phi_offset.push_back(temp2);
109 sprintf(ccdbTable,
"CDC/cdc_drift_table%s",dIsNoFieldFlag?
"::NoBField":
"");
111 if (jcalib->Get(ccdbTable, tvals)==
false){
112 for(
unsigned int i=0; i<tvals.size(); i++){
113 map<string, double> &row = tvals[i];
114 HistCurrentConstants->Fill(i+1,1000.*row[
"t"]);
118 jerr <<
" CDC time-to-distance table not available... bailing..." << endl;
122 sprintf(ccdbTable,
"CDC/drift_parameters%s",dIsNoFieldFlag?
"::NoBField":
"");
123 if (jcalib->Get(ccdbTable, tvals)==
false){
124 map<string, double> &row = tvals[0];
125 HistCurrentConstants->Fill(101,row[
"a1"]);
126 HistCurrentConstants->Fill(102,row[
"a2"]);
127 HistCurrentConstants->Fill(103,row[
"a3"]);
128 HistCurrentConstants->Fill(104,row[
"b1"]);
129 HistCurrentConstants->Fill(105,row[
"b2"]);
130 HistCurrentConstants->Fill(106,row[
"b3"]);
131 HistCurrentConstants->Fill(107,row[
"c1"]);
132 HistCurrentConstants->Fill(108,row[
"c2"]);
133 HistCurrentConstants->Fill(109,row[
"c3"]);
134 HistCurrentConstants->Fill(110,row[
"B1"]);
135 HistCurrentConstants->Fill(111,row[
"B2"]);
138 HistCurrentConstants->Fill(112,row[
"a1"]);
139 HistCurrentConstants->Fill(113,row[
"a2"]);
140 HistCurrentConstants->Fill(114,row[
"a3"]);
141 HistCurrentConstants->Fill(115,row[
"b1"]);
142 HistCurrentConstants->Fill(116,row[
"b2"]);
143 HistCurrentConstants->Fill(117,row[
"b3"]);
144 HistCurrentConstants->Fill(118,row[
"c1"]);
145 HistCurrentConstants->Fill(119,row[
"c2"]);
146 HistCurrentConstants->Fill(120,row[
"c3"]);
147 HistCurrentConstants->Fill(121,row[
"B1"]);
148 HistCurrentConstants->Fill(122,row[
"B2"]);
152 HistCurrentConstants->Fill(125,runnumber);
162 int straw_offset[29] = {0,0,42,84,138,192,258,324,404,484,577,670,776,882,1005,1128,1263,1398,1544,1690,1848,2006,2176,2346,2528,2710,2907,3104,3313};
166 loop->GetSingle(locTrigger);
170 vector <const DChargedTrack *> chargedTrackVector;
171 loop->Get(chargedTrackVector);
173 for (
unsigned int iTrack = 0; iTrack < chargedTrackVector.size(); iTrack++){
182 if(!thisTimeBasedTrack->IsSmoothed)
continue;
183 if (thisTimeBasedTrack->FOM < 1E-10)
continue;
184 vector<DTrackFitter::pull_t> pulls = thisTimeBasedTrack->
pulls;
186 for (
unsigned int i = 0; i < pulls.size(); i++){
188 double residual = thisPull.
resi;
190 double time = thisPull.
tcorr;
191 double docaphi = thisPull.
docaphi;
192 if (docaphi > TMath::Pi()) docaphi -= 2 * TMath::Pi();
193 double docaz = thisPull.
z;
196 double predictedDistance = thisPull.
d;
200 if (thisCDCHit == NULL)
continue;
201 if (predictedDistance > 1.5 || predictedDistance < 0.0)
continue;
207 time,straw_offset[ring]+straw,
208 "Per straw drift times; Drift time [ns];CCDB Index",
209 200,-50,50,3522,0.5,3522.5);
213 "Residual Vs. Drift Time; Drift time [ns];Residual [cm]",
214 250,0.,1250,100, -0.05,0.05);
216 if(UNBIASED_RING != 0 && (ring != UNBIASED_RING) )
continue;
221 double dz = docaz - 92.0;
225 double Bz = dMagneticField->GetBz(thisHitLocation.X(), thisHitLocation.Y(), thisHitLocation.Z());
229 "B_{z};B_{z} [T]", 100, 0.0, 2.5);
231 double delta = max_sag[ring - 1][straw - 1]*(1.-dz*dz/5625.)
232 *cos(docaphi + sag_phi_offset[ring - 1][straw - 1]);
234 Fill2DProfile(
"CDC_TimeToDistance",
"",
"Predicted Drift Distance Vs Delta Vs t_drift",
235 time, delta, predictedDistance,
236 "Predicted Drift Distance Vs. #delta Vs. t_{drift}; t_{drift} [ns]; #delta [cm]",
237 500, 0, 1500, 200, -0.3, 0.3);
239 if (max_sag[ring - 1][straw - 1] < 0.05){
240 Fill2DProfile(
"CDC_TimeToDistance",
"",
"Predicted Drift Distance Vs Delta Vs t_drift < 0.05",
241 time, delta, predictedDistance,
242 "Predicted Drift Distance Vs. #delta Vs. t_{drift}; t_{drift} [ns]; #delta [cm]",
243 500, 0, 1500, 200, -0.3, 0.3);
245 else if (max_sag[ring - 1][straw - 1] < 0.10){
246 Fill2DProfile(
"CDC_TimeToDistance",
"",
"Predicted Drift Distance Vs Delta Vs t_drift < 0.10",
247 time, delta, predictedDistance,
248 "Predicted Drift Distance Vs. #delta Vs. t_{drift}; t_{drift} [ns]; #delta [cm]",
249 500, 0, 1500, 200, -0.3, 0.3);
251 else if (max_sag[ring - 1][straw - 1] < 0.15){
252 Fill2DProfile(
"CDC_TimeToDistance",
"",
"Predicted Drift Distance Vs Delta Vs t_drift < 0.15",
253 time, delta, predictedDistance,
254 "Predicted Drift Distance Vs. #delta Vs. t_{drift}; t_{drift} [ns]; #delta [cm]",
255 500, 0, 1500, 200, -0.3, 0.3);
257 else if (max_sag[ring - 1][straw - 1] < 0.20){
258 Fill2DProfile(
"CDC_TimeToDistance",
"",
"Predicted Drift Distance Vs Delta Vs t_drift < 0.20",
259 time, delta, predictedDistance,
260 "Predicted Drift Distance Vs. #delta Vs. t_{drift}; t_{drift} [ns]; #delta [cm]",
261 500, 0, 1500, 200, -0.3, 0.3);
263 else if (max_sag[ring - 1][straw - 1] < 0.25){
264 Fill2DProfile(
"CDC_TimeToDistance",
"",
"Predicted Drift Distance Vs Delta Vs t_drift < 0.25",
265 time, delta, predictedDistance,
266 "Predicted Drift Distance Vs. #delta Vs. t_{drift}; t_{drift} [ns]; #delta [cm]",
267 500, 0, 1500, 200, -0.3, 0.3);
jerror_t brun(jana::JEventLoop *eventLoop, int32_t runnumber)
Called everytime a new run number is detected.
jerror_t fini(void)
Called after last event of last event source has been processed.
sprintf(text,"Post KinFit Cut")
DMagneticFieldMap * GetBfield(unsigned int run_number=1)
jerror_t evnt(jana::JEventLoop *eventLoop, uint64_t eventnumber)
Called every event.
const DTrackTimeBased * Get_TrackTimeBased(void) const
uint32_t Get_L1FrontPanelTriggerBits(void) const
const DCDCTrackHit * cdc_hit
jerror_t init(void)
Called once at program start.
jerror_t erun(void)
Called everytime run number changes, provided brun has been called.
JEventProcessor_CDC_TimeToDistance()
vector< DTrackFitter::pull_t > pulls
Holds pulls used in chisq calc. (not including off-diagonals)
~JEventProcessor_CDC_TimeToDistance()