#include "AliMUONResponseV0.h"
#include "AliMUON.h"
#include "AliMUONConstants.h"
#include "AliMUONDigit.h"
#include "AliMUONGeometryTransformer.h"
#include "AliMUONHit.h"
#include "AliMUONConstants.h"
#include "AliMpArea.h"
#include "AliMpDEManager.h"
#include "AliMpVPadIterator.h"
#include "AliMpSegmentation.h"
#include "AliMpVSegmentation.h"
#include "AliMpCathodType.h"
#include "AliRun.h"
#include "AliLog.h"
#include "Riostream.h"
#include "TVector2.h"
#include <TMath.h>
#include <TRandom.h>
using std::endl;
using std::cout;
ClassImp(AliMUONResponseV0)
AliMUON* muon()
{
return static_cast<AliMUON*>(gAlice->GetModule("MUON"));
}
void Global2Local(Int_t detElemId, Double_t xg, Double_t yg, Double_t zg,
Double_t& xl, Double_t& yl, Double_t& zl)
{
const AliMUONGeometryTransformer* transformer = muon()->GetGeometryTransformer();
transformer->Global2Local(detElemId,xg,yg,zg,xl,yl,zl);
}
AliMUONResponseV0::AliMUONResponseV0()
: AliMUONResponse(),
fChargeSlope(0.0),
fChargeSpreadX(0.0),
fChargeSpreadY(0.0),
fSigmaIntegration(0.0),
fMaxAdc(0),
fSaturation(0),
fZeroSuppression(0),
fChargeCorrel(0.0),
fMathieson(new AliMUONMathieson),
fChargeThreshold(1e-4),
fIsTailEffect(kFALSE)
{
AliDebug(1,Form("Default ctor"));
}
AliMUONResponseV0::AliMUONResponseV0(const AliMUONResponseV0& other)
: AliMUONResponse(),
fChargeSlope(0.0),
fChargeSpreadX(0.0),
fChargeSpreadY(0.0),
fSigmaIntegration(0.0),
fMaxAdc(0),
fSaturation(0),
fZeroSuppression(0),
fChargeCorrel(0.0),
fMathieson(0),
fChargeThreshold(1e-4),
fIsTailEffect(kFALSE)
{
other.CopyTo(*this);
}
AliMUONResponseV0&
AliMUONResponseV0::operator=(const AliMUONResponseV0& other)
{
other.CopyTo(*this);
return *this;
}
AliMUONResponseV0::~AliMUONResponseV0()
{
AliDebug(1,"");
delete fMathieson;
}
void
AliMUONResponseV0::CopyTo(AliMUONResponseV0& other) const
{
other.fChargeSlope=fChargeSlope;
other.fChargeSpreadX=fChargeSpreadX;
other.fChargeSpreadY=fChargeSpreadY;
other.fSigmaIntegration=fSigmaIntegration;
other.fMaxAdc=fMaxAdc;
other.fSaturation=fSaturation;
other.fZeroSuppression=fZeroSuppression;
other.fChargeCorrel=fChargeCorrel;
delete other.fMathieson;
other.fMathieson = new AliMUONMathieson(*fMathieson);
other.fChargeThreshold=fChargeThreshold;
}
void
AliMUONResponseV0::Print(Option_t*) const
{
cout << " ChargeSlope=" << fChargeSlope
<< " ChargeSpreadX,Y=" << fChargeSpreadX
<< fChargeSpreadY
<< " ChargeCorrelation=" << fChargeCorrel
<< endl;
}
void AliMUONResponseV0::SetSqrtKx3AndDeriveKx2Kx4(Float_t SqrtKx3)
{
fMathieson->SetSqrtKx3AndDeriveKx2Kx4(SqrtKx3);
}
void AliMUONResponseV0::SetSqrtKy3AndDeriveKy2Ky4(Float_t SqrtKy3)
{
fMathieson->SetSqrtKy3AndDeriveKy2Ky4(SqrtKy3);
}
Float_t AliMUONResponseV0::IntPH(Float_t eloss) const
{
Int_t nel;
nel= Int_t(eloss*1.e9/27.4);
Float_t charge=0;
if (nel == 0) nel=1;
for (Int_t i=1;i<=nel;i++) {
Float_t arg=0.;
while(!arg) arg = gRandom->Rndm();
charge -= fChargeSlope*TMath::Log(arg);
}
return charge;
}
Float_t
AliMUONResponseV0::GetAnod(Float_t x) const
{
Int_t n = Int_t(x/Pitch());
Float_t wire = (x>0) ? n+0.5 : n-0.5;
return Pitch()*wire;
}
void
AliMUONResponseV0::DisIntegrate(const AliMUONHit& hit, TList& digits, Float_t timeDif)
{
digits.Clear();
Int_t detElemId = hit.DetElemId();
Double_t hitX = hit.X() ;
Double_t hitY = hit.Y() ;
Double_t hitZ = hit.Z() ;
Double_t dx = SigmaIntegration()*ChargeSpreadX();
Double_t dy = SigmaIntegration()*ChargeSpreadY();
if(fIsTailEffect){
Double_t locX,locY,locZ,globXCenter,globYCenter,globZ;
Int_t para = 5;
Double_t termA = 1.0;
Double_t termB = 1.0;
if(para>0){
for ( Int_t cath = AliMp::kCath0; cath <= AliMp::kCath1; ++cath )
{
const AliMpVSegmentation* seg =
AliMpSegmentation::Instance()
->GetMpSegmentation(detElemId,AliMp::GetCathodType(cath));
AliMp::PlaneType plane = seg->PlaneType();
if(plane == AliMp::kBendingPlane) {
Global2Local(detElemId,hitX,hitY,hitZ,locX,locY,locZ);
AliMpPad pad = seg->PadByPosition(locX,locY,kFALSE);
if(pad.IsValid()){
Double_t locYCenter = pad.GetPositionY();
Double_t locXCenter = pad.GetPositionX();
const AliMUONGeometryTransformer* transformer = muon()->GetGeometryTransformer();
transformer->Local2Global(detElemId,locXCenter,locYCenter,locZ,globXCenter,globYCenter,globZ);
for(Int_t itime = 0; itime<para; itime++)
termA *= 10.0;
for(Int_t itime = 0; itime<Int_t((2*para) + 1); itime++)
termB *= (hitY - globYCenter) ;
hitY = hitY + termA*termB;
}
}
}
}
}
Double_t x,y,z;
Global2Local(detElemId,hitX,hitY,hitZ,x,y,z);
x = GetAnod(x);
AliMpArea area(x,y,dx,dy);
Float_t qtot = IntPH(hit.Eloss());
if (timeDif!=0){
qtot = AliMUONConstants::ReducedQTot(qtot,timeDif);
}
qtot *= AliMUONConstants::DefaultADC2MV()*AliMUONConstants::DefaultA0()*AliMUONConstants::DefaultCapa();
Float_t currentCorrel = TMath::Exp(gRandom->Gaus(0.0,ChargeCorrel()/2.0));
for ( Int_t cath = AliMp::kCath0; cath <= AliMp::kCath1; ++cath )
{
Float_t qcath = qtot * ( cath == 0 ? currentCorrel : 1.0/currentCorrel);
const AliMpVSegmentation* seg =
AliMpSegmentation::Instance()
->GetMpSegmentation(detElemId,AliMp::GetCathodType(cath));
AliMpVPadIterator* it = seg->CreateIterator(area);
if (!it)
{
AliError(Form("Could not get iterator for detElemId %d",detElemId));
return;
}
it->First();
if ( it->IsDone() )
{
AliMpPad pad = seg->PadByPosition(area.GetPositionX(),area.GetPositionY(),
kFALSE);
if ( pad.IsValid() )
{
AliDebug(1, Form("Got an invalid iterator bug (area.Position() is within "
" DE but the iterator is void) for detElemId %d cath %d",
detElemId,cath));
}
else
{
AliDebug(1, Form("Got an invalid iterator bug for detElemId %d cath %d."
"Might be a bad hit ? area.Position()=(%e,%e) "
"Dimensions()=(%e,%e)",
detElemId,cath,area.GetPositionX(),area.GetPositionY(),
area.GetDimensionX(),area.GetDimensionY()));
}
delete it;
return;
}
while ( !it->IsDone() )
{
AliMpPad pad = it->CurrentItem();
TVector2 lowerLeft(TVector2(x,y)-TVector2(pad.GetPositionX(),pad.GetPositionY())-
TVector2(pad.GetDimensionX(),pad.GetDimensionY()));
TVector2 upperRight(lowerLeft + TVector2(pad.GetDimensionX(),pad.GetDimensionY())*2.0);
Float_t qp = TMath::Abs(fMathieson->IntXY(lowerLeft.X(),lowerLeft.Y(),
upperRight.X(),upperRight.Y()));
if ( qp > fChargeThreshold &&
qp*qcath > AliMUONConstants::DefaultADC2MV()*AliMUONConstants::DefaultA0()*AliMUONConstants::DefaultCapa() )
{
AliMUONDigit* d = new AliMUONDigit(detElemId,pad.GetManuId(),
pad.GetManuChannel(),cath);
d->SetPadXY(pad.GetIx(),pad.GetIy());
d->SetCharge(qp*qcath);
digits.Add(d);
}
it->Next();
}
delete it;
}
}
AliMUONResponseV0.cxx:100 AliMUONResponseV0.cxx:101 AliMUONResponseV0.cxx:102 AliMUONResponseV0.cxx:103 AliMUONResponseV0.cxx:104 AliMUONResponseV0.cxx:105 AliMUONResponseV0.cxx:106 AliMUONResponseV0.cxx:107 AliMUONResponseV0.cxx:108 AliMUONResponseV0.cxx:109 AliMUONResponseV0.cxx:110 AliMUONResponseV0.cxx:111 AliMUONResponseV0.cxx:112 AliMUONResponseV0.cxx:113 AliMUONResponseV0.cxx:114 AliMUONResponseV0.cxx:115 AliMUONResponseV0.cxx:116 AliMUONResponseV0.cxx:117 AliMUONResponseV0.cxx:118 AliMUONResponseV0.cxx:119 AliMUONResponseV0.cxx:120 AliMUONResponseV0.cxx:121 AliMUONResponseV0.cxx:122 AliMUONResponseV0.cxx:123 AliMUONResponseV0.cxx:124 AliMUONResponseV0.cxx:125 AliMUONResponseV0.cxx:126 AliMUONResponseV0.cxx:127 AliMUONResponseV0.cxx:128 AliMUONResponseV0.cxx:129 AliMUONResponseV0.cxx:130 AliMUONResponseV0.cxx:131 AliMUONResponseV0.cxx:132 AliMUONResponseV0.cxx:133 AliMUONResponseV0.cxx:134 AliMUONResponseV0.cxx:135 AliMUONResponseV0.cxx:136 AliMUONResponseV0.cxx:137 AliMUONResponseV0.cxx:138 AliMUONResponseV0.cxx:139 AliMUONResponseV0.cxx:140 AliMUONResponseV0.cxx:141 AliMUONResponseV0.cxx:142 AliMUONResponseV0.cxx:143 AliMUONResponseV0.cxx:144 AliMUONResponseV0.cxx:145 AliMUONResponseV0.cxx:146 AliMUONResponseV0.cxx:147 AliMUONResponseV0.cxx:148 AliMUONResponseV0.cxx:149 AliMUONResponseV0.cxx:150 AliMUONResponseV0.cxx:151 AliMUONResponseV0.cxx:152 AliMUONResponseV0.cxx:153 AliMUONResponseV0.cxx:154 AliMUONResponseV0.cxx:155 AliMUONResponseV0.cxx:156 AliMUONResponseV0.cxx:157 AliMUONResponseV0.cxx:158 AliMUONResponseV0.cxx:159 AliMUONResponseV0.cxx:160 AliMUONResponseV0.cxx:161 AliMUONResponseV0.cxx:162 AliMUONResponseV0.cxx:163 AliMUONResponseV0.cxx:164 AliMUONResponseV0.cxx:165 AliMUONResponseV0.cxx:166 AliMUONResponseV0.cxx:167 AliMUONResponseV0.cxx:168 AliMUONResponseV0.cxx:169 AliMUONResponseV0.cxx:170 AliMUONResponseV0.cxx:171 AliMUONResponseV0.cxx:172 AliMUONResponseV0.cxx:173 AliMUONResponseV0.cxx:174 AliMUONResponseV0.cxx:175 AliMUONResponseV0.cxx:176 AliMUONResponseV0.cxx:177 AliMUONResponseV0.cxx:178 AliMUONResponseV0.cxx:179 AliMUONResponseV0.cxx:180 AliMUONResponseV0.cxx:181 AliMUONResponseV0.cxx:182 AliMUONResponseV0.cxx:183 AliMUONResponseV0.cxx:184 AliMUONResponseV0.cxx:185 AliMUONResponseV0.cxx:186 AliMUONResponseV0.cxx:187 AliMUONResponseV0.cxx:188 AliMUONResponseV0.cxx:189 AliMUONResponseV0.cxx:190 AliMUONResponseV0.cxx:191 AliMUONResponseV0.cxx:192 AliMUONResponseV0.cxx:193 AliMUONResponseV0.cxx:194 AliMUONResponseV0.cxx:195 AliMUONResponseV0.cxx:196 AliMUONResponseV0.cxx:197 AliMUONResponseV0.cxx:198 AliMUONResponseV0.cxx:199 AliMUONResponseV0.cxx:200 AliMUONResponseV0.cxx:201 AliMUONResponseV0.cxx:202 AliMUONResponseV0.cxx:203 AliMUONResponseV0.cxx:204 AliMUONResponseV0.cxx:205 AliMUONResponseV0.cxx:206 AliMUONResponseV0.cxx:207 AliMUONResponseV0.cxx:208 AliMUONResponseV0.cxx:209 AliMUONResponseV0.cxx:210 AliMUONResponseV0.cxx:211 AliMUONResponseV0.cxx:212 AliMUONResponseV0.cxx:213 AliMUONResponseV0.cxx:214 AliMUONResponseV0.cxx:215 AliMUONResponseV0.cxx:216 AliMUONResponseV0.cxx:217 AliMUONResponseV0.cxx:218 AliMUONResponseV0.cxx:219 AliMUONResponseV0.cxx:220 AliMUONResponseV0.cxx:221 AliMUONResponseV0.cxx:222 AliMUONResponseV0.cxx:223 AliMUONResponseV0.cxx:224 AliMUONResponseV0.cxx:225 AliMUONResponseV0.cxx:226 AliMUONResponseV0.cxx:227 AliMUONResponseV0.cxx:228 AliMUONResponseV0.cxx:229 AliMUONResponseV0.cxx:230 AliMUONResponseV0.cxx:231 AliMUONResponseV0.cxx:232 AliMUONResponseV0.cxx:233 AliMUONResponseV0.cxx:234 AliMUONResponseV0.cxx:235 AliMUONResponseV0.cxx:236 AliMUONResponseV0.cxx:237 AliMUONResponseV0.cxx:238 AliMUONResponseV0.cxx:239 AliMUONResponseV0.cxx:240 AliMUONResponseV0.cxx:241 AliMUONResponseV0.cxx:242 AliMUONResponseV0.cxx:243 AliMUONResponseV0.cxx:244 AliMUONResponseV0.cxx:245 AliMUONResponseV0.cxx:246 AliMUONResponseV0.cxx:247 AliMUONResponseV0.cxx:248 AliMUONResponseV0.cxx:249 AliMUONResponseV0.cxx:250 AliMUONResponseV0.cxx:251 AliMUONResponseV0.cxx:252 AliMUONResponseV0.cxx:253 AliMUONResponseV0.cxx:254 AliMUONResponseV0.cxx:255 AliMUONResponseV0.cxx:256 AliMUONResponseV0.cxx:257 AliMUONResponseV0.cxx:258 AliMUONResponseV0.cxx:259 AliMUONResponseV0.cxx:260 AliMUONResponseV0.cxx:261 AliMUONResponseV0.cxx:262 AliMUONResponseV0.cxx:263 AliMUONResponseV0.cxx:264 AliMUONResponseV0.cxx:265 AliMUONResponseV0.cxx:266 AliMUONResponseV0.cxx:267 AliMUONResponseV0.cxx:268 AliMUONResponseV0.cxx:269 AliMUONResponseV0.cxx:270 AliMUONResponseV0.cxx:271 AliMUONResponseV0.cxx:272 AliMUONResponseV0.cxx:273 AliMUONResponseV0.cxx:274 AliMUONResponseV0.cxx:275 AliMUONResponseV0.cxx:276 AliMUONResponseV0.cxx:277 AliMUONResponseV0.cxx:278 AliMUONResponseV0.cxx:279 AliMUONResponseV0.cxx:280 AliMUONResponseV0.cxx:281 AliMUONResponseV0.cxx:282 AliMUONResponseV0.cxx:283 AliMUONResponseV0.cxx:284 AliMUONResponseV0.cxx:285 AliMUONResponseV0.cxx:286 AliMUONResponseV0.cxx:287 AliMUONResponseV0.cxx:288 AliMUONResponseV0.cxx:289 AliMUONResponseV0.cxx:290 AliMUONResponseV0.cxx:291 AliMUONResponseV0.cxx:292 AliMUONResponseV0.cxx:293 AliMUONResponseV0.cxx:294 AliMUONResponseV0.cxx:295 AliMUONResponseV0.cxx:296 AliMUONResponseV0.cxx:297 AliMUONResponseV0.cxx:298 AliMUONResponseV0.cxx:299 AliMUONResponseV0.cxx:300 AliMUONResponseV0.cxx:301 AliMUONResponseV0.cxx:302 AliMUONResponseV0.cxx:303 AliMUONResponseV0.cxx:304 AliMUONResponseV0.cxx:305 AliMUONResponseV0.cxx:306 AliMUONResponseV0.cxx:307 AliMUONResponseV0.cxx:308 AliMUONResponseV0.cxx:309 AliMUONResponseV0.cxx:310 AliMUONResponseV0.cxx:311 AliMUONResponseV0.cxx:312 AliMUONResponseV0.cxx:313 AliMUONResponseV0.cxx:314 AliMUONResponseV0.cxx:315 AliMUONResponseV0.cxx:316 AliMUONResponseV0.cxx:317 AliMUONResponseV0.cxx:318 AliMUONResponseV0.cxx:319 AliMUONResponseV0.cxx:320 AliMUONResponseV0.cxx:321 AliMUONResponseV0.cxx:322 AliMUONResponseV0.cxx:323 AliMUONResponseV0.cxx:324 AliMUONResponseV0.cxx:325 AliMUONResponseV0.cxx:326 AliMUONResponseV0.cxx:327 AliMUONResponseV0.cxx:328 AliMUONResponseV0.cxx:329 AliMUONResponseV0.cxx:330 AliMUONResponseV0.cxx:331 AliMUONResponseV0.cxx:332 AliMUONResponseV0.cxx:333 AliMUONResponseV0.cxx:334 AliMUONResponseV0.cxx:335 AliMUONResponseV0.cxx:336 AliMUONResponseV0.cxx:337 AliMUONResponseV0.cxx:338 AliMUONResponseV0.cxx:339 AliMUONResponseV0.cxx:340 AliMUONResponseV0.cxx:341 AliMUONResponseV0.cxx:342 AliMUONResponseV0.cxx:343 AliMUONResponseV0.cxx:344 AliMUONResponseV0.cxx:345 AliMUONResponseV0.cxx:346 AliMUONResponseV0.cxx:347 AliMUONResponseV0.cxx:348 AliMUONResponseV0.cxx:349 AliMUONResponseV0.cxx:350 AliMUONResponseV0.cxx:351 AliMUONResponseV0.cxx:352 AliMUONResponseV0.cxx:353 AliMUONResponseV0.cxx:354 AliMUONResponseV0.cxx:355 AliMUONResponseV0.cxx:356 AliMUONResponseV0.cxx:357 AliMUONResponseV0.cxx:358