59 #include <StMessMgr.h>
60 #include "StPmdSimulatorMaker.h"
62 #include "StPhmdCollection.h"
63 #include "StPhmdClusterCollection.h"
64 #include "StPhmdDetector.h"
65 #include "StPhmdHit.h"
66 #include "StPhmdModule.h"
68 #include "StPmdUtil/StPmdCollection.h"
69 #include "StPmdUtil/StPmdDetector.h"
70 #include "StPmdUtil/StPmdHit.h"
71 #include "StPmdUtil/StPmdModule.h"
72 #include "StPmdUtil/StPmdMapUtil.h"
73 #include "tables/St_g2t_pmd_hit_Table.h"
74 #include "tables/St_g2t_track_Table.h"
75 #include <TTableSorter.h>
77 #include "StEvent/StEvent.h"
78 #include "StEvent/StEventTypes.h"
85 St_g2t_pmd_hit *g2t_pmd_hit;
98 gMessMgr->SetLimit(
"StPmdSimulator",100);
101 StPmdSimulatorMaker::~StPmdSimulatorMaker()
110 return StMaker::Init();
112 void StPmdSimulatorMaker::bookHistograms()
114 m_pmdEdep2D =
new TH2F(
"PMDEdep2D" ,
"PMD Edep (2D)",150,-150.,150.,150,-150.,150.);
115 m_cpvEdep2D =
new TH2F(
"CPVEdep2D" ,
"CPV Edep (2D)",150,-150.,150.,150,-150.,150.);
117 mEdepPmd =
new TH1F(
"PmdEdep" ,
"Edep for PMD",1000,0.,500.);
118 mEdepPmd_part =
new TH1F(
"PmdEdep_part" ,
"Edep Part for PMD",1000,0.,1000.);
119 mPmdAdc =
new TH1F(
"pmdadc" ,
"ADC for PMD",1000, 0.,1000.);
120 mHitPmd =
new TH1F(
"PMDHit" ,
"Hits for PMD",9000, -0.5,8999.5);
122 mEdepCpv =
new TH1F(
"CpvEdep" ,
"Edep for CPV",400,0.,200.);
123 mEdepCpv_part =
new TH1F(
"CpvEdep_part" ,
"Edep Part for CPV",200,0.,200.);
124 mCpvAdc =
new TH1F(
"cpvadc" ,
"ADC for CPV",1000, 0.,1000.);
125 mHitCpv =
new TH1F(
"CpvHit" ,
"Hits for CPV",5000, -0.5,4999.5);
127 m_pmdsuper =
new TH1F(
"PmdSuper" ,
"Super for PMD",12,0.5,12.5);
128 m_pmdrow =
new TH2F(
"PMD_SupervsRow" ,
"Pmd super vs row",12,0.5,12.5,100,0.5,100.5);
129 m_pmdcol =
new TH2F(
"PMD_SupervsCol" ,
"Pmd super vs col",12,0.5,12.5,100,0.5,100.5);
131 m_cpvsuper =
new TH1F(
"CpvSuper" ,
"Super for CPV",12,0.5,12.5);
132 m_cpvrow =
new TH2F(
"CPV_SupervsRow" ,
"Cpv super vs row",12,0.5,12.5,100,0.5,100.5);
133 m_cpvcol =
new TH2F(
"CPV_SupervsCol" ,
"Cpv super vs col",12,0.5,12.5,100,0.5,100.5);
141 geaIn = GetDataSet(
"geant");
143 geaIn = GetDataSet(
"event/geant/Event");
145 gMessMgr->Error()<<
"Geant Data didn't find in event/geant/Event and geant directories"<<endm;
157 g2t_pmd_hit = (St_g2t_pmd_hit *) geaIn->
Find(
"g2t_pmd_hit");
160 if ( g2t_pmd_hit && g2t_pmd_hit->GetTableSize()>0)
164 if(phit!=
kStOK){cout<<
"problem in Hit formation"<<endl;
return kStWarn;}
166 else gMessMgr->Warning()<<
167 "StPmdSimulatorMaker::makePmd=>table g2t_PMD_hit isn't found in dataset or size is 0 "<<
168 geaIn->GetName()<<endm;
183 g2t_pmd_hit_st *
hit = g2t_pmd_hit->GetTable();
184 Int_t nhits = g2t_pmd_hit->GetNRows();
192 for(Int_t ihit=0; ihit<nhits; ihit++,hit++) {
193 Int_t sector=0,super=0,subdet=0,row=0,col=0;
198 Int_t decode=
Decode_VolId(hit->volume_id,sector,super,subdet,row,col);
201 mpmdgeom->
NModule(Int_t(sector),Int_t(super),gsuper);
213 phit->setSubDetector(Int_t(subdet));
214 phit->setRow(Int_t(row));
215 phit->setColumn(Int_t(col));
216 phit->setEdep((hit->de)*1000000.);
250 Float_t newEdep=hitmatched->
Edep()+(hit->de)*1000000.;
251 hitmatched->setEdep(newEdep);
263 m_pmdrow->Fill(Float_t(gsuper),Float_t(row));
264 m_pmdcol->Fill(Float_t(gsuper),Float_t(col));
277 Float_t newEdep=hitmatched->
Edep()+(hit->de)*1000000.;
278 hitmatched->setEdep(newEdep);
287 Float_t xCPV,yCPV,etaCPV,phiCPV;
288 mpmdgeom->
DetCell_xy(gsuper,Int_t(row),Int_t(col),xCPV,yCPV,etaCPV,phiCPV);
292 m_cpvrow->Fill(Float_t(gsuper),Float_t(row));
293 m_cpvcol->Fill(Float_t(gsuper),Float_t(col));
301 for(Int_t ii=1;ii<13;ii++)
308 for(Int_t ii=1;ii<13;ii++)
314 for(Int_t ii=1;ii<13;ii++)
335 Int_t temp0=vol%1000000;
336 Int_t temp1=temp0%100000;
337 Int_t temp2=temp1%10000;
338 Int_t temp3=temp2%100;
352 Int_t xpad,ypad,super;
355 TIter next(pmod->Hits());
358 for(Int_t im=0; im<nmh; im++)
364 xpad=spmcl->Column();
365 super = spmcl->Gsuper();
366 if(phit->
Row()==ypad && phit->
Column()==xpad && phit->
Gsuper() == super)
return spmcl;
377 Float_t edep_part = 0.;
379 TIter next(pmd_mod->Hits());
381 for(Int_t im=0; im<nmh1; im++)
386 Int_t gsuper = spmcl1->Gsuper();
387 Int_t row=spmcl1->Row();
388 Int_t col=spmcl1->Column();
389 Float_t edep=spmcl1->Edep();
390 Int_t adc=spmcl1->Adc();
393 if(edep>0.) edep_part = edep_part+edep;
395 Float_t xPMD,yPMD,etaPMD,phiPMD;
396 mpmdgeom->
DetCell_xy(gsuper,Int_t(row),Int_t(col),xPMD,yPMD,etaPMD,phiPMD);
399 m_pmdrow->Fill(Float_t(gsuper),Float_t(row));
400 m_pmdcol->Fill(Float_t(gsuper),Float_t(col));
413 TIter next(cpv_mod->Hits());
416 for(Int_t im=0; im<nmh2; im++)
421 Int_t gsuper = spmcl2->Gsuper();
422 Int_t row=spmcl2->Row();
423 Int_t col=spmcl2->Column();
424 Float_t edep=spmcl2->Edep();
426 Float_t xCPV,yCPV,etaCPV,phiCPV;
427 mpmdgeom->
DetCell_xy(gsuper,Int_t(row),Int_t(col),xCPV,yCPV,etaCPV,phiCPV);
430 if(edep>0.4) edep_part = edep_part+edep;
432 mpmdgeom->
DetCell_xy(gsuper,Int_t(row),Int_t(col),xCPV,yCPV,etaCPV,phiCPV);
436 m_cpvrow->Fill(Float_t(gsuper),Float_t(row));
437 m_cpvcol->Fill(Float_t(gsuper),Float_t(col));
458 for(Int_t
id=1;
id<13;
id++)
469 TIter next(pmd_mod->Hits());
471 for(Int_t im=0; im<nmh1; im++)
476 Int_t gsuper=spmcl1->Gsuper();
477 Int_t col=spmcl1->Column();
478 Int_t row=spmcl1->Row();
479 Float_t edep=spmcl1->Edep();
480 Int_t adc=spmcl1->Adc();
483 phit->setSuperModule(Int_t(gsuper-1));
484 phit->setSubDetector(Int_t(subdet));
485 phit->setRow(Int_t(row));
486 phit->setColumn(Int_t(col));
487 phit->setEnergy(edep);
489 evtdet0->addHit(phit);
500 TIter next(cpv_mod->Hits());
502 for(Int_t im=0; im<nmh2; im++)
507 Int_t gsuper=spmcl2->Gsuper();
508 Int_t col=spmcl2->Column();
509 Int_t row=spmcl2->Row();
510 Float_t edep=spmcl2->Edep();
511 Int_t adc=spmcl2->Adc();
514 phit->setSuperModule(Int_t(gsuper-1));
515 phit->setSubDetector(Int_t(subdet));
516 phit->setRow(Int_t(row));
517 phit->setColumn(Int_t(col));
518 phit->setEnergy(edep);
520 evtdet1->addHit(phit);
529 void StPmdSimulatorMaker::FinalEdep(
StPmdDetector* pdet,Int_t
id)
536 TIter next(mod->Hits());
538 for(Int_t im=0; im<nmh; im++)
546 Float_t rawedep=spmcl->Edep();
547 Float_t keVedep=rawedep;
548 keV_ADC(keVedep,rawadc);
549 if(mResFlag) ADC_Readout(rawadc,ADC);
550 else ADC = (int)rawadc;
561 Float_t StPmdSimulatorMaker::keV_ADC(Float_t edep, Float_t& adc)
563 adc=mlcon0 + mlcon1*edep + mlcon2*pow(edep,2);
567 Float_t StPmdSimulatorMaker::ADC_Readout(Float_t adc,Int_t& ADC)
569 Float_t reso_percent=0., reso=0.;
570 reso_percent=mpcon0 + mpcon1*adc + mpcon2*pow(adc,2);
571 reso=(reso_percent*100.)/adc;
573 Float_t adcprime=gRandom->Gaus(adc,reso);
574 if(adcprime<0)adcprime=0;
Int_t GetPmd()
Getting GEANT tables from input file.
bool addHit(StPmdHit *)
no of modules
Int_t fillStEvent(StPmdDetector *, StPmdDetector *)
Int_t module_hit(Int_t)
module number
StPmdDetector * detector(Int_t)
destructor
TH2F * m_cpvrow
Pmd super vs row.
Int_t Decode_VolId(Int_t &, Int_t &, Int_t &, Int_t &, Int_t &, Int_t &)
Making Pmd hits after slow simulation.
void FillHistograms(StPmdDetector *, StPmdDetector *, Int_t)
Booking histograms.
StPhmdCollection * mevtPmdCollection
Pmd and CPV collections.
TH1F * m_cpvsuper
total no of Supermodules for PMD
virtual void AddData(TDataSet *data, const char *dir=".data")
User methods.
TH2F * m_pmdcol
Cpv super vs row.
TH1F * mHitPmd
total ADC on PMD
TH1F * mCpvAdc
Total edep on CPV.
TH1F * mEdepPmd
2D-Edep Display of Cpv
virtual void Browse(TBrowser *b)
Browse this dataset (called by TBrowser).
void Sim2Detmap(Int_t &, Int_t &, Int_t &)
function for convering supermodule,row,col (from GEANT) to supermodule,row,col as in hardware...
TH2F * m_pmdEdep2D
Pmd and CPV collections for Stevent.
void DetCell_xy(Int_t, Float_t, Float_t, Float_t &, Float_t &, Float_t &, Float_t &)
function for converting supermodule,row,col to x,y,eta,phi after conversionfrom 17 to 12 supermodule ...
Int_t Row() const
function for subdetector
Int_t Column() const
function for row
TH2F * m_cpvEdep2D
2D-Edep Display of Pmd
TH1F * m_pmdsuper
total no of hits on Cpv
void Browse(TBrowser *b)
Readout resolution is applied when Flag = 1.
virtual Int_t Init()
A destructor.
TH2F * m_cpvcol
Pmd super vs col.
Int_t makePmdHits()
Getting Pmdhits from geant.
Int_t NModule(Int_t, Int_t, Int_t &)
A destructor.
void setGsuper(Int_t)
Cell status (chain selection based)
Int_t Gsuper() const
A destructor.
TH1F * mEdepPmd_part
cell edep on Pmd
TH1F * mPmdAdc
total edep on Pmd
TH1F * mEdepCpv
total no of hits on Pmd
StPmdHit * Exist(StPmdHit *, StPmdDetector *, Int_t)
decoding
Float_t Edep() const
function for col
StPmdModule * module(unsigned int)
number of hits
TH1F * mEdepCpv_part
cell edep on CPV
virtual TDataSet * Find(const char *path) const
TH2F * m_pmdrow
total no of Supermodules for CPV
TH1F * mHitCpv
Total ADC on CPV.