/[PAMELA software]/tof/flight/ToFNuclei/src/ToFNuclei.cpp
ViewVC logotype

Diff of /tof/flight/ToFNuclei/src/ToFNuclei.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by pamela, Mon Oct 13 13:41:39 2008 UTC revision 1.9 by mayorov, Fri Dec 28 15:52:46 2018 UTC
# Line 1  Line 1 
1    //*****************************************************
2    // october 2015: Updated for use in 10th reduction
3    // calibration parameters changed to 10th reduction dEdx
4    //
5    //24-feb-2009: introduced "beta_in" and "Set_Beta":
6    // beta_in is set to 100 by default. If it is not overwritten
7    // by "Set_Beta" (ToFNuclei.h), the code is used as before.
8    // If beta_in was set by the user using "Set_Beta", this beta
9    // is taken for the calculations.
10    //
11    //26-feb-2009: Inserted S115B calibrations from Lucia
12    //
13    //02-apr-2009: bug found in some "if" statements for the
14    // "Layercharge" definition, but only important if ADC=4095
15    //
16    //15-apr-2009: small bug found in the calculation of the PMT
17    // charge, the charge for the PMTs 1,9,28.. was calculated
18    // twice, but the final result was OK
19    //
20    //05-may-2009: bug found in the calculation of the PMT
21    // charge for standalone ToF due to changes made for rev 1.4:
22    // For PMTs 4,8,39,41 (counting 0..47) no charge was calculated
23    // calibration arrays now including correct brackets to avoid
24    // compiler warnings  
25    //06-aug-2009: charge_layer_trk_raw  and charge_layer_std_raw
26    // added: These are the "raw" values before doing the 2nd-order
27    // correction
28    //*****************************************************
29  #include <ToFNuclei.h>  #include <ToFNuclei.h>
30    
31  //--------------------------------------  //--------------------------------------
32  /**  /**
33   * Default constructor   * Default constructor
34   */   */
35  ToFNuclei::ToFNuclei(){  //ToFNuclei::ToFNuclei(){
36    Clear();  //  Clear();
37  };  //};
38    
39  ToFNuclei::ToFNuclei(PamLevel2 *l2p){    ToFNuclei::ToFNuclei(PamLevel2 *l2p,const char* alg){  
40    //    //
41    Clear();    Clear();
42    //    //
43    L2 = l2p;    L2 = l2p;
44    //    //
45      beta_in = 100.;
46      //
47    if ( !L2->IsORB() ) printf(" WARNING: OrbitalInfo Tree is needed, the plugin could not work properly without it \n");    if ( !L2->IsORB() ) printf(" WARNING: OrbitalInfo Tree is needed, the plugin could not work properly without it \n");
48    //    //
49    OBT = 0;    OBT = 0;
# Line 22  ToFNuclei::ToFNuclei(PamLevel2 *l2p){   Line 52  ToFNuclei::ToFNuclei(PamLevel2 *l2p){  
52    //    //
53    sntr = 0;    sntr = 0;
54    debug = false;    debug = false;
55      trkAlg = alg;
56    //    //
57  };  };
58    
59  void ToFNuclei::Clear(){  void ToFNuclei::Clear(){
60    //    //
61    ncount_trk = 0.;    ncount_trk = 0;
62    charge_trk = 0.;    charge_trk = 0.;
63    memset (charge_layer_trk,0,6*sizeof(Float_t));  //    memset (charge_layer_trk,0,6*sizeof(Float_t));  //
64      memset (charge_layer_trk_raw,0,6*sizeof(Float_t));  //
65      memset (charge_PMT_trk,0,48*sizeof(Float_t));  //
66    memset (layerinfo_trk,0,6*sizeof(Int_t));  //    memset (layerinfo_trk,0,6*sizeof(Int_t));  //
67    ncount_std = 0.;    ncount_std = 0;
68    charge_std = 0.;    charge_std = 0.;
69    memset (charge_layer_std,0,6*sizeof(Float_t));  //    memset (charge_layer_std,0,6*sizeof(Float_t));  //
70      memset (charge_layer_std_raw,0,6*sizeof(Float_t));  //
71      memset (charge_PMT_std,0,48*sizeof(Float_t));  //
72    memset (layerinfo_std,0,6*sizeof(Int_t));  //    memset (layerinfo_std,0,6*sizeof(Int_t));  //
73  };  };
74    
# Line 70  void ToFNuclei::Process(Int_t ntr){ Line 105  void ToFNuclei::Process(Int_t ntr){
105    };    };
106    //    //
107    Bool_t newentry = false;    Bool_t newentry = false;
108      
109    //    //
110    if ( L2->IsORB() ){    if ( L2->IsORB() ){
111      if ( L2->GetOrbitalInfo()->pkt_num != PKT || L2->GetOrbitalInfo()->OBT != OBT || L2->GetOrbitalInfo()->absTime != atime || ntr != sntr ){      if ( L2->GetOrbitalInfo()->pkt_num != PKT || L2->GetOrbitalInfo()->OBT != OBT || L2->GetOrbitalInfo()->absTime != atime || ntr != sntr ){
# Line 83  void ToFNuclei::Process(Int_t ntr){ Line 119  void ToFNuclei::Process(Int_t ntr){
119      newentry = true;      newentry = true;
120    };    };
121    //    //
122    if ( !newentry ) return;    
123      if ( !newentry ) {
124      return;
125                      }
126    //    //
127    tr = ntr;    tr = ntr;
128    //    //
# Line 96  void ToFNuclei::Process(Int_t ntr){ Line 135  void ToFNuclei::Process(Int_t ntr){
135    
136    Clear();    Clear();
137    
138    //    //  cout<<"beta_in = "<<beta_in<<endl;
139    
140    
141      Double_t time;
142    
143      if ( L2->IsORB() ){
144       time = L2->GetOrbitalInfo()->absTime;
145      } else {
146       time = 1153000000.;  // simulated data no OrbitalInfo  fixed date 15-jul-2006
147      };
148    
   Double_t time = L2->GetOrbitalInfo()->absTime;  
149    
150  //=======================================================================  //=======================================================================
151  //==============          Siegen version 1           ====================  //==============          Siegen version 1           ====================
# Line 106  void ToFNuclei::Process(Int_t ntr){ Line 153  void ToFNuclei::Process(Int_t ntr){
153  //=======================================================================  //=======================================================================
154    
155  //if (L2->GetTrkLevel2()->GetNTracks()!=1) return;  //if (L2->GetTrkLevel2()->GetNTracks()!=1) return;
156  if (L2->GetTrkLevel2()->GetNTracks()==1) {  //if (L2->GetTrkLevel2()->GetNTracks()==1) {
157    
158    if( L2->GetNTracks(trkAlg)>=1 ){
159    /*
160  Float_t  PMTsat[48] = {  Float_t  PMTsat[48] = {
161  3162.14, 3165.48, 3153.85, 3085.73, 3089.65, 3107.64, 3097.52, 3078.37, 3130.05, 3087.07, 3112.22,  3162.14, 3165.48, 3153.85, 3085.73, 3089.65, 3107.64, 3097.52, 3078.37, 3130.05, 3087.07, 3112.22,
162  3102.92, 3080.58, 3092.55, 3087.94, 3125.03, 3094.09, 3143.16,  3102.92, 3080.58, 3092.55, 3087.94, 3125.03, 3094.09, 3143.16,
163  3125.51, 3181.27, 3092.09, 3124.98, 3069.3, 3095.53, 3097.11, 3133.53, 3114.73, 3113.01, 3091.19,  3125.51, 3181.27, 3092.09, 3124.98, 3069.3, 3095.53, 3097.11, 3133.53, 3114.73, 3113.01, 3091.19,
164  3097.99, 3033.84, 3134.98, 3081.37, 3111.04, 3066.77, 3108.17,  3097.99, 3033.84, 3134.98, 3081.37, 3111.04, 3066.77, 3108.17,
165  3133, 3111.06, 3052.52, 3140.66, 3106.33, 3094.85, 3150.85, 3118.8, 3096.24, 3118.47,3111.36, 3117.11  3133, 3111.06, 3052.52, 3140.66, 3106.33, 3094.85, 3150.85, 3118.8, 3096.24, 3118.47,3111.36, 3117.11
166  }  };
167  ;  */
168    
169    // new values from Napoli dec 2008
170    Float_t  PMTsat[48] = {
171    3176.35,3178.19,3167.38,3099.73,3117.00,3126.29,3111.44,3092.27,
172    3146.48,3094.41,3132.13,3115.37,3099.32,3110.97,3111.80,3143.14,
173    3106.72,3153.44,3136.00,3188.96,3104.73,3140.45,3073.18,3106.62,
174    3112.48,3146.92,3127.24,3136.52,3109.59,3112.89,3045.15,3147.26,
175    3095.92,3121.05,3083.25,3123.62,3150.92,3125.30,3067.60,3160.18,
176    3119.36,3108.92,3164.77,3133.64,3111.47,3131.98,3128.87,3135.56 };
177    
178    for (Int_t i=0; i<48;i++) PMTsat[i] = PMTsat[i] - 5.;  // safety margin
179    
180    
181    Float_t C0t[48][9] = {
182    {0, 1, 2, 3, 4, 5, 6, 8, 90},
183    {0, 1, 2, 3, 4, 5, 6, 8, 90},
184    {0, 1, 2, 3, 4, 5, 6, 8, 90},
185    {0, 1, 2, 3, 4, 5, 6, 8, 90},
186    {0, 1, 2, 3, 4, 5, 6, 8, 90},
187    {0, 1, 2, 3, 4, 5, 6, 8, 90},
188    {0, 1, 2, 3, 4, 5, 6, 8, 90},
189    {0, 1, 2, 3, 4, 5, 6, 8, 90},
190    {0, 1, 2, 3, 4, 5, 6, 8, 90},
191    {0, 1, 2, 3, 4, 5, 6, 8, 90},
192    {0, 1, 2, 3, 4, 5, 6, 8, 90},
193    {0, 1, 2, 3, 4, 5, 6, 8, 90},
194    {0, 1, 2, 3, 4, 5, 6, 8, 90},
195    {0, 1, 2, 3, 4, 5, 6, 8, 90},
196    {0, 1, 2, 3, 4, 5, 6, 8, 90},
197    {0, 1, 2, 3, 4, 5, 6, 8, 90},
198    {0, 1, 2, 3, 4, 5, 6, 8, 90},
199    {0, 1, 2, 3, 4, 5, 6, 8, 90},
200    {0, 1, 2, 3, 4, 5, 6, 8, 90},
201    {0, 1, 2, 3, 4, 5, 6, 8, 90},
202    {0, 1, 2, 3, 4, 5, 6, 8, 90},
203    {0, 1, 2, 3, 4, 5, 6, 8, 90},
204    {0, 1, 2, 3, 4, 5, 6, 8, 90},
205    {0, 1, 2, 3, 4, 5, 6, 8, 90},
206    {0, 1, 2, 3, 4, 5, 6, 8, 90},
207    {0, 1, 2, 3, 4, 5, 6, 8, 90},
208    {0, 1, 2, 3, 4, 5, 6, 8, 90},
209    {0, 1, 2, 3, 4, 5, 6, 8, 90},
210    {0, 1, 2, 3, 4, 5, 6, 8, 90},
211    {0, 1, 2, 3, 4, 5, 6, 8, 90},
212    {0, 1, 2, 3, 4, 5, 6, 8, 90},
213    {0, 1, 2, 3, 4, 5, 6, 8, 90},
214    {0, 1, 2, 3, 4, 5, 6, 8, 90},
215    {0, 1, 2, 3, 4, 5, 6, 8, 90},
216    {0, 1, 2, 3, 4, 5, 6, 8, 90},
217    {0, 1, 2, 3, 4, 5, 6, 8, 90},
218    {0, 1, 2, 3, 4, 5, 6, 8, 90},
219    {0, 1, 2, 3, 4, 5, 6, 8, 90},
220    {0, 1, 2, 3, 4, 5, 6, 8, 90},
221    {0, 1, 2, 3, 4, 5, 6, 8, 90},
222    {0, 1, 2, 3, 4, 5, 6, 8, 90},
223    {0, 1, 2, 3, 4, 5, 6, 8, 90},
224    {0, 1, 2, 3, 4, 5, 6, 8, 90},
225    {0, 1, 2, 3, 4, 5, 6, 8, 90},
226    {0, 1, 2, 3, 4, 5, 6, 8, 90},
227    {0, 1, 2, 3, 4, 5, 6, 8, 90},
228    {0, 1, 2, 3, 4, 5, 6, 8, 90},
229    {0, 1, 2, 3, 4, 5, 6, 8, 90}} ;
230    
231    
 Float_t C0t[48][9] = {0, 1, 2, 3, 4, 5, 6, 8, 92, 0, 1, 2, 3, 4, 5, 6, 8, 92, 0, 1, 2, 3, 4, 5, 6, 8, 92, 0, 1, 2, 3, 4, 5, 6, 8, 92, 0, 1, 2, 3, 4, 5, 6, 8, 92, 0, 1, 2, 3, 4, 5, 6, 8, 92,  
 0, 1, 2, 3, 4, 5, 6, 8, 92, 0, 1, 2, 3, 4, 5, 6, 8, 92, 0, 1, 2, 3, 4, 5, 6, 8, 92, 0, 1, 2, 3, 4, 5, 6, 8, 92, 0, 1, 2, 3, 4, 5, 6, 8, 92, 0, 1, 2, 3, 4, 5, 6, 8, 92,  
 0, 1, 2, 3, 4, 5, 6, 8, 92, 0, 1, 2, 3, 4, 5, 6, 8, 92, 0, 1, 2, 3, 4, 5, 6, 8, 92, 0, 1, 2, 3, 4, 5, 6, 8, 92, 0, 1, 2, 3, 4, 5, 6, 8, 92, 0, 1, 2, 3, 4, 5, 6, 8, 92,  
 0, 1, 2, 3, 4, 5, 6, 8, 92, 0, 1, 2, 3, 4, 5, 6, 8, 92, 0, 1, 2, 3, 4, 5, 6, 8, 92, 0, 1, 2, 3, 4, 5, 6, 8, 92, 0, 1, 2, 3, 4, 5, 6, 8, 92, 0, 1, 2, 3, 4, 5, 6, 8, 92,  
 0, 1, 2, 3, 4, 5, 6, 8, 92, 0, 1, 2, 3, 4, 5, 6, 8, 92, 0, 1, 2, 3, 4, 5, 6, 8, 92, 0, 1, 2, 3, 4, 5, 6, 8, 92, 0, 1, 2, 3, 4, 5, 6, 8, 92, 0, 1, 2, 3, 4, 5, 6, 8, 92,  
 0, 1, 2, 3, 4, 5, 6, 8, 92, 0, 1, 2, 3, 4, 5, 6, 8, 92, 0, 1, 2, 3, 4, 5, 6, 8, 92, 0, 1, 2, 3, 4, 5, 6, 8, 92, 0, 1, 2, 3, 4, 5, 6, 8, 92, 0, 1, 2, 3, 4, 5, 6, 8, 92,  
 0, 1, 2, 3, 4, 5, 6, 8, 92, 0, 1, 2, 3, 4, 5, 6, 8, 92, 0, 1, 2, 3, 4, 5, 6, 8, 92, 0, 1, 2, 3, 4, 5, 6, 8, 92, 0, 1, 2, 3, 4, 5, 6, 8, 92, 0, 1, 2, 3, 4, 5, 6, 8, 92,  
 0, 1, 2, 3, 4, 5, 6, 8, 92, 0, 1, 2, 3, 4, 5, 6, 8, 92, 0, 1, 2, 3, 4, 5, 6, 8, 92, 0, 1, 2, 3, 4, 5, 6, 8, 92, 0, 1, 2, 3, 4, 5, 6, 8, 92, 0, 1, 2, 3, 4, 5, 6, 8, 92 };  
232    
233  Float_t A0t[48][9] = {  Float_t A0t[48][9] = {
234  0, 0.90472, 5.19581, 7.99982, 11, 13, 16, 18, 2000, 0, 0.7774, 5.15121, 7.99976, 11, 13, 16, 18, 2000, 0, 1.18414, 5.1952, 8, 11, 13, 16, 17.9999, 2000, 0, 1.0189, 5.61869, 8, 11, 13.0006, 15.9998, 18.0014, 2000, 0, 1.08725, 4.4728, 7.99979, 11,  {0, 0.966862, 6.90746, 13.0828, 27.5276, 37.8862, 46.0339, 59.9999, 8100},
235  13.0002, 16, 18, 2000, 0, 0.946462, 4.69554, 7.99994, 11, 13.0001, 16, 18, 2000, 0, 1.13176, 4.57483, 7.99999, 11, 13.0002, 15.9999, 18.0002, 2000, 0, 1.00872, 4.99316, 8, 11, 13, 16, 18, 2000, 0, 1.19891, 5.01355, 8, 11, 13.0003, 16, 18, 2000, 0, 0.5,  {0, 0.89781, 6.27511, 12.0001, 16.3328, 26.9085, 48.9715, 60.0001, 8100},
236  2, 4.5, 5.50003, 6.50028, 8.00004, 8.99989, 2000, 0, 1.16961, 4.59028, 8, 11, 13.0001, 16, 18, 2000, 0, 0.989643, 5.21958, 7.99998, 11, 13, 16,  {0, 1.28799, 5.18918, 14.087, 23.9813, 26.9957, 37.3137, 57.6302, 8100},
237  17.9999, 2000, 0, 0.952029, 5.19598, 7.99998, 11, 13.0005, 16.0005, 18, 2000, 0, 0.736833, 4.95596, 8, 11, 13, 16, 18, 2000, 0, 1.34007, 3.74275, 8, 11, 13, 16, 18, 2000, 0, 1.47101, 4.31154, 8, 11, 13, 16, 18,  {0, 1.15409, 5.62046, 12.9582, 29.0246, 36.1749, 34.2915, 62.8713, 8100},
238  2000, 0, 1.3754, 4.83141, 8.00002, 11, 13, 16, 18, 2000, 0, 1.47712, 5.79783, 8, 11, 13, 16, 18, 2000, 0, 1.19127, 5.35796, 7.99996, 11, 13,  {0, 1.15346, 6.52882, 13.8033, 23.4424, 32.5014, 35.5784, 49.9999, 8100},
239  16, 18, 2000, 0, 1.25745, 5.98391, 8, 11, 13.0004, 16.0001, 18.0001, 2000, 0, 1.18024, 5.40107, 7.99999, 11, 13, 16, 18.0001, 2000, 0, 0.961883,  {0, 1.06303, 6.30765, 12.6676, 23.5195, 27.4434, 29.3732, 50.6973, 8100},
240  5.10846, 7.99999, 11, 13, 16, 18, 2000, 0, 1.23192, 6.21098, 8, 11, 13.0005, 16, 18.0003, 2000, 0, 1.15846, 5.23573, 7.99995,  {0, 1.19687, 6.39298, 14.352, 23.7507, 31.3431, 38.2434, 60, 8100},
241  11, 13, 16, 18.0002, 2000, 0, 1.26163, 5.5425, 8.00001, 11, 13.0002, 16.0006, 18, 2000, 0, 1.12754, 5.57064, 7.99999, 11, 13, 16, 18.0002,  {0, 1.08344, 5.69174, 13.1589, 29.0491, 33.8223, 34.5832, 42.4801, 8100},
242  2000, 0, 1.22768, 6.06283, 8, 11, 13.0002, 16, 18, 2000, 0, 1.83569, 5.87584, 8.00006, 11, 13.0005, 16, 18,  {0, 1.27778, 6.04128, 12.1344, 20, 29.5231, 40.6637, 70, 8100},
243  2000, 0, 1.61434, 5.56634, 7, 7.99999, 8.99999, 14.999, 16, 2000, 0, 1.61287, 5.46416, 7.99989, 10, 12, 14.9997, 16, 2000, 0, 1.49053,  {0, 1.1633, 6.24587, 15.3981, 22.6264, 25.4787, 40.9823, 54.3096, 8100},
244  6.21581, 9.00001, 12, 14, 16, 22, 2000, 0, 1.64579, 5.08498, 7.99989, 10, 12, 15, 16, 2000, 0, 1.83474, 6.29746, 9.00001, 12, 14.0001, 16.0001, 22,  {0, 1.25099, 5.51503, 13.0747, 25.7338, 28.0607, 29.3234, 43.1166, 8100},
245  2000, 0, 1.80066, 6.19725, 9, 12, 14, 16, 22, 2000, 0, 1.9025, 5.83736, 8, 10, 12, 14.9999, 16, 2000, 0, 1.90163, 5.62801, 7.99999, 10, 12, 15, 16, 2000, 0, 2.5518,  {0, 1.14791, 5.28525, 11.3329, 22.0258, 29.1518, 31.5672, 48.5941, 8100},
246  5.97325, 9.00012, 12, 15, 18, 22, 2000, 0, 2.53476, 5.75312, 9.00007, 12, 15, 18, 22, 2000, 0, 2.67784, 6.9232, 9.00005, 12, 15, 18, 22, 2000, 0, 2.62769, 7.22552, 9.00003,  {0, 0.989178, 6.46598, 16.008, 27.7832, 38.1067, 51.0926, 83.9029, 8100},
247  12.0001, 15, 18, 22, 2000, 0, 2.58088, 6.30413, 9.0001, 12, 15, 18, 22, 2000, 0, 2.48219, 7.06085, 9.00005, 12, 15, 18, 22, 2000, 0, 3.23157, 5.20668, 9.00007, 12, 15,  {0, 0.791611, 6.25114, 14.4726, 22.3348, 40.498, 38.8456, 76.8415, 8100},
248  18, 22, 2000, 0, 3.38244, 6.45172, 9.00006, 12.0001, 15, 18.0001, 22, 2000, 0, 3.14595, 5.29036, 9.00008, 12, 15, 18, 22.0001, 2000, 0, 3.34692, 6.17283, 9.00041, 12,  {0, 1.08442, 6.22537, 10.786, 13.7616, 22.0316, 34.2567, 70.0001, 8100},
249  15, 18.0001, 22, 2000, 0, 3.16915, 4.25973, 9.00015, 12, 15, 18, 22, 2000, 0, 3.25809, 5.58971, 9.00068, 12, 15, 18,  {0, 1.06481, 5.81616, 15.9999, 25.0001, 27.7402, 39.9999, 62.4627, 8100},
250  22.0001, 2000 } ;  {0, 1.54106, 7.73501, 14.8365, 33.808, 38.6967, 55.3031, 55.1627, 8100},
251    {0, 0.181194, 8.88375, 19.761, 30.0001, 37.5278, 60.0001, 79.9997, 8100},
252    {0, 1.20333, 6.4235, 14.438, 20.6791, 37.59, 43.0118, 84.5498, 8100},
253    {0, 1.38501, 6.33531, 12.6738, 26.5495, 32.5919, 39.7116, 66.775, 8100},
254    {0, 1.2447, 6.41472, 13.1281, 24.5903, 27.8925, 34.4098, 52.9463, 8100},
255    {0, 1.10032, 6.84365, 14.8743, 29.1848, 36.0101, 42.1412, 79.1916, 8100},
256    {0, 1.37387, 6.1759, 12.3971, 26.6771, 34.5125, 38.8504, 67.9609, 8100},
257    {0, 1.26074, 6.44693, 13.4109, 23.0619, 31.6812, 37.3077, 57.2156, 8100},
258    {0, 1.27824, 6.99981, 15.2662, 31.25, 40.268, 40.9496, 83.4595, 8100},
259    {0, 1.27135, 6.1494, 14.6932, 25.7259, 35.6644, 43.8106, 65.4656, 8100},
260    {0, 1.40868, 6.80116, 14.308, 22.7333, 28.8201, 43.6075, 75.1262, 8100},
261    {0, 2.17689, 7.12873, 14.4537, 26.6741, 33.406, 40.8852, 59.659, 8100},
262    {0, 1.8449, 11.9433, 21.2362, 34.4344, 43.4968, 54.9996, 60, 8100},
263    {0, 1.71308, 7.86445, 15.1826, 20.2075, 22.4894, 30, 40, 8100},
264    {0, 2.47299, 6.72486, 15.6655, 25.0002, 29.7029, 31.7548, 45, 8100},
265    {0, 1.73646, 7.28222, 14.6779, 20.0001, 23.1851, 24.6151, 34.9945, 8100},
266    {0, 2.10843, 8.61062, 17.3962, 28.7763, 39.014, 52.9373, 80.1161, 8100},
267    {0, 2.12514, 9.41508, 19.6945, 38.8657, 49.4172, 70.8189, 117.259, 8100},
268    {0, 1.96994, 8.71348, 16.2668, 20.6351, 22.7219, 30.0001, 50, 8100},
269    {0, 1.97711, 9.8935, 20.0511, 28.0006, 34.1434, 45.5466, 49.9974, 8100},
270    {0, 3.02174, 11.9467, 22.1838, 44.8834, 67.8526, 87.5638, 99.9968, 8100},
271    {0, 3.23019, 12.396, 21.1859, 43.4576, 69.1176, 102.143, 129.986, 8100},
272    {0, 3.05255, 11.4421, 22.1753, 39.4975, 57.5947, 75.0661, 109.538, 8100},
273    {0, 3.03561, 11.281, 21.7485, 35.0295, 55.2597, 77.795, 138.547, 8100},
274    {0, 2.74373, 10.8424, 22.9863, 46.0158, 63.3989, 85.9676, 100.002, 8100},
275    {0, 2.91456, 10.4374, 18.7076, 37.4149, 44.8928, 53.9337, 69.9997, 8100},
276    {0, 3.35025, 7.22152, 27.5385, 38.8628, 57.2992, 83.4745, 139.076, 8100},
277    {0, 3.29637, 11.1582, 23.0533, 46.9451, 65.503, 94.1756, 135.554, 8100},
278    {0, 3.17507, 12.3589, 22.0947, 47.3915, 78.6842, 117.078, 121.698, 8100},
279    {0, 3.27437, 12.2762, 22.9416, 48.1462, 72.4744, 117.944, 129.998, 8100},
280    {0, 3.3915, 11.4755, 24.4284, 42.7813, 65.1621, 93.6156, 147.765, 8100},
281    {0, 3.11795, 10.5757, 22.8067, 41.8451, 68.3004, 91.8733, 145.854, 8100} } ;
282    
283    
284  Float_t A1t[48][9] = {  Float_t A1t[48][9] = {
285  0, -0.148721, -3.39495, -4.31459, -0.929148, 3.54132, -0.781274, 1.31968, 0, 0, 0.300986, -2.80331, -4.23227, 0.298916, 4.10416, -5.18516, 7.03041, 0,  {0, -0.445487, -6.83011, -7.76746, -26.8019, -33.6372, -33.4238, -34.3206, 0},
286  0, -0.590177, -3.12529, -0.44614, 0.620419, 5.19609, 9.88925, 14.9819, 0, 0, -0.173358, -3.98938, -0.616916, 0.405404,  {0, -0.154046, -5.11675, -6.68917, -1.29614, -7.64427, -42.6283, -37.5536, 0},
287  6.25045, 10.5087, 24.7055, 0, 0, -0.32707, -1.1686, -3.46701, -0.284242, 4.09514, -0.561233, -0.166844, 0, 0, 0.0440221, -1.5147, -2.67239,  {0, -0.926441, -2.41216, -10.4314, -18.6624, -2.56534, -5.91767, -4.52255, 0},
288  -1.08848, 5.05632, 3.92546, -0.0525454, 0, 0, -0.331836, -1.25371, -1.59317, 0.654738, 4.41673, 5.99879,  {0, -0.669591, -3.17426, -8.41107, -30.2702, -28.1341, -0.952674, -28.7299, 0},
289  14.9057, 0, 0, 0.00587183, -2.17841, -1.48496, 0.477997, 6.24062, 6.19841, 11.4798, 0, 0, -0.515989, -2.1195, -1.44376, 0.145546, 5.41926,  {0, -0.650638, -5.55242, -9.21873, -16.4049, -19.1945, -9.79077, -25.7112, 0},
290  5.03587, 10.7126, 0, 0, 0, 0, -0.5, 0, 4.35377, 6.97709, 15.0047, 0, 0, -0.554732, -1.6306, -1.54677,  {0, -0.357887, -5.01401, -6.99931, -16.2411, -5.48061, 7.12013, -7.63631, 0},
291  0.687092, 3.97612, 4.05449, 3.44324, 0, 0, -0.0314164, -2.83515, -1.29946, 2.31597, 7.15645, 6.95353, 12.8573, 0, 0, -0.218413, -3.04095, -1.50327,  {0, -0.638868, -5.04599, -9.72543, -15.2232, -6.64514, 2.25032, 9.31463, 0},
292  0.291698, 5.27119, 9.06051, 18.4417, 0, 0, 0.410005, -2.45452, -0.851601, 0.206665, 6.44906, 7.53132,  {0, -0.357529, -3.33754, -8.25226, -29.5745, -20.183, 1.57311, 29.3872, 0},
293  10.5636, 0, 0, -1.29063, 0.463767, -0.720394, 1.27269, 3.66394, 4.52102, 7.33444, 0, 0, -1.54073, -1.60146, -1.91721, -0.640132, 3.58881, 0.561348,  {0, -0.812946, -4.17262, -5.66565, -4, -4.22773, -0.362511, -15.5266, 0},
294  7.33444, 0, 0, -0.558527, -2.43481, -1.64492, 1.51694, 6.05449, 4.67951, 5.40004, 0, 0, -1.44736, -5.265, -1.28878, -0.238869, 4.13668, 4.58264,  {0, -0.348653, -4.64069, -14.5046, -9.84901, -0.193718, -12.1145, 16.7739, 0},
295  3.28758, 0, 0, -0.596315, -3.35555, -2.03624, -0.148223, 6.16332, 4.71164, 15.6531, 0, 0, -0.740826, -4.79843, 0.345734, -0.210722, 6.32702, 9.76698, 19.9151, 0, 0, -0.541817,  {0, -0.861006, -3.09587, -8.27656, -22.4036, -8.06958, 8.55529, 16.6237, 0},
296  -3.30557, -1.76057, -0.216039, 5.79923, 8.00931, 16.4061, 0, 0, -0.0503124, -2.66635, -1.70196, -1.07446, 3.46058, 1.45824,  {0, -0.622119, -2.31927, -3.8959, -14.6788, -11.5365, 4.07618, 13.565, 0},
297  -2.21932, 0, 0, -0.495955, -5.78012, -0.174017, 0.675206, 6.30264, 8.30058, 20.3899, 0, 0, -0.315843, -2.8796, -3.04323, -0.681945, 5.49248, 7.42757,  {0, -0.5254, -5.57273, -15.4304, -24.9533, -23.3748, -30.7083, -60.3975, 0},
298  17.1667, 0, 0, -0.643179, -3.5364, -0.245549, 0.694213, 5.79727, 10.2911, 9.61651, 0, 0, -0.315433, -3.56856, -1.25894, 2.05501, 6.85829, 8.74895,  {0, 0.0969597, -4.99926, -12.3993, -14.8107, -37.9522, -10.6047, -50.5152, 0},
299  14.9955, 0, 0, -0.478207, -4.82517, 0.688668, 1.40183, 6.78743, 8.02806, 2.65821, 0, 0, -1.63072, -5.05269, -0.582789, 1.22014, 6.80023, 8.8931, 5.15517, 0, 0,  {0, -0.933961, -5.87726, -3.98088, 2.03266, 1.00194, -13.1254, -37.0729, 0},
300  -1.50826, -3.68958, 0.420744, 3.25124, 4.28046, -16.9712, -12, 0, 0, -1.52021, -3.37459, -2.41086, 0.547517, -0.56013, -8.59935, -3, 0, 0, -0.998702, -4.7187, -2.33974,  {0, -0.455788, -5.27479, -18.0196, -27.5684, -14.3756, -30.1785, -37.5799, 0},
301  -0.0974348, 3.10138, 2.3293, -5.71135, 0, 0, -1.66188, -2.39145, -2.55052, 0.29005, -0.16697, -3.97018, -1.5, 0, 0,  {0, -1.54773, -9.60851, -13.3097, -42.6674, -40.9163, -58.1322, -19.1456, 0},
302  -2.04431, -4.95214, -1.51889, 1.92081, 5.92476, 8.94417, -0.172422, 0, 0, -1.94155, -4.95644, -2.47063, 0.0233995, 2.57015, 4.84173,  {0, 4.8413, -11.2091, -20.5107, -26.3785, -10.1217, -32.6092, -38.9083, 0},
303  -0.555407, 0, 0, -2.22045, -4.21875, -1.23892, 0.911188, -0.705415, -11.5648, -7, 0, 0, -2.25418, -3.71067,  {0, -0.732962, -5.46743, -11.9727, -11.1357, -31.2803, -22.1011, -75.8073, 0},
304  -1.87307, 0.560423, 0.206679, -4.27293, -3, 0, 0, -3.90179, -5.14354, -4.08454, -3.13545, -3.57868, -5.13198, -1.0019, 0, 0, -3.78789, -4.50313,  {0, -1.23536, -5.59948, -9.07015, -28.2917, -22.0218, -18.8519, -34.4378, 0},
305  -5.24307, -3.24931, -0.319336, -1.407, -3.77821, 0, 0, -4.16337, -7.12861, -2.29639, -0.786276, 2.58494, 4.16162, 7.22747, 0, 0, -4.04189, -7.82707,  {0, -0.826823, -5.20145, -8.3843, -19.0111, -7.15699, -3.34332, -9.75121, 0},
306  -1.34893, -1.05519, 4.33166, 4.87264, 12.3328, 0, 0, -3.85946, -5.71064, -4.43564, -1.53025, 1.42505, -0.0695653, 4.33418, 0, 0, -3.65794, -8.19828,  {0, -0.577046, -6.28584, -11.4426, -28.0901, -21.3916, -12.5135, -61.76, 0},
307  -3.32738, -1.25785, -1.13124, -6.79745, -8.37113, 0, 0, -5.571, -2.49596, -2.8623, -2.74219, -1.43215, -0.359863, 0.25062, 0, 0, -6.00932, -5.60393,  {0, -0.956059, -5.00839, -7.22107, -25.7981, -25.7054, -15.0595, -40.2528, 0},
308  -2.33967, -1.53792, 3.67721, 5.49137, 8.34507, 0, 0, -5.36442, -3.19657, -2.9975, -1.73078, 0.0558693, -0.179221, 9.45231, 0, 0, -5.91858, -5.04606, -2.88549, -0.953526, 1.17816, 5.43427, 0.871257, 0,  {0, -0.810131, -5.26933, -8.78012, -15.6279, -16.893, -9.72584, -17.8252, 0},
309  0, -5.53832, -0.498886, -3.85789, -2.61557, -2.45863, -1.44554, -7.21927, 0, 0, -5.70059, -3.94476, -3.23927, 0.15573, 1.85295, 3.96162, 8.70362, 0 } ;  {0, -0.860119, -6.88744, -13.564, -35.2424, -35.6772, -14.8418, -77.2316, 0},
310    {0, -0.918947, -4.55685, -11.788, -23.1715, -26.2671, -25.1524, -32.8089, 0},
311    {0, -1.01825, -6.16033, -12.1071, -16.7393, -12.9732, -30.675, -67.521, 0},
312    {0, -2.63702, -7.23262, -12.3963, -29.1537, -26.1829, -24.3426, -35.0455, 0},
313    {0, -2.38232, -17.8376, -18.8801, -24.8636, -24.6509, -36.4698, -8.39844, 0},
314    {0, -1.96152, -8.79052, -11.6813, -4.72686, 4.81693, -4.2978, -8.39844, 0},
315    {0, -4.62994, -2.94981, -13.2937, -16.7482, -6.56193, 6.03485, -0.743217, 0},
316    {0, -2.06572, -7.28882, -11.7746, -5.47966, 0.813888, 10.4071, 20.0873, 0},
317    {0, -2.98167, -10.7673, -18.7865, -29.1646, -34.3681, -46.7229, -64.2386, 0},
318    {0, -3.09488, -12.6801, -23.2807, -50.5952, -50.3281, -77.6809, -127.885, 0},
319    {0, -2.6353, -11.327, -15.1071, -8.63713, -2.76153, -10.9598, -8.39844, 0},
320    {0, -2.69369, -14.0086, -23.0438, -20.243, -14.7684, -26.9053, 17.557, 0},
321    {0, -5.05491, -18.6246, -29.6528, -66.0253, -96.0606, -112.211, -87.435, 0},
322    {0, -5.6635, -19.449, -24.0238, -54.6138, -87.6223, -130.704, -149.534, 0},
323    {0, -5.14866, -17.6404, -30.0265, -53.7582, -74.4213, -88.8939, -107.031, 0},
324    {0, -5.1263, -17.4454, -28.9617, -43.0586, -71.6189, -103.028, -188.977, 0},
325    {0, -4.33081, -16.4979, -32.5261, -73.0454, -91.2755, -118.952, -83.7061, 0},
326    {0, -4.92134, -15.2835, -21.598, -48.8622, -43.3094, -40.5892, -69.4005, 0},
327    {0, -5.92968, -6.72971, -43.7034, -51.7821, -74.8294, -114.17, -209.667, 0},
328    {0, -5.65963, -17.484, -33.7998, -73.0621, -95.5599, -138.248, -182.989, 0},
329    {0, -5.45507, -20.3714, -29.0252, -69.4724, -120.52, -180.644, -117.081, 0},
330    {0, -5.67273, -20.3007, -32.4896, -74.9897, -109.782, -190.237, -146.269, 0},
331    {0, -6.15455, -18.331, -37.7733, -65.3947, -101.823, -146.711, -221.847, 0},
332    {0, -5.2493, -16.0076, -33.4883, -62.4233, -106.247, -139.708, -214.149, 0}};
333    
334    
335  Float_t A2t[48][9] = {  Float_t A2t[48][9] = {
336  0, 0.447567, 2.19777, 4.56362, 2.7416, 2.05411, 10.11, 19.0312, 0, 0, 0.11417, 1.62292, 5.00684, 3,  {0, 0.603703, 3.86157, 3.70388, 16.0228, 22.6954, 26.319, 44.3508, 0},
337  3.00006, 17.3401, 17.8502, 0, 0, 0.613665, 1.84729, 0.717669, 3, 2.53701, 1.23897, 10.2529, 0, 0, 0.318447, 2.30647, 0.936633, 3, 3, 2.95973, 3, 0, 0,  {0, 0.312779, 2.71821, 3.73851, 1.04468, 6.95408, 32.127, 46.5395, 0},
338  0.398201, 0.701095, 3.91236, 3, 3, 11.5693, 17.9749, 0, 0, 0.202853, 0.806934, 3.11779, 3.57657, 1.59933,  {0, 0.743361, 1.07616, 5.29201, 11.4779, 2.26256, 8.01082, 19.1997, 0},
339  6.71492, 23.6721, 0, 0, 0.378081, 0.60131, 1.91722, 1.97014, 3, 5.08036, 9.64776, 0, 0, 0.185602, 1.13243, 1.95726, 2.25608, 1.31382,  {0, 0.534443, 1.40779, 4.55333, 17.9865, 18.9162, 5.49797, 36.8004, 0},
340  6.06097, 15.9104, 0, 0, 0.519026, 1.16139, 1.92471, 3, 3, 6.24901, 15.0465, 0, 0, 0, 0, 0, 0, 3, 1.24657,  {0, 0.626433, 2.91524, 4.57075, 9.93735, 13.6735, 12.7599, 43.2477, 0},
341  0.76179, 0, 0, 0.584808, 1.01299, 1.55521, 1.3038, 3, 7.23646, 20.977, 0, 0, 0.252569, 1.60163, 1.83587, 0.630466, 0.777058, 6.0142, 15.4738, 0, 0,  {0, 0.403304, 2.5958, 3.37659, 9.36547, 4.78695, 3, 25.6807, 0},
342  0.434331, 1.84922, 1.83168, 3, 3, 3, 6.44375, 0, 0, 0.0330463, 1.50249, 1.15961, 3, 0.810556, 4.20175,  {0, 0.554686, 2.54239, 4.54521, 8.81473, 3.42239, 1.55152, 10.102, 0},
343  16.0172, 0, 0, 1.15272, -0.461141, 0.6358, 0.566375, 3.20343, 5.26698, 14.6336, 0, 0, 1.24677, 1.12736, 1.76074, 3, 3.77723, 10.7814, 14.6336, 0,  {0, 0.40188, 1.53765, 4.26228, 17.2971, 13.2302, 3.44777, 1.44658, 0},
344  0, 0.551726, 1.59633, 1.18411, 0.119382, 0.843864, 6.67491, 20.4289, 0, 0, 1.17008, 3.53223, 1.7298, 3,  {0, 0.686001, 2.0432, 2.49348, 0, 3, 1.5756, 25.2157, 0},
345  3.51043, 7.10543, 22.3253, 0, 0, 0.612142, 1.96606, 2.64693, 3.25016, 1.25888, 7.04821, 11.7283, 0, 0, 0.69148, 2.84536, 0.249509, 4.29848, 3,  {0, 0.123351, 2.27207, 8.01038, 3, 3, 12.2309, 3, 0},
346  3.58229, 9.01681, 0, 0, 0.565678, 1.96366, 2.32387, 3.15843, 1.66386, 3.07223, 7.67847, 0, 0, 0.286252,  {0, 0.73465, 1.47978, 4.24085, 13.1021, 6.44605, 0.681327, 8.34446, 0},
347  1.61749, 2.08437, 3.96745, 3.46972, 9.29207, 23.9444, 0, 0, 0.427677, 3.58328, 0.303785, 3, 3, 4.66547, 6.77271, 0, 0, 0.367136, 1.62323,  {0, 0.578203, 0.912111, 1.41144, 8.98856, 8.75212, 3, 7.95492, 0},
348  3.53394, 3.22174, 1.19152, 2.67962, 7.37085, 0, 0, 0.571177, 2.03267, 0.714761, 2.31548, 3, 3, 23.2035, 0,  {0, 0.654411, 2.97054, 8.56266, 14.2585, 13.2056, 22.2557, 56.2898, 0},
349  0, 0.410871, 2.02075, 2.01824, 1.2684, 1.18522, 3.21976, 12.8378, 0, 0, 0.463877, 2.86112, 0.170916, 3, 3, 5.97413, 28.4085, 0, 0, 1.30088,  {0, 0.194551, 2.5935, 6.94048, 9.31167, 24.9638, 11.8554, 46.4502, 0},
350  3.26557, 2, 3, 3, 4.77584, 22.8794, 0, 0, 1.02941, 2.12558, 0.872765, 2.23727, 4.7981, 24.6338, 24.6338, 0, 0, 1.05783, 1.89525, 2.85289, 3.0898,  {0, 0.927312, 3.54272, 2, 0.557114, 3, 17.0684, 35.3889, 0},
351  7.83407, 17.8466, 20, 0, 0, 0.87851, 2.49044, 1.91387, 2.41541, 3.8418, 9.41288, 24.0375, 0, 0, 1.18188, 1.273, 2.9275, 3.06704, 7.12642, 12.7629, 15,  {0, 0.528366, 3.31646, 10.7953, 18.5896, 11.9005, 27.3322, 43.338, 0},
352  0, 0, 1.53682, 2.57011, 1.06205, 0.506326, 1.68314, 3.58498, 23.1595, 0, 0, 1.46302, 2.68515, 1.99381, 2.17816, 4.41356, 6.53634,  {0, 0.912506, 5.8462, 7.66762, 25.6121, 29.5684, 42.9147, 38.2599, 0},
353  20.7136, 0, 0, 1.4731, 2.3654, 1.53025, 2.96327, 8.70277, 21.6253, 25, 0, 0, 1.53808, 2.07089, 2.22662, 3.14766, 7.57131, 14.2471, 20, 0, 0,  {0, -7.12979, 6.21087, 11.6741, 17.4818, 6.79753, 26.0391, 58.7369, 0},
354  2.54185, 2.94079, 2.66362, 3.52374, 6.80629, 11.3325, 14.5186, 0, 0, 2.43664, 2.49436, 4.17446, 3.77162,  {0, 0.665521, 2.95822, 6.47192, 7.05822, 20.8593, 18.9282, 65.3209, 0},
355  3.31898, 7.43896, 18.2548, 0, 0, 2.66465, 3.9858, 1.0855, 1.91916, 1.82719, 3.62289, 11.3872, 0, 0, 2.59071, 4.39003, 0.0757547, 3, 0.158868,  {0, 1.01894, 3.18477, 5.19886, 18.0916, 15.3677, 17.1022, 37.5697, 0},
356  3.55454, 5.71387, 0, 0, 2.48014, 3.16071, 3.1975, 1.7259, 1.53532, 6.33812, 11.2325, 0, 0, 2.35236,  {0, 0.721677, 2.71689, 4.22996, 11.1311, 6.35347, 8.49712, 27.3577, 0},
357  4.94998, 1.78836, 1.9115, 4.74233, 13.6973, 21.965, 0, 0, 3.52215, 0.812087, 1.1768, 2.95239, 4.3202, 6.04614, 13.6556, 0, 0, 3.79446, 2.80606,  {0, 0.603829, 3.38297, 5.7368, 16.4073, 14.4175, 13.3666, 61.5047, 0},
358  0.88371, 3, 0.614106, 2.52782, 12.4441, 0, 0, 3.41363, 1.57296, 1.59021, 2.47593, 3.41146, 6.76304, 5.59471, 0, 0, 3.72529, 2.50889, 2, 3, 4.06815, 2.78676,  {0, 0.707386, 2.73555, 3.78417, 15.7034, 17.5119, 14.2389, 42.0363, 0},
359  19.6427, 0, 0, 3.54713, -0.296079, 2.10851, 2.42037, 5.37573, 6.78065, 22.298, 0, 0, 3.61517, 1.96909, 2, 0.249865, 2.46639, 3.42483, 8.1652, 0 } ;  {0, 0.607098, 2.73084, 4.67754, 9.60779, 12.6869, 12.1505, 31.9974, 0},
360    {0, 0.661681, 3.79845, 7.40469, 21.1087, 23.2647, 14.5452, 68.5165, 0},
361    {0, 0.759887, 2.30697, 6.18542, 14.5154, 18.0736, 21.6141, 40.9744, 0},
362    {0, 0.3993, 3.20066, 6.95586, 10.3351, 10.6496, 25.789, 62.6339, 0},
363    {0, 1.11922, 4.03052, 7.15435, 19.0396, 19.5893, 21.629, 44.3572, 0},
364    {0, 1.67562, 9.80356, 7.57421, 11.7968, 17.3663, 33.0567, 28.6826, 0},
365    {0, 1.40668, 4.83038, 5.51678, 1.37774, 0.515603, 13.2881, 28.6826, 0},
366    {0, 3.26101, 0.0412805, 6.93063, 8.88441, 4.63011, 3, 25.3611, 0},
367    {0, 1.4764, 3.91391, 6.07754, 1.73516, 3, 3, 0, 0},
368    {0, 1.99777, 6.09319, 10.6805, 17.6838, 23.1259, 33.9526, 56.8642, 0},
369    {0, 2.09954, 7.17996, 13.001, 29.8411, 30.6333, 51.8831, 95.4856, 0},
370    {0, 1.80733, 6.5434, 7.91278, 5.34262, 8.17397, 18.3942, 28.6826, 0},
371    {0, 1.85376, 8.04532, 12.3798, 10.2491, 11.3718, 26.4686, 0, 0},
372    {0, 3.17369, 10.6479, 17.0112, 38.8841, 56.9463, 67.0329, 68.4495, 0},
373    {0, 3.57082, 11.0378, 12.2117, 29.7697, 49.3163, 74.7644, 111.901, 0},
374    {0, 3.23427, 10.1924, 17.1503, 31.2101, 44.171, 53.5184, 70.3691, 0},
375    {0, 3.23098, 10.1544, 16.4254, 24.8279, 43.4414, 64.6698, 122.023, 0},
376    {0, 2.73301, 9.65117, 18.883, 44.9873, 56.0859, 74.1037, 59.0439, 0},
377    {0, 3.13644, 8.83143, 12.0223, 28.0669, 24.5783, 24.7598, 68.4073, 0},
378    {0, 3.73914, 3.39684, 25.5464, 30.2677, 45.1122, 71.13, 143.934, 0},
379    {0, 3.47069, 10.3132, 20.0929, 43.0092, 57.7104, 85.0343, 123.773, 0},
380    {0, 3.45366, 12.0263, 15.9729, 39.5061, 71.0447, 107.589, 81.6047, 0},
381    {0, 3.54807, 12.0303, 19.0313, 44.4776, 66.7032, 116.232, 101.634, 0},
382    {0, 3.93093, 10.8482, 22.6813, 39.5255, 64.357, 93.1016, 147.004, 0},
383    {0, 3.30655, 9.37748, 20.0108, 37.5016, 65.6635, 88.695, 142.669, 0}};
384    
385  // S115B failure: 1158700000 // 2006-09-19 21:06:40 UTC  // S115B failure: 1158700000 // 2006-09-19 21:06:40 UTC
386    
387  if (time > 1158700000.) {     // first workaround: just use calibration of PMT S115A  if (time > 1158700000.) {     // if time > 2006-09-19 use special constants for PMT S115B
388    Float_t A0tx1[9] = {0, 1.1633, 6.24587, 9.51267, 15.1138, 14.404, 15.5928, 20.3819, 8100};
389    Float_t A1tx1[9] = {0, -0.348653, -4.64069, -3.15991, -2.33796, 6.02431, 14.7019, 26.2542, 0};
390    Float_t A2tx1[9] = {0, 0.123351, 2.27207, 3.22407, 3, 3, 0.0440895, 0.542518, 0};
391    
392  for ( Int_t jj=0; jj<9; jj++ ){  for ( Int_t jj=0; jj<9; jj++ ){
393  A0t[9][jj] = A0t[8][jj] ;  A0t[9][jj] = A0tx1[jj] ;
394  A1t[9][jj] = A1t[8][jj] ;  A1t[9][jj] = A1tx1[jj] ;
395  A2t[9][jj] = A2t[8][jj] ;  A2t[9][jj] = A2tx1[jj] ;
396                                  }
397                             } // if time...
398    
399    // 1167605999  31 dec 2006  S11A has problems with the dEdx
400    
401    if (time > 1167605999 ) {    
402    Float_t A0tx2[9] = {0, 1.27778, 6.04128, 18.2621, 29.9833, 40, 48.6853, 70, 8100};  
403    Float_t A1tx2[9] = {0, -0.812946, -4.17262, -15.0648, -23.4309, -17.3787, -6.03927, 7.16296, 0};
404    Float_t A2tx2[9] = {0, 0.686001, 2.0432, 7.23452, 13.607, 10.2901, 5.99052, 15.045, 0};
405    for ( Int_t jj=0; jj<9; jj++ ){
406    A0t[8][jj] = A0tx2[jj] ;
407    A1t[8][jj] = A1tx2[jj] ;
408    A2t[8][jj] = A2tx2[jj] ;
409                                }                                }
410                           } // if time...                           } // if time...
411    
412    
413  //============================================================================  //============================================================================
414    
415  //  2nd-order correction  //  2nd-order correction
416  Float_t corr_a[6][4] = {  0.977261,  0.353729,  -0.83314,  0.452883, 1.27649,  3.53459,  Float_t corr_a[6][4] = {  
417  -5.41948,  2.67854, 2.21926,  4.32797,  -7.24001,  3.77247,  2.4202,  7.99552,  {0.977261,  0.353729,  -0.83314,  0.452883},
418  -12.4371,  6.08982, 2.04984,  13.3375, -19.178,  8.86101,  2.63322,  14.8072,  -20.911,  {1.27649,  3.53459, -5.41948,  2.67854},
419  9.57905 };  {2.21926,  4.32797,  -7.24001,  3.77247},  
420    {2.4202,  7.99552,-12.4371,  6.08982},
421    {2.04984,  13.3375, -19.178,  8.86101},  
422    {2.63322,  14.8072,  -20.911,9.57905} };
423    
424  //---------------------------------------------------------------------  //---------------------------------------------------------------------
425    
# Line 223  Float_t xv[6],yv[6]; Line 427  Float_t xv[6],yv[6];
427  Int_t  iz;  Int_t  iz;
428  Float_t x1[9],y1[9];  Float_t x1[9],y1[9];
429  Int_t n1 = 9;  Int_t n1 = 9;
430  Float_t  Layercharge[6] = {1000., 1000., 1000., 1000., 1000., 1000. };  
431    Float_t  Layercharge[6] = {1005., 1005., 1005., 1005., 1005., 1005. };
432    
433  Int_t  Layerinfo[6] = {0, 0, 0, 0, 0, 0 };  Int_t  Layerinfo[6] = {0, 0, 0, 0, 0, 0 };
434    
435  //------------------------------------------------------------------  //Float_t adc[48],adc_c[48],PMTcharge_arr[48];
436    Float_t adc[48],PMTcharge_arr[48];
437    
438  PamTrack *track = L2->GetTrack(0);  //------------------------------------------------------------------
439    
440    //PamTrack *track = L2->GetTrack(0);
441     PamTrack *track = L2->GetTrack(0,trkAlg);
442  Float_t beta_mean = fabs(track->GetToFTrack()->beta[12]);  Float_t beta_mean = fabs(track->GetToFTrack()->beta[12]);
443  Float_t def = track->GetTrkTrack()->al[4];  
444  Float_t rig = 1./def;  // New!! If "beta_in" != 100. then overwrite beta_mean with beta_in
445    if (beta_in != 100.) beta_mean=beta_in;
446    
447    //Float_t def = track->GetTrkTrack()->al[4];
448    //Float_t rig = 1./def;
449    
450  Int_t ncount=0;  Int_t ncount=0;
451  Float_t charge_chi=1000.;  Float_t charge_chi=1000.;
452    
453  if ((beta_mean > 0.05)  && (beta_mean < 1.5)) {  //----------------------------------------------------------------
454    
455    for (Int_t jj=0; jj<6; jj++){
456    xv[jj]=track->GetToFTrack()->xtr_tof[jj];
457    yv[jj]=track->GetToFTrack()->ytr_tof[jj];
458    }
459    
460    //----------------------------------------------------------------
461    
462    Float_t theta,dx,dy,dr;
463    
464          theta=0.;
465          dx=0.;
466          dy=0.;
467          dr=0.;
468    
469          if ((xv[0])<100.) {
470             dx = (xv[0])-(xv[5]);
471             dy = (yv[0])-(yv[5]);
472             dr = sqrt(dx*dx+dy*dy);
473             theta = atan(dr/77.5);
474          }
475    
476    
477    //  ratio helium to proton ca. 4
478        Float_t  hepratio = 4.;
479    
480  //-------------------------------------------------------------  //-------------------------------------------------------------
481  //------------------  ToF Charge ------------------------------  //------------------  ToF Charge ------------------------------
482  //-------------------------------------------------------------  //-------------------------------------------------------------
# Line 248  if ((beta_mean > 0.05)  && (beta_mean < Line 484  if ((beta_mean > 0.05)  && (beta_mean <
484  // fill adc and tdc  // fill adc and tdc
485    
486     Int_t ich,jj,kk;     Int_t ich,jj,kk;
    Float_t adc[48],adc_c[48],PMTcharge_arr[48];  
487    
488     for (ich=0; ich<48; ich++)   adc[ich]   = 4095.;     for (ich=0; ich<48; ich++)   adc[ich]   = 4095.;
489     for (ich=0; ich<48; ich++)   adc_c[ich] = 1000.;     //   for (ich=0; ich<48; ich++)   adc_c[ich] = 1000.;
490     for (ich=0; ich<48; ich++)   PMTcharge_arr[ich] = 1000.;     for (ich=0; ich<48; ich++)   PMTcharge_arr[ich] = 1000.;
491    
492    
493    
494    if ((beta_mean < 0.05)  || (beta_mean > 2.0)) {
495      for (Int_t jj=0; jj<48;jj++) charge_PMT_trk[jj] = 1001.;
496      for (Int_t jj=0; jj<6;jj++) charge_layer_trk[jj] = 1001.;
497      for (Int_t jj=0; jj<6;jj++) charge_layer_trk_raw[jj] = 1001.;
498      for (Int_t jj=0; jj<6;jj++) layerinfo_trk[jj] = 1001;
499      charge_trk = 1001.;
500      ncount_trk = 0;
501                                                  }
502    
503    
504    if ((beta_mean > 0.05)  && (beta_mean < 2.0)) {
505    
506     Float_t betahelp =   pow(beta_mean, 1.2);     Float_t betahelp =   pow(beta_mean, 1.2);
507    
508  //=======================================================================  //=======================================================================
# Line 269  if ((beta_mean > 0.05)  && (beta_mean < Line 518  if ((beta_mean > 0.05)  && (beta_mean <
518    
519         for (Int_t ipmt=0; ipmt<track->GetToFTrack()->npmtadc; ipmt++){         for (Int_t ipmt=0; ipmt<track->GetToFTrack()->npmtadc; ipmt++){
520            Float_t dEdx = track->GetToFTrack()->dedx[ipmt];            Float_t dEdx = track->GetToFTrack()->dedx[ipmt];
521              Int_t pmtadc = track->GetToFTrack()->pmtadc[ipmt];    
522        
523    //----------  S115B failure workaround  ---------------------------
524             if ((pmtadc==9) && (time > 1158700000)) {
525             Float_t x = adc[9];
526             Float_t adcr = 28.0407 + 0.628929*x - 5.80901e-05*x*x + 3.14092e-08*x*x*x;
527             adcr = adcr * cos(theta);
528             Float_t xpos=yv[0];
529             Float_t xkorr = 3.91621*exp(-0.0129234*xpos) + 7.23454*exp(0.102039*xpos) ;
530             xkorr=xkorr/hepratio;
531             dEdx = adcr/xkorr;
532                                                  }
533    //------------------------------------------------------------------    
534        
535            ym = dEdx*betahelp;            ym = dEdx*betahelp;
536            Int_t pmtadc = track->GetToFTrack()->pmtadc[ipmt];            //          Int_t adcflag = track->GetToFTrack()->adcflag[ipmt];
           Int_t adcflag = track->GetToFTrack()->adcflag[ipmt];  
537            L2->GetToFLevel2()->GetPMTIndex(pmtadc,jj,kk);            L2->GetToFLevel2()->GetPMTIndex(pmtadc,jj,kk);
538            if (adcflag==0) adc_c[pmtadc] = dEdx;            //          if (adcflag==0) adc_c[pmtadc] = dEdx;
           if (adc[pmtadc] > PMTsat[pmtadc]) adc_c[pmtadc] = 1000.;  
539    
           cout<<pmtadc<<" "<<adc[pmtadc]<<" "<<dEdx<<" "<<adc_c[pmtadc]<<endl;  
540    
541              //         if (adc[pmtadc] == 4095) adc_c[pmtadc] = 0.;
542             if (adc[pmtadc] == 4095) PMTcharge_arr[pmtadc] = 0.;
543    
544             //         if ((adc[pmtadc]>PMTsat[pmtadc]) && (adc[pmtadc]<4095)) adc_c[pmtadc] = 1000.;
545    
546           if (adc[pmtadc] < PMTsat[pmtadc]) {           if (adc[pmtadc] < PMTsat[pmtadc]) {
547  //----------------------------------------------------------------------------------------  //----------------------------------------------------------------------------------------
548  if ((pmtadc!=1) && (pmtadc!=9) || (pmtadc!=28) || (pmtadc!=29) || (pmtadc!=34)) {  //if ((pmtadc!=1) && (pmtadc!=9) && (pmtadc!=28) && (pmtadc!=29) && (pmtadc!=34)) {
549    
550      for ( Int_t jj=0; jj<9; jj++ ){      for ( Int_t jj=0; jj<9; jj++ ){
551      x1[jj] = A0t[pmtadc][jj]+A1t[pmtadc][jj]*beta_mean+A2t[pmtadc][jj]*beta_mean*beta_mean;      x1[jj] = A0t[pmtadc][jj]+A1t[pmtadc][jj]*beta_mean+A2t[pmtadc][jj]*beta_mean*beta_mean;
# Line 291  if ((pmtadc!=1) && (pmtadc!=9) || (pmtad Line 555  if ((pmtadc!=1) && (pmtadc!=9) || (pmtad
555      TGraph *gr2 = new TGraph(n1,x1,y1);      TGraph *gr2 = new TGraph(n1,x1,y1);
556      TSpline3 *spl2 = new TSpline3("grs",gr2);    // use a cubic spline      TSpline3 *spl2 = new TSpline3("grs",gr2);    // use a cubic spline
557      chelp = spl2->Eval(ym);      chelp = spl2->Eval(ym);
558        if (chelp<0.) chelp=0.0001;  //WM new
559      charge = TMath::Sqrt(chelp);      charge = TMath::Sqrt(chelp);
560      gr2->Delete();      gr2->Delete();
561      spl2->Delete();      spl2->Delete();
562      PMTcharge_arr[pmtadc] = charge;      PMTcharge_arr[pmtadc] = charge;
563                                                                           } // pmtadc != ...  
564    //                                                                         } // pmtadc != ...
565    
566  //----------------------------------------------------------------------------------------  //----------------------------------------------------------------------------------------
567    /*
568  if ((pmtadc==1) || (pmtadc==9) || (pmtadc==28) || (pmtadc==29) || (pmtadc==34)) {  if ((pmtadc==1) || (pmtadc==9) || (pmtadc==28) || (pmtadc==29) || (pmtadc==34)) {
569           for ( Int_t jj=0; jj<8; jj++ ){           for ( Int_t jj=0; jj<8; jj++ ){
570           yl = A0t[pmtadc][jj]+A1t[pmtadc][jj]*beta_mean+A2t[pmtadc][jj]*beta_mean*beta_mean;           yl = A0t[pmtadc][jj]+A1t[pmtadc][jj]*beta_mean+A2t[pmtadc][jj]*beta_mean*beta_mean;
# Line 305  if ((pmtadc==1) || (pmtadc==9) || (pmtad Line 573  if ((pmtadc==1) || (pmtadc==9) || (pmtad
573           m = (C0t[pmtadc][jj+1]*C0t[pmtadc][jj+1] - C0t[pmtadc][jj]*C0t[pmtadc][jj]) / (yh - yl);           m = (C0t[pmtadc][jj+1]*C0t[pmtadc][jj+1] - C0t[pmtadc][jj]*C0t[pmtadc][jj]) / (yh - yl);
574           b = (C0t[pmtadc][jj]*C0t[pmtadc][jj]) - m*yl;           b = (C0t[pmtadc][jj]*C0t[pmtadc][jj]) - m*yl;
575           chelp = m*ym + b;           chelp = m*ym + b;
576             if (chelp<0.) chelp=0.0001;  //WM new
577           charge= TMath::Sqrt(chelp);           charge= TMath::Sqrt(chelp);
578           PMTcharge_arr[pmtadc] = charge;           PMTcharge_arr[pmtadc] = charge;
579                               }                               }
580                                       } // jj=0..8                                       } // jj=0..8
581                                                                            } // if pmtadc ==....                                                                            } // if pmtadc ==....
582    */
583  //----------------------------------------------------------------------------------------  //----------------------------------------------------------------------------------------
584                                         } // adc < sat                                         } // adc < sat
585    
586               }   // ipmt...               }   // ipmt...
587    
588  //====================================================================  //====================================================================
589  //================  Find out the hitted ToF paddles    ===============  //================  Find out the hitted ToF paddles    ===============
590  //====================================================================  //====================================================================
591    
 for (Int_t jj=0; jj<6; jj++){  
 xv[jj]=track->GetToFTrack()->xtr_tof[jj];  
 yv[jj]=track->GetToFTrack()->ytr_tof[jj];  
 }  
   
592  Int_t PaddleIdOfTrack[6];  Int_t PaddleIdOfTrack[6];
593    
594  PaddleIdOfTrack[0] = L2->GetToFLevel2()->GetPaddleIdOfTrack(xv[0], yv[0], 0, 0.) ;  PaddleIdOfTrack[0] = L2->GetToFLevel2()->GetPaddleIdOfTrack(xv[0], yv[0], 0, 0.) ;
# Line 339  Int_t ihelp_a[6] = {0,16,28,32,36,42}; Line 605  Int_t ihelp_a[6] = {0,16,28,32,36,42};
605    
606  for (Int_t ilay=0; ilay<6; ilay ++) {  for (Int_t ilay=0; ilay<6; ilay ++) {
607  Int_t jj = PaddleIdOfTrack[ilay] ;  Int_t jj = PaddleIdOfTrack[ilay] ;
608  Float_t xhelp = 1000.;  //Float_t xhelp = 1000.;
609    Float_t xhelp = 1005.;
610    
611  if (jj == -1) Layerinfo[ilay] = -1;  if (jj == -1) Layerinfo[ilay] = -1;
612    
613  if (jj != -1) {  if (jj != -1) {
614  Int_t ih = ihelp_a[ilay] + 2*jj;  Int_t ih = ihelp_a[ilay] + 2*jj;
615    
616    // New WM
617    Int_t igood1=0;
618    Int_t igood2=0;
619    if ((PMTcharge_arr[ih] < 1000.) && (PMTcharge_arr[ih] > 0.)) igood1=1;
620    if ((PMTcharge_arr[ih+1] < 1000.) && (PMTcharge_arr[ih+1] > 0.)) igood2=1;
621    
622    if ((PMTcharge_arr[ih]==0.) && (PMTcharge_arr[ih+1]==0.))  xhelp = 0.;
623    if ((igood1==1)&&(igood2==1)) xhelp = 0.5*(PMTcharge_arr[ih]+PMTcharge_arr[ih+1]) ;
624    if ((igood1==1)&&(igood2==0)) xhelp = PMTcharge_arr[ih];
625    if ((igood2==1)&&(igood1==0)) xhelp = PMTcharge_arr[ih+1];
626    
627    
628    /*
629  if ((PMTcharge_arr[ih] < 1000.) && (PMTcharge_arr[ih+1] < 1000.)) xhelp = 0.5*(PMTcharge_arr[ih]+PMTcharge_arr[ih+1]) ;  if ((PMTcharge_arr[ih] < 1000.) && (PMTcharge_arr[ih+1] < 1000.)) xhelp = 0.5*(PMTcharge_arr[ih]+PMTcharge_arr[ih+1]) ;
630  if ((PMTcharge_arr[ih] < 1000.) && (PMTcharge_arr[ih+1]==1000.))  xhelp = PMTcharge_arr[ih] ;  if ((PMTcharge_arr[ih] < 1000.) && (PMTcharge_arr[ih+1]==1000.))  xhelp = PMTcharge_arr[ih] ;
631  if ((PMTcharge_arr[ih]==1000.) && (PMTcharge_arr[ih+1] < 1000.))  xhelp = PMTcharge_arr[ih+1] ;  if ((PMTcharge_arr[ih]==1000.) && (PMTcharge_arr[ih+1] < 1000.))  xhelp = PMTcharge_arr[ih+1] ;
632    */
633     if (adc[ih] ==  4095) Layerinfo[ilay] = Layerinfo[ilay] + 1;     if (adc[ih] ==  4095) Layerinfo[ilay] = Layerinfo[ilay] + 1;
634     if (adc[ih+1] ==  4095) Layerinfo[ilay] = Layerinfo[ilay] + 1;     if (adc[ih+1] ==  4095) Layerinfo[ilay] = Layerinfo[ilay] + 1;
635     if ((adc[ih] > PMTsat[ih]) && (adc[ih] < 4095)) Layerinfo[ilay] = Layerinfo[ilay] + 10;     if ((adc[ih] > PMTsat[ih]) && (adc[ih] < 4095)) Layerinfo[ilay] = Layerinfo[ilay] + 10;
636     if ((adc[ih+1] > PMTsat[ih+1]) && (adc[ih+1] < 4095)) Layerinfo[ilay] = Layerinfo[ilay] + 10;     if ((adc[ih+1] > PMTsat[ih+1]) && (adc[ih+1] < 4095)) Layerinfo[ilay] = Layerinfo[ilay] + 10;
 //   cout<<ilay<<" "<<jj<<" "<<Layerinfo[ilay]<<endl;  
   
637         }         }
638  Layercharge[ilay] = xhelp;  Layercharge[ilay] = xhelp;
639                                      } // ilay ...                                      } // ilay ...
640    
641    
642  //cout<<"Trk : ";  
643  //for (Int_t ilay=0; ilay<6; ilay ++) cout<<Layercharge[ilay]<<" ";  //==========================================================================
644    //============= Layercharge without 2nd-order correction   =================
645    //==========================================================================
646    
647      for (Int_t jj=0; jj<6;jj++) charge_layer_trk_raw[jj] = Layercharge[jj];
648    
649  //==========================================================================  //==========================================================================
650  //=========================   2nd-order correction   =======================  //=========================   2nd-order correction   =======================
# Line 381  Float_t c_corr = corr[0]+corr[1]*xb+corr Line 664  Float_t c_corr = corr[0]+corr[1]*xb+corr
664  if ((ic>0)&&(ic<=5)) c_corr = c_corr/(1.*ic) ;  if ((ic>0)&&(ic<=5)) c_corr = c_corr/(1.*ic) ;
665  if (ic>5) c_corr = c_corr/6. ;  if (ic>5) c_corr = c_corr/6. ;
666    
667    //cout<<"beta "<<xb<<" layer "<<ii<<" ic "<<ic<<" => "<<c_corr<<endl;
668    //cout<<xb<<"  "<<ic<<"  "<<c_corr<<endl;
669    
670  Layercharge[ii] = Layercharge[ii]/c_corr;  Layercharge[ii] = Layercharge[ii]/c_corr;
671    
672                              }                              }
# Line 388  Layercharge[ii] = Layercharge[ii]/c_corr Line 674  Layercharge[ii] = Layercharge[ii]/c_corr
674  //==========================================================================  //==========================================================================
675  //==========================================================================  //==========================================================================
676    
677    
678  Int_t  icount=0;  Int_t  icount=0;
679  Float_t charge_mean = 0.;  Float_t charge_mean = 0.;
680  for (Int_t ii=0; ii<6;  ii++) {  for (Int_t ii=0; ii<6;  ii++) {
# Line 461  if (icount>0) { Line 748  if (icount>0) {
748  //  cout<<" => "<<icount<<" "<<charge_chi<<endl;  //  cout<<" => "<<icount<<" "<<charge_chi<<endl;
749    
750  //=============================================================  //=============================================================
751    // changed 30-01-2009 WM
752    
753      for (Int_t jj=0; jj<48;jj++) charge_PMT_trk[jj] = PMTcharge_arr[jj];
 } // 0.05 < beta < 1.5  
   
754    for (Int_t jj=0; jj<6;jj++) charge_layer_trk[jj] = Layercharge[jj];    for (Int_t jj=0; jj<6;jj++) charge_layer_trk[jj] = Layercharge[jj];
755    for (Int_t jj=0; jj<6;jj++) layerinfo_trk[jj] = Layerinfo[jj];    for (Int_t jj=0; jj<6;jj++) layerinfo_trk[jj] = Layerinfo[jj];
756    charge_trk = charge_chi;    charge_trk = charge_chi;
757    ncount_trk = ncount;    ncount_trk = ncount;
758    
759    } // 0.05 < beta < 2.0
760    
761  } // if ntrk == 1  } // if ntrk == 1
762    
763  //================================================================  //================================================================
# Line 477  if (icount>0) { Line 765  if (icount>0) {
765  //==============        standalone dEdx and beta     =============  //==============        standalone dEdx and beta     =============
766  //================================================================  //================================================================
767    
 // ToF track  
768    ToFTrkVar *track = L2->GetToFStoredTrack(-1);    ToFTrkVar *track = L2->GetToFStoredTrack(-1);
769  //  if(!track)return;  //  if(!track)return;
770    if(track) {    if(track) {
771    
772    /*
773  Float_t  PMTsat[48] = {  Float_t  PMTsat[48] = {
774  3162.14, 3165.48, 3153.85, 3085.73, 3089.65, 3107.64, 3097.52, 3078.37, 3130.05, 3087.07, 3112.22,  3162.14, 3165.48, 3153.85, 3085.73, 3089.65, 3107.64, 3097.52, 3078.37, 3130.05, 3087.07, 3112.22,
775  3102.92, 3080.58, 3092.55, 3087.94, 3125.03, 3094.09, 3143.16,  3102.92, 3080.58, 3092.55, 3087.94, 3125.03, 3094.09, 3143.16,
# Line 489  Float_t  PMTsat[48] = { Line 777  Float_t  PMTsat[48] = {
777  3097.99, 3033.84, 3134.98, 3081.37, 3111.04, 3066.77, 3108.17,  3097.99, 3033.84, 3134.98, 3081.37, 3111.04, 3066.77, 3108.17,
778  3133, 3111.06, 3052.52, 3140.66, 3106.33, 3094.85, 3150.85, 3118.8, 3096.24, 3118.47,3111.36, 3117.11  3133, 3111.06, 3052.52, 3140.66, 3106.33, 3094.85, 3150.85, 3118.8, 3096.24, 3118.47,3111.36, 3117.11
779  };  };
780    */
781    
782  Float_t C0t[48][9] = {  // new values from Napoli dec 2008
783  0, 1, 2, 3, 4, 5, 6, 8, 92, 0, 1, 2, 3, 4, 5, 6, 8, 92, 0, 1, 2, 3, 4, 5, 6, 8, 92,  Float_t  PMTsat[48] = {
784  0, 1, 2, 3, 4, 5, 6, 8, 92, 0, 1, 2, 3, 4, 5, 6, 8, 92, 0, 1, 2, 3, 4, 5, 6, 8, 92,  3176.35,3178.19,3167.38,3099.73,3117.00,3126.29,3111.44,3092.27,
785  0, 1, 2, 3, 4, 5, 6, 8, 92, 0, 1, 2, 3, 4, 5, 6, 8, 92, 0, 1, 2, 3, 4, 5, 6, 8, 92,  3146.48,3094.41,3132.13,3115.37,3099.32,3110.97,3111.80,3143.14,
786  0, 1, 2, 3, 4, 5, 6, 8, 92, 0, 1, 2, 3, 4, 5, 6, 8, 92, 0, 1, 2, 3, 4, 5, 6, 8, 92,  3106.72,3153.44,3136.00,3188.96,3104.73,3140.45,3073.18,3106.62,
787  0, 1, 2, 3, 4, 5, 6, 8, 92, 0, 1, 2, 3, 4, 5, 6, 8, 92, 0, 1, 2, 3, 4, 5, 6, 8, 92,  3112.48,3146.92,3127.24,3136.52,3109.59,3112.89,3045.15,3147.26,
788  0, 1, 2, 3, 4, 5, 6, 8, 92, 0, 1, 2, 3, 4, 5, 6, 8, 92, 0, 1, 2, 3, 4, 5, 6, 8, 92,  3095.92,3121.05,3083.25,3123.62,3150.92,3125.30,3067.60,3160.18,
789  0, 1, 2, 3, 4, 5, 6, 8, 92, 0, 1, 2, 3, 4, 5, 6, 8, 92, 0, 1, 2, 3, 4, 5, 6, 8, 92,  3119.36,3108.92,3164.77,3133.64,3111.47,3131.98,3128.87,3135.56 };
 0, 1, 2, 3, 4, 5, 6, 8, 92, 0, 1, 2, 3, 4, 5, 6, 8, 92, 0, 1, 2, 3, 4, 5, 6, 8, 92,  
 0, 1, 2, 3, 4, 5, 6, 8, 92, 0, 1, 2, 3, 4, 5, 6, 8, 92, 0, 1, 2, 3, 4, 5, 6, 8, 92,  
 0, 1, 2, 3, 4, 5, 6, 8, 92, 0, 1, 2, 3, 4, 5, 6, 8, 92, 0, 1, 2, 3, 4, 5, 6, 8, 92,  
 0, 1, 2, 3, 4, 5, 6, 8, 92, 0, 1, 2, 3, 4, 5, 6, 8, 92, 0, 1, 2, 3, 4, 5, 6, 8, 92,  
 0, 1, 2, 3, 4, 5, 6, 8, 92, 0, 1, 2, 3, 4, 5, 6, 8, 92, 0, 1, 2, 3, 4, 5, 6, 8, 92,  
 0, 1, 2, 3, 4, 5, 6, 8, 92, 0, 1, 2, 3, 4, 5, 6, 8, 92, 0, 1, 2, 3, 4, 5, 6, 8, 92,  
 0, 1, 2, 3, 4, 5, 6, 8, 92, 0, 1, 2, 3, 4, 5, 6, 8, 92, 0, 1, 2, 3, 4, 5, 6, 8, 92,  
 0, 1, 2, 3, 4, 5, 6, 8, 92, 0, 1, 2, 3, 4, 5, 6, 8, 92, 0, 1, 2, 3, 4, 5, 6, 8, 92,  
 0, 1, 2, 3, 4, 5, 6, 8, 92, 0, 1, 2, 3, 4, 5, 6, 8, 92, 0, 1, 2, 3, 4, 5, 6, 8, 92 };  
790    
791    for (Int_t i=0; i<48;i++) PMTsat[i] = PMTsat[i] - 5.;  // safety margin
792    
793    // calibration file "charge_fits_10th_std.dat"
794    
795    Float_t C0t[48][9] = {
796    {0, 1, 2, 3, 4, 5, 6, 8, 90},
797    {0, 1, 2, 3, 4, 5, 6, 8, 90},
798    {0, 1, 2, 3, 4, 5, 6, 8, 90},
799    {0, 1, 2, 3, 4, 5, 6, 8, 90},
800    {0, 1, 2, 3, 4, 5, 6, 8, 90},
801    {0, 1, 2, 3, 4, 5, 6, 8, 90},
802    {0, 1, 2, 3, 4, 5, 6, 8, 90},
803    {0, 1, 2, 3, 4, 5, 6, 8, 90},
804    {0, 1, 2, 3, 4, 5, 6, 8, 90},
805    {0, 1, 2, 3, 4, 5, 6, 8, 90},
806    {0, 1, 2, 3, 4, 5, 6, 8, 90},
807    {0, 1, 2, 3, 4, 5, 6, 8, 90},
808    {0, 1, 2, 3, 4, 5, 6, 8, 90},
809    {0, 1, 2, 3, 4, 5, 6, 8, 90},
810    {0, 1, 2, 3, 4, 5, 6, 8, 90},
811    {0, 1, 2, 3, 4, 5, 6, 8, 90},
812    {0, 1, 2, 3, 4, 5, 6, 8, 90},
813    {0, 1, 2, 3, 4, 5, 6, 8, 90},
814    {0, 1, 2, 3, 4, 5, 6, 8, 90},
815    {0, 1, 2, 3, 4, 5, 6, 8, 90},
816    {0, 1, 2, 3, 4, 5, 6, 8, 90},
817    {0, 1, 2, 3, 4, 5, 6, 8, 90},
818    {0, 1, 2, 3, 4, 5, 6, 8, 90},
819    {0, 1, 2, 3, 4, 5, 6, 8, 90},
820    {0, 1, 2, 3, 4, 5, 6, 8, 90},
821    {0, 1, 2, 3, 4, 5, 6, 8, 90},
822    {0, 1, 2, 3, 4, 5, 6, 8, 90},
823    {0, 1, 2, 3, 4, 5, 6, 8, 90},
824    {0, 1, 2, 3, 4, 5, 6, 8, 90},
825    {0, 1, 2, 3, 4, 5, 6, 8, 90},
826    {0, 1, 2, 3, 4, 5, 6, 8, 90},
827    {0, 1, 2, 3, 4, 5, 6, 8, 90},
828    {0, 1, 2, 3, 4, 5, 6, 8, 90},
829    {0, 1, 2, 3, 4, 5, 6, 8, 90},
830    {0, 1, 2, 3, 4, 5, 6, 8, 90},
831    {0, 1, 2, 3, 4, 5, 6, 8, 90},
832    {0, 1, 2, 3, 4, 5, 6, 8, 90},
833    {0, 1, 2, 3, 4, 5, 6, 8, 90},
834    {0, 1, 2, 3, 4, 5, 6, 8, 90},
835    {0, 1, 2, 3, 4, 5, 6, 8, 90},
836    {0, 1, 2, 3, 4, 5, 6, 8, 90},
837    {0, 1, 2, 3, 4, 5, 6, 8, 90},
838    {0, 1, 2, 3, 4, 5, 6, 8, 90},
839    {0, 1, 2, 3, 4, 5, 6, 8, 90},
840    {0, 1, 2, 3, 4, 5, 6, 8, 90},
841    {0, 1, 2, 3, 4, 5, 6, 8, 90},
842    {0, 1, 2, 3, 4, 5, 6, 8, 90},
843    {0, 1, 2, 3, 4, 5, 6, 8, 90}} ;
844    
845  Float_t A0t[48][9] = {  Float_t A0t[48][9] = {
846  0, 0.707632, 5.09223, 7.99994, 11, 13, 16, 18, 2000, 0, 0.636707, 6.37524, 8, 11, 13.0002,  {0, 0.626244, 5.57075, 13.0829, 27.5278, 37.886, 46.0338, 59.9999, 8100},
847  16.0001, 18, 2000, 0, 0.952117, 6.04188, 7.99999, 11, 13, 16, 18, 2000, 0, 0.880805, 5.80883,  {0, 0.669967, 6.13887, 12.0001, 16.3328, 26.9085, 48.9715, 60.0001, 8100},
848  8.00003, 11.0001, 13.0005, 16.0011, 18.0027, 2000, 0, 0.834937, 5.12617, 8, 11, 13, 16, 17.9998,  {0, 1.07525, 4.95494, 14.0867, 23.9813, 26.9957, 37.3137, 57.6302, 8100},
849  2000, 0, 0.772954, 5.17221, 8, 11, 13, 16, 18.0006, 2000, 0, 0.911496, 5.04755, 8, 11, 13, 16,  {0, 0.991496, 6.14099, 12.9582, 29.0247, 36.1749, 34.2915, 62.8713, 8100},
850  18, 2000, 0, 0.86523, 5.55215, 8, 11, 13, 16, 17.9999, 2000, 0, 1.06061, 5.49757, 12, 15, 20,  {0, 0.894996, 5.84777, 13.8033, 23.4423, 32.5014, 35.5784, 49.9998, 8100},
851  25, 25, 2000, 0, 0.5, 1.8, 3, 3.8, 6.49999, 7.99996, 8.99998, 2000, 0, 1.06974, 4.86153,  {0, 1.1336, 5.59475, 12.6677, 23.5195, 27.4434, 29.3735, 50.6974, 8100},
852  7.99999, 11, 13, 16, 18, 2000, 0, 1.0465, 6.00778, 8, 11, 13, 16, 17.9999, 2000, 0, 1.18132,  {0, 0.691118, 5.26701, 14.351, 23.7506, 31.3431, 38.2434, 60.0001, 8100},
853  5.48741, 8, 11, 13, 16, 17.9999, 2000, 0, 1.10823, 5.43611, 8, 11, 13, 16, 18.0001, 2000, 0,  {0, 1.02012, 6.17243, 13.1588, 29.049, 33.8223, 34.5832, 42.4809, 8100},
854  1.19621, 5.27647, 7.99994, 11, 13, 16, 18, 2000, 0, 1.72505, 5.14873, 8.00006, 11, 13, 16,  {0, 0.0309897, 7.24482, 16.2425, 35.4099, 44.1408, 55.1932, 70, 8100},
855  17.9999, 2000, 0, 1.48515, 6.07123, 8.00006, 11, 13.0003, 16, 17.9999, 2000, 0, 1.17628,  {0, 0.65965, -0.44638, 9.51268, 15.1138, 14.4038, 15.5924, 20.3806, 8100},
856  6.63392, 8.00011, 11, 13, 16, 17.9999, 2000, 0, 1.11301, 5.94317, 7.99999, 11, 13, 16, 18, 2000,  {0, 0.681447, 4.88613, 13.0747, 25.7335, 28.0607, 29.3234, 43.1167, 8100},
857  0, 1.04361, 6.40789, 8.00002, 11.0002, 13.0015, 16, 17.9996, 2000, 0, 1.12658, 5.69828, 8, 11,  {0, 1.21702, 6.06734, 11.333, 22.0258, 29.1518, 31.5672, 48.5941, 8100},
858  13, 16, 18.0001, 2000, 0, 0.840188, 5.44945, 8.00005, 11, 13, 16, 18, 2000, 0, 1.16985, 6.21385,  {0, 0.492463, 6.1436, 16.0077, 27.7831, 38.1067, 51.0924, 83.9029, 8100},
859  8.00012, 11, 13.0002, 16, 17.9999, 2000, 0, 0.977696, 5.70252, 8.00004, 11, 13, 16, 17.9999,  {0, 0.83562, 5.31218, 14.4727, 22.3348, 40.4978, 38.8456, 76.8416, 8100},
860  2000, 0, 1.26298, 6.03137, 8.00003, 11, 13, 16.0009, 17.9998, 2000, 0, 0.988707, 5.98453, 8, 11,  {0, 0.174564, 3.49201, 10.7861, 13.7616, 22.0316, 34.2567, 70.0001, 8100},
861  13, 16, 18.0001, 2000, 0, 1.22109, 6.76385, 8.00002, 11, 13.0005, 16.0001, 18.0006, 2000, 0,  {0, 1.29945, 3.93137, 15.9999, 24.9999, 27.7403, 39.9996, 62.4627, 8100},
862  1.65541, 6.01998, 8.00006, 11.0057, 13, 16, 18, 2000, 0, 1.59779, 6.00152, 7.00005, 7.99997,  {0, 1.33337, 6.4213, 14.8368, 33.8082, 38.6969, 55.3044, 55.1627, 8100},
863  8.99997, 14.9991, 18, 2000, 0, 1.6515, 5.95297, 7.99999, 10, 12, 14.9995, 18, 2000, 0, 1.70339,  {0, -2.66314, 6.37651, 19.7608, 30.0002, 37.528, 60.0003, 79.9994, 8100},
864  6.43684, 9, 12, 14, 16, 21.9999, 2000, 0, 1.64867, 5.6503, 8, 10, 12, 14.9999, 18, 2000, 0,  {0, 0.974379, 5.37316, 14.438, 20.6792, 37.5899, 43.0121, 84.549, 8100},
865  1.83955, 6.64378, 9, 12, 14, 16, 22, 2000, 0, 1.71975, 6.42585, 9, 12, 14, 16, 22, 2000, 0,  {0, 0.980116, 6.6121, 12.6738, 26.5497, 32.5919, 39.7116, 66.775, 8100},
866  1.88735, 6.12987, 8, 10, 12, 15.0001, 18, 2000, 0, 1.86719, 5.94227, 8, 10, 12, 14.9999, 20,  {0, 1.26686, 5.57744, 13.1284, 24.5904, 27.8926, 34.4098, 52.9463, 8100},
867  2000, 0, 2.55127, 5.83621, 8.99997, 12, 15, 17.9999, 21.9998, 2000, 0, 2.59328, 5.90275,  {0, 1.05908, 7.61144, 14.8745, 29.1849, 36.0101, 42.1412, 79.1916, 8100},
868  8.99999, 12, 15, 18, 22, 2000, 0, 2.63523, 6.56428, 9.00004, 12, 15.0003, 18.001, 22.0029, 2000,  {0, 1.05984, 6.1965, 12.3971, 26.6773, 34.5123, 38.8503, 67.9607, 8100},
869  0, 2.63114, 6.77412, 8.99995, 11.9998, 14.9997, 17.9996, 21.9998, 2000, 0, 2.48986, 6.43372,  {0, 1.07406, 6.15097, 13.4108, 23.062, 31.6812, 37.3077, 57.2156, 8100},
870  8.99996, 11.9998, 14.9995, 17.9997, 21.9995, 2000, 0, 2.43724, 6.51911, 9.00012, 12, 15, 18,  {0, 1.27716, 6.50522, 15.266, 31.25, 40.2676, 40.9496, 83.4598, 8100},
871  21.9999, 2000, 0, 3.21403, 5.7, 9, 12, 15, 18, 22, 2000, 0, 3.3517, 6.30461, 8.99997, 12, 15,  {0, 1.09161, 6.2145, 14.6937, 25.726, 35.6646, 43.8102, 65.4656, 8100},
872  18, 22, 2000, 0, 3.0843, 5.90189, 8.99993, 12, 15, 18, 22, 2000, 0, 3.35806, 6.20792, 8.99998,  {0, 1.37356, 7.38264, 14.3081, 22.7334, 28.8201, 43.6075, 75.1262, 8100},
873  12.0001, 15, 18, 22, 2000, 0, 3.13525, 5.60432, 8.99997, 12, 15.0001, 18, 22, 2000, 0, 3.26271,  {0, 1.94333, 5.62022, 14.4537, 26.6738, 33.4061, 40.8853, 59.6588, 8100},
874  6.38934, 9, 12, 15, 18, 22.0001, 2000 };  {0, 2.03697, 12.6287, 21.2366, 34.4342, 43.4967, 54.9998, 60, 8100},
875    {0, 1.86647, 7.13185, 15.1822, 20.2075, 22.4894, 30, 40, 8100},
876    {0, 2.18716, 7.9365, 15.6656, 25.0005, 29.7029, 31.755, 45, 8100},
877    {0, 1.79435, 7.24238, 14.6779, 20, 23.1849, 24.6151, 29.9996, 8100},
878    {0, 1.903, 8.60739, 17.3971, 28.7765, 39.0144, 52.9377, 80.1161, 8100},
879    {0, 2.0422, 9.39568, 19.6939, 38.8651, 49.4168, 70.8184, 117.258, 8100},
880    {0, 2.05025, 8.91676, 16.2662, 20.635, 22.7219, 30.0003, 50, 8100},
881    {0, 2.12015, 9.326, 20.0518, 28.0012, 34.1434, 45.5466, 49.9966, 8100},
882    {0, 2.58767, 9.7282, 22.1808, 44.8816, 67.8511, 87.5578, 99.9969, 8100},
883    {0, 3.10718, 11.1535, 21.186, 43.4575, 69.117, 102.142, 129.985, 8100},
884    {0, 3.26593, 12.3316, 22.175, 39.4979, 57.5949, 75.0662, 100, 8100},
885    {0, 2.48401, 7.28773, 19.7467, 30.0293, 45.2555, 60.7865, 100.537, 8100},
886    {0, 2.49424, 7.53288, 11.0001, 14, 18, 22, 30, 8100},
887    {0, 2.79325, 10.4782, 18.7078, 37.416, 44.8931, 53.9337, 69.9999, 8100},
888    {0, 3.34308, 10.753, 27.5373, 38.8625, 57.2984, 83.477, 139.082, 8100},
889    {0, 3.237, 10.5464, 23.0534, 46.944, 60.5023, 70.4994, 80.0005, 8100},
890    {0, 3.357, 10.8631, 22.0952, 47.3909, 78.6842, 117.079, 121.698, 8100},
891    {0, 3.2013, 10.6812, 19.9973, 30, 60.4706, 70.9416, 100.999, 8100},
892    {0, 3.05856, 10.4004, 24.423, 42.78, 65.1617, 93.6214, 147.771, 8100},
893    {0, 3.41072, 11.4925, 22.8054, 41.8445, 68.2985, 91.872, 145.849, 8100}};
894    
895  Float_t A1t[48][9] = {  Float_t A1t[48][9] = {
896  0, 0.182202, -3.48762, -4.67241, -5.61872, 2.35336, -2.4112, -0.7861, 0, 0, 0.528581, -6.33244,  {0, 0.684247, -4.14554, -11.1094, -24.5129, -38.2756, -41.0959, -19.0501, 0},
897  0.176685, -3.3272, 5.47434, 7.62771, 18.9223, 0, 0, -0.148985, -5.31035, -3.1044, -1.84685,  {0, 0.623673, -4.60109, -4.78271, -0.884499, -3.96897, -46.489, -22.5088, 0},
898  -0.678725, -0.00713058, 11.2127, 0, 0, 0.01113, -4.6759, -0.669811, 1.69435, 7.44019, 12.2231,  {0, -0.249597, -3.13851, -15.133, -22.6693, -10.2338, -17.5215, -4.78572, 0},
899  26.9653, 0, 0, 0.0567585, -3.05564, -2.57264, -0.0868904, 4.88938, 2.64699, -10, 0, 0, 0.331112,  {0, 0.0901572, -3.61432, -5.22235, -26.2322, -19.3028, 3.73157, 2.91283, 0},
900  -3.06987, -0.451796, -0.660912, 4.49088, 6.43095, 16.7904, 0, 0, 0.0779621, -2.64271, -2.29896,  {0, -0.135542, -4.18558, -10.3476, -19.8513, -21.8227, -2.345, -47.9072, 0},
901  -1.95824, 1.8888, 1.02257, 10.5746, 0, 0, 0.257346, -3.93191, 0.564894, 2.04068, 4.12823,  {0, -0.528203, -2.78581, -5.76259, -14.4398, -4.65071, 6.9809, 10.9591, 0},
902  5.87416, 16.2268, 0, 0, -0.332593, -3.65149, 0, 10, 20, 30, 40, 0, 0, 0, 0, -0.5, 0, -6.80247,  {0, 0.738867, -3.05266, -14.0515, -16.8378, -11.685, -2.39992, 9.73815, 0},
903  -9.43463, -8.44329, 0, 0, -0.25099, -2.53532, -2.43846, -2.94008, -1.01258, -1.10502, 5.16068,  {0, 0.0240829, -4.06428, -7.4387, -25.1373, -15.4164, 4.23546, 30.1758, 0},
904  0, 0, -0.101144, -4.98664, -0.369916, 2.2648, 4.2727, 3.1653, 19.8617, 0, 0, -0.5074, -3.98429,  {0, 3.76114, -3.88903, -14.2742, -40.7931, -35.2381, -27.9355, 4.64363, 0},
905  -0.306633, 0.562595, 5.05787, 4.70127, 14.2399, 0, 0, -0.326603, -3.83632, -1.75409, -1.86815,  {0, 2.53218, 10.3913, -4.60302, -5.07342, -4.32836, 6.74167, 10.6971, 0},
906  0.84194, 1.32718, 14.4304, 0, 0, -0.597543, -3.82759, -6.9094, -2.88583, 5.50573, 4.30943,  {0, 0.734454, -1.34727, -8.2282, -24.7553, -12.4964, -2.70228, 12.3389, 0},
907  18.0664, 0, 0, -1.86862, -3.80777, -2.69084, -4.09258, 1.59904, 4.61543, 13.8186, 0, 0,  {0, -0.607144, -4.88443, -3.87857, -14.385, -14.7764, -0.913896, 9.46744, 0},
908  -0.932447, -6.02195, -0.891975, 0.870346, 7.22131, 6.03928, 20.5102, 0, 0, -0.439221, -7.66335,  {0, 1.18779, -4.14515, -13.6006, -23.6426, -21.2445, -30.6746, -14.5969, 0},
909  -2.7363, -3.29581, 3.74263, 3.2571, 15.8539, 0, 0, -0.487944, -5.05733, -2.61662, -2.86336,  {0, 0.230348, -3.47996, -13.5497, -13.5157, -42.2043, -18.865, -44.7452, 0},
910  2.65017, -0.919043, 7.10535, 0, 0, -0.0329559, -6.07396, -0.0044396, 2.75593, 8.87808, 14.9627,  {0, 2.43646, 0.989512, -3.92652, -0.0489174, -5.7052, -13.7881, -34.5402, 0},
911  28.8783, 0, 0, -0.573054, -4.15302, -2.15074, -1.83499, 0.969726, 1.36361, 17.6185, 0, 0,  {0, 0.508931, -1.76998, -20.025, -27.0253, -19.5194, -42.5512, -18.2329, 0},
912  0.238198, -3.75628, -1.02674, 1.12711, 3.06917, 2.61956, 11.2723, 0, 0, -0.473325, -5.88165,  {0, -0.279749, -6.95578, -12.9933, -42.4332, -30.4393, -45.8736, -11.4401, 0},
913  -2.10476, -0.508963, 4.24835, 6.41943, 14.9346, 0, 0, 0.0585487, -4.40372, -1.45949, 1.31992,  {0, 14.1581, -3.80609, -22.8216, -18.5728, -11.4838, -29.6653, -63.3054, 0},
914  4.7115, 5.03433, 11.968, 0, 0, -0.836615, -5.05945, -0.644868, 2.3894, 9.40413, 11.4195,  {0, 0.203648, -5.06129, -17.2442, -15.9798, -41.6745, -34.0871, -93.4167, 0},
915  25.3239, 0, 0, 0.026064, -4.78872, -0.819969, -0.57223, 1.84866, 0.29272, 15.1362, 0, 0,  {0, 0.527513, -5.25737, -5.07905, -19.5563, -9.89318, -0.0190118, -12.1354, 0},
916  -0.659228, -6.61715, 0.371846, 4.36719, 10.657, 17.8551, 29.3359, 0, 0, -1.27483, -4.52966,  {0, -0.987681, -4.45351, -10.8727, -22.6132, -11.9238, -8.73394, 0.495203, 0},
917  -1.85458, -0.9634, 3.65819, 2.89211, 13.508, 0, 0, -1.49858, -5.08299, 0.103222, 3.84545,  {0, -0.307322, -7.51125, -9.25771, -22.5488, -18.0782, -8.63964, -35.6685, 0},
918  3.46523, -13.6535, -20, 0, 0, -1.70043, -4.92192, -2.46523, -0.681845, -2.80632, -8.55159, -20,  {0, 0.12121, -5.91873, -8.14844, -26.6183, -27.4172, -17.9023, -45.658, 0},
919  0, 0, -1.85437, -5.65787, -1.56314, 0.372468, 4.54151, 2.97956, -7.90681, 0, 0, -1.78092,  {0, -0.0440127, -4.60804, -8.96586, -14.1608, -16.407, -9.45833, -13.0969, 0},
920  -4.19601, -1.84397, -0.175657, -2.0339, -5.64021, -20, 0, 0, -2.08786, -6.05197, -1.81875,  {0, -0.558487, -5.03789, -11.2856, -31.7381, -32.7836, -10.3583, -51.1819, 0},
921  -0.423923, 5.86772, 7.50042, 4.22714, 0, 0, -1.78679, -5.6835, -1.22858, -0.764359, 2.71007,  {0, -0.319563, -6.28345, -13.2449, -26.0895, -32.1212, -34.8085, -35.3115, 0},
922  4.16034, 4.49981, 0, 0, -2.21623, -5.39176, -0.174751, 0.19786, -1.93316, -7.45927, -20, 0, 0,  {0, -0.438421, -6.76323, -8.04215, -6.24, -3.51572, -3.26923, -14.7792, 0},
923  -2.2076, -4.93708, -1.49415, 0.576195, 0.552502, -5.02466, -18, 0, 0, -3.95472, -4.97236,  {0, -2.29529, -5.92959, -15.9074, -34.9195, -35.4169, -41.1345, -47.2614, 0},
924  -5.73642, -7.17611, -8.40014, -10.7071, -13.5198, 0, 0, -3.98713, -4.90269, -4.51467, -4.74549,  {0, -2.8399, -19.7623, -14.4555, -22.8945, -25.4665, -22.8025, -8.39844, 0},
925  -5.13124, -6.02539, -4.36386, 0, 0, -4.09193, -6.36148, -1.92129, 0.535293, 4.36379, 8.09335,  {0, -2.3361, -7.44249, -13.7837, -8.14004, -0.0720474, -7.50509, -8.39844, 0},
926  21.4513, 0, 0, -4.09301, -6.86077, -8.51634, -10.7671, -15.4194, -19.8748, -18.2532, 0, 0,  {0, -3.36944, -8.64707, -13.0254, -16.0805, -1.85751, 8.52888, 0.550509, 0},
927  -3.66083, -6.39249, -8.20002, -12.5867, -18.523, -21.1403, -22.5493, 0, 0, -3.66449, -6.84751,  {0, -2.18295, -7.89578, -12.4464, -7.93621, -6.2682, 6.24761, 14.8709, 0},
928  -3.49245, -4.82854, 0.21682, 0.54105, -16.1417, 0, 0, -5.55283, -4.22, -4.20093, -2.0392,  {0, -2.52134, -12.1011, -19.5864, -28.3525, -32.0441, -40.9499, -24.6919, 0},
929  -1.493, 0.481244, 6.28662, 0, 0, -5.93701, -5.45729, -6.95403, -6.68625, -5.13187, -5.10613,  {0, -2.64214, -12.1746, -21.8649, -49.8572, -50.3294, -77.8674, -91.4326, 0},
930  -2.64945, 0, 0, -5.25381, -4.94071, -7.72978, -4.67849, -4.74316, -3.91651, 1.17451, 0, 0,  {0, -2.83382, -12.3206, -15.0702, -8.91696, -6.24556, -16.5196, -8.39844, 0},
931  -6.01523, -5.33454, -6.26672, -5.88745, -8.91118, -11.1342, -7.91073, 0, 0, -5.53583, -4.3686,  {0, -3.0755, -12.831, -23.0945, -20.8865, -12.8932, -25.4243, 16.5467, 0},
932  -8.88023, -6.36106, -4.70941, -3.2139, -0.381882, 0, 0, -5.7646, -6.25807, -5.12981, -1.5055,  {0, -3.89104, -13.1829, -31.3708, -71.7052, -107.284, -129.239, -108.794, 0},
933  -1.11425, -0.388791, 8.42188, 0 } ;  {0, -5.37954, -17.0676, -24.4585, -49.6695, -89.3567, -134.941, -113.108, 0},
934    {0, -5.48076, -18.4538, -28.255, -48.7572, -56.4813, -46.2133, -13.7872, 0},
935    {0, -4.056, -9.7058, -32.0134, -48.0418, -82.316, -115.6, -185.798, 0},
936    {0, -3.58506, -8.95175, -7.02082, -3.72388, -8.31816, -3.70441, 8.91556, 0},
937    {0, -4.63926, -15.2966, -20.4456, -49.4273, -33.1319, -30.1151, -94.0042, 0},
938    {0, -5.9137, -16.5116, -42.9632, -48.5685, -70.2161, -104.088, -200.521, 0},
939    {0, -5.74618, -16.3597, -36.3691, -79.8407, -94.9335, -99.0161, -72.8879, 0},
940    {0, -6.07098, -17.0741, -30.4224, -69.8418, -120.675, -166.247, -88.5553, 0},
941    {0, -5.6577, -16.8394, -31.1924, -40.3184, -106.238, -112.924, -117.987, 0},
942    {0, -5.44442, -16.6105, -40.8566, -69.5939, -105.485, -143.841, -192.19, 0},
943    {0, -6.00784, -18.0034, -32.3969, -61.286, -107.103, -136.99, -213.381, 0}};
944    
 Float_t A2t[48][9] = {  
 0, 0.317852, 2.46394, 4.35287, 6.69993, 1.37704, 9.38636, 22.3426, 0, 0, 0.0270999, 4.03858,  
 0.614142, 7.64715, 3, 4.55046, 9.46688, 0, 0, 0.422802, 3.25444, 2.83067, 3.78916, 7.15528,  
 9.61404, 9.53181, 0, 0, 0.27719, 2.81849, 2, 3, 3, 3, 3, 0, 0, 0.257138, 1.96682, 2.66388,  
 2.02686, 0.981737, 7.07876, 32, 0, 0, 0.0777448, 1.95238, 0.591915, 3.36314, 1.71777, 3.1121, 3,  
 0, 0, 0.201297, 1.54333, 2.06343, 3.81529, 3.47056, 7.66122, 10.2165, 0, 0, 0.090275, 2.35456,  
 0.150419, 1.48979, 4.43331, 6.09798, 9.59925, 0, 0, 0.472466, 2.2568, 0, 0, 0, 0, 0, 0, 0, 0, 0,  
 0, 0, 5.8114, 8.76464, 11.718, 0, 0, 0.369669, 1.66502, 2.21937, 4.8545, 6.71778, 9.52608,  
 13.5645, 0, 0, 0.278447, 3.03196, 0.562358, 0.978803, 4.19387, 9.26949, 4.33973, 0, 0, 0.488781,  
 2.52383, 0.674871, 2.54554, 2.33603, 6.75428, 10.7769, 0, 0, 0.396462, 2.42949, 1.33035, 3.9579,  
 4.98889, 7.41728, 8.78462, 0, 0, 0.616543, 2.39152, 7.13157, 4.52173, 0.795959, 5.05895,  
 3.58876, 0, 0, 1.3407, 2.54098, 2, 7.35567, 6.08494, 6.47321, 6.60084, 0, 0, 0.855061, 3.97328,  
 2, 3, 3, 10.1946, 7.06782, 0, 0, 0.492265, 5.11681, 2, 2.24085, 0.00142742, 3.12852, 1.94308, 0,  
 0, 0.594536, 3.10529, 2.07652, 4.86122, 2.7748, 10.0368, 14.8149, 0, 0, 0.220041, 3.69287, 2, 3,  
 3, 0.0668348, 0.124322, 0, 0, 0.652342, 2.52474, 1.92129, 3.97957, 5.4076, 8.66393, 5.53485, 0,  
 0, 0.109911, 2.37426, 2, 2.09403, 4.25338, 7.64627, 8.96803, 0, 0, 0.503317, 3.66579, 2, 3, 3,  
 3.95553, 7.79201, 0, 0, 0.18358, 2.71524, 2, 1.64493, 2.67235, 6.00813, 13.3661, 0, 0, 0.762639,  
 3.10968, 2, 1.79493, 0.0228019, 3, 6.68329, 0, 0, 0.218363, 2.87712, 0.218535, 3, 4.57375,  
 9.68986, 4.89219, 0, 0, 0.675406, 4.00709, 2, 1.07325, 3, 0.182969, 8.20433, 0, 0, 0.991549,  
 2.68269, 2, 3.876, 2.94015, 6.72011, 7.03988, 0, 0, 1.02743, 3.12518, 2, 2.20294, 6.63646,  
 22.0153, 35, 0, 0, 1.18885, 3.01461, 2.30242, 3.46316, 8.98077, 16.6101, 35, 0, 0, 1.47119,  
 3.24004, 1.07333, 2.31147, 2.98418, 9.99881, 28.0778, 0, 0, 1.28408, 2.55246, 1.49292, 3.01143,  
 8.45419, 13.2062, 35, 0, 0, 1.56497, 3.35834, 0.73553, 3, 2.13162, 5.84836, 18.6428, 0, 0,  
 1.39782, 3.19843, 0.593735, 3.34643, 4.22204, 6.78619, 12.8529, 0, 0, 1.46182, 3.30186,  
 0.0348858, 3.87061, 9.87769, 16.8741, 35, 0, 0, 1.50597, 3.03838, 1.62411, 2.96043, 7.1428,  
 15.4035, 35, 0, 0, 2.6053, 2.92019, 3.8816, 7.13833, 9.84022, 13.4445, 22.2018, 0, 0, 2.58901,  
 2.74623, 2.66245, 5.37385, 8.40354, 11.6502, 17.4423, 0, 0, 2.65151, 3.592, 2, 3, 3, 3, 3, 0, 0,  
 2.65586, 3.87903, 6.12175, 9.92231, 16.1427, 21.4766, 21.4604, 0, 0, 2.38768, 3.77375, 5.67703,  
 11.8596, 18.8674, 20.8655, 24.5083, 0, 0, 2.40258, 4.1273, 2, 5.81564, 2.29756, 4.40615,  
 32.3639, 0, 0, 3.54156, 2.13, 2.79762, 2.76993, 4.67104, 5.20053, 8.36394, 0, 0, 3.76292,  
 2.83393, 5.30926, 6.67988, 7.35393, 9.46522, 14.8599, 0, 0, 3.37723, 2.74166, 6.71253, 5.63259,  
 8.42885, 9.99872, 14.8742, 0, 0, 3.83378, 2.79501, 4.78642, 5.94201, 11.4635, 14.7442, 16.5806,  
 0, 0, 3.59181, 2.3773, 7.14813, 5.60101, 6.47122, 6.64957, 14.2374, 0, 0, 3.68523, 3.54382,  
 3.92867, 2.18506, 5.56025, 7.75895, 7.448, 0 } ;  
945    
946    Float_t A2t[48][9] = {
947    {0, -0.256726, 2.27431, 6.43469, 11.8465, 25.5581, 31.0446, 22.2011, 0},
948    {0, -0.27314, 2.41841, 1.96977, 3, 4.1409, 37.5866, 31.8181, 0},
949    {0, 0.210304, 1.9894, 9.90239, 14.4125, 8.40969, 17.111, 11.0446, 0},
950    {0, -0.0897531, 1.31427, 1.38261, 13.8423, 10.7517, 3, 3, 0},
951    {0, 0.254985, 2.18331, 5.68851, 13.1542, 15.3206, 2.48479, 70.3325, 0},
952    {0, 0.403054, 1.07449, 2.02539, 7.53642, 3.53899, 3, 3, 0},
953    {0, -0.402018, 1.49429, 8.52411, 9.06339, 6.43531, 2.47331, 3, 0},
954    {0, 0.0163422, 1.90856, 3.94927, 13.6905, 10.1882, 3, 3, 0},
955    {0, -4.41759, 0.455884, 8.23305, 24.3049, 23.7324, 19.687, 9.34883, 0},
956    {0, -1.61978, -5.94435, 5.09418, 3.5784, 6.69858, 0, 3, 0},
957    {0, -0.406232, 0.261862, 3.87028, 14.9026, 9.15009, 8.09389, 3, 0},
958    {0, 0.450961, 2.79588, 1.475, 8.87168, 13.0701, 7.88346, 7.61453, 0},
959    {0, -0.642696, 1.93851, 7.07521, 13.7185, 12.8763, 23.2823, 7.88003, 0},
960    {0, -0.0242187, 1.90127, 7.67745, 6.80574, 27.4311, 16.7277, 32.2091, 0},
961    {0, -1.4328, -0.863971, 2, 4.44504, 10.57, 17.3062, 27.8696, 0},
962    {0, -0.670537, 1.49585, 12.8631, 16.2047, 14.9903, 36.0699, 16.2393, 0},
963    {0, -0.165185, 4.50708, 7.61307, 25.615, 20.0767, 33.8685, 31.1236, 0},
964    {0, -14.3972, -0.395553, 13.3646, 4.57022, 3, 7.13162, 73.4341, 0},
965    {0, -0.12435, 3.28793, 10.8198, 9.77605, 28.3088, 26.0003, 74.0148, 0},
966    {0, -0.249317, 2.71293, 1.75304, 10.5257, 5.86488, 1.62532, 21.8499, 0},
967    {0, 0.783725, 2.69445, 6.4717, 14.0212, 10.3889, 12.3235, 12.6467, 0},
968    {0, 0.251419, 3.89298, 3.7622, 11.1349, 11.8263, 8.91756, 30.8796, 0},
969    {0, -0.0967801, 3.47969, 4.14906, 15.4672, 17.9873, 14.6814, 40.101, 0},
970    {0, -0.0468341, 2.4518, 5.22592, 8.81726, 13.3005, 12.5642, 26.0746, 0},
971    {0, 0.361255, 2.6057, 5.68184, 18.9758, 23.0597, 13.4065, 42.9283, 0},
972    {0, 0.265048, 3.70422, 6.65035, 15.5919, 21.3769, 27.5229, 32.5316, 0},
973    {0, 0.131408, 3.54343, 4.01437, 3, 7.44138, 6.65706, 3, 0},
974    {0, 1.54593, 3.83503, 9.28219, 22.0934, 23.8119, 29.9772, 35.631, 0},
975    {0, 1.7922, 11.1126, 3.13824, 11.1306, 20.0004, 17.3392, 28.6826, 0},
976    {0, 1.47885, 4.12127, 7.4205, 3.88672, 3.32699, 12.5934, 28.6826, 0},
977    {0, 2.19139, 4.68991, 6.91045, 8.68486, 0.558281, 3, 25.2369, 0},
978    {0, 1.38324, 4.40549, 6.29519, 3.73961, 9.92062, 4.2368, 0, 0},
979    {0, 1.74636, 7.38456, 10.9205, 16.2117, 20.5563, 27.464, 10.1068, 0},
980    {0, 1.73446, 6.69344, 11.6119, 29.1162, 29.9171, 49.9535, 44.2648, 0},
981    {0, 1.77345, 7.29971, 7.85848, 5.92193, 11.9535, 23.2607, 28.6826, 0},
982    {0, 1.96343, 7.39403, 12.4053, 10.7737, 9.40302, 25.2622, 0, 0},
983    {0, 2.42414, 7.27305, 18.273, 42.3329, 63.3642, 76.6873, 68.8465, 0},
984    {0, 3.31282, 9.87776, 12.592, 23.6123, 51.5773, 79.4578, 70.7063, 0},
985    {0, 3.29838, 10.279, 15.8924, 26.8172, 26.854, 12.7043, 3, 0},
986    {0, 2.68146, 6.03602, 20.1606, 30.6191, 57.4667, 82.6249, 123.423, 0},
987    {0, 2.2217, 5.29813, 4.33261, 2.07538, 10.7653, 7.464, 0.349452, 0},
988    {0, 2.95636, 8.77044, 10.8631, 27.8588, 12.2192, 14.0908, 110.101, 0},
989    {0, 3.64161, 9.78281, 24.6906, 26.6128, 41.2993, 61.6105, 148.654, 0},
990    {0, 3.63967, 9.64793, 22.2672, 48.2125, 58.7374, 63.0135, 50.1782, 0},
991    {0, 3.82742, 10.2333, 17.375, 39.2687, 70.7411, 92.8927, 53.55, 0},
992    {0, 3.60427, 9.89206, 20.1062, 24.2838, 70.2791, 74.3114, 68.2462, 0},
993    {0, 3.49785, 10.0213, 25.4603, 42.8919, 66.5058, 87.2153, 118.037, 0},
994    {0, 3.7133, 10.5679, 19.2454, 36.5673, 67.1997, 85.7778, 144.19, 0}};
995    
996  // S115B failure: 1158700000 // 2006-09-19 21:06:40 UTC  // S115B failure: 1158700000 // 2006-09-19 21:06:40 UTC
997    
998  if (time > 1158700000.) {     // first workaround: just use calibration of PMT S115A  if (time < 1158700000.) {     // first workaround: just use calibration of PMT S115A
999  for ( Int_t jj=0; jj<9; jj++ ){  for ( Int_t jj=0; jj<9; jj++ ){
1000  A0t[9][jj] = A0t[8][jj] ;  A0t[9][jj] = A0t[8][jj] ;
1001  A1t[9][jj] = A1t[8][jj] ;  A1t[9][jj] = A1t[8][jj] ;
# Line 629  A2t[9][jj] = A2t[8][jj] ; Line 1006  A2t[9][jj] = A2t[8][jj] ;
1006    
1007  //  2nd-order correction  //  2nd-order correction
1008  Float_t corr_a[6][4] = {    Float_t corr_a[6][4] = {  
1009  0.551894 , 2.24353 , -3.35885 , 1.51401 , 0.915691 , 4.83967 , -6.85389 , 3.13679 ,  {0.551894 , 2.24353 , -3.35885 , 1.51401} ,
1010  1.84338 , 5.63517 , -8.41577 , 4.04055 , 1.51216 , 11.3233 , -16.2119 , 7.45008 ,  {0.915691 , 4.83967 , -6.85389 , 3.13679} ,
1011  1.50481 , 15.2538 , -21.2003 , 9.51127 , 1.82038 , 17.5336 , -23.5512 , 10.3036  };  {1.84338 , 5.63517 , -8.41577 , 4.04055} ,
1012    {1.51216 , 11.3233 , -16.2119 , 7.45008} ,
1013    {1.50481 , 15.2538 , -21.2003 , 9.51127} ,
1014    {1.82038 , 17.5336 , -23.5512 , 10.3036}  };
1015    
1016  //---------------------------------------------------------------------  //---------------------------------------------------------------------
1017    
1018  Float_t xv[6],yv[6];  //Float_t xv[6],yv[6];
1019  Int_t  iz;  Int_t  iz;
1020    
1021  Float_t x1[9],y1[9];  Float_t x1[9],y1[9];
1022  Int_t n1 = 9;  Int_t n1 = 9;
1023    
1024  Float_t  Layercharge[6] = {1000., 1000., 1000., 1000., 1000., 1000. };  Float_t  Layercharge[6] = {1005., 1005., 1005., 1005., 1005., 1005. };
1025    
1026  Int_t  Layerinfo[6] = {0, 0, 0, 0, 0, 0 };  Int_t  Layerinfo[6] = {0, 0, 0, 0, 0, 0 };
1027    
1028    //Float_t adc[48],adc_c[48],PMTcharge_arr[48];
1029    Float_t adc[48],PMTcharge_arr[48];
1030    
1031    Float_t beta_mean = fabs(track->beta[12]);
1032    
1033    Float_t beta_mean = fabs(track->beta[12]);  // New!! If "beta_in" != 100. then overwrite beta_mean with beta_in
1034    if (beta_in != 100.) beta_mean=beta_in;
1035    
1036    Int_t ncount=0;    Int_t ncount=0;
1037    Float_t charge_chi=1000.;    Float_t charge_chi=1000.;
1038    
   if ((beta_mean > 0.05)  && (beta_mean < 1.5)) {  
1039        
1040  //-------------------------------------------------------------  //-------------------------------------------------------------
1041    
1042  // fill adc and tdc  // fill adc and tdc
1043    
1044     Int_t ich,jj,kk;     Int_t ich,jj,kk;
    Float_t adc[48],adc_c[48],PMTcharge_arr[48];  
1045    
1046     for (ich=0; ich<48; ich++)   adc[ich]   = 4095.;     for (ich=0; ich<48; ich++)   adc[ich]   = 4095.;
1047     for (ich=0; ich<48; ich++)   adc_c[ich] = 1000.;     //   for (ich=0; ich<48; ich++)   adc_c[ich] = 1000.;
1048     for (ich=0; ich<48; ich++)   PMTcharge_arr[ich] = 1000.;     for (ich=0; ich<48; ich++)   PMTcharge_arr[ich] = 1000.;
1049    
1050    
1051    if ((beta_mean < 0.05)  || (beta_mean > 2.0)) {
1052      for (Int_t jj=0; jj<48;jj++) charge_PMT_std[jj] = 1001.;
1053      for (Int_t jj=0; jj<6;jj++) charge_layer_std[jj] = 1001.;
1054      for (Int_t jj=0; jj<6;jj++) charge_layer_std_raw[jj] = 1001.;
1055      for (Int_t jj=0; jj<6;jj++) layerinfo_std[jj] = 1001;
1056      charge_std = 1001.;
1057      ncount_std = 0;
1058                                                  }
1059    
1060    
1061      if ((beta_mean > 0.05)  && (beta_mean < 2.0)) {
1062    
1063     Float_t betahelp =   pow(beta_mean, 1.2);     Float_t betahelp =   pow(beta_mean, 1.2);
1064    
1065  //=======================================================================  //=======================================================================
# Line 682  Int_t  Layerinfo[6] = {0, 0, 0, 0, 0, 0 Line 1079  Int_t  Layerinfo[6] = {0, 0, 0, 0, 0, 0
1079            Float_t dEdx = track->dedx[ipmt];            Float_t dEdx = track->dedx[ipmt];
1080            ym = dEdx*betahelp;            ym = dEdx*betahelp;
1081            Int_t pmtadc = track->pmtadc[ipmt];            Int_t pmtadc = track->pmtadc[ipmt];
1082            Int_t adcflag = track->adcflag[ipmt];            //          Int_t adcflag = track->adcflag[ipmt];
1083            L2->GetToFLevel2()->GetPMTIndex(pmtadc,jj,kk);            L2->GetToFLevel2()->GetPMTIndex(pmtadc,jj,kk);
1084            if (adcflag==0) adc_c[pmtadc] = dEdx;            //          if (adcflag==0) adc_c[pmtadc] = dEdx;
1085            if (adc[pmtadc] > PMTsat[pmtadc]) adc_c[pmtadc] = 1000.;  
1086              //         if (adc[pmtadc] == 4095) adc_c[pmtadc] = 0.;
1087             if (adc[pmtadc] == 4095) PMTcharge_arr[pmtadc] = 0.;
1088    
1089             //         if ((adc[pmtadc]>PMTsat[pmtadc]) && (adc[pmtadc]<4095)) adc_c[pmtadc] = 1000.;
1090                                                                                    
1091           if (adc[pmtadc] < PMTsat[pmtadc]) {           if (adc[pmtadc] < PMTsat[pmtadc]) {
1092    
1093  if ((pmtadc!=4) && (pmtadc!=8) || (pmtadc!=28) || (pmtadc!=31) || (pmtadc!=34) || (pmtadc!=39) && (pmtadc!=41) || (pmtadc!=46)) {  if ((pmtadc!=4) && (pmtadc!=8) && (pmtadc!=28) && (pmtadc!=31) && (pmtadc!=34) && (pmtadc!=39) && (pmtadc!=41) && (pmtadc!=46)) {
1094    
1095      for ( Int_t jj=0; jj<9; jj++ ){      for ( Int_t jj=0; jj<9; jj++ ){
1096      x1[jj] = A0t[pmtadc][jj]+A1t[pmtadc][jj]*beta_mean+A2t[pmtadc][jj]*beta_mean*beta_mean;      x1[jj] = A0t[pmtadc][jj]+A1t[pmtadc][jj]*beta_mean+A2t[pmtadc][jj]*beta_mean*beta_mean;
# Line 702  if ((pmtadc!=4) && (pmtadc!=8) || (pmtad Line 1103  if ((pmtadc!=4) && (pmtadc!=8) || (pmtad
1103      TGraph *gr2 = new TGraph(n1,x1,y1);      TGraph *gr2 = new TGraph(n1,x1,y1);
1104      TSpline3 *spl2 = new TSpline3("grs",gr2);    // use a cubic spline      TSpline3 *spl2 = new TSpline3("grs",gr2);    // use a cubic spline
1105      chelp = spl2->Eval(ym);      chelp = spl2->Eval(ym);
1106        if (chelp<0.) chelp=0.0001;  //WM new
1107      charge = TMath::Sqrt(chelp);      charge = TMath::Sqrt(chelp);
1108    
1109      gr2->Delete();      gr2->Delete();
# Line 709  if ((pmtadc!=4) && (pmtadc!=8) || (pmtad Line 1111  if ((pmtadc!=4) && (pmtadc!=8) || (pmtad
1111      PMTcharge_arr[pmtadc] = charge;      PMTcharge_arr[pmtadc] = charge;
1112                                                                           } // pmtadc != ...                                                                           } // pmtadc != ...
1113    
1114  if ((pmtadc==4) && (pmtadc==8) || (pmtadc==28) || (pmtadc==31) || (pmtadc==34) || (pmtadc==39) && (pmtadc==41) || (pmtadc==46)) {  if ((pmtadc==4) || (pmtadc==8) || (pmtadc==28) || (pmtadc==31) || (pmtadc==34) || (pmtadc==39) || (pmtadc==41) || (pmtadc==46)) {
1115           for ( Int_t jj=0; jj<8; jj++ ){           for ( Int_t jj=0; jj<8; jj++ ){
1116           yl = A0t[pmtadc][jj]+A1t[pmtadc][jj]*beta_mean+A2t[pmtadc][jj]*beta_mean*beta_mean;           yl = A0t[pmtadc][jj]+A1t[pmtadc][jj]*beta_mean+A2t[pmtadc][jj]*beta_mean*beta_mean;
1117           yh = A0t[pmtadc][jj+1]+A1t[pmtadc][jj+1]*beta_mean+A2t[pmtadc][jj+1]*beta_mean*beta_mean;           yh = A0t[pmtadc][jj+1]+A1t[pmtadc][jj+1]*beta_mean+A2t[pmtadc][jj+1]*beta_mean*beta_mean;
# Line 717  if ((pmtadc==4) && (pmtadc==8) || (pmtad Line 1119  if ((pmtadc==4) && (pmtadc==8) || (pmtad
1119           m = (C0t[pmtadc][jj+1]*C0t[pmtadc][jj+1] - C0t[pmtadc][jj]*C0t[pmtadc][jj]) / (yh - yl);           m = (C0t[pmtadc][jj+1]*C0t[pmtadc][jj+1] - C0t[pmtadc][jj]*C0t[pmtadc][jj]) / (yh - yl);
1120           b = (C0t[pmtadc][jj]*C0t[pmtadc][jj]) - m*yl;           b = (C0t[pmtadc][jj]*C0t[pmtadc][jj]) - m*yl;
1121           chelp = m*ym + b;           chelp = m*ym + b;
1122             if (chelp<0.) chelp=0.0001;  //WM new
1123           charge= TMath::Sqrt(chelp);           charge= TMath::Sqrt(chelp);
1124           PMTcharge_arr[pmtadc] = charge;           PMTcharge_arr[pmtadc] = charge;
1125                               }                               }
# Line 768  Int_t ihelp_a[6] = {0,16,28,32,36,42}; Line 1171  Int_t ihelp_a[6] = {0,16,28,32,36,42};
1171    
1172  for (Int_t ilay=0; ilay<6; ilay ++) {  for (Int_t ilay=0; ilay<6; ilay ++) {
1173  Int_t jj = PaddleIdOfTrack[ilay] ;  Int_t jj = PaddleIdOfTrack[ilay] ;
1174  Float_t xhelp = 1000.;  //Float_t xhelp = 1000.;
1175    Float_t xhelp = 1005.;
1176    
1177  if (jj == -1) Layerinfo[ilay] = -1;  if (jj == -1) Layerinfo[ilay] = -1;
1178    
1179  if (jj != -1) {  if (jj != -1) {
1180  Int_t ih = ihelp_a[ilay] + 2*jj;  Int_t ih = ihelp_a[ilay] + 2*jj;
1181    
1182    // New WM
1183    Int_t igood1=0;
1184    Int_t igood2=0;
1185    if ((PMTcharge_arr[ih] < 1000.) && (PMTcharge_arr[ih] > 0.)) igood1=1;
1186    if ((PMTcharge_arr[ih+1] < 1000.) && (PMTcharge_arr[ih+1] > 0.)) igood2=1;
1187    
1188    if ((PMTcharge_arr[ih]==0.) && (PMTcharge_arr[ih+1]==0.))  xhelp = 0.;
1189    if ((igood1==1)&&(igood2==1)) xhelp = 0.5*(PMTcharge_arr[ih]+PMTcharge_arr[ih+1]) ;
1190    if ((igood1==1)&&(igood2==0)) xhelp = PMTcharge_arr[ih];
1191    if ((igood2==1)&&(igood1==0)) xhelp = PMTcharge_arr[ih+1];
1192    
1193    
1194    /*
1195  if ((PMTcharge_arr[ih] < 1000.) && (PMTcharge_arr[ih+1] < 1000.)) xhelp = 0.5*(PMTcharge_arr[ih]+PMTcharge_arr[ih+1]) ;  if ((PMTcharge_arr[ih] < 1000.) && (PMTcharge_arr[ih+1] < 1000.)) xhelp = 0.5*(PMTcharge_arr[ih]+PMTcharge_arr[ih+1]) ;
1196  if ((PMTcharge_arr[ih] < 1000.) && (PMTcharge_arr[ih+1]==1000.))  xhelp = PMTcharge_arr[ih] ;  if ((PMTcharge_arr[ih] < 1000.) && (PMTcharge_arr[ih+1]==1000.))  xhelp = PMTcharge_arr[ih] ;
1197  if ((PMTcharge_arr[ih]==1000.) && (PMTcharge_arr[ih+1] < 1000.))  xhelp = PMTcharge_arr[ih+1] ;  if ((PMTcharge_arr[ih]==1000.) && (PMTcharge_arr[ih+1] < 1000.))  xhelp = PMTcharge_arr[ih+1] ;
1198    */
1199    
1200     if (adc[ih] ==  4095) Layerinfo[ilay] = Layerinfo[ilay] + 1;     if (adc[ih] ==  4095) Layerinfo[ilay] = Layerinfo[ilay] + 1;
1201     if (adc[ih+1] ==  4095) Layerinfo[ilay] = Layerinfo[ilay] + 1;     if (adc[ih+1] ==  4095) Layerinfo[ilay] = Layerinfo[ilay] + 1;
# Line 793  Layercharge[ilay] = xhelp; Line 1212  Layercharge[ilay] = xhelp;
1212  //for (Int_t ilay=0; ilay<6; ilay ++) cout<<Layercharge[ilay]<<" ";  //for (Int_t ilay=0; ilay<6; ilay ++) cout<<Layercharge[ilay]<<" ";
1213    
1214  //==========================================================================  //==========================================================================
1215    //============= Layercharge without 2nd-order correction   =================
1216    //==========================================================================
1217    
1218      for (Int_t jj=0; jj<6;jj++) charge_layer_std_raw[jj] = Layercharge[jj];
1219    
1220    //==========================================================================
1221  //=========================   2nd-order correction   =======================  //=========================   2nd-order correction   =======================
1222  //==========================================================================  //==========================================================================
1223    
# Line 801  Float_t xb = beta_mean; Line 1226  Float_t xb = beta_mean;
1226  for (Int_t ii=0; ii<6;  ii++) {  for (Int_t ii=0; ii<6;  ii++) {
1227  Int_t ic = 0;  Int_t ic = 0;
1228  Float_t corr[4] = {1., 0., 0., 0.};  Float_t corr[4] = {1., 0., 0., 0.};
1229  for (Int_t iii=1; iii<9;  iii++) if (fabs(Layercharge[ii] - iii)<0.50) ic = iii;  //for (Int_t iii=1; iii<9;  iii++) if (fabs(Layercharge[ii] - iii)<0.50) ic = iii;
1230    for (Int_t iii=1; iii<10;  iii++) if (fabs(Layercharge[ii] - iii)<0.50) ic = iii;
1231  if ((ic>0)&&(ic<=5)) for (Int_t iii=0; iii<4;  iii++) corr[iii] = corr_a[ic-1][iii];  if ((ic>0)&&(ic<=5)) for (Int_t iii=0; iii<4;  iii++) corr[iii] = corr_a[ic-1][iii];
1232  if (ic >5) for (Int_t iii=0; iii<4;  iii++) corr[iii] = corr_a[5][iii];  if (ic >5) for (Int_t iii=0; iii<4;  iii++) corr[iii] = corr_a[5][iii];
1233    
# Line 810  Float_t c_corr = corr[0]+corr[1]*xb+corr Line 1236  Float_t c_corr = corr[0]+corr[1]*xb+corr
1236  if ((ic>0)&&(ic<=5)) c_corr = c_corr/(1.*ic) ;  if ((ic>0)&&(ic<=5)) c_corr = c_corr/(1.*ic) ;
1237  if (ic>5) c_corr = c_corr/6. ;  if (ic>5) c_corr = c_corr/6. ;
1238    
1239    //cout<<Layercharge[ii]<<" "<<ic<<" "<<c_corr<<" => ";
1240  Layercharge[ii] = Layercharge[ii]/c_corr;  Layercharge[ii] = Layercharge[ii]/c_corr;
1241    //cout<<Layercharge[ii]<<endl;
1242    
1243                              }                              }
1244    
1245    
1246  //==========================================================================  //==========================================================================
1247    //cout<<"In ToFNuclei Std: ";
1248    //for (Int_t ilay=0; ilay<6; ilay ++) cout<<Layercharge[ilay]<<" ";
1249    //cout<<endl;
1250  //==========================================================================  //==========================================================================
1251    
1252    
   
1253  Int_t  icount=0;  Int_t  icount=0;
1254  Float_t charge_mean = 0.;  Float_t charge_mean = 0.;
1255  for (Int_t ii=0; ii<6;  ii++) {  for (Int_t ii=0; ii<6;  ii++) {
# Line 827  if (Layercharge[ii] < 1000) icount++; Line 1258  if (Layercharge[ii] < 1000) icount++;
1258                              }                              }
1259  if (icount>0) charge_mean = charge_mean/(1.*icount) ;  if (icount>0) charge_mean = charge_mean/(1.*icount) ;
1260    
1261    if (icount>0) {
1262    
1263    //for (Int_t ii=0; ii<6;  ii++) cout<<Layercharge[ii]<<" ";
1264    //cout<<endl;
1265    
1266    
1267      vector<float> charge_v;
1268      Float_t charge_median = 0.;
1269    
1270      ////////  get the median charge ////////////
1271      for(Int_t ii=0;ii<6;ii++) {
1272      if (Layercharge[ii] < 1000) charge_v.push_back(Layercharge[ii]);
1273                                }
1274    
1275      std::sort(charge_v.begin(),charge_v.end());
1276      charge_median = charge_v[(int)(charge_v.size()/2+charge_v.size()%2)-1];
1277    
1278    //cout<<charge_mean<<" "<<charge_median<<endl;
1279    
1280      charge_mean = charge_median;
1281    
1282    }  // icount>0
1283    
1284  //--- Calculate charge for the second time, use residuals of the single  //--- Calculate charge for the second time, use residuals of the single
1285  //--- measurements to get a chi2 value  //--- measurements to get a chi2 value
# Line 873  if (icount>0) charge_mean = charge_mean/ Line 1326  if (icount>0) charge_mean = charge_mean/
1326    
1327  //  charge_tof = charge_chi;  //  charge_tof = charge_chi;
1328    
1329   } // 0.05 < fabs( beta) < 1.5  // changed 30-01-2009 WM
1330    
1331      for (Int_t jj=0; jj<48;jj++) charge_PMT_std[jj] = PMTcharge_arr[jj];
1332    for (Int_t jj=0; jj<6;jj++) charge_layer_std[jj] = Layercharge[jj];    for (Int_t jj=0; jj<6;jj++) charge_layer_std[jj] = Layercharge[jj];
1333    for (Int_t jj=0; jj<6;jj++) layerinfo_std[jj] = Layerinfo[jj];    for (Int_t jj=0; jj<6;jj++) layerinfo_std[jj] = Layerinfo[jj];
1334    charge_std = charge_chi;    charge_std = charge_chi;
1335    ncount_std = ncount;    ncount_std = ncount;
1336    
1337     } // 0.05 < fabs( beta) < 2.0
1338    
1339    
1340  } // standalone track found  } // standalone track found
1341    
1342  }  }

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.9

  ViewVC Help
Powered by ViewVC 1.1.23