#include #include #include #include #include #include #include "TriggerObjects/XFLD_StorableBank.hh" #include "TriggerObjects/XFFD_StorableBank.hh" #include #include int layer[2][48] = {3,3,3,3,3,3,3,3,1,1,1,1,1,1,1,1,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 4,4,4,4,4,4,4,4,4,4,2,2,2,2,2,2,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,2,2,2,2,2,2,2,2,2,2,2,2}; int cell[2][48] = {0,2,4,6,8,10,12,14,0,2,4,6,0,2,4,6,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,0,1,2,3,4,5,6,7, 0,2,4,6,8,10,12,14,16,18,0,2,4,6,8,10,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,0,1,2,3,4,5,6,7,8,9,10,11}; const int offset[] = {4,4,8,4}; const int COT_CELLS[] ={168, 192, 240, 288, 336, 384, 432, 480}; // const int coffset[5] = {0,48,120,216,336}; // const int coff[4] = {1,1,2,1}; const int fndBrd[4] = {2,3,4,5}; //_____________________________________________________________________________ Int_t StntupleInitXftBlock(TStnDataBlock* block, AbsEvent* event, int mode) { // initialize PES data block with the `event' data // return -1, if bank doesn't exist, 0, if everything is OK TXftBlock* xft = (TXftBlock*) block; xft->Clear(); // // The following code loops over the contents of the XFFD bank (stores pixel info) and // dumps this info into the XFT Tree if(xft->storePixels() | xft->storeHits()) { for (EventRecord::ConstIterator xffd_iter(event,"XFFD_StorableBank"); xffd_iter.is_valid() ; ++xffd_iter) { ConstHandle handle4(xffd_iter) ; ConstHandle handle_xffd(xffd_iter) ; // handle4->print() ; // print is a Trigger_StorableBank method - NOTE THE DIFFERENT HANDLE // handle4->dump() ; // dump() is in StorableBank method // Grab the Finder Output Data for each Board for(ConstBankIterTDC block(handle_xffd); block.is_valid(); ++block) { for(ConstBlockIterTDC card(block); card.is_valid(); ++card) { // for(int nc=0; nc<6; nc++){ //for(int nb=0; nb<8; nb++){ int nc = handle_xffd->get_block(card); int crate = nc/2; int nb = handle_xffd->get_board(card); // if((nc%2)==0) { // printf(" Crate %i Board 1-3 %i \n",nc/2,nb); // } else { // printf(" Crate %i Board 2-4 %i \n",nc/2,nb); // } // Check for nonzero Pixel data from Finders if(xft->storePixels()) { for(int wd=0; wd<16; wd++) { // // Which superlayer are we looking at? int sl = layer[nc%2][wd]; // // Now grab the pixel information (info from 2 cells are stored in this word) int fPixels = card.data_word(wd+1); //int fPixels = handle_xffd->get_word(nc,nb,wd+1); if(fPixels!=-1) { // Now get absolute cell number within the axial superlayer // The last term represents the rotation in phi of the XFT crates relative to CDF phi0. This corresponds to // a shift of 6 slots * #of FinderChips per board * 4 cells per finder chip. int Alayer = layer[nc%2][wd]; int acell = (nc/2*8+nb)*(4*layer[nc%2][wd]+4)+cell[nc%2][wd] - offset[layer[nc%2][wd]-1]-6*4*fndBrd[Alayer-1]; if (acell < 0) acell = acell + COT_CELLS[2*layer[nc%2][wd]-1]; // // The "lower" pixels are the pixels for the lower cell in this word int lowerPixels = (fPixels & 0xFFF); // if(lowerPixels != 0) printf(" Pixels: Layer %i Cell %i, Value %x \n", // layer[nc%2][wd],cell[nc%2][wd],lowerPixels); // // The "upper" pixels are the pixels for the upper cell in this word int upperPixels = (fPixels & 0xFFF0000)>>16; // if(upperPixels != 0) printf(" Pixels: Layer %i Cell %i, Value %x \n", // layer[nc%2][wd],cell[nc%2][wd]+1,upperPixels); // // Now put the pixel info into the tree for (int ipix = 0; ipix<12; ipix++) { int jpix = (lowerPixels>>ipix) & 0x1; int localcell = cell[nc%2][wd]%4; int abspix = 0; int localpix = 0; int chip = cell[nc%2][wd]/4; // // This needs to fixed, look in triggerObjects/xfldstorable bank if (jpix != 0) { // printf("Pixel Found 1: %d %d \n",ipix,jpix); if (sl < 3) { localpix = ipix; abspix = localpix + 12*acell - 6; } else { localpix = ipix/2; if ( (ipix %2) == 0){ abspix = localpix + 6*acell - 3; } else if( (ipix %2) == 1 ){ abspix =(-1)*( localpix + 6*acell - 3); } } xft->NewXftPixel(sl,abspix,crate,nb,chip, localpix,localcell); } jpix = (upperPixels>>ipix) & 0x1 ; localcell = (cell[nc%2][wd]+1)%4; if (jpix != 0) { // printf("Pixel Found 1: %d %d \n",ipix,jpix); if (sl < 3) { localpix = ipix; abspix = localpix + 12*(acell+1) - 6; } else { localpix = ipix/2; if ( (ipix %2) == 0){ abspix = localpix + 6*(acell+1) - 3; } else if( (ipix %2) == 1 ){ abspix =(-1)*( localpix + 6*(acell+1) - 3); } } xft->NewXftPixel(sl,abspix,crate,nb,chip, localpix,localcell); } } } } // loop over words in bank } //if(storePixels.value()) // Check for nonzero Hit information into Finders if(xft->storeHits()) { for(int wd=16; wd<48; wd++) { int fHits = card.data_word(wd+1); //int fHits = handle_xffd->get_word(nc,nb,wd+1); if((fHits&0xFFFFFF) != 0) { int prompt = (fHits & 0xFFF); int delayed = (fHits & 0xFFF000)>>12; // Get the information to associate with the hit int sl = layer[nc%2][wd]; int abscell = (nc/2*8+nb)*(4*layer[nc%2][wd]+4)+cell[nc%2][wd] - offset[layer[nc%2][wd]-1]-6*4*fndBrd[sl-1]; if (abscell < 0) abscell = abscell + COT_CELLS[2*layer[nc%2][wd]-1]; int localcell = cell[nc%2][wd]%4; int chip = cell[nc%2][wd]/4; // printf(" Mez Hits: Layer %i Cell %i Prompt %x Delayed %x \n",sl,localcell,prompt,delayed); xft->NewXftHit(prompt,delayed,sl,abscell,localcell,crate,nb,chip); } } } //if(storeHits.value()) } //loop over boards } //loop over crates } // loop over XFFD bank } //if(storeHits.value() | storePixels.value()) // // The following code loops over the contents of the XFLD bank (stores found track info) and // dumps this info into the XFT Tree if(xft->storeTracks()) { for (EventRecord::ConstIterator xfld_iter(event,"XFLD_StorableBank"); xfld_iter.is_valid() ; ++xfld_iter) { ConstHandle handle3(xfld_iter) ; ConstHandle handle_xfld(xfld_iter) ; // handle3->print() ; // print is a Trigger_StorableBank method - NOTE THE DIFFERENT HANDLE // handle3->dump() ; // dump() is in StorableBank method // this 'if' is added for special version of InitXftBlock for simulated bank, standard vesion doesn't have this. //if (!( handle_xfld->description() == "Simulated Trigger Bank") ) { // Loop over the linker chip on this board and get the track information for(ConstBankIterTDC block(handle_xfld); block.is_valid(); ++block) { for(ConstBlockIterTDC card(block); card.is_valid(); ++card) { int nc = handle_xfld->get_block(card); int nb = handle_xfld->get_board(card)%8; for(int ch=0; ch<12; ch++){ int tfnd4 = handle_xfld->get_isolation(card,ch); int tfnd3 = handle_xfld->get_short(card,ch); if(tfnd4 == 1 || tfnd3 == 1) { int phi = handle_xfld->get_localPhiSL6(card,ch); int pt = handle_xfld->get_ptBin(card,ch); //printf(" Track Found: Crate %i, Board %i, Chip %i \n",nc,nb,ch); //printf(" 4-lay %i, 3-lay %i, Phi %i, Pt %x \n",tfnd4,tfnd3,phi,pt); // // Get phi float phi3 = handle_xfld->get_absPhiSL6(card,ch); // // Get the pt value of this bin float ptValue = handle_xfld->get_ptValue(card,ch); // // Now put the info into the tree xft->NewXftTrack(pt, phi,tfnd3, tfnd4, ch, nb, nc,phi3,ptValue); // } //if track found } // loop over linker chips } //loop over boards } //loop over crates } // xfld_iter.is_valid() ; ++xfld_iter } //if(storeXFTTracks.value()) return 0; }