CMS 3D CMS Logo

EcalTB07DaqFormatter Class Reference

Date
2007/10/23 16:04:07
Revision
1.6
More...

#include <EventFilter/EcalTBRawToDigi/src/EcalTB07DaqFormatter.h>

List of all members.

Public Member Functions

 EcalTB07DaqFormatter (std::string tbName, int a[68][5][5], int b[71], int c[201])
void interpretRawData (const FEDRawData &data, EBDigiCollection &digicollection, EEDigiCollection &eeDigiCollection, EcalPnDiodeDigiCollection &pndigicollection, EcalRawDataCollection &DCCheaderCollection, EBDetIdCollection &dccsizecollection, EcalElectronicsIdCollection &ttidcollection, EcalElectronicsIdCollection &blocksizecollection, EBDetIdCollection &chidcollection, EBDetIdCollection &gaincollection, EBDetIdCollection &gainswitchcollection, EBDetIdCollection &gainswitchstaycollection, EcalElectronicsIdCollection &memttidcollection, EcalElectronicsIdCollection &memblocksizecollection, EcalElectronicsIdCollection &memgaincollection, EcalElectronicsIdCollection &memchidcollection, EcalTrigPrimDigiCollection &tpcollection)
virtual ~EcalTB07DaqFormatter ()

Private Types

enum  SMElectronics_t {
  kSamplesPerChannel = 10, kSamplesPerPn = 50, kChannelsPerTower = 25, kStripsPerTower = 5,
  kChannelsPerStrip = 5, kPnPerTowerBlock = 5, kTriggerTowersAndMem = 70
}
enum  SMGeom_t {
  kModules = 4, kTriggerTowers = 68, kTowersInPhi = 4, kTowersInEta = 17,
  kCrystals = 1700, kPns = 10, kCrystalsInPhi = 20, kCrystalsInEta = 85,
  kCrystalsPerTower = 25, kCardsPerTower = 5, kChannelsPerCard = 5
}

Private Member Functions

std::pair< int, intcellIndex (int tower_id, int strip, int xtal)
int cryIc (int tower_id, int strip, int xtal)
void DecodeMEM (DCCTBTowerBlock *towerblock, EcalPnDiodeDigiCollection &pndigicollection, EcalElectronicsIdCollection &memttidcollection, EcalElectronicsIdCollection &memblocksizecollection, EcalElectronicsIdCollection &memgaincollection, EcalElectronicsIdCollection &memchidcollection)
int getEE_ix (int tower, int strip, int ch)
int getEE_iy (int tower, int strip, int ch)
bool leftTower (int tower) const
bool rightTower (int tower) const

Private Attributes

unsigned _ExpectedTowers [71]
unsigned _expTowersIndex
unsigned _numExpectedTowers
int cryIcMap_ [68][5][5]
int data_MEM [500]
int memRawSample_ [kStripsPerTower][kChannelsPerStrip][kSamplesPerChannel+1]
bool pnAllocated
bool pnIsOkInBlock [kPnPerTowerBlock]
std::string tbName_
int tbStatusToLocation_ [71]
int tbTowerIDToLocation_ [201]
DCCTBDataParsertheParser_


Detailed Description

Date
2007/10/23 16:04:07
Revision
1.6

Author:
N. Marinelli IASA-Athens

G. Della Ricca

G. Franzoni

A. Ghezzi

Definition at line 29 of file EcalTB07DaqFormatter.h.


Member Enumeration Documentation

enum EcalTB07DaqFormatter::SMElectronics_t [private]

Enumerator:
kSamplesPerChannel 
kSamplesPerPn 
kChannelsPerTower 
kStripsPerTower 
kChannelsPerStrip 
kPnPerTowerBlock 
kTriggerTowersAndMem 

Definition at line 83 of file EcalTB07DaqFormatter.h.

00083                        {
00084     kSamplesPerChannel = 10,  // Number of sample per channel, per event
00085     kSamplesPerPn          = 50,  // Number of sample per PN, per event
00086     kChannelsPerTower   = 25,  // Number of channels per trigger tower
00087     kStripsPerTower        = 5,   // Number of VFE cards per trigger tower
00088     kChannelsPerStrip     = 5,   // Number channels per VFE card
00089     kPnPerTowerBlock    = 5,    // Number Pn diodes pertaining to 1 tower block = 1/2 mem box
00090     kTriggerTowersAndMem  = 70    // Number of trigger towers block including mems
00091   };

enum EcalTB07DaqFormatter::SMGeom_t [private]

Enumerator:
kModules 
kTriggerTowers 
kTowersInPhi 
kTowersInEta 
kCrystals 
kPns 
kCrystalsInPhi 
kCrystalsInEta 
kCrystalsPerTower 
kCardsPerTower 
kChannelsPerCard 

Definition at line 69 of file EcalTB07DaqFormatter.h.

00069                 {
00070      kModules = 4,           // Number of modules per supermodule
00071      kTriggerTowers = 68,    // Number of trigger towers per supermodule
00072      kTowersInPhi = 4,       // Number of trigger towers in phi
00073      kTowersInEta = 17,      // Number of trigger towers in eta
00074      kCrystals = 1700,       // Number of crystals per supermodule
00075      kPns = 10,                  // Number of PN laser monitoring diodes per supermodule
00076      kCrystalsInPhi = 20,    // Number of crystals in phi
00077      kCrystalsInEta = 85,    // Number of crystals in eta
00078      kCrystalsPerTower = 25, // Number of crystals per trigger tower
00079      kCardsPerTower = 5,     // Number of VFE cards per trigger tower
00080      kChannelsPerCard = 5    // Number of channels per VFE card
00081    };


Constructor & Destructor Documentation

EcalTB07DaqFormatter::EcalTB07DaqFormatter ( std::string  tbName,
int  a[68][5][5],
int  b[71],
int  c[201] 
)

Definition at line 37 of file EcalTB07DaqFormatter.cc.

References cryIcMap_, i, j, k, LogDebug, python::trackProbabilityAnalysis_cff::parameters, tbName_, tbStatusToLocation_, tbTowerIDToLocation_, and theParser_.

00040                                                                           {
00041 
00042   LogDebug("EcalTB07RawToDigi") << "@SUB=EcalTB07DaqFormatter";
00043   std::vector<ulong> parameters;
00044   parameters.push_back(10); // parameters[0] is the xtal samples 
00045   parameters.push_back(1);  // parameters[1] is the number of trigger time samples for TPG's
00046   parameters.push_back(68); // parameters[2] is the number of TT
00047   parameters.push_back(68); // parameters[3] is the number of SR Flags
00048   parameters.push_back(1);  // parameters[4] is the dcc id
00049   parameters.push_back(1);  // parameters[5] is the sr id
00050   parameters.push_back(1);  // parameters[6] is the tcc1 id
00051   parameters.push_back(2);  // parameters[7] is the tcc2 id
00052   parameters.push_back(3);  // parameters[8] is the tcc3 id
00053   parameters.push_back(4);  // parameters[9] is the tcc4 id
00054 
00055   theParser_ = new DCCTBDataParser(parameters);
00056 
00057   tbName_ = tbName;
00058 
00059   for(int i=0; i<68; ++i) 
00060     for (int j=0; j<5; ++j)
00061       for (int k=0; k<5; ++k)
00062         cryIcMap_[i][j][k] = cryIcMap[i][j][k];
00063   
00064   for(int i=0; i<71; ++i)
00065     tbStatusToLocation_[i] = tbStatusToLocation[i];
00066   
00067   for(int i=0; i<201; ++i)
00068     tbTowerIDToLocation_[i] = tbTowerIDToLocation[i];
00069 
00070 
00071 }

