-
Notifications
You must be signed in to change notification settings - Fork 0
/
MC_change.cxx
123 lines (103 loc) · 3.11 KB
/
MC_change.cxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#include "MC_change.h"
#include "SniperKernel/AlgFactory.h"
#include "SniperKernel/SniperPtr.h"
#include "EvtNavigator/NavBuffer.h"
#include "Event/SimHeader.h"
#include "BufferMemMgr/IDataMemMgr.h"
#include "RootIOSvc/RootOutputSvc.h"
#include "Geometry/SimGeomSvc.h"
#include "TROOT.h"
#include "TGeoManager.h"
DECLARE_ALGORITHM(MC_change);
MC_change::MC_change(const std::string& name)
: AlgBase(name)
{
declProp("InputMCName", InputMCName="test.root");
declProp("InputMCDir", InputMCDir="");
}
MC_change::~MC_change()
{
}
bool
MC_change::initialize()
{
fpTEEnergy = fpTEX = fpTEY = fpTEZ = 0LL;
std::string filename = InputMCDir + "/" + InputMCName;
f = new TFile(filename.c_str());
t1 = (TTree*)f->Get("nEXOevents");
t1->SetBranchAddress("EventNumber", &fEventNumber);
t1->SetBranchAddress("GenX", &fGenX);
t1->SetBranchAddress("GenY", &fGenY);
t1->SetBranchAddress("GenZ", &fGenZ);
t1->SetBranchAddress("TotalEventEnergy", &fTotalEventEnergy);
t1->SetBranchAddress("InitNumOP", &fInitNOP);
t1->SetBranchAddress("NumTE", &fNTE);
// t1->SetBranchAddress("TEEnergy", &fpTEEnergy);
t1->SetBranchAddress("TEX", &fpTEX);
t1->SetBranchAddress("TEY", &fpTEY);
t1->SetBranchAddress("TEZ", &fpTEZ);
EVENT=0;
TGeoManager* nEXOGeometry = (TGeoManager*) f->Get("nEXOGeometry");
// SimGeomSvc parts copied from :
// nexo-offline/Simulation/DetSim/nEXOSim/src/nEXOAnalysis.cc
SniperPtr<RootOutputSvc> output_svc("OutputSvc");
if (output_svc.invalid()) {
LogWarn << "Can't find the OutputSvc in current task." << std::endl;
return false;
}
bool status = output_svc->attachObj("/Event/Sim", nEXOGeometry);
SniperPtr<SimGeomSvc> simgeom_svc("SimGeomSvc");
simgeom_svc->geom(nEXOGeometry);
return true;
}
bool
MC_change::execute()
{
// fpTEEnergy = fpTEX = fpTEY = fpTEZ = 0LL;
fTEEnergy.clear();
fTEX.clear();
fTEY.clear();
fTEZ.clear();
t1->GetEntry(EVENT);
EVENT++;
// std::cout<<fNTE<<" "<<fpTEX->size()<<" "<<fpTEEnergy->size()<<std::endl;
for(int i=0; i<fNTE; i++){
fTEEnergy.push_back( 9.47e-7 ); //Must be valued.
fTEX.push_back( (double)(*fpTEX)[i] );
fTEY.push_back( (double)(*fpTEY)[i] );
fTEZ.push_back( (double)(*fpTEZ)[i] );
}
// 1. create an event navigator
nEXO::EvtNavigator* nav = new nEXO::EvtNavigator();
TTimeStamp ts;
nav->setTimeStamp(ts);
// 2. put into data buffer
SniperPtr<IDataMemMgr> mMgr("BufferMemMgr");
mMgr->adopt(nav, "/Event");
// 3. create SimHeader
nEXO::SimHeader* header = new nEXO::SimHeader();
header->setEventID(fEventNumber);
nav->addHeader(header);
// 4. create SimEvent
nEXO::SimEvent* event = new nEXO::SimEvent();
// * fill all data
// **
event->EventNumber(fEventNumber);
event->GenX(fGenX);
event->GenY(fGenY);
event->GenZ(fGenZ);
event->TotalEventEnergy(fTotalEventEnergy);
event->InitNOP(fInitNOP);
event->NTE(fNTE);
event->TEEnergy(fTEEnergy);
event->TEX(fTEX);
event->TEY(fTEY);
event->TEZ(fTEZ);
header->setEvent(event);
return true;
}
bool
MC_change::finalize()
{
return true;
}