3 #include "art/Framework/Core/EDFilter.h"
4 #include "art/Framework/Core/ModuleMacros.h"
5 #include "art/Framework/Principal/Event.h"
7 #include "art_root_io/TFileService.h"
23 virtual bool filter(art::Event&
e)
override;
29 art::ServiceHandle<art::TFileService>
tfs;
58 hits =
tfs->make<TH1F>(
"hits",
"hits",14,39.5,63.5);
60 trigt =
tfs->make<TH1F>(
"trigt",
"trigt",200,-3000,3000);
61 trig =
tfs->make<TH1F>(
"trig",
"trig",2,-0.5,1.5);
70 fmodlistUTopL = p.get<std::vector<int>>(
"ModuleListUpstreamTopLeft");
71 fmodlistUBotL = p.get<std::vector<int>>(
"ModuleListUpstreamBotLeft");
72 fmodlistUTopR = p.get<std::vector<int>>(
"ModuleListUpstreamTopRight");
73 fmodlistUBotR = p.get<std::vector<int>>(
"ModuleListUpstreamBotRight");
74 fmodlistDTopL = p.get<std::vector<int>>(
"ModuleListDownstreamTopLeft");
75 fmodlistDBotL = p.get<std::vector<int>>(
"ModuleListDownstreamBotLeft");
76 fmodlistDTopR = p.get<std::vector<int>>(
"ModuleListDownstreamTopRight");
77 fmodlistDBotR = p.get<std::vector<int>>(
"ModuleListDownstreamBotRight");
78 fstripmatch = p.get<
bool>(
"RequireStripMatch",
true);
80 fedgecut = p.get<
int>(
"EdgeCutInStrips",12);
81 if (fedgecut>31) fedgecut=31;
82 fTimeCoinc = p.get<
float>(
"StripTimeCoincidence",0.2);
90 int event = e.id().event();
91 if (event%1000==0)
std::cout <<
"event " <<
event << std::endl;
93 uint64_t planeUtopL, planeUbotL, planeDtopL, planeDbotL;
94 uint64_t planeUtopR, planeUbotR, planeDtopR, planeDbotR;
95 uint64_t planeUpStL, planeDownStL;
96 uint64_t planeUpStR, planeDownStR;
101 art::Handle<std::vector<sbnd::crt::CRTData> > crtStripListHandle;
102 std::vector<art::Ptr<sbnd::crt::CRTData> > striplist;
105 art::fill_ptr_vector(striplist, crtStripListHandle);
106 nstr = striplist.size();
110 bool trigKeep =
false;
111 uint64_t edgecutL,edgecutR;
112 edgecutR = ~((uint64_t)(pow(2,
fedgecut)-1) | ((uint64_t)(pow(2,32)-1)<< 32));
113 edgecutL = ~(((uint64_t)(pow(2,
fedgecut)-1) << (32-
fedgecut))| ((uint64_t)(pow(2,32)-1) <<32));
118 float stripwidth = 11.2;
119 float driftvel = 0.16;
122 float rwcut =
fedgecut*stripwidth/driftvel;
123 float rwcutlow = -200.0 - rwcut;
124 float rwcuthigh = 1500.00 + rwcut;
126 for (
int i = 0; i<nstr-2; i+=2){
127 if ((striplist[i]->ADC()+striplist[i+1]->ADC())>
fADCthresh) {
128 uint32_t chan1 = striplist[i]->Channel();
129 int strip1 = (chan1 >> 1) & 15;
130 int module1 = (chan1>> 5);
131 uint32_t ttime1 = striplist[i]->T0();
132 float ctime1 = ttime1/16.;
133 if (ttime1 > 2147483648) {
134 ctime1 = ((ttime1-4294967296)/16.);
138 for (
int j = i+2; j<nstr; j+=2){
139 if ((striplist[j]->ADC()+striplist[j+1]->ADC())>
fADCthresh) {
141 uint32_t chan2 = striplist[j]->Channel();
142 int strip2 = (chan2 >> 1) & 15;
143 int module2 = (chan2>> 5);
145 uint32_t ttime2 = striplist[j]->T0();
148 float ctime2 = ttime2/16.;
149 if (ttime2 > 2147483648) {
150 ctime2 = ((ttime2-4294967296)/16.);
153 float diff =
abs(ctime1-ctime2);
158 planeUtopL=0; planeUbotL=0; planeDtopL=0; planeDbotL=0;
159 planeUtopR=0; planeUbotR=0; planeDtopR=0; planeDbotR=0;
162 if (module1==
fmodlistUTopL[im]) planeUtopL+=(1 << ((15-strip1)+iswap*16));
163 if (module2==
fmodlistUTopL[im]) planeUtopL+=(1 << ((15-strip2)+iswap*16));
167 if (module1==
fmodlistUBotL[im]) planeUbotL+=(1 << ((15-strip1)+iswap*16));
168 if (module2==
fmodlistUBotL[im]) planeUbotL+=(1 << ((15-strip2)+iswap*16));
172 if (module1==
fmodlistUTopR[im]) planeUtopR+=(1 << ((15-strip1)+iswap*16));
173 if (module2==
fmodlistUTopR[im]) planeUtopR+=(1 << ((15-strip2)+iswap*16));
177 if (module1==
fmodlistUBotR[im]) planeUbotR+=(1 << ((15-strip1)+iswap*16));
178 if (module2==
fmodlistUBotR[im]) planeUbotR+=(1 << ((15-strip2)+iswap*16));
182 if (module1==
fmodlistDTopL[im]) planeDtopL+=(1 << ((15-strip1)+iswap*16));
183 if (module2==
fmodlistDTopL[im]) planeDtopL+=(1 << ((15-strip2)+iswap*16));
187 if (module1==
fmodlistDBotL[im]) planeDbotL+=(1 << ((15-strip1)+iswap*16));
188 if (module2==
fmodlistDBotL[im]) planeDbotL+=(1 << ((15-strip2)+iswap*16));
192 if (module1==
fmodlistDTopR[im]) planeDtopR+=(1 << ((15-strip1)+iswap*16));
193 if (module2==
fmodlistDTopR[im]) planeDtopR+=(1 << ((15-strip2)+iswap*16));
197 if (module1==
fmodlistDBotR[im]) planeDbotR+=(1 << ((15-strip1)+iswap*16));
198 if (module2==
fmodlistDBotR[im]) planeDbotR+=(1 << ((15-strip2)+iswap*16));
201 planeUpStL = planeUtopL | planeUbotL;
202 planeUpStR = planeUtopR | planeUbotR;
203 planeDownStL = planeDtopL | planeDbotL;
204 planeDownStR = planeDtopR | planeDbotR;
205 if ((planeUpStR & edgecutR) && (planeDownStR & edgecutR)) {
207 if ( planeUpStR & planeDownStR ) match=
true;
209 uint64_t temp; temp=(planeUpStR << is);
210 if (temp & planeDownStR) match=
true;
211 temp=(planeDownStR << is);
212 if (temp & planeUpStR) match=
true;
215 if ((planeUpStL & edgecutL) && (planeDownStL & edgecutL)) {
216 if ( planeUpStL & planeDownStL ) match=
true;
218 uint64_t temp; temp=(planeUpStL << is);
219 if (temp & planeDownStL) match=
true;
220 temp=(planeDownStL << is);
221 if (temp & planeUpStL) match=
true;
233 if (module1<module2) xpos=((int(module1/2)-20)*16+strip1+0.5)*stripwidth-358.4;
234 else xpos=((int(module2/2)-20)*16+strip2+0.5)*stripwidth-358.4;
236 if (xpos>0) dtime = ctime1+((200.0-xpos)/driftvel);
237 else dtime = ctime1+((200.0+xpos)/driftvel);
238 if (dtime<rwcutlow || dtime>rwcuthigh ) match=
false;
250 if (trigKeep)
trig->Fill(1.0);
else trig->Fill(0.0);
art::ServiceHandle< art::TFileService > tfs
void reconfigure(fhicl::ParameterSet const &p)
std::vector< int > fmodlistUBotL
std::vector< int > fmodlistUBotR
std::vector< int > fmodlistDBotL
virtual bool filter(art::Event &e) override
std::vector< int > fmodlistDTopL
std::string fCRTStripModuleLabel
std::vector< int > fmodlistDTopR
std::vector< int > fmodlistUTopL
CRTTrigFilter(fhicl::ParameterSet const &p)
std::vector< int > fmodlistUTopR
art::ServiceHandle< art::TFileService > tfs
std::vector< int > fmodlistDBotR
BEGIN_PROLOG could also be cout