virtual EcalTB07DaqFormatter::~EcalTB07DaqFormatter (  )  [inline, virtual]

Definition at line 34 of file EcalTB07DaqFormatter.h.

References LogDebug.

00034 {LogDebug("EcalTB07RawToDigi") << "@SUB=EcalTB07DaqFormatter" << "\n"; };


Member Function Documentation

std::pair< int, int > EcalTB07DaqFormatter::cellIndex ( int  tower_id,
int  strip,
int  xtal 
) [private]

Definition at line 924 of file EcalTB07DaqFormatter.cc.

References eta, kCardsPerTower, kChannelsPerCard, kCrystalsPerTower, kTowersInPhi, phi, and rightTower().

00924                                                                                  {
00925   
00926   int xtal= (strip-1)*5+ch-1;
00927   //  cout << " cellIndex input xtal " << xtal << endl;
00928   std::pair<int,int> ind;
00929   
00930   int eta = (tower_id - 1)/kTowersInPhi*kCardsPerTower;
00931   int phi = (tower_id - 1)%kTowersInPhi*kChannelsPerCard;
00932 
00933   if (rightTower(tower_id))
00934     eta += xtal/kCardsPerTower;
00935   else
00936     eta += (kCrystalsPerTower - 1 - xtal)/kCardsPerTower;
00937 
00938   if (rightTower(tower_id) && (xtal/kCardsPerTower)%2 == 1 ||
00939       !rightTower(tower_id) && (xtal/kCardsPerTower)%2 == 0)
00940 
00941     phi += (kChannelsPerCard - 1 - xtal%kChannelsPerCard);
00942   else
00943     phi += xtal%kChannelsPerCard;
00944 
00945 
00946   ind.first =eta+1;  
00947   ind.second=phi+1; 
00948 
00949   //  cout << "  EcalTB07DaqFormatter::cell_index eta " << ind.first << " phi " << ind.second << " " << endl;
00950 
00951   return ind;
00952 
00953 }

int EcalTB07DaqFormatter::cryIc ( int  tower_id,
int  strip,
int  xtal 
) [private]

Definition at line 980 of file EcalTB07DaqFormatter.cc.

References cryIcMap_.

Referenced by getEE_ix(), getEE_iy(), and interpretRawData().

00980                                                              {
00981 
00982   if ( strip < 1 || 5<strip || ch <1 || 5 < ch || 68<tower)
00983     {
00984       edm::LogWarning("EcalTB07RawToDigiChId") << "EcalTB07DaqFormatter::interpretRawData (cryIc) "
00985                                              << " wrong channel id, since out of range: "
00986                                              << "\t strip: "  << strip  << "\t channel: " << ch
00987                                              << "\t in TT: " << tower;
00988       return -1;
00989     }
00990   
00991   // YM
00992   return cryIcMap_[tower-1][strip-1][ch-1];
00993   //std::pair<int,int> cellInd= EcalTB07DaqFormatter::cellIndex(tower, strip, ch); 
00994   //return cellInd.second + (cellInd.first-1)*kCrystalsInPhi;
00995 }

void EcalTB07DaqFormatter::DecodeMEM ( DCCTBTowerBlock towerblock,
EcalPnDiodeDigiCollection pndigicollection,
EcalElectronicsIdCollection memttidcollection,
EcalElectronicsIdCollection memblocksizecollection,
EcalElectronicsIdCollection memgaincollection,
EcalElectronicsIdCollection memchidcollection 
) [private]

Definition at line 707 of file EcalTB07DaqFormatter.cc.

References _ExpectedTowers, _expTowersIndex, edm::EDCollection< T >::begin(), data_MEM, edm::EDCollection< T >::end(), id, kChannelsPerStrip, kChannelsPerTower, kPnPerTowerBlock, kSamplesPerChannel, kSamplesPerPn, kStripsPerTower, LogDebug, memRawSample_, pnIsOkInBlock, edm::EDCollection< T >::push_back(), edm::SortedCollection< T, SORT >::push_back(), EcalPnDiodeDigi::setSample(), EcalPnDiodeDigi::setSize(), edm::EDCollection< T >::size(), strip(), DCCTBTowerBlock::towerID(), and DCCTBTowerBlock::xtalBlocks().

Referenced by interpretRawData().

