@@ -38,6 +38,9 @@ DFCALShower_factory::DFCALShower_factory()
38
38
39
39
USE_RING_E_CORRECTION_V2=false ;
40
40
gPARMS ->SetDefaultParameter (" FCAL:USE_RING_E_CORRECTION_V2" ,USE_RING_E_CORRECTION_V2);
41
+
42
+ USE_CPP_E_CORRECTION=false ;
43
+ gPARMS ->SetDefaultParameter (" FCAL:USE_CPP_CORRECTION" ,USE_CPP_E_CORRECTION);
41
44
42
45
SHOWER_ENERGY_THRESHOLD = 50 *k_MeV;
43
46
gPARMS ->SetDefaultParameter (" FCAL:SHOWER_ENERGY_THRESHOLD" , SHOWER_ENERGY_THRESHOLD);
@@ -79,15 +82,22 @@ DFCALShower_factory::DFCALShower_factory()
79
82
SHOWER_POSITION_LOG = true ;
80
83
USE_RING_E_CORRECTION_V1 = true ;
81
84
USE_RING_E_CORRECTION_V2 = false ;
85
+ USE_CPP_E_CORRECTION = false ;
82
86
} else if (USE_NONLINEAR_CORRECTION_TYPE == 2 ) {
83
87
expfit_param1 = 2 ;
84
88
expfit_param1 = 0 ;
85
89
expfit_param1 = 0 ;
86
90
SHOWER_POSITION_LOG = true ;
87
91
USE_RING_E_CORRECTION_V1 = false ;
88
92
USE_RING_E_CORRECTION_V2 = true ;
93
+ USE_CPP_E_CORRECTION = false ;
94
+ } else if (USE_NONLINEAR_CORRECTION_TYPE == 3 ) {
95
+ SHOWER_POSITION_LOG = true ;
96
+ USE_RING_E_CORRECTION_V1 = false ;
97
+ USE_RING_E_CORRECTION_V2 = false ;
98
+ USE_CPP_E_CORRECTION = true ;
89
99
}
90
-
100
+
91
101
gPARMS ->SetDefaultParameter (" FCAL:P0" , timeConst0);
92
102
gPARMS ->SetDefaultParameter (" FCAL:P1" , timeConst1);
93
103
gPARMS ->SetDefaultParameter (" FCAL:P2" , timeConst2);
@@ -197,6 +207,7 @@ jerror_t DFCALShower_factory::brun(JEventLoop *loop, int32_t runnumber)
197
207
jout << Form (" %s" , str_coef[0 ].Data ()) << nonlinear_correction_type[0 ];
198
208
jout << endl;
199
209
}
210
+
200
211
if (nonlinear_correction_type[0 ] == 0 ) {
201
212
LOAD_NONLIN_CCDB = true ;
202
213
} else if (nonlinear_correction_type[0 ] == 1 ) {
@@ -207,6 +218,7 @@ jerror_t DFCALShower_factory::brun(JEventLoop *loop, int32_t runnumber)
207
218
SHOWER_POSITION_LOG = true ;
208
219
USE_RING_E_CORRECTION_V1 = true ;
209
220
USE_RING_E_CORRECTION_V2 = false ;
221
+ USE_CPP_E_CORRECTION = false ;
210
222
} else if (nonlinear_correction_type[0 ] == 2 ) {
211
223
LOAD_NONLIN_CCDB = true ;
212
224
expfit_param1 = 2 ;
@@ -215,12 +227,21 @@ jerror_t DFCALShower_factory::brun(JEventLoop *loop, int32_t runnumber)
215
227
SHOWER_POSITION_LOG = true ;
216
228
USE_RING_E_CORRECTION_V1 = false ;
217
229
USE_RING_E_CORRECTION_V2 = true ;
230
+ USE_CPP_E_CORRECTION = false ;
231
+ } else if (nonlinear_correction_type[0 ] == 3 ) {
232
+ LOAD_NONLIN_CCDB = true ;
233
+ SHOWER_POSITION_LOG = true ;
234
+ USE_RING_E_CORRECTION_V1 = false ;
235
+ USE_RING_E_CORRECTION_V2 = false ;
236
+ USE_CPP_E_CORRECTION = true ;
218
237
}
219
238
}
220
-
239
+
221
240
// but allow these to be overridden by command line parameters
222
241
energy_dependence_correction_vs_ring.clear ();
223
242
nonlinear_correction.clear ();
243
+ nonlinear_correction_cpp.clear ();
244
+ block_to_square.clear ();
224
245
if (LOAD_NONLIN_CCDB) {
225
246
map<string, double > shower_calib_piecewise;
226
247
loop->GetCalib (" FCAL/shower_calib_piecewise" , shower_calib_piecewise);
@@ -232,7 +253,9 @@ jerror_t DFCALShower_factory::brun(JEventLoop *loop, int32_t runnumber)
232
253
expfit_param3 = shower_calib_piecewise[" expfit_param3" ];
233
254
m_beamSpotX = 0 ;
234
255
m_beamSpotY = 0 ;
235
-
256
+ // expfit_param1 = 1.10358;
257
+ // expfit_param2 = 0.31385;
258
+ // expfit_param3 = -2.02585;
236
259
if (debug_level>0 ) {
237
260
jout << " cutoff_energy = " << cutoff_energy << endl;
238
261
jout << " linfit_slope = " << linfit_slope << endl;
@@ -257,7 +280,7 @@ jerror_t DFCALShower_factory::brun(JEventLoop *loop, int32_t runnumber)
257
280
}
258
281
}
259
282
loop->GetCalib (" FCAL/nonlinear_correction" , nonlinear_correction);
260
- if (nonlinear_correction.size () > 0 && nonlinear_correction[ 0 ][ 0 ] != 0 ) {
283
+ if (nonlinear_correction.size () > 0 ) {
261
284
m_beamSpotX = beam_spot.at (" x" );
262
285
m_beamSpotY = beam_spot.at (" y" );
263
286
if (debug_level > 0 ) {
@@ -271,8 +294,29 @@ jerror_t DFCALShower_factory::brun(JEventLoop *loop, int32_t runnumber)
271
294
}
272
295
}
273
296
}
297
+
298
+ loop->GetCalib (" FCAL/block_to_square" , block_to_square);
299
+ if (block_to_square.size () > 0 ) {
300
+ if (debug_level > 0 ) {
301
+ for (int i = 0 ; i < (int ) block_to_square.size (); i ++) {
302
+ jout << block_to_square[i];
303
+ }
304
+ jout << endl;
305
+ }
306
+ }
307
+
308
+ loop->GetCalib (" FCAL/nonlinear_correction_cpp" , nonlinear_correction_cpp);
309
+ if (nonlinear_correction_cpp.size () > 0 ) {
310
+ m_beamSpotX = beam_spot.at (" x" );
311
+ m_beamSpotY = beam_spot.at (" y" );
312
+ if (debug_level > 0 ) {
313
+ for (int i = 0 ; i < (int ) nonlinear_correction_cpp.size (); i ++) {
314
+ jout << nonlinear_correction_cpp[i];
315
+ }
316
+ jout << endl;
317
+ }
318
+ }
274
319
}
275
-
276
320
if (LOAD_TIMING_CCDB) {
277
321
// Get timing correction polynomial, J. Mirabelli 10/31/17
278
322
map<string,double > timing_correction;
@@ -515,7 +559,11 @@ jerror_t DFCALShower_factory::evnt(JEventLoop *eventLoop, uint64_t eventnumber)
515
559
// int MAXITER = 1000;
516
560
517
561
DVector3 posInCal = cluster->getCentroid ();
518
-
562
+ int block = cluster->getChannelEmax ();
563
+ int square_nb = -1 ;
564
+ if (USE_CPP_E_CORRECTION)
565
+ square_nb = block_to_square[block];
566
+
519
567
float x0 = posInCal.Px ();
520
568
float y0 = posInCal.Py ();
521
569
double Eclust = cluster->getEnergy ();
@@ -533,6 +581,8 @@ jerror_t DFCALShower_factory::evnt(JEventLoop *eventLoop, uint64_t eventnumber)
533
581
double Egamma = Eclust;
534
582
Ecorrected = 0 ;
535
583
584
+
585
+
536
586
// block properties
537
587
double radiation_length=FCAL_RADIATION_LENGTH;
538
588
double shower_offset=FCAL_SHOWER_OFFSET;
@@ -632,7 +682,29 @@ jerror_t DFCALShower_factory::evnt(JEventLoop *eventLoop, uint64_t eventnumber)
632
682
// if all C=D=E=0 by mistake then Egamma = - Eclust
633
683
Egamma = Eclust / (C - exp (-D * Eclust + E)); // Non-linear part
634
684
}
635
- } // End Correction method I
685
+ // cout <<"Eclust " << Eclust << " Egamma " << Egamma << " A " << A << " B " << B << " C " << C << " D " << D << " E " << E << endl;
686
+ } // End Correction method I
687
+
688
+ if (USE_CPP_E_CORRECTION && !USE_RING_E_CORRECTION_V2 && !USE_RING_E_CORRECTION_V1) {
689
+ double scalef = nonlinear_correction_cpp[0 ];
690
+ if (square_nb >= 0 && square_nb <= 13 ) {
691
+ double Eshift = 0 ;
692
+ if (square_nb == 10 ) {
693
+ Eshift = atan (nonlinear_correction_cpp[4 + square_nb * 3 ] * Egamma + nonlinear_correction_cpp[5 + square_nb * 3 ]);
694
+ Eshift *= nonlinear_correction_cpp[3 + square_nb * 3 ] * Eshift;
695
+ } else {
696
+ Eshift = nonlinear_correction_cpp[3 + square_nb * 3 ] * atan (nonlinear_correction_cpp[4 + square_nb * 3 ] * Egamma + nonlinear_correction_cpp[5 + square_nb * 3 ]);
697
+ }
698
+ Eshift = scalef * Eshift;
699
+ if (Eshift > 0 .) {
700
+ Egamma *= (1 . + nonlinear_correction_cpp[1 ] * 1 .e -2 * Egamma + nonlinear_correction_cpp[2 ] * 1 .e -2 * Egamma * Egamma) / Eshift;
701
+ } else {
702
+ if (VERBOSE > 3 ) jerr << " CPP nonlinear correction has a wrong Eshift" << endl;
703
+ }
704
+ } else {
705
+ if (VERBOSE > 3 ) jerr << " CPP nonlinear correction has no square_nb" << endl;
706
+ }
707
+ }
636
708
}
637
709
// End energy dependence correction
638
710
0 commit comments