13 #include "StFgtSlowSimuMaker.h"
14 #include "HexLatice.h"
16 #include "tables/St_g2t_fgt_hit_Table.h"
24 memset(hA,0,
sizeof(hA));
26 mRnd =
new TRandom3();
29 forcePerpTracks(
false);
32 par_2DpixAmplThres=0.1;
33 par_stripAmplThres=1.0;
34 par_XYamplSigma=0.035 ;
36 par_radStripGainMean=1.0;par_radStripGainSigma=0.0;
37 par_cutoffOfBichel = 9992;
38 mRadStripRelativeGain=0;
39 mPhiStripRelativeGain=0;
47 for(i=0;i<kFgtMxDisk;i++){
48 for(j=0;j<kFgtMxQuad;j++) {
51 mRadAdcList[i].clear();
52 mPhiAdcList[i].clear();
59 StFgtSlowSimuMaker::~StFgtSlowSimuMaker(){
66 StFgtSlowSimuMaker::saveHisto(TString fname){
70 TString outName=fname+
".hist.root";
71 TFile f( outName,
"recreate");
73 printf(
"%d histos are written to '%s' ...\n",HList->GetEntries(),outName.Data());
86 LOG_INFO<<
"::Finish() \n"<< endm;
98 StFgtSlowSimuMaker::Init(){
99 LOG_INFO<<
"::Init() "<< endm;
101 assert( meLossTab[0]>0);
113 amplF=
new TF1(
"Gs",
"exp( -(x-[0])*(x-[0])/2./[1]/[1])",-1.,1.);
114 amplF->SetParNames(
"X0",
"sig");
115 amplF ->SetParameters(0.,par_XYamplSigma);
116 amplF ->SetLineWidth(2); amplF->SetLineColor(kMagenta);
122 mRadStripRelativeGain=
new double[geom->radStripGBLId_number()+1];
123 memset(mRadStripRelativeGain,0,
sizeof(mRadStripRelativeGain));
125 for(i=0;i<geom->radStripGBLId_number();i++) {
127 while(fabs(del)> 2.*par_radStripGainSigma)
128 del= mRnd->Gaus(0,par_radStripGainSigma);
129 mRadStripRelativeGain[i]=par_radStripGainMean+del;
134 mPhiStripRelativeGain=
new double[geom->phiStripGBLId_number()+1];
135 memset(mPhiStripRelativeGain,0,
sizeof(mPhiStripRelativeGain));
136 for(i=0;i<geom->phiStripGBLId_number();i++) {
138 while(fabs(del)> 2.*par_phiStripGainSigma)
139 del= mRnd->Gaus(0,par_phiStripGainSigma);
140 mPhiStripRelativeGain[i]=par_phiStripGainMean+del;
145 if(par_hexLaticePitch >0.001) {
146 hexLat=
new HexLatice (par_hexLaticePitch, par_hexLaticePhi1deg);
148 LOG_INFO<<Form(
"::Init hexGemLatice DISABLED, too small pitch")<<endm;
149 par_hexLaticePitch = 0.0;
154 LOG_INFO<<Form(
"::Init params: X,YamplSigma=%.4f cm, 2DpixAmplThres=%.2f a.u., stripAmplThres=%.2f a.u., forcePerpTracks=%d useOnlyDisk=%d RadGain(m=%.2f,sig=%.2f) PhiGain(m=%.2f,sig=%.2f, GemHexLatice: pitch/um=%.1f, phi1/deg=%.1f, transDiffusion=%.1f um/1cmOfPath, cutoffOfBichel=%d)",par_XYamplSigma,par_2DpixAmplThres,par_stripAmplThres,par_forcePerp,par_useOnlyDisk,par_radStripGainMean,par_radStripGainSigma,par_phiStripGainMean,par_phiStripGainSigma,par_hexLaticePitch*1e4, par_hexLaticePhi1deg,par_transDiffusionPerPath*1e4,par_cutoffOfBichel)<< endm;
156 assert(par_XYamplSigma>0);
158 Info(
"Init",
"testing access to TGeoManager");
161 Info(
"Load",
"TGeoManager(%s,%s) is already there"
162 ,gGeoManager->GetName(),gGeoManager->GetTitle());
164 Warning(
"Init",
"add TGeoManager");
168 TString ts =
"SandBox.C(0,0)";
171 gROOT->Macro(ts, &ierr);
176 TGeoVolume *geoFgt = gGeoManager ->FindVolumeFast(
"FGMO");
179 geoFgt -> InspectMaterial();
180 geoFgt -> InspectShape();
181 printf(
"XXXXXXXXXXXXXXXXXXXXXXXXX\nXXXXXXXXXXXXX\nXXXXXXXXXX\n");
185 return StMaker::Init();
195 LOG_INFO <<
"::Make() inpEve="<< mInpEve<<endm;
197 St_g2t_fgt_hit *fgt_hitT = (St_g2t_fgt_hit *) GetDataSet(
"g2t_fgt_hit");
199 LOG_FATAL<<Form(
"g2t_Fgt table empty")<<endm;
209 sort_g2t_hits( fgt_hitT );
212 for(iDisk=0;iDisk<kFgtMxDisk;iDisk++) {
213 digRad->Reset(); digPhi->Reset();
214 if(par_useOnlyDisk)
if(par_useOnlyDisk-1 != iDisk)
continue;
215 for(iQuad=0;iQuad<kFgtMxQuad;iQuad++) {
218 printf(
" process %d g2t hits in disk=%d quad=%d\n",
mG2tHitList[iDisk][iQuad].size(),iDisk,iQuad);
220 vector<fgt_g2t_auxil> &L=
mG2tHitList[iDisk][iQuad];
221 if(L.size()<=0)
continue;
223 i=0;i<L.size();i++) {
225 responseFrankModel(L[i].Rloc,L[i].Dloc);
226 hA[11+iDisk]->Fill(L[i].Rlab.x(),L[i].Rlab.y());
227 printf(
"iQ=%d itr=%d R/cm=%.2f phi/deg=%.3f\n",iQuad,i,L[i].Rlab.Perp(), L[i].Rlab.Phi()/3.1416*180);
230 if(!projectQuadrant(iQuad))
continue;
235 exportStripPlane(digRad,mRadAdcList[iDisk]);
236 exportStripPlane(digPhi,mPhiAdcList[iDisk]);
240 printf(
" Summary of fired strips\n disk #Rad-strip #Phi-strip \n");
241 for(iDisk=0;iDisk<kFgtMxDisk;iDisk++) printf(
"%d %d %d \n",iDisk,mRadAdcList[iDisk].size(),mPhiAdcList[iDisk].size());
250 StFgtSlowSimuMaker::sort_g2t_hits( St_g2t_fgt_hit *fgt_hitT){
251 g2t_fgt_hit_st *hitPtr = fgt_hitT->GetTable();
253 LOG_INFO<<Form(
"Sorting g2t FGT hits, size=%d",fgt_hitT->GetNRows())<<endm;
256 Int_t nhits = fgt_hitT->GetNRows();
257 for(Int_t ih=0; ih<nhits; ih++,hitPtr++) {
258 Int_t ivid = hitPtr->volume_id;
261 Int_t numbv1 = ivid/1000000;
278 cout <<
" Volume_id diskID QuadID: "
279 << ivid <<
" " << diskID <<
" " << iQuad << endl;
281 TVector3 Rlab( hitPtr->x);
291 Rloc.RotateZ(-geom->phiQuadXaxis(iQuad));
294 if(diskID!=8 && !geom->inDisk(Rlab))
continue;
297 if(fabs(Rloc.x()) < geom->deadQuadEdge())
continue;
299 if(fabs(Rloc.y()) < geom->deadQuadEdge())
continue;
302 double tof_ns=hitPtr->tof*1.e9;
304 if(hitPtr->tof> geom-> maxTof() )
continue;
307 TVector3 Plab(hitPtr->p);
308 if(Plab.Mag()>0) hA[7]->Fill(log10(Plab.Mag()*1000.));
309 if(Plab.Mag()< geom-> minPmag() )
continue;
326 int iQuadChk=geom->getQuad(Rlab.Phi());
327 if(iQuad != iQuadChk) {
328 cout <<
" Something wrong in quadIDs!! " << endl;
329 cout <<
" iQuad from StFgtGeom and iQuad from Geant = "
330 << iQuadChk <<
", " << iQuad << endl;
336 double ds=hitPtr->ds;
338 TVector3 verLab=Plab.Unit();
339 if(par_forcePerp) verLab=TVector3(0,0,1);
340 TVector3 Rloc2=Rlab+ds*verLab; Rloc2.RotateZ(-geom->phiQuadXaxis(iQuad));
341 TVector3 Dloc=Rloc2-Rloc;
347 aux.Rlab=Rlab+ds/2.*verLab;
357 hA[3]->Fill(10+5*diskID);
358 hA[3]->Fill(10+5*diskID+iQuad+1);
359 double de_kev=hitPtr->de*1.e6;
361 hA[1]->Fill(hitPtr->ds);
362 hA[2]->Fill(Rlab.z());
363 hA[4]->Fill(Rlab.x(),Rlab.y());
364 hA[6]->Fill(Rlab.Perp());
367 LOG_INFO<<Form(
"Sorting g2g FGT %d hits --> accepted %d",nhits,ntot)<<endm;
375 StFgtSlowSimuMaker::projectQuadrant(
int iquad) {
377 double totAmp=digXY->Integral();
378 LOG_INFO<<Form(
"::digiQuad() totAmp=%g",totAmp)<< endm;
379 if(totAmp <par_stripAmplThres)
return false;
385 int nx=digXY->GetNbinsX();
386 int ny=digXY->GetNbinsY();
388 for(bx=1;bx<=nx;bx++)
389 for(by=1;by<=ny;by++) {
390 float amp=digXY->GetBinContent(bx,by);
391 if(amp<par_2DpixAmplThres)
continue;
394 double x=digXY->GetXaxis()->GetBinCenter(bx);
395 double y=digXY->GetYaxis()->GetBinCenter(by);
397 if( !geom->localXYtoStripID(iquad,x,y,iRadID, iPhiID))
continue;
401 digRad->Fill(iRadID,amp* mRadStripRelativeGain[iRadID]);
402 digPhi->Fill(iPhiID,amp* mPhiStripRelativeGain[iPhiID]);
404 digRadAll->Fill(iRadID,amp* mRadStripRelativeGain[iRadID]);
405 digPhiAll->Fill(iPhiID,amp* mPhiStripRelativeGain[iPhiID]);
408 printf(
"digi: nPix=%d sumAmp=%g\n", nPix,sumAmp);
418 StFgtSlowSimuMaker::exportStripPlane(TH1F *h, vector<fgt_strip> &L) {
419 float *y=h->GetArray();
421 float nx=h->GetNbinsX();
422 for(
int id=0;
id<nx;
id++,y++) {
424 if(ene <par_stripAmplThres)
continue;
virtual void Clear(Option_t *option="")
User defined functions.
vector< fgt_g2t_auxil > mG2tHitList[kFgtMxDisk+1][kFgtMxQuad]
accepted track segements
virtual void Clear(Option_t *option="")
User defined functions.
.... utility c-struct for g2t hits
TVector3 Rloc
hit entrance in LAB
g2t_fgt_hit_st * hitPtr
entrance & path in local ref frame