00710 {
00711   
00712   LogDebug("EcalTB07RawToDigi") << "@SUB=EcalTB07DaqFormatter::DecodeMEM"
00713                               << "in mem " << towerblock->towerID();  
00714   
00715   int  tower_id = towerblock ->towerID() ;
00716   int  mem_id   = tower_id-69;
00717 
00718   // initializing container
00719   for (int st_id=0; st_id< kStripsPerTower; st_id++){
00720     for (int ch_id=0; ch_id<kChannelsPerStrip; ch_id++){
00721       for (int sa=0; sa<11; sa++){      
00722         memRawSample_[st_id][ch_id][sa] = -1;}    } }
00723 
00724   
00725   // check that tower block id corresponds to mem boxes
00726   if(tower_id != 69 && tower_id != 70) 
00727     {
00728       edm::LogWarning("EcalTB07RawToDigiTowerId") << "@SUB=EcalTB07DaqFormatter:decodeMem"
00729                                     << "DecodeMEM: this is not a mem box tower (" << tower_id << ")";
00730       ++ _expTowersIndex;
00731       return;
00732     }
00733 
00734      
00735   /******************************************************************************
00736    // getting the raw hits from towerBlock while checking tt and ch data structure 
00737    ******************************************************************************/
00738   std::vector<DCCTBXtalBlock *> & dccXtalBlocks = towerblock->xtalBlocks();
00739   std::vector<DCCTBXtalBlock*>::iterator itXtal;
00740 
00741   // checking mem tower block fo size
00742   if (dccXtalBlocks.size() != kChannelsPerTower)
00743     {     
00744       LogDebug("EcalTB07RawToDigiDccBlockSize") << "@SUB=EcalTB07DaqFormatter:decodeMem"
00745                                   << " wrong dccBlock size, namely: "  << dccXtalBlocks.size() 
00746                                   << ", for mem " << _ExpectedTowers[_expTowersIndex];
00747 
00748       // reporting mem-tt block size problem
00749       // chosing channel 1 as representative as a dummy...
00750       EcalElectronicsId id(1, (int)_ExpectedTowers[_expTowersIndex], 1, 1);
00751       memblocksizecollection.push_back(id);
00752 
00753       ++ _expTowersIndex;
00754       return;  // if mem tt block size not ok - do not build any Pn digis
00755     }
00756   
00757 
00758   // loop on channels of the mem block
00759   int  cryCounter = 0;   int  strip_id  = 0;   int  xtal_id   = 0;  
00760 
00761   for ( itXtal = dccXtalBlocks.begin(); itXtal < dccXtalBlocks.end(); itXtal++ ) {
00762     strip_id                     = (*itXtal) ->getDataField("STRIP ID");
00763     xtal_id                      = (*itXtal) ->getDataField("XTAL ID");
00764     int wished_strip_id  = cryCounter/ kStripsPerTower;
00765     int wished_ch_id     = cryCounter% kStripsPerTower;
00766     
00767     if( (wished_strip_id+1) != ((int)strip_id) ||
00768         (wished_ch_id+1) != ((int)xtal_id) )
00769       {
00770         
00771         LogDebug("EcalTB07RawToDigiChId") << "@SUB=EcalTB07DaqFormatter:decodeMem"
00772                                     << " in mem " <<  towerblock->towerID()
00773                                     << ", expected:\t strip"
00774                                     << (wished_strip_id+1)  << " cry " << (wished_ch_id+1) << "\tfound: "
00775                                     << "  strip " <<  strip_id << "  cry " << xtal_id;
00776         
00777         // report on crystal with unexpected indices
00778         EcalElectronicsId id(1, (int)_ExpectedTowers[_expTowersIndex], wished_strip_id,  wished_ch_id);
00779         memchidcollection.push_back(id);
00780       }
00781     
00782     
00783     // Accessing the 10 time samples per Xtal:
00784     memRawSample_[wished_strip_id][wished_ch_id][1] = (*itXtal)->getDataField("ADC#1");
00785     memRawSample_[wished_strip_id][wished_ch_id][2] = (*itXtal)->getDataField("ADC#2");
00786     memRawSample_[wished_strip_id][wished_ch_id][3] = (*itXtal)->getDataField("ADC#3");
00787     memRawSample_[wished_strip_id][wished_ch_id][4] = (*itXtal)->getDataField("ADC#4");
00788     memRawSample_[wished_strip_id][wished_ch_id][5] = (*itXtal)->getDataField("ADC#5");
00789     memRawSample_[wished_strip_id][wished_ch_id][6] = (*itXtal)->getDataField("ADC#6");
00790     memRawSample_[wished_strip_id][wished_ch_id][7] = (*itXtal)->getDataField("ADC#7");
00791     memRawSample_[wished_strip_id][wished_ch_id][8] = (*itXtal)->getDataField("ADC#8");
00792     memRawSample_[wished_strip_id][wished_ch_id][9] = (*itXtal)->getDataField("ADC#9");
00793     memRawSample_[wished_strip_id][wished_ch_id][10] = (*itXtal)->getDataField("ADC#10");
00794       
00795     cryCounter++;
00796   }// end loop on crystals of mem dccXtalBlock
00797   
00798   // tower accepted and digi read from all 25 channels.
00799   // Increase counter of expected towers before unpacking in the 5 PNs
00800   ++ _expTowersIndex;
00801 
00802 
00803 
00804   /************************************************************
00805    // unpacking and 'cooking' the raw numbers to get PN sample
00806    ************************************************************/
00807   int tempSample=0;
00808   int memStoreIndex=0;
00809   int ipn=0;
00810   for (memStoreIndex=0; memStoreIndex<500; memStoreIndex++)    {
00811     data_MEM[memStoreIndex]= -1;   }
00812   
00813   
00814   for(int strip=0; strip<kStripsPerTower; strip++) {// loop on strips
00815     for(int channel=0; channel<kChannelsPerStrip; channel++) {// loop on channels
00816 
00817       if(strip%2 == 0) 
00818         {ipn= mem_id*5+channel;}
00819       else 
00820         {ipn=mem_id*5+4-channel;}
00821 
00822       for(int sample=0;sample< kSamplesPerChannel ;sample++) {
00823         tempSample= memRawSample_[strip][channel][sample+1];
00824 
00825         int new_data=0;
00826         if(strip%2 == 1) {
00827           // 1) if strip number is even, 14 bits are reversed in order
00828           for(int ib=0;ib<14;ib++)
00829             { 
00830               new_data <<= 1;
00831               new_data=new_data | (tempSample&1);
00832               tempSample >>= 1;
00833             }
00834         } else {
00835           new_data=tempSample;
00836         }
00837 
00838         // 2) flip 11th bit for AD9052 still there on MEM !
00839         // 3) mask with 1 1111 1111 1111
00840         new_data = (new_data ^ 0x800) & 0x3fff;    // (new_data  XOR 1000 0000 0000) & 11 1111 1111 1111
00841         // new_data = (new_data ^ 0x800) & 0x1fff;    // (new_data  XOR 1000 0000 0000) & 1 1111 1111 1111
00842 
00843         //(Bit 12) == 1 -> Gain 16;    (Bit 12) == 0 -> Gain 1  
00844         // gain in mem can be 1 or 16 encoded resp. with 0 ir 1 in the 13th bit.
00845         // checking and reporting if there is any sample with gain==2,3
00846         short sampleGain = (new_data &0x3000)/4096;
00847         if (  sampleGain==2 || sampleGain==3) 
00848           {
00849             EcalElectronicsId id(1, (int)_ExpectedTowers[_expTowersIndex], strip, channel);
00850             memgaincollection.push_back(id);
00851             
00852             edm::LogWarning("EcalTB07RawToDigiGainZero")  << "@SUB=EcalTB07DaqFormatter:decodeMem"
00853                                            << "in mem " <<  towerblock->towerID()
00854                                            << " :\t strip: "
00855                                            << (strip +1)  << " cry: " << (channel+1) 
00856                                            << " has 14th bit non zero! Gain results: "
00857                                            << sampleGain << ".";
00858             
00859             continue;
00860           }// end 'if gain is zero'
00861 
00862         memStoreIndex= ipn*50+strip*kSamplesPerChannel+sample;
00863         // storing in data_MEM also the gain bits
00864         data_MEM[memStoreIndex]= new_data & 0x3fff;
00865 
00866       }// loop on samples
00867     }// loop on strips
00868   }// loop on channels
00869   
00870 
00871 
00872 
00873   for (int pnId=0; pnId<kPnPerTowerBlock; pnId++) pnIsOkInBlock[pnId]=true;
00874   // if anything was wrong with mem_tt_id or mem_tt_size: you would have already exited
00875   // otherwise, if any problem with ch_gain or ch_id: must not produce digis for the pertaining Pn
00876 
00877   if (!      (memgaincollection.size()==0 && memchidcollection.size()==0)          )
00878     {
00879       for ( EcalElectronicsIdCollection::const_iterator idItr = memgaincollection.begin();
00880             idItr != memgaincollection.end();
00881             ++ idItr ) {
00882         int ch = (*idItr).channelId();
00883         ch = (ch-1)/5;
00884         pnIsOkInBlock [ch] = false;
00885       }
00886 
00887       for ( EcalElectronicsIdCollection::const_iterator idItr = memchidcollection.begin();
00888             idItr != memchidcollection.end();
00889             ++ idItr ) {
00890         int ch = (*idItr).channelId();
00891         ch = (ch-1)/5;
00892         pnIsOkInBlock [ch] = false;
00893       }
00894 
00895     }// end: if any ch_gain or ch_id problems exclude the Pn's from digi production
00896 
00897 
00898 
00899 
00900   // looping on PN's of current mem box
00901   for (int pnId = 1;  pnId <  (kPnPerTowerBlock+1); pnId++){
00902 
00903     // if present Pn has any of its 5 channels with problems, do not produce digi for it
00904     if (! pnIsOkInBlock [pnId-1] ) continue;
00905 
00906     // second argument is DccId which is set to 46 to match h2 data in global CMS geometry
00907     EcalPnDiodeDetId PnId(2, 46, pnId +  kPnPerTowerBlock*mem_id);
00908     EcalPnDiodeDigi thePnDigi(PnId );
00909 
00910     thePnDigi.setSize(kSamplesPerPn);
00911 
00912     for (int sample =0; sample<kSamplesPerPn; sample++)
00913       {
00914         EcalFEMSample thePnSample( data_MEM[(mem_id)*250 + (pnId-1)*kSamplesPerPn + sample ] );
00915         thePnDigi.setSample(sample,  thePnSample );  
00916       }
00917     pndigicollection.push_back(thePnDigi);
00918   }
00919   
00920   
00921 }

