6 #include "GM_SubLibrary.h"
13 static constexpr
double Re = 6372.795477598e5;
15 template <
typename ValueType,
long unsigned int N>
16 constexpr
int FindBin(ValueType value,
const std::array<ValueType, N> &bins) {
17 auto binIt = std::lower_bound(
begin(bins),
end(bins), value, std::less_equal<ValueType>());
18 return binIt ==
end(bins) ? -1 : std::distance(
begin(bins), binIt) - 1;
21 template <
typename ValueType>
22 int FindBin(ValueType value,
const std::map<
unsigned int, std::pair<ValueType, ValueType>> &bins) {
23 auto binIt = std::find_if(
begin(bins),
end(bins),
24 [&value](
auto it) {
return (value >= it.second.first && value < it.second.second); });
25 return binIt ==
end(bins) ? -1 : binIt->first;
29 BetaHR *beta = part->pBetaH();
31 TrTrackR *trk = part->pTrTrack();
35 constexpr
int refit = 31;
36 constexpr
int fit_algo = 1;
37 int id_max = trk->iTrTrackPar(fit_algo, 0, refit);
41 bool hasinnery =
false;
42 bool L2y =
false, L34y =
false, L56y =
false, L78y =
false;
43 TrRecHitR *trkHit =
nullptr;
44 trkHit = trk->GetHitLJ(2);
46 if (trkHit->pTrCluster(
'y')) {
49 trkHit = trk->GetHitLJ(3);
51 if (trkHit->pTrCluster(
'y')) {
54 trkHit = trk->GetHitLJ(4);
56 if (trkHit->pTrCluster(
'y')) {
59 trkHit = trk->GetHitLJ(5);
61 if (trkHit->pTrCluster(
'y')) {
64 trkHit = trk->GetHitLJ(6);
66 if (trkHit->pTrCluster(
'y')) {
69 trkHit = trk->GetHitLJ(7);
71 if (trkHit->pTrCluster(
'y')) {
74 trkHit = trk->GetHitLJ(8);
76 if (trkHit->pTrCluster(
'y')) {
79 if (L2y && L34y && L56y && L78y)
82 float chi2 = trk->GetNormChisqY(id_max);
83 if (!beta || beta->GetSumHit() < 4 || !trk || id_max < 0 || !hasinnery || chi2 < 0 || chi2 > 10)
89 void RTIInfo::Fill(AMSSetupR::RTI *rtiPtr,
unsigned int runTag) {
96 Theta = rtiPtr->theta;
112 for (
unsigned int i = 0; i < 4; i++) {
113 for (
unsigned int j = 0; j < 2; j++) {
122 AMSPoint pn1, pn9, pd1, pd9;
123 AMSEventR::GetRTIdL1L9(0, pn1, pd1,
UTCTime, 60);
124 AMSEventR::GetRTIdL1L9(1, pn9, pd9,
UTCTime, 60);
125 MeanAlignDiffExtLayer[0] = {
static_cast<float>(pd1.x()), static_cast<float>(pd1.y()), static_cast<float>(pd1.z())};
126 MeanAlignDiffExtLayer[1] = {
static_cast<float>(pd9.x()), static_cast<float>(pd9.y()), static_cast<float>(pd9.z())};
140 AMSSetupR::DSPError dsperr;
143 for (
int inode = 0x80; inode < 0x88; inode++)
144 if (dsperr.SearchNA(inode))
147 for (
int inode = 0x88; inode < 0x8C; inode++)
148 if (dsperr.SearchNA(inode))
151 for (
int inode = 0x34; inode < 0x3E; inode++)
152 if (dsperr.SearchNA(inode))
154 for (
int inode = 0x96; inode < 0xCE; inode++)
155 if (dsperr.SearchNA(inode))
159 void RTIInfo::FillEventVariables() {
187 std::for_each(
begin(inner),
end(inner), normalize);
189 std::for_each(
begin(inner),
end(inner), normalize);
191 std::for_each(
begin(inner),
end(inner), normalize);
199 std::for_each(
begin(inner),
end(inner), normalize);
201 std::for_each(
begin(inner),
end(inner), normalize);
223 void RTIInfo::AccumulateEventVariables(AMSEventR *evPtr) {
230 std::for_each(
begin(evPtr->TrdCluster()),
end(evPtr->TrdCluster()),
231 [
this](
const TrdClusterR &cl) {
nTRDLayerHits[cl.Layer]++; });
238 std::for_each(
begin(evPtr->TrRawCluster()),
end(evPtr->TrRawCluster()), [
this](TrRawClusterR &cl) {
239 if (cl.GetSide() == 0) {
241 if (cl.GetLayerJ() == 1)
245 if (cl.GetLayerJ() == 1)
254 std::for_each(
begin(evPtr->Particle()),
end(evPtr->Particle()), [
this](ParticleR &part) {
260 constexpr
int refit = 31;
261 constexpr
int fit_algo = 1;
262 int id_inner = part.pTrTrack()->iTrTrackPar(fit_algo, 3, refit);
265 float rig = part.pTrTrack()->GetRigidity(id_inner);
266 float q = part.pTrTrack()->GetQ(part.pBetaH()->GetBeta());
269 if (qbin >= 0 && rbin >= 0)
270 nPartInnRate[qbin][rbin]++;
272 int id_max = part.pTrTrack()->iTrTrackPar(fit_algo, 0, refit);
275 float rig = part.pTrTrack()->GetRigidity(id_inner);
276 float q = part.pTrTrack()->GetQ(part.pBetaH()->GetBeta());
279 if (qbin >= 0 && rbin >= 0)
280 nPartRate[qbin][rbin]++;
283 nPartBetaRate[qbin][bbin]++;
287 if (qbin >= 0 && fabs(rig) < minrigcutoff)
289 if (qbin >= 0 && fabs(rig) > maxrigcutoff)
295 std::for_each(
begin(evPtr->TrTrack()),
end(evPtr->TrTrack()), [
this](TrTrackR &trtrack) {
296 constexpr
int refit = 31;
297 constexpr
int fit_algo = 1;
299 int id_inner = trtrack.iTrTrackPar(fit_algo, 3, refit);
302 float rig = trtrack.GetRigidity(id_inner);
303 float q = trtrack.GetQ(1.0);
306 if (qbin >= 0 && rbin >= 0)
307 nTrkInnRate[qbin][rbin]++;
309 int id_max = trtrack.iTrTrackPar(fit_algo, 0, refit);
312 float rig = trtrack.GetRigidity(id_max);
313 float q = trtrack.GetQ(1.0);
316 if (qbin >= 0 && rbin >= 0)
317 nTrkRate[qbin][rbin]++;
321 auto *trig = evPtr->pLevel1(0);
323 trig->RestorePhysBPat();
324 auto bpatt = std::bitset<8>(trig->PhysBPatt);
325 for (
size_t ipatt = 0; ipatt < 8; ipatt++)
329 auto jpatt = std::bitset<16>(trig->JMembPatt);
330 for (
size_t ipatt = 0; ipatt < 16; ipatt++)
334 for (
size_t i = 0; i < 19; i++)
335 TrigRates[i] += (
float)trig->TrigRates[i];
337 auto antipatt = std::bitset<8>(trig->AntiPatt);
338 for (
size_t iacc = 0; iacc < 8; iacc++)
342 if (trig->TofFlag1 < 0)
344 else if (trig->TofFlag1 < 15)
347 std::for_each(
begin(evPtr->TofRawSide()),
end(evPtr->TofRawSide()), [
this](TofRawSideR &tofraw) {
354 std::for_each(
begin(evPtr->AntiRawSide()),
end(evPtr->AntiRawSide()), [
this](AntiRawSideR &antiraw) {
360 auto *daq = evPtr->pDaqEvent(0);
362 bool jinj_room_error =
false;
363 for (
int ijinj = 0; ijinj < 4; ijinj++) {
364 if ((daq->JINJStatus[ijinj] >> 8) & 0x2) {
365 for (
int ijinf = 0; ijinf < 24; ijinf++) {
366 if ((((daq->JError[ijinf]) >> 3) == 0x1A) || (((daq->JError[ijinf]) >> 3) == 0x12))
367 jinj_room_error =
true;
float nTrigger
Number of events with trigger in this second.
float nPartTrkInn
Average number of ParticleR with InnerTracker track.
float nTRDHitAvg
Average number of TRD raw hits for one event.
bool DSPErrorJLV1
Has a DSP error occurred in JLV1 in this second?
float nEventParticle
Number of events with tof+trd+tracker+ecal data.
float Altitude
Altitude (gtod coordinate system) (cm)
std::array< std::array< float, 2 >, 4 > MaxStoermerCutoff
Max Stoermer cutoff within a 25,30,35,40 degrees field of view (for both negative and positive partic...
unsigned int LastEvNo
Last event no in this second.
unsigned int FirstEvNo
First event nnumber in this second.
unsigned int RunTag
Run tag.
std::array< std::array< float, 2 >, 4 > MaxIGRFCutoff
Max IGRF cutoff within a 25,30,35,40 degrees field of view (for both negative and positive particles)...
float nACC
Average number of ACC sectors.
std::array< std::array< float, nbetabins+1 >, nqbins+1 > nPartBetaRate
Average number of ParticleR object divided by charge and beta.
static const std::array< float, nbetabins+1 > betabins
Bin edges for beta-binned variables.
std::array< float, 16 > TofFlags
Average value of TofFlags.
std::array< std::array< float, nrigbins+1 >, nqbins+1 > nTrkInnRate
Average number of TrTrackR object divided by charge and rigidity (inner tracker fit) ...
std::array< float, nqbins+1 > nPartAboveCutoff
Average number of ParticleR objects above cutoff.
float nTrClusterL1X
Average number of TrRawCluster on x side of L1.
float nTrClusterY
Average number of TrRawCluster on y side.
std::array< std::array< float, nrigbins+1 >, nqbins+1 > nTrkRate
Average number of TrTrackR object divided by charge and rigidity.
std::array< float, 8 > TrigPhysBPatt
Average fraction of each trigger pattern.
NAIAChain::EventItr begin(NAIAChain &chain)
std::array< float, 16 > TrigJMembPatt
Average fraction of each trigger pattern.
float nHWError
Number of events with HW error (from JINJStatus)
float nParticle
Average number of ParticleR objects.
float nTrkInn
Average number of TrTrackR objects with inner fit.
std::array< float, nqbins+1 > nPartBelowCutoff
Average number of ParticleR objects below cutoff.
float MagAltSphCoo
Magnetic coordinates altitude.
float nTrClusterAvg
Average number of Tracker raw clusters for one event.
float MostProbableHeRig
Most probable He rigidity for this second;.
float LivetimeFraction
Livetime fraction during this second.
float nTRDHits
Average number of total TrdRawHit.
float nEcalShower
Average number of EcalShower objects.
float Phi
Phi (gtod coordinate system) (rad)
float nTrk
Average number of TrTrackR objects with default fit.
float TofRaw_nsumh
High Threshold history.
unsigned int UTCTime
JMDC unix time (seconds since 1 Jan 1970)
float Theta
Theta (gtod coordinate system) (rad)
bool DSPErrorJINF
Has a DSP error occurred in JINF in this second?
float GalacticLong
Galactic longitude of AMS pointing direction (degrees)
float Zenith
AMS zenith angle (degrees)
static const std::map< unsigned int, std::pair< float, float > > qbins
Bin edges for charge-binned variables, depending on particle species.
bool DSPError
Has a DSP error occurred in this second?
float nEcalHits
Average number of EcalHit objects.
float MagThetaSphCoo
Magnetic coordinates theta.
float TofRaw_nftdc
Fast Trigger history.
static constexpr double Re
float nEvent
Total number of events in this second.
float MagPhiSphCoo
Magnetic coordinates phi.
std::array< float, 19 > TrigRates
Average value of trigger rates.
float nError
Number of missing events due to errors.
float nPartTrk
Average number of ParticleR with Tracker track.
unsigned long long m_processedEvents
std::array< float, 20 > nTRDLayerHits
Average number of TRD hits in each layer.
int good
0 if good (Thanks, Qi. Very descriptive)
float nTrClusterX
Average number of TrRawCluster on x side.
std::array< std::array< float, 3 >, 2 > MeanAlignDiffExtLayer
mean difference(um) bewteen PG ad CIEMAT alignment of L1 and L9(XYZ)
constexpr int FindBin(ValueType value, const std::array< ValueType, N > &bins)
float AntiRaw_nftdc
Fast Trigger history.
std::array< std::array< float, 2 >, 2 > MinIGRFCutoff
Min IGRF cutoff within a 25,40 degrees field of view (for both negative and positive particles) ...
float nTofClusterH
Average number of TofClusterH objects.
float nGoodParticle
Average number of "good" ParticleR objects.
float TofRaw_nstdc
Low Threshold history.
std::array< std::array< float, nrigbins+1 >, nqbins+1 > nPartRate
Average number of ParticleR object divided by charge and rigidity.
NAIAChain::EventItr end(NAIAChain &chain)
float AntiRaw_ntdct
Low Threshold history.
std::array< std::array< float, nrigbins+1 >, nqbins+1 > nPartInnRate
Average number of ParticleR object divided by charge and rigidity (inner tracker fit) ...
bool DSPErrorJINJ
Has a DSP error occurred in JINJ in this second?
float nTRDTrack
Average number of TrdTrack objects.
float TofRaw_nsumsh
Super-High Threshold history.
float nTrClusterL1Y
Average number of TrRawCluster on y side of L1.
float GalacticLat
Galactic latitude of AMS pointing direction (degrees)
static const std::array< float, nrigbins+1 > rigbins
Bin edges for rigidity-binned variables.
RTIInfo container class description.
float nRoomError
Average number of room errors.
unsigned int Run
Run number.