All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Attributes | List of all members
CRTTrigFilter Class Reference
Inheritance diagram for CRTTrigFilter:

Public Member Functions

 CRTTrigFilter (fhicl::ParameterSet const &p)
 
virtual ~CRTTrigFilter ()
 
virtual bool filter (art::Event &e) override
 
void reconfigure (fhicl::ParameterSet const &p)
 

Private Attributes

art::ServiceHandle
< art::TFileService > 
tfs
 
std::string fCRTStripModuleLabel
 
std::vector< int > fmodlistUTopL
 
std::vector< int > fmodlistUBotL
 
std::vector< int > fmodlistUTopR
 
std::vector< int > fmodlistUBotR
 
std::vector< int > fmodlistDTopL
 
std::vector< int > fmodlistDBotL
 
std::vector< int > fmodlistDTopR
 
std::vector< int > fmodlistDBotR
 
bool fstripmatch
 
int fstripshift
 
int fedgecut
 
float fTimeCoinc
 
float fADCthresh
 
TH1F * hits
 
TH1F * trigt
 
TH1F * trig
 

Detailed Description

Definition at line 13 of file CRTTrigFilter_module.cc.

Constructor & Destructor Documentation

CRTTrigFilter::CRTTrigFilter ( fhicl::ParameterSet const &  p)
explicit

Definition at line 53 of file CRTTrigFilter_module.cc.

53  : EDFilter{p}
54  {
55 
56 
57  // Create histograms
58  hits = tfs->make<TH1F>("hits","hits",14,39.5,63.5);
59  // hits->GetXaxis()->SetTitle("Track Length (cm)");
60  trigt = tfs->make<TH1F>("trigt","trigt",200,-3000,3000); // trig time in us
61  trig = tfs->make<TH1F>("trig","trig",2,-0.5,1.5);
62 
63  this->reconfigure(p);
64  }
art::ServiceHandle< art::TFileService > tfs
void reconfigure(fhicl::ParameterSet const &p)
pdgs p
Definition: selectors.fcl:22
virtual CRTTrigFilter::~CRTTrigFilter ( )
inlinevirtual

Definition at line 22 of file CRTTrigFilter_module.cc.

22 { }

Member Function Documentation

bool CRTTrigFilter::filter ( art::Event &  e)
overridevirtual

Definition at line 86 of file CRTTrigFilter_module.cc.