int EcalTB07DaqFormatter::getEE_ix ( int  tower,
int  strip,
int  ch 
) [private]

Definition at line 955 of file EcalTB07DaqFormatter.cc.

References cryIc(), and tbName_.

Referenced by interpretRawData().

00955                                                               {
00956   // H2 -- ix is in [-90, -80], and iy is in [-5; 5]
00957   int ic = cryIc(tower, strip, ch);
00958   int ix = 0;
00959   if ( tbName_ == "h2" ) 
00960     ix = 95 - (ic-1)/20;
00961 
00962   if ( tbName_ == "h4" )
00963     ix = 35 - (ic-1)%20;
00964 
00965   return ix;
00966 
00967 }

int EcalTB07DaqFormatter::getEE_iy ( int  tower,
int  strip,
int  ch 
) [private]

Definition at line 968 of file EcalTB07DaqFormatter.cc.

References cryIc(), int, and tbName_.

Referenced by interpretRawData().

00968                                                               {
00969   int ic = cryIc(tower, strip, ch);
00970   int iy = 0;
00971   if ( tbName_ == "h2" ) 
00972     iy = 46 + (ic-1)%20;
00973 
00974   if ( tbName_ == "h4" )
00975     iy = 51 + (int)((ic-1)/20);
00976 
00977   return iy;
00978 }

void EcalTB07DaqFormatter::interpretRawData ( const FEDRawData data,
EBDigiCollection digicollection,
EEDigiCollection eeDigiCollection,
EcalPnDiodeDigiCollection pndigicollection,
EcalRawDataCollection DCCheaderCollection,
EBDetIdCollection dccsizecollection,
EcalElectronicsIdCollection ttidcollection,
EcalElectronicsIdCollection blocksizecollection,
EBDetIdCollection chidcollection,
EBDetIdCollection gaincollection,
EBDetIdCollection gainswitchcollection,
EBDetIdCollection gainswitchstaycollection,
EcalElectronicsIdCollection memttidcollection,
EcalElectronicsIdCollection memblocksizecollection,
EcalElectronicsIdCollection memgaincollection,
EcalElectronicsIdCollection memchidcollection,
EcalTrigPrimDigiCollection tpcollection 
)

Definition at line 73 of file EcalTB07DaqFormatter.cc.

References _ExpectedTowers, _expTowersIndex, _numExpectedTowers, edm::DataFrameContainer::back(), GenMuonPlsPt100GeV_cfg::cout, cryIc(), FEDRawData::data(), DCCTBDataParser::dccEvents(), EcalDCCTBHeaderRuntypeDecoder::Decode(), DecodeMEM(), EcalBarrel, lat::endl(), first, getEE_ix(), getEE_iy(), i, i1, id, int, kChannelsPerCard, kChannelsPerStrip, kChannelsPerTower, kCrystals, kPns, kStripsPerTower, kTowersInPhi, kTriggerTowers, kTriggerTowersAndMem, LogDebug, MAX_TCC_SIZE, MAX_TT_SIZE, DCCTBDataParser::parseBuffer(), pnAllocated, edm::DataFrameContainer::pop_back(), edm::DataFrameContainer::push_back(), edm::EDCollection< T >::push_back(), edm::SortedCollection< T, SORT >::push_back(), edm::SortedCollection< T, SORT >::reserve(), edm::DataFrameContainer::reserve(), edm::second(), EcalDCCHeaderBlock::setBasicTriggerType(), EcalDCCHeaderBlock::setBX(), EcalDCCHeaderBlock::setErrors(), EcalDCCHeaderBlock::setFedId(), EcalDCCHeaderBlock::setFEStatus(), EcalDCCHeaderBlock::setId(), EcalDCCHeaderBlock::setLV1(), EcalDCCHeaderBlock::setOrbit(), EcalDCCHeaderBlock::setRunNumber(), EcalTriggerPrimitiveDigi::setSample(), EcalDCCHeaderBlock::setSelectiveReadout(), EcalTriggerPrimitiveDigi::setSize(), EcalDCCHeaderBlock::setSrpStatus(), EcalDCCHeaderBlock::setTccStatus(), EcalDCCHeaderBlock::setTestZeroSuppression(), EcalDCCHeaderBlock::setZeroSuppression(), FEDRawData::size(), edm::AssociationMap< Tag >::size(), sr, strip(), tbName_, tbStatusToLocation_, tbTowerIDToLocation_, theParser_, and v.

Referenced by EcalDCCTB07UnpackingModule::produce().

