26 mm(nullptr),ms(nullptr),RTI(nullptr)
29 printf(
"In myEvent::myEvent\n");
34 printf(
"%s::%s was already existing (%p)... Substituting it (with %p)!\n",
ptr->ClassName(),
ptr->GetName(),
ptr,
this);
36 else printf(
"Object myEvent (%p) created...\n",
this);
56 for (
int ii=0; ii<(int)(
vmp.size()); ii++) {
57 vmp.push_back(orig.
vmp[ii]);
61 for (
int ii=0; ii<(int)(
vmt.size()); ii++) {
62 vmt.push_back(orig.
vmt[ii]);
65 for (
int ii=0; ii<(int)(
vme.size()); ii++) {
66 vme.push_back(orig.
vme[ii]);
69 for (
int ii=0; ii<(int)(
vmu.size()); ii++) {
70 vmu.push_back(orig.
vmu[ii]);
73 for (
int ii=0; ii<(int)(
vmb.size()); ii++) {
74 vmb.push_back(orig.
vmb[ii]);
77 for (
int ii=0; ii<(int)(
vmbh.size()); ii++) {
81 for (
int ii=0; ii<(int)(
vmr.size()); ii++) {
82 vmr.push_back(orig.
vmr[ii]);
86 for (
int ii=0; ii<(int)(
vmup.size()); ii++) {
99 for (
int ii=0; ii<(int)(
vmuqtp.size()); ii++) {
103 for (
int ii=0; ii<(int)(
vmtp.size()); ii++) {
107 for (
int ii=0; ii<(int)(
vmep.size()); ii++) {
111 for (
int ii=0; ii<(int)(
vmrp.size()); ii++) {
115 for (
int ii=0; ii<(int)(
vmbp.size()); ii++) {
119 for (
int ii=0; ii<(int)(
vmbhp.size()); ii++) {
212 printf(
"In myEvent::~myEvent\n");
222 printf(
"In myEvent::init\n");
232 printf(
"In myEvent::gethead\n");
239 printf(
"Object myEvent (%p) created as singleton...\n",
ptr);
242 else printf(
"%s existed (%p)!\n",
ptr->ClassName(),
ptr);
250 printf(
"In myEvent::printptr\n");
255 printf(
"myEvent pointer is %p...\n",
ptr);
262 printf(
"In myEvent::Clear\n");
456 if (
nBetaH() == 0)
return false;
465 for (Int_t i = 0; i < n_betah; i++) {
475 if (bt < betat)
continue;
493 if(pattern>= maxPattern){
497 if (chk < btchk)
continue;
506 <<
" beta_index "<<beta_index
518 if (index>=0 &&
vmp.size()>0) {
519 for (
int ii=0; ii<(int)(
vmp.size()); ii++) {
531 if (index>=0 && (
int)(
vmp.size())>index)
541 if (index>=0 &&
vmu.size()>0) {
542 for (
int ii=0; ii<(int)(
vmu.size()); ii++) {
554 if (index>=0 && (
int)(
vmu.size())>index)
562 if (index>=0 &&
vmup.size()>0) {
563 for (
int ii=0; ii<(int)(
vmup.size()); ii++) {
575 if (index>=0 && (
int)(
vmup.size())>index)
584 if (index>=0 &&
vmt.size()>0) {
585 for (
int ii=0; ii<(int)(
vmt.size()); ii++) {
597 if (index>=0 && (
int)(
vmt.size())>index)
605 if (index>=0 &&
vme.size()>0) {
606 for (
int ii=0; ii<(int)(
vme.size()); ii++) {
618 if (index>=0 && (
int)(
vme.size())>index)
626 if (index>=0 &&
vmb.size()>0) {
627 for (
int ii=0; ii<(int)(
vmb.size()); ii++) {
639 if (index>=0 && (
int)(
vmb.size())>index)
647 if (index>=0 &&
vmbh.size()>0) {
648 for (
int ii=0; ii<(int)(
vmbh.size()); ii++) {
660 if (index>=0 && (
int)(
vmbh.size())>index)
668 if (index>=0 &&
vmr.size()>0) {
669 for (
int ii=0; ii<(int)(
vmr.size()); ii++) {
681 if (index>=0 && (
int)(
vmr.size())>index)
691 if (index>=0 &&
vmuktp.size()>0) {
692 for (
int ii=0; ii<(int)(
vmuktp.size()); ii++) {
702 if (index>=0 &&
vmukup.size()>0) {
703 for (
size_t ii=0; ii<
vmukup.size(); ii++) {
705 if (k && k->
iMySelf()==index) {
return k; }
713 if (index>=0 && (
int)(
vmuktp.size())>index)
721 if (index>=0 && (
int)(
vmukup.size())>index)
729 if (index>=0 &&
vmuqtp.size()>0) {
730 for (
int ii=0; ii<(int)(
vmuqtp.size()); ii++) {
742 if (index>=0 && (
int)(
vmuqtp.size())>index)
750 if (index>=0 &&
vmtp.size()>0) {
751 for (
int ii=0; ii<(int)(
vmtp.size()); ii++) {
763 if (index>=0 && (
int)(
vmtp.size())>index)
771 if (index>=0 &&
vmep.size()>0) {
772 for (
int ii=0; ii<(int)(
vmep.size()); ii++) {
784 if (index>=0 && (
int)(
vmep.size())>index)
792 if (index>=0 &&
vmbp.size()>0) {
793 for (
int ii=0; ii<(int)(
vmbp.size()); ii++) {
805 if (index>=0 && (
int)(
vmbp.size())>index)
813 if (index>=0 &&
vmbhp.size()>0) {
814 for (
int ii=0; ii<(int)(
vmbhp.size()); ii++) {
826 if (index>=0 && (
int)(
vmbhp.size())>index)
834 if (index>=0 &&
vmrp.size()>0) {
835 for (
int ii=0; ii<(int)(
vmrp.size()); ii++) {
847 if (index>=0 && (
int)(
vmrp.size())>index)
853 bool pnpoly(
int npol,
float *xp,
float *yp,
float x,
float y){
858 for (i = 0, j = npol-1; i < npol; j = i++) {
860 (((yp[i] <= y) && (y < yp[j])) ||
861 ((yp[j] <= y) && (y < yp[i]))) &&
862 (x < (xp[j] - xp[i]) * (y - yp[i])/(yp[j] - yp[i]) + xp[i]))
871 static float Phi_SAA[5] = {-83.0, -38.0, 0.0, 0.0, -83.0};
872 static float Theta_SAA[5] = {-1.0, -1.0, -22.0, -60.0, -60.0};
891 return AMSEventR::getsetup()->getRTI(a,this->
fHeader.
Time[0]);
899 cerr<<
" Section RTI not available or not activated "<<endl;
904 cerr<<
" RTI TTree friend not available "<<endl;
908 cerr<<
"LoadmyRTI-S-BegintimeNotLessThanEndTime "<<t1<<
" "<<t2<<endl;
911 else if(t2-t1>864000){
912 cerr<<
"LoadmyRTI-S-EndBeginDifferenceTooBigMax864000 "<<t2-t1<<endl;
922 t3rti->SetBranchAddress(
"fmyRTI",a);
925 for(
int i_rti=0; i_rti<t3rti->GetEntries(); i_rti++){
926 t3rti->GetEntry(i_rti);
928 if(a->
run==0)
continue;
929 unsigned int nt=a->
utime;
930 if(nt<t1){bfound=1;
continue;}
933 fRTI.clear();bfound=2;
935 fRTI.insert(make_pair(nt,*a));
937 else if(nt>t2){efound=1;
break;}
940 if(bfound&&efound)ret=0;
941 else if(!bfound&&!efound)ret=2;
943 cout<<
"LoadmyRTI-I- "<<
fRTI.size()<<
" Entries Loaded "<<ret<<endl;
953 if(this->
RTI)
return 0;
960 static unsigned int stime[2]={1,1};
964 const int dt=3600*24;
965 if(stime[0]==1||xtime>stime[1]||xtime<stime[0]){
966 stime[0]=(xtime<=pt)?1:xtime-pt;
969 this->
LoadRTI(stime[0],stime[1]);
974 map< unsigned int, myRTI >::iterator k=
fRTI.lower_bound(xtime);
975 if (
fRTI.size()==0)
return 2;
976 if(k==
fRTI.end())
return 1;
986 unsigned int bt= xtime/dt*dt;
987 unsigned int et= bt+dt-1;
989 static unsigned int rbt=0;
990 static unsigned int ret=0;
991 static unsigned int rst=0;
996 if(!(bt>=rbt&&et<=ret)){
998 for(
int iexl=0;iexl<2;iexl++){rnxyz[iexl].
setp(0,0,0);rdxyz[iexl].
setp(0,0,0);}
1004 for(
unsigned int t=bt;t<=et;t++){
1007 if(
GetRTI(mya,t)!=0)
continue;
1009 if(AMSEventR::GetRTI(a,t)!=0)
continue;
1012 if(
GetRTI(mya,t)!=0)
continue;
1014 for(
int iexl=0;iexl<2;iexl++){
1015 for(
int ico=0;ico<3;ico++){
1019 nev=a.
nl1l9[iexl][ico==0?0:1];
1020 rdxyz[iexl][ico]+=a.dl1l9[iexl][ico]*nev;
1023 nev=mya.
nl1l9[iexl][ico==0?0:1];
1024 rdxyz[iexl][ico]+=mya.
dl1l9[iexl][ico]*nev;
1027 nev=mya.
nl1l9[iexl][ico==0?0:1];
1028 rdxyz[iexl][ico]+=mya.
dl1l9[iexl][ico]*nev;
1030 rnxyz[iexl][ico]+=nev;
1036 for(
int iexl=0;iexl<2;iexl++){
1037 for(
int ico=0;ico<3;ico++){
1038 rdxyz[iexl][ico]=(rnxyz[iexl][ico]>0)?rdxyz[iexl][ico]/rnxyz[iexl][ico]:0;
1043 nxyz=rnxyz[extlay]; dxyz=rdxyz[extlay];
1061 static int TRDWeakForEPSeparation(AMSEventR* pev);
1062 static int TrdRunCategory(AMSEventR* pev);
1063 static bool BadRunCheck(AMSEventR *pev);
1064 static int IsScienceRun(AMSEventR *pev);
1065 static int RunAnalysisCategory(AMSEventR *pev);
1079 myEventFiller::myEventFiller():
myEvent(){
1081 printf(
"In myEventFiller::myEventFiller\n");
1089 myEventFiller::~myEventFiller(){
1091 printf(
"In myEventFiller::~myEventFiller\n");
1100 myEventFiller* myEventFiller::gethead() {
1102 printf(
"In myEventFiller::gethead\n");
1108 ptr =
new myEventFiller();
1109 printf(
"Object myEventFiller (%p) created as singleton...\n", ptr);
1111 else printf(
"myEventFiller (%s) exists!\n", ptr->ClassName());
1112 return (myEventFiller*)ptr;
1115 void myEventFiller::init() {
1117 printf(
"In myEventFiller::init\n");
1122 for (
int ii=0; ii<9; ii++) {
1123 if(TkDBc::Head) zlay[ii]=TkDBc::Head->GetZlayer(ii+1);
1132 void myEventFiller::Clear(Option_t*){
1134 printf(
"In myEventFiller::Clear\n");
1142 tmp_filler.SetOwner(kTRUE);
1163 #if !defined _B524_ && !defined _B550_ && !defined _B572_
1170 void myEventFiller::Fill(
int fTree, Long64_t fEntry){
1172 printf(
"In myEventFiller::Fill\n");
1182 myHeaderFiller mhfill;
1192 mcevent = pev->pMCEventg(0);
1195 mmfill.Fill(mcevent);
1206 printf(
"Loop over TrdTrack's (%d)\n", _nTrdTrack);
1208 for (
int ii=0; ii<_nTrdTrack; ii++) {
1209 TrdTrackR* trdtrack = pev->pTrdTrack(ii);
1212 myTrdTrackFiller mu;
1218 tmp_filler.Add(mu2bewritten);
1219 vmu.push_back(mu2bewritten);
1220 vmukup.push_back(
nullptr);
1228 if(pev->nTrdSegment()>0){
1229 myTrdTrackPlusFiller mup;
1235 tmp_filler.Add(mup2bewritten);
1236 vmup.push_back(mup2bewritten);
1244 printf(
"Loop over TrTrack's (%d)\n", _nTrTrack);
1246 for (
int ii=0; ii<_nTrTrack; ii++) {
1247 TrTrackR* track = pev->pTrTrack(ii);
1256 tmp_filler.Add(mt2bewritten);
1257 vmt.push_back(mt2bewritten);
1258 vmtp.push_back(NULL);
1259 vmuktp.push_back(NULL);
1260 vmuqtp.push_back(NULL);
1262 printf(
"track=%d) iPart=%d, iMySelf=%d, i_part=%d, i_myself=%d\n", ii, mt.iPart(), mt.iMySelf(), mt.i_part, mt.i_myself);
1271 printf(
"Loop over EcalShower's (%d)\n", _nEcalShower);
1273 for (
int ii=0; ii<_nEcalShower; ii++) {
1274 EcalShowerR* shower = pev->pEcalShower(ii);
1277 myEcalShowerFiller me;
1283 tmp_filler.Add(me2bewritten);
1284 vme.push_back(me2bewritten);
1285 vmep.push_back(NULL);
1293 printf(
"Loop over RichRing's (%d)\n", _nRichRing);
1295 RichRingR::setBetaCorrection(RichRingR::fullUniformityCorrection);
1296 for (
int ii=0; ii<_nRichRing; ii++) {
1297 RichRingR* ring = pev->pRichRing(ii);
1300 myRichRingFiller mr;
1306 tmp_filler.Add(mr2bewritten);
1307 vmr.push_back(mr2bewritten);
1308 vmrp.push_back(NULL);
1316 printf(
"Loop over Beta's (%d)\n", _nBeta);
1318 for (
int ii=0; ii<_nBeta; ii++) {
1319 BetaR* beta = pev->pBeta(ii);
1328 tmp_filler.Add(mb2bewritten);
1329 vmb.push_back(mb2bewritten);
1330 vmbp.push_back(NULL);
1338 printf(
"Loop over BetaH's (%d)\n", _nBetaH);
1340 for (
int ii=0; ii<_nBetaH; ii++) {
1341 BetaHR* betah = pev->pBetaH(ii);
1350 tmp_filler.Add(mbh2bewritten);
1351 vmbh.push_back(mbh2bewritten);
1352 vmbhp.push_back(NULL);
1359 int i_part_max_qbh=-1;
1362 int i_part_max_r=-1;
1364 int i_part_max_r_trd=-1;
1366 int i_part_max_e=-1;
1373 printf(
"Loop over Particle's (%d)\n", _nParticle);
1376 for (
int ii=0; ii<_nParticle; ii++) {
1377 myParticleFiller mp;
1378 mp.Fill(pev->pParticle(ii));
1384 if (mp.trdtrack && mp.pmyTrdTrackByMySelf()) mp.pmyTrdTrackByMySelf()->SetPart(ii);
1386 if (mp.track && mp.pmyTrTrackByMySelf()) mp.pmyTrTrackByMySelf()->SetPart(ii);
1388 if (mp.shower && mp.pmyEcalShowerByMySelf()) mp.pmyEcalShowerByMySelf()->SetPart(ii);
1390 if (mp.ring && mp.pmyRichRingByMySelf()) mp.pmyRichRingByMySelf()->SetPart(ii);
1392 if (mp.beta && mp.pmyBetaByMySelf()) mp.pmyBetaByMySelf()->SetPart(ii);
1394 if (mp.betah && mp.pmyBetaHByMySelf()) mp.pmyBetaHByMySelf()->SetPart(ii);
1397 if (mp.track) printf(
"part=%d) mp.pmyTrTrack(), iPart=%d, iMySelf=%d, i_part=%d, i_myself=%d\n", ii, mp.pmyTrTrackByMySelf()->iPart(), mp.pmyTrTrackByMySelf()->iMySelf(), mp.pmyTrTrackByMySelf()->i_part, mp.pmyTrTrackByMySelf()->i_myself);
1398 if (mp.track) printf(
"mpart=%d) vmt[%d], iPart=%d, iMySelf=%d, i_part=%d, i_myself=%d\n", ii, mp.iTrTrack(), vmt[mp.iTrTrack()]->iPart(), vmt[mp.iTrTrack()]->iMySelf(), vmt[mp.iTrTrack()]->i_part, vmt[mp.iTrTrack()]->i_myself);
1403 bool NoEcalPlus = not
gsection.enabled(
"EcalPlus"),
1404 NoHeaderTree = not
gsection.enabled(
"HeaderTree");
1405 if (!(NoEcalPlus && NoHeaderTree) ) {
1407 myEcalShowerPlusFiller* mep =
new myEcalShowerPlusFiller();
1416 mep->Fill(mp.shower, NoEcalPlus&(!NoHeaderTree));
1419 mep->SetMySelf(mp.pp->iEcalShower());
1421 tmp_filler.Add(mep2bewritten);
1422 vmep[mep2bewritten->
iMySelf()] = mep2bewritten;
1423 if(mp.shower->EnergyD>=max_e){
1424 max_e=mp.shower->EnergyD;
1427 if (mep)
delete mep;
1435 bool NoTrackerPlus = not
gsection.enabled(
"TrackerPlus");
1436 if (!NoTrackerPlus) {
1438 myTrTrackPlusFiller* mtp =
new myTrTrackPlusFiller();
1441 if (mp.pmyBetaHByMySelf()) beta=mp.pmyBetaHByMySelf()->Beta;
1442 mtp->Fill(mp.track, ii, mp.shower, beta, kMC,
true);
1444 mtp->FillCharge(mp.track, beta);
1447 mtp->SetMySelf(mp.pp->iTrTrack());
1449 tmp_filler.Add(mtp2bewritten);
1450 vmtp[mtp2bewritten->
iMySelf()] = mtp2bewritten;
1451 if(mtp->GetRigidity(0)>=max_r){
1455 if (mtp)
delete mtp;
1462 if(
gsection.enabled(
"BetaHPlus") ){
1463 if ( mp.betah && mp.pmyBetaHByMySelf()) {
1464 myBetaHPlusFiller* mbhp =
new myBetaHPlusFiller();
1466 mbhp->Fill(mp.betah);
1469 mbhp->SetMySelf(mp.pp->iBetaH());
1471 tmp_filler.Add(mbhp2bewritten);
1472 vmbhp[mbhp2bewritten->
iMySelf()] = mbhp2bewritten;
1473 if(mbhp->Q>=max_qbh){
1477 if (mbhp)
delete mbhp;
1485 if (mp.beta && mp.pmyBetaByMySelf()) {
1486 myBetaPlusFiller* mbp =
new myBetaPlusFiller();
1488 if (mp.pmyTrTrackByMySelf()) mbp->Fill(mp.beta, mp.track, mp.pmyTrTrackByMySelf()->kDef);
1489 else mbp->Fill(mp.beta, mp.track);
1492 mbp->SetMySelf(mp.pp->iBeta());
1494 tmp_filler.Add(mbp2bewritten);
1495 vmbp[mbp2bewritten->
iMySelf()] = mbp2bewritten;
1496 if (mbp)
delete mbp;
1504 if (mp.ring && mp.pmyRichRingByMySelf()) {
1505 myRichRingPlusFiller* mrp =
new myRichRingPlusFiller();
1507 mrp->Fill(mp.ring, mp.pp);
1510 mrp->SetMySelf(mp.pp->iRichRing());
1512 tmp_filler.Add(mrp2bewritten);
1513 vmrp[mrp2bewritten->
iMySelf()] = mrp2bewritten;
1514 if (mrp)
delete mrp;
1520 if (
gsection.enabled(
"TRDKPlus")) {
1522 myTrdKFromTrTrackFiller* mukp =
new myTrdKFromTrTrackFiller();
1525 if (mp.pmyEcalShowerByMySelf()) energy=mp.pmyEcalShowerByMySelf()->EnergyE;
1527 if (mp.pmyTrTrackPlusByMySelf()) kDef=mp.pmyTrTrackPlusByMySelf()->kDef;
1529 if(!NoTrackerPlus)Error(__func__,
"strange kDef for %p", mp.pmyTrTrackPlusByMySelf());
1530 kDef = mp.track->Gettrdefaultfit();
1532 mukp->Fill(mp.iTrTrack(), mp.track, energy, kDef);
1535 mukp->SetMySelf(mp.pp->iTrTrack());
1537 tmp_filler.Add(mukp2bewritten);
1538 vmuktp[mukp2bewritten->
iMySelf()] = mukp2bewritten;
1539 if(mp.pmyTrTrackByMySelf() && mp.pmyTrTrackByMySelf()->Rigidity>=max_r_trd){
1540 max_r_trd=mp.pmyTrTrackByMySelf()->Rigidity;
1541 i_part_max_r_trd=ii;
1543 if (mukp)
delete mukp;
1547 myTrdKFromTrdTrackFiller mukup;
1549 float rig = std::abs(pev->Particle(ii).Momentum / pev->Particle(ii).Charge);
1551 if (mp.pmyEcalShowerByMySelf()) energy=mp.pmyEcalShowerByMySelf()->EnergyE;
1552 mukup.Fill(mp.iTrdTrack(), mp.trdtrack, energy, rig);
1555 mukup.SetMySelf(mp.pp->iTrdTrack());
1557 tmp_filler.Add(mukp2bewritten);
1558 vmukup[mukp2bewritten->
iMySelf()] = mukp2bewritten;
1562 if (
gsection.enabled(
"TRDQtPlus")) {
1564 myTrdQtFromTrTrackFiller* muqtp =
new myTrdQtFromTrTrackFiller();
1567 if (mp.pmyEcalShowerByMySelf()) energy=mp.pmyEcalShowerByMySelf()->EnergyE;
1569 if (mp.pmyTrTrackByMySelf()) kDef=mp.pmyTrTrackByMySelf()->kDef;
1570 muqtp->Fill(mp.iTrTrack(), mp.track, kDef, energy);
1573 muqtp->SetMySelf(mp.pp->iTrTrack());
1575 tmp_filler.Add(muqtp2bewritten);
1576 vmuqtp[muqtp2bewritten->
iMySelf()] = muqtp2bewritten;
1577 if (muqtp)
delete muqtp;
1585 tmp_filler.Add(mp2bewritten);
1586 vmp.push_back(mp2bewritten);
1591 if(
gsection.enabled(
"StatusTree")){
1593 printf(
"Filling Status \n");
1596 myStatusFiller msfill;
1597 msfill.fStatus=pev->fStatus;
1598 msfill.EntryNumber=fEntry;
1599 msfill.TreeNumber=fTree;
1600 msfill.Fill(i_part_max_r, i_part_max_qbh , i_part_max_e, i_part_max_r_trd);
1611 void myEventFiller::Fill(){
1613 printf(
"In myEventFiller::Fill\n");
1617 pev = AMSEventR::Head();
1620 if (AMSEventR::getsetup())
1621 AMSEventR::getsetup()->IsBadRun(reason, pev->UTime(), pev->Run());
1622 ReasonToBeBadRun = reason;
1623 _IsBadRun = pev->IsBadRun(
"");
1624 RunAnalCat = RunAnalysisCategory(pev);
1627 Event = pev->Event();
1629 head = &(pev->fHeader);
1632 _UTCTime = pev->UTCTime() ;
1637 static unsigned int TimeJMDCPrevious = fHeader.Time[0];
1638 static unsigned int MuTimeJMDCPrevious = fHeader.Time[1];
1639 DeltaTJMDC = fHeader.Time[0]+0.000001*fHeader.Time[1] - (TimeJMDCPrevious+0.000001*MuTimeJMDCPrevious);
1640 TimeJMDCPrevious = fHeader.Time[0];
1641 MuTimeJMDCPrevious = fHeader.Time[1];
1643 if (fHeader.Time[0]<TimeJMDCFirst) TimeJMDCFirst = fHeader.Time[0];
1644 if (fHeader.Time[0]>TimeJMDCLast) TimeJMDCLast = fHeader.Time[0];
1645 Duration = TimeJMDCLast - TimeJMDCFirst;
1650 lvl1 = pev->pLevel1(0);
1652 setup = pev->getsetup();
1654 daqev=pev->pDaqEvent(0);
1660 GM_GeoMagSphericalCoo(fHeader.Time[0], fHeader.RadS, fHeader.ThetaS, fHeader.PhiS, GeoMagSphericalCoo);
1671 static GeoMag geomag;
1675 static int counter=0;
1678 printf(
"%d-%d) in SAA (Lon,Lat)=(%f,%f)\n", Run, Event, Lon(), Lat());
1680 else if (counter==100) {
1682 printf(
"%d-%d) in SAA (Lon,Lat)=(%f,%f). I said %d times, it's enough...\n", Run, Event, Lon(), Lat(), counter);
1686 if ( isISS() and fHeader.Time[0] !=
TimePrevISS) {
1690 iss.TrackISS((
int)(fHeader.Time[0]), 0);
1694 cgm.GetCGM(Lat, Lon, Alt, (
int)(1970+(fHeader.Time[0]/(365*24*60*60))));
1699 geomag.Recalc(Lat, Lon, Alt, (
int)(1970+(fHeader.Time[0]/(365*24*60*60))));
1704 pev->GetMaxGeoCutoff(35.0, 1, cutoff);
1705 MaxGeoCutOff_n=cutoff[0];
1706 MaxGeoCutOff_p=cutoff[1];
1709 AMSSetupR::RTI::Version=2;
1710 AMSSetupR::RTI ev_RTI;
1711 int RTI_ko=pev->GetRTI(ev_RTI);
1713 myRTIFiller rtifill;
1714 rtifill.Fill(&ev_RTI);
1715 if (RTI)
delete RTI;
1719 }
else Error(__func__,
"fail getting RTI for %d: %d", fHeader.Time[0], RTI_ko);
1724 LonPred=(Double_t)((iss.Lon<180)?iss.Lon:(iss.Lon-360));
1725 LatPred=(Double_t)(iss.Lat);
1726 AltPred=(Double_t)(iss.Alt);
1731 LonCGM=M_PI*(Double_t)(cgm.clor)/180.0;
1732 LatCGM=M_PI*(Double_t)(cgm.clar)/180.0;
1733 RadCGM=((Double_t)(cgm.rbm));
1744 slowcontrol = &(setup->fSlowControl);
1745 #ifdef SLOWCONTROLTEMP
1746 std::vector<float> temp;
1747 slowcontrol->GetData(
"Sensor A", fHeader.Time[0], (
float)(fHeader.Time[1]/1000000.0), temp);
1748 if (temp.size()>0) SensorA = temp[0];
1749 slowcontrol->GetData(
"Sensor C", fHeader.Time[0], (
float)(fHeader.Time[1]/1000000.0), temp);
1750 if (temp.size()>0) SensorC = temp[0];
1751 slowcontrol->GetData(
"Sensor K", fHeader.Time[0], (
float)(fHeader.Time[1]/1000000.0), temp);
1752 if (temp.size()>0) SensorK = temp[0];
1753 slowcontrol->GetData(
"Sensor L", fHeader.Time[0], (
float)(fHeader.Time[1]/1000000.0), temp);
1754 if (temp.size()>0) SensorL = temp[0];
1755 slowcontrol->GetData(
"Sensor M", fHeader.Time[0], (
float)(fHeader.Time[1]/1000000.0), temp);
1756 if (temp.size()>0) SensorM = temp[0];
1757 slowcontrol->GetData(
"M-7X 0 1N-1", fHeader.Time[0], (
float)(fHeader.Time[1]/1000000.0), temp);
1758 if (temp.size()>0) Plane1N_M70 = temp[0];
1759 slowcontrol->GetData(
"M-7X 0 1N-2", fHeader.Time[0], (
float)(fHeader.Time[1]/1000000.0), temp);
1760 if (temp.size()>0) Plane1N_M71 = temp[0];
1761 slowcontrol->GetData(
"M-7X 0 1N-3", fHeader.Time[0], (
float)(fHeader.Time[1]/1000000.0), temp);
1762 if (temp.size()>0) Plane1N_M72 = temp[0];
1763 slowcontrol->GetData(
"M-7X 0 1N-4", fHeader.Time[0], (
float)(fHeader.Time[1]/1000000.0), temp);
1764 if (temp.size()>0) Plane1N_M73 = temp[0];
1765 slowcontrol->GetData(
"Sensor 8", fHeader.Time[0], (
float)(fHeader.Time[1]/1000000.0), temp);
1766 if (temp.size()>0) Sensor8 = temp[0];
1772 Lenght=daqev->Length;
1780 L3Error=daqev->L3Error;
1781 L3VEvent=daqev->L3VEvent;
1782 L3TimeD=daqev->L3TimeD;
1783 #if !defined _B524_ && !defined _B550_
1784 copy_n( daqev->JINJStatus, 4, JINJStatus);
1785 copy_n( daqev->JError, 24, JError);
1789 #if defined(DSPERRORS) && !defined _B524_ && !defined _B550_ && !defined _B572_
1790 pdsperr=head->pDSPError();
1802 EcalFlag = lvl1->EcalFlag;
1803 copy_n( lvl1->TrigRates, 19,TrigRates);
1804 copy_n( lvl1->TofPatt1, 4 ,TofPatt1);
1805 copy_n( lvl1->TofPatt2, 4 ,TofPatt2);
1806 JMembPatt = lvl1->JMembPatt;
1807 PhysBPatt=lvl1->PhysBPatt;
1808 PhysBPattPhys=PhysBPatt&0x3E;
1809 lvl1->RestorePhysBPat();
1810 PhysBPattRestored=lvl1->PhysBPatt;
1811 TofFlag1 = lvl1->TofFlag1;
1812 TofFlag2 = lvl1->TofFlag2;
1813 LiveTime = lvl1->LiveTime;
1814 DeltaT = lvl1->TrigTime[4];
1815 Lvl1Time = 0.64*(lvl1->TrigTime[2] + pow(2.0, 32.0)*lvl1->TrigTime[3]);
1816 DeltaTMine = Lvl1Time - Lvl1TimePrevious;
1817 if (DeltaTMine<0) DeltaTMine = Lvl1Time - (Lvl1TimePrevious - lvl1->TrigTime[0]*0.64);
1821 Lvl1TimePrevious = Lvl1Time;
1826 AntiPatt=lvl1->AntiPatt;
1828 for (
int ii=0; ii<=8; ii++){
1829 if((AntiPatt)&(1<<ii)) {
1838 nTofCluster=pev->nTofCluster();
1839 for (
int ii=0; ii<nTofCluster; ii++) {
1840 TofClusterR* tfr=pev->pTofCluster(ii);
1841 if (((tfr->Layer)-1)>3) printf(
"nTofCluster evaluation: layer number (%d) not possible!\n", tfr->Layer);
1842 else nTofClusterL[(tfr->Layer)-1]++;
1848 _nTrdTrack = pev->nTrdTrack();
1849 _nTrdCluster = pev->nTrdCluster();
1850 _nTrdRawHit = pev->nTrdRawHit();
1851 _nTrdSegment = pev->nTrdSegment();
1855 if(pev->nMCEventg()>0){
1857 _nTrTrack = pev->NTrTrack();
1858 _nTrCluster = pev->NTrCluster();
1859 _nTrRecHit = pev->NTrRecHit();
1860 _nTrRawCluster = pev->NTrRawCluster();
1862 _nEcalShower = pev->NEcalShower();
1865 _nBetaH = pev->NBetaH();
1867 _nBeta = pev->NBeta();
1870 _nRichRing = pev->NRichRing();
1871 _nRichHit = pev->NRichHit();
1874 _nParticle = pev->NParticle();
1878 _nTrTrack = pev->nTrTrack();
1879 _nTrCluster = pev->nTrCluster();
1880 _nTrRecHit = pev->nTrRecHit();
1881 _nTrRawCluster = pev->nTrRawCluster();
1883 _nEcalShower = pev->nEcalShower();
1886 _nBetaH = pev->nBetaH();
1888 _nBeta = pev->nBeta();
1891 _nRichRing = pev->nRichRing();
1892 _nRichHit = pev->nRichHit();
1895 _nParticle = pev->nParticle();
1899 for (
int ii=0; ii<_nTrRawCluster; ii++) {
1900 static TrClusterR* clu;
1901 clu = pev->pTrCluster(ii);
1904 layer = clu->GetLayer();
1906 if ((layer-1)>8) printf(
"nTrRawCluster evaluation: layer number (%d) not possible!\n", layer);
1907 else _nTrRawClusterL[layer-1]++;
1910 tkrechitsevent = &(pev->TrRecHit());
2005 int TRDWeakForEPSeparation(AMSEventR* pev){
2010 if (AMSEventR::getsetup())
2011 AMSEventR::getsetup()->IsBadRun(reason, pev->UTime(), pev->Run());
2018 if (reason.find(
"TRD_WeakForEPseparation") != string::npos && reason.find(
"TRD_BadForEPseparation") == string::npos && reason.find(
"TRD_UnusableForAnalysis") == string::npos)
2024 int TrdRunCategory( AMSEventR* pev ){
2026 if (!pev)
return -1;
2029 if (AMSEventR::getsetup())
2030 AMSEventR::getsetup()->IsBadRun(reason, pev->UTime(), pev->Run());
2034 bool weak = ( reason.find(
"TRD_WeakForEPseparation") != string::npos );
2035 bool bad = ( reason.find(
"TRD_BadForEPseparation") != string::npos );
2036 bool unusab = ( reason.find(
"TRD_UnusableForAnalysis") != string::npos );
2038 if ( weak && !bad && !unusab )
return 1;
2039 if ( bad && !unusab )
return 2;
2040 if ( unusab )
return 3;
2045 bool BadRunCheck(AMSEventR *pev){
2047 if (!pev)
return false;
2049 int tag = pev->IsBadRun(
"");
2051 if(tag==0)
return false;
2052 else if(tag==1)
return true;
2054 printf(
"Run:%d Ev:%d -> Cannot acces to root_setup. Skipping this event\n", (
int)pev->Run(), (int)pev->Event());
2060 int IsScienceRun(AMSEventR *pev){
2065 HeaderR* header = &(pev->fHeader);
2066 if (!header)
return -1;
2068 if (header->RunType>=0xF000)
return 1;
2070 if (header->RunType>=0xED0D)
return 2;
2071 else if (header->RunType==0xD53C)
return 2;
2072 else if (header->RunType>=0xD510 && header->RunType<=0xD51A)
return 2;
2077 int RunAnalysisCategory(AMSEventR *pev){
2087 int trd_cat = TrdRunCategory(pev);
2088 bool trd_unusable = (trd_cat==3);
2091 int runtag_cat = IsScienceRun(pev);
2092 bool sci = (runtag_cat==1 || runtag_cat==2);
2096 bool bad = (BadRunCheck(pev) || runtag_cat==2);
2099 if (trd_unusable)
return -1;
2115 int TrigPatt(0),PhysTrigPatt(0);
2116 int tofpattft[4]={0,0,0,0};
2117 int tofpattbz[4]={0,0,0,0};
2118 int AccPatt(0),NAccs(0);
2119 int TOFTrigFl1(-1),TOFTrigFl2(-1),ECTrigFl(-1);
2122 int PhysTrSet[8]={0,0,0,0,0,0,0,0};
2123 PhysTrSet[0]=(1<<1);
2124 PhysTrSet[1]=(1<<4)+(1<<7);
2125 PhysTrSet[2]=(1<<8)+(1<<9);
2126 PhysTrSet[3]=(1<<5);
2127 PhysTrSet[4]=(1<<4)+(1<<10);
2128 PhysTrSet[5]=(1<<12);
2129 PhysTrSet[6]=(1<<11);
2132 for(
int ii=0;ii<4;ii++){
2143 FTZ=((TrigPatt&(1<<5))!=0);
2156 bool CentrOK=((tofpattft[2]&0x1FE01FEL)>0);
2162 if(TOFTrigFl1<=4 && TOFTrigFl1>=0){
2163 L1TrMemPatt|=(1<<1);
2167 if(TOFTrigFl1==0)L1TrMemPatt|=(1<<2);
2171 if(TOFTrigFl1==0 && CentrOK){
2172 L1TrMemPatt|=(1<<4);
2177 for(
int i=0;i<8;i++)if((AccPatt & (1<<i))>0)NAccs+=1;
2178 if(NAccs<1)L1TrMemPatt|=(1<<7);
2179 if(NAccs<5)L1TrMemPatt|=(1<<8);
2183 if(FTZ)L1TrMemPatt|=(1<<5);
2184 if(TOFTrigFl2==0)L1TrMemPatt|=(1<<9);
2188 if((ECTrigFl/10)==3){
2189 L1TrMemPatt|=(1<<10);
2190 L1TrMemPatt|=(1<<11);
2192 else if((ECTrigFl/10==1) || (ECTrigFl/10==2))L1TrMemPatt|=(1<<11);
2195 if(ECTrigFl%10==3)L1TrMemPatt|=(1<<12);
2197 if((L1TrMemPatt&(1<<11))>0)L1TrMemPatt|=(1<<6);
2201 for(
int i=0;i<7;i++){
2202 if((L1TrMemPatt&PhysTrSet[i])==PhysTrSet[i])PhysTrPatt|=(1<<i);
2206 if((PhysTrPatt&0x3EL)>0)
return 1;