Skip to content

Commit 6015cd4

Browse files
committed
Made associations with Space Points. Added cluster->Tagger() functionality. Added MC versus Data fcls
1 parent a06aaa7 commit 6015cd4

5 files changed

Lines changed: 161 additions & 79 deletions

File tree

sbndcode/CRT/CRTReco/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,4 @@ simple_plugin(
3434
Eigen3::Eigen
3535
)
3636

37-
3837
install_fhicl()

sbndcode/CRT/CRTVeto/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
2+
13
art_make_library(
24
LIBRARIES
35
sbnobj::SBND_CRT

sbndcode/CRT/CRTVeto/CRTVetoProducer_module.cc

Lines changed: 142 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,15 @@
2222

2323
#include "lardata/Utilities/AssociationUtil.h"
2424

25+
#include "sbnobj/SBND/CRT/CRTEnums.hh"
2526
#include "sbnobj/SBND/CRT/CRTCluster.hh"
2627
#include "sbnobj/SBND/CRT/CRTSpacePoint.hh"
2728
#include "sbnobj/SBND/CRT/CRTTrack.hh"
2829
#include "sbnobj/SBND/CRT/CRTVeto.hh"
2930

3031
#include "sbndcode/Geometry/GeometryWrappers/CRTGeoAlg.h"
3132
#include "sbndcode/CRT/CRTUtils/CRTCommonUtils.h"
32-
33+
#include "lardata/Utilities/AssociationUtil.h"
3334

3435
#include "TMath.h"
3536

@@ -53,19 +54,24 @@ class sbnd::crt::CRTVetoProducer : public art::EDProducer {
5354
void produce(art::Event& e) override;
5455

5556
// Functions to check if a point is in a specific Tagger
56-
bool inSouth(const double &x, const double &y, const double &z);
57-
bool inNorth(const double &x, const double &y, const double &z);
58-
bool inEast(const double &x, const double &y, const double &z);
59-
bool inWest(const double &x, const double &y, const double &z);
60-
bool inTopLow(const double &x, const double &y, const double &z);
61-
bool inTopHigh(const double &x, const double &y, const double &z);
57+
bool inSouth(const CRTTagger t);
58+
bool inNorth(const CRTTagger t);
59+
bool inEast(const CRTTagger t);
60+
bool inWest(const CRTTagger t);
61+
bool inTopLow(const CRTTagger t);
62+
bool inTopHigh(const CRTTagger t);
6263

6364
private:
6465

6566
CRTGeoAlg fCRTGeoAlg;
6667
double fWindowStart;
6768
double fWindowEnd;
69+
std::string fCRTClusterModuleLabel;
6870
std::string fCRTSpacePointModuleLabel;
71+
bool fIsData;
72+
73+
std::vector<int> fVetoSpacePointIndices;
74+
std::vector<art::Ptr<CRTSpacePoint>> fVetoSpacePoints;
6975
};
7076

7177

@@ -74,16 +80,35 @@ sbnd::crt::CRTVetoProducer::CRTVetoProducer(fhicl::ParameterSet const& p)
7480
, fCRTGeoAlg(p.get<fhicl::ParameterSet>("CRTGeoAlg"))
7581
, fWindowStart(p.get<double>("WindowStart"))
7682
, fWindowEnd(p.get<double>("WindowEnd"))
83+
, fCRTClusterModuleLabel(p.get<std::string>("CRTClusterModuleLabel"))
7784
, fCRTSpacePointModuleLabel(p.get<std::string>("CRTSpacePointModuleLabel"))
85+
, fIsData(p.get<bool>("IsData"))
7886
{
79-
produces<CRTVeto>();
80-
// produces<art::Assns<CRTSpacePoint, CRTVeto>>();
87+
produces<std::vector<CRTVeto>>();
88+
produces<art::Assns<CRTVeto, CRTSpacePoint>>();
8189
}
8290

8391
void sbnd::crt::CRTVetoProducer::produce(art::Event& e)
8492
{
85-
//auto crtveto = std::make_unique<CRTVeto>();
86-
//auto vetoSpacePointAssn = std::make_unique<art::Assns<CRTSpacePoint, CRTVeto>>();
93+
94+
fVetoSpacePoints.clear();
95+
fVetoSpacePointIndices.clear();
96+
97+
if (fIsData) {
98+
std::cout << "Filling CRT Veto for Data" << std::endl;
99+
100+
}
101+
102+
103+
// Get the Clusters for this event
104+
art::Handle<std::vector<CRTCluster>> CRTClusterHandle;
105+
e.getByLabel(fCRTClusterModuleLabel, CRTClusterHandle);
106+
if(!CRTClusterHandle.isValid()){
107+
std::cout << "CRTCluster product " << fCRTClusterModuleLabel << " not found..." << std::endl;
108+
throw std::exception();
109+
}
110+
std::vector<art::Ptr<CRTCluster>> CRTClusterVec;
111+
art::fill_ptr_vector(CRTClusterVec, CRTClusterHandle);
87112

88113
// Get the Space Points for this event
89114
art::Handle<std::vector<CRTSpacePoint>> CRTSpacePointHandle;
@@ -95,65 +120,77 @@ void sbnd::crt::CRTVetoProducer::produce(art::Event& e)
95120
std::vector<art::Ptr<CRTSpacePoint>> CRTSpacePointVec;
96121
art::fill_ptr_vector(CRTSpacePointVec, CRTSpacePointHandle);
97122

123+
art::FindManyP<CRTSpacePoint> cluster_sps(CRTClusterVec, e, fCRTSpacePointModuleLabel);
124+
125+
// Get indices of Veto Space Points
126+
/*
127+
for (unsigned int i = 0; i < CRTSpacePointVec.size(); ++i) {
128+
129+
double t = CRTSpacePointVec.at(i)->Ts0()/1000; // Convert to us
130+
if ((t > fWindowEnd) || (t < fWindowStart)) {
131+
continue;
132+
}
133+
fVetoSpacePointIndices.push_back(i);
134+
135+
}
136+
*/
137+
138+
// initialize counters for veto hits in different taggers
98139
int S = 0;
99140
int N = 0;
100141
int E = 0;
101142
int W = 0;
102143
int TL = 0;
103144
int TH = 0;
104145

105-
// loop over the space points
106-
for (unsigned int i = 0; i < CRTSpacePointVec.size(); i++){
107-
108-
double x = CRTSpacePointVec[i]->X();
109-
double y = CRTSpacePointVec[i]->Y();
110-
double z = CRTSpacePointVec[i]->Z();
111-
double t = CRTSpacePointVec[i]->Ts0()/1000; // Convert to us
112-
113-
// Debugging statement
114-
115-
/*
116-
if ( (t <= 2) && (t >= 0.4) ) {
117-
std::cout << std::endl;
118-
std::cout << std::endl;
119-
std::cout << "Found a CRT Hit within the South Wall Top Hat Window!" << std::endl;
146+
// loop over clusters in this event
147+
// Note: there are usually more clusters than space points
148+
for(auto const &cluster : CRTClusterVec) {
149+
150+
std::vector<art::Ptr<CRTSpacePoint>> clusterSpacePoints = cluster_sps.at(cluster.key());
151+
152+
// loop over the space points in this cluster --> should be one per cluster
153+
for (auto const &sp : clusterSpacePoints) {
154+
155+
// Get the time and tagger for this space point
156+
double t = sp->Ts0()/1000; // Convert to us
157+
CRTTagger tag = cluster->Tagger();
158+
159+
// check if in the beam window --> Make configureable
160+
if ((t > fWindowEnd) || (t < fWindowStart)) {
161+
continue;
162+
}
120163
std::cout << std::endl;
164+
std::cout << "Found Space Point in time with the beam !!!" << std::endl;
121165
std::cout << std::endl;
122-
123-
}
124-
*/
125-
126-
// check if in the beam window --> Make configureable
127-
if ((t > fWindowEnd) || (t < fWindowStart)) {
128-
continue;
129-
}
130-
// We have a valid space point --> make assn
131-
//util::CreateAssn(*this, e, *crtveto, CRTSpacePointVec[i], *vetoSpacePointAssn);
132166

133-
if (inSouth(x, y, z)) {
134-
S += 1;
135-
}
136-
else if (inNorth(x, y, z)) {
137-
N += 1;
138-
}
139-
else if (inEast(x, y, z)) {
140-
E += 1;
141-
}
142-
else if (inWest(x, y, z)) {
143-
W += 1;
144-
}
145-
else if (inTopLow(x, y, z)) {
146-
TL += 1;
147-
}
148-
else if (inTopHigh(x, y, z)) {
149-
TH += 1;
150-
}
151-
else {
152-
std::cout << "Not a valid SpacePoint --> Outside Geometry !!!" << std::endl;
153-
}
154-
155-
} // end loop over space points
156-
167+
fVetoSpacePoints.push_back(sp);
168+
fVetoSpacePointIndices.push_back(sp.key());
169+
170+
if (inSouth(tag)) {
171+
S += 1;
172+
}
173+
else if (inNorth(tag)) {
174+
N += 1;
175+
}
176+
else if (inEast(tag)) {
177+
E += 1;
178+
}
179+
else if (inWest(tag)) {
180+
W += 1;
181+
}
182+
else if (inTopLow(tag)) {
183+
TL += 1;
184+
}
185+
else if (inTopHigh(tag)) {
186+
TH += 1;
187+
}
188+
else {
189+
std::cout << "Not a valid SpacePoint --> Outside Geometry !!!" << std::endl;
190+
}
191+
} // end loop over space points
192+
} // end of loop over clusters
193+
157194
int Nwalls_all = S + N + E + W;
158195
int Nwalls_noNorth = S + E + W;
159196
int Ntop = TL + TH;
@@ -185,58 +222,87 @@ void sbnd::crt::CRTVetoProducer::produce(art::Event& e)
185222
}
186223

