17 #include "FairEventHeader.h"
20 #include "FairRootManager.h"
21 #include "FairRunAna.h"
22 #include "FairRuntimeDb.h"
24 #include "TStopwatch.h"
26 #include "TClonesArray.h"
40 , fTimeOrderedWaveform(kFALSE)
58 FairRootManager* ioman = FairRootManager::Instance();
61 cout <<
"-E- PndMdtPointsToWaveform::Init: "
62 <<
"RootManager not instantiated!" << endl;
69 cout <<
"-W- PndMdtPointsToWaveform::Init: "
70 <<
"No MCTrack array!" << endl;
75 fPointArray = (TClonesArray*) ioman->GetObject(
"MdtPoint");
77 cout <<
"-W- PndMdtPointsToWaveform::Init: "
78 <<
"No MdtHit array!" << endl;
85 ioman->RegisterWriteoutBuffer(
"MdtWaveform",
fDataBuffer);
114 fFile =
new TFile(
"PndMdtPointsToWaveform.root",
"RECREATE");
115 tTree =
new TTree(
"pt",
"time-stamp diff");
130 cout <<
"-I- PndMdtPointsToWaveform: Intialization "<<(fGoodGeo ?
"successful." :
"failed.") << endl;
132 return fGoodGeo ? kSUCCESS : kERROR;
150 Double_t fEventTime = FairRootManager::Instance()->GetEventTime();
152 Int_t evtNo = FairRunAna::Instance()->GetEventHeader()->GetMCEntryNumber();
154 cout<<
"================PndMdtPointsToWaveform==============================================="<<endl;
155 cout<<
"Event No.: "<<evtNo<<
", Event Time: "<<fEventTime<<
", Load in "<<nHits<<
" PndMdtPoint."<<endl;
157 std::map<key, Int_t> fMcTrackingInfo;
162 TVector3 EntrancePosition;
163 TVector3 ExitingPosition;
169 std::map<Int_t, PndMdtWaveform* > listofWaveforms;
174 TVector3 fTubeCenter;
175 for (Int_t ip=0; ip<nPoints; ip++)
178 if(thePoint->GetEnergyLoss() == 0)
continue;
179 key _TrkandDetID(thePoint->GetTrackID(), thePoint->GetDetectorID());
181 std::map<key, Int_t>::iterator it = fMcTrackingInfo.find(_TrkandDetID);
182 if( fMcTrackingInfo.end() == it )
184 fMcTrackingInfo.insert(std::pair<key,Int_t>(_TrkandDetID, 1));
185 TrackID = thePoint->GetTrackID();
186 DetectorID = thePoint->GetDetectorID();
188 EntrancePosition = thePoint->
GetPosIn();
191 fWaveformTimeStamp = thePoint->GetTime() + fEventTime;
196 fLength = thePoint->GetLength();
200 TVector3 fNewEntrance(0,0,0);
201 TVector3 fNewExit(0,0,0);
204 if( ! (fOK1 && fOK2) ) {
205 cout <<
"PndMdtPointsToWaveform::exec_e, invliad detector index #"<<DetectorID<<endl;
208 TVector2 fexit = fNewExit.XYvector();
209 TVector2 fentr = fNewEntrance.XYvector();
210 TVector2 fvd = fexit - fentr;
214 cout<<
"================================================"<<endl;
215 cout<<
"Mod = "<<thePoint->
GetModule()<<endl;
216 cout<<
"Oct = "<<thePoint->
GetSector()<<endl
217 <<
"Entrance "<<EntrancePosition<<endl
218 <<
"Exiting "<<ExitingPosition<<endl
219 <<
"new Entrance "<<fNewEntrance<<endl
220 <<
"new Exiting "<<fNewExit<<endl;
237 std::map<Int_t, PndMdtWaveform*>::iterator mit3 = listofWaveforms.find(DetectorID);
238 if( mit3 == listofWaveforms.end())
240 listofWaveforms.insert(std::pair<Int_t, PndMdtWaveform*>(DetectorID, aWf));
242 *(mit3->second) += (*aWf);
246 Digitize(aWf, fTimeStamp, fAmplitude, kTRUE);
247 fWirpT = fTimeStamp + fEventTime;
251 std::map<Int_t, std::vector<Double_t> >::const_iterator mit = fStripSignals.begin();
252 std::map<Int_t, std::vector<Double_t> >::const_iterator mend = fStripSignals.end();
254 for(; mit != mend; ++mit){
257 Int_t lid = mit->first;
258 if(lid%2 == 0) newDetID += lid/2;
259 else newDetID -= lid/2;
264 Digitize(aSf, fTimeStamp, fAmplitude, kFALSE);
265 fStripT = fTimeStamp + fEventTime;
268 std::map<Int_t, PndMdtWaveform*>::iterator mit1 = listofWaveforms.find(newDetID);
269 if( mit1 == listofWaveforms.end())
271 listofWaveforms.insert(std::pair<Int_t, PndMdtWaveform*>(newDetID, aSf));
273 *(mit1->second) += (*aSf);
283 std::map<Int_t, PndMdtWaveform*>::iterator mit2 = listofWaveforms.begin();
284 for(; mit2 != listofWaveforms.end(); ++ mit2){
285 (*fWaveformArray)[
fWaveformArray->GetEntriesFast()] = mit2->second;
290 std::map<key, Int_t>::iterator it = fMcTrackingInfo.begin();
291 std::map<key, Int_t>::iterator end = fMcTrackingInfo.end();
292 for(; it != end; ++it){
293 cout<<
"Track #"<<it->first.TrkID<<
" contributes "<<it->second<<
" points in tube "<<it->first.DetID<<endl;
297 cout<<
"Number of produced waveforms: "<<
fWaveformArray->GetEntriesFast()<<endl;
298 cout<<
"================PndMdtPointsToWaveform==============================================="<<endl;
305 cout <<
"PndMdtPointsToWaveform, Real time " << rtime <<
" s, CPU time " << ctime <<
" s" << endl;
317 Double_t fEventTime = FairRootManager::Instance()->GetEventTime();
319 Int_t evtNo = FairRunAna::Instance()->GetEventHeader()->GetMCEntryNumber();
321 cout<<
"================PndMdtPointsToWaveform==============================================="<<endl;
322 cout<<
"Event No.: "<<evtNo<<
", Event Time: "<<fEventTime<<
", Load in "<<nHits<<
" PndMdtHit."<<endl;
323 cout<<
"Size of PndMdtWaveformWriteoutBuffer: "<<
fDataBuffer->GetNData()<<endl;
324 cout<<
"================PndMdtPointsToWaveform==============================================="<<endl;
326 std::map<key, Int_t> fMcTrackingInfo;
331 TVector3 EntrancePosition;
332 TVector3 ExitingPosition;
338 for (Int_t ip=0; ip<nPoints; ip++)
341 if(thePoint->GetEnergyLoss() == 0)
continue;
342 key _TrkandDetID(thePoint->GetTrackID(), thePoint->GetDetectorID());
343 std::map<key, Int_t>::iterator it = fMcTrackingInfo.find(_TrkandDetID);
344 if( fMcTrackingInfo.end() == it )
346 fMcTrackingInfo.insert(std::pair<key,Int_t>(_TrkandDetID, 1));
347 TrackID = thePoint->GetTrackID();
348 DetectorID = thePoint->GetDetectorID();
350 EntrancePosition = thePoint->
GetPosIn();
353 TimeStamp = thePoint->GetTime() + fEventTime;
355 TVector3 fNewEntrance(0,0,0);
356 TVector3 fNewExit(0,0,0);
359 if( ! (fOK1 && fOK2) ) {
360 cout <<
"PndMdtPointsToWaveform::exec_t, invalid detector index #"<<DetectorID<<endl;
363 TVector2 fexit = fNewExit.XYvector();
364 TVector2 fentr = fNewEntrance.XYvector();
365 TVector2 fvd = fexit - fentr;
369 cout<<
"================================================"<<endl;
370 cout<<
"Mod = "<<thePoint->
GetModule()<<endl;
371 cout<<
"Oct = "<<thePoint->
GetSector()<<endl
372 <<
"Entrance "<<EntrancePosition<<endl
373 <<
"Exiting "<<ExitingPosition<<endl
374 <<
"new Entrance "<<fNewEntrance<<endl
375 <<
"new Exiting "<<fNewExit<<endl;
395 std::map<Int_t, std::vector<Double_t> >::const_iterator mit = fStripSignals.begin();
396 std::map<Int_t, std::vector<Double_t> >::const_iterator mend = fStripSignals.end();
401 Int_t lid = mit->first;
402 if(lid%2 == 0) detID += lid/2;
416 std::map<key, Int_t>::iterator it = fMcTrackingInfo.begin();
417 std::map<key, Int_t>::iterator end = fMcTrackingInfo.end();
418 for(; it != end; ++it){
419 cout<<
"Track #"<<it->first.TrkID<<
" contributes "<<it->second<<
" points in tube "<<it->first.DetID<<endl;
427 cout <<
"PndMdtPointsToWaveform, Real time " << rtime <<
" s, CPU time " << ctime <<
" s" << endl;
434 FairRun*
run = FairRun::Instance();
435 if ( ! run ) Fatal(
"SetParContainers",
"No analysis run");
437 FairRuntimeDb* db = run->GetRuntimeDb();
438 if ( ! db ) Fatal(
"SetParContainers",
"No runtime database");
456 std::cout<<
"==================================================="<<std::endl;
457 std::cout<<
"PndMdtPointsToWaveform::FinishTask"<<std::endl;
458 std::cout<<
"***************************************************"<<std::endl;
461 std::cout<<
"***************************************************"<<std::endl;
469 const Double_t fWireNoiseSigma = 0.05;
470 const Double_t fStripNoiseSigma = 0.01;
471 const Double_t fSamplingInterval = 10.;
479 if(isWire) fThreshold = 5.*fWireNoiseSigma;
480 else fThreshold = 5.*fStripNoiseSigma;
482 const std::vector<Double_t>& fSignalData = theWf->
GetSignal();
483 for(
size_t is=0;
is < fSignalData.size(); ++
is){
485 if(
TMath::Abs(fSignalData[is]) > fThreshold && NotFound) {
486 time = is*fSamplingInterval;
495 Int_t abspdg = abs(pdg);
496 if(abspdg == 11)
return 0;
497 else if(abspdg == 211)
return 2;
498 else if(abspdg == 13)
return 1;
499 else if(abspdg == 2212)
return 4;
500 else if(abspdg == 321)
return 3;
void UseGaussianAmp(Bool_t swith)
Bool_t MasterToLocal(Int_t iDetId, TVector3 &master, TVector3 &local)
TVector3 GetPosOut() const
Double_t val[nBoxes][nFEBox]
void SetNoiseWidth(Double_t anode, Double_t strip)
void SetPersistency(Bool_t val=kTRUE)
Bool_t MapWireToStrip(Int_t iDetId, const TVector3 &fEntryPos, Int_t &fStripDetID)
Short_t GetSector() const
void UsePlot(Bool_t swith=kTRUE)
void AddSensor(TString _v)
TVector3 GetPosIn() const
void SetVerbose(Int_t _v)
void UseDetailedSim(Bool_t swith=kTRUE)
static PndMdtIGeometry * Instance()
PndMdtParamDigi & SetParams(Int_t ptlType, TVector3 iniP, TVector3 iniPos, TVector3 finalPos, Double_t stripLen=100.)
void Compute(Bool_t useConvolution=kTRUE)
void UseNoise(Bool_t swith)
const std::vector< Double_t > & GetWireSignal() const
TVector3 GetMomIn() const
const std::map< Int_t, std::vector< Double_t > > & GetStripSignals() const
void SetOptimization(Int_t val)
Short_t GetModule() const