FairRoot/PandaRoot
PndMvdRadDamIonizingTask.cxx
Go to the documentation of this file.
1 /*
2  * PndMvdRadDamIonizingTask.cxx
3  *
4  * Created on: Dec 16, 2008
5  * Author: stockman
6  */
7 
9 
10 #include "FairRootManager.h"
11 #include "PndSdsMCPoint.h"
12 #include "PndMCTrack.h"
13 #include "PndMvdRadDamHit.h"
14 #include "PndStringSeparator.h"
15 
16 
17 #include <iostream>
18 
20  fPersistance(kTRUE),
21  fMCHits(NULL),
22  fRadDamHits(NULL),
23  fGeoH(PndGeoHandling::Instance()),
24  fMapDetHistos(),
25  fRadDamHisto(NULL)
26 {
27 }
28 
30 {
31  for (std::map<std::string, TProfile2D*>::iterator it = fMapDetHistos.begin(); it != fMapDetHistos.end(); it++)
32  delete(it->second);
33  fMapDetHistos.clear();
34  delete (fRadDamHisto);
35 }
36 
37 
39 {
40 }
41 
43 {
45  return kSUCCESS;
46 }
47 
49 {
50  FairRootManager* ioman = FairRootManager::Instance();
51 
52  if (!ioman)
53  {
54  std::cout << "-E- PndMvdRadDamIonizingTask::Init: "
55  << "RootManager not instantiated!" << std::endl;
56  return kFATAL;
57  }
58 
59  fMCHits = (TClonesArray*) ioman->GetObject("MVDPoint");
60  if (!fMCHits)
61  {
62  std::cout << "-W- PndMvdRadDamIonizingTask::Init: " << "No MVDPoint array!"
63  << std::endl;
64  return kERROR;
65  }
66 
67  // Create and register output array
68 // fRadDamHits = ioman->Register("MVDRadDamHit", "PndMvdRadDamHit", "MVD", kTRUE);
69 
70 
71  fRadDamHisto = new TH1D("radDamH","absorbed dose", 10000000,1E-12,1E-4);
72 
73  std::cout << "-I- PndMvdRadDamIonizingTask: Initialization successful" << std::endl;
74 
75  return kSUCCESS;
76 }
77 
78 
80 {
81  // Reset output array
82 
83  PndSdsMCPoint* mcPoint;
84 
85 
86  for (int i = 0; i < fMCHits->GetEntriesFast(); i++){
87  mcPoint = (PndSdsMCPoint*)fMCHits->At(i);
88  TVector3 length = mcPoint->GetPosition();
89  length -= mcPoint->GetPositionOut();
90  TVector3 mom;
91  mcPoint->Momentum(mom);
92  Double_t energyLoss = mcPoint->GetEnergyLoss();
93  Double_t dEdx;
94  if (length.Mag() > 0)
95  dEdx = energyLoss / length.Mag();
96  else
97  dEdx = 0;
98  Double_t gray = dEdx * 1E9 * 1.6E-19 * 1/0.01 * 1/2.4 * 1000; // dEdx [GeV/cm] * conversion to electrons * conversion to Joule * sensitive Area mm2 * density silicon * conversion 1/g to 1/kg= Joule / kg
99 
100  TString detname = fGeoH->GetPath(mcPoint->GetSensorID());
101 
102  if (fMapDetHistos[detname.Data()] == 0){
103  PndStringSeparator svec(detname.Data(),"/");
104  TVector3 sensDim = fGeoH->GetSensorDimensionsShortId(mcPoint->GetSensorID());
105  std::string histoName = "";
106  histoName += svec.Replace("/","o");
107  fMapDetHistos[detname.Data()] = new TProfile2D(histoName.c_str(),
108  detname.Data(),
109  (Int_t)(2*sensDim.X()*10),-sensDim.X(),sensDim.X(), // point resolution mm^2
110  (Int_t)(2*sensDim.Y()*10),-sensDim.Y(),sensDim.Y());
111  }
112  //std::cout << "Damage: " << gray << " gray" << std::endl;
113  TVector3 localHit = fGeoH->MasterToLocalShortId(mcPoint->GetPosition(), mcPoint->GetSensorID());
114  ((TProfile2D*)(fMapDetHistos[detname.Data()]))->Fill(localHit.X(), localHit.Y(), gray);
115  fRadDamHisto->Fill(gray);
116 
117 // fRadDamHits = FairRootManager::Instance()->GetTClonesArray("MVDRadDamHit");
118 // PndMvdRadDamHit* tempHit = new ((*fRadDamHits)[fRadDamHits->GetEntries()]) PndMvdRadDamHit(mcPoint->GetTrackID(), i, mcPoint->GetSensorID(), 0, 0, mcPoint->GetPosition(), mom, dEdx);
119  // std::cout << "TempHit: " << *tempHit << std::endl;
120  }
121 }
122 
124 {
125  //fRadDamHits->Delete();
126 }
127 
129 {
130  for (std::map<std::string, TProfile2D*>::iterator it = fMapDetHistos.begin(); it != fMapDetHistos.end(); it++)
131  it->second->Write();
132  fRadDamHisto->Write();
133 
134  //fRadDamHisto->Draw();
135 }
136 
137 
Int_t i
Definition: run_full.C:25
PndGeoHandling * fGeoH
Definition: anasim.C:34
TString detname
Definition: anasim.C:61
TVector3 GetPositionOut() const
Definition: PndSdsMCPoint.h:91
Double_t mom
Definition: plot_dirc.C:14
Int_t GetSensorID() const
Definition: PndSdsMCPoint.h:89
TString GetPath(Int_t shortID)
for a given shortID the path is returned
TVector3 GetSensorDimensionsShortId(Int_t shortId)
std::map< std::string, TProfile2D * > fMapDetHistos
Class to access the naming information of the MVD.
Double_t
TVector3 MasterToLocalShortId(const TVector3 &master, const Int_t &shortId)
TVector3 GetPosition() const
Definition: PndSdsMCPoint.h:90
virtual void Exec(Option_t *opt)
ClassImp(PndAnaContFact)