FairRoot/PandaRoot
Public Member Functions | Private Member Functions | Private Attributes | List of all members
PndGemDetector Class Reference

#include <PndGemDetector.h>

Inheritance diagram for PndGemDetector:

Public Member Functions

 PndGemDetector ()
 
 PndGemDetector (const char *name, Bool_t active)
 
virtual ~PndGemDetector ()
 
virtual void Initialize ()
 
virtual Bool_t ProcessHits (FairVolume *vol=0)
 
virtual void EndOfEvent ()
 
virtual void FinishRun ()
 
virtual void Register ()
 
virtual TClonesArray * GetCollection (Int_t iColl) const
 
virtual void Print () const
 
virtual void Reset ()
 
virtual void CopyClones (TClonesArray *cl1, TClonesArray *cl2, Int_t offset)
 
virtual void ConstructGeometry ()
 
void MisalignDetector ()
 
void SetExclusiveSensorType (const TString sens)
 
void SetRadDamOption (bool val)
 
bool GetRadDamOption ()
 

Private Member Functions

Int_t GetSensorId (TString detName)
 
bool CheckIfSensitive (std::string name)
 
PndGemMCPointAddHit (Int_t trackID, Int_t detID, Int_t sensID, TVector3 posIn, TVector3 posOut, TVector3 momIn, TVector3 momOut, Double_t time, Double_t length, Double_t eLoss)
 
void ResetParameters ()
 
 ClassDef (PndGemDetector, 5)
 

Private Attributes

Int_t fTrackID
 
Int_t fVolumeID
 track index More...
 
TLorentzVector fPosIn
 Det id. More...
 
TLorentzVector fPosOut
 entry position in global frame More...
 
TLorentzVector fMomIn
 exit position in global frame More...
 
TLorentzVector fMomOut
 momentum More...
 
Double32_t fTime
 momentum More...
 
Double32_t fLength
 time More...
 
Double32_t fELoss
 length More...
 
Int_t fPosIndex
 energy loss More...
 
TClonesArray * fPndGemCollection
 
bool fUseRadDamOption
 Hit collection. More...
 
std::vector< std::string > fListOfSensitives
 enables the detection of neutral particles More...
 

Detailed Description

Definition at line 30 of file PndGemDetector.h.

Constructor & Destructor Documentation

PndGemDetector::PndGemDetector ( )

Default constructor

Definition at line 46 of file PndGemDetector.cxx.

References fListOfSensitives, fPndGemCollection, and fPosIndex.

46  : fUseRadDamOption(false) {
47  fPndGemCollection = new TClonesArray("PndGemMCPoint");
48  fPosIndex = 0;
49  fListOfSensitives.push_back("Sensor");
50  if (fVerboseLevel>0) {
51  std::cout<<"-I- PndGemDetector: fListOfSensitives contains:";
52  for(size_t k=0;k<fListOfSensitives.size();k++)
53  std::cout<<"\n\t"<<fListOfSensitives[k];
54  std::cout<<std::endl;
55  }
56 }
std::vector< std::string > fListOfSensitives
enables the detection of neutral particles
bool fUseRadDamOption
Hit collection.
TClonesArray * fPndGemCollection
Int_t fPosIndex
energy loss
PndGemDetector::PndGemDetector ( const char *  name,
Bool_t  active 
)

Standard constructor.

Parameters
namedetetcor name
activesensitivity flag

Definition at line 62 of file PndGemDetector.cxx.

References fListOfSensitives, fPndGemCollection, and fPosIndex.

63  : FairDetector(name, active), fUseRadDamOption(false) {
64  fPndGemCollection = new TClonesArray("PndGemMCPoint");
65  fPosIndex = 0;
66  fListOfSensitives.push_back("Sensor");
67  if (fVerboseLevel>0) {
68  std::cout<<"- I - PndGemDetector: fListOfSensitives contains:";
69  for(size_t k=0;k<fListOfSensitives.size();k++)
70  std::cout<<"\n\t"<<fListOfSensitives[k];
71  std::cout<<std::endl;
72  }
73 }
std::vector< std::string > fListOfSensitives
enables the detection of neutral particles
bool fUseRadDamOption
Hit collection.
TClonesArray * fPndGemCollection
TString name
Int_t fPosIndex
energy loss
PndGemDetector::~PndGemDetector ( )
virtual

