12 #include "FairRootManager.h"
13 #include "FairRunAna.h"
14 #include "FairRuntimeDb.h"
18 #include "TClonesArray.h"
19 #include "TObjArray.h"
21 #include "TGeoManager.h"
44 using std::setprecision;
57 fSaveOutsideHits(kFALSE),
58 fHitOutsideArray(NULL),
59 fRealisticResponse(kFALSE),
63 fRand(new TRandom2()),
65 fTimeOrderedDigi(kFALSE)
82 fSaveOutsideHits(kFALSE),
83 fHitOutsideArray(NULL),
84 fRealisticResponse(kFALSE),
88 fRand(new TRandom2()),
90 fTimeOrderedDigi(kFALSE)
107 fSaveOutsideHits(kFALSE),
108 fHitOutsideArray(NULL),
109 fRealisticResponse(kFALSE),
113 fRand(new TRandom2()),
115 fTimeOrderedDigi(kFALSE)
161 Double_t EventTime = FairRootManager::Instance()->GetEventTime();
167 cout <<
"---PndGemDigitize---> Event " <<
fTNofEvents
168 <<
" at " << EventTime <<
" ns"
169 <<
" has " <<
fDigis->GetEntriesFast() <<
" digis made from " <<
fPoints->GetEntriesFast() <<
" points" << endl;
172 for ( Int_t idigi = 0 ; idigi <
fDigis->GetEntriesFast() ; idigi++ ) {
174 adigi->SetTimeStamp(adigi->GetTimeStamp()+EventTime);
176 adigi->GetTimeStamp(),
177 adigi->GetTimeStamp()+100.);
187 if (
fVerbose > 0 ) cout <<
"-I- PndGemDigitize::DigitizeEvent()" << endl;
191 Int_t nofHitsOutside = 0;
192 Int_t nofPoints =
fPoints->GetEntriesFast();
204 for ( Int_t iPoint = 0 ; iPoint < nofPoints ; iPoint++ ) {
207 Double_t posIn[3] = {0.5*(currentPndGemMCPoint->GetX()+currentPndGemMCPoint->
GetXOut()),
208 0.5*(currentPndGemMCPoint->GetY()+currentPndGemMCPoint->
GetYOut()),
209 currentPndGemMCPoint->GetZ()};
211 Int_t sensorId = currentPndGemMCPoint->
GetSensorId();
226 cout <<
" -E- " << GetName() <<
":Exec() There is no sensor: \""
227 << nodeName.Data() <<
"\"." << endl;
234 curNode->MasterToLocal(posIn,locPosIn);
243 Int_t channelNumber = sensor->
GetChannel(locPosIn[0],locPosIn[1],0);
247 if ( channelNumber == -1 ) {
250 currentPndGemMCPoint->Position(pos);
251 TVector3 dposLocal(0.,0.,0.);
256 new ((*fHitOutsideArray)[nofHitsOutside])
PndGemHit(sensorDetId,
257 pos,dposLocal,iPoint,currentPndGemMCPoint->GetEnergyLoss(),1);
265 channelNumber = sensor->
GetChannel(locPosIn[0],locPosIn[1],1);
266 if ( channelNumber == -1 )
continue;
276 if (
fVerbose > 0 ) cout <<
"-I- PndGemDigitize::DigitizeRealisticEvent()" << endl;
286 cout <<
" showerSigma=" << showerSigma
287 <<
" sigMult=" << sigMult
294 Int_t nofPoints =
fPoints->GetEntriesFast();
304 cout <<
"GemDigiPar has "
311 for ( Int_t iPoint = 0 ; iPoint < nofPoints ; iPoint++ ) {
314 Double_t posIn[3] = {currentPndGemMCPoint->GetX(),
315 currentPndGemMCPoint->GetY(),
316 currentPndGemMCPoint->GetZ()};
318 Int_t sensorId = currentPndGemMCPoint->
GetSensorId();
321 cout << iPoint <<
" : "
322 << currentPndGemMCPoint->GetX() <<
" "
323 << currentPndGemMCPoint->GetY() <<
" "
324 << currentPndGemMCPoint->GetZ() <<
" in sensor "
333 cout <<
"got nodeName = \"" << nodeName.Data() <<
"\"" << endl;
347 cout <<
" -E- " << GetName() <<
":Exec() There is no sensor: \""
348 << nodeName.Data() <<
"\"." << endl;
355 curNode->MasterToLocal(posIn,locPosIn);
358 cout <<
"position: " << posIn[0] <<
" " << posIn[1] <<
" " << posIn[2] << endl;
359 cout <<
" transf to " << locPosIn[0] <<
" " << locPosIn[1] <<
" " << locPosIn[2] << endl;
374 SimulateGaussianResponse(sensor,0,currentPndGemMCPoint,showerSigma,sigMult*currentPndGemMCPoint->GetEnergyLoss(),iPoint);
383 SimulateGaussianResponse(sensor,1,currentPndGemMCPoint,showerSigma,sigMult*currentPndGemMCPoint->GetEnergyLoss(),iPoint);
391 Double_t posIn [3] = {gemPoint->GetX(),
408 curNode->MasterToLocal(posIn ,locPosIn );
409 curNode->MasterToLocal(posOut,locPosOut);
421 Int_t nofBBB = 1000+10*sensor->
GetDistance(side,minChan,maxChan);
426 for ( Int_t ico = 0 ; ico < 4 ; ico++ ) deltaPos[ico] = (locPosOut[ico] - locPosIn[ico])/((
Double_t)(nofBBB));
428 Int_t chanNr = sensor->
GetChannel(locPosIn[0],locPosIn[1],side);
430 Double_t time = gemPoint->GetTime();
435 for ( Int_t ibbb = 0 ; ibbb < nofBBB ; ibbb++ ) {
440 chanNr = sensor->
GetChannel2(xloc,yloc,side,feeDist);
441 time = gemPoint->GetTime()+
fRand->Gaus(5,0.5)+
fRand->Gaus(feeDist/30.,0.5);
443 if ( chanNr == -1 )
continue;
452 Int_t channelNumber = (Int_t)channelInd;
458 Int_t leftChan = channelNumber;
460 for ( Int_t ibin = 0 ; ibin < 50 ; ibin++ ) {
461 Double_t leftASig = leftTBin*showerStrength/showerSigma;
462 if ( leftTBin > leftSide ) {
463 leftASig = leftSide*showerStrength/showerSigma;
469 thisASig += leftASig;
473 leftSide = leftSide - leftTBin;
474 leftTBin = stripWidth;
480 Int_t rightChan = channelNumber;
482 for ( Int_t ibin = 0 ; ibin < 50 ; ibin++ ) {
483 Double_t rightASig = rightTBin*showerStrength/showerSigma;
484 if ( rightTBin > rightSide ) {
485 rightASig = rightSide*showerStrength/showerSigma;
491 thisASig += rightASig;
495 rightSide = rightSide - rightTBin;
496 rightTBin = stripWidth;
505 Int_t digiDetId = sensorDetId |
kGemDigi << 21 | sensorSide << 5;
507 pair<Int_t, Int_t>
a (digiDetId, channelNumber);
513 new ((*fDigis)[
fNDigis])
PndGemDigi(digiDetId, channelNumber, iPoint, signalHeight, signalTime);
534 Int_t nofDigis =
fDigis->GetEntriesFast();
535 for ( Int_t idigi = 0 ; idigi < nofDigis ; idigi++ ) {
539 Int_t digiSide = digiToDraw->
GetSide();
542 cout <<
"HAVE digi " << idigi <<
" at " << digiStationNr <<
"." << digiSensorNr <<
"." << digiSide <<
"." << channelNumber <<
" ( " << digiToDraw->
GetDetectorId() <<
" ) with signal = " << digiToDraw->
GetCharge() << endl;
552 FairRun*
run = FairRun::Instance();
553 if ( ! run ) Fatal(
"SetParContainers",
"No analysis run");
555 FairRuntimeDb* db = run->GetRuntimeDb();
556 if ( ! db ) Fatal(
"SetParContainers",
"No runtime database");
569 FairRootManager* ioman = FairRootManager::Instance();
571 if ( ! ioman ) Fatal(
"Init",
"No FairRootManager");
572 fPoints = (TClonesArray*) ioman->GetObject(
"GEMPoint");
576 ioman->Register(
"GEMOutsideHit",
"PndGem Hits in inactive region",
581 fDigis =
new TClonesArray(
"PndGemDigi",10000);
582 ioman->Register(
"GEMDigiNormal",
"Digital response in GEM",
fDigis, kFALSE);
589 cout <<
"-I- " << fName.Data() <<
"::Init(). There are " <<
fDigiPar->
GetNStations() <<
" GEM stations." << endl;
590 cout <<
"-I- " << fName.Data() <<
"::Init(). Initialization succesfull." << endl;
627 cout <<
"-------------------- " << fName.Data() <<
" : Summary ------------------------" << endl;
628 cout <<
" Events: " << setw(10) <<
fTNofEvents << endl;
634 cout <<
"---------------------------------------------------------------------" << endl;
virtual InitStatus Init()
void SimulateGaussianResponse(PndGemSensor *sensor, Int_t side, PndGemMCPoint *gemPoint, Double_t showerSigma, Double_t showerStrength, Int_t iPoint)
void ActivateChannel(Int_t sensorDetId, Int_t sensorSide, Int_t channelNumber, Double_t signalHeight, Double_t signalTime, Int_t iPoint)
Int_t GetStationNr() const
void SetPersistency(Bool_t val=kTRUE)
Digitization Parameter Class for GEM part.
Int_t GetDetectorId() const
TGeoManager * gGeoManager
Double_t GetStripOrientation(Double_t x, Double_t y, Int_t iSide)
Int_t GetSensorNr() const
virtual void Exec(Option_t *opt)
virtual InitStatus ReInit()
PndGemSensor * GetSensor(Int_t stationNr, Int_t sensorNr)
void AddCharge(Double_t iCharge)
Int_t GetSensorId() const
Int_t GetChannel(Double_t x, Double_t y, Int_t iSide)
TString GetNodeName(Int_t sensorId)
Double_t GetDistance(Int_t iSide, Double_t chan1, Double_t chan2)
Int_t GetChannel2(Double_t x, Double_t y, Int_t iSide, Double_t &feeDist)
Double_t GetChannelNr() const
PndGemDigiWriteoutBuffer * fDataBuffer
Int_t GetStationNr(Int_t sensorId)
virtual void SetParContainers()
TClonesArray * fHitOutsideArray
virtual ~PndGemDigitize()
Double_t GetCharge() const
Int_t GetDetectorId() const
TClonesArray * fDigiMatches
void DigitizeRealisticEvent()
std::map< std::pair< Int_t, Int_t >, Int_t > fChannelMap
void SimulateRectangularResponse(Int_t sensorDetId, Int_t side, Double_t channelInd, Double_t stripWidth, Double_t showerSigma, Double_t showerStrength, Int_t iPoint)
Bool_t fRealisticResponse