Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-04-20 11:33:59

0001 #include <iostream>
0002 #include <string>
0003 #include <vector>
0004 
0005 #include "TTree.h"
0006 
0007 #include "CommonTools/UtilAlgos/interface/TFileService.h"
0008 #include "FWCore/Framework/interface/Frameworkfwd.h"
0009 #include "FWCore/Framework/interface/stream/EDAnalyzer.h"
0010 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0011 #include "FWCore/ServiceRegistry/interface/Service.h"
0012 
0013 #include "FWCore/Framework/interface/ESHandle.h"
0014 #include "FWCore/Framework/interface/ESTransientHandle.h"
0015 #include "FWCore/Framework/interface/Event.h"
0016 #include "FWCore/Framework/interface/EventSetup.h"
0017 #include "FWCore/Framework/interface/MakerMacros.h"
0018 
0019 #include "DataFormats/ForwardDetId/interface/ForwardSubdetector.h"
0020 #include "DataFormats/ForwardDetId/interface/HFNoseTriggerDetId.h"
0021 #include "DataFormats/ForwardDetId/interface/HGCalDetId.h"
0022 #include "DataFormats/ForwardDetId/interface/HGCalTriggerDetId.h"
0023 #include "DataFormats/HcalDetId/interface/HcalDetId.h"
0024 
0025 #include "DataFormats/ForwardDetId/interface/HGCScintillatorDetId.h"
0026 #include "DataFormats/ForwardDetId/interface/HGCSiliconDetId.h"
0027 #include "Geometry/HGCalCommonData/interface/HGCalGeometryMode.h"
0028 #include "Geometry/HGCalGeometry/interface/HGCalGeometry.h"
0029 #include "Geometry/Records/interface/CaloGeometryRecord.h"
0030 #include "Geometry/Records/interface/IdealGeometryRecord.h"
0031 
0032 #include "L1Trigger/L1THGCal/interface/HGCalTriggerGeometryBase.h"
0033 
0034 #include <cstdlib>
0035 
0036 namespace {
0037   template <typename T>
0038   struct array_deleter {
0039     void operator()(T* arr) { delete[] arr; }
0040   };
0041 }  // namespace
0042 
0043 class HGCalTriggerGeomTesterV9Imp2 : public edm::stream::EDAnalyzer<> {
0044 public:
0045   explicit HGCalTriggerGeomTesterV9Imp2(const edm::ParameterSet&);
0046   ~HGCalTriggerGeomTesterV9Imp2() override = default;
0047 
0048   void beginRun(const edm::Run&, const edm::EventSetup&) override;
0049   void endRun(const edm::Run&, const edm::EventSetup&) override {}
0050   void analyze(const edm::Event&, const edm::EventSetup&) override;
0051 
0052 private:
0053   void fillTriggerGeometry();
0054   bool checkMappingConsistency();
0055   bool checkNeighborConsistency();
0056   void setTreeModuleSize(const size_t n);
0057   void setTreeModuleCellSize(const size_t n);
0058   void setTreeTriggerCellSize(const size_t n);
0059   void setTreeCellCornerSize(const size_t n);
0060   void setTreeTriggerCellNeighborSize(const size_t n);
0061 
0062   const edm::ESGetToken<HGCalTriggerGeometryBase, CaloGeometryRecord> triggerGeomToken_;
0063   edm::ESHandle<HGCalTriggerGeometryBase> triggerGeometry_;
0064   bool no_trigger_;
0065   bool no_neighbors_;
0066   TTree* treeModules_;
0067   TTree* treeTriggerCells_;
0068   TTree* treeCells_;
0069   TTree* treeCellsBH_;
0070   TTree* treeCellsNose_;
0071   TTree* treeModuleErrors_;
0072   // tree variables
0073   int moduleId_ = 0;
0074   int moduleSide_ = 0;
0075   int moduleSubdet_ = 0;
0076   int moduleLayer_ = 0;
0077   int moduleIEta_ = 0;
0078   int moduleIPhi_ = 0;
0079   int module_ = 0;
0080   float moduleX_ = 0;
0081   float moduleY_ = 0;
0082   float moduleZ_ = 0;
0083   int moduleTC_N_ = 0;
0084   int moduleLinks_ = 0;
0085   std::shared_ptr<int> moduleTC_id_;
0086   std::shared_ptr<int> moduleTC_zside_;
0087   std::shared_ptr<int> moduleTC_subdet_;
0088   std::shared_ptr<int> moduleTC_layer_;
0089   std::shared_ptr<int> moduleTC_waferU_;
0090   std::shared_ptr<int> moduleTC_waferV_;
0091   std::shared_ptr<int> moduleTC_cellU_;
0092   std::shared_ptr<int> moduleTC_cellV_;
0093   std::shared_ptr<int> moduleTC_ieta_;
0094   std::shared_ptr<int> moduleTC_iphi_;
0095   std::shared_ptr<float> moduleTC_x_;
0096   std::shared_ptr<float> moduleTC_y_;
0097   std::shared_ptr<float> moduleTC_z_;
0098   int moduleCell_N_ = 0;
0099   std::shared_ptr<int> moduleCell_id_;
0100   std::shared_ptr<int> moduleCell_zside_;
0101   std::shared_ptr<int> moduleCell_subdet_;
0102   std::shared_ptr<int> moduleCell_layer_;
0103   std::shared_ptr<int> moduleCell_waferU_;
0104   std::shared_ptr<int> moduleCell_waferV_;
0105   std::shared_ptr<int> moduleCell_cellU_;
0106   std::shared_ptr<int> moduleCell_cellV_;
0107   std::shared_ptr<float> moduleCell_x_;
0108   std::shared_ptr<float> moduleCell_y_;
0109   std::shared_ptr<float> moduleCell_z_;
0110   int triggerCellId_ = 0;
0111   int triggerCellSide_ = 0;
0112   int triggerCellSubdet_ = 0;
0113   int triggerCellLayer_ = 0;
0114   int triggerCellWaferU_ = 0;
0115   int triggerCellWaferV_ = 0;
0116   int triggerCellU_ = 0;
0117   int triggerCellV_ = 0;
0118   int triggerCellIEta_ = 0;
0119   int triggerCellIPhi_ = 0;
0120   float triggerCellX_ = 0;
0121   float triggerCellY_ = 0;
0122   float triggerCellZ_ = 0;
0123   int triggerCellNeighbor_N_ = 0;
0124   std::shared_ptr<int> triggerCellNeighbor_id_;
0125   std::shared_ptr<int> triggerCellNeighbor_zside_;
0126   std::shared_ptr<int> triggerCellNeighbor_subdet_;
0127   std::shared_ptr<int> triggerCellNeighbor_layer_;
0128   std::shared_ptr<int> triggerCellNeighbor_waferU_;
0129   std::shared_ptr<int> triggerCellNeighbor_waferV_;
0130   std::shared_ptr<int> triggerCellNeighbor_cellU_;
0131   std::shared_ptr<int> triggerCellNeighbor_cellV_;
0132   std::shared_ptr<int> triggerCellNeighbor_cellIEta_;
0133   std::shared_ptr<int> triggerCellNeighbor_cellIPhi_;
0134   std::shared_ptr<float> triggerCellNeighbor_distance_;
0135   int triggerCellCell_N_ = 0;
0136   std::shared_ptr<int> triggerCellCell_id_;
0137   std::shared_ptr<int> triggerCellCell_zside_;
0138   std::shared_ptr<int> triggerCellCell_subdet_;
0139   std::shared_ptr<int> triggerCellCell_layer_;
0140   std::shared_ptr<int> triggerCellCell_waferU_;
0141   std::shared_ptr<int> triggerCellCell_waferV_;
0142   std::shared_ptr<int> triggerCellCell_cellU_;
0143   std::shared_ptr<int> triggerCellCell_cellV_;
0144   std::shared_ptr<int> triggerCellCell_ieta_;
0145   std::shared_ptr<int> triggerCellCell_iphi_;
0146   std::shared_ptr<float> triggerCellCell_x_;
0147   std::shared_ptr<float> triggerCellCell_y_;
0148   std::shared_ptr<float> triggerCellCell_z_;
0149   int cellId_ = 0;
0150   int cellSide_ = 0;
0151   int cellSubdet_ = 0;
0152   int cellLayer_ = 0;
0153   int cellWaferU_ = 0;
0154   int cellWaferV_ = 0;
0155   int cellWaferType_ = 0;
0156   int cellWaferRow_ = 0;
0157   int cellWaferColumn_ = 0;
0158   int cellU_ = 0;
0159   int cellV_ = 0;
0160   float cellX_ = 0;
0161   float cellY_ = 0;
0162   float cellZ_ = 0;
0163   int cellCornersN_ = 0;
0164   std::shared_ptr<float> cellCornersX_;
0165   std::shared_ptr<float> cellCornersY_;
0166   std::shared_ptr<float> cellCornersZ_;
0167   int cellBHId_ = 0;
0168   int cellBHType_ = 0;
0169   int cellBHSide_ = 0;
0170   int cellBHSubdet_ = 0;
0171   int cellBHLayer_ = 0;
0172   int cellBHIEta_ = 0;
0173   int cellBHIPhi_ = 0;
0174   float cellBHEta_ = 0;
0175   float cellBHPhi_ = 0;
0176   float cellBHX_ = 0;
0177   float cellBHY_ = 0;
0178   float cellBHZ_ = 0;
0179   float cellBHX1_ = 0;
0180   float cellBHY1_ = 0;
0181   float cellBHX2_ = 0;
0182   float cellBHY2_ = 0;
0183   float cellBHX3_ = 0;
0184   float cellBHY3_ = 0;
0185   float cellBHX4_ = 0;
0186   float cellBHY4_ = 0;
0187   //
0188   int moduleErrorSubdet_ = 0;
0189   int moduleErrorLayer_ = 0;
0190   int moduleErrorWaferU_ = 0;
0191   int moduleErrorWaferV_ = 0;
0192 
0193 private:
0194   typedef std::unordered_map<uint32_t, std::unordered_set<uint32_t>> trigger_map_set;
0195 };
0196 
0197 /*****************************************************************/
0198 HGCalTriggerGeomTesterV9Imp2::HGCalTriggerGeomTesterV9Imp2(const edm::ParameterSet& conf)
0199     : triggerGeomToken_(esConsumes<HGCalTriggerGeometryBase, CaloGeometryRecord, edm::Transition::BeginRun>()),
0200       no_trigger_(false),
0201       no_neighbors_(false)
0202 /*****************************************************************/
0203 {
0204   // initialize output trees
0205   edm::Service<TFileService> fs;
0206   treeModules_ = fs->make<TTree>("TreeModules", "Tree of all HGC modules");
0207   treeModules_->Branch("id", &moduleId_, "id/I");
0208   treeModules_->Branch("zside", &moduleSide_, "zside/I");
0209   treeModules_->Branch("subdet", &moduleSubdet_, "subdet/I");
0210   treeModules_->Branch("layer", &moduleLayer_, "layer/I");
0211   treeModules_->Branch("ieta", &moduleIEta_, "ieta/I");
0212   treeModules_->Branch("iphi", &moduleIPhi_, "iphi/I");
0213   treeModules_->Branch("module", &module_, "module/I");
0214   treeModules_->Branch("links", &moduleLinks_, "links/I");
0215   treeModules_->Branch("x", &moduleX_, "x/F");
0216   treeModules_->Branch("y", &moduleY_, "y/F");
0217   treeModules_->Branch("z", &moduleZ_, "z/F");
0218   treeModules_->Branch("tc_n", &moduleTC_N_, "tc_n/I");
0219   moduleTC_id_.reset(new int[1], array_deleter<int>());
0220   moduleTC_zside_.reset(new int[1], array_deleter<int>());
0221   moduleTC_subdet_.reset(new int[1], array_deleter<int>());
0222   moduleTC_layer_.reset(new int[1], array_deleter<int>());
0223   moduleTC_waferU_.reset(new int[1], array_deleter<int>());
0224   moduleTC_waferV_.reset(new int[1], array_deleter<int>());
0225   moduleTC_cellU_.reset(new int[1], array_deleter<int>());
0226   moduleTC_cellV_.reset(new int[1], array_deleter<int>());
0227   moduleTC_x_.reset(new float[1], array_deleter<float>());
0228   moduleTC_y_.reset(new float[1], array_deleter<float>());
0229   moduleTC_z_.reset(new float[1], array_deleter<float>());
0230   treeModules_->Branch("tc_id", moduleTC_id_.get(), "tc_id[tc_n]/I");
0231   treeModules_->Branch("tc_zside", moduleTC_zside_.get(), "tc_zside[tc_n]/I");
0232   treeModules_->Branch("tc_subdet", moduleTC_subdet_.get(), "tc_subdet[tc_n]/I");
0233   treeModules_->Branch("tc_layer", moduleTC_layer_.get(), "tc_layer[tc_n]/I");
0234   treeModules_->Branch("tc_waferu", moduleTC_waferU_.get(), "tc_waferu[tc_n]/I");
0235   treeModules_->Branch("tc_waferv", moduleTC_waferV_.get(), "tc_waferv[tc_n]/I");
0236   treeModules_->Branch("tc_cellu", moduleTC_cellU_.get(), "tc_cellu[tc_n]/I");
0237   treeModules_->Branch("tc_cellv", moduleTC_cellV_.get(), "tc_cellv[tc_n]/I");
0238   treeModules_->Branch("tc_ieta", moduleTC_ieta_.get(), "tc_ieta[tc_n]/I");
0239   treeModules_->Branch("tc_iphi", moduleTC_iphi_.get(), "tc_iphi[tc_n]/I");
0240   treeModules_->Branch("tc_x", moduleTC_x_.get(), "tc_x[tc_n]/F");
0241   treeModules_->Branch("tc_y", moduleTC_y_.get(), "tc_y[tc_n]/F");
0242   treeModules_->Branch("tc_z", moduleTC_z_.get(), "tc_z[tc_n]/F");
0243   treeModules_->Branch("c_n", &moduleCell_N_, "c_n/I");
0244   moduleCell_id_.reset(new int[1], array_deleter<int>());
0245   moduleCell_zside_.reset(new int[1], array_deleter<int>());
0246   moduleCell_subdet_.reset(new int[1], array_deleter<int>());
0247   moduleCell_layer_.reset(new int[1], array_deleter<int>());
0248   moduleCell_waferU_.reset(new int[1], array_deleter<int>());
0249   moduleCell_waferV_.reset(new int[1], array_deleter<int>());
0250   moduleCell_cellU_.reset(new int[1], array_deleter<int>());
0251   moduleCell_cellV_.reset(new int[1], array_deleter<int>());
0252   moduleCell_x_.reset(new float[1], array_deleter<float>());
0253   moduleCell_y_.reset(new float[1], array_deleter<float>());
0254   moduleCell_z_.reset(new float[1], array_deleter<float>());
0255   treeModules_->Branch("c_id", moduleCell_id_.get(), "c_id[c_n]/I");
0256   treeModules_->Branch("c_zside", moduleCell_zside_.get(), "c_zside[c_n]/I");
0257   treeModules_->Branch("c_subdet", moduleCell_subdet_.get(), "c_subdet[c_n]/I");
0258   treeModules_->Branch("c_layer", moduleCell_layer_.get(), "c_layer[c_n]/I");
0259   treeModules_->Branch("c_waferu", moduleCell_waferU_.get(), "c_waferu[c_n]/I");
0260   treeModules_->Branch("c_waferv", moduleCell_waferV_.get(), "c_waferv[c_n]/I");
0261   treeModules_->Branch("c_cellu", moduleCell_cellU_.get(), "c_cellu[c_n]/I");
0262   treeModules_->Branch("c_cellv", moduleCell_cellV_.get(), "c_cellv[c_n]/I");
0263   treeModules_->Branch("c_x", moduleCell_x_.get(), "c_x[c_n]/F");
0264   treeModules_->Branch("c_y", moduleCell_y_.get(), "c_y[c_n]/F");
0265   treeModules_->Branch("c_z", moduleCell_z_.get(), "c_z[c_n]/F");
0266   //
0267   treeTriggerCells_ = fs->make<TTree>("TreeTriggerCells", "Tree of all HGC trigger cells");
0268   treeTriggerCells_->Branch("id", &triggerCellId_, "id/I");
0269   treeTriggerCells_->Branch("zside", &triggerCellSide_, "zside/I");
0270   treeTriggerCells_->Branch("subdet", &triggerCellSubdet_, "subdet/I");
0271   treeTriggerCells_->Branch("layer", &triggerCellLayer_, "layer/I");
0272   treeTriggerCells_->Branch("waferu", &triggerCellWaferU_, "waferu/I");
0273   treeTriggerCells_->Branch("waferv", &triggerCellWaferV_, "waferv/I");
0274   treeTriggerCells_->Branch("triggercellu", &triggerCellU_, "triggercellu/I");
0275   treeTriggerCells_->Branch("triggercellv", &triggerCellV_, "triggercellv/I");
0276   treeTriggerCells_->Branch("triggercellieta", &triggerCellIEta_, "triggercellieta/I");
0277   treeTriggerCells_->Branch("triggercelliphi", &triggerCellIPhi_, "triggercelliphi/I");
0278   treeTriggerCells_->Branch("x", &triggerCellX_, "x/F");
0279   treeTriggerCells_->Branch("y", &triggerCellY_, "y/F");
0280   treeTriggerCells_->Branch("z", &triggerCellZ_, "z/F");
0281   treeTriggerCells_->Branch("neighbor_n", &triggerCellNeighbor_N_, "neighbor_n/I");
0282   triggerCellNeighbor_id_.reset(new int[1], array_deleter<int>());
0283   triggerCellNeighbor_zside_.reset(new int[1], array_deleter<int>());
0284   triggerCellNeighbor_subdet_.reset(new int[1], array_deleter<int>());
0285   triggerCellNeighbor_layer_.reset(new int[1], array_deleter<int>());
0286   triggerCellNeighbor_waferU_.reset(new int[1], array_deleter<int>());
0287   triggerCellNeighbor_waferV_.reset(new int[1], array_deleter<int>());
0288   triggerCellNeighbor_cellU_.reset(new int[1], array_deleter<int>());
0289   triggerCellNeighbor_cellV_.reset(new int[1], array_deleter<int>());
0290   triggerCellNeighbor_distance_.reset(new float[1], array_deleter<float>());
0291   treeTriggerCells_->Branch("neighbor_id", triggerCellNeighbor_id_.get(), "neighbor_id[neighbor_n]/I");
0292   treeTriggerCells_->Branch("neighbor_zside", triggerCellNeighbor_zside_.get(), "neighbor_zside[neighbor_n]/I");
0293   treeTriggerCells_->Branch("neighbor_subdet", triggerCellNeighbor_subdet_.get(), "neighbor_subdet[neighbor_n]/I");
0294   treeTriggerCells_->Branch("neighbor_layer", triggerCellNeighbor_layer_.get(), "neighbor_layer[neighbor_n]/I");
0295   treeTriggerCells_->Branch("neighbor_waferu", triggerCellNeighbor_waferU_.get(), "neighbor_waferu[neighbor_n]/I");
0296   treeTriggerCells_->Branch("neighbor_waferv", triggerCellNeighbor_waferV_.get(), "neighbor_waferv[neighbor_n]/I");
0297   treeTriggerCells_->Branch("neighbor_cellu", triggerCellNeighbor_cellU_.get(), "neighbor_cellu[neighbor_n]/I");
0298   treeTriggerCells_->Branch("neighbor_cellv", triggerCellNeighbor_cellV_.get(), "neighbor_cellv[neighbor_n]/I");
0299   treeTriggerCells_->Branch(
0300       "neighbor_distance", triggerCellNeighbor_distance_.get(), "neighbor_distance[neighbor_n]/F");
0301   treeTriggerCells_->Branch("c_n", &triggerCellCell_N_, "c_n/I");
0302   triggerCellCell_id_.reset(new int[1], array_deleter<int>());
0303   triggerCellCell_zside_.reset(new int[1], array_deleter<int>());
0304   triggerCellCell_subdet_.reset(new int[1], array_deleter<int>());
0305   triggerCellCell_layer_.reset(new int[1], array_deleter<int>());
0306   triggerCellCell_waferU_.reset(new int[1], array_deleter<int>());
0307   triggerCellCell_waferV_.reset(new int[1], array_deleter<int>());
0308   triggerCellCell_cellU_.reset(new int[1], array_deleter<int>());
0309   triggerCellCell_cellV_.reset(new int[1], array_deleter<int>());
0310   triggerCellCell_ieta_.reset(new int[1], array_deleter<int>());
0311   triggerCellCell_iphi_.reset(new int[1], array_deleter<int>());
0312   triggerCellCell_x_.reset(new float[1], array_deleter<float>());
0313   triggerCellCell_y_.reset(new float[1], array_deleter<float>());
0314   triggerCellCell_z_.reset(new float[1], array_deleter<float>());
0315   treeTriggerCells_->Branch("c_id", triggerCellCell_id_.get(), "c_id[c_n]/I");
0316   treeTriggerCells_->Branch("c_zside", triggerCellCell_zside_.get(), "c_zside[c_n]/I");
0317   treeTriggerCells_->Branch("c_subdet", triggerCellCell_subdet_.get(), "c_subdet[c_n]/I");
0318   treeTriggerCells_->Branch("c_layer", triggerCellCell_layer_.get(), "c_layer[c_n]/I");
0319   treeTriggerCells_->Branch("c_waferu", triggerCellCell_waferU_.get(), "c_waferu[c_n]/I");
0320   treeTriggerCells_->Branch("c_waferv", triggerCellCell_waferV_.get(), "c_waferv[c_n]/I");
0321   treeTriggerCells_->Branch("c_cellu", triggerCellCell_cellU_.get(), "c_cellu[c_n]/I");
0322   treeTriggerCells_->Branch("c_cellv", triggerCellCell_cellV_.get(), "c_cellv[c_n]/I");
0323   treeTriggerCells_->Branch("c_ieta", triggerCellCell_ieta_.get(), "c_cell[c_n]/I");
0324   treeTriggerCells_->Branch("c_iphi", triggerCellCell_iphi_.get(), "c_cell[c_n]/I");
0325   treeTriggerCells_->Branch("c_x", triggerCellCell_x_.get(), "c_x[c_n]/F");
0326   treeTriggerCells_->Branch("c_y", triggerCellCell_y_.get(), "c_y[c_n]/F");
0327   treeTriggerCells_->Branch("c_z", triggerCellCell_z_.get(), "c_z[c_n]/F");
0328   //
0329   treeCells_ = fs->make<TTree>("TreeCells", "Tree of all HGC cells");
0330   treeCells_->Branch("id", &cellId_, "id/I");
0331   treeCells_->Branch("zside", &cellSide_, "zside/I");
0332   treeCells_->Branch("subdet", &cellSubdet_, "subdet/I");
0333   treeCells_->Branch("layer", &cellLayer_, "layer/I");
0334   treeCells_->Branch("waferu", &cellWaferU_, "waferu/I");
0335   treeCells_->Branch("waferv", &cellWaferV_, "waferv/I");
0336   treeCells_->Branch("wafertype", &cellWaferType_, "wafertype/I");
0337   treeCells_->Branch("waferrow", &cellWaferRow_, "waferrow/I");
0338   treeCells_->Branch("wafercolumn", &cellWaferColumn_, "wafercolumn/I");
0339   treeCells_->Branch("cellu", &cellU_, "cellu/I");
0340   treeCells_->Branch("cellv", &cellV_, "cellv/I");
0341   treeCells_->Branch("x", &cellX_, "x/F");
0342   treeCells_->Branch("y", &cellY_, "y/F");
0343   treeCells_->Branch("z", &cellZ_, "z/F");
0344   treeCells_->Branch("corner_n", &cellCornersN_, "corner_n/I");
0345   treeCells_->Branch("corner_x", cellCornersX_.get(), "corner_x[corner_n]/F");
0346   treeCells_->Branch("corner_y", cellCornersY_.get(), "corner_y[corner_n]/F");
0347   treeCells_->Branch("corner_z", cellCornersZ_.get(), "corner_z[corner_n]/F");
0348   //
0349   treeCellsBH_ = fs->make<TTree>("TreeCellsBH", "Tree of all BH cells");
0350   treeCellsBH_->Branch("id", &cellBHId_, "id/I");
0351   treeCellsBH_->Branch("type", &cellBHType_, "type/I");
0352   treeCellsBH_->Branch("zside", &cellBHSide_, "zside/I");
0353   treeCellsBH_->Branch("subdet", &cellBHSubdet_, "subdet/I");
0354   treeCellsBH_->Branch("layer", &cellBHLayer_, "layer/I");
0355   treeCellsBH_->Branch("ieta", &cellBHIEta_, "ieta/I");
0356   treeCellsBH_->Branch("iphi", &cellBHIPhi_, "iphi/I");
0357   treeCellsBH_->Branch("eta", &cellBHEta_, "eta/F");
0358   treeCellsBH_->Branch("phi", &cellBHPhi_, "phi/F");
0359   treeCellsBH_->Branch("x", &cellBHX_, "x/F");
0360   treeCellsBH_->Branch("y", &cellBHY_, "y/F");
0361   treeCellsBH_->Branch("z", &cellBHZ_, "z/F");
0362   treeCellsBH_->Branch("x1", &cellBHX1_, "x1/F");
0363   treeCellsBH_->Branch("y1", &cellBHY1_, "y1/F");
0364   treeCellsBH_->Branch("x2", &cellBHX2_, "x2/F");
0365   treeCellsBH_->Branch("y2", &cellBHY2_, "y2/F");
0366   treeCellsBH_->Branch("x3", &cellBHX3_, "x3/F");
0367   treeCellsBH_->Branch("y3", &cellBHY3_, "y3/F");
0368   treeCellsBH_->Branch("x4", &cellBHX4_, "x4/F");
0369   treeCellsBH_->Branch("y4", &cellBHY4_, "y4/F");
0370   //
0371   treeCellsNose_ = fs->make<TTree>("TreeCellsNose", "Tree of all HGCnose cells");
0372   treeCellsNose_->Branch("id", &cellId_, "id/I");
0373   treeCellsNose_->Branch("zside", &cellSide_, "zside/I");
0374   treeCellsNose_->Branch("subdet", &cellSubdet_, "subdet/I");
0375   treeCellsNose_->Branch("layer", &cellLayer_, "layer/I");
0376   treeCellsNose_->Branch("waferu", &cellWaferU_, "waferu/I");
0377   treeCellsNose_->Branch("waferv", &cellWaferV_, "waferv/I");
0378   treeCellsNose_->Branch("wafertype", &cellWaferType_, "wafertype/I");
0379   treeCellsNose_->Branch("waferrow", &cellWaferRow_, "waferrow/I");
0380   treeCellsNose_->Branch("wafercolumn", &cellWaferColumn_, "wafercolumn/I");
0381   treeCellsNose_->Branch("cellu", &cellU_, "cellu/I");
0382   treeCellsNose_->Branch("cellv", &cellV_, "cellv/I");
0383   treeCellsNose_->Branch("x", &cellX_, "x/F");
0384   treeCellsNose_->Branch("y", &cellY_, "y/F");
0385   treeCellsNose_->Branch("z", &cellZ_, "z/F");
0386   treeCellsNose_->Branch("corner_n", &cellCornersN_, "corner_n/I");
0387   treeCellsNose_->Branch("corner_x", cellCornersX_.get(), "corner_x[corner_n]/F");
0388   treeCellsNose_->Branch("corner_y", cellCornersY_.get(), "corner_y[corner_n]/F");
0389   treeCellsNose_->Branch("corner_z", cellCornersZ_.get(), "corner_z[corner_n]/F");
0390   //
0391   treeModuleErrors_ = fs->make<TTree>("TreeModuleErrors", "Tree of module mapping errors");
0392   treeModuleErrors_->Branch("subdet", &moduleErrorSubdet_, "subdet/I");
0393   treeModuleErrors_->Branch("layer", &moduleErrorLayer_, "layer/I");
0394   treeModuleErrors_->Branch("waferu", &moduleErrorWaferU_, "waferu/I");
0395   treeModuleErrors_->Branch("waferv", &moduleErrorWaferV_, "waferv/I");
0396 }
0397 
0398 /*****************************************************************/
0399 void HGCalTriggerGeomTesterV9Imp2::beginRun(const edm::Run& /*run*/, const edm::EventSetup& es)
0400 /*****************************************************************/
0401 {
0402   triggerGeometry_ = es.getHandle(triggerGeomToken_);
0403 
0404   no_trigger_ = !checkMappingConsistency();
0405   no_neighbors_ = !checkNeighborConsistency();
0406 
0407   fillTriggerGeometry();
0408 }
0409 
0410 bool HGCalTriggerGeomTesterV9Imp2::checkMappingConsistency() {
0411   try {
0412     // Set of (subdet,layer,waferU,waferV) with module mapping errors
0413     std::set<std::tuple<unsigned, unsigned, int, int>> module_errors;
0414     trigger_map_set modules_to_triggercells;
0415     trigger_map_set modules_to_cells;
0416     trigger_map_set triggercells_to_cells;
0417     // EE
0418     for (const auto& id : triggerGeometry_->eeGeometry()->getValidDetIds()) {
0419       HGCSiliconDetId detid(id);
0420       if (!triggerGeometry_->eeTopology().valid(id))
0421         continue;
0422       // fill trigger cells
0423       uint32_t trigger_cell = triggerGeometry_->getTriggerCellFromCell(id);
0424       auto itr_insert = triggercells_to_cells.emplace(trigger_cell, std::unordered_set<uint32_t>());
0425       itr_insert.first->second.emplace(id);
0426       // fill modules
0427       uint32_t module = 0;
0428       try {
0429         module = triggerGeometry_->getModuleFromCell(id);
0430       } catch (const cms::Exception& e) {
0431         module_errors.emplace(std::make_tuple(HGCalTriggerDetId(trigger_cell).subdet(),
0432                                               HGCalTriggerDetId(trigger_cell).layer(),
0433                                               HGCalTriggerDetId(trigger_cell).waferU(),
0434                                               HGCalTriggerDetId(trigger_cell).waferV()));
0435         continue;
0436       }
0437       itr_insert = modules_to_cells.emplace(module, std::unordered_set<uint32_t>());
0438       itr_insert.first->second.emplace(id);
0439     }
0440     // HSi
0441     for (const auto& id : triggerGeometry_->hsiGeometry()->getValidDetIds()) {
0442       if (!triggerGeometry_->hsiTopology().valid(id))
0443         continue;
0444       // fill trigger cells
0445       uint32_t trigger_cell = triggerGeometry_->getTriggerCellFromCell(id);
0446       auto itr_insert = triggercells_to_cells.emplace(trigger_cell, std::unordered_set<uint32_t>());
0447       itr_insert.first->second.emplace(id);
0448       // fill modules
0449       uint32_t module = 0;
0450       try {
0451         module = triggerGeometry_->getModuleFromCell(id);
0452       } catch (const cms::Exception& e) {
0453         module_errors.emplace(std::make_tuple(HGCalTriggerDetId(trigger_cell).subdet(),
0454                                               HGCalTriggerDetId(trigger_cell).layer(),
0455                                               HGCalTriggerDetId(trigger_cell).waferU(),
0456                                               HGCalTriggerDetId(trigger_cell).waferV()));
0457         continue;
0458       }
0459       itr_insert = modules_to_cells.emplace(module, std::unordered_set<uint32_t>());
0460       itr_insert.first->second.emplace(id);
0461     }
0462     // HSc
0463     for (const auto& id : triggerGeometry_->hscGeometry()->getValidDetIds()) {
0464       // fill trigger cells
0465       unsigned layer = HGCScintillatorDetId(id).layer();
0466       if (HGCScintillatorDetId(id).type() != triggerGeometry_->hscTopology().dddConstants().getTypeTrap(layer)) {
0467         std::cout << "Sci cell type = " << HGCScintillatorDetId(id).type()
0468                   << " != " << triggerGeometry_->hscTopology().dddConstants().getTypeTrap(layer) << "\n";
0469       }
0470       uint32_t trigger_cell = triggerGeometry_->getTriggerCellFromCell(id);
0471       auto itr_insert = triggercells_to_cells.emplace(trigger_cell, std::unordered_set<uint32_t>());
0472       itr_insert.first->second.emplace(id);
0473       // fill modules
0474       uint32_t module = triggerGeometry_->getModuleFromCell(id);
0475       if (module != 0) {
0476         itr_insert = modules_to_cells.emplace(module, std::unordered_set<uint32_t>());
0477         itr_insert.first->second.emplace(id);
0478       }
0479     }
0480     // NOSE
0481     if (triggerGeometry_->isWithNoseGeometry()) {
0482       for (const auto& id : triggerGeometry_->noseGeometry()->getValidDetIds()) {
0483         if (!triggerGeometry_->noseTopology().valid(id))
0484           continue;
0485         // fill trigger cells
0486         uint32_t trigger_cell = triggerGeometry_->getTriggerCellFromCell(id);
0487         auto itr_insert = triggercells_to_cells.emplace(trigger_cell, std::unordered_set<uint32_t>());
0488         itr_insert.first->second.emplace(id);
0489         // fill modules
0490         uint32_t module = triggerGeometry_->getModuleFromCell(id);
0491         if (module != 0) {
0492           itr_insert = modules_to_cells.emplace(module, std::unordered_set<uint32_t>());
0493           itr_insert.first->second.emplace(id);
0494         }
0495       }
0496     }
0497 
0498     if (module_errors.size() > 0) {
0499       for (const auto& module : module_errors) {
0500         moduleErrorSubdet_ = std::get<0>(module);
0501         moduleErrorLayer_ = std::get<1>(module);
0502         moduleErrorWaferU_ = std::get<2>(module);
0503         moduleErrorWaferV_ = std::get<3>(module);
0504         treeModuleErrors_->Fill();
0505       }
0506       throw cms::Exception("BadGeometry") << "HGCalTriggerGeometry: Found  module mapping problems. Check the produced "
0507                                              "tree to see the list of problematic wafers";
0508     }
0509 
0510     edm::LogPrint("TriggerCellCheck") << "Checking cell -> trigger cell -> cell consistency";
0511     // Loop over trigger cells
0512     for (const auto& triggercell_cells : triggercells_to_cells) {
0513       DetId id(triggercell_cells.first);
0514 
0515       // fill modules
0516       uint32_t module = triggerGeometry_->getModuleFromTriggerCell(id);
0517       if (module != 0) {
0518         if (id.det() != DetId::HGCalHSc) {
0519           auto itr_insert = modules_to_triggercells.emplace(module, std::unordered_set<uint32_t>());
0520           itr_insert.first->second.emplace(id);
0521         }
0522       }
0523 
0524       // Check consistency of cells included in trigger cell
0525       HGCalTriggerGeometryBase::geom_set cells_geom = triggerGeometry_->getCellsFromTriggerCell(id);
0526       const auto& cells = triggercell_cells.second;
0527       for (auto cell : cells) {
0528         if (cells_geom.find(cell) == cells_geom.end()) {
0529           if (id.det() == DetId::HGCalHSc) {
0530             edm::LogProblem("BadTriggerCell")
0531                 << "Error: \n Cell " << cell << "(" << HGCScintillatorDetId(cell)
0532                 << ")\n has not been found in \n trigger cell " << HGCScintillatorDetId(id);
0533             std::stringstream output;
0534             output << " Available cells are:\n";
0535             for (auto cell_geom : cells_geom)
0536               output << "     " << HGCScintillatorDetId(cell_geom) << "\n";
0537             edm::LogProblem("BadTriggerCell") << output.str();
0538           } else if (HFNoseTriggerDetId(id).subdet() == HGCalTriggerSubdetector::HFNoseTrigger) {
0539             edm::LogProblem("BadTriggerCell")
0540                 << "Error: \n Cell " << cell << "(" << HFNoseDetId(cell) << ")\n has not been found in \n trigger cell "
0541                 << HFNoseTriggerDetId(triggercell_cells.first);
0542             std::stringstream output;
0543             output << " Available cells are:\n";
0544             for (auto cell_geom : cells_geom)
0545               output << "     " << HFNoseDetId(cell_geom) << "\n";
0546             edm::LogProblem("BadTriggerCell") << output.str();
0547           } else if (HGCalTriggerDetId(id).subdet() == HGCalTriggerSubdetector::HGCalEETrigger ||
0548                      HGCalTriggerDetId(id).subdet() == HGCalTriggerSubdetector::HGCalHSiTrigger) {
0549             edm::LogProblem("BadTriggerCell")
0550                 << "Error: \n Cell " << cell << "(" << HGCSiliconDetId(cell)
0551                 << ")\n has not been found in \n trigger cell " << HGCalTriggerDetId(triggercell_cells.first);
0552             std::stringstream output;
0553             output << " Available cells are:\n";
0554             for (auto cell_geom : cells_geom)
0555               output << "     " << HGCSiliconDetId(cell_geom) << "\n";
0556             edm::LogProblem("BadTriggerCell") << output.str();
0557           } else {
0558             edm::LogProblem("BadTriggerCell")
0559                 << "Unknown detector type " << id.det() << " " << id.subdetId() << " " << id.rawId() << "\n";
0560             edm::LogProblem("BadTriggerCell") << " cell " << std::hex << cell << std::dec << " "
0561                                               << "\n";
0562             edm::LogProblem("BadTriggerCell")
0563                 << "Cell ID " << HGCSiliconDetId(cell) << " or " << HFNoseDetId(cell) << "\n";
0564           }
0565           throw cms::Exception("BadGeometry")
0566               << "HGCalTriggerGeometry: Found inconsistency in cell <-> trigger cell mapping";
0567         }
0568       }
0569     }
0570     edm::LogPrint("ModuleCheck") << "Checking trigger cell -> module -> trigger cell consistency";
0571     // Loop over modules
0572     for (const auto& module_triggercells : modules_to_triggercells) {
0573       DetId id(module_triggercells.first);
0574       // Check consistency of trigger cells included in module
0575       HGCalTriggerGeometryBase::geom_set triggercells_geom = triggerGeometry_->getTriggerCellsFromModule(id);
0576       const auto& triggercells = module_triggercells.second;
0577       for (auto cell : triggercells) {
0578         if (triggercells_geom.find(cell) == triggercells_geom.end()) {
0579           if (id.det() == DetId::HGCalHSc) {
0580             HGCScintillatorDetId cellid(cell);
0581             edm::LogProblem("BadModule") << "Error: \n Trigger cell " << cell << "(" << cellid
0582                                          << ")\n has not been found in \n module " << HGCScintillatorDetId(id);
0583             std::stringstream output;
0584             output << " Available trigger cells are:\n";
0585             for (auto cell_geom : triggercells_geom) {
0586               output << "     " << HGCScintillatorDetId(cell_geom) << "\n";
0587             }
0588             edm::LogProblem("BadModule") << output.str();
0589             throw cms::Exception("BadGeometry")
0590                 << "HGCalTriggerGeometry: Found inconsistency in trigger cell <->  module mapping";
0591           } else if (id.det() == DetId::Forward and id.subdetId() == ForwardSubdetector::HFNose) {
0592             HFNoseTriggerDetId cellid(cell);
0593             edm::LogProblem("BadModule") << "Error : \n Trigger cell " << cell << "(" << cellid
0594                                          << ")\n has not been found in \n module " << HFNoseDetId(id);
0595             std::stringstream output;
0596             output << " Available trigger cells are:\n";
0597             for (auto cell_geom : triggercells_geom) {
0598               output << "     " << HFNoseTriggerDetId(cell_geom) << "\n";
0599             }
0600             edm::LogProblem("BadModule") << output.str();
0601             throw cms::Exception("BadGeometry")
0602                 << "HGCalTriggerGeometry: Found inconsistency in trigger cell <->  module mapping";
0603           } else {
0604             HGCalTriggerDetId cellid(cell);
0605             edm::LogProblem("BadModule") << "Error : \n Trigger cell " << cell << "(" << cellid
0606                                          << ")\n has not been found in \n module " << HGCalDetId(id);
0607             std::stringstream output;
0608             output << " Available trigger cells are:\n";
0609             for (auto cell_geom : triggercells_geom) {
0610               output << "     " << HGCalTriggerDetId(cell_geom) << "\n";
0611             }
0612             edm::LogProblem("BadModule") << output.str();
0613             throw cms::Exception("BadGeometry")
0614                 << "HGCalTriggerGeometry: Found inconsistency in trigger cell <->  module mapping";
0615           }
0616         }
0617       }
0618     }
0619     edm::LogPrint("ModuleCheck") << "Checking cell -> module -> cell consistency";
0620     for (const auto& module_cells : modules_to_cells) {
0621       DetId id(module_cells.first);
0622       // Check consistency of cells included in module
0623       HGCalTriggerGeometryBase::geom_set cells_geom = triggerGeometry_->getCellsFromModule(id);
0624       const auto& cells = module_cells.second;
0625       for (auto cell : cells) {
0626         if (cells_geom.find(cell) == cells_geom.end()) {
0627           if (id.det() == DetId::HGCalHSc) {
0628             edm::LogProblem("BadModule") << "Error: \n Cell " << cell << "(" << HGCScintillatorDetId(cell)
0629                                          << ")\n has not been found in \n module " << HGCScintillatorDetId(id);
0630           } else if (id.det() == DetId::Forward && id.subdetId() == ForwardSubdetector::HFNose) {
0631             edm::LogProblem("BadModule") << "Error: \n Cell " << cell << "(" << HFNoseDetId(cell)
0632                                          << ")\n has not been found in \n module " << HFNoseDetId(id);
0633           } else {
0634             edm::LogProblem("BadModule") << "Error: \n Cell " << cell << "(" << HGCSiliconDetId(cell)
0635                                          << ")\n has not been found in \n module " << HGCalDetId(id);
0636           }
0637           std::stringstream output;
0638           output << " Available cells are:\n";
0639           for (auto cell_geom : cells_geom) {
0640             output << cell_geom << " ";
0641           }
0642           edm::LogProblem("BadModule") << output.str();
0643           throw cms::Exception("BadGeometry") << "HGCalTriggerGeometry: Found inconsistency in cell <-> module mapping";
0644         }
0645       }
0646     }
0647   } catch (const cms::Exception& e) {
0648     edm::LogWarning("HGCalTriggerGeometryTester")
0649         << "Problem with the trigger geometry detected. Only the basic cells tree will be filled\n";
0650     edm::LogWarning("HGCalTriggerGeometryTester") << e.message() << "\n";
0651     return false;
0652   }
0653   return true;
0654 }
0655 
0656 bool HGCalTriggerGeomTesterV9Imp2::checkNeighborConsistency() {
0657   try {
0658     trigger_map_set triggercells_to_cells;
0659 
0660     // EE
0661     for (const auto& id : triggerGeometry_->eeGeometry()->getValidDetIds()) {
0662       if (!triggerGeometry_->eeTopology().valid(id))
0663         continue;
0664       // fill trigger cells
0665       // Skip trigger cells in module 0
0666       uint32_t trigger_cell = triggerGeometry_->getTriggerCellFromCell(id);
0667       uint32_t module = triggerGeometry_->getModuleFromTriggerCell(trigger_cell);
0668       if (HGCalDetId(module).wafer() == 0)
0669         continue;
0670       auto itr_insert = triggercells_to_cells.emplace(trigger_cell, std::unordered_set<uint32_t>());
0671       itr_insert.first->second.emplace(id);
0672     }
0673     // HSi
0674     for (const auto& id : triggerGeometry_->hsiGeometry()->getValidDetIds()) {
0675       if (!triggerGeometry_->hsiTopology().valid(id))
0676         continue;
0677       // fill trigger cells
0678       // Skip trigger cells in module 0
0679       uint32_t trigger_cell = triggerGeometry_->getTriggerCellFromCell(id);
0680       uint32_t module = triggerGeometry_->getModuleFromTriggerCell(trigger_cell);
0681       if (HGCalDetId(module).wafer() == 0)
0682         continue;
0683       auto itr_insert = triggercells_to_cells.emplace(trigger_cell, std::unordered_set<uint32_t>());
0684       itr_insert.first->second.emplace(id);
0685     }
0686     // HSc
0687     for (const auto& id : triggerGeometry_->hscGeometry()->getValidDetIds()) {
0688       if (!triggerGeometry_->hscTopology().valid(id))
0689         continue;
0690       // fill trigger cells
0691       // Skip trigger cells in module 0
0692       uint32_t trigger_cell = triggerGeometry_->getTriggerCellFromCell(id);
0693       uint32_t module = triggerGeometry_->getModuleFromTriggerCell(trigger_cell);
0694       if (HGCalDetId(module).wafer() == 0)
0695         continue;
0696       auto itr_insert = triggercells_to_cells.emplace(trigger_cell, std::unordered_set<uint32_t>());
0697       itr_insert.first->second.emplace(id);
0698     }
0699     // NOSE
0700     if (triggerGeometry_->isWithNoseGeometry()) {
0701       for (const auto& id : triggerGeometry_->noseGeometry()->getValidDetIds()) {
0702         if (!triggerGeometry_->noseTopology().valid(id))
0703           continue;
0704         // fill trigger cells
0705         // Skip trigger cells: no need since do disconnected layers
0706         uint32_t trigger_cell = triggerGeometry_->getTriggerCellFromCell(id);
0707         auto itr_insert = triggercells_to_cells.emplace(trigger_cell, std::unordered_set<uint32_t>());
0708         itr_insert.first->second.emplace(id);
0709       }
0710     }
0711     edm::LogPrint("NeighborCheck") << "Checking trigger cell neighbor consistency";
0712     // Loop over trigger cells
0713     for (const auto& triggercell_cells : triggercells_to_cells) {
0714       unsigned triggercell_id(triggercell_cells.first);
0715       const auto neighbors = triggerGeometry_->getNeighborsFromTriggerCell(triggercell_id);
0716       for (const auto neighbor : neighbors) {
0717         const auto neighbors_of_neighbor = triggerGeometry_->getNeighborsFromTriggerCell(neighbor);
0718         // check if the original cell is included in the neigbors of neighbor
0719         if (neighbors_of_neighbor.find(triggercell_id) == neighbors_of_neighbor.end()) {
0720           edm::LogProblem("BadNeighbor") << "Error: \n Trigger cell " << HGCalDetId(neighbor)
0721                                          << "\n is a neighbor of \n"
0722                                          << HGCalDetId(triggercell_id);
0723           edm::LogProblem("BadNeighbor") << " But the opposite is not true";
0724           std::stringstream output;
0725           output << " List of neighbors of neighbor = \n";
0726           for (const auto neighbor_of_neighbor : neighbors_of_neighbor) {
0727             output << "  " << HGCalDetId(neighbor_of_neighbor) << "\n";
0728           }
0729           edm::LogProblem("BadNeighbor") << output.str();
0730         }
0731       }
0732     }
0733   } catch (const cms::Exception& e) {
0734     edm::LogWarning("HGCalTriggerGeometryTester")
0735         << "Problem with the trigger neighbors detected. No neighbor information will be filled\n";
0736     edm::LogWarning("HGCalTriggerGeometryTester") << e.message() << "\n";
0737     return false;
0738   }
0739   return true;
0740 }
0741 
0742 /*****************************************************************/
0743 void HGCalTriggerGeomTesterV9Imp2::fillTriggerGeometry()
0744 /*****************************************************************/
0745 {
0746   trigger_map_set modules;
0747   trigger_map_set trigger_cells;
0748 
0749   // Loop over cells
0750   edm::LogPrint("TreeFilling") << "Filling cells tree";
0751   // EE
0752   std::cout << "Filling EE geometry\n";
0753   for (const auto& id : triggerGeometry_->eeGeometry()->getValidDetIds()) {
0754     HGCSiliconDetId detid(id);
0755     if (!triggerGeometry_->eeTopology().valid(id))
0756       continue;
0757     cellId_ = detid.rawId();
0758     cellSide_ = detid.zside();
0759     cellSubdet_ = detid.subdet();
0760     cellLayer_ = detid.layer();
0761     cellWaferU_ = detid.waferU();
0762     cellWaferV_ = detid.waferV();
0763     cellU_ = detid.cellU();
0764     cellV_ = detid.cellV();
0765     int type1 = detid.type();
0766     int type2 = triggerGeometry_->eeTopology().dddConstants().getTypeHex(cellLayer_, cellWaferU_, cellWaferV_);
0767     if (type1 != type2) {
0768       std::cout << "Found incompatible wafer types:\n  " << detid << "\n";
0769     }
0770     //
0771     GlobalPoint center = triggerGeometry_->eeGeometry()->getPosition(id);
0772     cellX_ = center.x();
0773     cellY_ = center.y();
0774     cellZ_ = center.z();
0775     std::vector<GlobalPoint> corners = triggerGeometry_->eeGeometry()->getCorners(id);
0776     cellCornersN_ = corners.size();
0777     setTreeCellCornerSize(cellCornersN_);
0778     for (unsigned i = 0; i < corners.size(); i++) {
0779       cellCornersX_.get()[i] = corners[i].x();
0780       cellCornersY_.get()[i] = corners[i].y();
0781       cellCornersZ_.get()[i] = corners[i].z();
0782     }
0783     treeCells_->Fill();
0784     // fill trigger cells
0785     if (!no_trigger_) {
0786       uint32_t trigger_cell = triggerGeometry_->getTriggerCellFromCell(id);
0787       // Skip trigger cells in module 0
0788       uint32_t module = triggerGeometry_->getModuleFromTriggerCell(trigger_cell);
0789       if (HGCalDetId(module).wafer() == 0)
0790         continue;
0791       auto itr_insert = trigger_cells.emplace(trigger_cell, std::unordered_set<uint32_t>());
0792       itr_insert.first->second.emplace(id);
0793     }
0794   }
0795   std::cout << "Filling HSi geometry\n";
0796   for (const auto& id : triggerGeometry_->hsiGeometry()->getValidDetIds()) {
0797     HGCSiliconDetId detid(id);
0798     if (!triggerGeometry_->hsiTopology().valid(id))
0799       continue;
0800     cellId_ = detid.rawId();
0801     cellSide_ = detid.zside();
0802     cellSubdet_ = detid.subdet();
0803     cellLayer_ = detid.layer();
0804     cellWaferU_ = detid.waferU();
0805     cellWaferV_ = detid.waferV();
0806     cellU_ = detid.cellU();
0807     cellV_ = detid.cellV();
0808     int type1 = detid.type();
0809     int type2 = triggerGeometry_->hsiTopology().dddConstants().getTypeHex(cellLayer_, cellWaferU_, cellWaferV_);
0810     if (type1 != type2) {
0811       std::cout << "Found incompatible wafer types:\n  " << detid << "\n";
0812     }
0813     //
0814     GlobalPoint center = triggerGeometry_->hsiGeometry()->getPosition(id);
0815     cellX_ = center.x();
0816     cellY_ = center.y();
0817     cellZ_ = center.z();
0818     std::vector<GlobalPoint> corners = triggerGeometry_->hsiGeometry()->getCorners(id);
0819     cellCornersN_ = corners.size();
0820     setTreeCellCornerSize(cellCornersN_);
0821     for (unsigned i = 0; i < corners.size(); i++) {
0822       cellCornersX_.get()[i] = corners[i].x();
0823       cellCornersY_.get()[i] = corners[i].y();
0824       cellCornersZ_.get()[i] = corners[i].z();
0825     }
0826     treeCells_->Fill();
0827     // fill trigger cells
0828     if (!no_trigger_) {
0829       uint32_t trigger_cell = triggerGeometry_->getTriggerCellFromCell(id);
0830       // Skip trigger cells in module 0
0831       uint32_t module = triggerGeometry_->getModuleFromTriggerCell(trigger_cell);
0832       if (HGCalDetId(module).wafer() == 0)
0833         continue;
0834       auto itr_insert = trigger_cells.emplace(trigger_cell, std::unordered_set<uint32_t>());
0835       itr_insert.first->second.emplace(id);
0836     }
0837   }
0838   std::cout << "Filling HSc geometry\n";
0839   for (const auto& id : triggerGeometry_->hscGeometry()->getValidDetIds()) {
0840     HGCScintillatorDetId cellid(id);
0841     cellBHId_ = cellid.rawId();
0842     cellBHType_ = cellid.type();
0843     cellBHSide_ = cellid.zside();
0844     cellBHSubdet_ = cellid.subdet();
0845     cellBHLayer_ = cellid.layer();
0846     cellBHIEta_ = cellid.ieta();
0847     cellBHIPhi_ = cellid.iphi();
0848     //
0849     GlobalPoint center = triggerGeometry_->hscGeometry()->getPosition(id);
0850     cellBHEta_ = center.eta();
0851     cellBHPhi_ = center.phi();
0852     cellBHX_ = center.x();
0853     cellBHY_ = center.y();
0854     cellBHZ_ = center.z();
0855     auto corners = triggerGeometry_->hscGeometry()->getCorners(id);
0856     if (corners.size() >= 4) {
0857       cellBHX1_ = corners[0].x();
0858       cellBHY1_ = corners[0].y();
0859       cellBHX2_ = corners[1].x();
0860       cellBHY2_ = corners[1].y();
0861       cellBHX3_ = corners[2].x();
0862       cellBHY3_ = corners[2].y();
0863       cellBHX4_ = corners[3].x();
0864       cellBHY4_ = corners[3].y();
0865     }
0866     treeCellsBH_->Fill();
0867     // fill trigger cells
0868     if (!no_trigger_) {
0869       uint32_t trigger_cell = triggerGeometry_->getTriggerCellFromCell(id);
0870       auto itr_insert = trigger_cells.emplace(trigger_cell, std::unordered_set<uint32_t>());
0871       itr_insert.first->second.emplace(id);
0872     }
0873   }
0874 
0875   if (triggerGeometry_->isWithNoseGeometry()) {
0876     // NOSE
0877     std::cout << "Filling NOSE geometry\n";
0878     for (const auto& id : triggerGeometry_->noseGeometry()->getValidDetIds()) {
0879       HFNoseDetId detid(id);
0880       cellId_ = detid.rawId();
0881       cellSide_ = detid.zside();
0882       cellSubdet_ = detid.subdet();
0883       cellLayer_ = detid.layer();
0884       cellWaferU_ = detid.waferU();
0885       cellWaferV_ = detid.waferV();
0886       cellU_ = detid.cellU();
0887       cellV_ = detid.cellV();
0888       int type1 = detid.type();
0889       int type2 = triggerGeometry_->noseTopology().dddConstants().getTypeHex(cellLayer_, cellWaferU_, cellWaferV_);
0890       if (type1 != type2) {
0891         std::cout << "Found incompatible wafer types:\n  " << detid << "\n";
0892       }
0893       GlobalPoint center = triggerGeometry_->noseGeometry()->getPosition(id);
0894       cellX_ = center.x();
0895       cellY_ = center.y();
0896       cellZ_ = center.z();
0897       std::vector<GlobalPoint> corners = triggerGeometry_->noseGeometry()->getCorners(id);
0898       cellCornersN_ = corners.size();
0899       setTreeCellCornerSize(cellCornersN_);
0900       for (unsigned i = 0; i < corners.size(); i++) {
0901         cellCornersX_.get()[i] = corners[i].x();
0902         cellCornersY_.get()[i] = corners[i].y();
0903         cellCornersZ_.get()[i] = corners[i].z();
0904       }
0905       treeCellsNose_->Fill();
0906       // fill trigger cells
0907       if (!no_trigger_) {
0908         uint32_t trigger_cell = triggerGeometry_->getTriggerCellFromCell(id);
0909         // Skip trigger cells in module 0
0910         uint32_t module = triggerGeometry_->getModuleFromTriggerCell(trigger_cell);
0911         if (HGCalDetId(module).wafer() == 0)
0912           continue;
0913         auto itr_insert = trigger_cells.emplace(trigger_cell, std::unordered_set<uint32_t>());
0914         itr_insert.first->second.emplace(id);
0915       }
0916     }
0917   }
0918 
0919   // if problem detected in the trigger geometry, don't produce trigger trees
0920   if (no_trigger_)
0921     return;
0922 
0923   // Loop over trigger cells
0924   edm::LogPrint("TreeFilling") << "Filling trigger cells tree";
0925   for (const auto& triggercell_cells : trigger_cells) {
0926     DetId id(triggercell_cells.first);
0927     GlobalPoint position = triggerGeometry_->getTriggerCellPosition(triggercell_cells.first);
0928     triggerCellId_ = id.rawId();
0929     if (id.det() == DetId::HGCalHSc) {
0930       HGCScintillatorDetId id_sc(triggercell_cells.first);
0931       triggerCellSide_ = id_sc.zside();
0932       triggerCellSubdet_ = id_sc.subdet();
0933       triggerCellLayer_ = id_sc.layer();
0934       triggerCellIEta_ = id_sc.ietaAbs();
0935       triggerCellIPhi_ = id_sc.iphi();
0936     } else if (HFNoseTriggerDetId(triggercell_cells.first).det() == DetId::HGCalTrigger &&
0937                HFNoseTriggerDetId(triggercell_cells.first).subdet() == HGCalTriggerSubdetector::HFNoseTrigger) {
0938       HFNoseTriggerDetId id_nose_trig(triggercell_cells.first);
0939       triggerCellSide_ = id_nose_trig.zside();
0940       triggerCellSubdet_ = id_nose_trig.subdet();
0941       triggerCellLayer_ = id_nose_trig.layer();
0942       triggerCellWaferU_ = id_nose_trig.waferU();
0943       triggerCellWaferV_ = id_nose_trig.waferV();
0944       triggerCellU_ = id_nose_trig.triggerCellU();
0945       triggerCellV_ = id_nose_trig.triggerCellV();
0946     } else {
0947       HGCalTriggerDetId id_si_trig(triggercell_cells.first);
0948       triggerCellSide_ = id_si_trig.zside();
0949       triggerCellSubdet_ = id_si_trig.subdet();
0950       triggerCellLayer_ = id_si_trig.layer();
0951       triggerCellWaferU_ = id_si_trig.waferU();
0952       triggerCellWaferV_ = id_si_trig.waferV();
0953       triggerCellU_ = id_si_trig.triggerCellU();
0954       triggerCellV_ = id_si_trig.triggerCellV();
0955     }
0956     triggerCellX_ = position.x();
0957     triggerCellY_ = position.y();
0958     triggerCellZ_ = position.z();
0959     triggerCellCell_N_ = triggercell_cells.second.size();
0960     //
0961     setTreeTriggerCellSize(triggerCellCell_N_);
0962     size_t ic = 0;
0963     for (const auto& c : triggercell_cells.second) {
0964       if (id.det() == DetId::HGCalHSc) {
0965         HGCScintillatorDetId cId(c);
0966         GlobalPoint cell_position = triggerGeometry_->hscGeometry()->getPosition(cId);
0967         triggerCellCell_id_.get()[ic] = c;
0968         triggerCellCell_zside_.get()[ic] = cId.zside();
0969         triggerCellCell_subdet_.get()[ic] = cId.subdetId();
0970         triggerCellCell_layer_.get()[ic] = cId.layer();
0971         triggerCellCell_waferU_.get()[ic] = 0;
0972         triggerCellCell_waferV_.get()[ic] = 0;
0973         triggerCellCell_cellU_.get()[ic] = 0;
0974         triggerCellCell_cellV_.get()[ic] = 0;
0975         triggerCellCell_ieta_.get()[ic] = cId.ietaAbs();
0976         triggerCellCell_iphi_.get()[ic] = cId.iphi();
0977         triggerCellCell_x_.get()[ic] = cell_position.x();
0978         triggerCellCell_y_.get()[ic] = cell_position.y();
0979         triggerCellCell_z_.get()[ic] = cell_position.z();
0980       } else if (HFNoseTriggerDetId(triggercell_cells.first).det() == DetId::HGCalTrigger &&
0981                  HFNoseTriggerDetId(triggercell_cells.first).subdet() == HGCalTriggerSubdetector::HFNoseTrigger) {
0982         HFNoseDetId cId(c);
0983         GlobalPoint cell_position = triggerGeometry_->noseGeometry()->getPosition(cId);
0984         triggerCellCell_id_.get()[ic] = c;
0985         triggerCellCell_zside_.get()[ic] = cId.zside();
0986         triggerCellCell_subdet_.get()[ic] = cId.subdet();
0987         triggerCellCell_layer_.get()[ic] = cId.layer();
0988         triggerCellCell_waferU_.get()[ic] = cId.waferU();
0989         triggerCellCell_waferV_.get()[ic] = cId.waferV();
0990         triggerCellCell_cellU_.get()[ic] = cId.cellU();
0991         triggerCellCell_cellV_.get()[ic] = cId.cellV();
0992         triggerCellCell_ieta_.get()[ic] = 0;
0993         triggerCellCell_iphi_.get()[ic] = 0;
0994         triggerCellCell_x_.get()[ic] = cell_position.x();
0995         triggerCellCell_y_.get()[ic] = cell_position.y();
0996         triggerCellCell_z_.get()[ic] = cell_position.z();
0997       } else {
0998         HGCSiliconDetId cId(c);
0999         GlobalPoint cell_position = (cId.det() == DetId::HGCalEE ? triggerGeometry_->eeGeometry()->getPosition(cId)
1000                                                                  : triggerGeometry_->hsiGeometry()->getPosition(cId));
1001         triggerCellCell_id_.get()[ic] = c;
1002         triggerCellCell_zside_.get()[ic] = cId.zside();
1003         triggerCellCell_subdet_.get()[ic] = cId.subdet();
1004         triggerCellCell_layer_.get()[ic] = cId.layer();
1005         triggerCellCell_waferU_.get()[ic] = cId.waferU();
1006         triggerCellCell_waferV_.get()[ic] = cId.waferV();
1007         triggerCellCell_cellU_.get()[ic] = cId.cellU();
1008         triggerCellCell_cellV_.get()[ic] = cId.cellV();
1009         triggerCellCell_ieta_.get()[ic] = 0;
1010         triggerCellCell_iphi_.get()[ic] = 0;
1011         triggerCellCell_x_.get()[ic] = cell_position.x();
1012         triggerCellCell_y_.get()[ic] = cell_position.y();
1013         triggerCellCell_z_.get()[ic] = cell_position.z();
1014       }
1015       ic++;
1016     }
1017 
1018     treeTriggerCells_->Fill();
1019 
1020     // fill modules
1021     uint32_t module = triggerGeometry_->getModuleFromTriggerCell(id);
1022     auto itr_insert = modules.emplace(module, std::unordered_set<uint32_t>());
1023     itr_insert.first->second.emplace(id);
1024   }
1025 
1026   // Loop over modules
1027   edm::LogPrint("TreeFilling") << "Filling modules tree";
1028 
1029   for (const auto& module_triggercells : modules) {
1030     DetId id(module_triggercells.first);
1031     GlobalPoint position = triggerGeometry_->getModulePosition(id);
1032     moduleId_ = id.rawId();
1033     moduleX_ = position.x();
1034     moduleY_ = position.y();
1035     moduleZ_ = position.z();
1036     if (id.det() == DetId::HGCalHSc) {
1037       HGCScintillatorDetId sc_id(module_triggercells.first);
1038       moduleSide_ = sc_id.zside();
1039       moduleSubdet_ = ForwardSubdetector::HGCHEB;
1040       moduleLayer_ = sc_id.layer();
1041       moduleIEta_ = sc_id.ietaAbs();
1042       moduleIPhi_ = sc_id.iphi();
1043       module_ = 0;
1044     } else if (id.det() == DetId::Forward and id.subdetId() == ForwardSubdetector::HFNose) {
1045       HFNoseTriggerDetId nose_id(module_triggercells.first);
1046       moduleSide_ = nose_id.zside();
1047       moduleSubdet_ = nose_id.subdetId();
1048       moduleLayer_ = nose_id.layer();
1049       moduleIEta_ = 0;
1050       moduleIPhi_ = 0;
1051       module_ = 0;
1052     } else {
1053       HGCalDetId si_id(module_triggercells.first);
1054       moduleSide_ = si_id.zside();
1055       moduleSubdet_ = si_id.subdetId();
1056       moduleLayer_ = si_id.layer();
1057       moduleIEta_ = 0;
1058       moduleIPhi_ = 0;
1059       module_ = si_id.wafer();
1060     }
1061     moduleTC_N_ = module_triggercells.second.size();
1062     if (triggerGeometry_->disconnectedModule(id)) {
1063       moduleLinks_ = 0;
1064     } else {
1065       moduleLinks_ = triggerGeometry_->getLinksInModule(id);
1066     }
1067 
1068     //
1069     setTreeModuleSize(moduleTC_N_);
1070     size_t itc = 0;
1071     for (const auto& tc : module_triggercells.second) {
1072       moduleTC_id_.get()[itc] = tc;
1073       if (id.det() == DetId::HGCalHSc) {
1074         HGCScintillatorDetId tcId(tc);
1075         moduleTC_zside_.get()[itc] = tcId.zside();
1076         moduleTC_subdet_.get()[itc] = tcId.subdet();
1077         moduleTC_layer_.get()[itc] = tcId.layer();
1078         moduleTC_waferU_.get()[itc] = 0;
1079         moduleTC_waferV_.get()[itc] = 0;
1080         moduleTC_cellU_.get()[itc] = 0;
1081         moduleTC_cellV_.get()[itc] = 0;
1082         moduleTC_ieta_.get()[itc] = tcId.ietaAbs();
1083         moduleTC_iphi_.get()[itc] = tcId.iphi();
1084       } else if (id.det() == DetId::Forward and id.subdetId() == ForwardSubdetector::HFNose) {
1085         HFNoseTriggerDetId tcId(tc);
1086         moduleTC_zside_.get()[itc] = tcId.zside();
1087         moduleTC_subdet_.get()[itc] = tcId.subdet();
1088         moduleTC_layer_.get()[itc] = tcId.layer();
1089         moduleTC_waferU_.get()[itc] = tcId.waferU();
1090         moduleTC_waferV_.get()[itc] = tcId.waferV();
1091         moduleTC_cellU_.get()[itc] = tcId.triggerCellU();
1092         moduleTC_cellV_.get()[itc] = tcId.triggerCellV();
1093         moduleTC_ieta_.get()[itc] = 0;
1094         moduleTC_iphi_.get()[itc] = 0;
1095       } else {
1096         HGCalTriggerDetId tcId(tc);
1097         moduleTC_zside_.get()[itc] = tcId.zside();
1098         moduleTC_subdet_.get()[itc] = tcId.subdet();
1099         moduleTC_layer_.get()[itc] = tcId.layer();
1100         moduleTC_waferU_.get()[itc] = tcId.waferU();
1101         moduleTC_waferV_.get()[itc] = tcId.waferV();
1102         moduleTC_cellU_.get()[itc] = tcId.triggerCellU();
1103         moduleTC_cellV_.get()[itc] = tcId.triggerCellV();
1104         moduleTC_ieta_.get()[itc] = 0;
1105         moduleTC_iphi_.get()[itc] = 0;
1106       }
1107       GlobalPoint position = triggerGeometry_->getTriggerCellPosition(tc);
1108       moduleTC_x_.get()[itc] = position.x();
1109       moduleTC_y_.get()[itc] = position.y();
1110       moduleTC_z_.get()[itc] = position.z();
1111       itc++;
1112     }
1113     auto cells_in_module = triggerGeometry_->getCellsFromModule(id);
1114     moduleCell_N_ = cells_in_module.size();
1115     //
1116     setTreeModuleCellSize(moduleCell_N_);
1117     size_t ic = 0;
1118     for (const auto& c : cells_in_module) {
1119       if (id.det() == DetId::HGCalHSc) {
1120         HGCScintillatorDetId cId(c);
1121         GlobalPoint cell_position = triggerGeometry_->hscGeometry()->getPosition(cId);
1122         triggerCellCell_id_.get()[ic] = c;
1123         triggerCellCell_zside_.get()[ic] = cId.zside();
1124         triggerCellCell_subdet_.get()[ic] = cId.subdetId();
1125         triggerCellCell_layer_.get()[ic] = cId.layer();
1126         triggerCellCell_waferU_.get()[ic] = 0;
1127         triggerCellCell_waferV_.get()[ic] = 0;
1128         triggerCellCell_cellU_.get()[ic] = 0;
1129         triggerCellCell_cellV_.get()[ic] = 0;
1130         triggerCellCell_ieta_.get()[ic] = cId.ietaAbs();
1131         triggerCellCell_iphi_.get()[ic] = cId.iphi();
1132         triggerCellCell_x_.get()[ic] = cell_position.x();
1133         triggerCellCell_y_.get()[ic] = cell_position.y();
1134         triggerCellCell_z_.get()[ic] = cell_position.z();
1135       } else if (id.det() == DetId::Forward and id.subdetId() == ForwardSubdetector::HFNose) {
1136         HFNoseDetId cId(c);
1137         const GlobalPoint position = triggerGeometry_->noseGeometry()->getPosition(c);
1138         moduleCell_id_.get()[ic] = c;
1139         moduleCell_zside_.get()[ic] = cId.zside();
1140         moduleCell_subdet_.get()[ic] = cId.subdetId();
1141         moduleCell_layer_.get()[ic] = cId.layer();
1142         moduleCell_waferU_.get()[ic] = cId.waferU();
1143         moduleCell_waferV_.get()[ic] = cId.waferV();
1144         moduleCell_cellU_.get()[ic] = cId.cellU();
1145         moduleCell_cellV_.get()[ic] = cId.cellV();
1146         moduleCell_x_.get()[ic] = position.x();
1147         moduleCell_y_.get()[ic] = position.y();
1148         moduleCell_z_.get()[ic] = position.z();
1149       } else {
1150         HGCSiliconDetId cId(c);
1151         const GlobalPoint position = (cId.det() == DetId::HGCalEE ? triggerGeometry_->eeGeometry()->getPosition(cId)
1152                                                                   : triggerGeometry_->hsiGeometry()->getPosition(cId));
1153         moduleCell_id_.get()[ic] = c;
1154         moduleCell_zside_.get()[ic] = cId.zside();
1155         moduleCell_subdet_.get()[ic] = cId.subdetId();
1156         moduleCell_layer_.get()[ic] = cId.layer();
1157         moduleCell_waferU_.get()[ic] = cId.waferU();
1158         moduleCell_waferV_.get()[ic] = cId.waferV();
1159         moduleCell_cellU_.get()[ic] = cId.cellU();
1160         moduleCell_cellV_.get()[ic] = cId.cellV();
1161         moduleCell_x_.get()[ic] = position.x();
1162         moduleCell_y_.get()[ic] = position.y();
1163         moduleCell_z_.get()[ic] = position.z();
1164         ic++;
1165       }
1166     }
1167     treeModules_->Fill();
1168   }
1169 }
1170 
1171 /*****************************************************************/
1172 void HGCalTriggerGeomTesterV9Imp2::analyze(const edm::Event& e, const edm::EventSetup& es)
1173 /*****************************************************************/
1174 {}
1175 
1176 /*****************************************************************/
1177 void HGCalTriggerGeomTesterV9Imp2::setTreeModuleSize(const size_t n)
1178 /*****************************************************************/
1179 {
1180   moduleTC_id_.reset(new int[n], array_deleter<int>());
1181   moduleTC_zside_.reset(new int[n], array_deleter<int>());
1182   moduleTC_subdet_.reset(new int[n], array_deleter<int>());
1183   moduleTC_layer_.reset(new int[n], array_deleter<int>());
1184   moduleTC_waferU_.reset(new int[n], array_deleter<int>());
1185   moduleTC_waferV_.reset(new int[n], array_deleter<int>());
1186   moduleTC_cellU_.reset(new int[n], array_deleter<int>());
1187   moduleTC_cellV_.reset(new int[n], array_deleter<int>());
1188   moduleTC_ieta_.reset(new int[n], array_deleter<int>());
1189   moduleTC_iphi_.reset(new int[n], array_deleter<int>());
1190   moduleTC_x_.reset(new float[n], array_deleter<float>());
1191   moduleTC_y_.reset(new float[n], array_deleter<float>());
1192   moduleTC_z_.reset(new float[n], array_deleter<float>());
1193 
1194   treeModules_->GetBranch("tc_id")->SetAddress(moduleTC_id_.get());
1195   treeModules_->GetBranch("tc_zside")->SetAddress(moduleTC_zside_.get());
1196   treeModules_->GetBranch("tc_subdet")->SetAddress(moduleTC_subdet_.get());
1197   treeModules_->GetBranch("tc_layer")->SetAddress(moduleTC_layer_.get());
1198   treeModules_->GetBranch("tc_waferu")->SetAddress(moduleTC_waferU_.get());
1199   treeModules_->GetBranch("tc_waferv")->SetAddress(moduleTC_waferV_.get());
1200   treeModules_->GetBranch("tc_cellu")->SetAddress(moduleTC_cellU_.get());
1201   treeModules_->GetBranch("tc_cellv")->SetAddress(moduleTC_cellV_.get());
1202   treeModules_->GetBranch("tc_ieta")->SetAddress(moduleTC_ieta_.get());
1203   treeModules_->GetBranch("tc_iphi")->SetAddress(moduleTC_iphi_.get());
1204   treeModules_->GetBranch("tc_x")->SetAddress(moduleTC_x_.get());
1205   treeModules_->GetBranch("tc_y")->SetAddress(moduleTC_y_.get());
1206   treeModules_->GetBranch("tc_z")->SetAddress(moduleTC_z_.get());
1207 }
1208 
1209 /*****************************************************************/
1210 void HGCalTriggerGeomTesterV9Imp2::setTreeModuleCellSize(const size_t n)
1211 /*****************************************************************/
1212 {
1213   moduleCell_id_.reset(new int[n], array_deleter<int>());
1214   moduleCell_zside_.reset(new int[n], array_deleter<int>());
1215   moduleCell_subdet_.reset(new int[n], array_deleter<int>());
1216   moduleCell_layer_.reset(new int[n], array_deleter<int>());
1217   moduleCell_waferU_.reset(new int[n], array_deleter<int>());
1218   moduleCell_waferV_.reset(new int[n], array_deleter<int>());
1219   moduleCell_cellU_.reset(new int[n], array_deleter<int>());
1220   moduleCell_cellV_.reset(new int[n], array_deleter<int>());
1221   moduleCell_x_.reset(new float[n], array_deleter<float>());
1222   moduleCell_y_.reset(new float[n], array_deleter<float>());
1223   moduleCell_z_.reset(new float[n], array_deleter<float>());
1224 
1225   treeModules_->GetBranch("c_id")->SetAddress(moduleCell_id_.get());
1226   treeModules_->GetBranch("c_zside")->SetAddress(moduleCell_zside_.get());
1227   treeModules_->GetBranch("c_subdet")->SetAddress(moduleCell_subdet_.get());
1228   treeModules_->GetBranch("c_layer")->SetAddress(moduleCell_layer_.get());
1229   treeModules_->GetBranch("c_waferu")->SetAddress(moduleCell_waferU_.get());
1230   treeModules_->GetBranch("c_waferv")->SetAddress(moduleCell_waferV_.get());
1231   treeModules_->GetBranch("c_cellu")->SetAddress(moduleCell_cellU_.get());
1232   treeModules_->GetBranch("c_cellv")->SetAddress(moduleCell_cellV_.get());
1233   treeModules_->GetBranch("c_x")->SetAddress(moduleCell_x_.get());
1234   treeModules_->GetBranch("c_y")->SetAddress(moduleCell_y_.get());
1235   treeModules_->GetBranch("c_z")->SetAddress(moduleCell_z_.get());
1236 }
1237 
1238 /*****************************************************************/
1239 void HGCalTriggerGeomTesterV9Imp2::setTreeTriggerCellSize(const size_t n)
1240 /*****************************************************************/
1241 {
1242   triggerCellCell_id_.reset(new int[n], array_deleter<int>());
1243   triggerCellCell_zside_.reset(new int[n], array_deleter<int>());
1244   triggerCellCell_subdet_.reset(new int[n], array_deleter<int>());
1245   triggerCellCell_layer_.reset(new int[n], array_deleter<int>());
1246   triggerCellCell_waferU_.reset(new int[n], array_deleter<int>());
1247   triggerCellCell_waferV_.reset(new int[n], array_deleter<int>());
1248   triggerCellCell_cellU_.reset(new int[n], array_deleter<int>());
1249   triggerCellCell_cellV_.reset(new int[n], array_deleter<int>());
1250   triggerCellCell_ieta_.reset(new int[n], array_deleter<int>());
1251   triggerCellCell_iphi_.reset(new int[n], array_deleter<int>());
1252   triggerCellCell_x_.reset(new float[n], array_deleter<float>());
1253   triggerCellCell_y_.reset(new float[n], array_deleter<float>());
1254   triggerCellCell_z_.reset(new float[n], array_deleter<float>());
1255 
1256   treeTriggerCells_->GetBranch("c_id")->SetAddress(triggerCellCell_id_.get());
1257   treeTriggerCells_->GetBranch("c_zside")->SetAddress(triggerCellCell_zside_.get());
1258   treeTriggerCells_->GetBranch("c_subdet")->SetAddress(triggerCellCell_subdet_.get());
1259   treeTriggerCells_->GetBranch("c_layer")->SetAddress(triggerCellCell_layer_.get());
1260   treeTriggerCells_->GetBranch("c_waferu")->SetAddress(triggerCellCell_waferU_.get());
1261   treeTriggerCells_->GetBranch("c_waferv")->SetAddress(triggerCellCell_waferV_.get());
1262   treeTriggerCells_->GetBranch("c_cellu")->SetAddress(triggerCellCell_cellU_.get());
1263   treeTriggerCells_->GetBranch("c_cellv")->SetAddress(triggerCellCell_cellV_.get());
1264   treeTriggerCells_->GetBranch("c_ieta")->SetAddress(triggerCellCell_ieta_.get());
1265   treeTriggerCells_->GetBranch("c_iphi")->SetAddress(triggerCellCell_iphi_.get());
1266   treeTriggerCells_->GetBranch("c_x")->SetAddress(triggerCellCell_x_.get());
1267   treeTriggerCells_->GetBranch("c_y")->SetAddress(triggerCellCell_y_.get());
1268   treeTriggerCells_->GetBranch("c_z")->SetAddress(triggerCellCell_z_.get());
1269 }
1270 
1271 /*****************************************************************/
1272 void HGCalTriggerGeomTesterV9Imp2::setTreeCellCornerSize(const size_t n)
1273 /*****************************************************************/
1274 {
1275   cellCornersX_.reset(new float[n], array_deleter<float>());
1276   cellCornersY_.reset(new float[n], array_deleter<float>());
1277   cellCornersZ_.reset(new float[n], array_deleter<float>());
1278 
1279   treeCells_->GetBranch("corner_x")->SetAddress(cellCornersX_.get());
1280   treeCells_->GetBranch("corner_y")->SetAddress(cellCornersY_.get());
1281   treeCells_->GetBranch("corner_z")->SetAddress(cellCornersZ_.get());
1282 }
1283 
1284 /*****************************************************************/
1285 void HGCalTriggerGeomTesterV9Imp2::setTreeTriggerCellNeighborSize(const size_t n)
1286 /*****************************************************************/
1287 {
1288   triggerCellNeighbor_id_.reset(new int[n], array_deleter<int>());
1289   triggerCellNeighbor_zside_.reset(new int[n], array_deleter<int>());
1290   triggerCellNeighbor_subdet_.reset(new int[n], array_deleter<int>());
1291   triggerCellNeighbor_layer_.reset(new int[n], array_deleter<int>());
1292   triggerCellNeighbor_waferU_.reset(new int[n], array_deleter<int>());
1293   triggerCellNeighbor_waferV_.reset(new int[n], array_deleter<int>());
1294   triggerCellNeighbor_cellU_.reset(new int[n], array_deleter<int>());
1295   triggerCellNeighbor_cellV_.reset(new int[n], array_deleter<int>());
1296   triggerCellNeighbor_distance_.reset(new float[n], array_deleter<float>());
1297   treeTriggerCells_->GetBranch("neighbor_id")->SetAddress(triggerCellNeighbor_id_.get());
1298   treeTriggerCells_->GetBranch("neighbor_zside")->SetAddress(triggerCellNeighbor_zside_.get());
1299   treeTriggerCells_->GetBranch("neighbor_subdet")->SetAddress(triggerCellNeighbor_subdet_.get());
1300   treeTriggerCells_->GetBranch("neighbor_layer")->SetAddress(triggerCellNeighbor_layer_.get());
1301   treeTriggerCells_->GetBranch("neighbor_waferu")->SetAddress(triggerCellNeighbor_waferU_.get());
1302   treeTriggerCells_->GetBranch("neighbor_waferv")->SetAddress(triggerCellNeighbor_waferV_.get());
1303   treeTriggerCells_->GetBranch("neighbor_cellu")->SetAddress(triggerCellNeighbor_cellU_.get());
1304   treeTriggerCells_->GetBranch("neighbor_cellv")->SetAddress(triggerCellNeighbor_cellV_.get());
1305   treeTriggerCells_->GetBranch("neighbor_distance")->SetAddress(triggerCellNeighbor_distance_.get());
1306 }
1307 
1308 // define this as a plug-in
1309 DEFINE_FWK_MODULE(HGCalTriggerGeomTesterV9Imp2);