CDF II
CDF KITS
source navigation ]
diff markup ]
identifier search ]
freetext search ]
file search ]
 
Architecture: i386 ]
Version: 4.10.4 ] [ 4.10.5 ] [ 4.8.4 ] [ 4.8.4l3s ] [ 4.8.5 ] [ 4.9.0 ] [ 4.9.1 ] [ 4.9.1.hpt3 ] [ 4.9.1hpt3 ] [ 4.9.1top1 ] [ 5.0.0 ] [ 5.1.0 ] [ 5.1.0beamonly ] [ 5.1.1 ] [ 5.2.0 ] [ 5.3.0 ] [ 5.3.1 ] [ 5.3.1dsp ] [ 5.3.3 ] [ 5.3.3_nt ] [ 5.3.4 ] [ 6.1.1 ] [ 6.1.1b ] [ 6.1.2 ] [ 6.1.3 ] [ 6.1.4 ] [ 6.1.4int3 ] [ 6.1.4mc ] [ 6.1.4mc_a ] [ 6.1.6 ] [ development ]

001 //-----------------------------------------------------------------------------
002 //  Jan 11 2001 P.Murat: STNTUPLE utility routines
003 //-----------------------------------------------------------------------------
004 
005 #include "evt/Event.hh"
006 #include "Bbos/bank_interface.hh"
007 #include "Stntuple/base/TStnArrayI.hh"
008 #include "Stntuple/data/TTdcHeader.hh"
009 
010 #include "Stntuple/mod/StntupleUtilities.hh"
011 
012 //_____________________________________________________________________________
013 Int_t StntupleUnpackTdcBank(TRYBOS_BANK* bank, TStnArrayI& a)
014 {
015   // unpack YBOS TDC bank into a TStnArrayI
016 
017   int         loc, iloc, nblk, nw, nw_blk, nw_total, ntdc, loc_blk, loc_hdr;
018   int         loc_data, ver;
019   TTdcHeader* header;
020 
021   if (! bank) return 0;
022 
023   nw_total    = 0;
024   nblk        = bank->iw(0);
025   ver         = bank->bank_version();
026 
027   if (ver == 0) {
028 //-----------------------------------------------------------------------------
029 // old TDC format : define total number of the data words to be copied
030 //-----------------------------------------------------------------------------
031     for (int iblk=0; iblk<nblk; iblk++) {
032       loc_blk = bank->iw(iblk+1);
033       nw_blk  = bank->iw(iblk+2)-loc_blk;
034       if (nw_blk > 0) {
035         ntdc = bank->iw(loc_blk);
036         for (int itdc=0; itdc<ntdc; itdc++) {
037           loc = loc_blk+itdc+1;
038           nw  = bank->iw(loc+1)-bank->iw(loc);
039 //-----------------------------------------------------------------------------
040 // forget about redundancy and rely on that TDC header has its ID in it
041 //-----------------------------------------------------------------------------
042           nw_total += nw;
043         }
044       }
045     }
046 
047     a.Reserve(nw_total);
048                                         // now loop over the data blocks 
049                                         // another time and copy the data
050     for (int iblk=0; iblk<nblk; iblk++) {
051       loc_blk = bank->iw(iblk+1);
052       nw_blk  = bank->iw(iblk+2)-loc_blk;
053       if (nw_blk > 0) {
054         ntdc = bank->iw(loc_blk);
055         for (int itdc=0; itdc<ntdc; itdc++) {
056           loc = loc_blk+itdc+1;
057           nw  = bank->iw(loc+1)-bank->iw(loc);
058       
059                                         // forget about redundancy and rely 
060                                         // on that TDC header has its ID in it
061           if (nw > 0) {
062             loc_data = loc_blk+bank->iw(loc);
063             a.Append(&bank->iw(loc_data),nw);
064           }
065         }
066       }
067     }
068   }
069   else if (ver == 1) {
070 //-----------------------------------------------------------------------------
071 // new TDC format : define total number of the data words to be copied
072 //-----------------------------------------------------------------------------
073     for (int iblk=0; iblk<nblk; iblk++) {
074       loc_blk = bank->iw(iblk+1);
075       nw_blk  = bank->iw(iblk+2)-loc_blk;
076       if (nw_blk > 0) {
077         ntdc = bank->iw(loc_blk);
078         for (int itdc=0; itdc<ntdc; itdc++) {
079           loc    = loc_blk+itdc+1;
080 //-----------------------------------------------------------------------------
081 // header - the last word in the group in V1
082 //-----------------------------------------------------------------------------
083           loc_hdr = loc_blk+bank->iw(loc+1)-1;
084           header  = (TTdcHeader*) &bank->iw(loc_hdr);
085           nw      = header->NDataWords();
086           nw_total += (1+nw);
087         }
088       }
089     }
090 
091     a.Reserve(nw_total);
092                                         // now loop over the data blocks 
093                                         // another time and copy the data
094     for (int iblk=0; iblk<nblk; iblk++) {
095       loc_blk = bank->iw(iblk+1);
096       nw_blk  = bank->iw(iblk+2)-loc_blk;
097       if (nw_blk > 0) {
098         ntdc = bank->iw(loc_blk);
099         for (int itdc=0; itdc<ntdc; itdc++) {
100           loc = loc_blk+itdc+1; 
101 //-----------------------------------------------------------------------------
102 // header - the last word in the group in V1
103 //-----------------------------------------------------------------------------
104           loc_hdr = loc_blk+bank->iw(loc+1)-1;
105           a.Append(&bank->iw(loc_hdr),1);
106           header  = (TTdcHeader*) &bank->iw(loc_hdr);
107           nw      = header->NDataWords();
108           if (nw > 0) {
109             loc_data = loc_blk+bank->iw(loc);
110             a.Append(&bank->iw(loc_data),nw);
111           }
112         }
113       }
114     }
115     loc = 0;
116   }
117   return 0;
118 }
119 
120 
121 
122 
123 
124 
125 
126 
127 

source navigation ] diff markup ] identifier search ] freetext search ] file search ]

This page was automatically generated by the LXR engine.
The LXR team
Valid HTML 4.01!

Send problems or questions to cdfcode@fnal.gov