// // C++ Implementation: PndSdsCalcStrip // // Description: // // // Author: HG Zaunick , (C) 2007 // // Copyright: See COPYING file that comes with this distribution // // #include #include "PndSdsCalcStripDif.h" #include "TRandom3.h" PndSdsCalcStripDif::PndSdsCalcStripDif(){ fPitch = 0.; fOrient = 0.; fAnchor = TVector2(0.,0.); fNrStrips = 0; fThreshold = 0.; fNoise = 0.; fVerboseLevel = 0; fRNG = new TRandom3(); } PndSdsCalcStripDif::PndSdsCalcStripDif(Double_t pitch, Double_t orient, Int_t nrStrips, Int_t nrFeChannels, const TVector2& firstStripAnchor, Double_t threshold, Double_t noise, Double_t sigma) : fPitch(pitch), fOrient(orient), fNrStrips(nrStrips), fNrFeChannels(nrFeChannels), fAnchor(firstStripAnchor), fThreshold(threshold), fNoise(noise) { fStripDir.Set(cos(fOrient),sin(fOrient)); fOrthoDir.Set(sin(fOrient),-cos(fOrient)); fVerboseLevel = 0; fRNG = new TRandom3(); fSigma = sigma; //Print(); } PndSdsCalcStripDif::PndSdsCalcStripDif(const PndSdsStripDigiPar* digipar, SensorSide side) { if(side == kTOP) { fPitch = digipar->GetTopPitch(); fOrient = digipar->GetOrient(); fAnchor = digipar->GetTopAnchor(); fNrStrips = digipar->GetNrTopFE()*digipar->GetNrFECh(); } else if(side == kBOTTOM) { fPitch = digipar->GetBotPitch(); fOrient = digipar->GetOrient() + digipar->GetSkew(); fAnchor = digipar->GetBotAnchor(); fNrStrips = digipar->GetNrBotFE()*digipar->GetNrFECh(); } fNrFeChannels = digipar->GetNrFECh(); fThreshold = digipar->GetThreshold(); fNoise = digipar->GetNoise(); fStripDir.Set(cos(fOrient),sin(fOrient)); fOrthoDir.Set(sin(fOrient),-cos(fOrient)); fVerboseLevel = 0; fRNG = new TRandom3(); if (fVerboseLevel > 0) Print(); } std::vector PndSdsCalcStripDif::GetStrips(Double_t inx, Double_t iny, Double_t inz, Double_t outx, Double_t outy, Double_t outz, Double_t eLoss) { if (fVerboseLevel > 2) std::cout<<"-I- PndSdsCalcStrip::GetStrips "< 2){ std::cout<<" InPoint: ("< strips; //Double_t smearedQ; if (path.Mod()<1E-18) { std::cout<<"-W- PndSdsCalcStrip::GetStrips : No Trajectory inside Sensor! (out-in).Mod() = "< 1) std::cout<<" pathlength: "< 2) std::cout<<" nuIn = "< (Double_t(fNrStrips))){ Q *= ((Double_t)fNrStrips-nuOut)/(-nuOut+nuIn); nuIn = Double_t(fNrStrips); } // is the Out-Point inside active area ? if (nuOut<0.){ Q *= (nuIn)/(-nuOut+nuIn); nuOut = 0.; } else if (nuOut > (Double_t(fNrStrips))){ Q *= ((Double_t)fNrStrips-nuIn)/(nuOut-nuIn); nuOut = Double_t(fNrStrips); } //path direction Double_t dir = (nuIn= fThreshold) // strips.push_back(PndSdsStrip(Int_t(nuOut),smearedQ)); //--------------------------Tsito Digi with diffusion------------------------------------------------ //Double_t path_real = path.Mod(); Int_t index = inStrip; Double_t charge1, charge2, dQ, dQR, dQL, QL, QR, QM; Int_t id; Double_t q_head,q_tail; //charge diffusion according to the gaussian smearing //between the 3 strips of index-1, index, and index+1 QL = ChargeDiffusion(0,Path1,pathO,dir,Q);//the diffusion charge from -infinite to index QR = Q - ChargeDiffusion(fPitch,Path1,pathO,dir,Q);//the diffusion charge from index to infinite QM = Q - QR -QL;// the charge left on the strip index if (fVerboseLevel > 1) std::cout<<"the QL,QR,QM are: "<fThreshold) strips.push_back(PndSdsStrip(index,dQ)); }else{ Int_t i=0; Int_t j=1; if(QL>=fThreshold){ //charge distribution at the head of the track charge1 = ChargeDiffusion((i-1)*fPitch,Path1,pathO,dir,Q);//charge distribution from -infinite to strip of index-1 if (fVerboseLevel > 1) std::cout<<"if QL>fThrehold, the charge on the strip(i-1)*fPitch is :"< 1) std::cout<<"if QL>fThrehold, the charge on the strip(i)*fPitch is :"<fThreshold) strips.push_back(PndSdsStrip(id,dQ)); } if(QR>=fThreshold){ //charge distribution at the head of the track charge1 = ChargeDiffusion(j*fPitch,Path1,pathO,dir,Q);//charge distribution from -infinite to strip of index-1 if (fVerboseLevel > 1) std::cout<<"if dQR>fThrehold, the charge on the strip(j)*fPitch is :"< 1) std::cout<<"if dQR>fThrehold, the charge on the strip(j+1)*fPitch is :"<fThreshold) strips.push_back(PndSdsStrip(id,dQ)); } //the charge left on the center strip Double_t restQ = ChargeDiffusion(fPitch,Path1,pathO,dir,Q) - ChargeDiffusion(0,Path1,pathO,dir,Q); restQ = SmearCharge(restQ); if(restQ>fThreshold)//added on Sep.17,2009 strips.push_back(PndSdsStrip(index,restQ)); if (fVerboseLevel > 1) std::cout<<"the rest Q on the middle strip is :"< 1) std::cout<<" -> "<nuIn) ? 1. : -1.; Int_t nrHits = 0; // calculate portion of track in first strip Int_t nextIn = Int_t(nuIn + 0.5+0.5*dir); Double_t Q1 = dQ*std::fabs(nextIn-nuIn); if (fVerboseLevel > 2){ std::cout<<" part of first strip : "<= fThreshold) strips.push_back(PndSdsStrip(Int_t(nuIn),Q1)); nrHits++; Q -= Q1; // calculate portion of track in last strip Int_t prevOut = Int_t(nuOut + 0.5-0.5*dir); Double_t Q2 = dQ*std::fabs(nuOut-prevOut); if (fVerboseLevel > 2){ std::cout<<" part of last strip : "<<(nuOut-prevOut)<= fThreshold) strips.push_back(PndSdsStrip(Int_t(nuOut),Q2)); nrHits++; Q -= Q2; // Distribute the charge among the intermediate strips nextIn = Int_t(nextIn - 0.5 + 0.5*dir); prevOut = Int_t(prevOut - 0.5 + 0.5*dir); if (fVerboseLevel > 2) { std::cout<<" dir="<outStrip, the head Path is "<0;i--) str_middle.push_back(strips[i]); dir=1; } strips.erase(strips.begin(),strips.begin()+size); //strips initialization Int_t index_head = str_head.GetIndex(); //Double_t path_head = str_head.GetPath(); Int_t index_tail = str_tail.GetIndex(); //Double_t path_tail = str_tail.GetPath(); //for the left strip of the head strip Double_t charge1, charge2; Int_t id; //Double_t ipath; //Double_t q_head,q_tail; Double_t dq_head = ChargeDiffusion(0,head_Path,path.Mod(),dir,total_Q);//the diffusion charge from -infinite to index // cout<<"the dir is "< 2) std::cout<<"the dq_head,dq_tail,q_head,q_tail are :"<fThreshold) { id = index_head-1; strip_head.push_back(PndSdsStrip(id,dQ_head)); } if(Q_head>fThreshold) { id = index_head; strip_head.push_back(PndSdsStrip(id,Q_head)); } strips.insert(strips.begin(),strip_head.begin(),strip_head.end()); if(dQ_tail>fThreshold) { id = index_tail+1; strip_tail.push_back(PndSdsStrip(id,dQ_tail)); } if(Q_tail>fThreshold) { id = index_tail; strip_head.push_back(PndSdsStrip(id,Q_tail)); } strips.insert(strips.end(),strip_tail.begin(),strip_tail.end()); //for the strips between the head and the tail //condition for middle strips nextIn = Int_t(nuIn+0.5+0.5*dir); prevOut = Int_t(nuOut+0.5-0.5*dir); nextIn=Int_t(nextIn-0.5+0.5*dir); prevOut=Int_t(prevOut-0.5+0.5*dir); if(nextIn != prevOut){ for(Int_t i= 1;i< size-1;i++){ charge1 = ChargeDiffusion(i*fPitch,head_Path,path.Mod(),dir,total_Q); charge2 = ChargeDiffusion((i+1)*fPitch,head_Path,path.Mod(),dir,total_Q); dQ = charge2 - charge1; //std::vector::iterator iter_ii=strip_middle.begin(); if(dir==-1) id = i; else id = size-1-i; //id = iter_ii->GetIndex(); //ipath = iter_ii->GetPath(); Double_t tmpCharge = SmearCharge(dQ); if(tmpCharge>fThreshold) strip_middle.push_back(PndSdsStrip(id,tmpCharge)); //iter_ii++; }//loop for all strips between head and tail strips.insert(strips.begin()+strip_head.size(),strip_middle.begin(),strip_middle.begin()+strip_middle.size()); /*for(Int_t i=0; i 2) if (fabs(Q)>1.) std::cout<<" charge Q = "< 1) std::cout<<" -> "<Gaus(charge,fNoise); if (fVerboseLevel > 3) std::cout<<" charge = "<