00001 #include "SimPmtM64ToyNL.h"
00002 #include "SimPmtM64CrosstalkTable.h"
00003 #include "SimPmtMaker.h"
00004 #include "SimPixelTimeBucket.h"
00005 #include "MessageService/MsgService.h"
00006
00007 #include "TMath.h"
00008 #include <cassert>
00009 #include <iostream>
00010
00011 using std::cout;
00012 using std::endl;
00013
00014 CVSID("$Id: SimPmtM64ToyNL.cxx,v 1.1 2005/06/06 20:36:52 litchfld Exp $");
00015
00016 SimPmtMakerProxy<SimPmtM64ToyNL> gSimPmtM64ToyNLProxy("SimPmtM64ToyNL");
00017
00018 ClassImp(SimPmtM64ToyNL)
00019
00020
00021 Float_t SimPmtM64ToyNL::fsNlSlope = 4.32e-4;
00022 Float_t SimPmtM64ToyNL::fsNlTurnOn = 15.8;
00023 Float_t SimPmtM64ToyNL::fsNlSaturate = 500;
00024
00025
00026
00027
00028 SimPmtM64ToyNL::SimPmtM64ToyNL(PlexPixelSpotId tube,
00029 VldContext context,
00030 TRandom* random ):
00031 SimPmtM64Full(tube,context,random)
00032 {
00033 if (fNPixels > 64) {
00034
00035
00036 MSG("Detsim",Msg::kFatal)
00037 << "M64 requested with " << fNPixels << "pixels. What?" << endl;
00038 assert(0);
00039 }
00040 }
00041
00042
00043
00044 void SimPmtM64ToyNL::SimulateNonlinearity()
00045 {
00046 Float_t totalQ[65];
00047
00048 for (UInt_t pix = 1 ; pix <= 64 ; ++pix ) totalQ[pix] = 0.0;
00049
00050
00051 for (SimPmtBucketIterator it(*this); !it.End(); it.Next()) {
00052 SimPmtTimeBucket& bucket = it.Bucket();
00053
00054
00055 for (Int_t pix =1; pix <= fNPixels; pix++) {
00056 SimPixelTimeBucket& pixelBucket = bucket.GetPixelBucket(pix);
00057
00058
00059 totalQ[pix] += pixelBucket.GetCharge();
00060
00061 }
00062 }
00063
00064
00065
00066
00067
00068 Float_t ratioNL[65];
00069 for (Int_t pix = 1 ; pix <= fNPixels ; ++pix ) {
00070 ratioNL[pix] = GenNonlinearRatio(pix, totalQ[pix]);
00071 }
00072
00073
00074 for (SimPmtBucketIterator it(*this); !it.End(); it.Next()) {
00075 SimPmtTimeBucket& bucket = it.Bucket();
00076
00077 for (Int_t pix =1; pix <= fNPixels; pix++) {
00078 SimPixelTimeBucket& pixelBucket = bucket.GetPixelBucket(pix);
00079
00080
00081
00082 pixelBucket.SetCharge( ratioNL[pix] * pixelBucket.GetCharge() );
00083
00084 }
00085 }
00086
00087 return;
00088 }
00089
00090
00091
00092
00093
00094 Float_t SimPmtM64ToyNL::GenNonlinearCharge( Int_t pixel,
00095 Float_t linCharge)
00096 {
00097
00098
00099
00100
00101 return linCharge * GenNonlinearRatio(pixel, linCharge);
00102 }
00103
00104
00105 Float_t SimPmtM64ToyNL::GenNonlinearRatio( Int_t ,
00106 Float_t linCharge)
00107 {
00108 Float_t q_in_pe = linCharge / (0.8 * 1e6 * Munits::e_SI);
00109
00110
00111
00112
00113
00114
00115
00116
00117 if ( q_in_pe > fsNlTurnOn ){
00118 if (q_in_pe <= fsNlSaturate){
00119
00120 return 1 - fsNlSlope * (q_in_pe - fsNlTurnOn);
00121
00122 }
00123 else {
00124
00125
00126
00127
00128 Float_t F = 1 - fsNlSlope * (fsNlSaturate - fsNlTurnOn);
00129 Float_t a = F*F / fsNlSlope;
00130 Float_t b = fsNlSaturate - F / fsNlSlope;
00131 return a / (q_in_pe - b);
00132
00133 }
00134 }
00135
00136 return 1;
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178 }