EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CompCal.cxx
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file CompCal.cxx
1 
2 //_____________________________________________________________________________
3 //
4 // composite calorimeter,
5 // consists of a matrix of individual cells
6 //_____________________________________________________________________________
7 
8 //local headers
9 #include "CompCal.h"
10 #include "Cell.h"
11 #include "OpDet.h"
12 #include "RootOut.h"
13 
14 //ROOT
15 #include <TTree.h>
16 
17 //Geant headers
18 #include <Geant4/G4LogicalVolume.hh>
19 
20 //C++ headers
21 #include <vector>
22 
23 
24 //_____________________________________________________________________________
25 CompCal::CompCal(const G4String& nam, G4double zpos, G4double ypos, G4LogicalVolume *top, RootOut *rout):
26  fNam(nam) {
27 
28 // G4cout << "CompCal::CompCal: " << fNam << G4endl;
29 
30  //number of cells in x and y
31  G4int ncells = 7;
32 
33  //create the cells
34  fCells = new std::vector<Cell*>;
35  for(G4int ix=0; ix<ncells; ix++) {
36  for(G4int iy=0; iy<ncells; iy++) {
37 
38  //name for the cell from ix and iy
39  std::stringstream ss;
40  ss << "_";
41  ss.fill('0');
42  ss.width(2);
43  ss << ix << "x";
44  ss.fill('0');
45  ss.width(2);
46  ss << iy;
47 
48  G4String cell_nam = fNam + ss.str();
49  Cell *cl = new Cell(cell_nam, ix, iy, ncells, zpos, ypos, top, *this, rout);
50  fCells->push_back(cl);
51  cl->CreateOutput(rout->GetTree());
52  }
53  }
54 
55  ClearEvent();
56 
57 }//CompCal
58 
59 //_____________________________________________________________________________
60 void CompCal::CreateOutput(TTree *tree) {
61 
62  AddBranch("_en", &fEdep, tree);
63  AddBranch("_x", &fX, tree);
64  AddBranch("_y", &fY, tree);
65  AddBranch("_z", &fZ, tree);
66  AddBranch("_xyzE", &fXyzE, tree);
67 
68  AddBranch("_nphot", &fNphot, tree);
69  AddBranch("_nscin", &fNscin, tree);
70  AddBranch("_ncerenkov", &fNcerenkov, tree);
71 
72  AddBranch("_nphotDet", &fNphotDet, tree);
73  AddBranch("_nscinDet", &fNscinDet, tree);
74  AddBranch("_ncerenkovDet", &fNcerenkovDet, tree);
75 
76 }//CreateOutput
77 
78 //_____________________________________________________________________________
80 
81  //cell loop
82  std::vector<Cell*>::iterator i;
83  for(i = fCells->begin(); i != fCells->end(); ++i) {
84  const Cell& c = **i;
85 
86  //deposited energy from cells
87  fEdep += c.fE;
88 
89  //optical photons in cells
90  fNphot += c.fNphot;
91  fNscin += c.fNscin;
93 
94  //optical photons from cell photon detectors
95  fNphotDet += c.fOpDet->fNphot;
96  fNscinDet += c.fOpDet->fNscin;
98 
99  }//cell loop
100 
101 }//WriteEvent
102 
103 //_____________________________________________________________________________
105 
106  fEdep = 0.;
107  fX = 9999.;
108  fY = 9999.;
109  fZ = 9999.;
110  fXyzE = -9999.;
111 
112  fNphot = 0;
113  fNscin = 0;
114  fNcerenkov = 0;
115 
116  fNphotDet = 0;
117  fNscinDet = 0;
118  fNcerenkovDet = 0;
119 
120 }//ClearEvent
121 
122 /*
123 //_____________________________________________________________________________
124 void CompCal::Add(std::vector<Detector*> *vec) {
125 
126  //add this detector and its parts to sensitive detectors
127  vec->push_back(this);
128 
129  //cell loop
130  std::vector<Cell*>::iterator i = fCells->begin();
131  while(i != fCells->end()) (*i++)->Add(vec);
132 
133 }//Add
134 */
135 
136 //_____________________________________________________________________________
137 void CompCal::AddBranch(const std::string& nam, Double_t *val, TTree *tree) {
138 
139  //add branch for one Double_t variable
140 
141  std::string name = fNam + nam; // branch name from detector name and variable name
142  std::string leaf = name + "/D"; // leaflist for Double_t
143  tree->Branch(name.c_str(), val, leaf.c_str()); // create the branch
144 
145 }//AddBranch
146 
147 //_____________________________________________________________________________
148 void CompCal::AddBranch(const std::string& nam, ULong64_t *val, TTree *tree) {
149 
150  //add branch for one ULong64_t variable
151 
152  std::string name = fNam + nam; // branch name from detector name and variable name
153  std::string leaf = name + "/l"; // leaflist for Double_t
154  tree->Branch(name.c_str(), val, leaf.c_str()); // create the branch
155 
156 }//AddBranch
157 
158 
159 
160 
161 
162 
163 
164 
165 
166 
167 
168 
169 
170 
171 
172