187224
//crtveto = CRTVeto(v0, v1, v2, v3);
225+
//
226+
//
227+
// Make Products for the Event
188228
auto crtveto = std::make_unique<CRTVeto>(v0, v1, v2, v3, v4);
189-
190-
e.put(std::move(crtveto));
191-
//e.put(std::move(vetoSpacePointAssn));
229+
auto vetoVec = std::make_unique<std::vector<CRTVeto>>();
230+
vetoVec->push_back(*crtveto);
231+
232+
auto vetoSpacePointAssn = std::make_unique<art::Assns<CRTVeto, CRTSpacePoint>>();
233+
234+
//auto const vetoPtrMaker = art::PtrMaker<CRTVeto>(e);
235+
//auto const vetoPtr = vetoPtrMaker(0);
236+
//auto const CRTSpacePointPtrMaker = art::PtrMaker<CRTSpacePoint>(e, CRTSpacePointHandle.id());
237+
238+
if (fVetoSpacePoints.size() != fVetoSpacePointIndices.size()) {
239+
std::cout << std::endl;
240+
std::cout << "Problem: Number of Space Points does not match!" << std::endl;
241+
std::cout << std::endl;
242+
}
243+
244+
util::CreateAssn(*this, e, *vetoVec, fVetoSpacePoints, *vetoSpacePointAssn);
245+
246+
/*
247+
for (unsigned int i = 0; i < fVetoSpacePoints.size(); ++i) {
248+
std::cout << "Veto SP index " << fVetoSpacePointIndices.at(i) << std::endl;
249+
//auto const CRTSpacePointPtr = CRTSpacePointPtrMaker(fVetoSpacePointIndices.at(i));
250+
//vetoSpacePointAssn->addSingle(vetoPtr, CRTSpacePointPtr);
251+
//vetoSpacePointAssn->addSingle(crtveto, CRTSpacePointPtr);
252+
util::CreateAssn(*this, e, *vetoVec, fVetoSpacePoints.at(i), *vetoSpacePointAssn);
253+
}
254+
*/
255+
256+
//e.put(std::move(crtveto));
257+
e.put(std::move(vetoVec));
258+
e.put(std::move(vetoSpacePointAssn));
192259