Destructor

Definition at line 80 of file PndGemDetector.cxx.

References fPndGemCollection.

81 {
83  {
84  fPndGemCollection->Delete();
85  delete fPndGemCollection;
86  }
87 // delete fGeoH;
88 }
TClonesArray * fPndGemCollection

Member Function Documentation

PndGemMCPoint * PndGemDetector::AddHit ( Int_t  trackID,
Int_t  detID,
Int_t  sensID,
TVector3  posIn,
TVector3  posOut,
TVector3  momIn,
TVector3  momOut,
Double_t  time,
Double_t  length,
Double_t  eLoss 
)
private

Private method AddHit

Adds a PndGemMCPoint to the HitCollection

Definition at line 422 of file PndGemDetector.cxx.

References fPndGemCollection.

Referenced by ProcessHits().

425 {
426  TClonesArray&
427  clref = *fPndGemCollection;
428 
429  Int_t
430  size = clref.GetEntriesFast();
431 
432  if (fVerboseLevel >= 2)
433  std::cout << "-I- PndGemDetector: Adding Point at (" << posIn.X() << ", " << posIn.Y()
434  << ", " << posIn.Z() << ") cm, (" << posOut.X() << ", " << posOut.Y()
435  << ", " << posOut.Z() << ") cm, sensor " << sensID << " " << detID << ", track "
436  << trackID << ", energy loss " << eLoss*1e06 << " keV" << std::endl;
437 
438  return new(clref[size]) PndGemMCPoint(trackID, detID, sensID, posIn, posOut,
439  momIn, momOut, time, length, eLoss);
440 }
TClonesArray * fPndGemCollection
bool PndGemDetector::CheckIfSensitive ( std::string  name)
private

Definition at line 329 of file PndGemDetector.cxx.

References fListOfSensitives, and i.

330 {
331  for (size_t i = 0; i < fListOfSensitives.size(); i++){
332  if (name.find(fListOfSensitives[i]) != std::string::npos)
333  return true;
334  }
335  return false;
336 }
std::vector< std::string > fListOfSensitives
enables the detection of neutral particles
Int_t i
Definition: run_full.C:25
TString name
PndGemDetector::ClassDef ( PndGemDetector  ,
 
)
private
void PndGemDetector::ConstructGeometry ( )
virtual

Virtual method Construct geometry

Constructs the PndGemDetector geometry

Definition at line 259 of file PndGemDetector.cxx.

References TString.

260 {
261  TString fileName=GetGeometryFileName();
262 // if(fileName.EndsWith(".geo")){
263 // ConstructASCIIGeometry();
264 // }else
265  if(fileName.EndsWith(".root")){
266  ConstructRootGeometry();
267  }else{
268  std::cout<< "Geometry format not supported " <<std::endl;
269  }
270 }
void PndGemDetector::CopyClones ( TClonesArray *  cl1,
TClonesArray *  cl2,
Int_t  offset 
)
virtual

Virtual method CopyClones

Copies the hit collection with a given track index offset

Parameters
cl1Origin
cl2Target
offsetIndex offset

Definition at line 232 of file PndGemDetector.cxx.

References fPosIndex, i, and offset().

233 {
234  Int_t
235  nEntries = cl1->GetEntriesFast();
236 
237  std::cout << "-I- PndGemDetector: " << nEntries << " entries to add." << std::endl;
238 
239  TClonesArray& clref = *cl2;
240 
242  *oldpoint = NULL;
243  for (Int_t i=0; i<nEntries; i++)
244  {
245  oldpoint = (PndGemMCPoint*) cl1->At(i);
246 
247  Int_t
248  index = oldpoint->GetTrackID() + offset;
249 
250  oldpoint->SetTrackID(index);
251  new (clref[fPosIndex]) PndGemMCPoint(*oldpoint);
252  fPosIndex++;
253  }
254  std::cout << "-I- PndGemDetector: " << cl2->GetEntriesFast() << " merged entries."
255  << std::endl;
256 }
Int_t i
Definition: run_full.C:25
TVector3 offset(2, 0, 0)
Int_t fPosIndex
energy loss
void PndGemDetector::EndOfEvent ( )
virtual

