CMS 3D CMS Logo

EcalTBReadout Class Reference

#include <SimCalorimetry/EcalTestBeamAlgos/interface/EcalTBReadout.h>

List of all members.

Public Member Functions

 EcalTBReadout (const std::string theEcalTBInfoLabel)
void findTTlist (const int &crysId, const EcalTrigTowerConstituentsMap &etmap)
 search for the TT to be read
void performReadout (edm::Event &event, const EcalTrigTowerConstituentsMap &theTTmap, EBDigiCollection &input, EBDigiCollection &output)
 master function to be called once per event
void readOut (EBDigiCollection &input, EBDigiCollection &output, const EcalTrigTowerConstituentsMap &etmap)
 read only the digis from the selected TT
void setDetIds (const std::vector< DetId > &detIds)
 tell the readout which cells exist
 ~EcalTBReadout ()

Private Attributes

std::string ecalTBInfoLabel_
std::vector< DetIdtheDetIds
int theTargetCrystal_
std::vector< EcalTrigTowerDetIdtheTTlist_

Static Private Attributes

static const int NCRYMATRIX = 7


Detailed Description

Definition at line 20 of file EcalTBReadout.h.


Constructor & Destructor Documentation

EcalTBReadout::EcalTBReadout ( const std::string  theEcalTBInfoLabel  ) 

Definition at line 8 of file EcalTBReadout.cc.

References theTargetCrystal_, and theTTlist_.

00009 : ecalTBInfoLabel_(theEcalTBInfoLabel) {
00010 
00011   theTargetCrystal_ = -1;
00012   theTTlist_.reserve(1);
00013 
00014 }

EcalTBReadout::~EcalTBReadout (  )  [inline]

Definition at line 28 of file EcalTBReadout.h.

00028 {};


Member Function Documentation

void EcalTBReadout::findTTlist ( const int crysId,
const EcalTrigTowerConstituentsMap etmap 
)

search for the TT to be read

step 1: find the correspondence between the crystal identified in module and its DetId assuming only 1 SM present

step 2: find the crystals in the matrix and fill the TT list

loop on all the valid DetId and search for the good ones

Definition at line 16 of file EcalTBReadout.cc.

References Exception, find(), i, EBDetId::ic(), EBDetId::ieta(), EBDetId::iphi(), LogDebug, NCRYMATRIX, theDetIds, theTargetCrystal_, theTTlist_, and EcalTrigTowerConstituentsMap::towerOf().

Referenced by performReadout().

00016                                                                                             {
00017 
00018   // search for the TT involved in the NCRYMATRIX x NCRYMATRIX
00019   // around the target crystal if a new target, otherwise use
00020   // the list already filled
00021 
00022   if ( crysId == theTargetCrystal_ ) { return; }
00023 
00024   theTTlist_.clear();
00025 
00029   
00030   EBDetId theTargetId;
00031   std::vector<DetId>::const_iterator idItr = theDetIds.begin();
00032   unsigned int ncount = 0;
00033   bool found = false;
00034   
00035   while  ( (ncount < theDetIds.size()) && !found ) 
00036   {
00037     EBDetId thisEBdetid(idItr->rawId());
00038     if (thisEBdetid.ic() == crysId) {
00039       theTargetId = thisEBdetid;
00040       found = true;
00041     }
00042     ++idItr;
00043     ++ncount;
00044   }
00045   if ( !found ) {
00046     throw cms::Exception("ObjectNotFound", "Ecal TB target crystal not found in geometry");
00047     return;
00048   }
00049   theTargetCrystal_ = theTargetId.ic();
00050 
00053 
00054   int myEta = theTargetId.ieta();
00055   int myPhi = theTargetId.iphi();
00056 
00057 
00058   for ( int icrysEta = (myEta-(NCRYMATRIX-1)/2) ; icrysEta <= (myEta+(NCRYMATRIX-1)/2) ; ++icrysEta ) {
00059     for ( int icrysPhi = (myPhi-(NCRYMATRIX-1)/2) ; icrysPhi <= (myPhi+(NCRYMATRIX-1)/2) ; ++icrysPhi ) {
00060       
00062 
00063       EBDetId thisEBdetid;
00064 
00065       idItr = theDetIds.begin();
00066       ncount = 0;
00067       found = false;
00068   
00069       while  ( (ncount < theDetIds.size()) && !found ) 
00070         {
00071           EBDetId myEBdetid(idItr->rawId());
00072           if ( (myEBdetid.ieta() == icrysEta) && (myEBdetid.iphi() == icrysPhi) ) {
00073             thisEBdetid = myEBdetid;
00074             found = true;
00075           }
00076           ++idItr;
00077           ++ncount;
00078         }
00079 
00080       if ( found ) {
00081 
00082         EcalTrigTowerDetId thisTTdetId=etmap.towerOf(thisEBdetid);
00083 
00084         LogDebug("EcalDigi") << "Crystal to be readout: sequential id = " << thisEBdetid.ic() << " eta = " << icrysEta << " phi = " << icrysPhi << " from TT = " << thisTTdetId;
00085 
00086         if ( theTTlist_.size() == 0 || ( theTTlist_.size() == 1 && theTTlist_[0] != thisTTdetId )) {
00087           theTTlist_.push_back(thisTTdetId);
00088         }
00089         else {
00090           std::vector<EcalTrigTowerDetId>::iterator ttFound = find(theTTlist_.begin(), theTTlist_.end(), thisTTdetId);
00091           if ( theTTlist_.size() > 1 && ttFound == theTTlist_.end() && *(theTTlist_.end()) != thisTTdetId ) { 
00092             theTTlist_.push_back(thisTTdetId);
00093           }
00094         }
00095       }
00096 
00097     }
00098   }
00099 
00100   edm::LogInfo("EcalDigi") << " TT to be read: ";
00101   for ( unsigned int i = 0 ; i < theTTlist_.size() ; ++i ) {
00102     edm::LogInfo("EcalDigi") << " TT " << i << " " << theTTlist_[i];
00103   }
00104 
00105 }

