Skip to content

Commit

Permalink
Merge pull request #846 in B2/basf2 from bugfix/BII-8733-neurotrigger…
Browse files Browse the repository at this point in the history
…-unpacker-and-nnta-rel to release/06-01

* commit 'a065e547869d024e41cabf49fc6ab2acfea9cae4':
  fix classversion of cdctriggertrack
  fix some compiler warnings
  add etf timing to cdctriggerneuroinput2dfindetracks
  fix errors in nntd script
  add hwneurovals to nntd module (neurotrigger)
  add 2 timing sources to neurotrack: etfcc, etfhwin
  add new quality flags for nnt in unpacker
  update nntscripts, add nntd script, fix nnt code
  fix classversion of cdctriggertrack
  +debug info, fix t0 calculation
  neurotrigger: remove some consts to fix code
  +etf in nnt, +raw hwvals in tracks, mod tsvector
  • Loading branch information
GiacomoXT committed Jun 4, 2022
2 parents 63a7335 + a065e54 commit 6654659
Show file tree
Hide file tree
Showing 12 changed files with 736 additions and 228 deletions.
69 changes: 59 additions & 10 deletions trg/cdc/dataobjects/include/CDCTriggerTrack.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace Belle2 {
public:
/** default constructor, initializing everything to 0. */
CDCTriggerTrack(): Helix(), m_chi2D(0.), m_chi3D(0.), m_time(0), m_quadrant(-1), m_foundoldtrack(6, false), m_driftthreshold(9,
false), m_valstereobit(false) , m_expert(-1), m_tsvector(9, false), m_qualityvector(0) { }
false), m_valstereobit(false) , m_expert(-1), m_tsvector(9, 0), m_qualityvector(0) { }

/** 2D constructor, initializing 3D values to 0.
* @param phi0 The angle between the transverse momentum and the x axis and in [-pi, pi].
Expand All @@ -45,7 +45,7 @@ namespace Belle2 {
m_driftthreshold(driftthreshold),
m_valstereobit(valstereobit),
m_expert(expert),
m_tsvector(9, false),
m_tsvector(9, 0),
m_qualityvector(0) { }

CDCTriggerTrack(double phi0, double omega, double chi2,
Expand All @@ -58,7 +58,7 @@ namespace Belle2 {
m_driftthreshold(9, false),
m_valstereobit(false),
m_expert(-1),
m_tsvector(9, false),
m_tsvector(9, 0),
m_qualityvector(0) { }

/** 3D constructor
Expand All @@ -77,7 +77,7 @@ namespace Belle2 {
const std::vector<bool>& driftthreshold = std::vector<bool>(9, false),
bool valstereobit = false,
int expert = -1,
const std::vector<bool>& tsvector = std::vector<bool>(9, false),
const std::vector<unsigned>& tsvector = std::vector<unsigned>(9, 0),
short time = 0, short quadrant = -1,
unsigned qualityvector = 0):
Helix(0., phi0, omega, z0, cotTheta), m_chi2D(chi2D), m_chi3D(chi3D), m_time(time), m_quadrant(quadrant),
Expand All @@ -86,7 +86,9 @@ namespace Belle2 {
m_valstereobit(valstereobit),
m_expert(expert),
m_tsvector(tsvector),
m_qualityvector(qualityvector) { }
m_qualityvector(qualityvector),
m_etf_unpacked(0),
m_etf_recalced(0) { }
/** destructor, empty because we don't allocate memory anywhere. */
~CDCTriggerTrack() { }

