Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-10-25 09:46:04

0001 // user include files
0002 #include "DQMServices/Core/interface/DQMEDAnalyzer.h"
0003 
0004 #include "FWCore/Framework/interface/Event.h"
0005 #include "FWCore/Framework/interface/EventSetup.h"
0006 #include "FWCore/Framework/interface/ESHandle.h"
0007 #include "FWCore/Framework/interface/MakerMacros.h"
0008 
0009 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0010 
0011 #include "SimGeneral/HepPDTRecord/interface/ParticleDataTable.h"
0012 #include "FastSimulation/Event/interface/FSimEvent.h"
0013 #include "FastSimulation/Event/interface/FSimTrack.h"
0014 #include "FastSimulation/Event/interface/FSimVertex.h"
0015 
0016 #include "FWCore/ServiceRegistry/interface/Service.h"
0017 #include <memory>
0018 #include <string>
0019 #include <vector>
0020 
0021 class testMaterialEffects : public DQMEDAnalyzer {
0022 public:
0023   explicit testMaterialEffects(const edm::ParameterSet&);
0024   ~testMaterialEffects() override = default;
0025 
0026   void analyze(const edm::Event&, const edm::EventSetup&) override;
0027   void dqmBeginRun(edm::Run const&, edm::EventSetup const&) override;
0028   void bookHistograms(DQMStore::IBooker&, edm::Run const&, edm::EventSetup const&) override;
0029 
0030 private:
0031   // See RecoParticleFlow/PFProducer/interface/PFProducer.h
0032   const edm::ParameterSet particleFilter_;
0033   const edm::ESGetToken<HepPDT::ParticleDataTable, PDTRecord> tok_pdt_;
0034   const edm::EDGetTokenT<std::vector<SimTrack>> tok_fullSimTk_;
0035   const edm::EDGetTokenT<std::vector<SimVertex>> tok_fullSimVx_;
0036   const edm::EDGetTokenT<std::vector<SimTrack>> tok_fastSimTk_;
0037   const edm::EDGetTokenT<std::vector<SimVertex>> tok_fastSimVx_;
0038   std::vector<std::unique_ptr<FSimEvent>> mySimEvent;
0039   std::string simModuleLabel_;
0040   //  TH2F * h100;
0041   std::vector<MonitorElement*> h0;
0042   std::vector<MonitorElement*> h1;
0043   std::vector<MonitorElement*> h2;
0044   std::vector<MonitorElement*> h3;
0045   std::vector<MonitorElement*> h4;
0046   std::vector<MonitorElement*> h5;
0047   std::vector<MonitorElement*> h6;
0048   std::vector<MonitorElement*> h7;
0049   std::vector<MonitorElement*> h8;
0050   std::vector<MonitorElement*> h9;
0051   std::vector<MonitorElement*> h10;
0052   std::vector<MonitorElement*> h11;
0053   std::vector<MonitorElement*> h12;
0054   std::vector<MonitorElement*> h13;
0055   std::vector<MonitorElement*> h14;
0056   std::vector<MonitorElement*> h15;
0057   std::vector<MonitorElement*> h16;
0058   std::vector<MonitorElement*> h17;
0059   std::vector<MonitorElement*> htmp;
0060 
0061   std::vector<std::vector<MonitorElement*>> h100;
0062   std::vector<std::vector<MonitorElement*>> h200;
0063   std::vector<std::vector<MonitorElement*>> h300;
0064   std::vector<std::vector<double>> trackerRadius;
0065   std::vector<std::vector<double>> trackerLength;
0066   std::vector<std::vector<double>> blockTrackerRadius;
0067   std::vector<std::vector<double>> blockTrackerLength;
0068   std::vector<std::vector<double>> subTrackerRadius;
0069   std::vector<std::vector<double>> subTrackerLength;
0070   std::vector<double> tmpRadius;
0071   std::vector<double> tmpLength;
0072 
0073   unsigned int nevt;
0074 };
0075 
0076 testMaterialEffects::testMaterialEffects(const edm::ParameterSet& p)
0077     : particleFilter_(p.getParameter<edm::ParameterSet>("TestParticleFilter")),
0078       tok_pdt_(esConsumes<HepPDT::ParticleDataTable, PDTRecord>()),
0079       tok_fullSimTk_(consumes<std::vector<SimTrack>>(edm::InputTag("g4SimHits"))),
0080       tok_fullSimVx_(consumes<std::vector<SimVertex>>(edm::InputTag("g4SimHits"))),
0081       tok_fastSimTk_(consumes<std::vector<SimTrack>>(edm::InputTag("famosSimHits"))),
0082       tok_fastSimVx_(consumes<std::vector<SimVertex>>(edm::InputTag("famosSimHits"))),
0083       h0(2, static_cast<MonitorElement*>(0)),
0084       h1(2, static_cast<MonitorElement*>(0)),
0085       h2(2, static_cast<MonitorElement*>(0)),
0086       h3(2, static_cast<MonitorElement*>(0)),
0087       h4(2, static_cast<MonitorElement*>(0)),
0088       h5(2, static_cast<MonitorElement*>(0)),
0089       h6(2, static_cast<MonitorElement*>(0)),
0090       h7(2, static_cast<MonitorElement*>(0)),
0091       h8(2, static_cast<MonitorElement*>(0)),
0092       h9(2, static_cast<MonitorElement*>(0)),
0093       h10(2, static_cast<MonitorElement*>(0)),
0094       h11(2, static_cast<MonitorElement*>(0)),
0095       h12(2, static_cast<MonitorElement*>(0)),
0096       h13(2, static_cast<MonitorElement*>(0)),
0097       h14(2, static_cast<MonitorElement*>(0)),
0098       h15(2, static_cast<MonitorElement*>(0)),
0099       h16(2, static_cast<MonitorElement*>(0)),
0100       h17(2, static_cast<MonitorElement*>(0)),
0101       htmp(2, static_cast<MonitorElement*>(0)),
0102       tmpRadius(2, static_cast<double>(0.)),
0103       tmpLength(2, static_cast<double>(0.)) {
0104   // For the full sim
0105   mySimEvent.emplace_back(std::make_unique<FSimEvent>(particleFilter_));
0106   // For the fast sim
0107   mySimEvent.emplace_back(std::make_unique<FSimEvent>(particleFilter_));
0108 
0109   // Beam Pipe
0110   std::vector<double> tmpRadius = p.getUntrackedParameter<std::vector<double>>("BPCylinderRadius");
0111   std::vector<double> tmpLength = p.getUntrackedParameter<std::vector<double>>("BPCylinderLength");
0112   trackerRadius.push_back(tmpRadius);
0113   trackerLength.push_back(tmpLength);
0114 
0115   // Beam Pipe (cont'd)
0116   blockTrackerRadius.push_back(tmpRadius);
0117   blockTrackerLength.push_back(tmpLength);
0118 
0119   // Beam Pipe (cont'd)
0120   subTrackerRadius.push_back(tmpRadius);
0121   subTrackerLength.push_back(tmpLength);
0122 
0123   // PIXB1
0124   tmpRadius = p.getUntrackedParameter<std::vector<double>>("PXB1CylinderRadius");
0125   tmpLength = p.getUntrackedParameter<std::vector<double>>("PXB1CylinderLength");
0126   trackerRadius.push_back(tmpRadius);
0127   trackerLength.push_back(tmpLength);
0128 
0129   // PIXB2
0130   tmpRadius = p.getUntrackedParameter<std::vector<double>>("PXB2CylinderRadius");
0131   tmpLength = p.getUntrackedParameter<std::vector<double>>("PXB2CylinderLength");
0132   trackerRadius.push_back(tmpRadius);
0133   trackerLength.push_back(tmpLength);
0134 
0135   // PIXB3
0136   tmpRadius = p.getUntrackedParameter<std::vector<double>>("PXB3CylinderRadius");
0137   tmpLength = p.getUntrackedParameter<std::vector<double>>("PXB3CylinderLength");
0138   trackerRadius.push_back(tmpRadius);
0139   trackerLength.push_back(tmpLength);
0140 
0141   // PIXB Cables
0142   tmpRadius = p.getUntrackedParameter<std::vector<double>>("PXBCablesCylinderRadius");
0143   tmpLength = p.getUntrackedParameter<std::vector<double>>("PXBCablesCylinderLength");
0144   trackerRadius.push_back(tmpRadius);
0145   trackerLength.push_back(tmpLength);
0146 
0147   // All Pixel Barrel
0148   blockTrackerRadius.push_back(tmpRadius);
0149   blockTrackerLength.push_back(tmpLength);
0150 
0151   // PIXD1
0152   tmpRadius = p.getUntrackedParameter<std::vector<double>>("PXD1CylinderRadius");
0153   tmpLength = p.getUntrackedParameter<std::vector<double>>("PXD1CylinderLength");
0154   trackerRadius.push_back(tmpRadius);
0155   trackerLength.push_back(tmpLength);
0156 
0157   // PIXD2
0158   tmpRadius = p.getUntrackedParameter<std::vector<double>>("PXD2CylinderRadius");
0159   tmpLength = p.getUntrackedParameter<std::vector<double>>("PXD2CylinderLength");
0160   trackerRadius.push_back(tmpRadius);
0161   trackerLength.push_back(tmpLength);
0162 
0163   // PIXD Cables
0164   tmpRadius = p.getUntrackedParameter<std::vector<double>>("PXDCablesCylinderRadius");
0165   tmpLength = p.getUntrackedParameter<std::vector<double>>("PXDCablesCylinderLength");
0166   trackerRadius.push_back(tmpRadius);
0167   trackerLength.push_back(tmpLength);
0168 
0169   // All Pixel Disks
0170   blockTrackerRadius.push_back(tmpRadius);
0171   blockTrackerLength.push_back(tmpLength);
0172 
0173   // All Pixel
0174   subTrackerRadius.push_back(tmpRadius);
0175   subTrackerLength.push_back(tmpLength);
0176 
0177   // TIB1
0178   tmpRadius = p.getUntrackedParameter<std::vector<double>>("TIB1CylinderRadius");
0179   tmpLength = p.getUntrackedParameter<std::vector<double>>("TIB1CylinderLength");
0180   trackerRadius.push_back(tmpRadius);
0181   trackerLength.push_back(tmpLength);
0182 
0183   // TIB2
0184   tmpRadius = p.getUntrackedParameter<std::vector<double>>("TIB2CylinderRadius");
0185   tmpLength = p.getUntrackedParameter<std::vector<double>>("TIB2CylinderLength");
0186   trackerRadius.push_back(tmpRadius);
0187   trackerLength.push_back(tmpLength);
0188 
0189   // TIB3
0190   tmpRadius = p.getUntrackedParameter<std::vector<double>>("TIB3CylinderRadius");
0191   tmpLength = p.getUntrackedParameter<std::vector<double>>("TIB3CylinderLength");
0192   trackerRadius.push_back(tmpRadius);
0193   trackerLength.push_back(tmpLength);
0194 
0195   // TIB4
0196   tmpRadius = p.getUntrackedParameter<std::vector<double>>("TIB4CylinderRadius");
0197   tmpLength = p.getUntrackedParameter<std::vector<double>>("TIB4CylinderLength");
0198   trackerRadius.push_back(tmpRadius);
0199   trackerLength.push_back(tmpLength);
0200 
0201   // TIB Cables
0202   tmpRadius = p.getUntrackedParameter<std::vector<double>>("TIBCablesCylinderRadius");
0203   tmpLength = p.getUntrackedParameter<std::vector<double>>("TIBCablesCylinderLength");
0204   trackerRadius.push_back(tmpRadius);
0205   trackerLength.push_back(tmpLength);
0206 
0207   // All TIB
0208   blockTrackerRadius.push_back(tmpRadius);
0209   blockTrackerLength.push_back(tmpLength);
0210 
0211   // TID1
0212   tmpRadius = p.getUntrackedParameter<std::vector<double>>("TID1CylinderRadius");
0213   tmpLength = p.getUntrackedParameter<std::vector<double>>("TID1CylinderLength");
0214   trackerRadius.push_back(tmpRadius);
0215   trackerLength.push_back(tmpLength);
0216 
0217   // TID2
0218   tmpRadius = p.getUntrackedParameter<std::vector<double>>("TID2CylinderRadius");
0219   tmpLength = p.getUntrackedParameter<std::vector<double>>("TID2CylinderLength");
0220   trackerRadius.push_back(tmpRadius);
0221   trackerLength.push_back(tmpLength);
0222 
0223   // TID3
0224   tmpRadius = p.getUntrackedParameter<std::vector<double>>("TID3CylinderRadius");
0225   tmpLength = p.getUntrackedParameter<std::vector<double>>("TID3CylinderLength");
0226   trackerRadius.push_back(tmpRadius);
0227   trackerLength.push_back(tmpLength);
0228 
0229   // TID Cables
0230   tmpRadius = p.getUntrackedParameter<std::vector<double>>("TIDCablesCylinderRadius");
0231   tmpLength = p.getUntrackedParameter<std::vector<double>>("TIDCablesCylinderLength");
0232   trackerRadius.push_back(tmpRadius);
0233   trackerLength.push_back(tmpLength);
0234 
0235   // All TID
0236   blockTrackerRadius.push_back(tmpRadius);
0237   blockTrackerLength.push_back(tmpLength);
0238 
0239   // All Inner Tracker
0240   subTrackerRadius.push_back(tmpRadius);
0241   subTrackerLength.push_back(tmpLength);
0242 
0243   // TOB1
0244   tmpRadius = p.getUntrackedParameter<std::vector<double>>("TOB1CylinderRadius");
0245   tmpLength = p.getUntrackedParameter<std::vector<double>>("TOB1CylinderLength");
0246   trackerRadius.push_back(tmpRadius);
0247   trackerLength.push_back(tmpLength);
0248 
0249   // TOB2
0250   tmpRadius = p.getUntrackedParameter<std::vector<double>>("TOB2CylinderRadius");
0251   tmpLength = p.getUntrackedParameter<std::vector<double>>("TOB2CylinderLength");
0252   trackerRadius.push_back(tmpRadius);
0253   trackerLength.push_back(tmpLength);
0254 
0255   // TOB3
0256   tmpRadius = p.getUntrackedParameter<std::vector<double>>("TOB3CylinderRadius");
0257   tmpLength = p.getUntrackedParameter<std::vector<double>>("TOB3CylinderLength");
0258   trackerRadius.push_back(tmpRadius);
0259   trackerLength.push_back(tmpLength);
0260 
0261   // TOB4
0262   tmpRadius = p.getUntrackedParameter<std::vector<double>>("TOB4CylinderRadius");
0263   tmpLength = p.getUntrackedParameter<std::vector<double>>("TOB4CylinderLength");
0264   trackerRadius.push_back(tmpRadius);
0265   trackerLength.push_back(tmpLength);
0266 
0267   // TOB5
0268   tmpRadius = p.getUntrackedParameter<std::vector<double>>("TOB5CylinderRadius");
0269   tmpLength = p.getUntrackedParameter<std::vector<double>>("TOB5CylinderLength");
0270   trackerRadius.push_back(tmpRadius);
0271   trackerLength.push_back(tmpLength);
0272 
0273   // TOB6
0274   tmpRadius = p.getUntrackedParameter<std::vector<double>>("TOB6CylinderRadius");
0275   tmpLength = p.getUntrackedParameter<std::vector<double>>("TOB6CylinderLength");
0276   trackerRadius.push_back(tmpRadius);
0277   trackerLength.push_back(tmpLength);
0278 
0279   // TOB Cables
0280   tmpRadius = p.getUntrackedParameter<std::vector<double>>("TOBCablesCylinderRadius");
0281   tmpLength = p.getUntrackedParameter<std::vector<double>>("TOBCablesCylinderLength");
0282   trackerRadius.push_back(tmpRadius);
0283   trackerLength.push_back(tmpLength);
0284 
0285   // All TOB
0286   blockTrackerRadius.push_back(tmpRadius);
0287   blockTrackerLength.push_back(tmpLength);
0288 
0289   // TEC1
0290   tmpRadius = p.getUntrackedParameter<std::vector<double>>("TEC1CylinderRadius");
0291   tmpLength = p.getUntrackedParameter<std::vector<double>>("TEC1CylinderLength");
0292   trackerRadius.push_back(tmpRadius);
0293   trackerLength.push_back(tmpLength);
0294 
0295   // TEC2
0296   tmpRadius = p.getUntrackedParameter<std::vector<double>>("TEC2CylinderRadius");
0297   tmpLength = p.getUntrackedParameter<std::vector<double>>("TEC2CylinderLength");
0298   trackerRadius.push_back(tmpRadius);
0299   trackerLength.push_back(tmpLength);
0300 
0301   // TEC3
0302   tmpRadius = p.getUntrackedParameter<std::vector<double>>("TEC3CylinderRadius");
0303   tmpLength = p.getUntrackedParameter<std::vector<double>>("TEC3CylinderLength");
0304   trackerRadius.push_back(tmpRadius);
0305   trackerLength.push_back(tmpLength);
0306 
0307   // TEC4
0308   tmpRadius = p.getUntrackedParameter<std::vector<double>>("TEC4CylinderRadius");
0309   tmpLength = p.getUntrackedParameter<std::vector<double>>("TEC4CylinderLength");
0310   trackerRadius.push_back(tmpRadius);
0311   trackerLength.push_back(tmpLength);
0312 
0313   // TEC5
0314   tmpRadius = p.getUntrackedParameter<std::vector<double>>("TEC5CylinderRadius");
0315   tmpLength = p.getUntrackedParameter<std::vector<double>>("TEC5CylinderLength");
0316   trackerRadius.push_back(tmpRadius);
0317   trackerLength.push_back(tmpLength);
0318 
0319   // TEC6
0320   tmpRadius = p.getUntrackedParameter<std::vector<double>>("TEC6CylinderRadius");
0321   tmpLength = p.getUntrackedParameter<std::vector<double>>("TEC6CylinderLength");
0322   trackerRadius.push_back(tmpRadius);
0323   trackerLength.push_back(tmpLength);
0324 
0325   // TEC7
0326   tmpRadius = p.getUntrackedParameter<std::vector<double>>("TEC7CylinderRadius");
0327   tmpLength = p.getUntrackedParameter<std::vector<double>>("TEC7CylinderLength");
0328   trackerRadius.push_back(tmpRadius);
0329   trackerLength.push_back(tmpLength);
0330 
0331   // TEC8
0332   tmpRadius = p.getUntrackedParameter<std::vector<double>>("TEC8CylinderRadius");
0333   tmpLength = p.getUntrackedParameter<std::vector<double>>("TEC8CylinderLength");
0334   trackerRadius.push_back(tmpRadius);
0335   trackerLength.push_back(tmpLength);
0336 
0337   // TEC9
0338   tmpRadius = p.getUntrackedParameter<std::vector<double>>("TEC9CylinderRadius");
0339   tmpLength = p.getUntrackedParameter<std::vector<double>>("TEC9CylinderLength");
0340   trackerRadius.push_back(tmpRadius);
0341   trackerLength.push_back(tmpLength);
0342 
0343   // All TEC
0344   blockTrackerRadius.push_back(tmpRadius);
0345   blockTrackerLength.push_back(tmpLength);
0346 
0347   // All Outer
0348   subTrackerRadius.push_back(tmpRadius);
0349   subTrackerLength.push_back(tmpLength);
0350 
0351   // Outer Cables
0352   tmpRadius = p.getUntrackedParameter<std::vector<double>>("TrackerCablesCylinderRadius");
0353   tmpLength = p.getUntrackedParameter<std::vector<double>>("TrackerCablesCylinderLength");
0354   trackerRadius.push_back(tmpRadius);
0355   trackerLength.push_back(tmpLength);
0356 
0357   // All TEC
0358   blockTrackerRadius.push_back(tmpRadius);
0359   blockTrackerLength.push_back(tmpLength);
0360 
0361   // All
0362   subTrackerRadius.push_back(tmpRadius);
0363   subTrackerLength.push_back(tmpLength);
0364 
0365   // All Patrice : Finer granularity
0366   subTrackerRadius.push_back(tmpRadius);
0367   subTrackerLength.push_back(tmpLength);
0368 
0369   nevt = 0;
0370 }
0371 
0372 void testMaterialEffects::bookHistograms(DQMStore::IBooker& ibooker,
0373                                          edm::Run const& iRun,
0374                                          edm::EventSetup const& iSetup) {
0375   ibooker.setCurrentFolder("testMaterialEffects");
0376 
0377   h0[0] = ibooker.book2D("radioFull", "Full Tracker radiography", 1000, 0., 320., 1000, 0., 150.);
0378   h0[1] = ibooker.book2D("radioFast", "Fast Tracker radiography", 1000, 0., 320., 1000, 0., 150.);
0379   h1[0] = ibooker.book1D("etaEFull", "Full Electron eta distribution", 54, 0., 2.7);
0380   h1[1] = ibooker.book1D("etaEFast", "Fast Electron eta distribution", 54, 0., 2.7);
0381   h2[0] = ibooker.book1D("EgammaFull", "Full Brem energy distribution", 600, 0., 300.);
0382   h2[1] = ibooker.book1D("EgammaFast", "Fast Brem energy distribution", 600, 0., 300.);
0383   h3[0] = ibooker.book1D("FEgammaFull", "Full Brem energy fraction distribution", 1000, 0., 1.);
0384   h3[1] = ibooker.book1D("FEgammaFast", "Fast Brem energy fraction distribution", 1000, 0., 1.);
0385   h4[0] = ibooker.book1D("NgammaFull", "Full Brem number", 25, -0.5, 24.5);
0386   h4[1] = ibooker.book1D("NgammaFast", "Fast Brem number", 25, -0.5, 24.5);
0387   h5[0] = ibooker.book1D("NgammaMinFull", "Full Brem number > Emin", 25, -0.5, 24.5);
0388   h5[1] = ibooker.book1D("NgammaMinFast", "Fast Brem number > Emin", 25, -0.5, 24.5);
0389   h6[0] = ibooker.book2D("radioFullRem1", "Full Tracker radiography", 1000, 0., 320., 1000, 0., 150.);
0390   h6[1] = ibooker.book2D("radioFastRem1", "Fast Tracker radiography", 1000, 0., 320., 1000, 0., 150.);
0391   h7[0] = ibooker.book2D("radioFullRem2", "Full Tracker radiography", 1000, 0., 320., 1000, 0., 150.);
0392   h7[1] = ibooker.book2D("radioFastRem2", "Fast Tracker radiography", 1000, 0., 320., 1000, 0., 150.);
0393   h8[0] = ibooker.book2D("radioFullBP", "Full BP radiography", 1000, 0., 320., 1000, 0., 150.);
0394   h8[1] = ibooker.book2D("radioFastBP", "Fast BP radiography", 1000, 0., 320., 1000, 0., 150.);
0395   h9[0] = ibooker.book2D("radioFullPX", "Full PX radiography", 1000, 0., 320., 1000, 0., 150.);
0396   h9[1] = ibooker.book2D("radioFastPX", "Fast PX radiography", 1000, 0., 320., 1000, 0., 150.);
0397   h10[0] = ibooker.book2D("radioFullTI", "Full TI radiography", 1000, 0., 320., 1000, 0., 150.);
0398   h10[1] = ibooker.book2D("radioFastTI", "Fast TI radiography", 1000, 0., 320., 1000, 0., 150.);
0399   h11[0] = ibooker.book2D("radioFullTO", "Full TO radiography", 1000, 0., 320., 1000, 0., 150.);
0400   h11[1] = ibooker.book2D("radioFastTO", "Fast TO radiography", 1000, 0., 320., 1000, 0., 150.);
0401   h12[0] = ibooker.book2D("radioFullCA", "Full CA radiography", 1000, 0., 320., 1000, 0., 150.);
0402   h12[1] = ibooker.book2D("radioFastCA", "Fast CA radiography", 1000, 0., 320., 1000, 0., 150.);
0403   h13[0] = ibooker.book1D("TrackerFullR", "Full Tracker Radius", 300, 0., 150.);
0404   h13[1] = ibooker.book1D("TrackerFastR", "Fast Tracker Radius", 300, 0., 150.);
0405   h14[0] = ibooker.book1D("TrackerFullR2", "Full Tracker Radius 2", 800, 0., 40.);
0406   h14[1] = ibooker.book1D("TrackerFastR2", "Fast Tracker Radius 2", 800, 0., 40.);
0407   h15[0] = ibooker.book1D("HF1Full", "Full HF1 region", 550, 0., 5.5);
0408   h15[1] = ibooker.book1D("HF1Fast", "Fast HF1 region", 550, 0., 5.5);
0409   h16[0] = ibooker.book1D("HF2Full", "Full HF2 region", 550, 0., 5.5);
0410   h16[1] = ibooker.book1D("HF2Fast", "Fast HF2 region", 550, 0., 5.5);
0411   h17[0] = ibooker.book1D("HF3Full", "Full HF3 region", 550, 0., 5.5);
0412   h17[1] = ibooker.book1D("HF3Fast", "Fast HF3 region", 550, 0., 5.5);
0413 
0414   // Beam Pipe
0415   htmp[0] = ibooker.book1D("BeamPipeFull", "Full Beam Pipe", 220, 0., 5.5);
0416   htmp[1] = ibooker.book1D("BeamPipeFast", "Fast Beam Pipe", 220, 0., 5.5);
0417   h100.push_back(htmp);
0418 
0419   // Beam Pipe (cont'd)
0420   htmp[0] = ibooker.book1D("BPFullDummy", "Full Beam Pipe", 220, 0., 5.5);
0421   htmp[1] = ibooker.book1D("BPFastDummy", "Fast Beam Pipe", 220, 0., 5.5);
0422   h200.push_back(htmp);
0423 
0424   // Beam Pipe (cont'd)
0425   htmp[0] = ibooker.book1D("BPFull", "Full Beam Pipe", 220, 0., 5.5);
0426   htmp[1] = ibooker.book1D("BPFast", "Fast Beam Pipe", 220, 0., 5.5);
0427   h300.push_back(htmp);
0428 
0429   // PIXB1
0430   htmp[0] = ibooker.book1D("PXB1Full", "Full Pixel Barrel 1", 220, 0., 5.5);
0431   htmp[1] = ibooker.book1D("PXB1Fast", "Fast Pixel Barrel 1", 220, 0., 5.5);
0432   h100.push_back(htmp);
0433 
0434   // PIXB2
0435   htmp[0] = ibooker.book1D("PXB2Full", "Full Pixel Barrel 2", 220, 0., 5.5);
0436   htmp[1] = ibooker.book1D("PXB2Fast", "Fast Pixel Barrel 2", 220, 0., 5.5);
0437   h100.push_back(htmp);
0438 
0439   // PIXB3
0440   htmp[0] = ibooker.book1D("PXB3Full", "Full Pixel Barrel 3", 220, 0., 5.5);
0441   htmp[1] = ibooker.book1D("PXB3Fast", "Fast Pixel Barrel 3", 220, 0., 5.5);
0442   h100.push_back(htmp);
0443 
0444   // PIXB Cables
0445   htmp[0] = ibooker.book1D("PXBCFull", "Full Pixel Barrel Cables", 220, 0., 5.5);
0446   htmp[1] = ibooker.book1D("PXBCFast", "Fast Pixel Barrel Cables", 220, 0., 5.5);
0447   h100.push_back(htmp);
0448 
0449   // All Pixel Barrel
0450   htmp[0] = ibooker.book1D("PXBFull", "Full Pixel Barrel", 220, 0., 5.5);
0451   htmp[1] = ibooker.book1D("PXBFast", "Fast Pixel Barrel", 220, 0., 5.5);
0452   h200.push_back(htmp);
0453 
0454   // PIXD1
0455   htmp[0] = ibooker.book1D("PXD1Full", "Full Pixel Disk 1", 220, 0., 5.5);
0456   htmp[1] = ibooker.book1D("PXD1Fast", "Fast Pixel Disk 1", 220, 0., 5.5);
0457   h100.push_back(htmp);
0458 
0459   // PIXD2
0460   htmp[0] = ibooker.book1D("PXD2Full", "Full Pixel Disk 2", 220, 0., 5.5);
0461   htmp[1] = ibooker.book1D("PXD2Fast", "Fast Pixel Disk 2", 220, 0., 5.5);
0462   h100.push_back(htmp);
0463 
0464   // PIXD Cables
0465   htmp[0] = ibooker.book1D("PXDCFull", "Full Pixel Disk Cables", 220, 0., 5.5);
0466   htmp[1] = ibooker.book1D("PXDCFast", "Fast Pixel Disk Cables", 220, 0., 5.5);
0467   h100.push_back(htmp);
0468 
0469   // All Pixel Disks
0470   htmp[0] = ibooker.book1D("PXDFull", "Full Pixel Disk", 220, 0., 5.5);
0471   htmp[1] = ibooker.book1D("PXDFast", "Fast Pixel Disk", 220, 0., 5.5);
0472   h200.push_back(htmp);
0473 
0474   // All Pixel
0475   htmp[0] = ibooker.book1D("PixelFull", "Full Pixel", 220, 0., 5.5);
0476   htmp[1] = ibooker.book1D("PixelFast", "Fast Pixel", 220, 0., 5.5);
0477   h300.push_back(htmp);
0478 
0479   // TIB1
0480   htmp[0] = ibooker.book1D("TIB1Full", "Full Tracker Inner Barrel 1", 220, 0., 5.5);
0481   htmp[1] = ibooker.book1D("TIB1Fast", "Fast Tracker Inner Barrel 1", 220, 0., 5.5);
0482   h100.push_back(htmp);
0483 
0484   // TIB2
0485   htmp[0] = ibooker.book1D("TIB2Full", "Full Tracker Inner Barrel 2", 220, 0., 5.5);
0486   htmp[1] = ibooker.book1D("TIB2Fast", "Fast Tracker Inner Barrel 2", 220, 0., 5.5);
0487   h100.push_back(htmp);
0488 
0489   // TIB3
0490   htmp[0] = ibooker.book1D("TIB3Full", "Full Tracker Inner Barrel 3", 220, 0., 5.5);
0491   htmp[1] = ibooker.book1D("TIB3Fast", "Fast Tracker Inner Barrel 3", 220, 0., 5.5);
0492   h100.push_back(htmp);
0493 
0494   // TIB4
0495   htmp[0] = ibooker.book1D("TIB4Full", "Full Tracker Inner Barrel 4", 220, 0., 5.5);
0496   htmp[1] = ibooker.book1D("TIB4Fast", "Fast Tracker Inner Barrel 4", 220, 0., 5.5);
0497   h100.push_back(htmp);
0498 
0499   // TIB Cables
0500   htmp[0] = ibooker.book1D("TIBCFull", "Full Tracker Inner Barrel Cables", 220, 0., 5.5);
0501   htmp[1] = ibooker.book1D("TIBCFast", "Fast Tracker Inner Barrel Cables", 220, 0., 5.5);
0502   h100.push_back(htmp);
0503 
0504   // All TIB
0505   htmp[0] = ibooker.book1D("TIBFull", "Full Tracker Inner Barrel", 220, 0., 5.5);
0506   htmp[1] = ibooker.book1D("TIBFast", "Fast Tracker Inner Barrel", 220, 0., 5.5);
0507   h200.push_back(htmp);
0508 
0509   // TID1
0510   htmp[0] = ibooker.book1D("TID1Full", "Full Tracker Inner Disk 1", 220, 0., 5.5);
0511   htmp[1] = ibooker.book1D("TID1Fast", "Fast Tracker Inner Disk 1", 220, 0., 5.5);
0512   h100.push_back(htmp);
0513 
0514   // TID2
0515   htmp[0] = ibooker.book1D("TID2Full", "Full Tracker Inner Disk 2", 220, 0., 5.5);
0516   htmp[1] = ibooker.book1D("TID2Fast", "Fast Tracker Inner Disk 2", 220, 0., 5.5);
0517   h100.push_back(htmp);
0518 
0519   // TID3
0520   htmp[0] = ibooker.book1D("TID3Full", "Full Tracker Inner Disk 3", 220, 0., 5.5);
0521   htmp[1] = ibooker.book1D("TID3Fast", "Fast Tracker Inner Disk 3", 220, 0., 5.5);
0522   h100.push_back(htmp);
0523 
0524   // TID Cables
0525   htmp[0] = ibooker.book1D("TIDCFull", "Full Tracker Inner Disk Cables", 220, 0., 5.5);
0526   htmp[1] = ibooker.book1D("TIDCFast", "Fast Tracker Inner Disk Cables", 220, 0., 5.5);
0527   h100.push_back(htmp);
0528 
0529   // All TID
0530   htmp[0] = ibooker.book1D("TIDFull", "Full Tracker Inner Disk", 220, 0., 5.5);
0531   htmp[1] = ibooker.book1D("TIDFast", "Fast Tracker Inner Disk", 220, 0., 5.5);
0532   h200.push_back(htmp);
0533 
0534   // All Inner Tracker
0535   htmp[0] = ibooker.book1D("InnerFull", "Full Inner Tracker", 220, 0., 5.5);
0536   htmp[1] = ibooker.book1D("InnerFast", "Fast Inner Tracker", 220, 0., 5.5);
0537   h300.push_back(htmp);
0538 
0539   // TOB1
0540   htmp[0] = ibooker.book1D("TOB1Full", "Full Tracker Outer Barrel 1", 220, 0., 5.5);
0541   htmp[1] = ibooker.book1D("TOB1Fast", "Fast Tracker Outer Barrel 1", 220, 0., 5.5);
0542   h100.push_back(htmp);
0543 
0544   // TOB2
0545   htmp[0] = ibooker.book1D("TOB2Full", "Full Tracker Outer Barrel 2", 220, 0., 5.5);
0546   htmp[1] = ibooker.book1D("TOB2Fast", "Fast Tracker Outer Barrel 2", 220, 0., 5.5);
0547   h100.push_back(htmp);
0548 
0549   // TOB3
0550   htmp[0] = ibooker.book1D("TOB3Full", "Full Tracker Outer Barrel 3", 220, 0., 5.5);
0551   htmp[1] = ibooker.book1D("TOB3Fast", "Fast Tracker Outer Barrel 3", 220, 0., 5.5);
0552   h100.push_back(htmp);
0553 
0554   // TOB4
0555   htmp[0] = ibooker.book1D("TOB4Full", "Full Tracker Outer Barrel 4", 220, 0., 5.5);
0556   htmp[1] = ibooker.book1D("TOB4Fast", "Fast Tracker Outer Barrel 4", 220, 0., 5.5);
0557   h100.push_back(htmp);
0558 
0559   // TOB5
0560   htmp[0] = ibooker.book1D("TOB5Full", "Full Tracker Outer Barrel 5", 220, 0., 5.5);
0561   htmp[1] = ibooker.book1D("TOB5Fast", "Fast Tracker Outer Barrel 5", 220, 0., 5.5);
0562   h100.push_back(htmp);
0563 
0564   // TOB6
0565   htmp[0] = ibooker.book1D("TOB6Full", "Full Tracker Outer Barrel 6", 220, 0., 5.5);
0566   htmp[1] = ibooker.book1D("TOB6Fast", "Fast Tracker Outer Barrel 6", 220, 0., 5.5);
0567   h100.push_back(htmp);
0568 
0569   // TOB Cables
0570   htmp[0] = ibooker.book1D("TOBCFull", "Full Tracker Outer Barrel Cables", 220, 0., 5.5);
0571   htmp[1] = ibooker.book1D("TOBCFast", "Fast Tracker Outer Barrel Cables", 220, 0., 5.5);
0572   h100.push_back(htmp);
0573 
0574   // All TOB
0575   htmp[0] = ibooker.book1D("TOBFull", "Full Tracker Outer Barrel", 220, 0., 5.5);
0576   htmp[1] = ibooker.book1D("TOBFast", "Fast Tracker Outer Barrel", 220, 0., 5.5);
0577   h200.push_back(htmp);
0578 
0579   // TEC1
0580   htmp[0] = ibooker.book1D("TEC1Full", "Full Tracker EndCap 1", 220, 0., 5.5);
0581   htmp[1] = ibooker.book1D("TEC1Fast", "Fast Tracker Endcap 1", 220, 0., 5.5);
0582   h100.push_back(htmp);
0583 
0584   // TEC2
0585   htmp[0] = ibooker.book1D("TEC2Full", "Full Tracker EndCap 2", 220, 0., 5.5);
0586   htmp[1] = ibooker.book1D("TEC2Fast", "Fast Tracker Endcap 2", 220, 0., 5.5);
0587   h100.push_back(htmp);
0588 
0589   // TEC3
0590   htmp[0] = ibooker.book1D("TEC3Full", "Full Tracker EndCap 3", 220, 0., 5.5);
0591   htmp[1] = ibooker.book1D("TEC3Fast", "Fast Tracker Endcap 3", 220, 0., 5.5);
0592   h100.push_back(htmp);
0593 
0594   // TEC4
0595   htmp[0] = ibooker.book1D("TEC4Full", "Full Tracker EndCap 4", 220, 0., 5.5);
0596   htmp[1] = ibooker.book1D("TEC4Fast", "Fast Tracker Endcap 4", 220, 0., 5.5);
0597   h100.push_back(htmp);
0598 
0599   // TEC5
0600   htmp[0] = ibooker.book1D("TEC5Full", "Full Tracker EndCap 5", 220, 0., 5.5);
0601   htmp[1] = ibooker.book1D("TEC5Fast", "Fast Tracker Endcap 5", 220, 0., 5.5);
0602   h100.push_back(htmp);
0603 
0604   // TEC6
0605   htmp[0] = ibooker.book1D("TEC6Full", "Full Tracker EndCap 6", 220, 0., 5.5);
0606   htmp[1] = ibooker.book1D("TEC6Fast", "Fast Tracker Endcap 6", 220, 0., 5.5);
0607   h100.push_back(htmp);
0608 
0609   // TEC7
0610   htmp[0] = ibooker.book1D("TEC7Full", "Full Tracker EndCap 7", 220, 0., 5.5);
0611   htmp[1] = ibooker.book1D("TEC7Fast", "Fast Tracker Endcap 7", 220, 0., 5.5);
0612   h100.push_back(htmp);
0613 
0614   // TEC8
0615   htmp[0] = ibooker.book1D("TEC8Full", "Full Tracker EndCap 8", 220, 0., 5.5);
0616   htmp[1] = ibooker.book1D("TEC8Fast", "Fast Tracker Endcap 8", 220, 0., 5.5);
0617   h100.push_back(htmp);
0618 
0619   // TEC9
0620   htmp[0] = ibooker.book1D("TEC9Full", "Full Tracker EndCap 9", 220, 0., 5.5);
0621   htmp[1] = ibooker.book1D("TEC9Fast", "Fast Tracker Endcap 9", 220, 0., 5.5);
0622   h100.push_back(htmp);
0623 
0624   // All TEC
0625   htmp[0] = ibooker.book1D("TECFull", "Full Tracker EndCap", 220, 0., 5.5);
0626   htmp[1] = ibooker.book1D("TECFast", "Fast Tracker EndCap", 220, 0., 5.5);
0627   h200.push_back(htmp);
0628 
0629   // All Outer
0630   htmp[0] = ibooker.book1D("OuterFull", "Full Outer Tracker", 220, 0., 5.5);
0631   htmp[1] = ibooker.book1D("OuterFast", "Fast Outer Tracker", 220, 0., 5.5);
0632   h300.push_back(htmp);
0633 
0634   // Outer Cables
0635   htmp[0] = ibooker.book1D("TECCFull", "Full Tracker Outer Cables", 220, 0., 5.5);
0636   htmp[1] = ibooker.book1D("TECCFast", "Fast Tracker Outer Cables", 220, 0., 5.5);
0637   h100.push_back(htmp);
0638 
0639   // All TEC
0640   htmp[0] = ibooker.book1D("CablesFull", "Full Tracker Cables", 220, 0., 5.5);
0641   htmp[1] = ibooker.book1D("CablesFast", "Fast Tracker Cables", 220, 0., 5.5);
0642   h200.push_back(htmp);
0643 
0644   // All
0645   htmp[0] = ibooker.book1D("TrackerFull", "Full Tracker", 220, 0., 5.5);
0646   htmp[1] = ibooker.book1D("TrackerFast", "Fast Tracker", 220, 0., 5.5);
0647   h300.push_back(htmp);
0648 
0649   // All Patrice : Finer granularity
0650   htmp[0] = ibooker.book1D("TrackerFull2", "Full Tracker 2", 550, 0., 5.5);
0651   htmp[1] = ibooker.book1D("TrackerFast2", "Fast Tracker 2", 550, 0., 5.5);
0652   h300.push_back(htmp);
0653 }
0654 
0655 void testMaterialEffects::dqmBeginRun(edm::Run const&, edm::EventSetup const& es) {
0656   // init Particle data table (from Pythia)
0657   const edm::ESHandle<HepPDT::ParticleDataTable> pdt = es.getHandle(tok_pdt_);
0658   mySimEvent[0]->initializePdt(&(*pdt));
0659   mySimEvent[1]->initializePdt(&(*pdt));
0660 }
0661 
0662 void testMaterialEffects::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
0663   if ((nevt < 100 && nevt % 10 == 0) || (nevt < 1000 && nevt % 100 == 0) || nevt % 1000 == 0)
0664     std::cout << "process entry " << nevt << std::endl;
0665   nevt++;
0666 
0667   //std::cout << "Fill full event " << std::endl;
0668   const edm::Handle<std::vector<SimTrack>>& fullSimTracks = iEvent.getHandle(tok_fullSimTk_);
0669   const edm::Handle<std::vector<SimVertex>>& fullSimVertices = iEvent.getHandle(tok_fullSimVx_);
0670   mySimEvent[0]->fill(*fullSimTracks, *fullSimVertices);
0671 
0672   //std::cout << "Fill fast event " << std::endl;
0673   const edm::Handle<std::vector<SimTrack>>& fastSimTracks = iEvent.getHandle(tok_fastSimTk_);
0674   const edm::Handle<std::vector<SimVertex>>& fastSimVertices = iEvent.getHandle(tok_fastSimVx_);
0675   mySimEvent[1]->fill(*fastSimTracks, *fastSimVertices);
0676 
0677   for (unsigned ievt = 0; ievt < 2; ++ievt) {
0678     //    std::cout << "Event number " << ievt << std::endl;
0679     //    mySimEvent[ievt]->print();
0680 
0681     int nvertices = mySimEvent[ievt]->nVertices();
0682     for (int i = 0; i < nvertices; ++i) {
0683       FSimVertex& vertex = mySimEvent[ievt]->vertex(i);
0684       h0[ievt]->Fill(fabs(vertex.position().z()), vertex.position().pt());
0685     }
0686 
0687     // Loop over all tracks
0688     int ntracks = mySimEvent[ievt]->nTracks();
0689 
0690     for (int i = 0; i < ntracks; ++i) {
0691       FSimTrack& myTrack = mySimEvent[ievt]->track(i);
0692       std::vector<int> myGammas;
0693 
0694       // Select the original electrons
0695       if (abs(myTrack.type()) == 11 && myTrack.vertex().noParent()) {
0696         int firstDaughter = -1;
0697         int lastDaughter = -1;
0698         unsigned nbrems = 0;
0699         unsigned nbremsmin = 0;
0700         double feta = fabs(myTrack.momentum().eta());
0701         // Plot electron pseudo-rapidity
0702         h1[ievt]->Fill(feta);
0703 
0704         if (myTrack.nDaughters()) {
0705           firstDaughter = myTrack.daughters()[0];
0706           lastDaughter = myTrack.daughters()[myTrack.nDaughters() - 1];
0707         }
0708 
0709         XYZTLorentzVector theElectron = myTrack.momentum();
0710         //  std::cout << " The starting electron " << theElectron << " "
0711         //        << myTrack.vertex().position() << " "
0712         //        << myTrack.endVertex().position() << " "
0713         //        << myTrack.nDaughters() << " "
0714         //        << firstDaughter << " "
0715         //        << lastDaughter << " "
0716         //        << std::endl;
0717 
0718         // Fill the photons.
0719         if (!(firstDaughter < 0 || lastDaughter < 0)) {
0720           for (int igamma = firstDaughter; igamma <= lastDaughter; ++igamma) {
0721             FSimTrack myGamma = mySimEvent[ievt]->track(igamma);
0722             if (myGamma.type() != 22)
0723               continue;
0724             XYZTLorentzVector theFather = theElectron;
0725             theElectron = theElectron - myGamma.momentum();
0726             nbrems++;
0727             if (myGamma.momentum().e() < 0.5 ||
0728                 //         myGamma.momentum().e() > 10. ||
0729                 myGamma.momentum().e() / theElectron.e() < 0.005)
0730               continue;
0731             nbremsmin++;
0732             myGammas.push_back(igamma);
0733 
0734             h2[ievt]->Fill(myGamma.momentum().e());
0735             h3[ievt]->Fill(myGamma.momentum().e() / theFather.e());
0736           }
0737           h4[ievt]->Fill(nbrems);
0738           h5[ievt]->Fill(nbremsmin);
0739         }
0740       } else {
0741         continue;
0742       }
0743 
0744       // Loop over all stored brems
0745       for (unsigned ig = 0; ig < myGammas.size(); ++ig) {
0746         FSimTrack theGamma = mySimEvent[ievt]->track(myGammas[ig]);
0747         float radius = theGamma.vertex().position().pt();
0748         float zed = fabs(theGamma.vertex().position().z());
0749         float eta = fabs(theGamma.vertex().position().eta());
0750 
0751         // Fill the individual layer histograms !
0752         bool filled = false;
0753         for (unsigned hist = 0; hist < h100.size() && !filled; ++hist) {
0754           if (eta < 5. && (radius < trackerRadius[hist][ievt] && zed < trackerLength[hist][ievt])) {
0755             h100[hist][ievt]->Fill(eta);
0756             filled = true;
0757           }
0758         }
0759         if (!filled)
0760           h6[ievt]->Fill(zed, radius);
0761 
0762         // Fill the block histograms !
0763         filled = false;
0764         for (unsigned hist = 0; hist < h200.size() && !filled; ++hist) {
0765           if (eta < 5. && (radius < blockTrackerRadius[hist][ievt] && zed < blockTrackerLength[hist][ievt])) {
0766             h200[hist][ievt]->Fill(eta);
0767             filled = true;
0768           }
0769         }
0770         if (!filled)
0771           h7[ievt]->Fill(zed, radius);
0772 
0773         // Patrice
0774         if (eta > 3.) {
0775           h13[ievt]->Fill(radius);
0776           h14[ievt]->Fill(radius);
0777           if (eta < 3.61)
0778             h15[ievt]->Fill(eta);
0779           if (eta >= 3.61 && eta < 4.835)
0780             h16[ievt]->Fill(eta);
0781           if (eta >= 4.835 && eta < 4.915)
0782             h17[ievt]->Fill(eta);
0783         }
0784 
0785         // Fill the cumulative histograms !
0786         for (unsigned hist = 0; hist < h300.size(); ++hist) {
0787           if ((radius < subTrackerRadius[hist][ievt] && zed < subTrackerLength[hist][ievt]) ||
0788               (hist == 2 && radius < subTrackerRadius[1][ievt] && zed < subTrackerLength[1][ievt])) {
0789             if ((hist <= 3 && eta < 5.) || hist >= 4)
0790               h300[hist][ievt]->Fill(eta);
0791             if (hist == 0)
0792               h8[ievt]->Fill(zed, radius);
0793             if (hist == 1)
0794               h9[ievt]->Fill(zed, radius);
0795             if (hist == 2)
0796               h10[ievt]->Fill(zed, radius);
0797             if (hist == 3)
0798               h11[ievt]->Fill(zed, radius);
0799             if (hist == 4)
0800               h12[ievt]->Fill(zed, radius);
0801           }
0802         }
0803       }
0804     }
0805   }
0806 }
0807 
0808 //define this as a plug-in
0809 
0810 DEFINE_FWK_MODULE(testMaterialEffects);