// ssthandler.cc // Eric Aubourg CEA/DAPNIA/SPP juillet 1999 // Prediction mouvement d'etoiles entre un tour et le suivant... // si TS -> TS + dT, H -> H + dT, dT=dH // // dz = - cos phi sin az dH (check sign) // daz = (sin phi - cos az cotg z cos phi) dH (check sign) // // free parameters = period + phase #include #include "ssthandler.h" #include "pisteetoile.h" // diodpermut[i] = channel de la diode i int SSTHandler::diodpermut[46]= { 8,24,40, 9,25,41,10,26,42,11, 27,43,16,32, 1,17,33, 2,18,34, 3,19,35,12,28,44,13,29,45,14, 30,46,15,31,47,20,36, 5,21,37, 6,22,38, 7,23,39}; // voies 0 et 4 non connectees, voie 1 en panne. SSTHandler::SSTHandler() :sstchass("SSTChassLogFile") { diodeHistLength = nb_per_block*2+10; diodeT = new int[diodeHistLength*nb_photo_diodes]; starHistLength = 300; lastBlkNum = -1; //Has2Bars(false); prcTodo=0; pPiste = NULL; LastBlockSSTNb = -2; noStarDet = 0; findStarConstruct(); } SSTHandler::SSTHandler(SSTHandler const& x) :sstchass("SSTChassLogFile") { diodeHistLength = x.diodeHistLength; diodeT = new int[diodeHistLength*nb_photo_diodes]; memcpy(diodeT, x.diodeT, diodeHistLength*nb_photo_diodes); starHistLength = x.starHistLength; prcTodo = x.prcTodo; // has2bars = x.has2bars; lastBlkNum = x.lastBlkNum; pPiste = NULL; LastBlockSSTNb = x.LastBlockSSTNb; noStarDet = x.noStarDet; findStarConstruct(); for(int i=0; isst[i][j*3+k]; word = (word >> (4*l)) & 0xF; // printf("diode %d mot %d valeur %d\n", j*8+l, k, word); diod[j*8+l] = (diod[j*8+l] << 4) + word; } //for (j=0; j<48; j++) if (diod[j]>2047) diod[j] -= 4096; for (j=0; j<48; j++) diod[j] -= 2048; } void SSTHandler::PermutDiode() { int j0 = diodeHistLength-(nb_per_block*2); // Decalage vers la gauche de la taille d'un bloc memcpy(diodeT, diodeT + (nb_per_block*2)*nb_photo_diodes, j0*nb_photo_diodes); for (int j=0; j0) { m = s/n; sig = sqrt(s2/n - m*m); } else { m = 0; break; } } for (int i=0; i<46; i++) diode(j+j0,i) -= m; */ } } int SSTHandler::getRawSignal(int imesure, int idiode) // for last block { if (imesure<0 || imesure>=nb_per_block*2 || idiode<0 || idiode>=48) return -99999; return diodeRaw[imesure][idiode]; } int SSTHandler::getSignal(int imesure, int idiode) // for last block { int j0 = diodeHistLength-(nb_per_block*2); if (imesure+j0<0 || imesure>=nb_per_block*2 || idiode<0 || idiode>=nb_photo_diodes) return -99999; return diode(imesure+j0, idiode); } int SSTHandler::FindStars(block_type_sst* blk) { NbStarInBlock=0; LastBlockStarVec.clear(); int NoFirstSpInBlock=FirstSplNb(blk); int jd0 = diodeHistLength-NbSampleBlock; bool FlagLBlockPerdu=false; int ThisBlockNumb=numero_block(blk); if ((LastBlockSSTNb+1)==ThisBlockNumb) LastBlockSSTNb++; else { FlagLBlockPerdu=true; LastBlockSSTNb=ThisBlockNumb; } // On cherche les etoiles for(int NoDiode=0;NoDiodefill(Diodedata+offseDataDiod,FirstSplNb(blk)); offseDataDiod+=PhDiodTabLong; } else { pPiste->push(Diodedata); offseDataDiod+=Pousslong; } // Recherchons les etoiles while (true) { if (pPiste->traque()) { // On a trouve! LastStar=pPiste->DonneEtoile(); /* double dum= LastStar.TEchan; pair unepaire=make_pair(dum,LastStar); StarHistoryMap.insert(unepaire); */ StarHistoryMap[LastStar.TEchan]=LastStar; //On empile sur la map. NbStarInBlock++; #ifdef SST_DEBUG // On écrit les pistes ayant déclénchées int NoDiodeEvt=LastStar.NoDiode; if(pPisteDump[NoDiodeEvt]->is_open()) for(int noSamp=0; noSamp=NbSampleBlock) break; else { pPiste->push(Diodedata+offseDataDiod); offseDataDiod+=Pousslong; } } } // On ne garde que les NbEtInSetMax dernières étoiles int nbEtoileInMap=StarHistoryMap.size(); if(nbEtoileInMap>NbEtInMapMax) { int nbErase=nbEtoileInMap-NbEtInMapMax; StarHistIter StarIter=StarHistoryMap.begin(); for(int i=0;i::reverse_iterator StarHistReIter= StarHistoryMap.rbegin() ; for(int i=0; i0) { // On écrit les étoiles detectées vector::reverse_iterator StarVecRevIter; StarVecRevIter=LastBlockStarVec.rbegin(); for(int i=0; iclose(); delete pPisteDump[pistNumb]; } delete pPisteDump; #endif return; } int SSTHandler::getNumbStar(int iSampl) { StarHistIter IterLow=StarHistoryMap.lower_bound((double)iSampl); StarHistIter IterHigh=StarHistoryMap.upper_bound((double)(iSampl+1.)); int Compteur=0; while (!(IterLow==IterHigh)) {IterLow++; Compteur++;} return Compteur; } double SSTHandler::getStarF(int iSampl, int istar){ if( (getNumbStar(iSampl)==0)||(getNumbStar(iSampl)