Virtual method EndOfEvent

If verbosity level is set, Print hit collection at the end of the event and resets it afterwards.

Definition at line 169 of file PndGemDetector.cxx.

References fPndGemCollection, fPosIndex, and Print().

170 {
171  if (fVerboseLevel)
172  Print();
173 
174  fPndGemCollection->Delete();
175  fPosIndex = 0;
176 }
virtual void Print() const
TClonesArray * fPndGemCollection
Int_t fPosIndex
energy loss
void PndGemDetector::FinishRun ( )
virtual

Definition at line 179 of file PndGemDetector.cxx.

180 {
181 
182 }
TClonesArray * PndGemDetector::GetCollection ( Int_t  iColl) const
virtual

Accessor to the hit collection

Definition at line 194 of file PndGemDetector.cxx.

References fPndGemCollection.

195 {
196  if (iColl == 0)
197  return fPndGemCollection;
198  else
199  return NULL;
200 }
TClonesArray * fPndGemCollection
bool PndGemDetector::GetRadDamOption ( )
inline

Definition at line 121 of file PndGemDetector.h.

References fUseRadDamOption.

121 {return fUseRadDamOption;}
bool fUseRadDamOption
Hit collection.
Int_t PndGemDetector::GetSensorId ( TString  detName)
private

Definition at line 339 of file PndGemDetector.cxx.

Referenced by ProcessHits().

340 {
341  // std::cout << "name is " << detName.Data() << " -> " << std::flush;
342  detName.Remove(0,detName.Last('/')+1);
343  detName.Remove(0,detName.First("Disk")+4);
344  Int_t stationNr = detName.Atoi();
345  detName.Remove(0,detName.First("Seg")+3);
346  Int_t segmentNr = detName.Atoi();
347  detName.Remove(0,detName.First("Gem")+3);
348  Int_t sensorNr = detName.Atoi();
349  if ( sensorNr == 6 ) sensorNr = 2;
350 // std::cout << "stat " << stationNr << " sens " << sensorNr << " seg " << segmentNr << " > "
351 // << stationNr*256+sensorNr*16+segmentNr << std::endl;
352  return stationNr*256+sensorNr*16+segmentNr;
353 }
void PndGemDetector::Initialize ( )
virtual

Definition at line 90 of file PndGemDetector.cxx.

References gGeoManager, and Initialize().

91 {
92  std::cout<<" -I- Initializing PndGemDetector()"<<std::endl;
94  if(0==gGeoManager) {
95  std::cout<<" -E- No gGeoManager in PndGemDetector::Initialize()!"<<std::endl;
96  abort();
97  }
98 // fGeoH = new PndGemGeoHandling(gGeoManager);
99 }
TGeoManager * gGeoManager
Mvd Initialize()
void PndGemDetector::MisalignDetector ( )

Definition at line 273 of file PndGemDetector.cxx.

References Double_t, gGeoManager, trans, and TString.

