CMS 3D CMS Logo

Public Member Functions | Private Types | Private Attributes

cms::DigitizerFP420 Class Reference

#include <DigitizerFP420.h>

Inheritance diagram for cms::DigitizerFP420:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

List of all members.

Public Member Functions

 DigitizerFP420 (const edm::ParameterSet &conf)
virtual void produce (edm::Event &e, const edm::EventSetup &c)
virtual ~DigitizerFP420 ()

Private Types

typedef std::map< unsigned int,
std::vector< PSimHit >
, std::less< unsigned int > > 
simhit_map
typedef simhit_map::iterator simhit_map_iterator
typedef std::vector< std::string > vstring

Private Attributes

std::vector< HDigiFP420collector
edm::ParameterSet conf_
int dn0
int numStrips
int pn0
int rn0
simhit_map SimHitMap
int sn0
FP420DigiMainstripDigitizer_
FP420NumberingSchemetheFP420NumberingScheme
vstring trackerContainers
int verbosity

Detailed Description

Definition at line 42 of file DigitizerFP420.h.


Member Typedef Documentation

typedef std::map<unsigned int, std::vector<PSimHit>,std::less<unsigned int> > cms::DigitizerFP420::simhit_map [private]

Definition at line 63 of file DigitizerFP420.h.

typedef simhit_map::iterator cms::DigitizerFP420::simhit_map_iterator [private]

Definition at line 64 of file DigitizerFP420.h.

typedef std::vector<std::string> cms::DigitizerFP420::vstring [private]

Definition at line 62 of file DigitizerFP420.h.


Constructor & Destructor Documentation

cms::DigitizerFP420::DigitizerFP420 ( const edm::ParameterSet conf) [explicit]

Definition at line 96 of file DigitizerFP420.cc.

References conf_, gather_cfg::cout, dn0, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), pn0, rn0, sn0, theFP420NumberingScheme, trackerContainers, and verbosity.

                                                           :conf_(conf),stripDigitizer_(new FP420DigiMain(conf)) {
    
    
    std::string alias ( conf.getParameter<std::string>("@module_label") );
    
    //  produces<edm::DetSetVector<HDigiFP420> >().setBranchAlias( alias );
    //  produces<edm::DetSetVector<HDigiFP420SimLink> >().setBranchAlias ( alias + "hDigiFP420SimLink");
    produces<DigiCollectionFP420>().setBranchAlias( alias );
    
    trackerContainers.clear();
    trackerContainers = conf.getParameter<std::vector<std::string> >("ROUList");
    
    verbosity = conf_.getUntrackedParameter<int>("VerbosityLevel");
    dn0   = conf_.getParameter<int>("NumberFP420Detectors");
    sn0   = conf_.getParameter<int>("NumberFP420Stations");
    pn0 = conf_.getParameter<int>("NumberFP420SPlanes");
      rn0 = 7;
    //rn0 = 3;
      theFP420NumberingScheme = new FP420NumberingScheme();
    
    //  produces<DigiCollectionFP420>();
    
    //  produces<StripDigiCollection>();
    //   produces<HDigiFP420>();
    //  produces<edm::DetSetVector<HDigiFP420> >().setBranchAlias( alias );  
    
    //  produces<DigiCollectionFP420>();
    // produces<DigiCollectionFP420>("HDigiFP420");
    
    //  produces<edm::DigiCollectionFP420>();
    
    //   produces<edm::DetSetVector<DigiCollectionFP420> >();
    
    if(verbosity>0) {
      std::cout << "Creating a DigitizerFP420" << std::endl;
      std::cout << "DigitizerFP420: dn0=" << dn0 << " sn0=" << sn0 << " pn0=" << pn0 <<  " rn0=" << rn0 << std::endl;
      std::cout << "DigitizerFP420:trackerContainers.size()=" << trackerContainers.size() << std::endl;
      
    }
  }
cms::DigitizerFP420::~DigitizerFP420 ( ) [virtual]

Definition at line 138 of file DigitizerFP420.cc.