00088   {
00089 
00090 
00091   const unsigned char * pData = fedData.data();
00092   int length = fedData.size();
00093   bool shit=true;
00094   unsigned int tower=0;
00095   int ch=0;
00096   int strip=0;
00097 
00098   LogDebug("EcalTB07RawToDigi") << "@SUB=EcalTB07DaqFormatter::interpretRawData"
00099                               << "size " << length;
00100  
00101 
00102   // mean + 3sigma estimation needed when switching to 0suppressed data
00103   digicollection.reserve(kCrystals);
00104   eeDigiCollection.reserve(kCrystals);
00105   pnAllocated = false;
00106   
00107 
00108   theParser_->parseBuffer( reinterpret_cast<ulong*>(const_cast<unsigned char*>(pData)), static_cast<ulong>(length), shit );
00109   
00110   std::vector< DCCTBEventBlock * > &   dccEventBlocks = theParser_->dccEvents();
00111 
00112   // Access each DCCTB block
00113   for( std::vector< DCCTBEventBlock * >::iterator itEventBlock = dccEventBlocks.begin(); 
00114        itEventBlock != dccEventBlocks.end(); 
00115        itEventBlock++){
00116     
00117     bool _displayParserMessages = false;
00118     if( (*itEventBlock)->eventHasErrors() && _displayParserMessages)
00119       {
00120         edm::LogWarning("EcalTB07RawToDigi") << "@SUB=EcalTB07DaqFormatter::interpretRawData"
00121                                       << "errors found from parser... ";
00122         edm::LogWarning("EcalTB07RawToDigi") << (*itEventBlock)->eventErrorString();
00123         edm::LogWarning("EcalTB07RawToDigi") << "@SUB=EcalTB07DaqFormatter::interpretRawData"
00124                                       << "... errors from parser notified";
00125       }
00126 
00127     // getting the fields of the DCC header
00128     EcalDCCHeaderBlock theDCCheader;
00129 
00130     theDCCheader.setId(46);                                                      // tb EE unpacker: forced to 46 to match EE region used at h2
00131     int fedId = (*itEventBlock)->getDataField("FED/DCC ID");
00132     theDCCheader.setFedId( fedId );                                             // fed id as found in raw data (0... 35 at tb )
00133 
00134     theDCCheader.setRunNumber((*itEventBlock)->getDataField("RUN NUMBER"));
00135     short trigger_type = (*itEventBlock)->getDataField("TRIGGER TYPE");
00136     short zs  = (*itEventBlock)->getDataField("ZS");
00137     short tzs = (*itEventBlock)->getDataField("TZS");
00138     short sr  = (*itEventBlock)->getDataField("SR");
00139     bool  dataIsSuppressed;
00140 
00141     // if zs&&tzs the suppression algo is used in DCC, the data are not suppressed and zs-bits are set
00142     if ( zs && !(tzs) ) dataIsSuppressed = true;
00143     else  dataIsSuppressed = false;
00144 
00145     if(trigger_type >0 && trigger_type <5){theDCCheader.setBasicTriggerType(trigger_type);}
00146     else{ edm::LogWarning("EcalTB07RawToDigiTriggerType") << "@SUB=EcalTB07DaqFormatter::interpretRawData"
00147                                                         << "unrecognized TRIGGER TYPE: "<<trigger_type;}
00148     theDCCheader.setLV1((*itEventBlock)->getDataField("LV1"));
00149     theDCCheader.setOrbit((*itEventBlock)->getDataField("ORBIT COUNTER"));
00150     theDCCheader.setBX((*itEventBlock)->getDataField("BX"));
00151     theDCCheader.setErrors((*itEventBlock)->getDataField("DCC ERRORS"));
00152     theDCCheader.setSelectiveReadout( sr );
00153     theDCCheader.setZeroSuppression( zs );
00154     theDCCheader.setTestZeroSuppression( tzs );
00155     theDCCheader.setSrpStatus((*itEventBlock)->getDataField("SR_CHSTATUS"));
00156 
00157 
00158 
00159 
00160     std::vector<short> theTCCs;
00161     for(int i=0; i<MAX_TCC_SIZE; i++){
00162       
00163       char TCCnum[20]; sprintf(TCCnum,"TCC_CHSTATUS#%d",i+1); std::string TCCnumS(TCCnum);
00164       theTCCs.push_back ((*itEventBlock)->getDataField(TCCnumS) );
00165     }
00166     theDCCheader.setTccStatus(theTCCs);
00167 
00168 
00169     std::vector< DCCTBTCCBlock * > tccBlocks = (*itEventBlock)->tccBlocks();
00170     
00171     for(    std::vector< DCCTBTCCBlock * >::iterator itTCCBlock = tccBlocks.begin(); 
00172             itTCCBlock != tccBlocks.end(); 
00173             itTCCBlock ++)
00174       {
00175 
00176         std::vector< std::pair<int,bool> > TpSamples = (* itTCCBlock) -> triggerSamples() ;
00177         // std::vector of 3 bits
00178         std::vector<int> TpFlags      = (* itTCCBlock) -> triggerFlags() ;
00179         
00180         // there have always to be 68 primitives and flags, per FED
00181         if (TpSamples.size()==68   && TpFlags.size()==68)
00182           {
00183             for(int i=0; i<((int)TpSamples.size()); i++)        
00184               {
00185                 
00186                 int etaTT = (i)  / kTowersInPhi +1;
00187                 int phiTT = (i) % kTowersInPhi +1;
00188 
00189                 // follow HB convention in iphi
00190                 phiTT=3-phiTT;
00191                 if(phiTT<=0)phiTT=phiTT+72;
00192 
00193                 EcalTriggerPrimitiveSample theSample(TpSamples[i].first, TpSamples[i].second, TpFlags[i]);
00194 
00195                 EcalTrigTowerDetId idtt(2, EcalBarrel, etaTT, phiTT, 0);
00196                 EcalTriggerPrimitiveDigi thePrimitive(idtt);
00197                 thePrimitive.setSize(1);                          // hard coded
00198                 thePrimitive.setSample(0, theSample);
00199                 
00200                 tpcollection.push_back(thePrimitive);
00201                 
00202                 LogDebug("EcalTB07RawToDigiTpg") << "@SUBS=EcalTB07DaqFormatter::interpretRawData"
00203                                                << "tower: " << (i+1) 
00204                                                << " primitive: " << TpSamples[i].first
00205                                                << " flag: " << TpSamples[i].second;
00206 
00207                 LogDebug("EcalTB07RawToDigiTpg") << "@SUBS=EcalTB07DaqFormatter::interpretRawData"<<
00208                   "tower: " << (i+1) << " flag: " << TpFlags[i];
00209               }// end loop on tower primitives
00210             
00211           }// end if
00212         else
00213           {
00214             edm::LogWarning("EcalTB07RawToDigiTpg") << "68 elements not found for TpFlags or TpSamples, collection will be empty";
00215           }
00216       }  
00217     
00218     
00219     
00220     
00221     short TowerStatus[MAX_TT_SIZE+1];
00222     char buffer[20];
00223     std::vector<short> theTTstatus;
00224     for(int i=1;i<MAX_TT_SIZE+1;i++)
00225       { 
00226         sprintf(buffer, "FE_CHSTATUS#%d", i);
00227         std::string Tower(buffer);
00228         TowerStatus[i]= (*itEventBlock)->getDataField(Tower);
00229         theTTstatus.push_back(TowerStatus[i]);
00230         //std::cout << "tower " << i << " has status " <<  TowerStatus[i] << std::endl;  
00231       }
00232     bool checkTowerStatus = TowerStatus[1] == 0 && TowerStatus[2] == 0 && TowerStatus[3] == 0 && TowerStatus[4] == 0;
00233     for (int i=5; i < MAX_TT_SIZE+1; ++i) checkTowerStatus = checkTowerStatus && TowerStatus[i] == 1;
00234     if (!checkTowerStatus) {
00235       for(int i=1; i<MAX_TT_SIZE+1; ++i) {
00236         std::cout << "tower " << i << " has status " << TowerStatus[i] << std::endl;
00237       }
00238     }
00239 
00240     theDCCheader.setFEStatus(theTTstatus);
00241 
00242     EcalDCCTBHeaderRuntypeDecoder theRuntypeDecoder;
00243     ulong DCCruntype = (*itEventBlock)->getDataField("RUN TYPE");
00244     theRuntypeDecoder.Decode(DCCruntype, &theDCCheader);
00245     //DCCHeader filled!
00246     DCCheaderCollection.push_back(theDCCheader);
00247     
00248     // add three more DCC headers (EE region used at h4)
00249     EcalDCCHeaderBlock hdr = theDCCheader;
00250     hdr.setId(04);
00251     DCCheaderCollection.push_back(hdr);
00252     hdr.setId(05);
00253     DCCheaderCollection.push_back(hdr);
00254     hdr.setId(06);
00255     DCCheaderCollection.push_back(hdr);
00256 
00257     std::vector< DCCTBTowerBlock * > dccTowerBlocks = (*itEventBlock)->towerBlocks();
00258     LogDebug("EcalTB07RawToDigi") << "@SUBS=EcalTB07DaqFormatter::interpretRawData"
00259                                 << "dccTowerBlocks size " << dccTowerBlocks.size();
00260 
00261 
00262 
00263     _expTowersIndex=0;_numExpectedTowers=0;
00264     for (int v=0; v<71; v++){
00265       _ExpectedTowers[v]=99999;
00266     }
00267 
00268     // note: these are the tower statuses handled at the moment - to be completed
00269     // staus==0:   tower expected;
00270     // staus==9:   Synk error LV1, tower expected;
00271     // staus==10:  Synk error BX, tower expected;
00272     // status==1, 2, 3, 4, 5:  tower not expected
00273     for (int u=1; u< (kTriggerTowersAndMem+1); u++)
00274       {
00275         // map status array to expected tower array
00276         int towerMap[kTriggerTowersAndMem+1];
00277         for (int i=0; i<kTriggerTowersAndMem; ++i ) towerMap[i] = i;
00278         //towerMap[1] = 6;
00279         //towerMap[2] = 2;
00280         //towerMap[3] = 1;
00281         //towerMap[4] = 5;
00282 
00283         if(   TowerStatus[u] ==0 || TowerStatus[u] ==9 || TowerStatus[u] ==10  ) 
00284           {_ExpectedTowers[_expTowersIndex]= tbStatusToLocation_[u];
00285             _expTowersIndex++;
00286             _numExpectedTowers++;
00287           }
00288       }
00289     // resetting counter of expected towers
00290     _expTowersIndex=0;
00291       
00292       
00293     // if number of dccEventBlocks NOT same as expected stop
00294     if (!      (dccTowerBlocks.size() == _numExpectedTowers)      )
00295       {
00296         // we probably always want to know if this happens
00297         edm::LogWarning("EcalTB07RawToDigiNumTowerBlocks") << "@SUB=EcalTB07DaqFormatter::interpretRawData"
00298                                       << "number of TowerBlocks found (" << dccTowerBlocks.size()
00299                                       << ") differs from expected (" << _numExpectedTowers 
00300                                       << ") skipping event"; 
00301 
00302         EBDetId idsm(1, 1);
00303         dccsizecollection.push_back(idsm);
00304         
00305         return;
00306         
00307       }
00308       
00309 
00310 
00311 
00312 
00313     // Access the Tower block    
00314     for( std::vector< DCCTBTowerBlock * >::iterator itTowerBlock = dccTowerBlocks.begin(); 
00315          itTowerBlock!= dccTowerBlocks.end(); 
00316          itTowerBlock++){
00317 
00318       tower=(*itTowerBlock)->towerID();
00319       // here is "correct" h2 map
00320       //if ( tower == 1  ) tower = 6;
00321       //if ( tower == 71 ) tower = 2;
00322       //if ( tower == 80 ) tower = 1;
00323       //if ( tower == 45 ) tower = 5;
00324       tower = tbTowerIDToLocation_[tower];
00325 
00326       // checking if tt in data is the same as tt expected 
00327       // else skip tower and increment problem counter
00328             
00329       // dccId set to 46 in order to match 'real' CMS positio at H2
00330 
00331       EcalElectronicsId idtt(46, _ExpectedTowers[_expTowersIndex], 1, 1);
00332     
00333 
00334       if (  !(tower == _ExpectedTowers[_expTowersIndex])          )
00335         {       
00336           
00337           if (_ExpectedTowers[_expTowersIndex] <= 68){
00338             edm::LogWarning("EcalTB07RawToDigiTowerId") << "@SUBS=EcalTB07DaqFormatter::interpretRawData"
00339                                                         << "TTower id found (=" << tower 
00340                                                         << ") different from expected (=" <<  _ExpectedTowers[_expTowersIndex] 
00341                                                         << ") " << (_expTowersIndex+1) << "-th tower checked"
00342                                                         << "\n Real hardware id is " << (*itTowerBlock)->towerID();
00343 
00344             //  report on failed tt_id for regular tower block
00345             ttidcollection.push_back(idtt);
00346           }
00347           else
00348             {
00349               edm::LogWarning("EcalTB07RawToDigiTowerId") << "@SUB=EcalTB07DaqFormatter:interpretRawData"
00350                                                         << "DecodeMEM: tower " << tower  
00351                                                         << " is not the same as expected " << ((int)_ExpectedTowers[_expTowersIndex])
00352                                                         << " (according to DCC header channel status)";
00353               
00354               // report on failed tt_id for mem tower block
00355               // chosing channel 1 as representative
00356               EcalElectronicsId id(1, (int)_ExpectedTowers[_expTowersIndex], 1, 1);
00357               memttidcollection.push_back(id);
00358             }
00359 
00360           ++ _expTowersIndex;
00361           continue;     
00362         }// if TT id found  different than expected 
00363         
00364 
00365 
00366       /*********************************
00367        //    tt: 1 ... 68: crystal data
00368        *********************************/
00369       if (  0<  (*itTowerBlock)->towerID() &&
00370             ((*itTowerBlock)->towerID() < (kTriggerTowers+1)  || 
00371              (*itTowerBlock)->towerID() == 71 || 
00372              (*itTowerBlock)->towerID() == 80)
00373             )
00374         {
00375           
00376           std::vector<DCCTBXtalBlock * > & xtalDataBlocks = (*itTowerBlock)->xtalBlocks();      
00377           
00378           // if there is no zero suppression, tower block must have have 25 channels in it
00379           if (  (!dataIsSuppressed)   &&   (xtalDataBlocks.size() != kChannelsPerTower)   )
00380             {     
00381               edm::LogWarning("EcalTB07RawToDigiTowerSize") << "EcalTB07DaqFormatter::interpretRawData, no zero suppression "
00382                                             << "wrong tower block size is: "  << xtalDataBlocks.size() 
00383                                             << " at LV1 " << (*itEventBlock)->getDataField("LV1")
00384                                             << " for TT " << _ExpectedTowers[_expTowersIndex];
00385               // report on wrong tt block size
00386               blocksizecollection.push_back(idtt);
00387 
00388               ++ _expTowersIndex;             continue; 
00389 
00390             }
00391           
00392 
00393           short cryInTower =0;
00394 
00395           short expStripInTower;
00396           short expCryInStrip;
00397           short expCryInTower =0;
00398 
00399           // Access the Xstal data
00400           for( std::vector< DCCTBXtalBlock * >::iterator itXtalBlock = xtalDataBlocks.begin(); 
00401                itXtalBlock!= xtalDataBlocks.end(); 
00402                itXtalBlock++){ //loop on crys of a  tower
00403 
00404             strip              =(*itXtalBlock)->stripID();
00405             ch                 =(*itXtalBlock)->xtalID();
00406             cryInTower  =(strip-1)* kChannelsPerCard + (ch -1);
00407 
00408             expStripInTower   =  expCryInTower/5 +1;
00409             expCryInStrip     =  expCryInTower%5 +1;
00410             
00411             
00412             // FIXME: waiting for geometry to do (TT, strip,chNum) <--> (SMChId)
00413             // short abscissa = (_ExpectedTowers[_expTowersIndex]-1)  /4;
00414             // short ordinate = (_ExpectedTowers[_expTowersIndex]-1)  %4;
00415             // temporarily choosing central crystal in trigger tower
00416             // int cryIdInSM  = 45 + ordinate*5 + abscissa * 100;
00417             
00418             
00419             // in case of 0 zuppressed data, check that cryInTower constantly grows
00420             if (dataIsSuppressed)
00421               {
00422                 
00423                 if ( strip < 1 || 5<strip || ch <1 || 5 < ch)
00424                   {
00425                     int  sm = 1; // hardcoded because of test  beam
00426                     for (int StripInTower_ =1;  StripInTower_ < 6; StripInTower_++){
00427                       for (int  CryInStrip_ =1;  CryInStrip_ < 6; CryInStrip_++){
00428                         int  ic        = cryIc(tower, StripInTower_,  CryInStrip_) ;
00429                         EBDetId               idExp(sm, ic,1);
00430                         chidcollection.push_back(idExp);
00431                       }
00432                     }
00433                     
00434                     edm::LogWarning("EcalTB07RawToDigiChId") << "EcalTB07DaqFormatter::interpretRawData with zero suppression, "
00435                                                            << " wrong channel id, since out of range: "
00436                                                            << "\t strip: "  << strip  << "\t channel: " << ch
00437                                                            << "\t in TT: " << _ExpectedTowers[_expTowersIndex]
00438                                                            << "\t at LV1 : " << (*itEventBlock)->getDataField("LV1");
00439                     
00440                     expCryInTower++;
00441                     continue;
00442                   }
00443 
00444 
00445                 // correct ordering
00446                 if(  cryInTower >= expCryInTower ){
00447                   expCryInTower = cryInTower +1;
00448                 }
00449                 
00450                 
00451                 // cry_id wrong because of incorrect ordering within trigger tower
00452                 else
00453                   {
00454                     edm::LogWarning("EcalTB07RawToDigiChId") << "EcalTB07DaqFormatter::interpretRawData with zero suppression, "
00455                                                   << " based on ch ordering within tt, wrong channel id: "
00456                                                   << "\t strip: "  << strip  << "\t channel: " << ch
00457                                                   << "\t cryInTower "  << cryInTower
00458                                                   << "\t expCryInTower: " << expCryInTower
00459                                                   << "\t in TT: " << _ExpectedTowers[_expTowersIndex]
00460                                                   << "\t at LV1: " << (*itEventBlock)->getDataField("LV1");
00461                     
00462                     int  sm = 1; // hardcoded because of test  beam
00463                     for (int StripInTower_ =1;  StripInTower_ < 6; StripInTower_++){
00464                       for (int  CryInStrip_ =1;  CryInStrip_ < 6; CryInStrip_++){
00465                         int  ic        = cryIc(tower, StripInTower_,  CryInStrip_) ;
00466                         EBDetId               idExp(sm, ic,1);
00467                         chidcollection.push_back(idExp);
00468                       }
00469                     }
00470                     
00471                     // chennel with id which does not follow correct odering
00472                     expCryInTower++;                continue;
00473                     
00474                   }// end 'ch_id does not respect growing order'
00475                 
00476               }// end   if zero supression
00477             
00478             
00479 
00480             else {
00481               
00482               // checking that ch and strip are within range and cryInTower is as expected
00483               if(   cryInTower != expCryInTower   ||  
00484                     strip < 1 ||   kStripsPerTower <strip  ||
00485                     ch <1  ||   kChannelsPerStrip < ch    ) 
00486                 {
00487                   
00488                   int ic        = cryIc(tower, expStripInTower,  expCryInStrip) ;
00489                   int  sm = 1; // hardcoded because of test  beam
00490                   EBDetId  idExp(sm, ic,1);
00491                   
00492                   edm::LogWarning("EcalTB07RawToDigiChId") << "EcalTB07DaqFormatter::interpretRawData no zero suppression "
00493                                                     << " wrong channel id for channel: "  << expCryInStrip
00494                                                     << "\t strip: " << expStripInTower
00495                                                     << "\t in TT: " << _ExpectedTowers[_expTowersIndex]
00496                                                     << "\t at LV1: " << (*itEventBlock)->getDataField("LV1")
00497                                                     << "\t   (in the data, found channel:  " << ch
00498                                                     << "\t strip:  " << strip << " ).";
00499 
00500                   
00501                   // report on wrong channel id
00502                   chidcollection.push_back(idExp);
00503 
00504                   // there has been unexpected crystal id, dataframe not to go to the Event
00505                   expCryInTower++;                continue;
00506                   
00507                 } // if channel in data does not equal expected channel
00508 
00509               expCryInTower++;
00510 
00511             } // end 'not zero suppression'
00512             
00513             
00514             
00515             // data  to be stored in EBDataFrame, identified by EBDetId
00516             int  ic = cryIc(tower, strip, ch) ;
00517             int  sm = 1;
00518             EBDetId  id(sm, ic,1);      
00519             // EE data to be stored in EEDataFrame, identified by EEDetId
00520             // eeId(int i, int j, int iz (+1/-1), int mode = XYMODE)
00521             int ix = getEE_ix(tower, strip, ch);
00522             int iy = getEE_iy(tower, strip, ch);
00523 
00524             int iz = 1;
00525             if ( tbName_ == "h4" ) iz = -1;
00526             EEDetId  eeId(ix, iy, iz);
00527                 
00528             // here data frame go into the Event
00529             // removed later on (with a pop_back()) if gain==0 or if forbidden-gain-switch
00530             digicollection.push_back( id );
00531             eeDigiCollection.push_back( eeId );
00532             EBDataFrame theFrame ( digicollection.back() );
00533             EEDataFrame eeFrame ( eeDigiCollection.back() );
00534 
00535             std::vector<int> xtalDataSamples = (*itXtalBlock)->xtalDataSamples();   
00536             //theFrame.setSize(xtalDataSamples.size()); // if needed, to be changed when constructing digicollection
00537             //eeFrame. setSize(xtalDataSamples.size()); // if needed, to be changed when constructing eeDigicollection
00538       
00539 
00540             // gain cannot be 0, checking for that
00541             bool        gainIsOk =true;
00542             unsigned gain_mask      = 12288;    //12th and 13th bit
00543             std::vector <int> xtalGain;
00544 
00545             for (unsigned short i=0; i<xtalDataSamples.size(); ++i ) {
00546               
00547               theFrame.setSample (i, xtalDataSamples[i] );
00548               eeFrame .setSample (i, xtalDataSamples[i] );
00549               
00550               if((xtalDataSamples[i] & gain_mask) == 0){gainIsOk =false;}
00551               
00552               xtalGain.push_back(0);
00553               xtalGain[i] |= (xtalDataSamples[i] >> 12);
00554             }
00555             
00556             if (! gainIsOk) {
00557               
00558               edm::LogWarning("EcalTB07RawToDigiGainZero") << "@SUB=EcalTB07DaqFormatter::interpretRawData"
00559                                             << " gain==0 for strip: "  << expStripInTower
00560                                             << "\t channel: " << expCryInStrip
00561                                             << "\t in TT: " << _ExpectedTowers[_expTowersIndex]
00562                                             << "\t ic: " << ic
00563                                             << "\t at LV1: " << (*itEventBlock)->getDataField("LV1");
00564               // report on gain==0
00565               gaincollection.push_back(id);
00566               
00567               // there has been a gain==0, dataframe not to go to the Event
00568               digicollection.pop_back();
00569               eeDigiCollection.pop_back();
00570               continue; //            expCryInTower already incremented
00571             }
00572 
00573 
00574             
00575             
00576             // looking for forbidden gain transitions
00577             
00578             short firstGainWrong=-1;
00579             short numGainWrong=0;
00580             
00581             for (unsigned short i=0; i<xtalGain.size(); i++ ) {
00582               
00583               if (i>0 && xtalGain[i-1]>xtalGain[i]) {
00584                 
00585                 numGainWrong++;// counting forbidden gain transitions
00586                 
00587                 if (firstGainWrong == -1) {
00588                   firstGainWrong=i;
00589                   edm::LogWarning("EcalTB07RawToDigiGainSwitch") << "@SUB=EcalTB07DaqFormatter::interpretRawData"
00590                                                           << "channelHasGainSwitchProblem: crystal eta = " 
00591                                                           << id.ieta() << " phi = " << id.iphi();
00592                 }
00593                 edm::LogWarning("EcalTB07RawToDigiGainSwitch") << "@SUB=EcalTB07DaqFormatter::interpretRawData"
00594                                                         << "channelHasGainSwitchProblem: sample = " << (i-1) 
00595                                                         << " gain: " << xtalGain[i-1] << " sample: " 
00596                                                         << i << " gain: " << xtalGain[i];
00597               }
00598             }
00599 
00600             // only discriminating if gain stays the same after the forbidden gain transition
00601             bool wrongGainStaysTheSame=false;
00602             if (firstGainWrong!=-1 && firstGainWrong<9){
00603               short gainWrong = xtalGain[firstGainWrong];
00604     
00605               // does wrong gain stay the same after the forbidden transition?
00606               for (unsigned short u=firstGainWrong+1; u<xtalGain.size(); u++){
00607 
00608                 if( gainWrong == xtalGain[u]) 
00609                   wrongGainStaysTheSame=true; 
00610                 else
00611                   wrongGainStaysTheSame=false; 
00612 
00613               }// END loop on samples after forbidden transition
00614             
00615             }// END OF if firstGainWrong!=0 && firstGainWrong<8
00616 
00617 
00618             if (numGainWrong>0) {
00619               gainswitchcollection.push_back(id);
00620 
00621               if (numGainWrong == 1 && (wrongGainStaysTheSame)) {
00622               
00623                 edm::LogWarning("EcalTB07RawToDigiGainSwitch") << "@SUB=EcalTB07DaqFormatter:interpretRawData"
00624                                                         << "channelHasGainSwitchProblem: wrong transition stays till last sample";
00625                 
00626                 gainswitchstaycollection.push_back(id);              
00627               }
00628               else if (numGainWrong>1) {
00629                 edm::LogWarning("EcalTB07RawToDigiGainSwitch") << "@SUB=EcalTB07DaqFormatter:interpretRawData"
00630                                                         << "channelHasGainSwitchProblem: more than 1 wrong transition";
00631                 
00632                 for (unsigned short i1=0; i1<xtalDataSamples.size(); ++i1 ) {
00633                   int countADC = 0x00000FFF;
00634                   countADC &= xtalDataSamples[i1];
00635                   LogDebug("EcalTB07RawToDigi") << "Sample " << i1 << " ADC " << countADC << " Gain " << xtalGain[i1];
00636                 }
00637 
00638               }// end 'if there is multiple transition'
00639              
00640 
00641               // there has been a forbidden gain transition,  dataframe not to go to the Event
00642               digicollection.pop_back();
00643               eeDigiCollection.pop_back();
00644               continue; //            expCryInTower already incremented
00645 
00646             }// END of:   'if there is a forbidden gain transition'
00647 
00648 
00649           }// end loop on crystals within a tower block
00650           
00651           
00652           _expTowersIndex++;
00653         }// end: tt1 ... tt68, crystal data
00654       
00655 
00656 
00657       
00658       
00659       /******************************************************************
00660        //    tt 69 and 70:  two mem boxes, holding PN0 ... PN9
00661        ******************************************************************/      
00662       else if (       (*itTowerBlock)->towerID() == 69 
00663                       ||           (*itTowerBlock)->towerID() == 70       )     
00664         {
00665           
00666           LogDebug("EcalTB07RawToDigi") << "@SUB=EcalTB07DaqFormatter::interpretRawData"
00667                                       << "processing mem box num: " << (*itTowerBlock)->towerID();
00668 
00669           // if tt 69 or 70 found, allocate Pn digi collection
00670           if(! pnAllocated) 
00671             {
00672               pndigicollection.reserve(kPns);
00673               pnAllocated = true;
00674             }
00675 
00676           DecodeMEM( (*itTowerBlock),  pndigicollection , 
00677                      memttidcollection,  memblocksizecollection,
00678                      memgaincollection,  memchidcollection);
00679           
00680         }// end of < if it is a mem box>
00681       
00682       
00683     
00684 
00685 
00686       // wrong tt id
00687       else  {
00688         edm::LogWarning("EcalTB07RawToDigiTowerId") <<"@SUB=EcalTB07DaqFormatter::interpretRawData"
00689                                       << " processing tt with ID not existing ( "
00690                                       <<  (*itTowerBlock)->towerID() << ")";
00691         ++ _expTowersIndex;
00692         continue; 
00693       }// end: tt id error
00694 
00695     }// end loop on trigger towers
00696       
00697   }// end loop on events
00698 }