274 {
275  std::cout << "-----------------------------------" << std::endl;
276  std::cout << " M I S A L I G N D E T E C T O R " << std::endl;
277 
278  /* TGeoPhysicalNode* pn1 = gGeoManager->MakePhysicalNode("/cave_1/Gem_Disks_0/Gem_Disk1_Volume_0/Gem_Disk1_Seg1_Gem1_Sensor_GEMmixture_0");
279  cout << "got the node " << pn1 << endl;
280  cout << "print the orig rot matrix:" << endl;
281  pn1->GetOriginalMatrix()->Print();
282  cout << "print the rot matrix:" << endl;
283  pn1->GetMatrix()->Print();
284 
285  TGeoHMatrix* dummyRot = new TGeoHMatrix();
286  // dummyRot->RotateZ(90);
287  dummyRot->RotateX(0.3);
288  dummyRot->RotateY(0.1);
289  Double_t trans[3] = {0.,-0.1,-1.123400};
290  dummyRot->SetTranslation(trans);
291 
292  cout << "dummyRot ---> " << endl;
293  dummyRot->Print();
294 
295  cout << "aligning to dummyRot" << endl;
296  pn1->Align(dummyRot); // in Align, if (!newmat&&!newshape)return;*/
297 
298  Int_t nofSeg = 2;
299  for ( Int_t ist = 0 ; ist < 3 ; ist++ ) {
300  if ( ist == 2 ) nofSeg = 3;
301  for ( Int_t isg = 0 ; isg < nofSeg ; isg++ ) {
302  for ( Int_t isp = 0 ; isp < 2 ; isp++ ) {
303  TString tName = Form("/cave_1/Gem_Disks_0/Gem_Disk%d_Volume_0/Gem_Disk%d_Seg%d_Gem%d_Sensor_GEMmixture_0",ist+1,ist+1,isg+1,isp*5+1);
304  cout << tName.Data() << endl;
305  TGeoPhysicalNode* tgpn = gGeoManager->MakePhysicalNode(tName.Data());
306  TGeoHMatrix* tghm = (TGeoHMatrix*)tgpn->GetOriginalMatrix();
307  cout << " * * * o r i g * * * o r i g * * * o r i g * * * o r i g * * * " << endl;
308  tghm->Print();
309  tghm->RotateX(gRandom->Gaus(0.,.1));
310  tghm->RotateY(gRandom->Gaus(0.,.1));
311  tghm->RotateZ(gRandom->Gaus(0.,.1));
312  Double_t* trans = tghm->GetTranslation();
313  cout << "trans = " << trans[0] << " " << trans[1] << " " << trans[2] << endl;
314  for ( Int_t ic = 0 ; ic < 3 ; ic++ )
315  trans[0] += gRandom->Gaus(0.,.03);
316  tghm->SetTranslation(trans);
317  cout << " * * * m o v e d * * * m o v e d * * * m o v e d * * * m o v e d * * * " << endl;
318  tghm->Print();
319  cout << " * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * " << endl;
320  tgpn->Align(tghm);
321  }
322  }
323  }
324 
325  std::cout << "-----------------------------------" << std::endl;
326 }
TGeoManager * gGeoManager
TGeoTranslation * trans
Double_t
void PndGemDetector::Print ( ) const
virtual

Virtual method Print

Screen output of hit collection.

Definition at line 206 of file PndGemDetector.cxx.

References fPndGemCollection, i, and nHits.

Referenced by EndOfEvent().

207 {
208  Int_t
209  nHits = fPndGemCollection->GetEntriesFast();
210 
211  std::cout << "-I- PndGemDetector: " << nHits << " points registered in this event." << std::endl;
212 
213  if (fVerboseLevel>1)
214  for (Int_t i=0; i<nHits; i++)
215  (*fPndGemCollection)[i]->Print();
216 }
Int_t i
Definition: run_full.C:25
int nHits
Definition: RiemannTest.C:16
TClonesArray * fPndGemCollection
Bool_t PndGemDetector::ProcessHits ( FairVolume *  vol = 0)
virtual

Virtual method ProcessHits

Defines the action to be taken when a step is inside the active volume. Creates CbmTrdPoints and adds them to the collection.

Parameters
volPointer to the active volume

Definition at line 103 of file PndGemDetector.cxx.

References AddHit(), PndStack::AddPoint(), fELoss, fLength, fMomIn, fMomOut, fPosIn, fPosOut, fTime, fTrackID, fUseRadDamOption, GetSensorId(), kGEM, ResetParameters(), and TString.