References gather_cfg::cout, stripDigitizer_, and verbosity.

                                  { 
    if(verbosity>0) {
      std::cout << "Destroying a DigitizerFP420" << std::endl;
    }
    delete stripDigitizer_;
    
  }  

Member Function Documentation

void cms::DigitizerFP420::produce ( edm::Event e,
const edm::EventSetup c 
) [virtual]

Implements edm::EDProducer.

Definition at line 149 of file DigitizerFP420.cc.

References HDigiFP420::adc(), HDigiFP420::channel(), collector, gather_cfg::cout, PSimHit::detUnitId(), dn0, first, edm::Event::getByLabel(), i, getHLTprescales::index, estimatePileup::inputRange, convertSQLitetoXML_cfg::output, pn0, edm::Event::put(), rn0, FP420DigiMain::run(), SimHitMap, sn0, HDigiFP420::strip(), stripDigitizer_, HDigiFP420::stripV(), HDigiFP420::stripVW(), theFP420NumberingScheme, trackerContainers, FP420NumberingScheme::unpackFP420Index(), and verbosity.

                                                                             {
    // be lazy and include the appropriate namespaces
    using namespace edm; 
    using namespace std;   
    
    if(verbosity>0) {
      std::cout <<" ===" << std::endl;
      std::cout <<" ============== DigitizerFP420: start   produce= " << std::endl;
      std::cout <<" ===" << std::endl;
    }
    // Get input
    //    std::cout << "DigitizerFP420 start produce" << std::endl;
    //  edm::ESHandle < ParticleDataTable > pdt;
    //  iSetup.getData( pdt );
    
    // Step A: Get Inputs for allTrackerHits
    
    
    edm::Handle<CrossingFrame<PSimHit> > cf_simhit;
    std::vector<const CrossingFrame<PSimHit> *> cf_simhitvec;
    for(uint32_t i = 0; i< trackerContainers.size();i++){
      iEvent.getByLabel("mix",trackerContainers[i],cf_simhit);
      cf_simhitvec.push_back(cf_simhit.product());   }
    std::auto_ptr<MixCollection<PSimHit> > allTrackerHits(new MixCollection<PSimHit>(cf_simhitvec));
    
    // use instead of the previous
    /*    
          std::cout <<" ============== DigitizerFP420: start loop           1   " << std::endl;
          edm::Handle<CrossingFrame<PSimHit> > xFrame;
          std::cout <<" ============== DigitizerFP420: start loop           2   " << std::endl;
          iEvent.getByLabel("mix","FP420SI",xFrame);
          std::cout <<" ============== DigitizerFP420: start loop           3   " << std::endl;
          std::auto_ptr<MixCollection<PSimHit> > allTrackerHits( new MixCollection<PSimHit>(xFrame.product()) );
          std::cout <<" ============== DigitizerFP420: start loop           4   " << std::endl;
    */
    
    // use instead of the previous
    /*           
                 edm::Handle<CrossingFrame<PSimHit> > crossingFrame;
                 const std::string FP420HitsName("FP420SI");
                 bool isHit = true;
                 iEvent.getByLabel("mix",FP420HitsName,crossingFrame);
                 MixCollection<PSimHit> * FP420Hits = 0 ;
                 std::cout <<" ============== DigitizerFP420: start loop           1   " << std::endl;
                 //    std::auto_ptr<MixCollection<PSimHit> > allTrackerHits(new MixCollection<PSimHit>(crossingFrame.product()));
                 FP420Hits = new MixCollection<PSimHit>(crossingFrame.product());
                 std::cout <<" ============== DigitizerFP420: start loop           2   " << std::endl;
                 //  if ( ! FP420Hits->inRegistry()  ) isHit = false;
                 //  if ( isHit ) {
                 std::auto_ptr<MixCollection<PSimHit> >  allTrackerHits( FP420Hits );
                 std::cout <<" ============== DigitizerFP420: start loop           3   " << std::endl;
                 //  }  
                 */
    
    //    std::cout << "DigitizerFP420 Step A done" << std::endl;
    
    //Loop on PSimHit
    
    
      // Step C: create empty output collection
      std::auto_ptr<DigiCollectionFP420> output(new DigiCollectionFP420);
      //  std::auto_ptr<edm::DetSetVector<HDigiFP420> > outputfinal(new edm::DetSetVector<HDigiFP420>(output) );
      //  std::auto_ptr<edm::DetSetVector<HDigiFP420> > outputfinal(new edm::DetSetVector<HDigiFP420>(output) );
      //  std::auto_ptr<edm::DetSetVector<HDigiFP420SimLink> > outputlink(new edm::DetSetVector<HDigiFP420SimLink>(output) );
      
      SimHitMap.clear();
      
      // ==================================
      if(verbosity>0) {
        std::cout <<" ===" << std::endl;
        std::cout <<" ============== DigitizerFP420: MixCollection treatment= " << std::endl;
        std::cout <<" ===" << std::endl;
      }
      
      MixCollection<PSimHit>::iterator isim;
      for (isim=allTrackerHits->begin(); isim!= allTrackerHits->end();isim++) {
        unsigned int unitID = (*isim).detUnitId();
        int det, zside, sector, zmodule; 
        FP420NumberingScheme::unpackFP420Index(unitID, det, zside, sector, zmodule);
        // below, the continues plane index should be (for even different sensor index zside)
        //      unsigned int intindex = packMYIndex(rn0, pn0, sn0, det, zside, sector, zmodule);
        unsigned int intindex = theFP420NumberingScheme->FP420NumberingScheme::packMYIndex(rn0, pn0, sn0, det, zside, sector, zmodule);
        //      int zScale=(rn0-1), sScale = (rn0-1)*(pn0-1), dScale = (rn0-1)*(pn0-1)*(sn0-1);
        //      unsigned int intindex = dScale*(det - 1)+sScale*(sector - 1)+zScale*(zmodule - 1)+zside;

        if(verbosity>0) {
          double  losenergy = (*isim).energyLoss();
          std::cout <<" ===" << std::endl;
          std::cout <<" ============== DigitizerFP420:  losenergy= " << losenergy << std::endl;
          std::cout <<" === for intindex = " << intindex << std::endl;
        }
        // does not matter which index is used: intindex or unitID - mainly to collect hits under every index   
        SimHitMap[intindex].push_back((*isim));
        // for development later one( cal be used another index):
        //      SimHitMap[unitID].push_back((*isim));
      }
      //============================================================================================================================
      
      if(verbosity>0) {
        std::cout <<" ===" << std::endl;
        std::cout <<" ============== DigitizerFP420: put zero to container " << std::endl;
        std::cout <<" ===" << std::endl;
      }
      //    put zero to container info from the beginning (important! because not any detID is updated with coming of new event     !!!!!!   
      // clean info of container from previous event
      for (int det=1; det<dn0; det++) {
        for (int sector=1; sector<sn0; sector++) {
          for (int zmodule=1; zmodule<pn0; zmodule++) {
            for (int zside=1; zside<rn0; zside++) {
              // intindex is a continues numbering of FP420
              unsigned int detID = theFP420NumberingScheme->FP420NumberingScheme::packMYIndex(rn0, pn0, sn0, det, zside, sector, zmodule);
              // int zScale=(rn0-1), sScale = (rn0-1)*(pn0-1), dScale = (rn0-1)*(pn0-1)*(sn0-1);
              // unsigned int detID = dScale*(det - 1)+sScale*(sector - 1)+zScale*(zmodule - 1)+zside;
              std::vector<HDigiFP420> collector;
              collector.clear();
              DigiCollectionFP420::Range inputRange;
              inputRange.first = collector.begin();
              inputRange.second = collector.end();
              output->putclear(inputRange,detID);
            }//for
          }//for
        }//for
      }//for
      //                                                                                                                      !!!!!!   
      // if we want to keep Digi container/Collection for one event uncomment the line below and vice versa
      output->clear();   //container_.clear() --> start from the beginning of the container
      
      //============================================================================================================================================
      
      
      if(verbosity>0) {
        std::cout <<" ===" << std::endl;
        std::cout <<" ============== DigitizerFP420: start loop over det iu " << std::endl;
        std::cout <<" ============== DigitizerFP420: SimHitMap.size()= " << SimHitMap.size() << std::endl;
        std::cout <<" ===" << std::endl;
      }
      bool first = true;

      /*      
      if(verbosity>0) std::cout <<"=======  DigitizerFP420:  SimHitMap size = " << SimHitMap.size() << std::endl;
      for(unsigned int i = 0; i < SimHitMap.size(); i++ ) {
        //        std::cout <<" ====== DigitizerFP420:                                                      i= " << i << std::endl;
        vector<PSimHit>::const_iterator simHitIter = SimHitMap[i].begin();
        vector<PSimHit>::const_iterator simHitIterEnd = SimHitMap[i].end();
        for (;simHitIter != simHitIterEnd; ++simHitIter) {
          const PSimHit ihit = *simHitIter;
          unsigned int unitID = ihit.detUnitId();
          if(verbosity>0) std::cout <<" ====== DigitizerFP420: unitID= " << unitID << " i=  " << i << std::endl;
          int det, zside, sector, zmodule; 
          FP420NumberingScheme::unpackFP420Index(unitID, det, zside, sector, zmodule);
          int zScale=(rn0-1), sScale = (rn0-1)*(pn0-1), dScale = (rn0-1)*(pn0-1)*(sn0-1);
          unsigned int iu = dScale*(det - 1)+sScale*(sector - 1)+zScale*(zmodule - 1)+zside;
        }
      }
*/
      //============================================================================================================================================
      // new:   <------
      for(unsigned int i = 0; i < SimHitMap.size(); i++ ) {
        vector<PSimHit>::const_iterator simHitIter = SimHitMap[i].begin();
        vector<PSimHit>::const_iterator simHitIterEnd = SimHitMap[i].end();
        for (;simHitIter != simHitIterEnd; ++simHitIter) {
          const PSimHit ihit = *simHitIter;
          unsigned int unitID = ihit.detUnitId();
          if(verbosity>0 || verbosity==-50) std::cout <<" ====== DigitizerFP420: unitID= " << unitID << "Hit number i=  " << i << std::endl;
          int det, zside, sector, zmodule; 
          FP420NumberingScheme::unpackFP420Index(unitID, det, zside, sector, zmodule);
          // <------
          // old: <------
          //     for (int det=1; det<dn0; det++) {
          //    for (int sector=1; sector<sn0; sector++) {
          // for (int zmodule=1; zmodule<pn0; zmodule++) {
          //  for (int zside=1; zside<rn0; zside++) {
          // <------
          
          
          
          
          
          unsigned int iu = theFP420NumberingScheme->FP420NumberingScheme::packMYIndex(rn0, pn0, sn0, det, zside, sector, zmodule);
          if(verbosity>0 || verbosity==-50) std::cout <<"for Hits iu = " << iu <<" sector = " << sector <<" zmodule = " << zmodule <<" zside = " << zside << "  det=" << det << std::endl;
          //   int zScale=(rn0-1), sScale = (rn0-1)*(pn0-1), dScale = (rn0-1)*(pn0-1)*(sn0-1);
          //  unsigned int iu = dScale*(det - 1)+sScale*(sector - 1)+zScale*(zmodule - 1)+zside;

          if(verbosity>0) {
            unsigned int index = theFP420NumberingScheme->FP420NumberingScheme::packFP420Index(det, zside, sector, zmodule);
            std::cout << " DigitizerFP420:       index = " <<  index <<  " iu = " << iu  << std::endl;
          }
          
          //    GlobalVector bfield=pSetup->inTesla((*iu)->surface().position());
          //      CLHEP::Hep3Vector Bfieldloc=bfield();
          G4ThreeVector bfield(  0.,  0.,  0.0  );
          //    G4ThreeVector bfield(  0.5,  0.5,  1.0  );
          
          
          if(verbosity>0) {
            std::cout <<" ===" << std::endl;
            std::cout <<" ============== DigitizerFP420:  call run for iu= " << iu << std::endl;
            std::cout <<" ===" << std::endl;
          }
          collector.clear();
          
          collector= stripDigitizer_->run( SimHitMap[iu],
                                           bfield,
                                           iu
                                           ); // stripDigitizer_.run...  return 
          //                                             ,sScale
          
          
          
          if(verbosity>0) {
            std::cout <<" ===" << std::endl;
            std::cout <<" ===" << std::endl;
            std::cout <<"=======  DigitizerFP420:  collector size = " << collector.size() << std::endl;
            std::cout <<" ===" << std::endl;
            std::cout <<" ===" << std::endl;
          }           
          /*            
            
          std::vector<HDigiFP420> collector;
          collector.clear();
          DigiCollectionFP420::Range inputRange;
          inputRange.first = collector.begin();
          inputRange.second = collector.end();
          output->putclear(inputRange,detID);
          */
          if (collector.size()>0){
            if(verbosity>0) {
              std::cout <<"         ============= DigitizerFP420:collector start!!!!!!!!!!!!!!" << std::endl;
            }
            DigiCollectionFP420::Range outputRange;
            outputRange.first = collector.begin();
            outputRange.second = collector.end();
            
            if ( first ) {
              // use it only if ClusterCollectionFP420 is the ClusterCollection of one event, otherwise, do not use (loose 1st cl. of 1st event only)
              first = false;
              unsigned int  detID0= 0;
              output->put(outputRange,detID0); // !!! put into adress 0 for detID which will not be used never
            } //if ( first ) 
            
            // put !!!
            output->put(outputRange,iu);
            
          } // if(collector.size()>0
          
          //   }   // for
          // }   // for
          //    }   // for
          // }   // for
          
        }//for
      }//for
      
      // END
      
      /*      
      if(verbosity>0) {
        std::vector<HDigiFP420> theAllDigis;
        theAllDigis.clear();
        DigiCollectionFP420::Range outputRange;
        DigiCollectionFP420::ContainerIterator sort_begin = outputRange.first;
        DigiCollectionFP420::ContainerIterator sort_end = outputRange.second;
        theAllDigis.insert(theAllDigis.end(), sort_begin, sort_end);
        std::cout <<"======  theAllDigis size = " << theAllDigis.size() << std::endl;
        for (std::vector<HDigiFP420>::iterator isim = theAllDigis.begin();
             isim != theAllDigis.end(); ++isim){
          const HDigiFP420 istrip = *isim;
          std::cout << "*******************************************DigitizerFP420:check1" << std::endl;
          std::cout << " strip number=" << istrip.strip() << "  adc=" << istrip.adc() << std::endl;
          std::cout <<" channel =" << istrip.channel() <<" V " << istrip.stripV() <<" VW " << istrip.stripVW() << std::endl;
          std::cout <<" ===" << std::endl;
          std::cout <<" ===" << std::endl;
          std::cout <<" =======================" << std::endl;
        }// for
      }
*/
      if(verbosity==-50) {
        //     check of access to the collector:
        for (int det=1; det<dn0; det++) {
          for (int sector=1; sector<sn0; sector++) {
            for (int zmodule=1; zmodule<pn0; zmodule++) {
              for (int zside=1; zside<rn0; zside++) {
                unsigned int iu = theFP420NumberingScheme->FP420NumberingScheme::packMYIndex(rn0, pn0, sn0, det, zside, sector, zmodule);
                int layer = theFP420NumberingScheme->FP420NumberingScheme::unpackLayerIndex(rn0,zside);
                int orient = theFP420NumberingScheme->FP420NumberingScheme::unpackOrientation(rn0,zside);
                std::cout << "****DigitizerFP420:check2" << std::endl;
                //      std::cout <<" iu = " << iu <<" sector = " << sector <<" zmodule = " << zmodule <<" zside = " << zside << "  det=" << det << std::endl;
                //      std::cout <<" layer = " << layer <<" orient = " << orient << std::endl;
                int newdet, newzside, newsector, newzmodule;
                theFP420NumberingScheme->FP420NumberingScheme::unpackMYIndex(iu, rn0, pn0, sn0, newdet, newzside, newsector, newzmodule);
                std::cout <<" newdet = " << newdet <<" newsector = " << newsector <<" newzmodule = " << newzmodule <<" newzside = " << newzside << std::endl;
                
                collector.clear();
                DigiCollectionFP420::Range outputRange;
                //      outputRange = output->get(iu);
                outputRange = output->get(iu);
                
                // fill output in collector vector (for may be sorting? or other checks)
                std::vector<HDigiFP420> collector;
                //  collector.clear();
                DigiCollectionFP420::ContainerIterator sort_begin = outputRange.first;
                DigiCollectionFP420::ContainerIterator sort_end = outputRange.second;
                for ( ;sort_begin != sort_end; ++sort_begin ) {
                  collector.push_back(*sort_begin);
                } // for
                  //  std::sort(collector.begin(),collector.end());
                std::cout <<" ===" << std::endl;
                std::cout <<"======  collector size = " << collector.size() << std::endl;
                if(collector.size()>0) {
                  std::cout <<" iu = " << iu <<" sector = " << sector <<" zmodule = " << zmodule <<" zside = " << zside << "  det=" << det <<" layer = " << layer <<" orient = " << orient << std::endl;
                  std::cout <<" ===" << std::endl;
                }
                vector<HDigiFP420>::const_iterator simHitIter = collector.begin();
                vector<HDigiFP420>::const_iterator simHitIterEnd = collector.end();
                for (;simHitIter != simHitIterEnd; ++simHitIter) {
                  const HDigiFP420 istrip = *simHitIter;
                  std::cout << " strip number=" << istrip.strip() << "  adc=" << istrip.adc() << std::endl;
                  std::cout <<" channel =" << istrip.channel() <<" V " << istrip.stripV() <<" VW " << istrip.stripVW() << std::endl;
                  std::cout <<" ===" << std::endl;
                  std::cout <<" ===" << std::endl;
                  std::cout <<" ===================================================" << std::endl;
                }
                
                //==================================
                
              }   // for
            }   // for
          }   // for
        }   // for
        
        //     end of check of access to the strip collection
        
      }// if(verbosity  
      //     
      
      
      // Step D: write output to file
      //    iEvent.put(output);
      
      if(verbosity>0) {
        std::cout << "DigitizerFP420 recoutput" << std::endl;
      }
      // Step D: write output to file
      iEvent.put(output);
      // iEvent.put(outputlink);
      //          iEvent.put(pDigis);
      
      // Step D: write output to file 
      //  iEvent.put(output);
      //  iEvent.put(outputlink);
      //-------------------------------------------------------------------
      //    std::cout << "DigitizerFP420 recoutput" << std::endl;
      //          iEvent.put(pDigis);
      
      
      
      
  }//produce