87  {
88 
89  bool KeepMe = false;
90  int event = e.id().event();
91  if (event%1000==0) std::cout << "event " << event << std::endl;
92  // unsigned long long planeUtop, planeUbot, planeDtop, planeDbot;
93  uint64_t planeUtopL, planeUbotL, planeDtopL, planeDbotL;
94  uint64_t planeUtopR, planeUbotR, planeDtopR, planeDbotR;
95  uint64_t planeUpStL, planeDownStL;
96  uint64_t planeUpStR, planeDownStR;
97 
98  // uint64 planeUpSt,planeDownSt;
99 
100  int nstr=0;
101  art::Handle<std::vector<sbnd::crt::CRTData> > crtStripListHandle;
102  std::vector<art::Ptr<sbnd::crt::CRTData> > striplist;
103  if (e.getByLabel(fCRTStripModuleLabel, crtStripListHandle)) {
104  // if (e.getByLabel("crt", crtStripListHandle)) {
105  art::fill_ptr_vector(striplist, crtStripListHandle);
106  nstr = striplist.size();
107  }
108  // std::cout << "number of crt strips " << nstr << std::endl;
109 
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));
114  // std::cout << "left " << std::bitset<64>(edgecutL) << " right " << std::bitset<64>(edgecutR) << std::endl;
115  // left 0000000000000000000000000000000000000000000011111111111111111111
116  // right 0000000000000000000000000000000011111111111111111111000000000000
117 
118  float stripwidth = 11.2; //cm
119  float driftvel = 0.16; //cm/us
120 
121  // set cut limits on drift window time expectation of track from CRT hit.
122  float rwcut = fedgecut*stripwidth/driftvel;
123  float rwcutlow = -200.0 - rwcut;
124  float rwcuthigh = 1500.00 + rwcut;
125 
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.);
135  }
136 
137  //
138  for (int j = i+2; j<nstr; j+=2){
139  if ((striplist[j]->ADC()+striplist[j+1]->ADC())>fADCthresh) {
140  bool match = false;
141  uint32_t chan2 = striplist[j]->Channel();
142  int strip2 = (chan2 >> 1) & 15;
143  int module2 = (chan2>> 5);
144  //
145  uint32_t ttime2 = striplist[j]->T0();
146  // T0 in units of ticks, but clock frequency (16 ticks = 1 us) is wrong.
147  // ints were stored as uints, need to patch this up
148  float ctime2 = ttime2/16.;
149  if (ttime2 > 2147483648) {
150  ctime2 = ((ttime2-4294967296)/16.);
151  }
152  //
153  float diff = abs(ctime1-ctime2);
154  // if (diff<=fTimeCoinc && ctime1>-1300 && ctime1<1300) {
155  if (diff<=fTimeCoinc ) {
156 
157 
158  planeUtopL=0; planeUbotL=0; planeDtopL=0; planeDbotL=0;
159  planeUtopR=0; planeUbotR=0; planeDtopR=0; planeDbotR=0;
160  for (size_t im=0;im<fmodlistUTopL.size();++im) {
161  size_t iswap = fmodlistUTopL.size()-im-1;
162  if (module1==fmodlistUTopL[im]) planeUtopL+=(1 << ((15-strip1)+iswap*16));
163  if (module2==fmodlistUTopL[im]) planeUtopL+=(1 << ((15-strip2)+iswap*16));
164  }
165  for (size_t im=0;im<fmodlistUBotL.size();++im) {
166  size_t iswap = fmodlistUBotL.size()-im-1;
167  if (module1==fmodlistUBotL[im]) planeUbotL+=(1 << ((15-strip1)+iswap*16));
168  if (module2==fmodlistUBotL[im]) planeUbotL+=(1 << ((15-strip2)+iswap*16));
169  }
170  for (size_t im=0;im<fmodlistUTopR.size();++im) {
171  size_t iswap = fmodlistUTopR.size()-im-1;
172  if (module1==fmodlistUTopR[im]) planeUtopR+=(1 << ((15-strip1)+iswap*16));
173  if (module2==fmodlistUTopR[im]) planeUtopR+=(1 << ((15-strip2)+iswap*16));
174  }
175  for (size_t im=0;im<fmodlistUBotR.size();++im) {
176  size_t iswap = fmodlistUBotR.size()-im-1;
177  if (module1==fmodlistUBotR[im]) planeUbotR+=(1 << ((15-strip1)+iswap*16));
178  if (module2==fmodlistUBotR[im]) planeUbotR+=(1 << ((15-strip2)+iswap*16));
179  }
180  for (size_t im=0;im<fmodlistDTopL.size();++im) {
181  size_t iswap = fmodlistDTopL.size()-im-1;
182  if (module1==fmodlistDTopL[im]) planeDtopL+=(1 << ((15-strip1)+iswap*16));
183  if (module2==fmodlistDTopL[im]) planeDtopL+=(1 << ((15-strip2)+iswap*16));
184  }
185  for (size_t im=0;im<fmodlistDBotL.size();++im) {
186  size_t iswap = fmodlistDBotL.size()-im-1;
187  if (module1==fmodlistDBotL[im]) planeDbotL+=(1 << ((15-strip1)+iswap*16));
188  if (module2==fmodlistDBotL[im]) planeDbotL+=(1 << ((15-strip2)+iswap*16));
189  }
190  for (size_t im=0;im<fmodlistDTopR.size();++im) {
191  size_t iswap = fmodlistDTopR.size()-im-1;
192  if (module1==fmodlistDTopR[im]) planeDtopR+=(1 << ((15-strip1)+iswap*16));
193  if (module2==fmodlistDTopR[im]) planeDtopR+=(1 << ((15-strip2)+iswap*16));
194  }
195  for (size_t im=0;im<fmodlistDBotR.size();++im) {
196  size_t iswap = fmodlistDBotR.size()-im-1;
197  if (module1==fmodlistDBotR[im]) planeDbotR+=(1 << ((15-strip1)+iswap*16));
198  if (module2==fmodlistDBotR[im]) planeDbotR+=(1 << ((15-strip2)+iswap*16));
199  }
200 
201  planeUpStL = planeUtopL | planeUbotL;
202  planeUpStR = planeUtopR | planeUbotR;
203  planeDownStL = planeDtopL | planeDbotL;
204  planeDownStR = planeDtopR | planeDbotR;
205  if ((planeUpStR & edgecutR) && (planeDownStR & edgecutR)) {
206 
207  if ( planeUpStR & planeDownStR ) match=true;
208  for (int is=1;is<=fstripshift;++is) {
209  uint64_t temp; temp=(planeUpStR << is);
210  if (temp & planeDownStR) match=true;
211  temp=(planeDownStR << is);
212  if (temp & planeUpStR) match=true;
213  }
214  }
215  if ((planeUpStL & edgecutL) && (planeDownStL & edgecutL)) {
216  if ( planeUpStL & planeDownStL ) match=true;
217  for (int is=1;is<=fstripshift;++is) {
218  uint64_t temp; temp=(planeUpStL << is);
219  if (temp & planeDownStL) match=true;
220  temp=(planeDownStL << is);
221  if (temp & planeUpStL) match=true;
222  }
223  }
224  if (match) {
225  // std::cout << " before drift window cut " << std::endl;
226  // std::cout << " module and strip 1 " << module1 << " " << strip1 << std::endl;
227  // std::cout << " module and strip 2 " << module2 << " " << strip2 << std::endl;
228  // std::cout << " upstream " << std::bitset<64>(planeUpStR) <<
229  // std::endl << "downstream " << std::bitset<64>(planeDownStR) <<
230  // std::endl;
231  // std::cout << " ----------------------------------" << std::endl;
232  float xpos; // in cm
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;
235  float dtime; // in us
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;
239  // std::cout << "Event " << event << " " << module1 << " " << xpos << " " << ctime1 << " " << dtime << std::endl;
240  }
241  }
242  if (match) {
243  // std::cout << "Found One! Event " << event <<
244  // " m/s1 m/s2 " << module1 << " " << strip1 << " " <<
245  // module2 << " " << strip2 << " " << ctime1 << " " <<ctime2 << std::endl;
246  KeepMe=true;
247  }
248  }} // end loop over second strip
249  }} // end loop over first strip
250  if (trigKeep) trig->Fill(1.0); else trig->Fill(0.0);
251  return KeepMe;
252 
253  }
std::vector< int > fmodlistUBotL
std::vector< int > fmodlistUBotR
std::vector< int > fmodlistDBotL
T abs(T value)
std::vector< int > fmodlistDTopL
std::string fCRTStripModuleLabel
std::vector< int > fmodlistDTopR
std::vector< int > fmodlistUTopL
std::vector< int > fmodlistUTopR
do i e
std::vector< int > fmodlistDBotR
BEGIN_PROLOG could also be cout
void CRTTrigFilter::reconfigure ( fhicl::ParameterSet const &  p)