bool EcalTB07DaqFormatter::leftTower ( int  tower  )  const [private]

Definition at line 1010 of file EcalTB07DaqFormatter.cc.

References rightTower().

01011 {
01012   return !rightTower(tower);
01013 }

bool EcalTB07DaqFormatter::rightTower ( int  tower  )  const [private]

Definition at line 999 of file EcalTB07DaqFormatter.cc.

Referenced by cellIndex(), and leftTower().

00999                                                      {
01000   
01001   if ((tower>12 && tower<21) || (tower>28 && tower<37) ||
01002       (tower>44 && tower<53) || (tower>60 && tower<69))
01003     return true;
01004   else
01005     return false;
01006 }


Member Data Documentation

unsigned EcalTB07DaqFormatter::_ExpectedTowers[71] [private]

Definition at line 95 of file EcalTB07DaqFormatter.h.

Referenced by DecodeMEM(), and interpretRawData().

unsigned EcalTB07DaqFormatter::_expTowersIndex [private]

Definition at line 96 of file EcalTB07DaqFormatter.h.

Referenced by DecodeMEM(), and interpretRawData().

unsigned EcalTB07DaqFormatter::_numExpectedTowers [private]

Definition at line 94 of file EcalTB07DaqFormatter.h.

Referenced by interpretRawData().