Member Data Documentation

Definition at line 80 of file DigitizerFP420.h.

Referenced by produce().

Definition at line 67 of file DigitizerFP420.h.

Referenced by DigitizerFP420().

int cms::DigitizerFP420::dn0 [private]

Definition at line 77 of file DigitizerFP420.h.

Referenced by DigitizerFP420(), and produce().

Definition at line 75 of file DigitizerFP420.h.

int cms::DigitizerFP420::pn0 [private]

Definition at line 77 of file DigitizerFP420.h.

Referenced by DigitizerFP420(), and produce().

int cms::DigitizerFP420::rn0 [private]

Definition at line 77 of file DigitizerFP420.h.

Referenced by DigitizerFP420(), and produce().

Definition at line 65 of file DigitizerFP420.h.

Referenced by produce().

int cms::DigitizerFP420::sn0 [private]

Definition at line 77 of file DigitizerFP420.h.

Referenced by DigitizerFP420(), and produce().

Definition at line 72 of file DigitizerFP420.h.

Referenced by produce(), and ~DigitizerFP420().

Definition at line 73 of file DigitizerFP420.h.

Referenced by DigitizerFP420(), and produce().

Definition at line 68 of file DigitizerFP420.h.

Referenced by DigitizerFP420(), and produce().

Definition at line 77 of file DigitizerFP420.h.

Referenced by DigitizerFP420(), produce(), and ~DigitizerFP420().