104 {
105 
106  if ( gMC->IsTrackEntering() )
107  {
108  // Set parameters at entrance of volume. Reset ELoss.
109  fELoss = 0.;
110  fTime = gMC->TrackTime() * 1.0e09;
111  fLength = gMC->TrackLength();
112  gMC->TrackPosition(fPosIn);
113  gMC->TrackMomentum(fMomIn);
114  }
115 
116  // Sum energy loss for all steps in the active volume
117  fELoss += gMC->Edep();
118 
119 
120  // Create PndGemMCPoint at exit of active volume
121 
122  if ( gMC->IsTrackExiting() ||
123  gMC->IsTrackStop() ||
124  gMC->IsTrackDisappeared() ) {
125 
126  fTrackID = gMC->GetStack()->GetCurrentTrackNumber();
127 
128 /* if(0==fGeoH) {
129  std::cout<<" -E- No PndGemGeoHandling loaded."<<std::endl;
130  abort();
131  }*/
132  if (fVerboseLevel > 1){
133  std::cout << "******* Info from gMC *************" << std::endl;
134  std::cout << "Hit in " << gMC->CurrentVolPath() << " with MCiD: " << vol->getMCid() << " PixelDetectorID: " << kGEM << std::endl;
135 // std::cout<<"VolumeID: "<<fGeoH->GetID(gMC->CurrentVolPath())<<std::endl;
136  std::cout << "PosIn: " << fPosIn.X() << " " << fPosIn.Y() << " " << fPosIn.Z() << " " << fELoss << std::endl;
137  }
138 
139  gMC->TrackPosition(fPosOut);
140  gMC->TrackMomentum(fMomOut);
141 
142  if (fUseRadDamOption == false){
143  if (fELoss == 0.) return kFALSE;
144  }
145 
146  TString detPath = gMC->CurrentVolPath();
147  Int_t sensID = GetSensorId(detPath);
148  AddHit(fTrackID, kGEM, sensID,
149  TVector3(fPosIn.X(), fPosIn.Y(), fPosIn.Z()),
150  TVector3(fPosOut.X(), fPosOut.Y(), fPosOut.Z()),
151  TVector3(fMomIn.Px(), fMomIn.Py(), fMomIn.Pz()),
152  TVector3(fMomOut.Px(), fMomOut.Py(), fMomOut.Pz()),
153  fTime, fLength, fELoss);
154 
155  // Increment number of PndGem points for TParticle
156  PndStack* stack = (PndStack*) gMC->GetStack();
157  stack->AddPoint(kGEM);
158 
159  ResetParameters();
160  }
161 
162  return kTRUE;
163 }
void ResetParameters()
TLorentzVector fMomIn
exit position in global frame
Double32_t fELoss
length
bool fUseRadDamOption
Hit collection.
void AddPoint(DetectorId iDet)
Definition: PndStack.cxx:408
Int_t GetSensorId(TString detName)
TLorentzVector fPosIn
Det id.
PndGemMCPoint * AddHit(Int_t trackID, Int_t detID, Int_t sensID, TVector3 posIn, TVector3 posOut, TVector3 momIn, TVector3 momOut, Double_t time, Double_t length, Double_t eLoss)
TLorentzVector fMomOut
momentum
Double32_t fLength
time
TLorentzVector fPosOut
entry position in global frame
Double32_t fTime
momentum
void PndGemDetector::Register ( )
virtual

Virtual method Register

Registers the hit collection in the ROOT manager.

Definition at line 185 of file PndGemDetector.cxx.

References fPndGemCollection.

186 {
187  FairRootManager::Instance()->Register("GEMPoint", "PndGem", fPndGemCollection, kTRUE);
188 }
TClonesArray * fPndGemCollection
void PndGemDetector::Reset ( )
virtual

Virtual method Reset

Clears the hit collection

Definition at line 222 of file PndGemDetector.cxx.

References fPndGemCollection, and ResetParameters().

223 {
224  fPndGemCollection->Delete();
225  ResetParameters();
226 }
void ResetParameters()
TClonesArray * fPndGemCollection
void PndGemDetector::ResetParameters ( )
inlineprivate

Private method ResetParameters

Resets the private members for the track parameters

Definition at line 171 of file PndGemDetector.h.

References fELoss, fLength, fMomIn, fMomOut, fPosIn, fPosIndex, fPosOut, fTime, fTrackID, and fVolumeID.

Referenced by ProcessHits(), and Reset().