Definition at line 66 of file CRTTrigFilter_module.cc.

67  {
68 
69  fCRTStripModuleLabel = p.get< std::string >("CRTStripModuleLabel","crt");
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);
79  fstripshift = p.get<int>("AllowedStripShift",4);
80  fedgecut = p.get<int>("EdgeCutInStrips",12);
81  if (fedgecut>31) fedgecut=31;
82  fTimeCoinc = p.get<float>("StripTimeCoincidence",0.2);
83  fADCthresh = p.get<float>("ADCthresh",500.0);
84  }
pdgs p
Definition: selectors.fcl:22
std::vector< int > fmodlistUBotL
std::vector< int > fmodlistUBotR
std::vector< int > fmodlistDBotL
std::vector< int > fmodlistDTopL
std::string fCRTStripModuleLabel
std::vector< int > fmodlistDTopR
std::vector< int > fmodlistUTopL
std::vector< int > fmodlistUTopR
std::vector< int > fmodlistDBotR

Member Data Documentation

float CRTTrigFilter::fADCthresh
private

Definition at line 44 of file CRTTrigFilter_module.cc.

std::string CRTTrigFilter::fCRTStripModuleLabel
private

Definition at line 31 of file CRTTrigFilter_module.cc.

int CRTTrigFilter::fedgecut
private

Definition at line 42 of file CRTTrigFilter_module.cc.

std::vector<int> CRTTrigFilter::fmodlistDBotL
private

Definition at line 37 of file CRTTrigFilter_module.cc.

std::vector<int> CRTTrigFilter::fmodlistDBotR
private

Definition at line 39 of file CRTTrigFilter_module.cc.

std::vector<int> CRTTrigFilter::fmodlistDTopL
private

Definition at line 36 of file CRTTrigFilter_module.cc.

std::vector<int> CRTTrigFilter::fmodlistDTopR
private

Definition at line 38 of file CRTTrigFilter_module.cc.

std::vector<int> CRTTrigFilter::fmodlistUBotL
private

Definition at line 33 of file CRTTrigFilter_module.cc.

std::vector<int> CRTTrigFilter::fmodlistUBotR
private

Definition at line 35 of file CRTTrigFilter_module.cc.

std::vector<int> CRTTrigFilter::fmodlistUTopL
private

Definition at line 32 of file CRTTrigFilter_module.cc.

std::vector<int> CRTTrigFilter::fmodlistUTopR
private

Definition at line 34 of file CRTTrigFilter_module.cc.

bool CRTTrigFilter::fstripmatch
private

Definition at line 40 of file CRTTrigFilter_module.cc.

int CRTTrigFilter::fstripshift
private

Definition at line 41 of file CRTTrigFilter_module.cc.

float CRTTrigFilter::fTimeCoinc
private

Definition at line 43 of file CRTTrigFilter_module.cc.

TH1F* CRTTrigFilter::hits
private

Definition at line 47 of file CRTTrigFilter_module.cc.

art::ServiceHandle<art::TFileService> CRTTrigFilter::tfs
private

Definition at line 29 of file CRTTrigFilter_module.cc.

TH1F* CRTTrigFilter::trig
private

Definition at line 49 of file CRTTrigFilter_module.cc.

TH1F* CRTTrigFilter::trigt
private

Definition at line 48 of file CRTTrigFilter_module.cc.


The documentation for this class was generated from the following file: