21 #include "canvas/Persistency/Common/FindManyP.h" 22 #include "art_root_io/TFileService.h" 29 #include "nug4/ParticleNavigation/ParticleList.h" 63 class CRTTimingValidation;
85 bool moduleCheckX(
int module);
86 int moduletoCTB(
int module2,
int module1);
88 void endJob()
override;
101 int matchedCTBtoCRT=0;
156 EDAnalyzer(p), fCRTLabel(p.
get <
art::InputTag > (
"CRTLabel")), fCTBLabel(p.
get<
art::InputTag>(
"CTBLabel")) {
157 consumes < std::vector < CRT::Trigger >> (
fCRTLabel);
158 consumes < std::vector < art::Assns < sim::AuxDetSimChannel, CRT::Trigger >>> (
fCRTLabel);
167 if (module==4 || module==5 || module==6 || module==7 || module==8 || module==9 || module==10 || module==11 || module==20 || module==21 || module==22 || module==23 || module==24 || module==25 || module==26 || module==27)
return 1;
173 if (module1 == 13 && module2 == 6 )
return 15;
174 else if (module1 == 13 && module2 == 7)
return 10;
175 else if (module1 == 1 && module2 == 6)
return 8;
176 else if (module1 == 1 && module2 == 7)
return 9;
177 else if (module1 == 16 && module2 == 20)
return 4;
178 else if (module1 == 16 && module2 == 21)
return 13;
179 else if (module1 == 28 && module2 == 20)
return 3;
180 else if (module1 == 28 && module2 == 21)
return 2;
181 else if (module1 == 29 && module2 == 22)
return 1;
182 else if (module1 == 29 && module2 == 23)
return 0;
183 else if (module1 == 17 && module2 == 22)
return 12;
184 else if (module1 == 17 && module2 == 23)
return 11;
185 else if (module1 == 0 && module2 == 5)
return 7;
186 else if (module1 == 0 && module2 == 4)
return 6;
187 else if (module1 == 12 && module2 == 5)
return 14;
188 else if (module1 == 12 && module2 == 4)
return 5;
189 else if (module1 == 3 && module2 == 8)
return 25;
190 else if (module1 == 3 && module2 == 9)
return 24;
191 else if (module1 == 15 && module2 == 8)
return 26;
192 else if (module1 == 15 && module2 == 9)
return 31;
193 else if (module1 == 18 && module2 == 26)
return 27;
194 else if (module1 == 18 && module2 == 27)
return 28;
195 else if (module1 == 30 && module2 == 26)
return 16;
196 else if (module1 == 30 && module2 == 27)
return 17;
197 else if (module1 == 31 && module2 == 24)
return 18;
198 else if (module1 == 31 && module2 == 25)
return 19;
199 else if (module1 == 19 && module2 == 24)
return 29;
200 else if (module1 == 19 && module2 == 25)
return 20;
201 else if (module1 == 14 && module2 == 10)
return 30;
202 else if (module1 == 14 && module2 == 11)
return 21;
203 else if (module1 == 2 && module2 == 10)
return 23;
204 else if (module1 == 2 && module2 == 11)
return 22;
222 if(timeStamp.
GetFlags()!= 13)
return;
255 const auto & triggers =
event.getValidHandle < std::vector < CRT::Trigger >> (
fCRTLabel);
257 art::FindManyP < sim::AuxDetSimChannel > trigToSim(triggers, event,
fCRTLabel);
263 std::unordered_map < size_t, double > prevTimes;
267 for (
const auto &
trigger: * triggers) {
276 const auto & trigGeo = geom -> AuxDet(
trigger.Channel());
277 const auto & csens = trigGeo.SensitiveVolume(0);
278 const auto center = csens.GetCenter();
285 for (
unsigned int i=0; i <
trigger_F_X.size(); i++){
286 for (
unsigned int j=0; j <
trigger_F_Y.size(); j++){
300 for(
const auto&
time: *timingHandle)
303 const timestamp_t& rawTime =
time.GetTimeStamp();
304 const auto deltaT = rawTime - (
trigger_F_X[i].triggerTime);
306 if(fabs(deltaT) < fabs(minDeltaT)) minDeltaT = deltaT;
331 for(
const auto&
time: *timingHandle)
333 const timestamp_t& rawTime =
time.GetTimeStamp();
334 const auto deltaT = rawTime - (
trigger_B_X[i].triggerTime);
335 if(fabs(deltaT) < fabs(minDeltaT)) minDeltaT=deltaT;
344 const auto& pdspctbs = *
event.getValidHandle<std::vector<raw::ctb::pdspctb>>(
fCTBLabel);
345 std::vector<int> uS, dS;
352 const size_t npdspctbs = pdspctbs.size();
353 for(
size_t j=0;j<npdspctbs;++j)
355 const std::vector<raw::ctb::Trigger> HLTriggers = pdspctbs[j].GetHLTriggers();
356 const std::vector<raw::ctb::ChStatus> chs = pdspctbs[j].GetChStatusAfterHLTs();
357 for (
size_t k=0;
k<HLTriggers.size(); ++
k)
365 dS.clear(); uS.clear();
367 int num = chs[
k].crt;
378 const auto crtmask=chs[
k].crt;
382 for (
int i = 0; i<32; ++i){
383 if (crtmask & (1<<i)){
392 if (pixel0!=-1 && pixel1!=1) {
396 cout<<
nEvents<<
" TJYang Pixels: "<<pixel0<<
","<<pixel1<<
endl;
411 for (
unsigned int i=0; i<
hits_F.size(); i++){
412 for (
unsigned int j=0; j<
hits_B.size(); j++){
440 fCRTTreeF = fileServiceHandle->make<TTree>(
"T_F",
"event by event info");
441 fCRTTreeB = fileServiceHandle->make<TTree>(
"T_B",
"event by event info");
443 fCRTTree = fileServiceHandle->make<TTree>(
"Matching TOF",
"event by event info");
447 fCRTTreeB->Branch(
"nEvents", &
nEvents,
"nEvents/I");
448 fCRTTree->Branch(
"nEvents", &
nEvents,
"nEvents/I");
450 fCRTTreeB->Branch(
"minDeltaT_B", &
RDminDeltaT_B,
"RDminDeltaT_B/D");
453 fCRTTreeB->Branch(
"T0Offset_B", &
T0Offset_B,
"T0Offset_B/I");
457 fCRTTreeB->Branch(
"hmoduleX_B", &
moduleX_B,
"moduleX_B/I");
460 fCRTTreeB->Branch(
"hmoduleY_B", &
moduleY_B,
"moduleY_B/I");
462 fCRTTree->Branch(
"CRT_TOF", &
CRT_TOF,
"CRT_TOF/D");
463 fCRTTree->Branch(
"T_B", &
T_B,
"T_B/D");
464 fCRTTree->Branch(
"T_F", &
T_F,
"T_F/D");
467 fCRTTree->Branch(
"hmoduleX_F", &
moduleX_F,
"moduleX_F/I");
468 fCRTTree->Branch(
"hmoduleX_B", &
moduleX_B,
"moduleX_B/I");
469 fCRTTree->Branch(
"hmoduleY_F", &
moduleY_F,
"moduleY_F/I");
470 fCRTTree->Branch(
"hmoduleY_B", &
moduleY_B,
"moduleY_B/I");
std::vector< tempHits > hits_F
def analyze(root, level, gtrees, gbranches, doprint)
int moduletoCTB(int module2, int module1)
uint16_t GetFlags() const
bool moduleCheckX(int module)
std::vector< tempTrigger > trigger_B_X
std::vector< tempTrigger > trigger_F_X
std::vector< tempTrigger > trigger_B_Y
art framework interface to geometry description
#define DEFINE_ART_MODULE(klass)
T get(std::string const &key) const
struct ptb::content::word::timestamp_t timestamp_t
CRTTimingValidation(fhicl::ParameterSet const &p)
std::vector< ctbHits > ctbTriggers
Declaration of signal hit object.
Provides recob::Track data product.
std::vector< tempHits > hits_B
auto const & get(AssnsNode< L, R, D > const &r)
std::vector< tempTrigger > trigger_F_Y
std::string to_string(ModuleType const mt)
void analyze(art::Event const &e) override
QTextStream & endl(QTextStream &s)
Event finding and building.