171  {
172  fTrackID = 0;
173  fVolumeID = 1;
174  fPosIn.SetXYZM(0.0, 0.0, 0.0, 0.0);
175  fPosOut.SetXYZM(0.0, 0.0, 0.0, 0.0);
176  fMomIn.SetXYZM(0.0, 0.0, 0.0, 0.0);
177  fMomOut.SetXYZM(0.0, 0.0, 0.0, 0.0);
178  fTime = fLength = fELoss = 0;
179  fPosIndex = 0;
180 }
TLorentzVector fMomIn
exit position in global frame
Double32_t fELoss
length
Int_t fVolumeID
track index
TLorentzVector fPosIn
Det id.
TLorentzVector fMomOut
momentum
Double32_t fLength
time
Int_t fPosIndex
energy loss
TLorentzVector fPosOut
entry position in global frame
Double32_t fTime
momentum
void PndGemDetector::SetExclusiveSensorType ( const TString  sens)

Definition at line 408 of file PndGemDetector.cxx.

References fListOfSensitives.

409 {
410  //Set one exclusive sensor type for testing purposes
411  fListOfSensitives.clear();
412  fListOfSensitives.push_back(sens.Data());
413  std::cout<<"-I- PndGemDetector: Only active sensor type is set to \""<<sens.Data()<<"\","<<std::endl;
414  std::cout<<" this is not a default setting."<<std::endl;
415 }
std::vector< std::string > fListOfSensitives
enables the detection of neutral particles
void PndGemDetector::SetRadDamOption ( bool  val)
inline

Definition at line 120 of file PndGemDetector.h.

References fUseRadDamOption, and val.

120 {fUseRadDamOption = val;};
Double_t val[nBoxes][nFEBox]
Definition: createCalib.C:11
bool fUseRadDamOption
Hit collection.

Member Data Documentation

Double32_t PndGemDetector::fELoss
private

length

Definition at line 138 of file PndGemDetector.h.

Referenced by ProcessHits(), and ResetParameters().

Double32_t PndGemDetector::fLength
private

time

Definition at line 137 of file PndGemDetector.h.

Referenced by ProcessHits(), and ResetParameters().

std::vector<std::string> PndGemDetector::fListOfSensitives
private

enables the detection of neutral particles

Definition at line 145 of file PndGemDetector.h.

Referenced by CheckIfSensitive(), PndGemDetector(), and SetExclusiveSensorType().

TLorentzVector PndGemDetector::fMomIn
private

exit position in global frame

Definition at line 134 of file PndGemDetector.h.

Referenced by ProcessHits(), and ResetParameters().

TLorentzVector PndGemDetector::fMomOut
private

momentum

Definition at line 135 of file PndGemDetector.h.

Referenced by ProcessHits(), and ResetParameters().

TClonesArray* PndGemDetector::fPndGemCollection
private
TLorentzVector PndGemDetector::fPosIn
private

Det id.

Definition at line 132 of file PndGemDetector.h.

Referenced by ProcessHits(), and ResetParameters().

Int_t PndGemDetector::fPosIndex
private

energy loss

Definition at line 141 of file PndGemDetector.h.

Referenced by CopyClones(), EndOfEvent(), PndGemDetector(), and ResetParameters().

TLorentzVector PndGemDetector::fPosOut
private

entry position in global frame

Definition at line 133 of file PndGemDetector.h.

Referenced by ProcessHits(), and ResetParameters().

Double32_t PndGemDetector::fTime
private

momentum

Definition at line 136 of file PndGemDetector.h.

Referenced by ProcessHits(), and ResetParameters().

Int_t PndGemDetector::fTrackID
private

Track information to be stored until the track leaves the active volume.

Definition at line 130 of file PndGemDetector.h.

Referenced by ProcessHits(), and ResetParameters().

bool PndGemDetector::fUseRadDamOption
private

Hit collection.

Definition at line 143 of file PndGemDetector.h.

Referenced by GetRadDamOption(), ProcessHits(), and SetRadDamOption().

Int_t PndGemDetector::fVolumeID
private

track index

Definition at line 131 of file PndGemDetector.h.

Referenced by ResetParameters().


The documentation for this class was generated from the following files: