clas12root
Loading...
Searching...
No Matches
particle_detector.h
Go to the documentation of this file.
1/*
2 * To change this license header, choose License Headers in Project Properties.
3 * To change this template file, choose Tools | Templates
4 * and open the template in the editor.
5 */
6
7/*
8 * File: particle_detector.h
9 * Author: dglazier
10 *
11 * Created on April 27, 2017, 10:01 AM
12 */
13
14#ifndef PARTICLE_DETECTOR_H
15#define PARTICLE_DETECTOR_H
16
17#include <iostream>
18#include <map>
19#include <algorithm>
20#include <string>
21#include <memory>
22#include "clas12defs.h"
23#include <hipo4/bank.h>
24
25
26namespace clas12 {
27
28 class particle_detector : public hipo::bank {
29
30
31 public:
32
33
35
36 particle_detector(hipo::schema __schema);
37
38 ~particle_detector() override=default;
39
41 //utiltiy functions, same for derived classes
42 void scanIndex();
43 std::vector<short > scanForParticle(short iparticle);
44 void readItems(const std::string& items);
45 bool useItem(const std::string& item);
46
48 //getter functions, same for derived classes
49 //get detector id
50 virtual int getDetector(int index) const noexcept{ return getByte(_detector_id_order,index);} //if the bank does not have a detector entry, you may inherit and chenge this getter.
51 virtual int getDetector() const noexcept{ return getByte(_detector_id_order,_index);}
52 //get the pindex = corresponding particle index
53 int getPindex(int index) const noexcept{ return getShort(_pindex_order,index);}
54 int getPindex() const noexcept{ return getShort(_pindex_order,_index);}
55
56 //given a detector (layer if exists) and pindex find the position in this bank
57 int getIndex() const noexcept{return _index;}
58 int getIndex(int pindex, int detector=0, int layer=0);
59
60 virtual void setIndex(int ind) const{_index=ind;}
61 void setBankEntry(short i){ _index=i;} //faster for BankHist
62 void setEntry(int ind) const{_index=ind;}
63
65 //virtual functions can be overridden in derived class
66 virtual int getLayer(int index) const noexcept{return 0;}
67 virtual int getLayer() const noexcept{return 0;}
68 virtual void print();
69
71 //override header notify, called at start of event
72 void notify() override {
73 if(_detector_id_order==-1) return;
74 bank::notify();
75 scanIndex();
76 }
77
78
79 protected:
80
83 mutable int _index=-1;
84
85 // std::map<int,int> _rmap;
86 std::vector<int> _rvec{};
87 std::vector<std::string > _sitems{};
88
89
90 };
91
92}
93
94#endif /* PARTICLE_DETECTOR_H */
Definition detector.h:45
std::vector< int > _rvec
Definition particle_detector.h:86
void notify() override
Definition particle_detector.h:72
virtual int getDetector() const noexcept
Definition particle_detector.h:51
void scanIndex()
Definition particle_detector.cpp:75
virtual int getLayer(int index) const noexcept
Definition particle_detector.h:66
virtual int getLayer() const noexcept
Definition particle_detector.h:67
int getPindex(int index) const noexcept
Definition particle_detector.h:53
void readItems(const std::string &items)
load items to be used
Definition particle_detector.cpp:22
std::vector< short > scanForParticle(short iparticle)
Definition particle_detector.cpp:40
~particle_detector() override=default
int _detector_id_order
Definition particle_detector.h:81
virtual void setIndex(int ind) const
Definition particle_detector.h:60
virtual int getDetector(int index) const noexcept
Definition particle_detector.h:50
virtual void print()
Definition particle_detector.cpp:57
void setEntry(int ind) const
Definition particle_detector.h:62
int _index
Definition particle_detector.h:83
int getIndex() const noexcept
Definition particle_detector.h:57
int _pindex_order
Definition particle_detector.h:82
void setBankEntry(short i)
Definition particle_detector.h:61
int getPindex() const noexcept
Definition particle_detector.h:54
std::vector< std::string > _sitems
Definition particle_detector.h:87
bool useItem(const std::string &item)
check if item should be used
Definition particle_detector.cpp:30
Definition calextras.cpp:10