int EcalTB07DaqFormatter::cryIcMap_[68][5][5] [private]

Definition at line 61 of file EcalTB07DaqFormatter.h.

Referenced by cryIc(), and EcalTB07DaqFormatter().

int EcalTB07DaqFormatter::data_MEM[500] [private]

Definition at line 100 of file EcalTB07DaqFormatter.h.

Referenced by DecodeMEM().

int EcalTB07DaqFormatter::memRawSample_[kStripsPerTower][kChannelsPerStrip][kSamplesPerChannel+1] [private]

Definition at line 99 of file EcalTB07DaqFormatter.h.

Referenced by DecodeMEM().

bool EcalTB07DaqFormatter::pnAllocated [private]

Definition at line 101 of file EcalTB07DaqFormatter.h.

Referenced by interpretRawData().

bool EcalTB07DaqFormatter::pnIsOkInBlock[kPnPerTowerBlock] [private]

Definition at line 102 of file EcalTB07DaqFormatter.h.

Referenced by DecodeMEM().

std::string EcalTB07DaqFormatter::tbName_ [private]

Definition at line 64 of file EcalTB07DaqFormatter.h.

Referenced by EcalTB07DaqFormatter(), getEE_ix(), getEE_iy(), and interpretRawData().

int EcalTB07DaqFormatter::tbStatusToLocation_[71] [private]

Definition at line 62 of file EcalTB07DaqFormatter.h.

Referenced by EcalTB07DaqFormatter(), and interpretRawData().

int EcalTB07DaqFormatter::tbTowerIDToLocation_[201] [private]

Definition at line 63 of file EcalTB07DaqFormatter.h.

Referenced by EcalTB07DaqFormatter(), and interpretRawData().

DCCTBDataParser* EcalTB07DaqFormatter::theParser_ [private]

Definition at line 60 of file EcalTB07DaqFormatter.h.

Referenced by EcalTB07DaqFormatter(), and interpretRawData().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:19:56 2009 for CMSSW by  doxygen 1.5.4