Expand All @@ -106,7 +108,7 @@ namespace Belle2 {
return getTransverseMomentum(bField);
}
/** get the quadrant */
short getQuadrant()
short getQuadrant() const
{
return m_quadrant;
}
Expand All @@ -124,7 +126,7 @@ namespace Belle2 {

/** return the vector of used Track Segments.
* The First bit is the innermost TS, the last bit the outermost. */
std::vector<bool> getTSVector() const {return m_tsvector;}
std::vector<unsigned> getTSVector() const {return m_tsvector;}
/** setter and getter for the quality vector. For the setter, the given
* uint is xored with the current qualityvector, thus all bits with
* a 1 are changed.
Expand All @@ -134,9 +136,36 @@ namespace Belle2 {
m_qualityvector = m_qualityvector ^ newbits;
}
unsigned getQualityVector() const {return m_qualityvector;}
void setHasETFTime(bool x) {m_hasETFTime = x;}
bool getHasETFTime() const {return m_hasETFTime;}
/** getter and setter functions for etf timing */
int getETF_unpacked() const {return m_etf_unpacked;}
int getETF_recalced() const {return m_etf_recalced;}
void setETF_unpacked(int x) {m_etf_unpacked = x;}
void setETF_recalced(int x) {m_etf_recalced = x;}
/** setter and getter functions for raw track values */
void setRawPhi0(const int phi0)
{
m_rawphi0 = phi0;
}
void setRawOmega(const int omega)
{
m_rawomega = omega;
}
void setRawZ(const int z)
{
m_rawz = z;
}
void setRawTheta(const int theta)
{
m_rawtheta = theta;
}
int getRawPhi0() const {return m_rawphi0;}
int getRawOmega() const {return m_rawomega;}
int getRawZ() const {return m_rawz;}
int getRawTheta() const {return m_rawtheta;}

protected:
/** chi2 value from 2D fitter */
float m_chi2D;
/** chi2 value from 3D fitter */
float m_chi3D;
Expand All @@ -154,13 +183,33 @@ namespace Belle2 {
int m_expert;
/** store which track segments were used.
* The First bit is the innermost TS, the last bit the outermost. */
std::vector<bool> m_tsvector;
std::vector<unsigned> m_tsvector;
/** store bits for different quality flags.
* 2^0 : 0 if all axial ts are contained in the related 2dfindertrack; 1 otherwise.
* 2^1 : 0 if hwsim nntrack is less than 1cm in z away from hwtrack; 1 otherwise.
* 2^2 : 0 if all input values for the ID are exactly the same in hw and hwsim; 1 otherwise.
* 2^3 : 0 if all input values for alpa are exactly the same in hw and hwsim; 1 otherwise.
* 2^4 : 1 if dt in hw/hwsim is 0 and in hwsim/hw is 1; 0 otherwise.
* 2^5 : 1 if all inputs in hw are 0 but at least 1 is filled in hwsim; 0 otherwise.
* 2^6 : 1 if all inputs in hwsim are 0 but at least 1 is filled in hw; 0 otherwise.
* 2^7 : 1 if more than 1 etf time was recalculated from hw. this indicates, that an old input
* from a previous track was used in the network.
*/
unsigned m_qualityvector;
/** unpacked etf time from the unpacker */
int m_etf_unpacked;
/** etf time recalculated from the hw input */
int m_etf_recalced;
/** chi2 value from 2D fitter */
bool m_hasETFTime{0};
/** values to store the raw network and 2dfinder output */
int m_rawphi0{0};
int m_rawomega{0};
int m_rawz{0};
int m_rawtheta{0};
//! Needed to make the ROOT object storable
ClassDef(CDCTriggerTrack, 9);
ClassDef(CDCTriggerTrack, 14);

};
}
#endif
2 changes: 1 addition & 1 deletion trg/cdc/dataobjects/include/linkdef.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#pragma link C++ class bitset <639>+; // checksum=0x88f24d, version=2
#pragma link C++ class bitset <256>+; // checksum=0x88f1ea, version=2
#pragma link C++ class Belle2::CDCTriggerSegmentHit+; // checksum=0x89ed4679, version=4
#pragma link C++ class Belle2::CDCTriggerTrack+; // checksum=0x589cc554, version=9
#pragma link C++ class Belle2::CDCTriggerTrack+; // checksum=0xdde6f688, version=14
#pragma link C++ class Belle2::CDCTriggerMLP+; // checksum=0x2d137aa, version=7
#pragma link C++ class Belle2::CDCTriggerMLPData+; // checksum=0x48969a58, version=1
#pragma link C++ class Belle2::CDCTriggerMLPInput+; // checksum=0x6fd59940, version=1
Expand Down
6 changes: 5 additions & 1 deletion trg/cdc/include/NeuroTrigger.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
**************************************************************************/
#ifndef NEUROTRIGGER_H
#define NEUROTRIGGER_H

#pragma once
#include <string>
#include <trg/cdc/dataobjects/CDCTriggerMLP.h>
#include <framework/datastore/StoreArray.h>
#include <framework/datastore/StoreObjPtr.h>
Expand Down Expand Up @@ -142,6 +143,7 @@ namespace Belle2 {
/** set the hit collection and event time to required
* and store the hit collection name */
void initializeCollections(std::string hitCollectionName, std::string eventTimeName, const std::string& et_option);
void initializeCollections(std::string hitCollectionName);

/** return reference to a neural network */
CDCTriggerMLP& operator[](unsigned index) { return m_MLPs[index]; }
Expand Down Expand Up @@ -179,6 +181,8 @@ namespace Belle2 {
/** Calculate phi position of a hit relative to 2D track
* (scaled to number of wires). */
double getRelId(const CDCTriggerSegmentHit& hit);
/** helper function to get the fastest priority time of given ts array */
int getLowestTime(unsigned isector, RelationVector<CDCTriggerSegmentHit> Hits, bool onlyAxials);
/** Read out the event time and store it.
* It can be given different options in the et_option ("EventTime option")
* parameter.
Expand Down
Loading

0 comments on commit 6654659

Please sign in to comment.