File indexing completed on 2024-04-06 12:11:13
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #include <iomanip>
0017 #include <memory>
0018
0019
0020 #include "FWCore/Framework/interface/stream/EDAnalyzer.h"
0021
0022 #include "FWCore/Framework/interface/EventSetup.h"
0023 #include "FWCore/Framework/interface/ESHandle.h"
0024 #include "FWCore/Framework/interface/Event.h"
0025 #include "FWCore/Framework/interface/MakerMacros.h"
0026
0027 #include "Geometry/Records/interface/CaloGeometryRecord.h"
0028 #include "Geometry/Records/interface/CaloTopologyRecord.h"
0029 #include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h"
0030 #include "Geometry/CaloGeometry/interface/CaloGeometry.h"
0031
0032 #include "DataFormats/EcalDetId/interface/EBDetId.h"
0033 #include "DataFormats/Math/interface/Vector3D.h"
0034 #include "DataFormats/Math/interface/LorentzVector.h"
0035
0036 #include "FastSimulation/ShowerDevelopment/interface/EMECALShowerParametrization.h"
0037 #include "FastSimulation/ShowerDevelopment/interface/EMShower.h"
0038 #include "FastSimulation/CaloGeometryTools/interface/CaloGeometryHelper.h"
0039 #include "FastSimulation/CaloHitMakers/interface/EcalHitMaker.h"
0040 #include "FastSimulation/CaloHitMakers/interface/HcalHitMaker.h"
0041 #include "CommonTools/BaseParticlePropagator/interface/RawParticle.h"
0042 #include "FastSimulation/Event/interface/FSimTrack.h"
0043 #include "FastSimulation/Event/interface/FSimEvent.h"
0044 #include "FastSimulation/Utilities/interface/RandomEngineAndDistribution.h"
0045 #include "FastSimulation/Utilities/interface/GammaFunctionGenerator.h"
0046
0047 #include "SimGeneral/HepPDTRecord/interface/ParticleDataTable.h"
0048
0049
0050
0051
0052
0053 typedef math::XYZVector XYZVector;
0054 typedef math::XYZVector XYZPoint;
0055
0056 class testEcalHitMaker : public edm::stream::EDAnalyzer<> {
0057 public:
0058 explicit testEcalHitMaker(const edm::ParameterSet&);
0059 ~testEcalHitMaker();
0060 virtual void beginRun(edm::Run const&, edm::EventSetup const&);
0061
0062 virtual void analyze(const edm::Event&, const edm::EventSetup&);
0063
0064 private:
0065
0066 void testBorderCrossing();
0067 int pass_;
0068
0069 const edm::ESGetToken<CaloTopology, CaloTopologyRecord> tokCaloTopo_;
0070 const edm::ESGetToken<CaloGeometry, CaloGeometryRecord> tokCaloGeom_;
0071 const edm::ESGetToken<HepPDT::ParticleDataTable, PDTRecord> tokPdt_;
0072
0073 CaloGeometryHelper* myGeometry;
0074 GammaFunctionGenerator* aGammaGenerator;
0075 FSimEvent* mySimEvent;
0076 };
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086
0087
0088
0089 testEcalHitMaker::testEcalHitMaker(const edm::ParameterSet& iConfig)
0090 : tokCaloTopo_(esConsumes<edm::Transition::BeginRun>()),
0091 tokCaloGeom_(esConsumes<edm::Transition::BeginRun>()),
0092 tokPdt_(esConsumes<edm::Transition::BeginRun>()) {
0093 aGammaGenerator = new GammaFunctionGenerator();
0094
0095 mySimEvent = new FSimEvent(iConfig.getParameter<edm::ParameterSet>("TestParticleFilter"));
0096
0097 myGeometry = new CaloGeometryHelper(iConfig.getParameter<edm::ParameterSet>("Calorimetry"));
0098 }
0099
0100 void testEcalHitMaker::beginRun(edm::Run const& run, edm::EventSetup const& iSetup) {
0101 const edm::ESHandle<CaloTopology>& theCaloTopology = iSetup.getHandle(tokCaloTopo_);
0102 const edm::ESHandle<CaloGeometry>& pG = iSetup.getHandle(tokCaloGeom_);
0103
0104
0105 double bField000 = 4.;
0106 myGeometry->setupGeometry(*(pG.product()));
0107 myGeometry->setupTopology(*(theCaloTopology.product()));
0108 myGeometry->initialize(bField000);
0109
0110
0111 const edm::ESHandle<HepPDT::ParticleDataTable>& pdt = iSetup.getHandle(tokPdt_);
0112 mySimEvent->initializePdt(pdt.product());
0113 std::cout << " done with beginRun " << std::endl;
0114 }
0115
0116 testEcalHitMaker::~testEcalHitMaker() {
0117
0118
0119 }
0120
0121
0122 void testEcalHitMaker::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
0123 using namespace edm;
0124
0125 RandomEngineAndDistribution random(iEvent.streamID());
0126
0127 math::XYZTLorentzVectorD theMomentum(10., 0., 5., sqrt(125));
0128
0129
0130
0131 math::XYZVectorD thePositionatEcalEntrance(129., 0., 60);
0132
0133 std::vector<SimTrack> mySimTracks;
0134 SimTrack myTrack(11, theMomentum, 0, -1, thePositionatEcalEntrance, theMomentum);
0135 mySimTracks.push_back(myTrack);
0136 std::vector<SimVertex> mySimVertices;
0137 mySimVertices.push_back(SimVertex(thePositionatEcalEntrance, 0.));
0138
0139 mySimEvent->fill(mySimTracks, mySimVertices);
0140
0141
0142
0143
0144
0145
0146
0147
0148
0149
0150
0151
0152
0153
0154 FSimTrack& mySimTrack(mySimEvent->track(0));
0155 std::cout << mySimTrack << std::endl;
0156 std::cout << " done " << std::endl;
0157 RawParticle myPart = mySimTrack.ecalEntrance();
0158 std::vector<const RawParticle*> thePart;
0159 thePart.push_back(&myPart);
0160
0161 XYZPoint ecalentrance = myPart.vertex().Vect();
0162
0163 std::cout << " on ECAL/HCAL etc " << mySimTrack.onEcal() << " ";
0164 std::cout << mySimTrack.onHcal() << " ";
0165 std::cout << mySimTrack.onLayer1() << " ";
0166 std::cout << mySimTrack.onLayer2() << " " << std::endl;
0167
0168
0169 std::vector<double> coreParams;
0170 coreParams.push_back(100);
0171 coreParams.push_back(0.1);
0172 std::vector<double> tailParams;
0173 tailParams.push_back(1);
0174 tailParams.push_back(0.1);
0175 tailParams.push_back(100);
0176 tailParams.push_back(1);
0177
0178
0179 EMECALShowerParametrization showerparam(myGeometry->ecalProperties(mySimTrack.onEcal()),
0180 myGeometry->hcalProperties(mySimTrack.onHcal()),
0181 myGeometry->layer1Properties(mySimTrack.onLayer1()),
0182 myGeometry->layer2Properties(mySimTrack.onLayer2()),
0183 coreParams,
0184 tailParams);
0185
0186
0187 EMShower theShower(&random, aGammaGenerator, &showerparam, &thePart);
0188
0189
0190 DetId pivot(myGeometry->getClosestCell(ecalentrance, true, mySimTrack.onEcal() == 1));
0191
0192
0193 EcalHitMaker myGrid(myGeometry, ecalentrance, pivot, mySimTrack.onEcal(), 7, 0, &random);
0194 myGrid.setCrackPadSurvivalProbability(0.9);
0195 myGrid.setRadiusFactor(1.096);
0196
0197
0198 myGrid.setTrackParameters(myPart.Vect().Unit(), 0., mySimTrack);
0199
0200 HcalHitMaker myHcalHitMaker(myGrid, (unsigned)0);
0201
0202 theShower.setGrid(&myGrid);
0203 theShower.setHcal(&myHcalHitMaker);
0204 theShower.compute();
0205
0206
0207 std::map<CaloHitID, float>::const_iterator mapitr;
0208 std::map<CaloHitID, float>::const_iterator endmapitr = myGrid.getHits().end();
0209 for (mapitr = myGrid.getHits().begin(); mapitr != endmapitr; ++mapitr) {
0210 if (mapitr->second != 0)
0211 std::cout << "DetId " << EBDetId(mapitr->first.unitID()) << " " << std::setw(8) << std::setprecision(4)
0212 << mapitr->second << std::endl;
0213 }
0214 }
0215
0216
0217
0218
0219 DEFINE_FWK_MODULE(testEcalHitMaker);