23#define LAR_MAX_DOUBLE MAXDOUBLE
25#define LAR_MAX_DOUBLE __DBL_MAX__
45 declareInterface<LArWFParamTool>(
this);
53 int default_deltattail[3] = { 100, 50, 0 } ;
54 for (
unsigned i=0; i<3; ++i )
60 int default_ttailmin[4] = { 0, 0, 0, 0 };
61 int default_ttailmax[4] = { 0, 0, 0, 0 };
62 for (
unsigned i=0; i<4; ++i ) {
71 bool defaults[4] = { false , true , false ,
true } ;
72 for (
unsigned i=0 ; i<4 ; ++i )
81 float default_omegamin[4] = { 0.01 , 0.10 , 0.10 , 0.10 };
82 float default_omegamax[4] = { 1.00 , 0.33 , 0.20 , 0.33 };
83 unsigned default_npoints[4] = { 100 , 100 , 100 , 100 };
87 for (
unsigned i=0 ; i<4 ; ++i ) {
114 std::string layerName[4] = {
"PS" ,
"Strips" ,
"Middle" ,
"Back" } ;
123 ATH_MSG_INFO(
"Cosine response (Omega0) -> Will use OmegaScanHelper() to dynamically select settings" );
127 for (
unsigned layer=0 ; layer<4 ; ++layer ) {
128 ATH_MSG_INFO(
"options for Layer " << layer <<
" (" << layerName[layer] <<
")" ) ;
136 ATH_MSG_INFO(
"Will use OmegaScanHelper() to dynamically select settings" ) ;
141 ATH_MSG_ERROR(
"Omega0Min >= Omega0Max in layer " << layer <<
" -- exit!" ) ;
142 return StatusCode::FAILURE ;
176 return StatusCode::FAILURE;
185 return StatusCode::FAILURE;
189 return StatusCode::SUCCESS;
198 std::optional<LArCaliWave>& omegaScanWave,
199 std::optional<LArCaliWave>& resOscill0,
200 std::optional<LArCaliWave>& resOscill1)
const
212 const double Tcal =
expTail(gCali,waveTiming) ;
215 <<
" gain=" << (
int)gain ) ;
217 return StatusCode::FAILURE;
227 StatusCode
sc =
GetFstep(gCali,wfParams,waveTiming);
228 if (
sc.isFailure() ) {
230 <<
" gain=" << (
int)gain );
240 StatusCode
sc =
RTM_Omega0(gCali,chid,wfParams,waveTiming,cabling,omegaScanWave);
241 if (
sc.isFailure() ) {
243 <<
" gain=" << (
int)gain );
252 const Identifier id = cabling->cnvToIdentifier(chid);
253 const unsigned layer=
m_emId->sampling(
id);
261 StatusCode
sc =
RTM_Taur(gCali, wfParams,waveTiming ) ;
262 if (
sc.isFailure() ) {
264 <<
" gain=" << (
int)gain ) ;
278 return( StatusCode::SUCCESS );
319 const unsigned nAfterMin = 150;
320 const unsigned nBeforeEnd = 125;
321 t1 = wt.
Tmin + nAfterMin;
322 t2 = gCali.
getSize() - nBeforeEnd ;
327 std::vector<double> fitPars =
m_wHelper.expfit(gCali,t1,t2,rho) ;
328 if (fitPars.size() == 2 ) {
335 const double Tcal = -1./
A ;
349 const double fstep1=0.0;
350 const double Tcal=wfParams.
tcal();
353 return StatusCode::SUCCESS ;
361 const double dfstep =
dFstep(gCali,fstep,
Tc,Ttail) ;
363 if ( niter > 50 || fstep < 0. ) {
367 if ( fabs( dfstep ) <=
m_TINY )
break;
381 b =
m_wHelper.getSumTail( stepResp1 * dstepRespDfstep1,Ttail);
382 a =
m_wHelper.getSumSquareTail( dstepRespDfstep1,Ttail);
384 if (
a == 0)
return 0;
396 const unsigned N = gCali.
getSize() ;
397 const double dt = gCali.
getDt() ;
400 const double A=(1.-fstep)/
Tc;
401 for (
unsigned i=0 ; i<N ; i++ ) {
402 w.setSample(i,
A*exp(-fstep*i*dt/
Tc));
412 return (-1./
Tc)*(1.+((1.-fstep)/
Tc)*t)*exp(-fstep*t/
Tc);
416 const unsigned N = gCali.
getSize() ;
417 const double dt = gCali.
getDt() ;
419 for (
unsigned i=0 ; i<N ; i++ ) w.setSample(i,
dstepCorrDfstep(i*dt,fstep,Tcal)) ;
427 const Identifier id = cabling->cnvToIdentifier(chid);
443 const unsigned layer=
m_emId->sampling(
id);
456 if (range.min==0 || range.max==0 || range.min>=range.max) {
464 const unsigned vectSize = (unsigned) ceil ( OSParams.
omegamax/dOmega );
465 const unsigned indexmin = (unsigned) floor( OSParams.
omegamin/dOmega );
466 if (omegaScanWave) omegaScanWave->setSize(vectSize);
468 for (
int i=0;i<OSParams.
Npoint;i++) {
469 const double omega = OSParams.
omegamin+dOmega*i ;
471 if (omegaScanWave) omegaScanWave->setSample(i+indexmin,
chi2);
472 if (
chi2 < chi2min ) {
491 return StatusCode::SUCCESS ;
502 const unsigned layer=
m_emId->sampling(
id);
514 if (
m_emId->is_em_barrel(
id)) {
575 const bool IsEMECInnerWheel =
m_emId->is_em_endcap_inner(
id);
577 if ( IsEMECInnerWheel ) {
687 double taurmax = 100.;
710 return StatusCode::SUCCESS ;
718 return cosResp(gCali,fstep,tcal, w) * (
pow((1.+ w*w*tsh*tsh),1.5)/(w*tsh));
736 const double C1=(fstep*fstep-fstep*fstep*fstep)/
Tc;
737 const double C2=(fstep+omega*omega*
Tc*
Tc);
738 const double C3=(fstep-1.)*omega*
Tc;
739 const double C4=( fstep*fstep+omega*omega*
Tc*
Tc );
740 for (
unsigned i=0 ; i<N ; i++ ) {
743 const double p=(C1*exp(-fstep*t/
Tc) - omega*(C2*sin(omega*t) + C3*cos(omega*t))) / C4 ;
759 return w - ( w %
injCorr(w.getSize(),w.getDt(),omega0,taur) );
766 const double tau0 = 1./omega0;
767 const double Delta = taur*taur - 4*
tau0*
tau0;
769 const double sqrtDelta = sqrt(Delta) ;
770 const double taup = 0.5*( taur + sqrtDelta ) ;
771 const double taum = 0.5*( taur - sqrtDelta ) ;
772 for (
unsigned i=0 ; i<N ; i++ ) {
774 w.setSample(i, (exp(-t/
taup) - exp(-t/taum) ) / (
taup - taum));
777 }
else if ( Delta < 0 ) {
778 const double T = sqrt(-Delta) ;
779 const double A = 2 * taur / ( (taur*taur) - Delta ) ;
780 const double B = 2 * T / ( (taur*taur) - Delta );
781 for (
unsigned i=0 ; i<N ; i++ ) {
783 w.setSample(i, 2 * exp(-
A*t) * sin(B*t) / T);
787 const double tau = 0.5 * taur ;
789 for (
unsigned i=0 ; i<N ; i++ ) {
791 w.setSample(i,exp(-t/tau) * t / (tau*tau)) ;
878 const double r = (3.-sqrt(5.0))/2;
880 assert( tol > 0 && b >
a );
882 v =
a +
r*(b-
a); fv = (this->*f)(v,gCali,wf,waverange);
890 double middle_range = (
a+b)/2;
895 if( fabs(
x-middle_range) + range/2 <= 2*tol_act )
899 new_step =
r * (
x<middle_range ? b-
x :
a-
x );
903 if( fabs(
x-w) >= tol_act )
912 p = (
x-v)*q - (
x-w)*t;
920 if( fabs(p) < fabs(new_step*q) &&
921 p > q*(
a-
x+2*tol_act) &&
922 p < q*(b-
x-2*tol_act) )
930 if( fabs(new_step) < tol_act ) {
931 if( new_step > (
double)0 )
939 double t =
x + new_step;
940 double ft = (this->*f)(t,gCali,wf,waverange);
958 if( ft <= fw || w==
x )
963 else if( ft<=fv || v==
x || v==w )
990 const unsigned range = 2 ;
993 double maxSample = -9.E+10 ;
994 for (
unsigned i=0 ; i<
length ; i++ ) {
1003 double thisSample = larCaliWave.
getTrigger(i) ;
1004 if ( thisSample > maxSample ) maxSample = thisSample ;
1005 if ( i>=range && i<
length-range ) {
1007 double loc_tremble = 0 ;
1008 for (
unsigned k=i-range ; k<=i+range ; k++ ) {
1009 double delta = thisSample - larCaliWave.
getSample(k) ;
1010 loc_tremble += delta*delta;
1011 if ( delta < 0 )
max = false ;
1013 if (
max ) nMax ++ ;
1014 tremble += loc_tremble / (2*range) ;
1017 if ( sqrt(tremble/
length)/maxSample > 0.1 ) {
Scalar eta() const
pseudorapidity method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
Helper class for LArEM offline identifiers for supercells.
constexpr int pow(int base, int exp) noexcept
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
const ServiceHandle< StoreGateSvc > & detStore() const
This class initializes the Calo (LAr and Tile) offline identifiers.
const LArEM_SuperCell_ID * getEM_SuperCell_ID(void) const
const LArEM_ID * getEM_ID(void) const
value_type get_compact() const
Get the compact id.
int getDAC() const
DAC value.
Helper for the Liquid Argon Calorimeter cell identifiers.
void setTaur(double taur)
void setFstep(double fstep)
void setTcal(double tcal)
void setOmega0(double omega0)
void setFlag(unsigned flag)
void setTshaper(double tsh)
double getError(unsigned i) const
error per time bin
int getTrigger(unsigned i) const
trigger per time bin
size_t getSize() const
number of time samples
const double & getSample(const unsigned int i) const
Amplitude per time bin.
const std::vector< double > & getWave() const
Wave parameters.
const double & getDt() const
delta time
double chi2(TH1 *h0, TH1 *h1)
hold the test vectors and ease the comparison