StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StFgtSlowSimuMaker.cxx
1 // *-- Author : J.Balewski
2 //
3 // $Id: StFgtSlowSimuMaker.cxx,v 1.4 2012/11/08 17:16:20 akio Exp $
4 #include <TVector3.h>
5 #include <TH2.h>
6 #include <TF1.h>
7 #include <TFile.h>
8 #include <TLine.h>
9 #include <TPolyLine.h>
10 #include <TCrown.h>
11 #include <TRandom3.h>
12 
13 #include "StFgtSlowSimuMaker.h"
14 
15 #include "tables/St_g2t_fgt_hit_Table.h"
16 #include "StFgtDbMaker/StFgtDbMaker.h"
17 #include "StFgtDbMaker/StFgtDb.h"
18 
19 #include "StRoot/StEvent/StFgtCollection.h"
20 #include "StRoot/StEvent/StEvent.h"
21 
22 ClassImp(StFgtSlowSimuMaker)
23 
24 //--------------------------------------------
25  StFgtSlowSimuMaker::StFgtSlowSimuMaker(const char *name):StMaker(name){
26  setHList(0);
27  memset(hA,0,sizeof(hA));
28  fgtDb=0;
29  par_badSetup=0; // default all is OK
30  mRnd = new TRandom3(); // general use random generator
31  mRnd->SetSeed(0); // activate, assure every set of data is different
32  switch_addPeds=1; // re-set in bfc.C
33 
34 }
35 
36 const Float_t StFgtSlowSimuMaker::pulseShape[20]={0.0,0.1,0.3,0.4,0.2,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0};//sum 1.0
37 //--------------------------------------------
38 //--------------------------------------------
39 void
40 StFgtSlowSimuMaker::Clear(Option_t *) {
41  Int_t i,j;
42  for(i=0;i<kFgtNumDiscs;i++){
43  for(j=0;j<kFgtNumQuads;j++) {
44  mG2tHitList[i][j].clear();
45  }
46  }
47 
49 }
50 
51 
52 //--------------------------------------------
53 //--------------------------------------------
54 StFgtSlowSimuMaker::~StFgtSlowSimuMaker(){
55 
56 }
57 
58 //_______________________________________________
59 //________________________________________________
60 void
61 StFgtSlowSimuMaker::saveHisto(TString fname){
62 
63 #ifdef __FGT_QA_HISTO__
64  CloseHisto();
65 
66  TString outName=fname+".hist.root";
67  TFile f( outName,"recreate");
68  // jjassert(f.IsOpen());
69  printf("%d histos are written to '%s' ...\n",HList->GetEntries(),outName.Data());
70 
71  HList->Write();
72  f.Close();
73 #endif
74 
75 }
76 
77 
78 //--------------------------------------------
79 //--------------------------------------------
80 //--------------------------------------------
81 Int_t
83  LOG_INFO<<"::Finish() \n"<< endm;
84 
85 #ifdef __FGT_QA_HISTO__
86  TString a("fgtSlowSimQA");
87  saveHisto(a);
88 #endif
89 
90  return StMaker::Finish();
91 }
92 
93 //--------------------------------------------
94 //--------------------------------------------
95 //--------------------------------------------
96 Int_t
97 StFgtSlowSimuMaker::InitRun(Int_t runNumber){
98  LOG_INFO<<"::InitRun() "<< runNumber<< endm;
99 
100  if(fgtDb==0){
101  StFgtDbMaker* dbmkr=(StFgtDbMaker*)GetMaker("fgtDb");
102  if(!dbmkr) {
103  LOG_ERROR<<"StFgtSlowSimuMaker::InitRun could not find FgtDb Maker"<<endm;
104  return kStWarn;
105  }
106  fgtDb=dbmkr->getDbTables();
107  if(!fgtDb){
108  LOG_ERROR<<"StFgtSlowSimuMaker::InitRun could not find FgtDb table from FgtDbMaker"<<endm;
109  return kStWarn;
110  }
111  }
112 
113  LOG_INFO<< Form("fgt-simu-params from DB, ver=%.0f:\n",fgtDb->getSimuParam(0))<<endl;
114  // for(int kk=0;kk<15;kk++) printf("par[%d]=%f\n",kk, fgtDb->getSimuParam(kk));
115 
116  // analog signal propagation
117  par_cutoffOfBichel=fgtDb->getSimuParam(1); // eLossTable
118  par_pairsPerCm =fgtDb->getSimuParam(2); //( ions/cm) # of primary pairs produced per cm of path
119  par_trackTOFcutoff=fgtDb->getSimuParam(3); // (seconds) track ignored by FGT slow sim
120  par_XYamplSigma =fgtDb->getSimuParam(4) ; // cm, for 2D gauss smearing, default=0.035 for FNAL
121  par_trackPcutoff =fgtDb->getSimuParam(5); // (GeV) track ignored by FGT slow sim
122  par_transDiffusionPerPath=fgtDb->getSimuParam(6); // (cm per 1 cm of path) , must be specified
123  par_binStep=fgtDb->getSimuParam(7); // # of bins in 2D distribution to store 2D gauss
124 
125  // digitalization
126  par_stripThreshAdc=fgtDb->getSimuParam(10); // drop strips below it
127  par_2DampCutoffScale=fgtDb->getSimuParam(11); // in a.u. used in simu
128  par_overalGain=fgtDb->getSimuParam(12); // a factor making simulated ADCs comparable to 2012 data
129  LOG_INFO<<"par_overalGain from DB = " << par_overalGain << ", but overwriting to 20 for now. Need fix in DB later"<<endm;
130  par_overalGain=20;
131  par_PplaneChargeFraction=fgtDb->getSimuParam(13); // divide charge between P/R plane
132 
133  LOG_INFO<<Form("::InitRun() runNo=%d badSetup=0x%x; params: track cutoff: TOF<%.1fns and P>%.1f MeV/c ; prim ions/cm=%.1f, X,YamplSigma=%.4f cm, stripThres=%.2f (ADC), transDiffusion=%.1f um/1cm, cutoffOfBichel=%d, binStep=%d Digi: 2DampCutoffScale=%.1f a.u., overalGain=%.2f a.u. P-planeChargFract=%.2f switch_addPeds=%d", runNumber, par_badSetup,
134  par_trackTOFcutoff*1e9,par_trackPcutoff*1e3,
135  par_pairsPerCm, par_XYamplSigma,par_stripThreshAdc,
136  par_transDiffusionPerPath*1e4,
137  par_cutoffOfBichel, par_binStep,
138  par_2DampCutoffScale,par_overalGain,par_PplaneChargeFraction,
139  switch_addPeds)<< endm; // fix it
140 
141  //if() par_badSetup+=0x1;
142  if(par_XYamplSigma<=0) par_badSetup+=0x2;//jjassert(par_XYamplSigma>0);
143  if(par_pairsPerCm <=0) par_badSetup+=0x4;//jjassert(par_pairsPerCm >0);
144 
145 
146  return kStOK;
147 }
148 
149 
150 //--------------------------------------------
151 //--------------------------------------------
152 //--------------------------------------------
153 Int_t
154 StFgtSlowSimuMaker::Init(){
155 
156  LOG_INFO<<"::Init()"<< endm;
157 
158  mInpEve=0;
159 
160 #ifdef __FGT_QA_HISTO__
161  HList=new TObjArray;
162 #endif
163 
164  InitHisto1();
165 
166 #ifdef __FGT_QA_HISTO__
167  InitHisto2();
168 #endif
169 
170 
171 
172  //jjassert(fgtDb);
173 
174  return StMaker::Init();
175 }
176 
177 //--------------------------------------------
178 //--------------------------------------------
179 //--------------------------------------------
180 Int_t
182  bool debug=false;
183  mInpEve++;
184 
185  if( par_badSetup) {
186  LOG_ERROR<< Form(" Make skips FGT content for this event %d because of incorrect initialization from DB, val=0x%0x",mInpEve,par_badSetup);
187  return kStOK;
188  }
189 
190 
191  // Prepare the environment for filling the FGT --> StEvent
192  StEvent* mEvent = (StEvent*)GetInputDS("StEvent");
193  //jjassert(mEvent); // fix your chain
194  if ( !mEvent )
195  {
196  LOG_WARN << "StEvent is missing. FGT slow simulator skipping event" << endl;
197  return kStWarn;
198  }
199 
200  mEventId=mEvent->id();
201  LOG_INFO <<Form("%s::Make() inpEve=%d, eveId=%d", GetName(),mInpEve,mEventId)<<endm;
202 
203 
204  // new access to fgtCollection
205  StFgtCollection* fgtColl= mEvent-> fgtCollection();
206 
207  if(fgtColl==0) {
208  StFgtCollection* fgtX=new StFgtCollection();
209  mEvent->setFgtCollection(fgtX);
210  //LOG_INFO << Form("%s::Make added a non existing StFgtCollection()",GetName())<<endm;
211  fgtColl= mEvent-> fgtCollection();
212  }
213 
214  //jjassert(fgtColl);// now it can't fail unless ths big is messed up
215 
216  //jjassert((int)fgtColl->getNumDiscs()==kFgtNumDiscs); // tmp, should be initialized from the common source - keep it for now
217  //mEvent->ls(3);
218 
219 
220  //============ FGT ==========
221  St_g2t_fgt_hit *fgt_hitT = (St_g2t_fgt_hit *) GetDataSet("g2t_fgt_hit");
222  if(fgt_hitT ==0) {
223  LOG_FATAL<<Form("g2t_Fgt table empty")<<endm;
224  return kStOK;
225  }
226 
227 
228  unpack_g2t_hits( fgt_hitT ); // unpack geant response
229 
230  /* the 2D quadrant response map is produced separately for each of
231  24 quadrant due to RAM limitations for quadDigitizationXY which is humongous.
232  Strip response is accumulated for whole disk, then exported
233  */
234  Int_t iDisc=0,iQuad=0;
235  for(iDisc=0;iDisc<kFgtNumDiscs ;iDisc++) {
236  for(iQuad=0;iQuad<kFgtNumQuads;iQuad++) {
237 
238  quadDigitizationXY->Reset(); // needs reset for every quadrant
239  quadDigitizationRad->Reset(); quadDigitizationPhi->Reset(); //clear once per quad
240  // accumulate response in quadDigitizationXY array
241  vector<fgt_g2t_auxil> &L=mG2tHitList[iDisc][iQuad];
242  if(L.size()<=0) continue;// drop if empty quad
243  Int_t stripIdOffset= kFgtNumStrips * ( iDisc*kFgtNumQuads + iQuad)*2;
244  if(debug) LOG_INFO<<Form("Process g2t hits in disk=%d quad=%d nHit=%d idOff=%d",iDisc,iQuad,L.size(),stripIdOffset)<<endm;
245  for(UInt_t i=0;i<L.size();i++) { // populate: quadDigitizationXY
246  responseMipModel(L[i].Rloc,L[i].Dloc);
247 #ifdef __FGT_QA_HISTO__
248  hA[11+iDisc] ->Fill(L[i].Rlab.x(),L[i].Rlab.y()); // monitor hit distribution
249 #endif
250  if(debug){
251  printf("DIGIXY Lab: Disc=%1d Quad=%1d itr=%d x=%8.4f y=%8.4f z=%8.4f R=%8.4f phi=%10.6f\n",
252  iDisc,iQuad,i,L[i].Rlab.X(),L[i].Rlab.Y(),L[i].Rlab.Z(),L[i].Rlab.Perp(), L[i].Rlab.Phi()); // pi value corrected WMZ
253  printf("DIGIXY Loc: Disc=%1d Quad=%1d itr=%d x=%8.4f y=%8.4f z=%8.4f R=%8.4f phi=%10.6f\n",
254  iDisc,iQuad,i,L[i].Rloc.X(),L[i].Rloc.Y(),L[i].Rloc.Z(),L[i].Rloc.Perp(), L[i].Rloc.Phi()); // pi value corrected WMZ
255  }
256  }
257  // now full quadrtant response is stored in quadDigitizationXY array
258  if(quadDigitizationXY->Integral()<0.1) continue;
259  projectQuad2strips( iDisc, iQuad);
260  // strips response is generated (and projected to 1D stip histos: R & Phi for QA)
261  exportStripPlane2StEvent(quadDigitizationRad,stripIdOffset,fgtColl->getStripCollection(iDisc));
262  exportStripPlane2StEvent(quadDigitizationPhi,stripIdOffset+kFgtNumStrips,fgtColl->getStripCollection(iDisc));
263  }// end of quadrant
264  } // end of disk
265 
266  LOG_INFO<<Form("End of fgt-slow-simu FgtColl: numDisc=%d, total strips=%d",fgtColl->getNumDiscs(),fgtColl -> getNumStrips() )<<endm;
267 
268  if(debug){
269  for(iDisc=0; iDisc <(int)fgtColl->getNumDiscs(); iDisc++) {
270  StFgtStripCollection *stripPtr= fgtColl->getStripCollection(iDisc);
271 
272  //printf(" content: iDisc=%d # of : strips=%d clust=hits=%d\n" ,stripPtr -> getDisc() ,fgtColl ->getNumStrips(iDisc) ,fgtColl -> getNumHits( iDisc));
273 
274  StSPtrVecFgtStrip &stripVec = stripPtr->getStripVec();
275  Int_t ih=0;
276  for( StSPtrVecFgtStripIterator it=stripVec.begin();it!=stripVec.end();++it, ih++) {
277  // details of strip localization, use output variables ending w/ X
278  Short_t discX, quadrantX, stripX; Char_t layerX;
279  StFgtGeom::decodeGeoId(((*it))->getGeoId(),discX,quadrantX, layerX, stripX);
280  // octX is 0 for short octant and 1 for long octant
281  //Int_t octX=1; if (stripX<300) octX=0;
282  LOG_DEBUG<<Form("iDisc=%d ih=%d strip: geoId=%d ADC=%d charge=%.1f deco0: strip=%d quad=%d oct=%d plane=%c disc=%d \n",iDisc,ih,((*it))->getGeoId(),((*it))->getAdc(0),((*it))->getCharge(),stripX,quadrantX,stripX>=300,layerX,discX)<<endm;
283  //printf(" decode -> disc=%d, quad=%d layer=%c, strip=%d xOct=%d\n", disc,quadrant, layer, strip,xOct);
284  }
285  }
286  }
287 
288  return kStOK;
289 }
290 
291 //--------------------------------------------
292 //--------------------------------------------
293 //--------------------------------------------
294 void
295 StFgtSlowSimuMaker::unpack_g2t_hits( St_g2t_fgt_hit *fgt_hitT){
296  g2t_fgt_hit_st *hitPtr = fgt_hitT->GetTable();
297  //jjassert(hitPtr);
298  //LOG_INFO<<Form("Unpacking g2t FGT hits, size=%d",fgt_hitT->GetNRows())<<endm;
299 
300  Int_t ntot=0;
301  Int_t nhits = fgt_hitT->GetNRows();
302  for(Int_t ih=0; ih<nhits; ih++,hitPtr++) {
303  Int_t ivid = hitPtr->volume_id;
304  Double_t de_keV= hitPtr->de*1e6;
305  Double_t tof_ns=hitPtr->tof*1.e9;
306 
307  // decode volume_id , Victor: I will use volume_id = numbv(1)*100 + numbv(2)
308  Int_t numbv1 = ivid/100;
309  Int_t numbv2 = ivid%100;
310  Int_t iDisc; // range [0 //myMkSM->testStripMap('R');-5]
311  Int_t iQuad; // range [0-3]
312 
313  iDisc = numbv1-1 ;
314  iQuad = numbv2 - 1;
315 
316  TVector3 Rlab( hitPtr->x); // entrance point in Lab ref
317  Float_t Rxy=sqrt(Rlab.X()*Rlab.X()+Rlab.Y()*Rlab.Y());
318  //LOG_INFO<<Form("Volume_id ivid=%d discID=%d QuadID=%c LAB x=%.2f y=%.2f z=%.2f eta=%.3f phi=%10.6f, Rxy/cm=%8.4f de/keV=%g tof/ns=%f",
319  // ivid, iDisc+1, iQuad+'A',Rlab.X(),Rlab.Y(),Rlab.Z(), Rlab.Eta(), Rlab.Phi(), Rxy ,de_keV, tof_ns);
320  //LOG_INFO<<Form(" Px=%8.4f Py=%8.4f Pz=%8.4f\n",hitPtr->p[0],hitPtr->p[1],hitPtr->p[2]);
321 
322 #if 0 // use only disc #1, for testing
323  if(iDisc!=0 || iQuad!=1) {
324  printf("TT tmp skip disc ? or quad ?\n");
325  hA[3]->Fill(8);
326  continue;
327  }
328 #endif
329 
330  /*
331  IQuad my not match Rlab.Phi() for hits at edges between two quadrants
332  (deadQuadEdge)! The following conversion would rotate Rlab with a wrong
333  angle if a mismatch happens. However, Rloc.x() or Rloc.y() would be still
334  very close to one of two edges of a local quadrant and the cuts on Rloc.x()
335  and Rloc.y() later would reject them. WMZ
336  */
337 
338  //printf("Unpack Rlab: Disc=%1d Quad=%1d x=%10.6f y=%10.6f z=%10.6f R=%10.6f phi=%10.6f\n",
339  // iDisc,iQuad,Rlab.X(),Rlab.Y(),Rlab.Z(),Rlab.Perp(), Rlab.Phi());
340  TVector3 Rloc=Rlab; // tmp, no ability to shift/tilt disc in STAR Jan
341  Rloc.RotateZ(-StFgtGeom::phiQuadXaxis(iQuad));
342  //printf("Unpack RLoc: Disc=%1d Quad=%1d x=%10.6f y=%10.6f z=%10.6f R=%10.6f phi=%10.6f\n",
343  // iDisc,iQuad,Rloc.X(),Rloc.Y(),Rloc.Z(),Rloc.Perp(), Rloc.Phi());
344 
345 #ifdef __FGT_QA_HISTO__
346  hA[3]->Fill(1);
347 #endif
348  if(!StFgtGeom::inDisc(Rlab)) continue;
349 #ifdef __FGT_QA_HISTO__
350  hA[3]->Fill(2);
351 #endif
352  if(fabs(Rloc.x()) < StFgtGeom::deadQuadEdge()) continue;
353 #ifdef __FGT_QA_HISTO__
354  hA[3]->Fill(3);
355 #endif
356  if(fabs(Rloc.y()) < StFgtGeom::deadQuadEdge()) continue;
357 #ifdef __FGT_QA_HISTO__
358  hA[3]->Fill(4);
359 #endif
360  if(!StFgtGeom::belowFlat(Rloc)) continue;
361 #ifdef __FGT_QA_HISTO__
362  hA[3]->Fill(5);
363  hA[5]->Fill(tof_ns);
364 #endif
365  if(hitPtr->tof> par_trackTOFcutoff ) continue;
366 #ifdef __FGT_QA_HISTO__
367  hA[3]->Fill(6);
368 #endif
369 
370  TVector3 Plab(hitPtr->p);
371  //TVector3 Plab(0,0,1);
372 #ifdef __FGT_QA_HISTO__
373  if(Plab.Mag()>0) hA[7]->Fill(log10(Plab.Mag()*1000.));
374 #endif
375  if(Plab.Mag()< par_trackPcutoff ) continue;
376 #ifdef __FGT_QA_HISTO__
377  hA[3]->Fill(7);
378 #endif
379  /* *** This model assumes all tracks are MIPS *** */
380 
381  // hA[3]->Fill(7...9); free
382 
383  //....... hit is accepted for processing ...............
384  Double_t ds=hitPtr->ds;
385 
386  TVector3 verLab=Plab.Unit(); // direction of track in LAB
387  // if(par_forcePerp) verLab=TVector3(0,0,1);// for testing ONLY: make track perp to GEM
388  TVector3 Rloc2=Rlab+ds*verLab; Rloc2.RotateZ(-StFgtGeom::phiQuadXaxis(iQuad));
389  TVector3 Dloc=Rloc2-Rloc; // local vector along the path
390  /*
391  printf("Unpack Plab: Disc=%1d Quad=%1d x=%10.6f y=%10.6f z=%10.6f R=%10.6f phi=%10.6f\n",
392  iDisc,iQuad,Plab.X(),Plab.Y(),Plab.Z(),Plab.Perp(),Plab.Phi());
393  printf("Unpack verL: Disc=%1d Quad=%1d x=%10.6f y=%10.6f z=%10.6f R=%10.6f phi=%10.6f\n",
394  iDisc,iQuad,verLab.X(),verLab.Y(),verLab.Z(),verLab.Perp(),verLab.Phi());
395  printf("Unpack RLo2: Disc=%1d Quad=%1d x=%10.6f y=%10.6f z=%10.6f R=%10.6f phi=%10.6f\n",
396  iDisc,iQuad,Rloc2.X(),Rloc2.Y(),Rloc2.Z(),Rloc2.Perp(),Rloc2.Phi());
397  printf("Unpack DLoc: Disc=%1d Quad=%1d x=%10.6f y=%10.6f z=%10.6f R=%10.6f phi=%10.6f\n",
398  iDisc,iQuad,Dloc.X(),Dloc.Y(),Dloc.Z(),Dloc.Perp(),Dloc.Phi());
399  */
400 
401  fgt_g2t_auxil aux;
402  aux.Rlab=aux.Rloc=aux.Dloc=TVector3(0,0,0); aux.hitPtr=0; aux.iQuad=-1;// clear it
403 
404  aux.hitPtr=hitPtr;
405  aux.Rloc=Rloc;
406  aux.Dloc=Dloc;
407  aux.Rlab=Rlab+ds/2.*verLab; // set it in the middle of the track segment
408 
409  aux.iQuad=iQuad;
410  mG2tHitList[iDisc][iQuad].push_back(aux); // ID starts from 0, WMZ
411 
412  ntot++;
413 
414  //...... only QA is below .......
415 #ifdef __FGT_QA_HISTO__
416  // QA accpted hits
417  hA[3]->Fill(10+5*iDisc);
418  hA[3]->Fill(10+5*iDisc+iQuad+1);
419  Double_t de_kev=hitPtr->de*1.e6;
420  hA[0]->Fill(de_kev);
421  hA[1]->Fill(hitPtr->ds);
422  hA[2]->Fill(Rlab.z());
423  hA[4]->Fill(Rlab.x(),Rlab.y());
424  hA[6]->Fill(Rlab.Perp());
425 #endif
426  }// loop over hits
427  //LOG_INFO<<Form("Unpacking g2t FGT %d hits --> accepted %d",nhits,ntot)<<endm;
428 }
429 
430 
431 //--------------------------------------------
432 //--------------------------------------------
433 //--------------------------------------------
434 void
435 StFgtSlowSimuMaker::projectQuad2strips( Int_t iDisc, Int_t iQuad ){
436 
437  Double_t totAmp=quadDigitizationXY->Integral();
438  Double_t maxAmp=quadDigitizationXY->GetMaximum();
439  Double_t cut_2DampCutoff= maxAmp/par_2DampCutoffScale;
440 
441  //LOG_INFO<<Form("::digiQuad(iDsc=%d, iQuad=%d) totAmp=%g , maxAmp=%g(a.u.)",iQuad, iDisc,totAmp,maxAmp)<< endm;
442 
443  Int_t nPix0=0, nPix1=0;
444  Double_t sumAmp=0.,sumAmpAtten=0., sumAdcP=0., sumAdcR=0.; //for QA
445 
446  Int_t nx=quadDigitizationXY->GetNbinsX();
447  Int_t ny=quadDigitizationXY->GetNbinsY();
448  Int_t bx,by;
449  for(bx=1;bx<=nx;bx++)
450  for(by=1;by<=ny;by++) {
451  Float_t amp=quadDigitizationXY->GetBinContent(bx,by); // this is not double because histo if float
452  if (amp < cut_2DampCutoff) continue;
453  nPix0++;
454  Double_t x=quadDigitizationXY->GetXaxis()->GetBinCenter(bx); // SLOW?
455  Double_t y=quadDigitizationXY->GetYaxis()->GetBinCenter(by); // SLOW?
456  Double_t ampAtten=amp*par_overalGain;
457  if (ampAtten < cut_2DampCutoff) continue;
458  nPix1++;
459 
460  Double_t r=sqrt(x*x+y*y);
461  Double_t phi=atan2(y,x);
462  Double_t binFrac;
463 
464  Int_t iRadID=StFgtGeom::rad2LocalStripId(r,phi,&binFrac);
465  if(iRadID<0) {
466  //printf("bad iRad xy->R, x=%f y=%f r=%f phi/deg=%f iRid=%d\n",x,y,r,phi/3.1416*180.,iRadID);
467  continue;
468  }
469  //jjassert(iRadID>=0 && iRadID<720);
470 
471  Int_t iPhiID=StFgtGeom::phi2LocalStripId(r,phi,&binFrac);
472  if(iPhiID<0) {
473  //printf("bad iPhi xy->R, x=%f y=%f r=%f phi/deg=%f iPhiID=%d\n",x,y,r,phi/3.1416*180.,iPhiID);
474  continue;
475  }
476  //jjassert(iPhiID>=0 && iPhiID<720);
477 
478  //printf("x=%f y=%f r=%f phi/deg=%f iRid=%d iPhi=%d amp=%8.4f AmpAttrn=%8.4f > cut_2DampCutoff=%8.4f\n",
479  // x,y,r,phi/3.1416*180.,iRadID,iPhiID,amp,ampAtten,cut_2DampCutoff);
480 
481  Double_t adcP= par_PplaneChargeFraction *ampAtten;
482  Double_t adcR=(1.-par_PplaneChargeFraction)*ampAtten;
483  //printf(" iRad xy->R, x=%f y=%f r=%f phi/deg=%f iRid=%d strip=%d%cR%03d adc=%.2f\n",x,y,r,phi/3.1416*180.,iRadID , iDisc+1,iQuad+'A',iRadID,adcR);
484 
485  // sums are only for monitoring
486  sumAmp+=amp; sumAmpAtten+=ampAtten;
487  sumAdcP+=adcP; sumAdcR+=adcR;
488 
489  //accumulate response of individual strips
490  quadDigitizationRad->Fill(iRadID,adcR);
491  quadDigitizationPhi->Fill(iPhiID,adcP);
492 
493  //printf("DIG disc=%1d ix=%4d iy=%4d ir=%4d ip=%4d x=%8.4f y=%8.4f r=%8.4f p=%10.6f a=%8.4f %8.4f %8.4f\n",
494  // iDisc,bx,by,iRadID,iPhiID,x,y,r,phi,ampAtten,adcR,adcP);
495 
496 #ifdef __FGT_QA_HISTO__
497  // monitoring, not cleared, may be dropped out to speed up the code marginally
498  digRAll->Fill(iRadID,adcR);
499  digPAll->Fill(iPhiID,adcP);
500  digRadcAll->Fill(x,y,adcR); // for monitoring
501  digPadcAll->Fill(x,y,adcP); // for monitoring
502 #endif
503  } //...... end of loop over quadrant
504  //printf(" fgt-digi: nPix0=%d nPix1=%d, sumAmp=%g, sumAmpAtten=%g ADC: sumP=%.3g sumR=%.3g\n", nPix0,nPix1,sumAmp,sumAmpAtten,sumAdcP,sumAdcR);
505 
506 #ifdef __FGT_QA_HISTO__
507  hA[29]->Fill(sumAdcR);
508  hA[30]->Fill(sumAdcP);
509  hA[31]->Fill(sumAdcP,sumAdcR);
510 #endif
511 }
512 
513 
514 //--------------------------------------------
515 //--------------------------------------------
516 //--------------------------------------------
517 void
518 StFgtSlowSimuMaker::exportStripPlane2StEvent(TH1F *h, Int_t stripIdOffset, StFgtStripCollection *stripCollectionPtr){
519 
520  //jjassert(stripCollectionPtr);
521  //printf("write fgt strips , --> StEvent: #hits=%d on input\n",stripCollectionPtr->getNumStrips());
522 
523  Float_t *adcPtr=h->GetArray();
524  //adcPtr++; // root histo counts bins from 1 - incredible silly --> double accounting with 4 lines below... removing
525  Int_t nx=h->GetNbinsX(); //is 720
526  Int_t nSeq=0;
527  for(Int_t iId=0;iId<nx;iId++) {
528  Double_t adc=adcPtr[iId+1];
529  nSeq--;
530  if(adc >par_stripThreshAdc ) nSeq=3; // adds few strips after every fired for continuity
531  if( nSeq<=0) continue;
532  Int_t geoId=stripIdOffset+iId;
533  Int_t timebin=0;
534 
535  Int_t rdo, arm, apv, chan;
536  fgtDb->getElecCoordFromGeoId( geoId, rdo, arm, apv, chan );
537  //LOG_INFO << Form("geoId=%5d rdo=%1d arm=%1d apv=%2d ch=%3d",geoId, rdo, arm, apv, chan);
538 
539  Int_t elecId = StFgtGeom::getElectIdFromElecCoord( rdo, arm, apv, chan );
540  StFgtStrip* stripPtr = stripCollectionPtr->getStrip( elecId );
541 
542  Double_t ped=0;
543  Double_t sigPed=0;
544  Short_t stat=0;
545  if( switch_addPeds ) {
546  stat=fgtDb->getStatusFromElecCoord(rdo,arm,apv,chan);
547  //if(stat) continue; // drop bad strips -> Temp removed status check until DB fixes.
548  ped=fgtDb ->getPedestalFromGeoId( geoId);
549  sigPed=fgtDb->getPedestalSigmaFromGeoId( geoId);
550  //LOG_INFO << Form(" ped=%6.1f sig=%6.1f stat=%1d",ped,sigPed,stat);
551  }
552 
553  //LOG_INFO << " adc-ped=";
554  float sum=0;
555  double adc2;
556  for(int iTbOff=0;iTbOff<7;iTbOff++)
557  {
558  if( switch_addPeds ) {
559  adc2=adc*pulseShape[iTbOff];
560  adc2+=mRnd->Gaus(ped,sigPed);
561  if(adc2<ped-3*sigPed) adc2=ped-3*sigPed;
562  if(adc2 <0 ) adc=0;
563  if(adc2 >4095 ) adc=4095;
564  sum+=adc2-ped;
565  }
566  stripPtr->setAdc( (Short_t)(adc2), timebin+iTbOff );
567  //LOG_INFO << Form("%7.0f",adc2-ped);
568  }
569  stripPtr->setGeoId( geoId );
570  stripPtr->setElecCoords(rdo,arm,apv,chan);
571  //LOG_INFO << Form(" sum=%7.0f",sum) << endm;
572  }
573 }
574 
575 
576 
579 
580 // $Log: StFgtSlowSimuMaker.cxx,v $
581 // Revision 1.4 2012/11/08 17:16:20 akio
582 // http://www.star.bnl.gov/~akio/fgt/mc/index.php#code
583 //
584 // - get fgtDb automatically without setting by hand
585 // - default changed to do pedestal (switch_addPeds=1 in constructor)
586 // - bug fix in logic flaw when creating timebin distribution causing "flat" hit
587 // - bug fix which causes a event to take forever when there is a hit but no signal in a quadrant
588 // - bug fix for cut_2DampCutoff becoming 0 for empty quadrant digitization, causing taking forever to finish
589 // - bug fix in exportStripPlane2StEvent() which account for ROOT histo first bin is at index=1 TWICE
590 //
591 // Following 2 chages are temp fix and need to be removed one DB is updated
592 // - Overwriting par_overalgain=2 from DB by 20
593 // - Do NOT do status check (DB entry for 2012Dec15 has status=1 -> need fix in DB)
594 //
595 // Revision 1.3 2012/06/20 18:32:40 avossen
596 // setting elec ids for strips now, implemented pulse shape over 7 timebins
597 //
598 // Revision 1.2 2012/06/18 20:41:37 balewski
599 // corrected crash on attampt to save not initializaed histos
600 //
601 // Revision 1.1 2012/06/06 20:35:09 jeromel
602 // Code review closed (requested Anselm/Jan; reviewed Jonathan/Jason)
603 //
604 // Revision 1.47 2012/05/08 16:40:25 avossen
605 // prepare for review
606 //
607 // Revision 1.46 2012/04/05 19:04:10 balewski
608 // reduced smearing back to 0.035 mm
609 //
610 // Revision 1.45 2012/03/17 03:55:29 balewski
611 // *** empty log message ***
612 //
613 // Revision 1.44 2012/03/17 01:17:45 balewski
614 // *** empty log message ***
615 //
616 // Revision 1.43 2012/03/17 01:15:23 balewski
617 // wider spread of GEM signal, sigma is now 1mm
618 //
619 // Revision 1.42 2012/03/17 01:08:31 balewski
620 // works with Anselm's cluster finder
621 //
622 // Revision 1.41 2012/03/09 12:51:12 rfatemi
623 // removed references to old StFgtDb methods
624 //
625 // Revision 1.40 2012/03/07 15:23:53 sgliske
626 // StFgtStrip no longer has a type field
627 //
628 // Revision 1.39 2012/01/30 10:42:23 sgliske
629 // strip containers now contain adc values for
630 // all time bins. Also fixed bug where setType modified the timebin
631 // rather than the type.
632 //
633 // Revision 1.38 2012/01/27 14:09:34 balewski
634 // switch to new consts
635 //
636 // Revision 1.37 2012/01/26 18:41:43 balewski
637 // fixing , new constants
638 //
639 // Revision 1.36 2012/01/25 21:57:38 balewski
640 // removing printDB map
641 //
642 // Revision 1.35 2012/01/20 17:30:01 balewski
643 // *** empty log message ***
644 //
645 // Revision 1.34 2012/01/18 19:43:00 balewski
646 // better DB dump
647 //
648 // Revision 1.33 2012/01/18 17:48:32 sgliske
649 // StEvent/StFgtStrip now contains rdo/arm/apv/channel
650 //
651 // Revision 1.32 2012/01/14 01:42:19 balewski
652 // more printouts
653 //
654 // Revision 1.31 2012/01/13 21:35:05 balewski
655 // added printing of FGT -DB-map
656 //
657 // Revision 1.30 2011/12/01 23:18:59 avossen
658 // changed dir of StFgtDb
659 //
660 // Revision 1.29 2011/12/01 21:57:47 balewski
661 // revert to Anselm's version and use StFgtDb
662 //
663 // Revision 1.28 2011/12/01 19:45:54 balewski
664 // *** empty log message ***
665 //
666 // Revision 1.27 2011/12/01 00:58:00 avossen
667 // changed the use of the naive maker to use of StFgtDb, replaced geom-> with StFgtGeom::
668 //
669 // Revision 1.26 2011/11/09 19:08:01 balewski
670 // *** empty log message ***
671 //
672 // Revision 1.25 2011/11/09 17:50:26 balewski
673 // working on phi-strip cluster
674 //
675 // Revision 1.24 2011/11/08 21:43:25 balewski
676 // testing P-strips
677 //
678 // Revision 1.23 2011/11/08 03:40:37 balewski
679 // added testing of xy->phi mapping
680 //
681 // Revision 1.22 2011/11/04 17:37:55 balewski
682 // *** empty log message ***
683 //
684 // Revision 1.21 2011/11/04 17:01:35 balewski
685 // added A2C to BFC
686 //
687 // Revision 1.20 2011/11/02 20:53:07 balewski
688 // slow simu works for 6 discs, onlt R-plane
689 //
690 // Revision 1.19 2011/11/01 22:00:24 balewski
691 // using fgt-strip-collection
692 //
693 // Revision 1.18 2011/11/01 18:53:45 sgliske
694 // Added ''#if 0'' and ''#endif'' to comment out use of older FGT containers.
695 // It now compiles, but needs to be updated for FGT containers, take 2.
696 // All changes include a comment with 'sgliske'.
697 //
698 // Revision 1.17 2011/10/27 19:29:17 balewski
699 // fixed strip indexing, R-cluster works
700 //
701 // Revision 1.16 2011/10/26 19:32:36 balewski
702 // now fgt-geom is owned by fgtDb-maker
703 //
704 // Revision 1.15 2011/10/26 17:02:14 balewski
705 // get fgt event the proper way
706 //
707 // Revision 1.14 2011/10/25 18:39:55 balewski
708 // StEvent is working, muDst not yet
709 //
710 // Revision 1.13 2011/10/20 22:33:24 balewski
711 // enable fgt-sub eve - it crashed BFC
712 //
713 // Revision 1.12 2011/10/20 17:30:57 balewski
714 // *** empty log message ***
715 //
716 // Revision 1.11 2011/10/17 21:39:56 balewski
717 // added temp interface to fgt cluster finder
718 //
719 // Revision 1.10 2011/10/13 21:02:34 balewski
720 // the R-strip projection works now
721 //
722 // Revision 1.9 2011/10/12 21:15:02 balewski
723 // half way
724 //
725 // Revision 1.8 2011/10/12 18:20:38 balewski
726 // after testing of R-strip ID mapping
727 //
728 // Revision 1.7 2011/10/07 19:45:33 balewski
729 // testing strip ID
730 //
731 // Revision 1.5 2011/10/06 19:41:45 balewski
732 // cleanup
733 //
734 // Revision 1.4 2011/10/06 19:05:56 balewski
735 // Elos table is now read in from STAR DB
736 //
737 // Revision 1.3 2011/10/05 18:04:33 balewski
738 // storing of FGT in StEvent is almost working
739 //
740 // Revision 1.2 2011/09/29 21:36:17 balewski
741 // now 2D distribution of charge & fiducial cuts are workimng properly
742 //
743 // Revision 1.1 2011/09/28 20:57:37 balewski
744 // merging private code
745 //
746 // Revision 1.5 2011/04/11 19:35:38 fisyak
747 // Replace uint by UInt_t, use TMath
748 //
749 // Revision 1.4 2011/04/08 22:18:42 balewski
750 // added access to TGeo
751 //
752 // Revision 1.3 2011/04/08 19:25:45 wzhang
753 // Changed diskID assignment for Jan temporarily
754 //
755 // Revision 1.2 2011/04/08 01:14:13 balewski
756 // removed most of FGT from ver 3
757 //
758 // Revision 1.1 2011/04/07 19:31:22 balewski
759 // start
760 //
761 
762 
763 
764 
765 
virtual Int_t Finish()
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.
Definition: StMaker.cxx:634
virtual const char * GetName() const
special overload
Definition: StMaker.cxx:237
Definition: Stypes.h:42
Definition: Stypes.h:40
.... utility c-struct for g2t hits
TVector3 Rloc
hit entrance in LAB
virtual Int_t Finish()
Definition: StMaker.cxx:776
g2t_fgt_hit_st * hitPtr
entrance &amp; path in local ref frame