SND@LHC Software
Loading...
Searching...
No Matches
ecalAnalysisMaterial.cxx
Go to the documentation of this file.
2
3#include "FairRootManager.h"
4#include "ShipMCTrack.h"
5#include "FairRadLenPoint.h"
6
7
8#include "TTree.h"
9#include "TClonesArray.h"
10#include "TLorentzVector.h"
11
12#include <iostream>
13
14using std::cout;
15using std::cerr;
16using std::endl;
17using std::list;
18
20void ecalAnalysisMaterial::Exec(Option_t* option)
21{
22 fEvent++;
23 if (fVerbose>0)
24 Info("Exec", "Event %d.", fEvent);
25 InitTree();
26 ShipMCTrack* tr;
27 FairRadLenPoint* p;
28 Int_t i;
29 Int_t k;
30 Int_t n;
31 Double_t z=3535;
32 TVector3 newp;
33 TVector3 oldp(0.0, 0.0, 0.0);
34 TVector3 d;
35 if (fMC->GetEntriesFast()!=1)
36 {
37 cout << "Size of MC points arrays differs from one" << endl;
38 }
39 tr=(ShipMCTrack*)fMC->At(0);
40 fX=tr->GetPx();
41 fY=tr->GetPy();
42 fZ=tr->GetPz();
43 fX*=z/fZ;
44 fY*=z/fZ;
45 fZ*=z/fZ;
46// if (TMath::Abs(fX)>594||TMath::Abs(fY)>474) return;
47// if (TMath::Abs(fX)<42&&TMath::Abs(fY)<42) return;
48 n=fRadLen->GetEntriesFast();
49 fX0=0; fIntL=0;
50 for(i=0;i<400;i++) fX0z[i]=0;
51 for(i=0;i<n;i++)
52 {
53 p=(FairRadLenPoint*)fRadLen->At(i);
54 newp=p->GetPositionOut();
55// cout << d.Mag() << " " << p->GetRadLength() << " " << newp.Z() << " " << fX0 << endl;
56 if (newp.Z()>3535) break;
57 k=newp.Z()/10;
58 d=newp-oldp;
59// cout << p->GetLength() << " " << p->GetRadLength() << " " << fEvent << " " <<p->GetXOut() << " " << p->GetYOut() << " " << p->GetZOut() << endl;
60 fX0+=d.Mag()/p->GetRadLength();
61 fX0z[k]+=d.Mag()/p->GetRadLength();
62 oldp=newp;
63 }
64 fTree->Fill();
65}
66
67
70{
71 if (fTree) return;
72 fTree=new TTree("rad","Radiation lenght tree");
73 fTree->Branch("ev", &fEvent, "ev/I");
74 fTree->Branch("x", &fX, "x/D");
75 fTree->Branch("y", &fY, "Y/D");
76 fTree->Branch("z", &fZ, "z/D");
77 fTree->Branch("x0", &fX0, "x0/D");
78 fTree->Branch("x0z", &fX0z, "x0z[400]/D");
79 fTree->Branch("intl", &fIntL, "intl/D");
80}
81
83 : FairTask(),
84 fTree(NULL),
85 fEvent(0),
86 fX(0.),
87 fY(0.),
88 fZ(0.),
89 fX0(0.),
90 fIntL(0.),
91 fMC(NULL),
92 fRadLen(NULL)
93{
94}
95
96ecalAnalysisMaterial::ecalAnalysisMaterial(const char* name, const Int_t iVerbose)
97 : FairTask(name, iVerbose),
98 fTree(NULL),
99 fEvent(0),
100 fX(0.),
101 fY(0.),
102 fZ(0.),
103 fX0(0.),
104 fIntL(0.),
105 fMC(NULL),
106 fRadLen(NULL)
107{
108}
109
112{
113 FairRootManager* fManager=FairRootManager::Instance();
114 if (!fManager)
115 {
116 Fatal("Init", "Can't find a Root Manager.");
117 return kFATAL;
118 }
119 fMC=(TClonesArray*)fManager->GetObject("MCTrack");
120 if (!fMC)
121 {
122 Fatal("Init", "Can't find an array of MC tracks.");
123 return kFATAL;
124 }
125 fRadLen=(TClonesArray*)fManager->GetObject("RadLen");
126 if (!fRadLen)
127 {
128 Fatal("Init", "Can't find an array of radiation length points.");
129 return kFATAL;
130 }
131 fTree=NULL;
132
133 return kSUCCESS;
134}
135
138{
139 if (fTree)
140 fTree->Write();
141}
142
Double_t GetPy() const
Definition ShipMCTrack.h:61
Double_t GetPx() const
Definition ShipMCTrack.h:60
Double_t GetPz() const
Definition ShipMCTrack.h:62
virtual InitStatus Init()
virtual void Exec(Option_t *option)
ClassImp(ecalContFact) ecalContFact