193260
} // end of produce
194261

195-
bool sbnd::crt::CRTVetoProducer::inSouth(const double &x, const double &y, const double &z)
262+
bool sbnd::crt::CRTVetoProducer::inSouth(const CRTTagger t)
196263
{
197-
if ((z > -1000) && (z < -179) && (y > -370) && (y < 400)) {
264+
if (t == kSouthTagger) {
198265
return true;
199266
}
200267
return false;
201268
}
202-
bool sbnd::crt::CRTVetoProducer::inNorth(const double &x, const double &y, const double &z)
269+
bool sbnd::crt::CRTVetoProducer::inNorth(const CRTTagger t)
203270
{
204-
// check that this isn't affected by x from east and west --> TODO
205-
if ((z > 746) && (y > -370) && (y < 400)) {
271+
if (t == kNorthTagger) {
206272
return true;
207273
}
208274
return false;
209275
}
210276

211-
bool sbnd::crt::CRTVetoProducer::inEast(const double &x, const double &y, const double &z)
277+
bool sbnd::crt::CRTVetoProducer::inEast(const CRTTagger t)
212278
{
213279
//east_sel = "x < -380 and z < 770 and -370 < y < 400"
214-
if ((x < -380) && (z < 770) && (y > -370) && (y < 400)) {
280+
if (t == kEastTagger) {
215281
return true;
216282
}
217283
return false;
218284
}
219285

220-
bool sbnd::crt::CRTVetoProducer::inWest(const double &x, const double &y, const double &z)
286+
bool sbnd::crt::CRTVetoProducer::inWest(const CRTTagger t)
221287
{
222288
//west_sel = "x < -380 and z < 770 and -370 < y < 400"
223-
if ((x > 380) && (z < 770) && (y > -370) && (y < 400)) {
289+
if (t == kWestTagger) {
224290
return true;
225291
}
226292
return false;
227293
}
228294

229-
bool sbnd::crt::CRTVetoProducer::inTopLow(const double &x, const double &y, const double &z)
295+
bool sbnd::crt::CRTVetoProducer::inTopLow(const CRTTagger t)
230296
{
231-
if ((y > 400) && (y < 700)) {
297+
if (t == kTopLowTagger) {
232298
return true;
233299
}
234300
return false;
235301
}
236302

237-
bool sbnd::crt::CRTVetoProducer::inTopHigh(const double &x, const double &y, const double &z)
303+
bool sbnd::crt::CRTVetoProducer::inTopHigh(const CRTTagger t)
238304
{
239-
if (y > 700) {
305+
if (t == kTopHighTagger) {
240306
return true;
241307
}
242308
return false;

sbndcode/CRT/CRTVeto/crtvetoproducer_sbnd.fcl

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,19 @@ BEGIN_PROLOG
77
crtvetoproducer_sbnd:
88
{
99
CRTGeoAlg: @local::crtgeoalg_sbnd
10+
CRTClusterModuleLabel: "crtclustering"
1011
CRTSpacePointModuleLabel: "crtspacepoints"
11-
WindowStart: 0.4
12-
WindowEnd: 2.0
12+
WindowStart: 0.265
13+
WindowEnd: 1.965
14+
IsData: false
1315
module_type: "CRTVetoProducer"
1416
}
1517

1618
crtvetoproducer_data_sbnd: @local::crtvetoproducer_sbnd
1719
crtvetoproducer_data_sbnd.CRTGeoAlg: @local::crtgeoalg_data_sbnd
20+
crtvetoproducer_data_sbnd.IsData: true
21+
crtvetoproducer_data_sbnd.WindowStart: 0.365
22+
crtvetoproducer_data_sbnd.WindowEnd: 2.065
1823

1924

2025
END_PROLOG
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#include "crt_channel_map_service.fcl"
2+
#include "crt_calib_service.fcl"
3+
#include "run_crtveto.fcl"
4+
5+
services.message: @local::sbnd_message_services
6+
services.CRTChannelMapService: @local::crt_channel_map_standard
7+
services.CRTCalibService: @local::crt_calib_service
8+
9+
physics.producers.crtveto: @local::crtvetoproducer_data_sbnd
10+

0 commit comments

Comments
 (0)