void EcalTBReadout::performReadout ( edm::Event event,
const EcalTrigTowerConstituentsMap theTTmap,
EBDigiCollection input,
EBDigiCollection output 
)

master function to be called once per event

Definition at line 137 of file EcalTBReadout.cc.

References ecalTBInfoLabel_, findTTlist(), readOut(), and theEcalTBInfo.

Referenced by EcalTBDigiProducer::produce().

00137                                                                                                                                                       {
00138 
00139   // TB readout
00140   // step 1: get the target crystal index
00141 
00142   edm::Handle<PEcalTBInfo> theEcalTBInfo;
00143   event.getByLabel(ecalTBInfoLabel_,theEcalTBInfo);
00144 
00145   int crysId = theEcalTBInfo->nCrystal();
00146 
00147   // step 2: update (if needed) the TT list to be read
00148 
00149   findTTlist(crysId, theTTmap);
00150 
00151   // step 3: perform the readout
00152 
00153   readOut(input, output, theTTmap);
00154 
00155 }

void EcalTBReadout::readOut ( EBDigiCollection input,
EBDigiCollection output,
const EcalTrigTowerConstituentsMap etmap 
)

read only the digis from the selected TT

Definition at line 107 of file EcalTBReadout.cc.

References edm::DataFrameContainer::back(), edm::DataFrame::begin(), edmNew::copy(), edm::DataFrame::end(), find(), EcalDataFrame::frame(), EBDataFrame::id(), edm::DataFrameContainer::push_back(), edm::DataFrameContainer::size(), theTTlist_, and EcalTrigTowerConstituentsMap::towerOf().

Referenced by performReadout().

00107                                                                                                                           {
00108 
00109   /*
00110   for(EBDigiCollection::const_iterator digiItr = input.begin();
00111       digiItr != input.end(); ++digiItr)
00112     {
00113       EcalTrigTowerDetId thisTTdetId=etmap.towerOf(digiItr->id());
00114       std::vector<EcalTrigTowerDetId>::iterator ttFound = find(theTTlist_.begin(), theTTlist_.end(), thisTTdetId);
00115       if ((ttFound != theTTlist_.end()) || *(theTTlist_.end()) == thisTTdetId) { 
00116         output.push_back(*digiItr);
00117       }
00118     }
00119   edm::LogInfo("EcalDigi") << "Read EB Digis: " << output.size();
00120   */
00121 
00122   for (unsigned int digis=0; digis<input.size(); ++digis){
00123     
00124     EBDataFrame ebdf = input[digis];
00125     
00126     EcalTrigTowerDetId thisTTdetId=etmap.towerOf(ebdf.id());
00127     std::vector<EcalTrigTowerDetId>::iterator ttFound = find(theTTlist_.begin(), theTTlist_.end(), thisTTdetId);
00128 
00129     if ((ttFound != theTTlist_.end()) || *(theTTlist_.end()) == thisTTdetId) {      
00130       output.push_back(ebdf.id());
00131       EBDataFrame ebdf2(output.back() );
00132       std::copy( ebdf.frame().begin(), ebdf.frame().end(), ebdf2.frame().begin() );
00133     }
00134   }
00135 }

void EcalTBReadout::setDetIds ( const std::vector< DetId > &  detIds  )  [inline]

tell the readout which cells exist

Definition at line 31 of file EcalTBReadout.h.

References theDetIds.

Referenced by EcalTBDigiProducer::updateGeometry().

00031 {theDetIds = detIds;}


Member Data Documentation

std::string EcalTBReadout::ecalTBInfoLabel_ [private]

Definition at line 52 of file EcalTBReadout.h.

Referenced by performReadout().

const int EcalTBReadout::NCRYMATRIX = 7 [static, private]

Definition at line 48 of file EcalTBReadout.h.

Referenced by findTTlist().

std::vector<DetId> EcalTBReadout::theDetIds [private]

Definition at line 50 of file EcalTBReadout.h.

Referenced by findTTlist(), and setDetIds().

int EcalTBReadout::theTargetCrystal_ [private]

Definition at line 44 of file EcalTBReadout.h.

Referenced by EcalTBReadout(), and findTTlist().

std::vector<EcalTrigTowerDetId> EcalTBReadout::theTTlist_ [private]

Definition at line 46 of file EcalTBReadout.h.

Referenced by EcalTBReadout(), findTTlist(), and readOut().


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