Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:02:47

0001 
0002 /*----------------------------------------------------------------------
0003 
0004 Toy EDAnalyzer for testing purposes only.
0005 
0006 ----------------------------------------------------------------------*/
0007 
0008 #include <stdexcept>
0009 #include <iostream>
0010 #include <map>
0011 #include "FWCore/Framework/interface/ESHandle.h"
0012 #include "FWCore/Framework/interface/MakerMacros.h"
0013 
0014 #include "CondTools/DT/test/stubs/DTGeometryDump.h"
0015 
0016 #include "Geometry/DTGeometry/interface/DTGeometry.h"
0017 #include "Geometry/Records/interface/MuonGeometryRecord.h"
0018 
0019 namespace edmtest {
0020 
0021   DTGeometryDump::DTGeometryDump(edm::ParameterSet const& p) : dtgeomToken_(esConsumes()) {}
0022 
0023   DTGeometryDump::DTGeometryDump(int i) : dtgeomToken_(esConsumes()) {}
0024 
0025   void DTGeometryDump::analyze(const edm::Event& e, const edm::EventSetup& context) {
0026     using namespace edm::eventsetup;
0027     auto muonGeom = context.getHandle(dtgeomToken_);
0028     const std::vector<const DTChamber*>& ch_cont = muonGeom->chambers();
0029     std::vector<const DTChamber*>::const_iterator ch_iter = ch_cont.begin();
0030     std::vector<const DTChamber*>::const_iterator ch_iend = ch_cont.end();
0031     std::vector<DTChamberId> ch_id_cont;
0032     while (ch_iter != ch_iend) {
0033       const DTChamber* ch_ptr = *ch_iter++;
0034       DTChamberId ch_id = ch_ptr->id();
0035       std::vector<DTChamberId>::const_iterator ch_id_iter = ch_id_cont.begin();
0036       std::vector<DTChamberId>::const_iterator ch_id_iend = ch_id_cont.end();
0037       bool ch_found = false;
0038       while (ch_id_iter != ch_id_iend) {
0039         if (*ch_id_iter++ == ch_id) {
0040           ch_found = true;
0041           std::cout << "chamber already found:: " << ch_id.wheel() << " " << ch_id.sector() << " " << ch_id.station()
0042                     << std::endl;
0043           break;
0044         }
0045       }
0046       if (!ch_found)
0047         ch_id_cont.push_back(ch_id);
0048       else
0049         continue;
0050       const std::vector<const DTSuperLayer*>& sl_cont = ch_ptr->superLayers();
0051       std::vector<const DTSuperLayer*>::const_iterator sl_iter = sl_cont.begin();
0052       std::vector<const DTSuperLayer*>::const_iterator sl_iend = sl_cont.end();
0053       std::vector<DTSuperLayerId> sl_id_cont;
0054       while (sl_iter != sl_iend) {
0055         const DTSuperLayer* sl_ptr = *sl_iter++;
0056         DTSuperLayerId sl_id = sl_ptr->id();
0057         std::vector<DTSuperLayerId>::const_iterator sl_id_iter = sl_id_cont.begin();
0058         std::vector<DTSuperLayerId>::const_iterator sl_id_iend = sl_id_cont.end();
0059         bool sl_found = false;
0060         while (sl_id_iter != sl_id_iend) {
0061           if (*sl_id_iter++ == sl_id) {
0062             sl_found = true;
0063             std::cout << "superlayer already found: " << sl_id.wheel() << " " << sl_id.sector() << " "
0064                       << sl_id.station() << " " << sl_id.superlayer() << std::endl;
0065             break;
0066           }
0067         }
0068         if (!sl_found)
0069           sl_id_cont.push_back(sl_id);
0070         else
0071           continue;
0072 
0073         const std::vector<const DTLayer*>& cl_cont = sl_ptr->layers();
0074         std::vector<const DTLayer*>::const_iterator cl_iter = cl_cont.begin();
0075         std::vector<const DTLayer*>::const_iterator cl_iend = cl_cont.end();
0076         std::vector<DTLayerId> cl_id_cont;
0077         while (cl_iter != cl_iend) {
0078           const DTLayer* cl_ptr = *cl_iter++;
0079           DTLayerId cl_id = cl_ptr->id();
0080           std::vector<DTLayerId>::const_iterator cl_id_iter = cl_id_cont.begin();
0081           std::vector<DTLayerId>::const_iterator cl_id_iend = cl_id_cont.end();
0082           bool cl_found = false;
0083           while (cl_id_iter != cl_id_iend) {
0084             if (*cl_id_iter++ == cl_id) {
0085               cl_found = true;
0086               std::cout << "layer already found: " << cl_id.wheel() << " " << cl_id.sector() << " " << cl_id.station()
0087                         << " " << cl_id.superlayer() << " " << cl_id.layer() << std::endl;
0088               break;
0089             }
0090           }
0091           if (!cl_found)
0092             cl_id_cont.push_back(cl_id);
0093           else
0094             continue;
0095 
0096           const DTTopology& topo = cl_ptr->specificTopology();
0097           int fcell = topo.firstChannel();
0098           int lcell = topo.lastChannel();
0099           std::cout << "layer: " << cl_id.wheel() << " " << cl_id.sector() << " " << cl_id.station() << " "
0100                     << cl_id.superlayer() << " " << cl_id.layer() << " has cells from " << fcell << " to " << lcell
0101                     << std::endl;
0102         }
0103       }
0104     }
0105 
0106     //    cond::Time_t itime=(cond::Time_t)evt.time().value();
0107     //    std::cout << "TIME: " << itime << std::endl;
0108     std::cout << "TIME: " << e.time().value() << std::endl;
0109   }
0110   DEFINE_FWK_MODULE(DTGeometryDump);
0111 }  // namespace edmtest