From 83aeb0d99708462ee30e7744af7056c70a8a3715 Mon Sep 17 00:00:00 2001 From: sophieMu2e Date: Wed, 2 Feb 2022 08:47:53 -0600 Subject: [PATCH 01/33] added calibration geometry, modifying gun --- CommonMC/fcl/prolog.fcl | 1 - EventGenerator/inc/CaloCalibGun.hh | 31 ++- EventGenerator/src/CaloCalibGun.cc | 273 ++++++++++++------- EventGenerator/src/NewCaloCalibGun_module.cc | 136 +++++++++ GeometryService/src/DiskCalorimeterMaker.cc | 36 ++- MCDataProducts/inc/ProcessCode.hh | 4 +- Mu2eG4/geom/calorimeter_CsI.txt | 6 +- Mu2eG4/src/constructDiskCalorimeter.cc | 144 +++++++--- Mu2eG4/test/genconfig_calocalib.txt | 10 +- 9 files changed, 470 insertions(+), 171 deletions(-) create mode 100644 EventGenerator/src/NewCaloCalibGun_module.cc diff --git a/CommonMC/fcl/prolog.fcl b/CommonMC/fcl/prolog.fcl index 8e8043d5a4..56a470db78 100644 --- a/CommonMC/fcl/prolog.fcl +++ b/CommonMC/fcl/prolog.fcl @@ -18,7 +18,6 @@ CommonMC: { FindMCPrimary : { module_type : FindMCPrimary debugLevel : 0 - GenParticles : "compressDigiMCs" SimParticles : "compressDigiMCs" PrimaryGenIds : ["CeEndpoint", "CeLeadingLog", "dioTail", "cosmicDYB", "CosmicCRY", "CosmicCORSIKA", diff --git a/EventGenerator/inc/CaloCalibGun.hh b/EventGenerator/inc/CaloCalibGun.hh index 96373e540b..b3c68d5da0 100644 --- a/EventGenerator/inc/CaloCalibGun.hh +++ b/EventGenerator/inc/CaloCalibGun.hh @@ -3,6 +3,9 @@ // // Generate some number of DIO electrons. // +// $Id: CaloCalibGun.hh,v 1.34 2013/07/22 18:57:42 knoepfel Exp $ +// $Author: knoepfel $ +// $Date: 2013/07/22 18:57:42 $ // // // ==================================================================== @@ -20,18 +23,19 @@ #include "art/Framework/Principal/Run.h" // Mu2e includes -#include "Offline/EventGenerator/inc/GeneratorBase.hh" -#include "Offline/CalorimeterGeom/inc/DiskCalorimeter.hh" -#include "Offline/Mu2eUtilities/inc/RandomUnitSphere.hh" +#include "EventGenerator/inc/GeneratorBase.hh" +#include "CalorimeterGeom/inc/DiskCalorimeter.hh" +#include "Mu2eUtilities/inc/RandomUnitSphere.hh" // CLHEP includes #include "CLHEP/Random/RandPoissonQ.h" #include "CLHEP/Random/RandGeneral.h" #include "CLHEP/Random/RandFlat.h" -class TH1D; -class TH2D; +// ROOT includes +#include "TTree.h" +class TTree; namespace art { class Run; @@ -76,14 +80,15 @@ namespace mu2e { bool _doHistograms; - TH1D* _hE; - TH1D* _hT; - TH1D* _hcos; - TH1D* _hphi; - TH1D* _hrad; - TH1D* _hz; - TH2D* _hxy; - + TTree* _Ntupe; + float _genErg; + float _genTime; + float _genCos; + //float _genPhi; + //float _genRad; + float _genPosX; + float _genPosY; + float _genPosZ; }; diff --git a/EventGenerator/src/CaloCalibGun.cc b/EventGenerator/src/CaloCalibGun.cc index 58fb6797c8..b8a9da9e6e 100644 --- a/EventGenerator/src/CaloCalibGun.cc +++ b/EventGenerator/src/CaloCalibGun.cc @@ -1,11 +1,12 @@ // -// // Simulate the photons coming from the pipe calibration source // // +// $Id: CaloCalibGun.cc,v 1.16 2014/01/27 22:20:17 knoepfel Exp $ +// $Author: knoepfel $ +// $Date: 2014/01/27 22:20:17 $ // // Original author Bertrand Echenard -// -// +// Edited by: De Xu Lin, Sophie Middleton // C++ includes. #include @@ -35,33 +36,28 @@ #include "CLHEP/Units/PhysicalConstants.h" //ROOT Includes -#include "TH1D.h" -#include "TH2D.h" #include "TMath.h" - using namespace std; +using namespace TMath; +const double piconst = Pi(); -namespace mu2e { - +namespace mu2e +{ CaloCalibGun::CaloCalibGun(CLHEP::HepRandomEngine& engine, art::Run& run, const SimpleConfig& config): - - // Configurable parameters - _mean(config.getDouble("caloCalibGun.mean",1.)), - _energy(config.getDouble("caloCalibGun.energy",6.13)), - _cosmin(config.getDouble("caloCalibGun.cosmin", -1.)), - _cosmax(config.getDouble("caloCalibGun.cosmax", 1.)), - _phimin(config.getDouble("caloCalibGun.phimin", 0. )), - _phimax(config.getDouble("caloCalibGun.phimax", CLHEP::twopi )), - _randFlat{engine}, - _randPoissonQ{engine, std::abs(_mean)}, - _randomUnitSphere{engine, _cosmin, _cosmax, 0, CLHEP::twopi}, - _detSys(), - _doHistograms(config.getBool("caloCalibGun.doHistograms",true)), - - // Histogram pointers - _hE(0),_hT(0),_hcos(0),_hphi(0),_hrad(0),_hz(0),_hxy(0) - { - + // Configurable parameters + _mean(config.getDouble("caloCalibGun.mean",1.)), + _energy(config.getDouble("caloCalibGun.energy",6.13)), + _cosmin(config.getDouble("caloCalibGun.cosmin", -1.)), + _cosmax(config.getDouble("caloCalibGun.cosmax", 1.)), + _phimin(config.getDouble("caloCalibGun.phimin", 0. )), + _phimax(config.getDouble("caloCalibGun.phimax", CLHEP::twopi )), + _randFlat{engine}, + _randPoissonQ{engine, std::abs(_mean)}, + _randomUnitSphere{engine, _cosmin, _cosmax, 0, CLHEP::twopi}, + _detSys(), + _doHistograms(config.getBool("caloCalibGun.doHistograms",true)), + _Ntupe(0) + { // About the ConditionsService: // The argument to the constructor is ignored for now. It will be a // data base key. There is a second argument that I have let take its @@ -69,7 +65,6 @@ namespace mu2e { ConditionsHandle accPar("ignored"); GlobalConstantsHandle pdt; - // Default values for the start and end of the live window. _tmin = 0.; _tmax = accPar->deBuncherPeriod; @@ -82,97 +77,171 @@ namespace mu2e { _pipeRadius = _cal->caloInfo().getDouble("pipeRadius"); _pipeTorRadius = _cal->caloInfo().getVDouble("pipeTorRadius"); _randomRad = _cal->caloInfo().getVDouble("pipeTorRadius"); - _zPipeCenter = _cal->disk(0).geomInfo().origin()-CLHEP::Hep3Vector(0,0,_cal->disk(0).geomInfo().size().z()/2.0-_pipeRadius); - - - - + //_zPipeCenter = _cal->disk(0).geomInfo().origin()-CLHEP::Hep3Vector(0,0,_cal->disk(0).geomInfo().size().z()/2.0-_pipeRadius); // we normalize to the volume of the pipe (proportional to 2*pi*R if they have all the same radius) to draw a // random number from which to generate the photons double sumR(0); std::for_each(_randomRad.begin(), _randomRad.end(), [&](double& d) {sumR+=d; d = sumR; }); std::for_each(_randomRad.begin(), _randomRad.end(), [&](double& d) {d /= sumR;}); - // Book histograms. if ( _doHistograms ) { - art::ServiceHandle tfs; - art::TFileDirectory tfdir = tfs->mkdir( "CaloPhotonCalibGun" ); - _hE = tfdir.make( "hE", "Photon Energy" , 100, 0, 20); - _hT = tfdir.make( "hT", "Photon Time" , 100, 0, 2000); - _hcos = tfdir.make( "hcos", "Photon cos theta", 100, -1, 1); - _hphi = tfdir.make( "hphi", "Photon phi" , 100, 0, 6.3); - _hrad = tfdir.make( "hrad", "Pos radius" , 100, 0, 700); - _hz = tfdir.make( "hz", "Pos z " , 100, 10000, 14000); - _hxy = tfdir.make( "hxy", "Pos xy" , 100, -700, 700, 100, -700 ,700); + art::ServiceHandle tfs; + _Ntupe = tfs->make("caliGun", "caliGun"); + + _Ntupe -> Branch("genErg", &_genErg, "genErg/F"); + _Ntupe -> Branch("genTime", &_genTime, "genTime/F"); + _Ntupe -> Branch("genCos", &_genCos, "genCos/F"); + //_Ntupe -> Branch("genPhi", &_genPhi, "genPhi/F"); + //_Ntupe -> Branch("genRad", &_genRad, "genRad/F"); + _Ntupe -> Branch("genPosX", &_genPosX, "genPosX/F"); + _Ntupe -> Branch("genPosY", &_genPosY, "genPosY/F"); + _Ntupe -> Branch("genPosZ", &_genPosZ, "genPosZ/F"); } - - if (_mean < 0) throw cet::exception("RANGE") << "CaloCalibGun.mean must be non-negative "<< '\n'; - } -// to do on that one -// get the correct z position of the pipes -// check what these detector positions are - - - + // to do on that one + // get the correct z position of the pipes + // check what these detector positions are CaloCalibGun::~CaloCalibGun(){} - - - - void CaloCalibGun::generate( GenParticleCollection& genParts ){ - - - //int nGen = _randPoissonQ.fire(); - int nGen = _mean; - for (int ig=0; igFill(energy); - _hT ->Fill(time); - _hcos ->Fill(p3.cosTheta()); - _hphi ->Fill(phi); - _hrad ->Fill(rad); - _hz ->Fill(pos.z()); - _hxy ->Fill(rad*cos(phi),rad*sin(phi)); - } + void CaloCalibGun::generate(GenParticleCollection& genParts) + { + //int nGen = _randPoissonQ.fire(); + int nGen = _mean; + // define the parameters of the pipes + // angle of large torus in degrees + double phi_lbd[5] = {161.34, 149.50, 139.50, 132.07, 125.39}; + // angle of small torus in degrees + double phi_sbd[5] = {84.63, 85.28, 85.79, 86.20, 86.53}; + // angle of the end point + double phi_end[5] = {3.96, 10.53, 15.80, 20.16, 23.84}; + // center position y of the small torus + double ysmall[5] = {432.2, 480.5, 524.3, 564.7, 602.5}; + // radius of small torus + double radSmTor = 41.0; + // first center position x of the small torus + double xsmall = 71.0; + // distance of the small torus center + double xdistance = 60.0; + // inner radius of the manifold + double rInnerManifold = 681.6; // 713.35 mm - 1.25 in (31.75 mm) + vector sign{-1.0, 1.0}; + + for (int ig=0; igdisk(nDisk).geomInfo().origin()-CLHEP::Hep3Vector(0,0,_cal->disk(nDisk).geomInfo().size().z()/2.0-_pipeRadius); + //cout << "The number of disk: " << nDisk << "; z position: " << _zPipeCenter << endl; + + double xpipe, ypipe, zpipe; + //Pick position + int xsn = rint(_randFlat.fire()); + int ysn = rint(_randFlat.fire()); + + double theta = _randFlat.fire() * 2.0 * piconst; + double pipeR = _pipeRadius * _randFlat.fire(); + zpipe = pipeR*sin(theta); + + double rtest = _randFlat.fire(); + int idx = int( std::lower_bound(_randomRad.begin(), _randomRad.end(), rtest) - _randomRad.begin()); + double radLgTor = _pipeTorRadius[idx]; + // modify to the full circle, Aug. 21, 2018 + // The phi range from 0 to half phi_lbd for the large torus + double phiLgTor = _randFlat.fire() * phi_lbd[idx] * piconst / 2. / 180.; + // x, y, z position of the large torus + double xLgTor = sign[xsn]*(radLgTor + pipeR*cos(theta))*cos(phiLgTor); + double yLgTor = sign[ysn]*(radLgTor + pipeR*cos(theta))*sin(phiLgTor); + // circulus (center) of the large torus + double circLgTor = radLgTor * phi_lbd[idx] * piconst / 2. / 180.; + + // The phi range for the small torus + double phiSmTor = piconst * (_randFlat.fire() * phi_sbd[idx] + 180. + phi_lbd[idx]/2. - phi_sbd[idx])/180.; + // x, y, z position of the small torus + double xSmTor = sign[xsn]*((radSmTor + pipeR*cos(theta))*cos(phiSmTor) + xsmall + xdistance * idx); + double ySmTor = sign[ysn]*((radSmTor + pipeR*cos(theta))*sin(phiSmTor) + ysmall[idx]); + // circulus (center) of the small torus + double circSmTor = radSmTor * piconst * phi_sbd[idx] / 180.; + + // strait pipe + //double xmanifold = rInnerManifold * cos(piconst * (90 - phi_end[idx])/180.); + double ymanifold = rInnerManifold * sin(piconst * (90 - phi_end[idx])/180.); + double xstart = xsmall + xdistance * idx - radSmTor * cos(piconst * phi_end[idx]/180.); + double ystart = ysmall[idx] + radSmTor * sin(piconst * phi_end[idx]/180.); + // height of the strait pipe + double hPipe = (ymanifold - ystart) / sin(piconst * (90 - phi_end[idx]) / 180.); + // a cylinder along y-axis + double y_center = _randFlat.fire() * hPipe; + double xPipe = pipeR * cos(theta); + double xStrait = sign[xsn] * (xPipe * cos(-piconst * phi_end[idx] / 180.) - y_center * sin(-piconst * phi_end[idx] / 180.) + xstart); + double yStrait = sign[ysn] * (xPipe * sin(-piconst * phi_end[idx] / 180.) + y_center * cos(-piconst * phi_end[idx] / 180.) + ystart); + double lenStrait = hPipe; + + double sample = _randFlat.fire(); + if(sample <= circLgTor / (circLgTor + circSmTor + lenStrait)) +// if(sample <= circLgTor / (circLgTor + circSmTor)) + { + xpipe = xLgTor; + ypipe = yLgTor; + } + else if(sample > circLgTor / (circLgTor + circSmTor + lenStrait) && sample <= (circLgTor + circSmTor) / (circLgTor + circSmTor + lenStrait)) +// else + { + xpipe = xSmTor; + ypipe = ySmTor; + } + else + { + xpipe = xStrait; + ypipe = yStrait; } + //cout << "===============================================" << endl; + //cout << "pipe center position: " << _zPipeCenter.x() << "; " << _zPipeCenter.y() << "; " << _zPipeCenter.z() << endl; + //cout << "X position: " << rad*cos(phi) << endl; + CLHEP::Hep3Vector pos(xpipe, ypipe, zpipe); + // shift the pipe to the front of the calorimeter disk 0 + pos +=_zPipeCenter; + //cout << "Positions: x = " << pos.x() << "; y = " << pos.y() << "; z = " << pos.z() << endl; + + //pick time + double time = _tmin + _randFlat.fire() * ( _tmax - _tmin ); + + //Pick energy and momentum vector + //double e = _elow + _flatmomentum.fire() * ( _ehi - _elow ); + double energy =_energy; + CLHEP::Hep3Vector p3 = _randomUnitSphere.fire(_energy); + //while (p3.cosTheta()<0) p3 = _randomUnitSphere.fire(_energy); + + //Set Four-momentum + CLHEP::HepLorentzVector mom(0,0,0,0); + mom.setPx( p3.x() ); + mom.setPy( p3.y() ); + mom.setPz( p3.z() ); + mom.setE( energy ); + + // Add the particle to the list. + genParts.push_back( GenParticle(PDGCode::gamma, GenId::CaloCalib, pos, mom, time)); + + // Fill histograms. + if ( _doHistograms) + { + _genErg = energy; + _genTime = time; + _genCos = p3.cosTheta(); + //_genPhi = phi; + //_genRad = rad; + _genPosX = pos.x(); + _genPosY = pos.y(); + _genPosZ = pos.z(); + } + if(_doHistograms) _Ntupe -> Fill(); + } + } - } diff --git a/EventGenerator/src/NewCaloCalibGun_module.cc b/EventGenerator/src/NewCaloCalibGun_module.cc new file mode 100644 index 0000000000..7e167419fc --- /dev/null +++ b/EventGenerator/src/NewCaloCalibGun_module.cc @@ -0,0 +1,136 @@ +// Sophie Middleton, 2022 +// C++ includes. +#include +#include + +// Framework includes +#include "art/Framework/Principal/Run.h" +#include "art_root_io/TFileDirectory.h" +#include "art_root_io/TFileService.h" +#include "messagefacility/MessageLogger/MessageLogger.h" + +// Mu2e includes +#include "Offline/ConditionsService/inc/AcceleratorParams.hh" +#include "Offline/ConditionsService/inc/ConditionsHandle.hh" +#include "Offline/GlobalConstantsService/inc/GlobalConstantsHandle.hh" +#include "Offline/GlobalConstantsService/inc/ParticleDataTable.hh" +//#include "Offline/EventGenerator/inc/CaloCalibGun.hh" +#include "Offline/GeometryService/inc/GeomHandle.hh" +#include "Offline/GeometryService/inc/DetectorSystem.hh" +#include "Offline/DataProducts/inc/PDGCode.hh" +#include "Offline/ConfigTools/inc/SimpleConfig.hh" +#include "Offline/CalorimeterGeom/inc/DiskCalorimeter.hh" +#include "Offline/Mu2eUtilities/inc/RandomUnitSphere.hh" + +// Other external includes. +#include "CLHEP/Random/RandFlat.h" +#include "CLHEP/Units/PhysicalConstants.h" + +//ROOT Includes +#include "TMath.h" +using namespace std; +using namespace TMath; + +// Generates particles in a flat shaped spectrum, size determined by FCL params these will be attached to a mu- in +// the input SimParticleCollection. +// This module throws an exception if no suitable muon is found. +// +// S Middleton, 2021 + +#include +#include +#include +#include + +#include "CLHEP/Vector/ThreeVector.h" +#include "CLHEP/Vector/LorentzVector.h" +#include "CLHEP/Random/RandomEngine.h" +#include "CLHEP/Random/RandExponential.h" +#include "CLHEP/Random/RandFlat.h" +#include "CLHEP/Units/PhysicalConstants.h" + +#include "fhiclcpp/types/Atom.h" +#include "messagefacility/MessageLogger/MessageLogger.h" + +#include "art/Framework/Core/EDProducer.h" +#include "art/Framework/Core/ModuleMacros.h" +#include "art/Framework/Principal/Event.h" +#include "art/Framework/Services/Registry/ServiceHandle.h" +#include "art_root_io/TFileService.h" +#include "Offline/SeedService/inc/SeedService.hh" +#include "Offline/GlobalConstantsService/inc/GlobalConstantsHandle.hh" +#include "Offline/GlobalConstantsService/inc/ParticleDataList.hh" +#include "Offline/GlobalConstantsService/inc/PhysicsParams.hh" +#include "Offline/Mu2eUtilities/inc/RandomUnitSphere.hh" +#include "Offline/DataProducts/inc/PDGCode.hh" +#include "Offline/MCDataProducts/inc/ProcessCode.hh" +#include "Offline/MCDataProducts/inc/StageParticle.hh" +#include "Offline/Mu2eUtilities/inc/simParticleList.hh" + +//For primary: +#include "Offline/MCDataProducts/inc/PrimaryParticle.hh" +#include "Offline/MCDataProducts/inc/StepPointMC.hh" +#include "Offline/MCDataProducts/inc/MCTrajectoryCollection.hh" + +#include +namespace mu2e { + + //================================================================ + class NewCaloCalibGun : public art::EDProducer { + public: + struct Config { + using Name=fhicl::Name; + using Comment=fhicl::Comment; + fhicl::Atom PhotonEnergy{Name("PhotonEnergy"),6.13};//MeV + fhicl::Atom Mean{Name("Mean"),1.}, + fhicl::Atom CosMin{Name("cosmin"),-1.}, + fhicl::Atom CosMin{Name("cosmin"),1.}, + fhicl::Atom PhiMin{Name("phimin"),0.}, + fhicl::Atom PhiMin{Name("phimax"), CLHEP::twopi }, + fhicl::Atom doHistograms{Name("doHistograms"), true }, + }; + + using Parameters= art::EDProducer::Table; + explicit NewCaloCalibGun(const Parameters& conf); + + virtual void produce(art::Event& event) override; + + //---------------------------------------------------------------- + private: + + double PhotonEnergy_; + + }; + + //================================================================ + NewCaloCalibGun::NewCaloCalibGun(const Parameters& conf) + : EDProducer{conf} + , PhotonEnergy_{conf().PhotonEnergy()} + , randFlat_{engine}, + , randPoissonQ_{engine, std::abs(_mean)}, + , randomUnitSphere_{engine, _cosmin, _cosmax, 0, CLHEP::twopi}, +// _detSys(), + { + produces(); + produces(); + } + + //================================================================ + void NewCaloCalibGun::produce(art::Event& event) { + auto output{std::make_unique()}; + //Call the gun here + output->emplace_back(mustop, + ProcessCode::CaloCalib, + PDGCode::gamma, + mustop->endPosition(), + CLHEP::HepLorentzVector{randomUnitSphere_.fire(randomMom), randomE}, + time + ); + + event.put(std::move(output)); + } + + //================================================================ +} // namespace mu2e + +DEFINE_ART_MODULE(mu2e::NewCaloCalibGun); diff --git a/GeometryService/src/DiskCalorimeterMaker.cc b/GeometryService/src/DiskCalorimeterMaker.cc index 8f5bd5a925..adce714e48 100644 --- a/GeometryService/src/DiskCalorimeterMaker.cc +++ b/GeometryService/src/DiskCalorimeterMaker.cc @@ -112,20 +112,32 @@ namespace mu2e { calo_->caloInfo_.set("BPPipeThickness", config.getDouble("calorimeter.BPPipeThickness") ); calo_->caloInfo_.set("BPPipeZOffset", config.getDouble("calorimeter.BPPipeZOffset") ); - calo_->caloInfo_.set("FPInnerRadius", config.getDouble("calorimeter.FPInnerRadius") ); - calo_->caloInfo_.set("FPOuterRadius", config.getDouble("calorimeter.FPOuterRadius") ); - calo_->caloInfo_.set("FPFoamZLength", config.getDouble("calorimeter.FPFoamZLength") ); - calo_->caloInfo_.set("FPCarbonZLength", config.getDouble("calorimeter.FPCarbonZLength") ); - calo_->caloInfo_.set("FPCoolPipeTorRadius", config.getDouble("calorimeter.FPCoolPipeTorRadius") ); - calo_->caloInfo_.set("FPCoolPipeRadius", config.getDouble("calorimeter.FPCoolPipeRadius") ); - calo_->caloInfo_.set("FPCoolPipeThickness", config.getDouble("calorimeter.FPCoolPipeThickness") ); - calo_->caloInfo_.set("nPipes", config.getInt("calorimeter.nPipes") ); + calo_->caloInfo_.set("FPInnerRadius", config.getDouble("calorimeter.FPInnerRadius") ); + calo_->caloInfo_.set("FPOuterRadius", config.getDouble("calorimeter.FPOuterRadius") ); + calo_->caloInfo_.set("FPFoamZLength", config.getDouble("calorimeter.FPFoamZLength") ); + calo_->caloInfo_.set("FPCarbonZLength", config.getDouble("calorimeter.FPCarbonZLength") ); + calo_->caloInfo_.set("FPCoolPipeTorRadius", config.getDouble("calorimeter.FPCoolPipeTorRadius") ); + calo_->caloInfo_.set("FPCoolPipeRadius", config.getDouble("calorimeter.FPCoolPipeRadius") ); + calo_->caloInfo_.set("FPCoolPipeThickness", config.getDouble("calorimeter.FPCoolPipeThickness") ); + calo_->caloInfo_.set("nPipes", config.getInt("calorimeter.nPipes") ); calo_->caloInfo_.set("pipeRadius", config.getDouble("calorimeter.pipeRadius") ); calo_->caloInfo_.set("pipeThickness", config.getDouble("calorimeter.pipeThickness") ); - calo_->caloInfo_.set("pipeInitSeparation", config.getDouble("calorimeter.pipeInitSeparation") ); - temp.clear(); - config.getVectorDouble("calorimeter.pipeTorRadius", temp, calo_->caloInfo_.getInt("nPipes")); - calo_->caloInfo_.set("pipeTorRadius",temp ); + calo_->caloInfo_.set("pipeInitSeparation", config.getDouble("calorimeter.pipeInitSeparation") ); + temp.clear(); + config.getVectorDouble("calorimeter.pipeTorRadius", temp, calo_->caloInfo_.getInt("nPipes")); + calo_->caloInfo_.set("pipeTorRadius",temp ); + temp.clear(); + config.getVectorDouble("calorimeter.halfTorPhi", temp, calo_->caloInfo_.getInt("nPipes")); + calo_->caloInfo_.set("halfTorPhi", temp ); + temp.clear(); + config.getVectorDouble("calorimeter.smallTorPhi", temp, calo_->caloInfo_.getInt("nPipes")); + calo_->caloInfo_.set("smallTorPhi", temp ); + temp.clear(); + config.getVectorDouble("calorimeter.yposition", temp, calo_->caloInfo_.getInt("nPipes")); + calo_->caloInfo_.set("yposition", temp ); + temp.clear(); + config.getVectorDouble("calorimeter.straitEndPhi", temp, calo_->caloInfo_.getInt("nPipes")); + calo_->caloInfo_.set("straitEndPhi", temp ); calo_->caloInfo_.set("numberOfCrates", config.getInt("calorimeter.numberOfCrates") ); calo_->caloInfo_.set("nCrateBeforeSpace", config.getInt("calorimeter.nCrateBeforeSpace") ); diff --git a/MCDataProducts/inc/ProcessCode.hh b/MCDataProducts/inc/ProcessCode.hh index 4396b6b213..a770108290 100644 --- a/MCDataProducts/inc/ProcessCode.hh +++ b/MCDataProducts/inc/ProcessCode.hh @@ -85,7 +85,7 @@ namespace mu2e { truncated, mu2eMuonCaptureAtRest, mu2eMuonDecayAtRest, mu2eCeMinusEndpoint, // 167 mu2eCeMinusLeadingLog, mu2eCePlusEndpoint, mu2eDIOLeadingLog, mu2eInternalRMC, // 171 mu2eExternalRMC, mu2eFlateMinus, mu2eFlatePlus, mu2eFlatPhoton, // 175 - mu2eCePlusLeadingLog, mu2eunused2, mu2eunused3, mu2eunused4, + mu2eCePlusLeadingLog, CaloCalib, mu2eunused3, mu2eunused4, mu2eunused5, mu2eunused6, mu2eunused7, mu2eunused8, uninitialized, lastEnum, @@ -141,7 +141,7 @@ namespace mu2e { "truncated", "mu2eMuonCaptureAtRest", "mu2eMuonDecayAtRest", "mu2eCeMinusEndpoint", \ "mu2eCeMinusLeadingLog", "mu2eCePlusEndpoint", "mu2eDIOLeadingLog", "mu2eInternalRMC", \ "mu2eExternalRMC", "mu2eFlateMinus", "mu2eFlatePlus", "mu2eFlatPhoton", \ - "mu2eCePlusLeadingLog", "mu2eunused2", "mu2eunused3", "mu2eunused4", \ + "mu2eCePlusLeadingLog", "CaloCalib", "mu2eunused3", "mu2eunused4", \ "mu2eunused5", "mu2eunused6", "mu2eunused7", "mu2eunused8", \ "uninitialized" #endif diff --git a/Mu2eG4/geom/calorimeter_CsI.txt b/Mu2eG4/geom/calorimeter_CsI.txt index 970b4777e7..ee0ae2fcef 100644 --- a/Mu2eG4/geom/calorimeter_CsI.txt +++ b/Mu2eG4/geom/calorimeter_CsI.txt @@ -60,7 +60,11 @@ vector calorimeter.pipeTorRadius = {397,457,517,577,637}; double calorimeter.pipeRadius = 4.75; double calorimeter.pipeThickness = 0.5; double calorimeter.pipeInitSeparation = 25.4; - +//double calorimeter.FPCoolPipeThickness = 1.4732; +vector calorimeter.halfTorPhi = {80.67, 74.75, 69.98, 66.04, 62.70}; // half angle of large torus +vector calorimeter.smallTorPhi = {84.63, 85.28, 85.79, 86.20, 86.53}; // full angle of small torus +vector calorimeter.straitEndPhi = {3.96, 10.53, 15.80, 20.16, 23.84}; // angle of the ending poing of the strait pipe +vector calorimeter.yposition = {432.2, 480.5, 524.3, 564.7, 602.5}; // start y position of the strait pipe int calorimeter.crateVersion = 2; int calorimeter.numberOfCrates = 10; diff --git a/Mu2eG4/src/constructDiskCalorimeter.cc b/Mu2eG4/src/constructDiskCalorimeter.cc index 16d8874ec2..4c42891dad 100644 --- a/Mu2eG4/src/constructDiskCalorimeter.cc +++ b/Mu2eG4/src/constructDiskCalorimeter.cc @@ -215,7 +215,7 @@ namespace mu2e { // the big pipe is aligned with the small pipes (centered on the same z). Big cooling pipe needs to be larger than // carbon thickness+small pipe radius and smaller than Carbon thick + foam thick - small pipe radius or the model needs to be updated. // - G4LogicalVolume* caloBuildFrontPlate(const SimpleConfig& config, MaterialFinder& materialFinder, const DiskCalorimeter& cal, int idisk) + G4LogicalVolume* caloBuildFrontPlate(const SimpleConfig& config, MaterialFinder& materialFinder, const DiskCalorimeter& cal, int idisk) { Mu2eG4Helper& _helper = *(art::ServiceHandle()); AntiLeakRegistry& reg = _helper.antiLeakRegistry(); @@ -225,14 +225,9 @@ namespace mu2e { const bool isPipeVisible = geomOptions->isVisible("calorimeterPipe"); const bool isPipeSolid = geomOptions->isSolid("calorimeterPipe"); - const bool forceEdge = geomOptions->forceAuxEdgeVisible("calorimeterPipe"); - const bool doSurfaceCheck = geomOptions->doSurfaceCheck("calorimeterPipe"); + const bool forceEdge = config.getBool("g4.forceEdge",false); + const bool doSurfaceCheck = config.getBool("g4.doSurfaceCheck",false) || config.getBool("calorimeter.doSurfaceCheck",false); const int verbosityLevel = config.getInt("calorimeter.verbosityLevel",1); - - if ( verbosityLevel > 0) { - G4cout << __func__ << " Called. doSurfaceCheck: " << doSurfaceCheck << G4endl; - } - G4VPhysicalVolume* pv; G4Material* vacuumMaterial = materialFinder.get("calorimeter.vacuumMaterial"); @@ -253,6 +248,10 @@ namespace mu2e { G4double pipeThickness = cal.caloInfo().getDouble("pipeThickness"); G4double pipeInitSeparation = cal.caloInfo().getDouble("pipeInitSeparation"); std::vector pipeTorRadius = cal.caloInfo().getVDouble("pipeTorRadius"); + std::vector halfTorPhi = cal.caloInfo().getVDouble("halfTorPhi"); + std::vector smallTorPhi = cal.caloInfo().getVDouble("smallTorPhi"); + std::vector yposition = cal.caloInfo().getVDouble("yposition"); + std::vector straitEndPhi = cal.caloInfo().getVDouble("straitEndPhi"); G4double frontPanelHalfThick = (2.0*FPCarbonDZ+2.0*FPFoamDZ-pipeRadius+FPCoolPipeRadius)/2.0; G4double ZposCarbon2 = frontPanelHalfThick-FPCarbonDZ; @@ -264,11 +263,11 @@ namespace mu2e { //this is the full front panel G4Tubs* frontPlate = new G4Tubs("caloFrontPlate",FPInnerRadius,FPCoolPipeTorRadius+FPCoolPipeRadius,frontPanelHalfThick,0,CLHEP::twopi); - G4LogicalVolume* frontPlateLog = caloBuildLogical(frontPlate, vacuumMaterial, "caloFrontPlateLog_"+std::to_string(idisk),0,G4Color::White(),0,0); + G4LogicalVolume* frontPlateLog = caloBuildLogical(frontPlate, vacuumMaterial, "caloFrontPlateLog",0,G4Color::White(),0,0); //carbon fiber panels G4Tubs* frontPanelCarb = new G4Tubs("caloFPCarb",FPInnerRadius,FPOuterRadius,FPCarbonDZ,0,CLHEP::twopi); - G4LogicalVolume* frontPanelCarbLog = caloBuildLogical(frontPanelCarb, FPCarbonMaterial, "caloFPCarbLog_"+std::to_string(idisk),isPipeVisible,G4Color::Grey(),0,forceEdge); + G4LogicalVolume* frontPanelCarbLog = caloBuildLogical(frontPanelCarb, FPCarbonMaterial, "caloFPCarbLog",isPipeVisible,G4Color::Grey(),0,forceEdge); pv = new G4PVPlacement(0,G4ThreeVector(0.0,0.0,ZposCarbon1), frontPanelCarbLog, "caloFPCarbPV1", frontPlateLog, false, 0, false); doSurfaceCheck && checkForOverlaps( pv, config, verbosityLevel>0); @@ -277,7 +276,7 @@ namespace mu2e { //Foam panel G4Tubs* frontPanelFoam = new G4Tubs("caloFPFoam",FPInnerRadius,FPOuterRadius,FPFoamDZ,0,CLHEP::twopi); - G4LogicalVolume* frontPanelFoamLog = caloBuildLogical(frontPanelFoam, FPFoamMaterial, "caloFPFoamLog_"+std::to_string(idisk),isPipeVisible,G4Color::Brown(),0,forceEdge); + G4LogicalVolume* frontPanelFoamLog = caloBuildLogical(frontPanelFoam, FPFoamMaterial, "caloFPFoamLog",isPipeVisible,G4Color::Brown(),0,forceEdge); pv = new G4PVPlacement(0,G4ThreeVector(0.0,0.0,ZposFoam), frontPanelFoamLog, "caloFPFoamPV", frontPlateLog, false, 0, false); doSurfaceCheck && checkForOverlaps( pv, config, verbosityLevel>0); @@ -289,48 +288,117 @@ namespace mu2e { reg.add(rotFPPipe); G4Torus* coolFP = new G4Torus("caloCoolFP",FPCoolPipeRadius-FPCoolPipeThickness, FPCoolPipeRadius, FPCoolPipeTorRadius, angMax, CLHEP::twopi-2.0*angMax); - G4LogicalVolume* coolFPLog = caloBuildLogical(coolFP, pipeMaterial, "caloCoolFPLog_"+std::to_string(idisk),isPipeVisible,G4Color::Red(),isPipeSolid,0); + G4LogicalVolume* coolFPLog = caloBuildLogical(coolFP, pipeMaterial, "caloCoolFPLog",isPipeVisible,G4Color::Red(),isPipeSolid,0); pv = new G4PVPlacement(rotFPPipe,G4ThreeVector(0.0,0.0,ZposPipe), coolFPLog, "caloCoolFPPV", frontPlateLog, false, 0, false); doSurfaceCheck && checkForOverlaps( pv, config, verbosityLevel>0); //pipes nside foam G4RotationMatrix* rotPipe1 = new G4RotationMatrix(CLHEP::HepRotation::IDENTITY); - rotPipe1->rotateZ(CLHEP::pi/2.0); + //rotPipe1->rotateZ(CLHEP::pi/2.0); + rotPipe1->rotateZ(0.0 * CLHEP::pi); G4RotationMatrix* rotPipe2 = new G4RotationMatrix(CLHEP::HepRotation::IDENTITY); - rotPipe2->rotateZ(1.5*CLHEP::pi); - G4RotationMatrix* rotPipeFlat = new G4RotationMatrix(CLHEP::HepRotation::IDENTITY); - rotPipeFlat->rotateX(CLHEP::pi/2.0); + rotPipe2->rotateZ(1.0 * CLHEP::pi); + G4RotationMatrix* rotPipe3 = new G4RotationMatrix(CLHEP::HepRotation::IDENTITY); + rotPipe3->rotateY(1.0 * CLHEP::pi); + G4RotationMatrix* rotPipe4 = new G4RotationMatrix(CLHEP::HepRotation::IDENTITY); + rotPipe4->rotateX(1.0 * CLHEP::pi); + //G4RotationMatrix* rotPipeFlat = new G4RotationMatrix(CLHEP::HepRotation::IDENTITY); + //rotPipeFlat->rotateX(CLHEP::pi/2.0); reg.add(rotPipe1); reg.add(rotPipe2); - reg.add(rotPipeFlat); + reg.add(rotPipe3); + reg.add(rotPipe4); + //reg.add(rotPipeFlat); + double smallRadius = 41.; for (int ipipe=0; ipipe rotateX(0.5 * CLHEP::pi); + sPipeRotate1 -> rotateY((-0.5*CLHEP::pi + zRotateAngle) * CLHEP::rad); + G4RotationMatrix* sPipeRotate2 = new G4RotationMatrix(); + sPipeRotate2 -> rotateX(0.5 * CLHEP::pi); + sPipeRotate2 -> rotateY((-0.5*CLHEP::pi - zRotateAngle) * CLHEP::rad); + G4RotationMatrix* sPipeRotate3 = new G4RotationMatrix(); + sPipeRotate3 -> rotateX(0.5 * CLHEP::pi); + sPipeRotate3 -> rotateY((-1.5*CLHEP::pi + zRotateAngle) * CLHEP::rad); + G4RotationMatrix* sPipeRotate4 = new G4RotationMatrix(); + sPipeRotate4 -> rotateX(0.5 * CLHEP::pi); + sPipeRotate4 -> rotateY((-1.5*CLHEP::pi - zRotateAngle) * CLHEP::rad); + //reg.add(sPipeRotate); + // transform movement + double xCenter = 0.5 * (xEnd + xStart); + double yCenter = 0.5 * (yEnd + yStart); + // the strait tubes at the origin coordinate system + //std::cout << "the length of the strait pipes: " << sLength << std::endl; + G4Tubs* pipe3 = new G4Tubs("caloPipe3", pipeRadius-pipeThickness, pipeRadius, 0.5 * (sLength - 4.), 0, CLHEP::twopi); + G4LogicalVolume* pipe3Log = caloBuildLogical(pipe3, pipeMaterial, "caloPipe3Log",isPipeVisible,G4Color::Cyan(),isPipeSolid,forceEdge); + + // large bending torus + pv = new G4PVPlacement(rotPipe1, G4ThreeVector(0,0,z), pipe1Log, "caloPipePV", frontPanelFoamLog, false, ipipe, false); doSurfaceCheck && checkForOverlaps( pv, config, verbosityLevel>0); - pv = new G4PVPlacement(rotPipe2,G4ThreeVector(0,0,z), pipe1Log, "caloPipePV", frontPanelFoamLog, false, ipipe, false); - doSurfaceCheck && checkForOverlaps( pv, config, verbosityLevel>0); - pv = new G4PVPlacement(rotPipeFlat,G4ThreeVector(xpipe, y0,z), pipe2Log, "caloPipePV", frontPanelFoamLog, false, ipipe , false); - doSurfaceCheck && checkForOverlaps( pv, config, verbosityLevel>0); - pv = new G4PVPlacement(rotPipeFlat,G4ThreeVector(xpipe,-y0,z), pipe2Log, "caloPipePV", frontPanelFoamLog, false, ipipe , false); - doSurfaceCheck && checkForOverlaps( pv, config, verbosityLevel>0); - pv = new G4PVPlacement(rotPipeFlat,G4ThreeVector(-xpipe,y1,z), pipe2Log, "caloPipePV", frontPanelFoamLog, false, ipipe , false); - doSurfaceCheck && checkForOverlaps( pv, config, verbosityLevel>0); - pv = new G4PVPlacement(rotPipeFlat,G4ThreeVector(-xpipe,-y1,z), pipe2Log, "caloPipePV", frontPanelFoamLog, false, ipipe , false); - doSurfaceCheck && checkForOverlaps( pv, config, verbosityLevel>0); + pv = new G4PVPlacement(rotPipe2, G4ThreeVector(0,0,z), pipe1Log, "caloPipePV", frontPanelFoamLog, false, ipipe, false); + doSurfaceCheck && checkForOverlaps( pv, config, verbosityLevel>0); + // small bending torus + pv = new G4PVPlacement(rotPipe1, G4ThreeVector(sxPos, syPos, z), pipe2Log, "caloPipePV", frontPanelFoamLog, false, ipipe, false); + doSurfaceCheck && checkForOverlaps( pv, config, verbosityLevel>0); + pv = new G4PVPlacement(rotPipe3, G4ThreeVector(-sxPos, syPos, z), pipe2Log, "caloPipePV", frontPanelFoamLog, false, ipipe, false); + doSurfaceCheck && checkForOverlaps( pv, config, verbosityLevel>0); + pv = new G4PVPlacement(rotPipe2, G4ThreeVector(-sxPos, -syPos, z), pipe2Log, "caloPipePV", frontPanelFoamLog, false, ipipe, false); + doSurfaceCheck && checkForOverlaps( pv, config, verbosityLevel>0); + pv = new G4PVPlacement(rotPipe4, G4ThreeVector(sxPos, -syPos, z), pipe2Log, "caloPipePV", frontPanelFoamLog, false, ipipe, false); + doSurfaceCheck && checkForOverlaps( pv, config, verbosityLevel>0); + + // strait pipes + pv = new G4PVPlacement(sPipeRotate1, G4ThreeVector(xCenter, yCenter, z), pipe3Log, "caloPipePV", frontPanelFoamLog, false, ipipe, false); + doSurfaceCheck && checkForOverlaps( pv, config, verbosityLevel>0); + pv = new G4PVPlacement(sPipeRotate2, G4ThreeVector(-xCenter, yCenter, z), pipe3Log, "caloPipePV", frontPanelFoamLog, false, ipipe, false); + doSurfaceCheck && checkForOverlaps( pv, config, verbosityLevel>0); + pv = new G4PVPlacement(sPipeRotate3, G4ThreeVector(-xCenter, -yCenter, z), pipe3Log, "caloPipePV", frontPanelFoamLog, false, ipipe, false); + doSurfaceCheck && checkForOverlaps( pv, config, verbosityLevel>0); + pv = new G4PVPlacement(sPipeRotate4, G4ThreeVector(xCenter, -yCenter, z), pipe3Log, "caloPipePV", frontPanelFoamLog, false, ipipe, false); + doSurfaceCheck && checkForOverlaps( pv, config, verbosityLevel>0); + ////pv = new G4PVPlacement(rotPipeFlat,G4ThreeVector(xpipe, y0,z), pipe2Log, "caloPipePV", frontPanelFoamLog, false, ipipe , false); + //doSurfaceCheck && checkForOverlaps( pv, config, verbosityLevel>0); + //pv = new G4PVPlacement(rotPipeFlat,G4ThreeVector(xpipe,-y0,z), pipe2Log, "caloPipePV", frontPanelFoamLog, false, ipipe , false); + //doSurfaceCheck && checkForOverlaps( pv, config, verbosityLevel>0); + //pv = new G4PVPlacement(rotPipeFlat,G4ThreeVector(-xpipe,y1,z), pipe2Log, "caloPipePV", frontPanelFoamLog, false, ipipe , false); + //doSurfaceCheck && checkForOverlaps( pv, config, verbosityLevel>0); + //pv = new G4PVPlacement(rotPipeFlat,G4ThreeVector(-xpipe,-y1,z), pipe2Log, "caloPipePV", frontPanelFoamLog, false, ipipe , false); + //doSurfaceCheck && checkForOverlaps( pv, config, verbosityLevel>0); } return frontPlateLog; diff --git a/Mu2eG4/test/genconfig_calocalib.txt b/Mu2eG4/test/genconfig_calocalib.txt index 6b2b70ea43..170495fa8c 100644 --- a/Mu2eG4/test/genconfig_calocalib.txt +++ b/Mu2eG4/test/genconfig_calocalib.txt @@ -1,6 +1,9 @@ // // Run-time config info for the event generators. // +// $Id: genconfig_02.txt,v 1.12 2012/07/27 19:45:48 kutschke Exp $ +// $Author: kutschke $ +// $Date: 2012/07/27 19:45:48 $ // // Original author Rob Kutschke @@ -11,7 +14,10 @@ bool caloCalibGun.do = true; double caloCalibGun.cosmin = -1.0; double caloCalibGun.cosmax = 1.0; double caloCalibGun.phimin = 0.0; -double caloCalibGun.phimax = 1.5708; +//double caloCalibGun.phimax = 1.5708; +// the maximum phi/2 is: 0.4533, 0.4199, 0.3930, 0.3708, 0.3520 +// for the pipes from inner to outer. +double caloCalibGun.phimax = 2.0; // Time limits in ns, relative to protons on target. double caloCalibGun.tmin = 500.; @@ -21,4 +27,4 @@ double caloCalibGun.tmax = 1694.; // This tells emacs to view this file in c++ mode. // Local Variables: // mode:c++ -// End: +// End From 58f53fcc20f6ca92f3b0e3728f8a372c5470efc4 Mon Sep 17 00:00:00 2001 From: sophieMu2e Date: Wed, 2 Feb 2022 09:04:17 -0600 Subject: [PATCH 02/33] moved parameters --- EventGenerator/src/NewCaloCalibGun_module.cc | 158 ++++++++++++------- 1 file changed, 105 insertions(+), 53 deletions(-) diff --git a/EventGenerator/src/NewCaloCalibGun_module.cc b/EventGenerator/src/NewCaloCalibGun_module.cc index 7e167419fc..d974cca3ab 100644 --- a/EventGenerator/src/NewCaloCalibGun_module.cc +++ b/EventGenerator/src/NewCaloCalibGun_module.cc @@ -1,78 +1,62 @@ // Sophie Middleton, 2022 // C++ includes. #include -#include +#include +#include +#include // Framework includes #include "art/Framework/Principal/Run.h" #include "art_root_io/TFileDirectory.h" #include "art_root_io/TFileService.h" #include "messagefacility/MessageLogger/MessageLogger.h" +#include "art/Framework/Core/EDProducer.h" +#include "art/Framework/Core/ModuleMacros.h" +#include "art/Framework/Principal/Event.h" +#include "art/Framework/Services/Registry/ServiceHandle.h" // Mu2e includes #include "Offline/ConditionsService/inc/AcceleratorParams.hh" #include "Offline/ConditionsService/inc/ConditionsHandle.hh" #include "Offline/GlobalConstantsService/inc/GlobalConstantsHandle.hh" #include "Offline/GlobalConstantsService/inc/ParticleDataTable.hh" -//#include "Offline/EventGenerator/inc/CaloCalibGun.hh" #include "Offline/GeometryService/inc/GeomHandle.hh" #include "Offline/GeometryService/inc/DetectorSystem.hh" #include "Offline/DataProducts/inc/PDGCode.hh" -#include "Offline/ConfigTools/inc/SimpleConfig.hh" +#include "Offline/SeedService/inc/SeedService.hh" +#include "Offline/Mu2eUtilities/inc/RandomUnitSphere.hh" +#include "Offline/MCDataProducts/inc/ProcessCode.hh" +#include "Offline/MCDataProducts/inc/StageParticle.hh" +#include "Offline/Mu2eUtilities/inc/simParticleList.hh" #include "Offline/CalorimeterGeom/inc/DiskCalorimeter.hh" #include "Offline/Mu2eUtilities/inc/RandomUnitSphere.hh" +//For primary: +#include "Offline/MCDataProducts/inc/PrimaryParticle.hh" +#include "Offline/MCDataProducts/inc/StepPointMC.hh" +#include "Offline/MCDataProducts/inc/MCTrajectoryCollection.hh" + // Other external includes. #include "CLHEP/Random/RandFlat.h" #include "CLHEP/Units/PhysicalConstants.h" - -//ROOT Includes -#include "TMath.h" -using namespace std; -using namespace TMath; - -// Generates particles in a flat shaped spectrum, size determined by FCL params these will be attached to a mu- in -// the input SimParticleCollection. -// This module throws an exception if no suitable muon is found. -// -// S Middleton, 2021 - -#include -#include -#include -#include - #include "CLHEP/Vector/ThreeVector.h" #include "CLHEP/Vector/LorentzVector.h" #include "CLHEP/Random/RandomEngine.h" #include "CLHEP/Random/RandExponential.h" -#include "CLHEP/Random/RandFlat.h" #include "CLHEP/Units/PhysicalConstants.h" +#include "CLHEP/Random/RandPoissonQ.h" +#include "CLHEP/Random/RandGeneral.h" #include "fhiclcpp/types/Atom.h" #include "messagefacility/MessageLogger/MessageLogger.h" -#include "art/Framework/Core/EDProducer.h" -#include "art/Framework/Core/ModuleMacros.h" -#include "art/Framework/Principal/Event.h" -#include "art/Framework/Services/Registry/ServiceHandle.h" -#include "art_root_io/TFileService.h" -#include "Offline/SeedService/inc/SeedService.hh" -#include "Offline/GlobalConstantsService/inc/GlobalConstantsHandle.hh" -#include "Offline/GlobalConstantsService/inc/ParticleDataList.hh" -#include "Offline/GlobalConstantsService/inc/PhysicsParams.hh" -#include "Offline/Mu2eUtilities/inc/RandomUnitSphere.hh" -#include "Offline/DataProducts/inc/PDGCode.hh" -#include "Offline/MCDataProducts/inc/ProcessCode.hh" -#include "Offline/MCDataProducts/inc/StageParticle.hh" -#include "Offline/Mu2eUtilities/inc/simParticleList.hh" - -//For primary: -#include "Offline/MCDataProducts/inc/PrimaryParticle.hh" -#include "Offline/MCDataProducts/inc/StepPointMC.hh" -#include "Offline/MCDataProducts/inc/MCTrajectoryCollection.hh" - +//ROOT Includes +#include #include +const double piconst = Pi(); +using namespace std; +using namespace TMath; + namespace mu2e { //================================================================ @@ -81,12 +65,12 @@ namespace mu2e { struct Config { using Name=fhicl::Name; using Comment=fhicl::Comment; - fhicl::Atom PhotonEnergy{Name("PhotonEnergy"),6.13};//MeV - fhicl::Atom Mean{Name("Mean"),1.}, - fhicl::Atom CosMin{Name("cosmin"),-1.}, - fhicl::Atom CosMin{Name("cosmin"),1.}, - fhicl::Atom PhiMin{Name("phimin"),0.}, - fhicl::Atom PhiMin{Name("phimax"), CLHEP::twopi }, + fhicl::Atom mean{Name("Mean"),1.}, + fhicl::Atom energy{Name("PhotonEnergy"),6.13};//MeV + fhicl::Atom cosmin{Name("cosmin"),-1.}, + fhicl::Atom cosmin{Name("cosmin"),1.}, + fhicl::Atom phimin{Name("phimin"),0.}, + fhicl::Atom phimin{Name("phimax"), CLHEP::twopi }, fhicl::Atom doHistograms{Name("doHistograms"), true }, }; @@ -98,21 +82,89 @@ namespace mu2e { //---------------------------------------------------------------- private: - double PhotonEnergy_; + ConditionsHandle accPar("ignored"); + GlobalConstantsHandle pdt; + + // Default values for the start and end of the live window. + double _tmin = 0.; + double _tmax = accPar->deBuncherPeriod; + + double _mean; + double _energy; + double _cosmin; + double _cosmax; + double _phimin; + double _phimax; + + art::RandomNumberGenerator::base_engine_t& engine; + CLHEP::RandFlat _randFlat; + CLHEP::RandPoissonQ _randPoissonQ; + RandomUnitSphere _randomUnitSphere; + + const DetectorSystem *_detSys; + const DiskCalorimeter *_cal; + int _nPipes; + double _pipeRadius; + std::vector _pipeTorRadius; + std::vector _randomRad; + CLHEP::Hep3Vector _zPipeCenter; + + + bool _doHistograms; + TTree* _Ntupe; + float _genErg; + float _genTime; + float _genCos; + float _genPosX; + float _genPosY; + float _genPosZ; + }; //================================================================ NewCaloCalibGun::NewCaloCalibGun(const Parameters& conf) : EDProducer{conf} - , PhotonEnergy_{conf().PhotonEnergy()} - , randFlat_{engine}, - , randPoissonQ_{engine, std::abs(_mean)}, - , randomUnitSphere_{engine, _cosmin, _cosmax, 0, CLHEP::twopi}, -// _detSys(), + , _mean(config.getDouble("caloCalibGun.mean",1.)), + , _energy{conf().energy()} + , _cosmin{conf().cosmin()} + , _cosmax{conf().cosmax()} + , _phimin{conf().phimin()} + , _phimax{conf().phimax()} + , _engine{createEngine(art::ServiceHandle()->getSeed())} + , _randFlat{_engine}, + , _randPoissonQ{_engine, std::abs(_mean)}, + , _randomUnitSphere{_engine, _cosmin, _cosmax, 0, CLHEP::twopi}, + { produces(); produces(); + + _detSys = &*GeomHandle(); + _cal = &*GeomHandle(); + _nPipes = _cal->caloInfo().getInt("nPipes"); + _pipeRadius = _cal->caloInfo().getDouble("pipeRadius"); + _pipeTorRadius = _cal->caloInfo().getVDouble("pipeTorRadius"); + _randomRad = _cal->caloInfo().getVDouble("pipeTorRadius"); + //_zPipeCenter = _cal->disk(0).geomInfo().origin()-CLHEP::Hep3Vector(0,0,_cal->disk(0).geomInfo().size().z()/2.0-_pipeRadius); + // we normalize to the volume of the pipe (proportional to 2*pi*R if they have all the same radius) to draw a + // random number from which to generate the photons + double sumR(0); + std::for_each(_randomRad.begin(), _randomRad.end(), [&](double& d) {sumR+=d; d = sumR; }); + std::for_each(_randomRad.begin(), _randomRad.end(), [&](double& d) {d /= sumR;}); + // Book histograms. + if ( _doHistograms ) + { + art::ServiceHandle tfs; + _Ntupe = tfs->make("calibGun", "calibGun"); + _Ntupe -> Branch("genErg", &_genErg, "genErg/F"); + _Ntupe -> Branch("genTime", &_genTime, "genTime/F"); + _Ntupe -> Branch("genCos", &_genCos, "genCos/F"); + _Ntupe -> Branch("genPosX", &_genPosX, "genPosX/F"); + _Ntupe -> Branch("genPosY", &_genPosY, "genPosY/F"); + _Ntupe -> Branch("genPosZ", &_genPosZ, "genPosZ/F"); + } + if (_mean < 0) throw cet::exception("RANGE") << "CaloCalibGun.mean must be non-negative "<< '\n'; } //================================================================ From aafa6b8931a3d3a6b4047ea1c054f0fc40dfba4d Mon Sep 17 00:00:00 2001 From: sophieMu2e Date: Wed, 2 Feb 2022 09:15:20 -0600 Subject: [PATCH 03/33] new module coomplete, untested --- EventGenerator/src/NewCaloCalibGun_module.cc | 147 +++++++++++++++++-- 1 file changed, 135 insertions(+), 12 deletions(-) diff --git a/EventGenerator/src/NewCaloCalibGun_module.cc b/EventGenerator/src/NewCaloCalibGun_module.cc index d974cca3ab..b68302e979 100644 --- a/EventGenerator/src/NewCaloCalibGun_module.cc +++ b/EventGenerator/src/NewCaloCalibGun_module.cc @@ -30,7 +30,8 @@ #include "Offline/Mu2eUtilities/inc/simParticleList.hh" #include "Offline/CalorimeterGeom/inc/DiskCalorimeter.hh" #include "Offline/Mu2eUtilities/inc/RandomUnitSphere.hh" - +#include "Offline/MCDataProducts/inc/GenId.hh" +#include "Offline/MCDataProducts/inc/GenParticle.hh" //For primary: #include "Offline/MCDataProducts/inc/PrimaryParticle.hh" #include "Offline/MCDataProducts/inc/StepPointMC.hh" @@ -119,6 +120,7 @@ namespace mu2e { float _genPosX; float _genPosY; float _genPosZ; + void addParticles(GenParticleCollection* output); }; @@ -137,8 +139,9 @@ namespace mu2e { , _randomUnitSphere{_engine, _cosmin, _cosmax, 0, CLHEP::twopi}, { - produces(); + produces(); produces(); + produces (); _detSys = &*GeomHandle(); _cal = &*GeomHandle(); @@ -169,17 +172,137 @@ namespace mu2e { //================================================================ void NewCaloCalibGun::produce(art::Event& event) { - auto output{std::make_unique()}; - //Call the gun here - output->emplace_back(mustop, - ProcessCode::CaloCalib, - PDGCode::gamma, - mustop->endPosition(), - CLHEP::HepLorentzVector{randomUnitSphere_.fire(randomMom), randomE}, - time - ); - + auto output{std::make_unique()}; + addParticles(output); event.put(std::move(output)); + PrimaryParticle pp; + MCTrajectoryCollection mctc; + event.put(std::make_unique(pp)); + event.put(std::make_unique(mctc)); + } + + void CaloCalibGun::addParticles(GenParticleCollection* output) + { + int nGen = _mean; + // define the parameters of the pipes + // angle of large torus in degrees + double phi_lbd[5] = {161.34, 149.50, 139.50, 132.07, 125.39}; + // angle of small torus in degrees + double phi_sbd[5] = {84.63, 85.28, 85.79, 86.20, 86.53}; + // angle of the end point + double phi_end[5] = {3.96, 10.53, 15.80, 20.16, 23.84}; + // center position y of the small torus + double ysmall[5] = {432.2, 480.5, 524.3, 564.7, 602.5}; + // radius of small torus + double radSmTor = 41.0; + // first center position x of the small torus + double xsmall = 71.0; + // distance of the small torus center + double xdistance = 60.0; + // inner radius of the manifold + double rInnerManifold = 681.6; // 713.35 mm - 1.25 in (31.75 mm) + vector sign{-1.0, 1.0}; + + for (int ig=0; igdisk(nDisk).geomInfo().origin()-CLHEP::Hep3Vector(0,0,_cal->disk(nDisk).geomInfo().size().z()/2.0-_pipeRadius); + + double xpipe, ypipe, zpipe; + //Pick position + int xsn = rint(_randFlat.fire()); + int ysn = rint(_randFlat.fire()); + + double theta = _randFlat.fire() * 2.0 * piconst; + double pipeR = _pipeRadius * _randFlat.fire(); + zpipe = pipeR*sin(theta); + + double rtest = _randFlat.fire(); + int idx = int( std::lower_bound(_randomRad.begin(), _randomRad.end(), rtest) - _randomRad.begin()); + double radLgTor = _pipeTorRadius[idx]; + + // The phi range from 0 to half phi_lbd for the large torus + double phiLgTor = _randFlat.fire() * phi_lbd[idx] * piconst / 2. / 180.; + // x, y, z position of the large torus + double xLgTor = sign[xsn]*(radLgTor + pipeR*cos(theta))*cos(phiLgTor); + double yLgTor = sign[ysn]*(radLgTor + pipeR*cos(theta))*sin(phiLgTor); + // circulus (center) of the large torus + double circLgTor = radLgTor * phi_lbd[idx] * piconst / 2. / 180.; + + // The phi range for the small torus + double phiSmTor = piconst * (_randFlat.fire() * phi_sbd[idx] + 180. + phi_lbd[idx]/2. - phi_sbd[idx])/180.; + // x, y, z position of the small torus + double xSmTor = sign[xsn]*((radSmTor + pipeR*cos(theta))*cos(phiSmTor) + xsmall + xdistance * idx); + double ySmTor = sign[ysn]*((radSmTor + pipeR*cos(theta))*sin(phiSmTor) + ysmall[idx]); + // circulus (center) of the small torus + double circSmTor = radSmTor * piconst * phi_sbd[idx] / 180.; + + // strait pipe + //double xmanifold = rInnerManifold * cos(piconst * (90 - phi_end[idx])/180.); + double ymanifold = rInnerManifold * sin(piconst * (90 - phi_end[idx])/180.); + double xstart = xsmall + xdistance * idx - radSmTor * cos(piconst * phi_end[idx]/180.); + double ystart = ysmall[idx] + radSmTor * sin(piconst * phi_end[idx]/180.); + // height of the strait pipe + double hPipe = (ymanifold - ystart) / sin(piconst * (90 - phi_end[idx]) / 180.); + // a cylinder along y-axis + double y_center = _randFlat.fire() * hPipe; + double xPipe = pipeR * cos(theta); + double xStrait = sign[xsn] * (xPipe * cos(-piconst * phi_end[idx] / 180.) - y_center * sin(-piconst * phi_end[idx] / 180.) + xstart); + double yStrait = sign[ysn] * (xPipe * sin(-piconst * phi_end[idx] / 180.) + y_center * cos(-piconst * phi_end[idx] / 180.) + ystart); + double lenStrait = hPipe; + + double sample = _randFlat.fire(); + if(sample <= circLgTor / (circLgTor + circSmTor + lenStrait)) + { + xpipe = xLgTor; + ypipe = yLgTor; + } + else if(sample > circLgTor / (circLgTor + circSmTor + lenStrait) && sample <= (circLgTor + circSmTor) / (circLgTor + circSmTor + lenStrait)) + { + xpipe = xSmTor; + ypipe = ySmTor; + } + else + { + xpipe = xStrait; + ypipe = yStrait; + } + CLHEP::Hep3Vector pos(xpipe, ypipe, zpipe); + // shift the pipe to the front of the calorimeter disk 0 + pos +=_zPipeCenter; + + //pick time + double time = _tmin + _randFlat.fire() * ( _tmax - _tmin ); + + //Pick energy and momentum vector + double energy =_energy; + CLHEP::Hep3Vector p3 = _randomUnitSphere.fire(_energy); + + //Set Four-momentum + CLHEP::HepLorentzVector mom(0,0,0,0); + mom.setPx( p3.x() ); + mom.setPy( p3.y() ); + mom.setPz( p3.z() ); + mom.setE( energy ); + + // Add the particle to the list. + + // Add the particle to the list. + output.push_back( GenParticle(PDGCode::gamma, GenId::CaloCalib, pos, mom, time)); + + // Fill histograms. + if ( _doHistograms) + { + _genErg = energy; + _genTime = time; + _genCos = p3.cosTheta(); + _genPosX = pos.x(); + _genPosY = pos.y(); + _genPosZ = pos.z(); + } + if(_doHistograms) _Ntupe -> Fill(); + } } //================================================================ From bc15373846d1bba90900d5debbd8a7c2932cffbd Mon Sep 17 00:00:00 2001 From: sophieMu2e Date: Wed, 2 Feb 2022 09:50:42 -0600 Subject: [PATCH 04/33] removed old files --- EventGenerator/inc/CaloCalibGun.hh | 97 ----------- EventGenerator/src/CaloCalibGun.cc | 247 ----------------------------- 2 files changed, 344 deletions(-) delete mode 100644 EventGenerator/inc/CaloCalibGun.hh delete mode 100644 EventGenerator/src/CaloCalibGun.cc diff --git a/EventGenerator/inc/CaloCalibGun.hh b/EventGenerator/inc/CaloCalibGun.hh deleted file mode 100644 index b3c68d5da0..0000000000 --- a/EventGenerator/inc/CaloCalibGun.hh +++ /dev/null @@ -1,97 +0,0 @@ -#ifndef EventGenerator_CaloCalibGun_hh -#define EventGenerator_CaloCalibGun_hh -// -// Generate some number of DIO electrons. -// -// $Id: CaloCalibGun.hh,v 1.34 2013/07/22 18:57:42 knoepfel Exp $ -// $Author: knoepfel $ -// $Date: 2013/07/22 18:57:42 $ -// -// -// ==================================================================== -// -// IMPORTANT NOTE: -// -// _ehi MUST BE initialized before any of the CLHEP::Rand* variables -// -// ==================================================================== - -// C++ includes -#include - -// Framework includes -#include "art/Framework/Principal/Run.h" - -// Mu2e includes -#include "EventGenerator/inc/GeneratorBase.hh" -#include "CalorimeterGeom/inc/DiskCalorimeter.hh" -#include "Mu2eUtilities/inc/RandomUnitSphere.hh" - -// CLHEP includes -#include "CLHEP/Random/RandPoissonQ.h" -#include "CLHEP/Random/RandGeneral.h" -#include "CLHEP/Random/RandFlat.h" - -// ROOT includes -#include "TTree.h" - -class TTree; - -namespace art { - class Run; -} - - -namespace mu2e { - - class SimpleConfig; - class DetectorSystem; - - class CaloCalibGun: public GeneratorBase { - public: - - CaloCalibGun(CLHEP::HepRandomEngine& engine, art::Run& run, const SimpleConfig& config); - virtual ~CaloCalibGun(); - - virtual void generate( GenParticleCollection& ); - - private: - - double _mean; - double _energy; - double _cosmin; - double _cosmax; - double _phimin; - double _phimax; - double _tmin; - double _tmax; - - CLHEP::RandFlat _randFlat; - CLHEP::RandPoissonQ _randPoissonQ; - RandomUnitSphere _randomUnitSphere; - - const DetectorSystem *_detSys; - const DiskCalorimeter *_cal; - int _nPipes; - double _pipeRadius; - std::vector _pipeTorRadius; - std::vector _randomRad; - CLHEP::Hep3Vector _zPipeCenter; - - - bool _doHistograms; - TTree* _Ntupe; - float _genErg; - float _genTime; - float _genCos; - //float _genPhi; - //float _genRad; - float _genPosX; - float _genPosY; - float _genPosZ; - }; - - -} // end namespace mu2e, - -#endif /* EventGenerator_CaloCalibGun_hh */ diff --git a/EventGenerator/src/CaloCalibGun.cc b/EventGenerator/src/CaloCalibGun.cc deleted file mode 100644 index b8a9da9e6e..0000000000 --- a/EventGenerator/src/CaloCalibGun.cc +++ /dev/null @@ -1,247 +0,0 @@ -// -// Simulate the photons coming from the pipe calibration source -// // -// $Id: CaloCalibGun.cc,v 1.16 2014/01/27 22:20:17 knoepfel Exp $ -// $Author: knoepfel $ -// $Date: 2014/01/27 22:20:17 $ -// -// Original author Bertrand Echenard -// Edited by: De Xu Lin, Sophie Middleton - -// C++ includes. -#include -#include - -// Framework includes -#include "art/Framework/Principal/Run.h" -#include "art_root_io/TFileDirectory.h" -#include "art_root_io/TFileService.h" -#include "messagefacility/MessageLogger/MessageLogger.h" - -// Mu2e includes -#include "Offline/ConditionsService/inc/AcceleratorParams.hh" -#include "Offline/ConditionsService/inc/ConditionsHandle.hh" -#include "Offline/GlobalConstantsService/inc/GlobalConstantsHandle.hh" -#include "Offline/GlobalConstantsService/inc/ParticleDataTable.hh" -#include "Offline/EventGenerator/inc/CaloCalibGun.hh" -#include "Offline/GeometryService/inc/GeomHandle.hh" -#include "Offline/GeometryService/inc/DetectorSystem.hh" -#include "Offline/DataProducts/inc/PDGCode.hh" -#include "Offline/ConfigTools/inc/SimpleConfig.hh" -#include "Offline/CalorimeterGeom/inc/DiskCalorimeter.hh" -#include "Offline/Mu2eUtilities/inc/RandomUnitSphere.hh" - -// Other external includes. -#include "CLHEP/Random/RandFlat.h" -#include "CLHEP/Units/PhysicalConstants.h" - -//ROOT Includes -#include "TMath.h" -using namespace std; -using namespace TMath; -const double piconst = Pi(); - -namespace mu2e -{ - CaloCalibGun::CaloCalibGun(CLHEP::HepRandomEngine& engine, art::Run& run, const SimpleConfig& config): - // Configurable parameters - _mean(config.getDouble("caloCalibGun.mean",1.)), - _energy(config.getDouble("caloCalibGun.energy",6.13)), - _cosmin(config.getDouble("caloCalibGun.cosmin", -1.)), - _cosmax(config.getDouble("caloCalibGun.cosmax", 1.)), - _phimin(config.getDouble("caloCalibGun.phimin", 0. )), - _phimax(config.getDouble("caloCalibGun.phimax", CLHEP::twopi )), - _randFlat{engine}, - _randPoissonQ{engine, std::abs(_mean)}, - _randomUnitSphere{engine, _cosmin, _cosmax, 0, CLHEP::twopi}, - _detSys(), - _doHistograms(config.getBool("caloCalibGun.doHistograms",true)), - _Ntupe(0) - { - // About the ConditionsService: - // The argument to the constructor is ignored for now. It will be a - // data base key. There is a second argument that I have let take its - // default value of "current"; it will be used to specify a version number. - ConditionsHandle accPar("ignored"); - GlobalConstantsHandle pdt; - - // Default values for the start and end of the live window. - _tmin = 0.; - _tmax = accPar->deBuncherPeriod; - _tmin = config.getDouble("caloCalibGun.tmin", _tmin ); - _tmax = config.getDouble("caloCalibGun.tmax", _tmax ); - - _detSys = &*GeomHandle(); - _cal = &*GeomHandle(); - _nPipes = _cal->caloInfo().getInt("nPipes"); - _pipeRadius = _cal->caloInfo().getDouble("pipeRadius"); - _pipeTorRadius = _cal->caloInfo().getVDouble("pipeTorRadius"); - _randomRad = _cal->caloInfo().getVDouble("pipeTorRadius"); - //_zPipeCenter = _cal->disk(0).geomInfo().origin()-CLHEP::Hep3Vector(0,0,_cal->disk(0).geomInfo().size().z()/2.0-_pipeRadius); - // we normalize to the volume of the pipe (proportional to 2*pi*R if they have all the same radius) to draw a - // random number from which to generate the photons - double sumR(0); - std::for_each(_randomRad.begin(), _randomRad.end(), [&](double& d) {sumR+=d; d = sumR; }); - std::for_each(_randomRad.begin(), _randomRad.end(), [&](double& d) {d /= sumR;}); - // Book histograms. - if ( _doHistograms ) - { - art::ServiceHandle tfs; - _Ntupe = tfs->make("caliGun", "caliGun"); - - _Ntupe -> Branch("genErg", &_genErg, "genErg/F"); - _Ntupe -> Branch("genTime", &_genTime, "genTime/F"); - _Ntupe -> Branch("genCos", &_genCos, "genCos/F"); - //_Ntupe -> Branch("genPhi", &_genPhi, "genPhi/F"); - //_Ntupe -> Branch("genRad", &_genRad, "genRad/F"); - _Ntupe -> Branch("genPosX", &_genPosX, "genPosX/F"); - _Ntupe -> Branch("genPosY", &_genPosY, "genPosY/F"); - _Ntupe -> Branch("genPosZ", &_genPosZ, "genPosZ/F"); - } - if (_mean < 0) throw cet::exception("RANGE") << "CaloCalibGun.mean must be non-negative "<< '\n'; - } - - - // to do on that one - // get the correct z position of the pipes - // check what these detector positions are - CaloCalibGun::~CaloCalibGun(){} - void CaloCalibGun::generate(GenParticleCollection& genParts) - { - //int nGen = _randPoissonQ.fire(); - int nGen = _mean; - // define the parameters of the pipes - // angle of large torus in degrees - double phi_lbd[5] = {161.34, 149.50, 139.50, 132.07, 125.39}; - // angle of small torus in degrees - double phi_sbd[5] = {84.63, 85.28, 85.79, 86.20, 86.53}; - // angle of the end point - double phi_end[5] = {3.96, 10.53, 15.80, 20.16, 23.84}; - // center position y of the small torus - double ysmall[5] = {432.2, 480.5, 524.3, 564.7, 602.5}; - // radius of small torus - double radSmTor = 41.0; - // first center position x of the small torus - double xsmall = 71.0; - // distance of the small torus center - double xdistance = 60.0; - // inner radius of the manifold - double rInnerManifold = 681.6; // 713.35 mm - 1.25 in (31.75 mm) - vector sign{-1.0, 1.0}; - - for (int ig=0; igdisk(nDisk).geomInfo().origin()-CLHEP::Hep3Vector(0,0,_cal->disk(nDisk).geomInfo().size().z()/2.0-_pipeRadius); - //cout << "The number of disk: " << nDisk << "; z position: " << _zPipeCenter << endl; - - double xpipe, ypipe, zpipe; - //Pick position - int xsn = rint(_randFlat.fire()); - int ysn = rint(_randFlat.fire()); - - double theta = _randFlat.fire() * 2.0 * piconst; - double pipeR = _pipeRadius * _randFlat.fire(); - zpipe = pipeR*sin(theta); - - double rtest = _randFlat.fire(); - int idx = int( std::lower_bound(_randomRad.begin(), _randomRad.end(), rtest) - _randomRad.begin()); - double radLgTor = _pipeTorRadius[idx]; - // modify to the full circle, Aug. 21, 2018 - // The phi range from 0 to half phi_lbd for the large torus - double phiLgTor = _randFlat.fire() * phi_lbd[idx] * piconst / 2. / 180.; - // x, y, z position of the large torus - double xLgTor = sign[xsn]*(radLgTor + pipeR*cos(theta))*cos(phiLgTor); - double yLgTor = sign[ysn]*(radLgTor + pipeR*cos(theta))*sin(phiLgTor); - // circulus (center) of the large torus - double circLgTor = radLgTor * phi_lbd[idx] * piconst / 2. / 180.; - - // The phi range for the small torus - double phiSmTor = piconst * (_randFlat.fire() * phi_sbd[idx] + 180. + phi_lbd[idx]/2. - phi_sbd[idx])/180.; - // x, y, z position of the small torus - double xSmTor = sign[xsn]*((radSmTor + pipeR*cos(theta))*cos(phiSmTor) + xsmall + xdistance * idx); - double ySmTor = sign[ysn]*((radSmTor + pipeR*cos(theta))*sin(phiSmTor) + ysmall[idx]); - // circulus (center) of the small torus - double circSmTor = radSmTor * piconst * phi_sbd[idx] / 180.; - - // strait pipe - //double xmanifold = rInnerManifold * cos(piconst * (90 - phi_end[idx])/180.); - double ymanifold = rInnerManifold * sin(piconst * (90 - phi_end[idx])/180.); - double xstart = xsmall + xdistance * idx - radSmTor * cos(piconst * phi_end[idx]/180.); - double ystart = ysmall[idx] + radSmTor * sin(piconst * phi_end[idx]/180.); - // height of the strait pipe - double hPipe = (ymanifold - ystart) / sin(piconst * (90 - phi_end[idx]) / 180.); - // a cylinder along y-axis - double y_center = _randFlat.fire() * hPipe; - double xPipe = pipeR * cos(theta); - double xStrait = sign[xsn] * (xPipe * cos(-piconst * phi_end[idx] / 180.) - y_center * sin(-piconst * phi_end[idx] / 180.) + xstart); - double yStrait = sign[ysn] * (xPipe * sin(-piconst * phi_end[idx] / 180.) + y_center * cos(-piconst * phi_end[idx] / 180.) + ystart); - double lenStrait = hPipe; - - double sample = _randFlat.fire(); - if(sample <= circLgTor / (circLgTor + circSmTor + lenStrait)) -// if(sample <= circLgTor / (circLgTor + circSmTor)) - { - xpipe = xLgTor; - ypipe = yLgTor; - } - else if(sample > circLgTor / (circLgTor + circSmTor + lenStrait) && sample <= (circLgTor + circSmTor) / (circLgTor + circSmTor + lenStrait)) -// else - { - xpipe = xSmTor; - ypipe = ySmTor; - } - else - { - xpipe = xStrait; - ypipe = yStrait; - } - - //cout << "===============================================" << endl; - //cout << "pipe center position: " << _zPipeCenter.x() << "; " << _zPipeCenter.y() << "; " << _zPipeCenter.z() << endl; - //cout << "X position: " << rad*cos(phi) << endl; - CLHEP::Hep3Vector pos(xpipe, ypipe, zpipe); - // shift the pipe to the front of the calorimeter disk 0 - pos +=_zPipeCenter; - //cout << "Positions: x = " << pos.x() << "; y = " << pos.y() << "; z = " << pos.z() << endl; - - //pick time - double time = _tmin + _randFlat.fire() * ( _tmax - _tmin ); - - //Pick energy and momentum vector - //double e = _elow + _flatmomentum.fire() * ( _ehi - _elow ); - double energy =_energy; - CLHEP::Hep3Vector p3 = _randomUnitSphere.fire(_energy); - //while (p3.cosTheta()<0) p3 = _randomUnitSphere.fire(_energy); - - //Set Four-momentum - CLHEP::HepLorentzVector mom(0,0,0,0); - mom.setPx( p3.x() ); - mom.setPy( p3.y() ); - mom.setPz( p3.z() ); - mom.setE( energy ); - - // Add the particle to the list. - genParts.push_back( GenParticle(PDGCode::gamma, GenId::CaloCalib, pos, mom, time)); - - // Fill histograms. - if ( _doHistograms) - { - _genErg = energy; - _genTime = time; - _genCos = p3.cosTheta(); - //_genPhi = phi; - //_genRad = rad; - _genPosX = pos.x(); - _genPosY = pos.y(); - _genPosZ = pos.z(); - } - if(_doHistograms) _Ntupe -> Fill(); - } - - - } -} From 8492e1d2847897da042db83024011a1aeb698b76 Mon Sep 17 00:00:00 2001 From: sophieMu2e Date: Wed, 2 Feb 2022 10:49:53 -0600 Subject: [PATCH 05/33] changes --- EventGenerator/src/EventGenerator_module.cc | 3 - EventGenerator/src/NewCaloCalibGun_module.cc | 77 ++++++++++---------- 2 files changed, 37 insertions(+), 43 deletions(-) diff --git a/EventGenerator/src/EventGenerator_module.cc b/EventGenerator/src/EventGenerator_module.cc index cb4bf3cf80..20f7c72b30 100644 --- a/EventGenerator/src/EventGenerator_module.cc +++ b/EventGenerator/src/EventGenerator_module.cc @@ -38,7 +38,6 @@ #include "Offline/EventGenerator/inc/CosmicFromTH2.hh" #include "Offline/EventGenerator/inc/FromG4BLFile.hh" #include "Offline/EventGenerator/inc/ParticleGun.hh" -#include "Offline/EventGenerator/inc/CaloCalibGun.hh" #include "Offline/SeedService/inc/SeedService.hh" // Includes from art and its toolchain. @@ -169,14 +168,12 @@ namespace mu2e { bool doCosmicDYB = config.getBool( "cosmicDYB.do", false ); bool doCosmicFromTH2 = config.getBool( "cosmicFromTH2.do", false ); bool doFromG4BLFile = config.getBool( "fromG4BLFile.do", false ); - bool doCaloCalibGun = config.getBool( "caloCalibGun.do", false ); // Instantiate generators for this run. if ( doParticleGun) _generators.push_back( GeneratorBasePtr( new ParticleGun( _engine, run, config)) ); if ( doCosmicDYB) _generators.push_back( GeneratorBasePtr( new CosmicDYB( _engine, run, config)) ); if ( doCosmicFromTH2) _generators.push_back( GeneratorBasePtr( new CosmicFromTH2( _engine, run, config)) ); if ( doFromG4BLFile) _generators.push_back( GeneratorBasePtr( new FromG4BLFile( _engine, run, config)) ); - if ( doCaloCalibGun) _generators.push_back( GeneratorBasePtr( new CaloCalibGun( _engine, run, config)) ); if ( _generators.size() == 0 ){ mf::LogWarning("CONTROL") diff --git a/EventGenerator/src/NewCaloCalibGun_module.cc b/EventGenerator/src/NewCaloCalibGun_module.cc index b68302e979..ae37693b06 100644 --- a/EventGenerator/src/NewCaloCalibGun_module.cc +++ b/EventGenerator/src/NewCaloCalibGun_module.cc @@ -1,4 +1,7 @@ -// Sophie Middleton, 2022 +// Simulate the photons coming from the pipe calibration source +// based on CaloCalibGun by Bertrand Echenard (2014), later edited by De Xu Lin (2018) +// Current module author: Sophie Middleton (2022) + // C++ includes. #include #include @@ -54,25 +57,24 @@ //ROOT Includes #include #include -const double piconst = Pi(); +const double piconst =CLHEP::pi; using namespace std; using namespace TMath; namespace mu2e { - //================================================================ class NewCaloCalibGun : public art::EDProducer { public: struct Config { using Name=fhicl::Name; using Comment=fhicl::Comment; - fhicl::Atom mean{Name("Mean"),1.}, + fhicl::Atom mean{Name("mean"),1}; fhicl::Atom energy{Name("PhotonEnergy"),6.13};//MeV - fhicl::Atom cosmin{Name("cosmin"),-1.}, - fhicl::Atom cosmin{Name("cosmin"),1.}, - fhicl::Atom phimin{Name("phimin"),0.}, - fhicl::Atom phimin{Name("phimax"), CLHEP::twopi }, - fhicl::Atom doHistograms{Name("doHistograms"), true }, + fhicl::Atom cosmin{Name("cosmin"),-1.}; + fhicl::Atom cosmax{Name("cosmax"),1.}; + fhicl::Atom phimin{Name("phimin"),0.}; + fhicl::Atom phimax{Name("phimax"), CLHEP::twopi }; + fhicl::Atom doHistograms{Name("doHistograms"), true }; }; using Parameters= art::EDProducer::Table; @@ -82,23 +84,24 @@ namespace mu2e { //---------------------------------------------------------------- private: - - ConditionsHandle accPar("ignored"); + GlobalConstantsHandle pdt; - // Default values for the start and end of the live window. + // Default values for the start and end of the beam pulse double _tmin = 0.; - double _tmax = accPar->deBuncherPeriod; + //ConditionsHandle accPar("ignored"); --> doesnt compile, why? + double _tmax = 1695;//accPar->deBuncherPeriod; + - double _mean; + unsigned _mean; double _energy; double _cosmin; double _cosmax; double _phimin; double _phimax; - art::RandomNumberGenerator::base_engine_t& engine; + art::RandomNumberGenerator::base_engine_t& _engine; CLHEP::RandFlat _randFlat; CLHEP::RandPoissonQ _randPoissonQ; RandomUnitSphere _randomUnitSphere; @@ -111,7 +114,6 @@ namespace mu2e { std::vector _randomRad; CLHEP::Hep3Vector _zPipeCenter; - bool _doHistograms; TTree* _Ntupe; float _genErg; @@ -120,24 +122,21 @@ namespace mu2e { float _genPosX; float _genPosY; float _genPosZ; - void addParticles(GenParticleCollection* output); - }; //================================================================ NewCaloCalibGun::NewCaloCalibGun(const Parameters& conf) : EDProducer{conf} - , _mean(config.getDouble("caloCalibGun.mean",1.)), + , _mean{conf().mean()} , _energy{conf().energy()} , _cosmin{conf().cosmin()} , _cosmax{conf().cosmax()} , _phimin{conf().phimin()} , _phimax{conf().phimax()} , _engine{createEngine(art::ServiceHandle()->getSeed())} - , _randFlat{_engine}, - , _randPoissonQ{_engine, std::abs(_mean)}, - , _randomUnitSphere{_engine, _cosmin, _cosmax, 0, CLHEP::twopi}, - + , _randFlat{_engine} + , _randPoissonQ{_engine, _mean*1.0} + , _randomUnitSphere{_engine, _cosmin, _cosmax, 0, CLHEP::twopi} { produces(); produces(); @@ -172,19 +171,15 @@ namespace mu2e { //================================================================ void NewCaloCalibGun::produce(art::Event& event) { - auto output{std::make_unique()}; - addParticles(output); - event.put(std::move(output)); - PrimaryParticle pp; + std::unique_ptr output(new GenParticleCollection); + + PrimaryParticle primaryParticles; MCTrajectoryCollection mctc; - event.put(std::make_unique(pp)); - event.put(std::make_unique(mctc)); - } - - void CaloCalibGun::addParticles(GenParticleCollection* output) - { - int nGen = _mean; - // define the parameters of the pipes + + auto output{std::make_unique()}; + unsigned int nGen = _mean; + //Define the parameters of the pipes: + // angle of large torus in degrees double phi_lbd[5] = {161.34, 149.50, 139.50, 132.07, 125.39}; // angle of small torus in degrees @@ -203,7 +198,7 @@ namespace mu2e { double rInnerManifold = 681.6; // 713.35 mm - 1.25 in (31.75 mm) vector sign{-1.0, 1.0}; - for (int ig=0; igemplace_back(PDGCode::gamma, GenId::CaloCalib, pos, mom, time); + event.put(std::move(output)); // Fill histograms. if ( _doHistograms) { @@ -303,6 +296,10 @@ namespace mu2e { } if(_doHistograms) _Ntupe -> Fill(); } + event.put(std::make_unique(primaryParticles)); + event.put(std::make_unique(mctc)); + } + } //================================================================ From 4b96f46d70964af1b5904b3d9fd0b3da66660055 Mon Sep 17 00:00:00 2001 From: sophieMu2e Date: Wed, 2 Feb 2022 13:47:54 -0600 Subject: [PATCH 06/33] works i.e. compiles --- EventGenerator/src/NewCaloCalibGun_module.cc | 41 +++++++------------- EventGenerator/src/SConscript | 16 ++++++-- 2 files changed, 26 insertions(+), 31 deletions(-) diff --git a/EventGenerator/src/NewCaloCalibGun_module.cc b/EventGenerator/src/NewCaloCalibGun_module.cc index ae37693b06..1b472859f3 100644 --- a/EventGenerator/src/NewCaloCalibGun_module.cc +++ b/EventGenerator/src/NewCaloCalibGun_module.cc @@ -6,7 +6,6 @@ #include #include #include -#include // Framework includes #include "art/Framework/Principal/Run.h" @@ -24,32 +23,27 @@ #include "Offline/GlobalConstantsService/inc/GlobalConstantsHandle.hh" #include "Offline/GlobalConstantsService/inc/ParticleDataTable.hh" #include "Offline/GeometryService/inc/GeomHandle.hh" -#include "Offline/GeometryService/inc/DetectorSystem.hh" + #include "Offline/DataProducts/inc/PDGCode.hh" #include "Offline/SeedService/inc/SeedService.hh" -#include "Offline/Mu2eUtilities/inc/RandomUnitSphere.hh" #include "Offline/MCDataProducts/inc/ProcessCode.hh" -#include "Offline/MCDataProducts/inc/StageParticle.hh" -#include "Offline/Mu2eUtilities/inc/simParticleList.hh" #include "Offline/CalorimeterGeom/inc/DiskCalorimeter.hh" #include "Offline/Mu2eUtilities/inc/RandomUnitSphere.hh" #include "Offline/MCDataProducts/inc/GenId.hh" #include "Offline/MCDataProducts/inc/GenParticle.hh" + //For primary: #include "Offline/MCDataProducts/inc/PrimaryParticle.hh" -#include "Offline/MCDataProducts/inc/StepPointMC.hh" #include "Offline/MCDataProducts/inc/MCTrajectoryCollection.hh" // Other external includes. #include "CLHEP/Random/RandFlat.h" -#include "CLHEP/Units/PhysicalConstants.h" #include "CLHEP/Vector/ThreeVector.h" #include "CLHEP/Vector/LorentzVector.h" #include "CLHEP/Random/RandomEngine.h" #include "CLHEP/Random/RandExponential.h" -#include "CLHEP/Units/PhysicalConstants.h" #include "CLHEP/Random/RandPoissonQ.h" -#include "CLHEP/Random/RandGeneral.h" + #include "fhiclcpp/types/Atom.h" #include "messagefacility/MessageLogger/MessageLogger.h" @@ -59,7 +53,7 @@ #include const double piconst =CLHEP::pi; using namespace std; -using namespace TMath; +using namespace mu2e; namespace mu2e { @@ -90,9 +84,8 @@ namespace mu2e { // Default values for the start and end of the beam pulse double _tmin = 0.; - //ConditionsHandle accPar("ignored"); --> doesnt compile, why? - double _tmax = 1695;//accPar->deBuncherPeriod; - + //ConditionsHandle accPar("ignored"); --> doesnt compile, why? TODO + double _tmax = 1695;//accPar->deBuncherPeriod; TODO unsigned _mean; double _energy; @@ -106,9 +99,8 @@ namespace mu2e { CLHEP::RandPoissonQ _randPoissonQ; RandomUnitSphere _randomUnitSphere; - const DetectorSystem *_detSys; - const DiskCalorimeter *_cal; - int _nPipes; + const DiskCalorimeter *_cal = &*GeomHandle(); + //int _nPipes; double _pipeRadius; std::vector _pipeTorRadius; std::vector _randomRad; @@ -142,13 +134,12 @@ namespace mu2e { produces(); produces (); - _detSys = &*GeomHandle(); - _cal = &*GeomHandle(); - _nPipes = _cal->caloInfo().getInt("nPipes"); + + //_nPipes = _cal->caloInfo().getInt("nPipes"); _pipeRadius = _cal->caloInfo().getDouble("pipeRadius"); _pipeTorRadius = _cal->caloInfo().getVDouble("pipeTorRadius"); _randomRad = _cal->caloInfo().getVDouble("pipeTorRadius"); - //_zPipeCenter = _cal->disk(0).geomInfo().origin()-CLHEP::Hep3Vector(0,0,_cal->disk(0).geomInfo().size().z()/2.0-_pipeRadius); + _zPipeCenter = _cal->disk(1).geomInfo().origin()-CLHEP::Hep3Vector(0,0,_cal->disk(1).geomInfo().size().z()/2.0-_pipeRadius); // we normalize to the volume of the pipe (proportional to 2*pi*R if they have all the same radius) to draw a // random number from which to generate the photons double sumR(0); @@ -172,11 +163,9 @@ namespace mu2e { //================================================================ void NewCaloCalibGun::produce(art::Event& event) { std::unique_ptr output(new GenParticleCollection); - PrimaryParticle primaryParticles; MCTrajectoryCollection mctc; - auto output{std::make_unique()}; unsigned int nGen = _mean; //Define the parameters of the pipes: @@ -198,11 +187,11 @@ namespace mu2e { double rInnerManifold = 681.6; // 713.35 mm - 1.25 in (31.75 mm) vector sign{-1.0, 1.0}; - for (unsigned int ig=0; igdisk(nDisk).geomInfo().origin()-CLHEP::Hep3Vector(0,0,_cal->disk(nDisk).geomInfo().size().z()/2.0-_pipeRadius); + //int nDisk = 1; + //_zPipeCenter = _cal->disk(nDisk).geomInfo().origin()-CLHEP::Hep3Vector(0,0,_cal->disk(nDisk).geomInfo().size().z()/2.0-_pipeRadius); double xpipe, ypipe, zpipe; //Pick position @@ -300,8 +289,6 @@ namespace mu2e { event.put(std::make_unique(mctc)); } - } - //================================================================ } // namespace mu2e diff --git a/EventGenerator/src/SConscript b/EventGenerator/src/SConscript index 106b78edf2..56ae47a69d 100644 --- a/EventGenerator/src/SConscript +++ b/EventGenerator/src/SConscript @@ -17,18 +17,25 @@ crylib = os.environ['CRY_LIB'] rootlibs = env['ROOTLIBS'] mainlib = helper.make_mainlib ( [ + 'mu2e_GlobalConstantsService_GlobalConstantsService_service', + 'mu2e_GlobalConstantsService', + 'mu2e_GeometryService', + 'mu2e_ConditionsService', + 'mu2e_CalorimeterGeom', + 'mu2e_TrackerGeom', + 'mu2e_CosmicRayShieldGeom', + 'mu2e_GeomPrimitives', + 'mu2e_ConfigTools', + 'mu2e_Mu2eInterfaces', + 'mu2e_GeneralUtilities', 'mu2e_GlobalConstantsService', 'mu2e_Mu2eUtilities', - 'mu2e_ConditionsService', - 'mu2e_GeometryService', - 'mu2e_CalorimeterGeom', 'mu2e_ExtinctionMonitorFNAL_Geometry', 'mu2e_ProductionTargetGeom', 'mu2e_StoppingTargetGeom', 'mu2e_MCDataProducts', 'mu2e_RecoDataProducts', 'mu2e_Mu2eInterfaces', - 'mu2e_GlobalConstantsService', 'mu2e_DataProducts', 'mu2e_ConfigTools', 'mu2e_GeneralUtilities', @@ -68,6 +75,7 @@ helper.make_plugins( [ mainlib, 'mu2e_ProductionTargetGeom', 'mu2e_ProtonBeamDumpGeom', 'mu2e_MCDataProducts', + 'mu2e_CalorimeterGeom', 'mu2e_Mu2eInterfaces', 'mu2e_DataProducts', 'mu2e_ConfigTools', From 99e9731af100d0fc7e90b2f022c67c529c9ceddc Mon Sep 17 00:00:00 2001 From: sophieMu2e Date: Wed, 2 Feb 2022 14:01:16 -0600 Subject: [PATCH 07/33] cleaned --- EventGenerator/src/NewCaloCalibGun_module.cc | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/EventGenerator/src/NewCaloCalibGun_module.cc b/EventGenerator/src/NewCaloCalibGun_module.cc index 1b472859f3..f4a7e20873 100644 --- a/EventGenerator/src/NewCaloCalibGun_module.cc +++ b/EventGenerator/src/NewCaloCalibGun_module.cc @@ -68,6 +68,8 @@ namespace mu2e { fhicl::Atom cosmax{Name("cosmax"),1.}; fhicl::Atom phimin{Name("phimin"),0.}; fhicl::Atom phimax{Name("phimax"), CLHEP::twopi }; + fhicl::Atom tmin{Name("tmin"),0.}; + fhicl::Atom tmax{Name("tmax"),1694.}; fhicl::Atom doHistograms{Name("doHistograms"), true }; }; @@ -78,14 +80,6 @@ namespace mu2e { //---------------------------------------------------------------- private: - - - GlobalConstantsHandle pdt; - - // Default values for the start and end of the beam pulse - double _tmin = 0.; - //ConditionsHandle accPar("ignored"); --> doesnt compile, why? TODO - double _tmax = 1695;//accPar->deBuncherPeriod; TODO unsigned _mean; double _energy; @@ -93,6 +87,8 @@ namespace mu2e { double _cosmax; double _phimin; double _phimax; + double _tmin; + double _tmax; art::RandomNumberGenerator::base_engine_t& _engine; CLHEP::RandFlat _randFlat; @@ -134,7 +130,6 @@ namespace mu2e { produces(); produces (); - //_nPipes = _cal->caloInfo().getInt("nPipes"); _pipeRadius = _cal->caloInfo().getDouble("pipeRadius"); _pipeTorRadius = _cal->caloInfo().getVDouble("pipeTorRadius"); @@ -145,7 +140,7 @@ namespace mu2e { double sumR(0); std::for_each(_randomRad.begin(), _randomRad.end(), [&](double& d) {sumR+=d; d = sumR; }); std::for_each(_randomRad.begin(), _randomRad.end(), [&](double& d) {d /= sumR;}); - // Book histograms. + if ( _doHistograms ) { art::ServiceHandle tfs; From 582265ce21b56ae455e0cbcaee7fb3b0397ebe88 Mon Sep 17 00:00:00 2001 From: sophieMu2e Date: Wed, 2 Feb 2022 16:16:29 -0600 Subject: [PATCH 08/33] works --- EventGenerator/fcl/prolog.fcl | 11 ++++++++ EventGenerator/src/NewCaloCalibGun_module.cc | 29 ++++++++++++-------- 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/EventGenerator/fcl/prolog.fcl b/EventGenerator/fcl/prolog.fcl index 5295392abf..774f153114 100644 --- a/EventGenerator/fcl/prolog.fcl +++ b/EventGenerator/fcl/prolog.fcl @@ -133,6 +133,17 @@ CaloTBGun : { module_type : CaloTBGun } + +NewCaloCalibGun : { + module_type : NewCaloCalibGun + cosmin : -1.0 + cosmax : 1.0 + phimin : 0.0 + phimax : 2.0 + tmin : 500. + tmax : 1694. + doHistograms: true +} # Save state of random numbers at the start of each event # the module is defined in art/Framework/Modules diff --git a/EventGenerator/src/NewCaloCalibGun_module.cc b/EventGenerator/src/NewCaloCalibGun_module.cc index f4a7e20873..685c35085d 100644 --- a/EventGenerator/src/NewCaloCalibGun_module.cc +++ b/EventGenerator/src/NewCaloCalibGun_module.cc @@ -95,7 +95,7 @@ namespace mu2e { CLHEP::RandPoissonQ _randPoissonQ; RandomUnitSphere _randomUnitSphere; - const DiskCalorimeter *_cal = &*GeomHandle(); + const DiskCalorimeter *_cal; //int _nPipes; double _pipeRadius; std::vector _pipeTorRadius; @@ -121,25 +121,17 @@ namespace mu2e { , _cosmax{conf().cosmax()} , _phimin{conf().phimin()} , _phimax{conf().phimax()} + , _tmin{conf().tmin()} + , _tmax{conf().tmax()} , _engine{createEngine(art::ServiceHandle()->getSeed())} , _randFlat{_engine} , _randPoissonQ{_engine, _mean*1.0} , _randomUnitSphere{_engine, _cosmin, _cosmax, 0, CLHEP::twopi} { + std::cout<<" Entering NewCaloCalibGun "<(); produces(); produces (); - - //_nPipes = _cal->caloInfo().getInt("nPipes"); - _pipeRadius = _cal->caloInfo().getDouble("pipeRadius"); - _pipeTorRadius = _cal->caloInfo().getVDouble("pipeTorRadius"); - _randomRad = _cal->caloInfo().getVDouble("pipeTorRadius"); - _zPipeCenter = _cal->disk(1).geomInfo().origin()-CLHEP::Hep3Vector(0,0,_cal->disk(1).geomInfo().size().z()/2.0-_pipeRadius); - // we normalize to the volume of the pipe (proportional to 2*pi*R if they have all the same radius) to draw a - // random number from which to generate the photons - double sumR(0); - std::for_each(_randomRad.begin(), _randomRad.end(), [&](double& d) {sumR+=d; d = sumR; }); - std::for_each(_randomRad.begin(), _randomRad.end(), [&](double& d) {d /= sumR;}); if ( _doHistograms ) { @@ -157,10 +149,22 @@ namespace mu2e { //================================================================ void NewCaloCalibGun::produce(art::Event& event) { + std::cout<<" Entering NewCaloCalibGun produces "< output(new GenParticleCollection); PrimaryParticle primaryParticles; MCTrajectoryCollection mctc; + _cal = &*GeomHandle(); + //_nPipes = _cal->caloInfo().getInt("nPipes"); + _pipeRadius = _cal->caloInfo().getDouble("pipeRadius"); + _pipeTorRadius = _cal->caloInfo().getVDouble("pipeTorRadius"); + _randomRad = _cal->caloInfo().getVDouble("pipeTorRadius"); + _zPipeCenter = _cal->disk(1).geomInfo().origin()-CLHEP::Hep3Vector(0,0,_cal->disk(1).geomInfo().size().z()/2.0-_pipeRadius);//disk =1 + // we normalize to the volume of the pipe (proportional to 2*pi*R if they have all the same radius) to draw a random number from which to generate the photons TODO - is this used? + double sumR(0); + std::for_each(_randomRad.begin(), _randomRad.end(), [&](double& d) {sumR+=d; d = sumR; }); + std::for_each(_randomRad.begin(), _randomRad.end(), [&](double& d) {d /= sumR;}); + unsigned int nGen = _mean; //Define the parameters of the pipes: @@ -282,6 +286,7 @@ namespace mu2e { } event.put(std::make_unique(primaryParticles)); event.put(std::make_unique(mctc)); + std::cout<<" Leaving NewCaloCalibGun produces"< Date: Wed, 2 Feb 2022 16:25:09 -0600 Subject: [PATCH 09/33] cleaned up includes --- EventGenerator/src/NewCaloCalibGun_module.cc | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/EventGenerator/src/NewCaloCalibGun_module.cc b/EventGenerator/src/NewCaloCalibGun_module.cc index 685c35085d..658e751858 100644 --- a/EventGenerator/src/NewCaloCalibGun_module.cc +++ b/EventGenerator/src/NewCaloCalibGun_module.cc @@ -1,5 +1,5 @@ // Simulate the photons coming from the pipe calibration source -// based on CaloCalibGun by Bertrand Echenard (2014), later edited by De Xu Lin (2018) +// based on CaloCalibGun orginally written by Bertrand Echenard (2014) // Current module author: Sophie Middleton (2022) // C++ includes. @@ -18,12 +18,7 @@ #include "art/Framework/Services/Registry/ServiceHandle.h" // Mu2e includes -#include "Offline/ConditionsService/inc/AcceleratorParams.hh" -#include "Offline/ConditionsService/inc/ConditionsHandle.hh" -#include "Offline/GlobalConstantsService/inc/GlobalConstantsHandle.hh" -#include "Offline/GlobalConstantsService/inc/ParticleDataTable.hh" #include "Offline/GeometryService/inc/GeomHandle.hh" - #include "Offline/DataProducts/inc/PDGCode.hh" #include "Offline/SeedService/inc/SeedService.hh" #include "Offline/MCDataProducts/inc/ProcessCode.hh" @@ -31,10 +26,8 @@ #include "Offline/Mu2eUtilities/inc/RandomUnitSphere.hh" #include "Offline/MCDataProducts/inc/GenId.hh" #include "Offline/MCDataProducts/inc/GenParticle.hh" - -//For primary: #include "Offline/MCDataProducts/inc/PrimaryParticle.hh" -#include "Offline/MCDataProducts/inc/MCTrajectoryCollection.hh" +#include "Offline/MCDataProducts/inc/MCTrajectoryCollection.hh" //TODO - is this needed? // Other external includes. #include "CLHEP/Random/RandFlat.h" @@ -112,7 +105,6 @@ namespace mu2e { float _genPosZ; }; - //================================================================ NewCaloCalibGun::NewCaloCalibGun(const Parameters& conf) : EDProducer{conf} , _mean{conf().mean()} @@ -128,7 +120,6 @@ namespace mu2e { , _randPoissonQ{_engine, _mean*1.0} , _randomUnitSphere{_engine, _cosmin, _cosmax, 0, CLHEP::twopi} { - std::cout<<" Entering NewCaloCalibGun "<(); produces(); produces (); @@ -149,7 +140,6 @@ namespace mu2e { //================================================================ void NewCaloCalibGun::produce(art::Event& event) { - std::cout<<" Entering NewCaloCalibGun produces "< output(new GenParticleCollection); PrimaryParticle primaryParticles; MCTrajectoryCollection mctc; @@ -286,7 +276,6 @@ namespace mu2e { } event.put(std::make_unique(primaryParticles)); event.put(std::make_unique(mctc)); - std::cout<<" Leaving NewCaloCalibGun produces"< Date: Thu, 3 Feb 2022 08:16:18 -0600 Subject: [PATCH 10/33] changed name --- CaloMC/fcl/RunCaloCalibGun.fcl | 96 +++++++++++++++++++ EventGenerator/fcl/prolog.fcl | 4 +- ...ibGun_module.cc => CaloCalibGun_module.cc} | 10 +- 3 files changed, 103 insertions(+), 7 deletions(-) create mode 100644 CaloMC/fcl/RunCaloCalibGun.fcl rename EventGenerator/src/{NewCaloCalibGun_module.cc => CaloCalibGun_module.cc} (97%) diff --git a/CaloMC/fcl/RunCaloCalibGun.fcl b/CaloMC/fcl/RunCaloCalibGun.fcl new file mode 100644 index 0000000000..2e854c5c8a --- /dev/null +++ b/CaloMC/fcl/RunCaloCalibGun.fcl @@ -0,0 +1,96 @@ +// Driver FCL for the calocalibration (Reconstruct and truth) +#include "fcl/minimalMessageService.fcl" +#include "fcl/standardProducers.fcl" +#include "fcl/standardServices.fcl" +#include "CaloMC/fcl/prolog.fcl" +#include "CaloReco/fcl/prolog.fcl" +#include "CaloCluster/fcl/prolog.fcl" +#include "CommonMC/fcl/prolog.fcl" +#include "EventGenerator/fcl/prolog.fcl" +#include "Production/JobConfig/digitize/prolog.fcl" +process_name: CaloCalibExample + +source: { + module_type: EmptyEvent + maxEvents : 1000 +} + + +services : @local::Services.SimAndReco +services.TFileService : { fileName : "nts.owner.CaloCalib.version.sequencer.root" } +services.SeedService.baseSeed : 99 +services.SeedService.maxUniqueEngines : 20 + +physics: { + + producers: { + + generate: { + module_type : CaloCalibGun + cosmin : -1.0 + cosmax : 1.0 + phimin : 0.0 + phimax : 2.0 + tmin : 500. + tmax : 1694. + doHistograms: true + } + + g4run : @local::g4run + + protonTimeMap : { module_type : GenerateProtonTimes } + muonTimeMap : { module_type : GenerateMuonLife } + EWMProducer : { module_type : EventWindowMarkerProducer } + FindMCPrimary : { module_type : FindMCPrimary }//@local::CommonMC.FindMCPrimary + @table::EventGenerator.producers + @table::Digitize.producers + @table::CommonMC.producers + @table::CaloMC.producers + @table::CaloReco.producers + @table::CaloCluster.producers + @table::CaloMC.TruthProducers + + } + + filters: { + @table::Digitize.filters + } + + analyzers: { + + CaloExample: { + module_type : CaloExample + caloHitCollection : CaloHitMaker + caloClusterCollection : CaloClusterMaker + caloHitTruth : CaloHitTruthMatch + vdCollection : virtualdetector + caloClusterTruth : CaloClusterTruthMatch + + } + + } + + p1: [ generate, g4run, protonTimeMap, muonTimeMap, EWMProducer, + @sequence::CaloMC.StepSim, + @sequence::CommonMC.DigiSim, + @sequence::CaloMC.DigiSim, + @sequence::CaloReco.Reco, + @sequence::CaloCluster.Reco, + @sequence::CaloMC.TruthMatch + ] + + e1: [CaloExample] + + trigger_paths: [p1] + end_paths: [e1] +} + +physics.producers.CaloHitTruthMatch.primaryParticle : "generate" +physics.producers.FindMCPrimary.PrimaryProcess : "CaloCalib" + +physics.producers.EWMProducer.SpillType : 0 +physics.producers.muonTimeMap.applyToGenIds : [ "StoppedParticleReactionGun", "dioTail", "ExternalRMC", "InternalRMC", + "MuCapProtonGenTool", "MuCapDeuteronGenTool", "DIOGenTool", "MuCapNeutronGenTool", "MuCapPhotonGenTool", "MuCapGammaRayGenTool" ] +physics.producers.protonTimeMap.ignoredGenIds : ["unknown", "particleGun", "cosmicToy", "cosmicDYB", "cosmic", "CosmicCRY", "pbarFlat", "CosmicCORSIKA"] + +physics.producers.CaloShowerStepFromStepPt.physVolInfoInput : "g4run" diff --git a/EventGenerator/fcl/prolog.fcl b/EventGenerator/fcl/prolog.fcl index 774f153114..320632df1a 100644 --- a/EventGenerator/fcl/prolog.fcl +++ b/EventGenerator/fcl/prolog.fcl @@ -134,8 +134,8 @@ CaloTBGun : { } -NewCaloCalibGun : { - module_type : NewCaloCalibGun +CaloCalibGun : { + module_type : CaloCalibGun cosmin : -1.0 cosmax : 1.0 phimin : 0.0 diff --git a/EventGenerator/src/NewCaloCalibGun_module.cc b/EventGenerator/src/CaloCalibGun_module.cc similarity index 97% rename from EventGenerator/src/NewCaloCalibGun_module.cc rename to EventGenerator/src/CaloCalibGun_module.cc index 658e751858..28ef4b9e37 100644 --- a/EventGenerator/src/NewCaloCalibGun_module.cc +++ b/EventGenerator/src/CaloCalibGun_module.cc @@ -50,7 +50,7 @@ using namespace mu2e; namespace mu2e { - class NewCaloCalibGun : public art::EDProducer { + class CaloCalibGun : public art::EDProducer { public: struct Config { using Name=fhicl::Name; @@ -67,7 +67,7 @@ namespace mu2e { }; using Parameters= art::EDProducer::Table; - explicit NewCaloCalibGun(const Parameters& conf); + explicit CaloCalibGun(const Parameters& conf); virtual void produce(art::Event& event) override; @@ -105,7 +105,7 @@ namespace mu2e { float _genPosZ; }; - NewCaloCalibGun::NewCaloCalibGun(const Parameters& conf) + CaloCalibGun::CaloCalibGun(const Parameters& conf) : EDProducer{conf} , _mean{conf().mean()} , _energy{conf().energy()} @@ -139,7 +139,7 @@ namespace mu2e { } //================================================================ - void NewCaloCalibGun::produce(art::Event& event) { + void CaloCalibGun::produce(art::Event& event) { std::unique_ptr output(new GenParticleCollection); PrimaryParticle primaryParticles; MCTrajectoryCollection mctc; @@ -281,4 +281,4 @@ namespace mu2e { //================================================================ } // namespace mu2e -DEFINE_ART_MODULE(mu2e::NewCaloCalibGun); +DEFINE_ART_MODULE(mu2e::CaloCalibGun); From 584132606143fae169ae3a17a3bc4c77ecf28fd5 Mon Sep 17 00:00:00 2001 From: sophieMu2e Date: Thu, 3 Feb 2022 08:28:19 -0600 Subject: [PATCH 11/33] starting new analyzer --- Analyses/src/CaloCalibAna_module.cc | 488 ++++++++++++++++++ CaloDiag/src/CaloExample_module.cc | 743 ++++++++++++++-------------- CaloMC/fcl/RunCaloCalibGun.fcl | 2 +- 3 files changed, 857 insertions(+), 376 deletions(-) create mode 100644 Analyses/src/CaloCalibAna_module.cc diff --git a/Analyses/src/CaloCalibAna_module.cc b/Analyses/src/CaloCalibAna_module.cc new file mode 100644 index 0000000000..2323b7a73f --- /dev/null +++ b/Analyses/src/CaloCalibAna_module.cc @@ -0,0 +1,488 @@ +// +// An EDAnalyzer module that reads back the hits created by the calorimeter and produces an ntuple +// +#include "art/Framework/Core/EDAnalyzer.h" +#include "art/Framework/Core/ModuleMacros.h" +#include "art/Framework/Principal/Event.h" +#include "art/Framework/Principal/Run.h" +#include "art_root_io/TFileService.h" +#include "art/Framework/Principal/Handle.h" +#include "art/Framework/Principal/Selector.h" +#include "art/Framework/Principal/Provenance.h" +#include "cetlib_except/exception.h" +#include "fhiclcpp/types/Atom.h" +#include "fhiclcpp/types/Sequence.h" +#include "messagefacility/MessageLogger/MessageLogger.h" +#include "canvas/Utilities/InputTag.h" + +#include "Offline/GlobalConstantsService/inc/GlobalConstantsHandle.hh" +#include "Offline/GlobalConstantsService/inc/ParticleDataTable.hh" +#include "Offline/GlobalConstantsService/inc/unknownPDGIdName.hh" +#include "Offline/ConditionsService/inc/AcceleratorParams.hh" +#include "Offline/ConditionsService/inc/ConditionsHandle.hh" + +#include "Offline/CalorimeterGeom/inc/Calorimeter.hh" +#include "Offline/CalorimeterGeom/inc/DiskCalorimeter.hh" +#include "Offline/GeometryService/inc/GeomHandle.hh" +#include "Offline/GeometryService/inc/GeometryService.hh" +#include "Offline/GeometryService/inc/VirtualDetector.hh" + +#include "Offline/CaloCluster/inc/ClusterUtils.hh" +#include "Offline/DataProducts/inc/VirtualDetectorId.hh" +#include "Offline/MCDataProducts/inc/GenParticle.hh" +#include "Offline/MCDataProducts/inc/SimParticle.hh" +#include "Offline/MCDataProducts/inc/GenId.hh" +#include "Offline/MCDataProducts/inc/StepPointMC.hh" +#include "Offline/MCDataProducts/inc/CaloMCTruthAssns.hh" +#include "Offline/RecoDataProducts/inc/CaloHit.hh" +#include "Offline/RecoDataProducts/inc/CaloCluster.hh" + +#include "TDirectory.h" +#include "TNtuple.h" +#include "TTree.h" +#include "TH2F.h" +#include "TH1F.h" + + +namespace +{ + constexpr int ntupLen = 16384; +} + + +namespace mu2e { + + class CaloCalibAna : public art::EDAnalyzer { + + public: + struct Config + { + using Name = fhicl::Name; + using Comment = fhicl::Comment; + fhicl::Atom vdCollection { Name("vdCollection"), Comment("Virtual detector collection name") }; + fhicl::Atom caloHitCollection { Name("caloHitCollection"), Comment("Calo Hit collection name") }; + fhicl::Atom caloClusterCollection { Name("caloClusterCollection"), Comment("Calo cluster collection name") }; + fhicl::Atom caloHitTruth { Name("caloHitTruth"), Comment("CaloHit truth name") }; + fhicl::Atom caloClusterTruth { Name("caloClusterTruth"), Comment("caloCluster truth name") }; + fhicl::Atom diagLevel { Name("diagLevel"), Comment("Diag Level"),0 }; + }; + + explicit CaloCalibAna(const art::EDAnalyzer::Table& config); + virtual ~CaloCalibAna() {} + + virtual void beginJob(); + virtual void endJob() {}; + virtual void analyze(const art::Event& e); + + + private: + art::InputTag virtualDetectorTag_; + art::InputTag caloHitTag_; + art::InputTag caloClusterTag_; + art::InputTag caloHitTruthTag_; + art::InputTag caloClusterTruthTag_; + int diagLevel_; + int nProcess_; + + + TH1F *hcryE_,*hcryT_,*hcryX_,*hcryY_,*hcryZ_; + TH1F *hcluE_,*hcluT_,*hcluX_,*hcluY_,*hcluZ_,*hcluE_1Et,*hcluE_1E9,*hcluE_1E25,*hcluE_F; + TH2F *hxy_,*hECE,*hCryEEMC_,*hCryTTMC_,*hCluEEMC_,*hCluTTMC_,*hCryEEMC2_; + + TTree* Ntup_; + int _evt,_run; + + int nHits_,cryId_[ntupLen],crySectionId_[ntupLen],crySimIdx_[ntupLen],crySimLen_[ntupLen]; + float cryEtot_,cryTime_[ntupLen],cryEdep_[ntupLen],cryEdepErr_[ntupLen],cryPosX_[ntupLen],cryPosY_[ntupLen],cryPosZ_[ntupLen],_cryLeak[ntupLen]; + + int nSimHit_,crySimId_[ntupLen],crySimPdgId_[ntupLen],crySimCrCode_[ntupLen],crySimGenIdx_[ntupLen],cryConv_[ntupLen]; + float crySimMom_[ntupLen],crySimStartX_[ntupLen],crySimStartY_[ntupLen],crySimStartZ_[ntupLen],crySimStartT_[ntupLen]; + float crySimTime_[ntupLen],crySimEdep_[ntupLen],cryTimeErr_[ntupLen],cryT1_[ntupLen],cryT2_[ntupLen],cryT1Err_[ntupLen],cryT2Err_[ntupLen]; + + int nCluster_,nCluSim_,cluNcrys_[ntupLen]; + float cluEnergy_[ntupLen],cluEnergyErr_[ntupLen],cluTime_[ntupLen],cluTimeErr_[ntupLen],cluCogX_[ntupLen],cluCogY_[ntupLen], + cluCogZ_[ntupLen],cluE1_[ntupLen],cluE9_[ntupLen],cluE25_[ntupLen],cluSecMom_[ntupLen]; + int cluSplit_[ntupLen],cluConv_[ntupLen],cluSimIdx_[ntupLen],cluSimLen_[ntupLen]; + std::vector > cluList_; + + int cluSimId_[ntupLen],cluSimPdgId_[ntupLen],cluSimGenId_[ntupLen],cluSimGenPdg_[ntupLen],cluSimCrCode_[ntupLen]; + float cluSimMom_[ntupLen],cluSimMom2_[ntupLen],cluSimPosX_[ntupLen],cluSimPosY_[ntupLen],cluSimPosZ_[ntupLen],cluSimStartX_[ntupLen], + cluSimStartY_[ntupLen],cluSimStartZ_[ntupLen],cluSimTime_[ntupLen],cluSimEdep_[ntupLen]; + + int nVd_,vdId_[ntupLen],vdPdgId_[ntupLen],vdGenId_[ntupLen],vdGenIdx_[ntupLen]; + float vdTime_[ntupLen],vdPosX_[ntupLen],vdPosY_[ntupLen],vdPosZ_[ntupLen],vdMom_[ntupLen],vdMomX_[ntupLen],vdMomY_[ntupLen],vdMomZ_[ntupLen]; + }; + + + CaloCalibAna::CaloCalibAna(const art::EDAnalyzer::Table& config) : + EDAnalyzer{config}, + virtualDetectorTag_ (config().vdCollection()), + caloHitTag_ (config().caloHitCollection()), + caloClusterTag_ (config().caloClusterCollection()), + caloHitTruthTag_ (config().caloHitTruth()), + caloClusterTruthTag_(config().caloClusterTruth()), + diagLevel_ (config().diagLevel()), + nProcess_(0), + Ntup_(0) + {} + + void CaloCalibAna::beginJob(){ + + art::ServiceHandle tfs; + + Ntup_ = tfs->make("Calo", "Calo"); + + Ntup_->Branch("evt", &_evt , "evt/I"); + Ntup_->Branch("run", &_run , "run/I"); + Ntup_->Branch("cryEtot", &cryEtot_ , "cryEtot/F"); + + Ntup_->Branch("nCry", &nHits_ , "nCry/I"); + Ntup_->Branch("cryId", &cryId_ , "cryId[nCry]/I"); + Ntup_->Branch("crySectionId", &crySectionId_, "crySectionId[nCry]/I"); + Ntup_->Branch("cryPosX", &cryPosX_ , "cryPosX[nCry]/F"); + Ntup_->Branch("cryPosY", &cryPosY_ , "cryPosY[nCry]/F"); + Ntup_->Branch("cryPosZ", &cryPosZ_ , "cryPosZ[nCry]/F"); + Ntup_->Branch("cryEdep", &cryEdep_ , "cryEdep[nCry]/F"); + Ntup_->Branch("cryEdepErr", &cryEdepErr_ , "cryEdepErr[nCry]/F"); + Ntup_->Branch("cryTime", &cryTime_ , "cryTime[nCry]/F"); + Ntup_->Branch("cryTimeErr", &cryTimeErr_ , "cryTimeErr[nCry]/F"); + Ntup_->Branch("cryT1", &cryT1_ , "cryT1[nCry]/F"); + Ntup_->Branch("cryT2", &cryT2_ , "cryT2[nCry]/F"); + Ntup_->Branch("cryT1Err", &cryT1Err_ , "cryT1Err[nCry]/F"); + Ntup_->Branch("cryT2Err", &cryT2Err_ , "cryT2Err[nCry]/F"); + Ntup_->Branch("cryConv", &cryConv_ , "cryConv[nCry]/I"); + + Ntup_->Branch("crySimIdx", &crySimIdx_ , "crySimIdx[nCry]/I"); + Ntup_->Branch("crySimLen", &crySimLen_ , "crySimLen[nCry]/I"); + Ntup_->Branch("nSim", &nSimHit_ , "nSim/I"); + Ntup_->Branch("simId", &crySimId_ , "simId[nSim]/I"); + Ntup_->Branch("simPdgId", &crySimPdgId_ , "simPdgId[nSim]/I"); + Ntup_->Branch("simCrCode", &crySimCrCode_ ,"simCrCode[nSim]/I"); + Ntup_->Branch("simMom", &crySimMom_ , "simMom[nSim]/F"); + Ntup_->Branch("simStartX", &crySimStartX_ ,"simStartX[nSim]/F"); + Ntup_->Branch("simStartY", &crySimStartY_ ,"simStartY[nSim]/F"); + Ntup_->Branch("simStartZ", &crySimStartZ_ ,"simStartZ[nSim]/F"); + Ntup_->Branch("simStartT", &crySimStartT_ ,"simStartT[nSim]/F"); + Ntup_->Branch("simTime", &crySimTime_ , "simTime[nSim]/F"); + Ntup_->Branch("simEdep", &crySimEdep_ , "simEdep[nSim]/F"); + Ntup_->Branch("simGenIdx", &crySimGenIdx_ ,"simGenIdx[nSim]/I"); + + Ntup_->Branch("nCluster", &nCluster_ , "nCluster/I"); + Ntup_->Branch("cluEnergy", &cluEnergy_ , "cluEnergy[nCluster]/F"); + Ntup_->Branch("cluEnergyErr", &cluEnergyErr_ ,"cluEnergyErr[nCluster]/F"); + Ntup_->Branch("cluTime", &cluTime_ , "cluTime[nCluster]/F"); + Ntup_->Branch("cluTimeErr", &cluTimeErr_ , "cluTimeErr[nCluster]/F"); + Ntup_->Branch("cluCogX", &cluCogX_ , "cluCogX[nCluster]/F"); + Ntup_->Branch("cluCogY", &cluCogY_ , "cluCogY[nCluster]/F"); + Ntup_->Branch("cluCogZ", &cluCogZ_ , "cluCogZ[nCluster]/F"); + Ntup_->Branch("cluNcrys", &cluNcrys_ , "cluNcrys[nCluster]/I"); + Ntup_->Branch("cluE1", &cluE1_ , "cluE1[nCluster]/F"); + Ntup_->Branch("cluE9", &cluE9_ , "cluE9[nCluster]/F"); + Ntup_->Branch("cluE25", &cluE25_ , "cluE25[nCluster]/F"); + Ntup_->Branch("cluSecMom", &cluSecMom_ , "cluSecMom[nCluster]/F"); + Ntup_->Branch("cluSplit", &cluSplit_ , "cluSplit[nCluster]/I"); + Ntup_->Branch("cluConv", &cluConv_ , "cluConv[nCluster]/I"); + Ntup_->Branch("cluSimIdx", &cluSimIdx_ , "cluSimIdx[nCluster]/I"); + Ntup_->Branch("cluSimLen", &cluSimLen_ , "cluSimLen[nCluster]/I"); + Ntup_->Branch("cluList", &cluList_); + + Ntup_->Branch("nCluSim", &nCluSim_ , "nCluSim/I"); + Ntup_->Branch("cluSimId", &cluSimId_ , "cluSimId[nCluSim]/I"); + Ntup_->Branch("cluSimPdgId", &cluSimPdgId_ , "cluSimPdgId[nCluSim]/I"); + Ntup_->Branch("cluSimGenId", &cluSimGenId_ , "cluSimGenId[nCluSim]/I"); + Ntup_->Branch("cluSimGenPdg", &cluSimGenPdg_, "cluSimGenPdg[nCluSim]/I"); + Ntup_->Branch("cluSimCrCode", &cluSimCrCode_ ,"cluSimCrCode[nCluSim]/I"); + Ntup_->Branch("cluSimMom", &cluSimMom_ , "cluSimMom[nCluSim]/F"); + Ntup_->Branch("cluSimMom2", &cluSimMom2_ , "cluSimMom2[nCluSim]/F"); + Ntup_->Branch("cluSimPosX", &cluSimPosX_ , "cluSimPosX[nCluSim]/F"); + Ntup_->Branch("cluSimPosY", &cluSimPosY_ , "cluSimPosY[nCluSim]/F"); + Ntup_->Branch("cluSimPosZ", &cluSimPosZ_ , "cluSimPosZ[nCluSim]/F"); + Ntup_->Branch("cluSimStartX", &cluSimStartX_ ,"cluSimStartX[nCluSim]/F"); + Ntup_->Branch("cluSimStartY", &cluSimStartY_ ,"cluSimStartY[nCluSim]/F"); + Ntup_->Branch("cluSimStartZ", &cluSimStartZ_ ,"cluSimStartZ[nCluSim]/F"); + Ntup_->Branch("cluSimTime", &cluSimTime_ , "cluSimTime[nCluSim]/F"); + Ntup_->Branch("cluSimEdep", &cluSimEdep_ , "cluSimEdep[nCluSim]/F"); + + Ntup_->Branch("nVd", &nVd_ , "nVd/I"); + Ntup_->Branch("vdId", &vdId_ , "vdId[nVd]/I"); + Ntup_->Branch("vdPdgId", &vdPdgId_ , "vdPdgId[nVd]/I"); + Ntup_->Branch("vdGenId", &vdGenId_ , "vdGenId[nVd]/I"); + Ntup_->Branch("vdMom", &vdMom_ , "vdMom[nVd]/F"); + Ntup_->Branch("vdMomX", &vdMomX_ , "vdMomX[nVd]/F"); + Ntup_->Branch("vdMomY", &vdMomY_ , "vdMomY[nVd]/F"); + Ntup_->Branch("vdMomZ", &vdMomZ_ , "vdMomZ[nVd]/F"); + Ntup_->Branch("vdPosX", &vdPosX_ , "vdPosX[nVd]/F"); + Ntup_->Branch("vdPosY", &vdPosY_ , "vdPosY[nVd]/F"); + Ntup_->Branch("vdPosZ", &vdPosZ_ , "vdPosZ[nVd]/F"); + Ntup_->Branch("vdTime", &vdTime_ , "vdTime[nVd]/F"); + Ntup_->Branch("vdGenIdx", &vdGenIdx_ , "vdGenIdx[nVd]/I"); + + + hcryE_ = tfs->make("cryEdep", "Energy deposited / crystal", 100, 0., 50. ); + hcryT_ = tfs->make("cryTime", "Time of crystal hit", 100, 0., 2000. ); + hcryX_ = tfs->make("cryX", "X coord of crystal hit", 100, 300., 700. ); + hcryY_ = tfs->make("cryY", "Y coord of crystal hit", 100, 300., 700. ); + hcryZ_ = tfs->make("cryZ", "Z coord of crystal hit", 100,11000., 13000.); + hcluE_ = tfs->make("cluEdep", "Energy deposited / cluster", 150, 0., 150. ); + hcluT_ = tfs->make("cluTime", "Time of clustal hit", 100, 0., 2000. ); + hcluX_ = tfs->make("cluX", "X coord of cluster hit", 100, 300., 700. ); + hcluY_ = tfs->make("cluY", "Y coord of cluster hit", 100, 300., 700. ); + hcluZ_ = tfs->make("cluZ", "Z coord of cluster hit", 100,11000., 13000.); + hcluE_1Et = tfs->make("cluE1Et", "E1/Etot", 100, 0., 1.1 ); + hcluE_1E9 = tfs->make("cluE1E9", "E1/E9", 100, 0., 1.1 ); + hcluE_1E25 = tfs->make("cluE1E25", "E1/E25", 100, 0., 1.1 ); + hxy_ = tfs->make("cryxy", "cry XY", 350,-700,700,350,-700,700 ); + hCryEEMC_ = tfs->make("cryEEMC", "cry energy reco vs Energy MC", 50, 0, 50, 50, 0, 50 ); + hCryEEMC2_ = tfs->make("cryEEMC2", "cry energy reco vs Energy MC", 50, 0, 50, 50, 0, 50 ); + hCryTTMC_ = tfs->make("cryTTMC", "cry time reco vs Time MC", 100, 0, 2000, 100, 0, 2000 ); + hCluEEMC_ = tfs->make("cluEEMC", "clu energy reco vs Energy MC", 150, 0, 150, 150, 0, 150 ); + hCluTTMC_ = tfs->make("cluTTMC", "clu time reco vs Time MC", 100, 0, 2000, 100, 0, 2000 ); + + } + + void CaloCalibAna::analyze(const art::Event& event){ + ++nProcess_; + if (nProcess_%10==0 && diagLevel_ > 0) std::cout<<"Processing event from CaloCalibAna = "< geom; + if (!geom->hasElement() ) return; + const Calorimeter& cal = *(GeomHandle()); + + //Calorimeter crystal hits (average from readouts) + art::Handle CaloHitsHandle; + event.getByLabel(caloHitTag_, CaloHitsHandle); + const CaloHitCollection& CaloHits(*CaloHitsHandle); + + //Calorimeter clusters + art::Handle caloClustersHandle; + event.getByLabel(caloClusterTag_, caloClustersHandle); + const CaloClusterCollection& caloClusters(*caloClustersHandle); + + //Virtual detector hits + art::Handle vdhits; + event.getByLabel(virtualDetectorTag_,vdhits); + + //Calo digi truth assignment + art::Handle caloHitMCHandle; + event.getByLabel(caloHitTruthTag_, caloHitMCHandle); + const CaloHitMCCollection& caloHitTruth(*caloHitMCHandle); + + //Calo cluster truth assignment + art::Handle caloClusterMCHandle; + event.getByLabel(caloClusterTruthTag_, caloClusterMCHandle); + const CaloClusterMCCollection& caloClusterTruth(*caloClusterMCHandle); + + + _evt = event.id().event(); + _run = event.run(); + + if (diagLevel_ == 3){std::cout << "processing event in calo_example " << nProcess_ << " run and event = " << _run << " " << _evt << std::endl;} + + //-------------------------- Do calorimeter hits -------------------------------- + + nHits_ = nSimHit_ = 0; + cryEtot_ = 0.0; + + for (unsigned int ic=0; iccreationCode() == ProcessCode::mu2eCeMinusEndpoint) isConversion=true; + } + + constexpr float invalid(999.0); + float cryT1(invalid),cryT2(invalid),cryT1Err(invalid),cryT2Err(invalid); + if (hit.recoCaloDigis().size()>1) + { + int idx0 = cal.caloIDMapper().SiPMIdx(hit.recoCaloDigis().at(0)->SiPMID()); + int idx1 = cal.caloIDMapper().SiPMIdx(hit.recoCaloDigis().at(1)->SiPMID()); + cryT1 = hit.recoCaloDigis().at(idx0)->time(); + cryT2 = hit.recoCaloDigis().at(idx1)->time(); + cryT1Err = hit.recoCaloDigis().at(idx0)->timeErr(); + cryT2Err = hit.recoCaloDigis().at(idx1)->timeErr(); + } + + cryId_[nHits_] = hit.crystalID(); + crySectionId_[nHits_] = diskId; + cryEdep_[nHits_] = hit.energyDep(); + cryEdepErr_[nHits_] = hit.energyDepErr(); + cryTime_[nHits_] = hit.time(); + cryTimeErr_[nHits_] = hit.timeErr(); + cryT1_[nHits_] = cryT1; + cryT2_[nHits_] = cryT2; + cryT1Err_[nHits_] = cryT1Err; + cryT2Err_[nHits_] = cryT2Err; + cryPosX_[nHits_] = crystalPos.x(); + cryPosY_[nHits_] = crystalPos.y(); + cryPosZ_[nHits_] = crystalPos.z(); + cryConv_[nHits_] = isConversion ? 1 : 0; + cryEtot_ += hit.energyDep(); + + crySimIdx_[nHits_] = nSimHit_; + crySimLen_[nHits_] = eDepMCs.size(); + + double sumEdepMC(0),edepTime(0); + for (unsigned i=0;i< eDepMCs.size();++i) + { + const auto& eDepMC = eDepMCs[i]; + + auto parent(eDepMC.sim()); + while (parent->hasParent()) parent = parent->parent(); + int genId=-1; + if (parent->genParticle()) genId = parent->genParticle()->generatorId().id(); + + crySimId_[nSimHit_] = eDepMC.sim()->id().asInt(); + crySimPdgId_[nSimHit_] = eDepMC.sim()->pdgId(); + crySimCrCode_[nSimHit_] = eDepMC.sim()->creationCode(); + crySimTime_[nSimHit_] = eDepMC.time(); + crySimEdep_[nSimHit_] = eDepMC.energyDep(); + crySimMom_[nSimHit_] = eDepMC.momentumIn(); + crySimStartX_[nSimHit_] = parent->startPosition().x(); + crySimStartY_[nSimHit_] = parent->startPosition().y(); + crySimStartZ_[nSimHit_] = parent->startPosition().z(); + crySimStartT_[nSimHit_] = parent->startGlobalTime(); + crySimGenIdx_[nSimHit_] = genId; + ++nSimHit_; + + sumEdepMC += eDepMC.energyDep(); + if (edepTime<1) edepTime = eDepMC.time(); + } + ++nHits_; + + hcryE_->Fill(hit.energyDep()); + hcryT_->Fill(hit.time()); + hcryX_->Fill(crystalPos.x()); + hcryY_->Fill(crystalPos.y()); + hcryZ_->Fill(crystalPos.z()); + hxy_->Fill(crystalPos.x(),crystalPos.y(),hit.energyDep()); + hCryEEMC_->Fill(hit.energyDep(), sumEdepMC); + hCryTTMC_->Fill(hit.time(), edepTime); + if (edepTime<1) hCryEEMC2_->Fill(hit.energyDep(), sumEdepMC); + } + + //-------------------------- Do clusters -------------------------------- + nCluster_ = nCluSim_ = 0; + cluList_.clear(); + for (unsigned int ic=0; ic cryList; + for (auto cryPtr : cluster.caloHitsPtrVector()) cryList.push_back(std::distance(&CaloHits.at(0),cryPtr.get())); + + ClusterUtils cluUtil(cal, cluster); + auto cog = cluUtil.cog3Vector(); + + const auto eDepMCs = caloClusterTruth[ic].energyDeposits(); + + bool isConversion(false); + for (auto& edep : eDepMCs) + { + if (edep.sim()->creationCode() == ProcessCode::mu2eCeMinusEndpoint) isConversion=true; + } + + cluEnergy_[nCluster_] = cluster.energyDep(); + cluEnergyErr_[nCluster_] = cluster.energyDepErr(); + cluTime_[nCluster_] = cluster.time(); + cluTimeErr_[nCluster_] = cluster.timeErr(); + cluNcrys_[nCluster_] = cluster.size(); + cluCogX_[nCluster_] = cluster.cog3Vector().x(); //in disk FF frame + cluCogY_[nCluster_] = cluster.cog3Vector().y(); + cluCogZ_[nCluster_] = cluster.cog3Vector().z(); + cluE1_[nCluster_] = cluUtil.e1(); + cluE9_[nCluster_] = cluUtil.e9(); + cluE25_[nCluster_] = cluUtil.e25(); + cluSecMom_[nCluster_] = cluUtil.secondMoment(); + cluSplit_[nCluster_] = cluster.isSplit(); + cluConv_[nCluster_] = isConversion; + cluList_.push_back(cryList); + + cluSimIdx_[nCluster_] = nCluSim_; + cluSimLen_[nCluster_] = eDepMCs.size(); + + double sumEdepMC(0),edepTime(0); + for (unsigned i=0;i< eDepMCs.size();++i) + { + const auto& eDepMC = eDepMCs[i]; + art::Ptr sim = eDepMC.sim(); + + art::Ptr smother(sim); + while (smother->hasParent() && !smother->genParticle() ) smother = smother->parent(); + int genId=-1; + if (smother->genParticle()) genId = smother->genParticle()->generatorId().id(); + int genPdg=-1; + if (smother->genParticle()) genPdg = smother->genParticle()->pdgId(); + + cluSimId_[nCluSim_] = sim->id().asInt(); + cluSimPdgId_[nCluSim_] = sim->pdgId(); + cluSimCrCode_[nCluSim_] = sim->creationCode(); + cluSimGenId_[nCluSim_] = genId; + cluSimGenPdg_[nCluSim_] = genPdg; + cluSimTime_[nCluSim_] = eDepMC.time(); + cluSimEdep_[nCluSim_] = eDepMC.energyDep(); + cluSimMom_[nCluSim_] = eDepMC.momentumIn(); + cluSimStartX_[nCluSim_] = sim->startPosition().x(); // in disk FF frame + cluSimStartY_[nCluSim_] = sim->startPosition().y(); + cluSimStartZ_[nCluSim_] = sim->startPosition().z(); + ++nCluSim_; + + sumEdepMC += eDepMC.energyDep(); + if (edepTime<1) edepTime=eDepMC.time(); + } + ++nCluster_; + + hcluE_->Fill(cluster.energyDep()); + hcluT_->Fill(cluster.time()); + hcluX_->Fill(cluster.cog3Vector().x()); + hcluY_->Fill(cluster.cog3Vector().y()); + hcluZ_->Fill(cluster.cog3Vector().z()); + hCluEEMC_->Fill(cluster.energyDep(), sumEdepMC); + hCluTTMC_->Fill(cluster.time(), edepTime); + } + + + //-------------------------- Do virtual detectors -------------------------------- + //73/74/77/78 front back inner outer edges disk 0 + //75/76/79/80 front back inner outer edges disk 1 + nVd_ = 0; + if (vdhits.isValid()) + { + for (auto iter=vdhits->begin(), ie=vdhits->end(); iter!=ie; ++iter) + { + const StepPointMC& hit = *iter; + + if ( (hit.volumeId()VirtualDetectorId::EMC_Disk_1_EdgeOut) + && hit.volumeId() != VirtualDetectorId::TT_Back) continue; + + CLHEP::Hep3Vector VDPos = cal.geomUtil().mu2eToTracker(hit.position()); + + vdId_[nVd_] = hit.volumeId(); + vdPdgId_[nVd_] = hit.simParticle()->pdgId(); + vdGenId_[nVd_] = (hit.simParticle()->genParticle()) ? hit.simParticle()->genParticle()->generatorId().id() : -1; + vdTime_[nVd_] = hit.time(); + vdPosX_[nVd_] = VDPos.x(); //tracker frame + vdPosY_[nVd_] = VDPos.y(); + vdPosZ_[nVd_] = VDPos.z(); + vdMom_[nVd_] = hit.momentum().mag(); + vdMomX_[nVd_] = hit.momentum().x(); + vdMomY_[nVd_] = hit.momentum().y(); + vdMomZ_[nVd_] = hit.momentum().z(); + vdGenIdx_[nVd_] = hit.simParticle()->generatorIndex(); + ++nVd_; + } + } + Ntup_->Fill(); +} + + + +} + +DEFINE_ART_MODULE(mu2e::CaloCalibAna); diff --git a/CaloDiag/src/CaloExample_module.cc b/CaloDiag/src/CaloExample_module.cc index b25cdeda6c..2605f5c98b 100644 --- a/CaloDiag/src/CaloExample_module.cc +++ b/CaloDiag/src/CaloExample_module.cc @@ -52,200 +52,195 @@ namespace namespace mu2e { - class CaloExample : public art::EDAnalyzer { - - public: - struct Config - { - using Name = fhicl::Name; - using Comment = fhicl::Comment; - fhicl::Atom vdCollection { Name("vdCollection"), Comment("Virtual detector collection name") }; - fhicl::Atom caloHitCollection { Name("caloHitCollection"), Comment("Calo Hit collection name") }; - fhicl::Atom caloClusterCollection { Name("caloClusterCollection"), Comment("Calo cluster collection name") }; - fhicl::Atom caloHitTruth { Name("caloHitTruth"), Comment("CaloHit truth name") }; - fhicl::Atom caloClusterTruth { Name("caloClusterTruth"), Comment("caloCluster truth name") }; - fhicl::Atom diagLevel { Name("diagLevel"), Comment("Diag Level"),0 }; - }; - - explicit CaloExample(const art::EDAnalyzer::Table& config); - virtual ~CaloExample() {} - - virtual void beginJob(); - virtual void endJob() {}; - virtual void analyze(const art::Event& e); - - - private: - art::InputTag virtualDetectorTag_; - art::InputTag caloHitTag_; - art::InputTag caloClusterTag_; - art::InputTag caloHitTruthTag_; - art::InputTag caloClusterTruthTag_; - int diagLevel_; - int nProcess_; - - - - - TH1F *hcryE_,*hcryT_,*hcryX_,*hcryY_,*hcryZ_; - TH1F *hcluE_,*hcluT_,*hcluX_,*hcluY_,*hcluZ_,*hcluE_1Et,*hcluE_1E9,*hcluE_1E25,*hcluE_F; - TH2F *hxy_,*hECE,*hCryEEMC_,*hCryTTMC_,*hCluEEMC_,*hCluTTMC_,*hCryEEMC2_; - - TTree* Ntup_; - int _evt,_run; - - int nHits_,cryId_[ntupLen],crySectionId_[ntupLen],crySimIdx_[ntupLen],crySimLen_[ntupLen]; - float cryEtot_,cryTime_[ntupLen],cryEdep_[ntupLen],cryEdepErr_[ntupLen],cryPosX_[ntupLen],cryPosY_[ntupLen],cryPosZ_[ntupLen],_cryLeak[ntupLen]; - - int nSimHit_,crySimId_[ntupLen],crySimPdgId_[ntupLen],crySimCrCode_[ntupLen],crySimGenIdx_[ntupLen],cryConv_[ntupLen]; - float crySimMom_[ntupLen],crySimStartX_[ntupLen],crySimStartY_[ntupLen],crySimStartZ_[ntupLen],crySimStartT_[ntupLen]; - float crySimTime_[ntupLen],crySimEdep_[ntupLen],cryTimeErr_[ntupLen],cryT1_[ntupLen],cryT2_[ntupLen],cryT1Err_[ntupLen],cryT2Err_[ntupLen]; - - int nCluster_,nCluSim_,cluNcrys_[ntupLen]; - float cluEnergy_[ntupLen],cluEnergyErr_[ntupLen],cluTime_[ntupLen],cluTimeErr_[ntupLen],cluCogX_[ntupLen],cluCogY_[ntupLen], - cluCogZ_[ntupLen],cluE1_[ntupLen],cluE9_[ntupLen],cluE25_[ntupLen],cluSecMom_[ntupLen]; - int cluSplit_[ntupLen],cluConv_[ntupLen],cluSimIdx_[ntupLen],cluSimLen_[ntupLen]; - std::vector > cluList_; - - int cluSimId_[ntupLen],cluSimPdgId_[ntupLen],cluSimGenId_[ntupLen],cluSimGenPdg_[ntupLen],cluSimCrCode_[ntupLen]; - float cluSimMom_[ntupLen],cluSimMom2_[ntupLen],cluSimPosX_[ntupLen],cluSimPosY_[ntupLen],cluSimPosZ_[ntupLen],cluSimStartX_[ntupLen], - cluSimStartY_[ntupLen],cluSimStartZ_[ntupLen],cluSimTime_[ntupLen],cluSimEdep_[ntupLen]; - - int nVd_,vdId_[ntupLen],vdPdgId_[ntupLen],vdGenId_[ntupLen],vdGenIdx_[ntupLen]; - float vdTime_[ntupLen],vdPosX_[ntupLen],vdPosY_[ntupLen],vdPosZ_[ntupLen],vdMom_[ntupLen],vdMomX_[ntupLen],vdMomY_[ntupLen],vdMomZ_[ntupLen]; - }; - - - CaloExample::CaloExample(const art::EDAnalyzer::Table& config) : - EDAnalyzer{config}, - virtualDetectorTag_ (config().vdCollection()), - caloHitTag_ (config().caloHitCollection()), - caloClusterTag_ (config().caloClusterCollection()), - caloHitTruthTag_ (config().caloHitTruth()), - caloClusterTruthTag_(config().caloClusterTruth()), - diagLevel_ (config().diagLevel()), - nProcess_(0), - Ntup_(0) - {} - - void CaloExample::beginJob(){ - - art::ServiceHandle tfs; - - Ntup_ = tfs->make("Calo", "Calo"); - - Ntup_->Branch("evt", &_evt , "evt/I"); - Ntup_->Branch("run", &_run , "run/I"); - Ntup_->Branch("cryEtot", &cryEtot_ , "cryEtot/F"); - - Ntup_->Branch("nCry", &nHits_ , "nCry/I"); - Ntup_->Branch("cryId", &cryId_ , "cryId[nCry]/I"); - Ntup_->Branch("crySectionId", &crySectionId_, "crySectionId[nCry]/I"); - Ntup_->Branch("cryPosX", &cryPosX_ , "cryPosX[nCry]/F"); - Ntup_->Branch("cryPosY", &cryPosY_ , "cryPosY[nCry]/F"); - Ntup_->Branch("cryPosZ", &cryPosZ_ , "cryPosZ[nCry]/F"); - Ntup_->Branch("cryEdep", &cryEdep_ , "cryEdep[nCry]/F"); - Ntup_->Branch("cryEdepErr", &cryEdepErr_ , "cryEdepErr[nCry]/F"); - Ntup_->Branch("cryTime", &cryTime_ , "cryTime[nCry]/F"); - Ntup_->Branch("cryTimeErr", &cryTimeErr_ , "cryTimeErr[nCry]/F"); - Ntup_->Branch("cryT1", &cryT1_ , "cryT1[nCry]/F"); - Ntup_->Branch("cryT2", &cryT2_ , "cryT2[nCry]/F"); - Ntup_->Branch("cryT1Err", &cryT1Err_ , "cryT1Err[nCry]/F"); - Ntup_->Branch("cryT2Err", &cryT2Err_ , "cryT2Err[nCry]/F"); - Ntup_->Branch("cryConv", &cryConv_ , "cryConv[nCry]/I"); - - Ntup_->Branch("crySimIdx", &crySimIdx_ , "crySimIdx[nCry]/I"); - Ntup_->Branch("crySimLen", &crySimLen_ , "crySimLen[nCry]/I"); - Ntup_->Branch("nSim", &nSimHit_ , "nSim/I"); - Ntup_->Branch("simId", &crySimId_ , "simId[nSim]/I"); - Ntup_->Branch("simPdgId", &crySimPdgId_ , "simPdgId[nSim]/I"); - Ntup_->Branch("simCrCode", &crySimCrCode_ ,"simCrCode[nSim]/I"); - Ntup_->Branch("simMom", &crySimMom_ , "simMom[nSim]/F"); - Ntup_->Branch("simStartX", &crySimStartX_ ,"simStartX[nSim]/F"); - Ntup_->Branch("simStartY", &crySimStartY_ ,"simStartY[nSim]/F"); - Ntup_->Branch("simStartZ", &crySimStartZ_ ,"simStartZ[nSim]/F"); - Ntup_->Branch("simStartT", &crySimStartT_ ,"simStartT[nSim]/F"); - Ntup_->Branch("simTime", &crySimTime_ , "simTime[nSim]/F"); - Ntup_->Branch("simEdep", &crySimEdep_ , "simEdep[nSim]/F"); - Ntup_->Branch("simGenIdx", &crySimGenIdx_ ,"simGenIdx[nSim]/I"); - - Ntup_->Branch("nCluster", &nCluster_ , "nCluster/I"); - Ntup_->Branch("cluEnergy", &cluEnergy_ , "cluEnergy[nCluster]/F"); - Ntup_->Branch("cluEnergyErr", &cluEnergyErr_ ,"cluEnergyErr[nCluster]/F"); - Ntup_->Branch("cluTime", &cluTime_ , "cluTime[nCluster]/F"); - Ntup_->Branch("cluTimeErr", &cluTimeErr_ , "cluTimeErr[nCluster]/F"); - Ntup_->Branch("cluCogX", &cluCogX_ , "cluCogX[nCluster]/F"); - Ntup_->Branch("cluCogY", &cluCogY_ , "cluCogY[nCluster]/F"); - Ntup_->Branch("cluCogZ", &cluCogZ_ , "cluCogZ[nCluster]/F"); - Ntup_->Branch("cluNcrys", &cluNcrys_ , "cluNcrys[nCluster]/I"); - Ntup_->Branch("cluE1", &cluE1_ , "cluE1[nCluster]/F"); - Ntup_->Branch("cluE9", &cluE9_ , "cluE9[nCluster]/F"); - Ntup_->Branch("cluE25", &cluE25_ , "cluE25[nCluster]/F"); - Ntup_->Branch("cluSecMom", &cluSecMom_ , "cluSecMom[nCluster]/F"); - Ntup_->Branch("cluSplit", &cluSplit_ , "cluSplit[nCluster]/I"); - Ntup_->Branch("cluConv", &cluConv_ , "cluConv[nCluster]/I"); - Ntup_->Branch("cluSimIdx", &cluSimIdx_ , "cluSimIdx[nCluster]/I"); - Ntup_->Branch("cluSimLen", &cluSimLen_ , "cluSimLen[nCluster]/I"); - Ntup_->Branch("cluList", &cluList_); - - Ntup_->Branch("nCluSim", &nCluSim_ , "nCluSim/I"); - Ntup_->Branch("cluSimId", &cluSimId_ , "cluSimId[nCluSim]/I"); - Ntup_->Branch("cluSimPdgId", &cluSimPdgId_ , "cluSimPdgId[nCluSim]/I"); - Ntup_->Branch("cluSimGenId", &cluSimGenId_ , "cluSimGenId[nCluSim]/I"); - Ntup_->Branch("cluSimGenPdg", &cluSimGenPdg_, "cluSimGenPdg[nCluSim]/I"); - Ntup_->Branch("cluSimCrCode", &cluSimCrCode_ ,"cluSimCrCode[nCluSim]/I"); - Ntup_->Branch("cluSimMom", &cluSimMom_ , "cluSimMom[nCluSim]/F"); - Ntup_->Branch("cluSimMom2", &cluSimMom2_ , "cluSimMom2[nCluSim]/F"); - Ntup_->Branch("cluSimPosX", &cluSimPosX_ , "cluSimPosX[nCluSim]/F"); - Ntup_->Branch("cluSimPosY", &cluSimPosY_ , "cluSimPosY[nCluSim]/F"); - Ntup_->Branch("cluSimPosZ", &cluSimPosZ_ , "cluSimPosZ[nCluSim]/F"); - Ntup_->Branch("cluSimStartX", &cluSimStartX_ ,"cluSimStartX[nCluSim]/F"); - Ntup_->Branch("cluSimStartY", &cluSimStartY_ ,"cluSimStartY[nCluSim]/F"); - Ntup_->Branch("cluSimStartZ", &cluSimStartZ_ ,"cluSimStartZ[nCluSim]/F"); - Ntup_->Branch("cluSimTime", &cluSimTime_ , "cluSimTime[nCluSim]/F"); - Ntup_->Branch("cluSimEdep", &cluSimEdep_ , "cluSimEdep[nCluSim]/F"); - - Ntup_->Branch("nVd", &nVd_ , "nVd/I"); - Ntup_->Branch("vdId", &vdId_ , "vdId[nVd]/I"); - Ntup_->Branch("vdPdgId", &vdPdgId_ , "vdPdgId[nVd]/I"); - Ntup_->Branch("vdGenId", &vdGenId_ , "vdGenId[nVd]/I"); - Ntup_->Branch("vdMom", &vdMom_ , "vdMom[nVd]/F"); - Ntup_->Branch("vdMomX", &vdMomX_ , "vdMomX[nVd]/F"); - Ntup_->Branch("vdMomY", &vdMomY_ , "vdMomY[nVd]/F"); - Ntup_->Branch("vdMomZ", &vdMomZ_ , "vdMomZ[nVd]/F"); - Ntup_->Branch("vdPosX", &vdPosX_ , "vdPosX[nVd]/F"); - Ntup_->Branch("vdPosY", &vdPosY_ , "vdPosY[nVd]/F"); - Ntup_->Branch("vdPosZ", &vdPosZ_ , "vdPosZ[nVd]/F"); - Ntup_->Branch("vdTime", &vdTime_ , "vdTime[nVd]/F"); - Ntup_->Branch("vdGenIdx", &vdGenIdx_ , "vdGenIdx[nVd]/I"); - - - hcryE_ = tfs->make("cryEdep", "Energy deposited / crystal", 100, 0., 50. ); - hcryT_ = tfs->make("cryTime", "Time of crystal hit", 100, 0., 2000. ); - hcryX_ = tfs->make("cryX", "X coord of crystal hit", 100, 300., 700. ); - hcryY_ = tfs->make("cryY", "Y coord of crystal hit", 100, 300., 700. ); - hcryZ_ = tfs->make("cryZ", "Z coord of crystal hit", 100,11000., 13000.); - hcluE_ = tfs->make("cluEdep", "Energy deposited / cluster", 150, 0., 150. ); - hcluT_ = tfs->make("cluTime", "Time of clustal hit", 100, 0., 2000. ); - hcluX_ = tfs->make("cluX", "X coord of cluster hit", 100, 300., 700. ); - hcluY_ = tfs->make("cluY", "Y coord of cluster hit", 100, 300., 700. ); - hcluZ_ = tfs->make("cluZ", "Z coord of cluster hit", 100,11000., 13000.); - hcluE_1Et = tfs->make("cluE1Et", "E1/Etot", 100, 0., 1.1 ); - hcluE_1E9 = tfs->make("cluE1E9", "E1/E9", 100, 0., 1.1 ); - hcluE_1E25 = tfs->make("cluE1E25", "E1/E25", 100, 0., 1.1 ); - hxy_ = tfs->make("cryxy", "cry XY", 350,-700,700,350,-700,700 ); - hCryEEMC_ = tfs->make("cryEEMC", "cry energy reco vs Energy MC", 50, 0, 50, 50, 0, 50 ); - hCryEEMC2_ = tfs->make("cryEEMC2", "cry energy reco vs Energy MC", 50, 0, 50, 50, 0, 50 ); - hCryTTMC_ = tfs->make("cryTTMC", "cry time reco vs Time MC", 100, 0, 2000, 100, 0, 2000 ); - hCluEEMC_ = tfs->make("cluEEMC", "clu energy reco vs Energy MC", 150, 0, 150, 150, 0, 150 ); - hCluTTMC_ = tfs->make("cluTTMC", "clu time reco vs Time MC", 100, 0, 2000, 100, 0, 2000 ); - - } - - - - void CaloExample::analyze(const art::Event& event) - { + class CaloExample : public art::EDAnalyzer { + + public: + struct Config + { + using Name = fhicl::Name; + using Comment = fhicl::Comment; + fhicl::Atom vdCollection { Name("vdCollection"), Comment("Virtual detector collection name") }; + fhicl::Atom caloHitCollection { Name("caloHitCollection"), Comment("Calo Hit collection name") }; + fhicl::Atom caloClusterCollection { Name("caloClusterCollection"), Comment("Calo cluster collection name") }; + fhicl::Atom caloHitTruth { Name("caloHitTruth"), Comment("CaloHit truth name") }; + fhicl::Atom caloClusterTruth { Name("caloClusterTruth"), Comment("caloCluster truth name") }; + fhicl::Atom diagLevel { Name("diagLevel"), Comment("Diag Level"),0 }; + }; + + explicit CaloExample(const art::EDAnalyzer::Table& config); + virtual ~CaloExample() {} + + virtual void beginJob(); + virtual void endJob() {}; + virtual void analyze(const art::Event& e); + + + private: + art::InputTag virtualDetectorTag_; + art::InputTag caloHitTag_; + art::InputTag caloClusterTag_; + art::InputTag caloHitTruthTag_; + art::InputTag caloClusterTruthTag_; + int diagLevel_; + int nProcess_; + + + TH1F *hcryE_,*hcryT_,*hcryX_,*hcryY_,*hcryZ_; + TH1F *hcluE_,*hcluT_,*hcluX_,*hcluY_,*hcluZ_,*hcluE_1Et,*hcluE_1E9,*hcluE_1E25,*hcluE_F; + TH2F *hxy_,*hECE,*hCryEEMC_,*hCryTTMC_,*hCluEEMC_,*hCluTTMC_,*hCryEEMC2_; + + TTree* Ntup_; + int _evt,_run; + + int nHits_,cryId_[ntupLen],crySectionId_[ntupLen],crySimIdx_[ntupLen],crySimLen_[ntupLen]; + float cryEtot_,cryTime_[ntupLen],cryEdep_[ntupLen],cryEdepErr_[ntupLen],cryPosX_[ntupLen],cryPosY_[ntupLen],cryPosZ_[ntupLen],_cryLeak[ntupLen]; + + int nSimHit_,crySimId_[ntupLen],crySimPdgId_[ntupLen],crySimCrCode_[ntupLen],crySimGenIdx_[ntupLen],cryConv_[ntupLen]; + float crySimMom_[ntupLen],crySimStartX_[ntupLen],crySimStartY_[ntupLen],crySimStartZ_[ntupLen],crySimStartT_[ntupLen]; + float crySimTime_[ntupLen],crySimEdep_[ntupLen],cryTimeErr_[ntupLen],cryT1_[ntupLen],cryT2_[ntupLen],cryT1Err_[ntupLen],cryT2Err_[ntupLen]; + + int nCluster_,nCluSim_,cluNcrys_[ntupLen]; + float cluEnergy_[ntupLen],cluEnergyErr_[ntupLen],cluTime_[ntupLen],cluTimeErr_[ntupLen],cluCogX_[ntupLen],cluCogY_[ntupLen], + cluCogZ_[ntupLen],cluE1_[ntupLen],cluE9_[ntupLen],cluE25_[ntupLen],cluSecMom_[ntupLen]; + int cluSplit_[ntupLen],cluConv_[ntupLen],cluSimIdx_[ntupLen],cluSimLen_[ntupLen]; + std::vector > cluList_; + + int cluSimId_[ntupLen],cluSimPdgId_[ntupLen],cluSimGenId_[ntupLen],cluSimGenPdg_[ntupLen],cluSimCrCode_[ntupLen]; + float cluSimMom_[ntupLen],cluSimMom2_[ntupLen],cluSimPosX_[ntupLen],cluSimPosY_[ntupLen],cluSimPosZ_[ntupLen],cluSimStartX_[ntupLen], + cluSimStartY_[ntupLen],cluSimStartZ_[ntupLen],cluSimTime_[ntupLen],cluSimEdep_[ntupLen]; + + int nVd_,vdId_[ntupLen],vdPdgId_[ntupLen],vdGenId_[ntupLen],vdGenIdx_[ntupLen]; + float vdTime_[ntupLen],vdPosX_[ntupLen],vdPosY_[ntupLen],vdPosZ_[ntupLen],vdMom_[ntupLen],vdMomX_[ntupLen],vdMomY_[ntupLen],vdMomZ_[ntupLen]; + }; + + + CaloExample::CaloExample(const art::EDAnalyzer::Table& config) : + EDAnalyzer{config}, + virtualDetectorTag_ (config().vdCollection()), + caloHitTag_ (config().caloHitCollection()), + caloClusterTag_ (config().caloClusterCollection()), + caloHitTruthTag_ (config().caloHitTruth()), + caloClusterTruthTag_(config().caloClusterTruth()), + diagLevel_ (config().diagLevel()), + nProcess_(0), + Ntup_(0) + {} + + void CaloExample::beginJob(){ + + art::ServiceHandle tfs; + + Ntup_ = tfs->make("Calo", "Calo"); + + Ntup_->Branch("evt", &_evt , "evt/I"); + Ntup_->Branch("run", &_run , "run/I"); + Ntup_->Branch("cryEtot", &cryEtot_ , "cryEtot/F"); + + Ntup_->Branch("nCry", &nHits_ , "nCry/I"); + Ntup_->Branch("cryId", &cryId_ , "cryId[nCry]/I"); + Ntup_->Branch("crySectionId", &crySectionId_, "crySectionId[nCry]/I"); + Ntup_->Branch("cryPosX", &cryPosX_ , "cryPosX[nCry]/F"); + Ntup_->Branch("cryPosY", &cryPosY_ , "cryPosY[nCry]/F"); + Ntup_->Branch("cryPosZ", &cryPosZ_ , "cryPosZ[nCry]/F"); + Ntup_->Branch("cryEdep", &cryEdep_ , "cryEdep[nCry]/F"); + Ntup_->Branch("cryEdepErr", &cryEdepErr_ , "cryEdepErr[nCry]/F"); + Ntup_->Branch("cryTime", &cryTime_ , "cryTime[nCry]/F"); + Ntup_->Branch("cryTimeErr", &cryTimeErr_ , "cryTimeErr[nCry]/F"); + Ntup_->Branch("cryT1", &cryT1_ , "cryT1[nCry]/F"); + Ntup_->Branch("cryT2", &cryT2_ , "cryT2[nCry]/F"); + Ntup_->Branch("cryT1Err", &cryT1Err_ , "cryT1Err[nCry]/F"); + Ntup_->Branch("cryT2Err", &cryT2Err_ , "cryT2Err[nCry]/F"); + Ntup_->Branch("cryConv", &cryConv_ , "cryConv[nCry]/I"); + + Ntup_->Branch("crySimIdx", &crySimIdx_ , "crySimIdx[nCry]/I"); + Ntup_->Branch("crySimLen", &crySimLen_ , "crySimLen[nCry]/I"); + Ntup_->Branch("nSim", &nSimHit_ , "nSim/I"); + Ntup_->Branch("simId", &crySimId_ , "simId[nSim]/I"); + Ntup_->Branch("simPdgId", &crySimPdgId_ , "simPdgId[nSim]/I"); + Ntup_->Branch("simCrCode", &crySimCrCode_ ,"simCrCode[nSim]/I"); + Ntup_->Branch("simMom", &crySimMom_ , "simMom[nSim]/F"); + Ntup_->Branch("simStartX", &crySimStartX_ ,"simStartX[nSim]/F"); + Ntup_->Branch("simStartY", &crySimStartY_ ,"simStartY[nSim]/F"); + Ntup_->Branch("simStartZ", &crySimStartZ_ ,"simStartZ[nSim]/F"); + Ntup_->Branch("simStartT", &crySimStartT_ ,"simStartT[nSim]/F"); + Ntup_->Branch("simTime", &crySimTime_ , "simTime[nSim]/F"); + Ntup_->Branch("simEdep", &crySimEdep_ , "simEdep[nSim]/F"); + Ntup_->Branch("simGenIdx", &crySimGenIdx_ ,"simGenIdx[nSim]/I"); + + Ntup_->Branch("nCluster", &nCluster_ , "nCluster/I"); + Ntup_->Branch("cluEnergy", &cluEnergy_ , "cluEnergy[nCluster]/F"); + Ntup_->Branch("cluEnergyErr", &cluEnergyErr_ ,"cluEnergyErr[nCluster]/F"); + Ntup_->Branch("cluTime", &cluTime_ , "cluTime[nCluster]/F"); + Ntup_->Branch("cluTimeErr", &cluTimeErr_ , "cluTimeErr[nCluster]/F"); + Ntup_->Branch("cluCogX", &cluCogX_ , "cluCogX[nCluster]/F"); + Ntup_->Branch("cluCogY", &cluCogY_ , "cluCogY[nCluster]/F"); + Ntup_->Branch("cluCogZ", &cluCogZ_ , "cluCogZ[nCluster]/F"); + Ntup_->Branch("cluNcrys", &cluNcrys_ , "cluNcrys[nCluster]/I"); + Ntup_->Branch("cluE1", &cluE1_ , "cluE1[nCluster]/F"); + Ntup_->Branch("cluE9", &cluE9_ , "cluE9[nCluster]/F"); + Ntup_->Branch("cluE25", &cluE25_ , "cluE25[nCluster]/F"); + Ntup_->Branch("cluSecMom", &cluSecMom_ , "cluSecMom[nCluster]/F"); + Ntup_->Branch("cluSplit", &cluSplit_ , "cluSplit[nCluster]/I"); + Ntup_->Branch("cluConv", &cluConv_ , "cluConv[nCluster]/I"); + Ntup_->Branch("cluSimIdx", &cluSimIdx_ , "cluSimIdx[nCluster]/I"); + Ntup_->Branch("cluSimLen", &cluSimLen_ , "cluSimLen[nCluster]/I"); + Ntup_->Branch("cluList", &cluList_); + + Ntup_->Branch("nCluSim", &nCluSim_ , "nCluSim/I"); + Ntup_->Branch("cluSimId", &cluSimId_ , "cluSimId[nCluSim]/I"); + Ntup_->Branch("cluSimPdgId", &cluSimPdgId_ , "cluSimPdgId[nCluSim]/I"); + Ntup_->Branch("cluSimGenId", &cluSimGenId_ , "cluSimGenId[nCluSim]/I"); + Ntup_->Branch("cluSimGenPdg", &cluSimGenPdg_, "cluSimGenPdg[nCluSim]/I"); + Ntup_->Branch("cluSimCrCode", &cluSimCrCode_ ,"cluSimCrCode[nCluSim]/I"); + Ntup_->Branch("cluSimMom", &cluSimMom_ , "cluSimMom[nCluSim]/F"); + Ntup_->Branch("cluSimMom2", &cluSimMom2_ , "cluSimMom2[nCluSim]/F"); + Ntup_->Branch("cluSimPosX", &cluSimPosX_ , "cluSimPosX[nCluSim]/F"); + Ntup_->Branch("cluSimPosY", &cluSimPosY_ , "cluSimPosY[nCluSim]/F"); + Ntup_->Branch("cluSimPosZ", &cluSimPosZ_ , "cluSimPosZ[nCluSim]/F"); + Ntup_->Branch("cluSimStartX", &cluSimStartX_ ,"cluSimStartX[nCluSim]/F"); + Ntup_->Branch("cluSimStartY", &cluSimStartY_ ,"cluSimStartY[nCluSim]/F"); + Ntup_->Branch("cluSimStartZ", &cluSimStartZ_ ,"cluSimStartZ[nCluSim]/F"); + Ntup_->Branch("cluSimTime", &cluSimTime_ , "cluSimTime[nCluSim]/F"); + Ntup_->Branch("cluSimEdep", &cluSimEdep_ , "cluSimEdep[nCluSim]/F"); + + Ntup_->Branch("nVd", &nVd_ , "nVd/I"); + Ntup_->Branch("vdId", &vdId_ , "vdId[nVd]/I"); + Ntup_->Branch("vdPdgId", &vdPdgId_ , "vdPdgId[nVd]/I"); + Ntup_->Branch("vdGenId", &vdGenId_ , "vdGenId[nVd]/I"); + Ntup_->Branch("vdMom", &vdMom_ , "vdMom[nVd]/F"); + Ntup_->Branch("vdMomX", &vdMomX_ , "vdMomX[nVd]/F"); + Ntup_->Branch("vdMomY", &vdMomY_ , "vdMomY[nVd]/F"); + Ntup_->Branch("vdMomZ", &vdMomZ_ , "vdMomZ[nVd]/F"); + Ntup_->Branch("vdPosX", &vdPosX_ , "vdPosX[nVd]/F"); + Ntup_->Branch("vdPosY", &vdPosY_ , "vdPosY[nVd]/F"); + Ntup_->Branch("vdPosZ", &vdPosZ_ , "vdPosZ[nVd]/F"); + Ntup_->Branch("vdTime", &vdTime_ , "vdTime[nVd]/F"); + Ntup_->Branch("vdGenIdx", &vdGenIdx_ , "vdGenIdx[nVd]/I"); + + + hcryE_ = tfs->make("cryEdep", "Energy deposited / crystal", 100, 0., 50. ); + hcryT_ = tfs->make("cryTime", "Time of crystal hit", 100, 0., 2000. ); + hcryX_ = tfs->make("cryX", "X coord of crystal hit", 100, 300., 700. ); + hcryY_ = tfs->make("cryY", "Y coord of crystal hit", 100, 300., 700. ); + hcryZ_ = tfs->make("cryZ", "Z coord of crystal hit", 100,11000., 13000.); + hcluE_ = tfs->make("cluEdep", "Energy deposited / cluster", 150, 0., 150. ); + hcluT_ = tfs->make("cluTime", "Time of clustal hit", 100, 0., 2000. ); + hcluX_ = tfs->make("cluX", "X coord of cluster hit", 100, 300., 700. ); + hcluY_ = tfs->make("cluY", "Y coord of cluster hit", 100, 300., 700. ); + hcluZ_ = tfs->make("cluZ", "Z coord of cluster hit", 100,11000., 13000.); + hcluE_1Et = tfs->make("cluE1Et", "E1/Etot", 100, 0., 1.1 ); + hcluE_1E9 = tfs->make("cluE1E9", "E1/E9", 100, 0., 1.1 ); + hcluE_1E25 = tfs->make("cluE1E25", "E1/E25", 100, 0., 1.1 ); + hxy_ = tfs->make("cryxy", "cry XY", 350,-700,700,350,-700,700 ); + hCryEEMC_ = tfs->make("cryEEMC", "cry energy reco vs Energy MC", 50, 0, 50, 50, 0, 50 ); + hCryEEMC2_ = tfs->make("cryEEMC2", "cry energy reco vs Energy MC", 50, 0, 50, 50, 0, 50 ); + hCryTTMC_ = tfs->make("cryTTMC", "cry time reco vs Time MC", 100, 0, 2000, 100, 0, 2000 ); + hCluEEMC_ = tfs->make("cluEEMC", "clu energy reco vs Energy MC", 150, 0, 150, 150, 0, 150 ); + hCluTTMC_ = tfs->make("cluTTMC", "clu time reco vs Time MC", 100, 0, 2000, 100, 0, 2000 ); + + } + + void CaloExample::analyze(const art::Event& event){ ++nProcess_; if (nProcess_%10==0 && diagLevel_ > 0) std::cout<<"Processing event from CaloExample = "< caloHitMCHandle; event.getByLabel(caloHitTruthTag_, caloHitMCHandle); const CaloHitMCCollection& caloHitTruth(*caloHitMCHandle); - + //Calo cluster truth assignment art::Handle caloClusterMCHandle; event.getByLabel(caloClusterTruthTag_, caloClusterMCHandle); @@ -291,86 +286,86 @@ namespace mu2e { for (unsigned int ic=0; iccreationCode() == ProcessCode::mu2eCeMinusEndpoint) isConversion=true; - } - - constexpr float invalid(999.0); - float cryT1(invalid),cryT2(invalid),cryT1Err(invalid),cryT2Err(invalid); - if (hit.recoCaloDigis().size()>1) - { - int idx0 = cal.caloIDMapper().SiPMIdx(hit.recoCaloDigis().at(0)->SiPMID()); - int idx1 = cal.caloIDMapper().SiPMIdx(hit.recoCaloDigis().at(1)->SiPMID()); - cryT1 = hit.recoCaloDigis().at(idx0)->time(); - cryT2 = hit.recoCaloDigis().at(idx1)->time(); - cryT1Err = hit.recoCaloDigis().at(idx0)->timeErr(); - cryT2Err = hit.recoCaloDigis().at(idx1)->timeErr(); - } - - cryId_[nHits_] = hit.crystalID(); - crySectionId_[nHits_] = diskId; - cryEdep_[nHits_] = hit.energyDep(); - cryEdepErr_[nHits_] = hit.energyDepErr(); - cryTime_[nHits_] = hit.time(); - cryTimeErr_[nHits_] = hit.timeErr(); - cryT1_[nHits_] = cryT1; - cryT2_[nHits_] = cryT2; - cryT1Err_[nHits_] = cryT1Err; - cryT2Err_[nHits_] = cryT2Err; - cryPosX_[nHits_] = crystalPos.x(); - cryPosY_[nHits_] = crystalPos.y(); - cryPosZ_[nHits_] = crystalPos.z(); - cryConv_[nHits_] = isConversion ? 1 : 0; - cryEtot_ += hit.energyDep(); - - crySimIdx_[nHits_] = nSimHit_; - crySimLen_[nHits_] = eDepMCs.size(); - - double sumEdepMC(0),edepTime(0); - for (unsigned i=0;i< eDepMCs.size();++i) - { - const auto& eDepMC = eDepMCs[i]; - - auto parent(eDepMC.sim()); - while (parent->hasParent()) parent = parent->parent(); - int genId=-1; - if (parent->genParticle()) genId = parent->genParticle()->generatorId().id(); - - crySimId_[nSimHit_] = eDepMC.sim()->id().asInt(); - crySimPdgId_[nSimHit_] = eDepMC.sim()->pdgId(); - crySimCrCode_[nSimHit_] = eDepMC.sim()->creationCode(); - crySimTime_[nSimHit_] = eDepMC.time(); - crySimEdep_[nSimHit_] = eDepMC.energyDep(); - crySimMom_[nSimHit_] = eDepMC.momentumIn(); - crySimStartX_[nSimHit_] = parent->startPosition().x(); - crySimStartY_[nSimHit_] = parent->startPosition().y(); - crySimStartZ_[nSimHit_] = parent->startPosition().z(); - crySimStartT_[nSimHit_] = parent->startGlobalTime(); - crySimGenIdx_[nSimHit_] = genId; - ++nSimHit_; - - sumEdepMC += eDepMC.energyDep(); - if (edepTime<1) edepTime = eDepMC.time(); - } - ++nHits_; - - hcryE_->Fill(hit.energyDep()); - hcryT_->Fill(hit.time()); - hcryX_->Fill(crystalPos.x()); - hcryY_->Fill(crystalPos.y()); - hcryZ_->Fill(crystalPos.z()); - hxy_->Fill(crystalPos.x(),crystalPos.y(),hit.energyDep()); - hCryEEMC_->Fill(hit.energyDep(), sumEdepMC); - hCryTTMC_->Fill(hit.time(), edepTime); - if (edepTime<1) hCryEEMC2_->Fill(hit.energyDep(), sumEdepMC); + const CaloHit& hit = CaloHits.at(ic); + int diskId = cal.crystal(hit.crystalID()).diskID(); + CLHEP::Hep3Vector crystalPos = cal.geomUtil().mu2eToDiskFF(diskId,cal.crystal(hit.crystalID()).position()); //in disk FF frame + + const auto eDepMCs = caloHitTruth[ic].energyDeposits(); + + bool isConversion(false); + for (auto& edep : eDepMCs) + { + if (edep.sim()->creationCode() == ProcessCode::mu2eCeMinusEndpoint) isConversion=true; + } + + constexpr float invalid(999.0); + float cryT1(invalid),cryT2(invalid),cryT1Err(invalid),cryT2Err(invalid); + if (hit.recoCaloDigis().size()>1) + { + int idx0 = cal.caloIDMapper().SiPMIdx(hit.recoCaloDigis().at(0)->SiPMID()); + int idx1 = cal.caloIDMapper().SiPMIdx(hit.recoCaloDigis().at(1)->SiPMID()); + cryT1 = hit.recoCaloDigis().at(idx0)->time(); + cryT2 = hit.recoCaloDigis().at(idx1)->time(); + cryT1Err = hit.recoCaloDigis().at(idx0)->timeErr(); + cryT2Err = hit.recoCaloDigis().at(idx1)->timeErr(); + } + + cryId_[nHits_] = hit.crystalID(); + crySectionId_[nHits_] = diskId; + cryEdep_[nHits_] = hit.energyDep(); + cryEdepErr_[nHits_] = hit.energyDepErr(); + cryTime_[nHits_] = hit.time(); + cryTimeErr_[nHits_] = hit.timeErr(); + cryT1_[nHits_] = cryT1; + cryT2_[nHits_] = cryT2; + cryT1Err_[nHits_] = cryT1Err; + cryT2Err_[nHits_] = cryT2Err; + cryPosX_[nHits_] = crystalPos.x(); + cryPosY_[nHits_] = crystalPos.y(); + cryPosZ_[nHits_] = crystalPos.z(); + cryConv_[nHits_] = isConversion ? 1 : 0; + cryEtot_ += hit.energyDep(); + + crySimIdx_[nHits_] = nSimHit_; + crySimLen_[nHits_] = eDepMCs.size(); + + double sumEdepMC(0),edepTime(0); + for (unsigned i=0;i< eDepMCs.size();++i) + { + const auto& eDepMC = eDepMCs[i]; + + auto parent(eDepMC.sim()); + while (parent->hasParent()) parent = parent->parent(); + int genId=-1; + if (parent->genParticle()) genId = parent->genParticle()->generatorId().id(); + + crySimId_[nSimHit_] = eDepMC.sim()->id().asInt(); + crySimPdgId_[nSimHit_] = eDepMC.sim()->pdgId(); + crySimCrCode_[nSimHit_] = eDepMC.sim()->creationCode(); + crySimTime_[nSimHit_] = eDepMC.time(); + crySimEdep_[nSimHit_] = eDepMC.energyDep(); + crySimMom_[nSimHit_] = eDepMC.momentumIn(); + crySimStartX_[nSimHit_] = parent->startPosition().x(); + crySimStartY_[nSimHit_] = parent->startPosition().y(); + crySimStartZ_[nSimHit_] = parent->startPosition().z(); + crySimStartT_[nSimHit_] = parent->startGlobalTime(); + crySimGenIdx_[nSimHit_] = genId; + ++nSimHit_; + + sumEdepMC += eDepMC.energyDep(); + if (edepTime<1) edepTime = eDepMC.time(); + } + ++nHits_; + + hcryE_->Fill(hit.energyDep()); + hcryT_->Fill(hit.time()); + hcryX_->Fill(crystalPos.x()); + hcryY_->Fill(crystalPos.y()); + hcryZ_->Fill(crystalPos.z()); + hxy_->Fill(crystalPos.x(),crystalPos.y(),hit.energyDep()); + hCryEEMC_->Fill(hit.energyDep(), sumEdepMC); + hCryTTMC_->Fill(hit.time(), edepTime); + if (edepTime<1) hCryEEMC2_->Fill(hit.energyDep(), sumEdepMC); } //-------------------------- Do clusters -------------------------------- @@ -378,78 +373,78 @@ namespace mu2e { cluList_.clear(); for (unsigned int ic=0; ic cryList; - for (auto cryPtr : cluster.caloHitsPtrVector()) cryList.push_back(std::distance(&CaloHits.at(0),cryPtr.get())); - - ClusterUtils cluUtil(cal, cluster); - auto cog = cluUtil.cog3Vector(); - - const auto eDepMCs = caloClusterTruth[ic].energyDeposits(); - - bool isConversion(false); - for (auto& edep : eDepMCs) - { - if (edep.sim()->creationCode() == ProcessCode::mu2eCeMinusEndpoint) isConversion=true; - } - - cluEnergy_[nCluster_] = cluster.energyDep(); - cluEnergyErr_[nCluster_] = cluster.energyDepErr(); - cluTime_[nCluster_] = cluster.time(); - cluTimeErr_[nCluster_] = cluster.timeErr(); - cluNcrys_[nCluster_] = cluster.size(); - cluCogX_[nCluster_] = cluster.cog3Vector().x(); //in disk FF frame - cluCogY_[nCluster_] = cluster.cog3Vector().y(); - cluCogZ_[nCluster_] = cluster.cog3Vector().z(); - cluE1_[nCluster_] = cluUtil.e1(); - cluE9_[nCluster_] = cluUtil.e9(); - cluE25_[nCluster_] = cluUtil.e25(); - cluSecMom_[nCluster_] = cluUtil.secondMoment(); - cluSplit_[nCluster_] = cluster.isSplit(); - cluConv_[nCluster_] = isConversion; - cluList_.push_back(cryList); - - cluSimIdx_[nCluster_] = nCluSim_; - cluSimLen_[nCluster_] = eDepMCs.size(); - - double sumEdepMC(0),edepTime(0); - for (unsigned i=0;i< eDepMCs.size();++i) - { - const auto& eDepMC = eDepMCs[i]; - art::Ptr sim = eDepMC.sim(); - - art::Ptr smother(sim); - while (smother->hasParent() && !smother->genParticle() ) smother = smother->parent(); - int genId=-1; - if (smother->genParticle()) genId = smother->genParticle()->generatorId().id(); - int genPdg=-1; - if (smother->genParticle()) genPdg = smother->genParticle()->pdgId(); - - cluSimId_[nCluSim_] = sim->id().asInt(); - cluSimPdgId_[nCluSim_] = sim->pdgId(); - cluSimCrCode_[nCluSim_] = sim->creationCode(); - cluSimGenId_[nCluSim_] = genId; - cluSimGenPdg_[nCluSim_] = genPdg; - cluSimTime_[nCluSim_] = eDepMC.time(); - cluSimEdep_[nCluSim_] = eDepMC.energyDep(); - cluSimMom_[nCluSim_] = eDepMC.momentumIn(); - cluSimStartX_[nCluSim_] = sim->startPosition().x(); // in disk FF frame - cluSimStartY_[nCluSim_] = sim->startPosition().y(); - cluSimStartZ_[nCluSim_] = sim->startPosition().z(); - ++nCluSim_; - - sumEdepMC += eDepMC.energyDep(); - if (edepTime<1) edepTime=eDepMC.time(); - } - ++nCluster_; - - hcluE_->Fill(cluster.energyDep()); - hcluT_->Fill(cluster.time()); - hcluX_->Fill(cluster.cog3Vector().x()); - hcluY_->Fill(cluster.cog3Vector().y()); - hcluZ_->Fill(cluster.cog3Vector().z()); - hCluEEMC_->Fill(cluster.energyDep(), sumEdepMC); - hCluTTMC_->Fill(cluster.time(), edepTime); + const CaloCluster& cluster = caloClusters.at(ic); + std::vector cryList; + for (auto cryPtr : cluster.caloHitsPtrVector()) cryList.push_back(std::distance(&CaloHits.at(0),cryPtr.get())); + + ClusterUtils cluUtil(cal, cluster); + auto cog = cluUtil.cog3Vector(); + + const auto eDepMCs = caloClusterTruth[ic].energyDeposits(); + + bool isConversion(false); + for (auto& edep : eDepMCs) + { + if (edep.sim()->creationCode() == ProcessCode::mu2eCeMinusEndpoint) isConversion=true; + } + + cluEnergy_[nCluster_] = cluster.energyDep(); + cluEnergyErr_[nCluster_] = cluster.energyDepErr(); + cluTime_[nCluster_] = cluster.time(); + cluTimeErr_[nCluster_] = cluster.timeErr(); + cluNcrys_[nCluster_] = cluster.size(); + cluCogX_[nCluster_] = cluster.cog3Vector().x(); //in disk FF frame + cluCogY_[nCluster_] = cluster.cog3Vector().y(); + cluCogZ_[nCluster_] = cluster.cog3Vector().z(); + cluE1_[nCluster_] = cluUtil.e1(); + cluE9_[nCluster_] = cluUtil.e9(); + cluE25_[nCluster_] = cluUtil.e25(); + cluSecMom_[nCluster_] = cluUtil.secondMoment(); + cluSplit_[nCluster_] = cluster.isSplit(); + cluConv_[nCluster_] = isConversion; + cluList_.push_back(cryList); + + cluSimIdx_[nCluster_] = nCluSim_; + cluSimLen_[nCluster_] = eDepMCs.size(); + + double sumEdepMC(0),edepTime(0); + for (unsigned i=0;i< eDepMCs.size();++i) + { + const auto& eDepMC = eDepMCs[i]; + art::Ptr sim = eDepMC.sim(); + + art::Ptr smother(sim); + while (smother->hasParent() && !smother->genParticle() ) smother = smother->parent(); + int genId=-1; + if (smother->genParticle()) genId = smother->genParticle()->generatorId().id(); + int genPdg=-1; + if (smother->genParticle()) genPdg = smother->genParticle()->pdgId(); + + cluSimId_[nCluSim_] = sim->id().asInt(); + cluSimPdgId_[nCluSim_] = sim->pdgId(); + cluSimCrCode_[nCluSim_] = sim->creationCode(); + cluSimGenId_[nCluSim_] = genId; + cluSimGenPdg_[nCluSim_] = genPdg; + cluSimTime_[nCluSim_] = eDepMC.time(); + cluSimEdep_[nCluSim_] = eDepMC.energyDep(); + cluSimMom_[nCluSim_] = eDepMC.momentumIn(); + cluSimStartX_[nCluSim_] = sim->startPosition().x(); // in disk FF frame + cluSimStartY_[nCluSim_] = sim->startPosition().y(); + cluSimStartZ_[nCluSim_] = sim->startPosition().z(); + ++nCluSim_; + + sumEdepMC += eDepMC.energyDep(); + if (edepTime<1) edepTime=eDepMC.time(); + } + ++nCluster_; + + hcluE_->Fill(cluster.energyDep()); + hcluT_->Fill(cluster.time()); + hcluX_->Fill(cluster.cog3Vector().x()); + hcluY_->Fill(cluster.cog3Vector().y()); + hcluZ_->Fill(cluster.cog3Vector().z()); + hCluEEMC_->Fill(cluster.energyDep(), sumEdepMC); + hCluTTMC_->Fill(cluster.time(), edepTime); } @@ -459,34 +454,32 @@ namespace mu2e { nVd_ = 0; if (vdhits.isValid()) { - for (auto iter=vdhits->begin(), ie=vdhits->end(); iter!=ie; ++iter) - { - const StepPointMC& hit = *iter; - - if ( (hit.volumeId()VirtualDetectorId::EMC_Disk_1_EdgeOut) - && hit.volumeId() != VirtualDetectorId::TT_Back) continue; - - CLHEP::Hep3Vector VDPos = cal.geomUtil().mu2eToTracker(hit.position()); - - vdId_[nVd_] = hit.volumeId(); - vdPdgId_[nVd_] = hit.simParticle()->pdgId(); - vdGenId_[nVd_] = (hit.simParticle()->genParticle()) ? hit.simParticle()->genParticle()->generatorId().id() : -1; - vdTime_[nVd_] = hit.time(); - vdPosX_[nVd_] = VDPos.x(); //tracker frame - vdPosY_[nVd_] = VDPos.y(); - vdPosZ_[nVd_] = VDPos.z(); - vdMom_[nVd_] = hit.momentum().mag(); - vdMomX_[nVd_] = hit.momentum().x(); - vdMomY_[nVd_] = hit.momentum().y(); - vdMomZ_[nVd_] = hit.momentum().z(); - vdGenIdx_[nVd_] = hit.simParticle()->generatorIndex(); - ++nVd_; - } - } - - Ntup_->Fill(); - - } + for (auto iter=vdhits->begin(), ie=vdhits->end(); iter!=ie; ++iter) + { + const StepPointMC& hit = *iter; + + if ( (hit.volumeId()VirtualDetectorId::EMC_Disk_1_EdgeOut) + && hit.volumeId() != VirtualDetectorId::TT_Back) continue; + + CLHEP::Hep3Vector VDPos = cal.geomUtil().mu2eToTracker(hit.position()); + + vdId_[nVd_] = hit.volumeId(); + vdPdgId_[nVd_] = hit.simParticle()->pdgId(); + vdGenId_[nVd_] = (hit.simParticle()->genParticle()) ? hit.simParticle()->genParticle()->generatorId().id() : -1; + vdTime_[nVd_] = hit.time(); + vdPosX_[nVd_] = VDPos.x(); //tracker frame + vdPosY_[nVd_] = VDPos.y(); + vdPosZ_[nVd_] = VDPos.z(); + vdMom_[nVd_] = hit.momentum().mag(); + vdMomX_[nVd_] = hit.momentum().x(); + vdMomY_[nVd_] = hit.momentum().y(); + vdMomZ_[nVd_] = hit.momentum().z(); + vdGenIdx_[nVd_] = hit.simParticle()->generatorIndex(); + ++nVd_; + } + } + Ntup_->Fill(); +} diff --git a/CaloMC/fcl/RunCaloCalibGun.fcl b/CaloMC/fcl/RunCaloCalibGun.fcl index 2e854c5c8a..112de117bd 100644 --- a/CaloMC/fcl/RunCaloCalibGun.fcl +++ b/CaloMC/fcl/RunCaloCalibGun.fcl @@ -59,7 +59,7 @@ physics: { analyzers: { CaloExample: { - module_type : CaloExample + module_type : CaloCalibAna caloHitCollection : CaloHitMaker caloClusterCollection : CaloClusterMaker caloHitTruth : CaloHitTruthMatch From ed8fb216886e63b28f0eeba7ac5542d9c224d4c0 Mon Sep 17 00:00:00 2001 From: sophieMu2e Date: Thu, 3 Feb 2022 11:26:59 -0600 Subject: [PATCH 12/33] merged --- Mu2eG4/test/genconfig_calocalib.txt | 30 ----------------------------- 1 file changed, 30 deletions(-) delete mode 100644 Mu2eG4/test/genconfig_calocalib.txt diff --git a/Mu2eG4/test/genconfig_calocalib.txt b/Mu2eG4/test/genconfig_calocalib.txt deleted file mode 100644 index 170495fa8c..0000000000 --- a/Mu2eG4/test/genconfig_calocalib.txt +++ /dev/null @@ -1,30 +0,0 @@ -// -// Run-time config info for the event generators. -// -// $Id: genconfig_02.txt,v 1.12 2012/07/27 19:45:48 kutschke Exp $ -// $Author: kutschke $ -// $Date: 2012/07/27 19:45:48 $ -// -// Original author Rob Kutschke - -// Which generators to enable. -bool caloCalibGun.do = true; - -// Limits on cos(polar angle): -double caloCalibGun.cosmin = -1.0; -double caloCalibGun.cosmax = 1.0; -double caloCalibGun.phimin = 0.0; -//double caloCalibGun.phimax = 1.5708; -// the maximum phi/2 is: 0.4533, 0.4199, 0.3930, 0.3708, 0.3520 -// for the pipes from inner to outer. -double caloCalibGun.phimax = 2.0; - -// Time limits in ns, relative to protons on target. -double caloCalibGun.tmin = 500.; -double caloCalibGun.tmax = 1694.; - - -// This tells emacs to view this file in c++ mode. -// Local Variables: -// mode:c++ -// End From 49e033dd4899b00c1986726b379a9588c0154ad6 Mon Sep 17 00:00:00 2001 From: sophieMu2e Date: Mon, 7 Feb 2022 09:45:18 -0600 Subject: [PATCH 13/33] module updated --- Analyses/src/CaloCalibAna_module.cc | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/Analyses/src/CaloCalibAna_module.cc b/Analyses/src/CaloCalibAna_module.cc index 3661270808..284e27fe7f 100644 --- a/Analyses/src/CaloCalibAna_module.cc +++ b/Analyses/src/CaloCalibAna_module.cc @@ -33,7 +33,7 @@ #include "Offline/MCDataProducts/inc/CaloMCTruthAssns.hh" #include "Offline/RecoDataProducts/inc/CaloHit.hh" #include "Offline/RecoDataProducts/inc/CaloCluster.hh" - +#include "Offline/GeometryService/inc/DetectorSystem.hh" #include "TDirectory.h" #include "TNtuple.h" #include "TTree.h" @@ -94,6 +94,7 @@ namespace mu2e { int nSimHit_,crySimId_[ntupLen],crySimPdgId_[ntupLen],crySimCrCode_[ntupLen],crySimGenIdx_[ntupLen],cryConv_[ntupLen]; float crySimMom_[ntupLen],crySimStartX_[ntupLen],crySimStartY_[ntupLen],crySimStartZ_[ntupLen],crySimStartT_[ntupLen]; + float crySimEndX_[ntupLen],crySimEndY_[ntupLen],crySimEndZ_[ntupLen],crySimEndT_[ntupLen]; float crySimTime_[ntupLen],crySimEdep_[ntupLen],cryTimeErr_[ntupLen],cryT1_[ntupLen],cryT2_[ntupLen],cryT1Err_[ntupLen],cryT2Err_[ntupLen]; int nCluster_,nCluSim_,cluNcrys_[ntupLen]; @@ -162,6 +163,10 @@ namespace mu2e { Ntup_->Branch("simStartY", &crySimStartY_ ,"simStartY[nSim]/F"); Ntup_->Branch("simStartZ", &crySimStartZ_ ,"simStartZ[nSim]/F"); Ntup_->Branch("simStartT", &crySimStartT_ ,"simStartT[nSim]/F"); + Ntup_->Branch("simEndX", &crySimEndX_ ,"simEndX[nSim]/F"); + Ntup_->Branch("simEndY", &crySimEndY_ ,"simEndY[nSim]/F"); + Ntup_->Branch("simEndZ", &crySimEndZ_ ,"simEndZ[nSim]/F"); + Ntup_->Branch("simEndT", &crySimEndT_ ,"simEndT[nSim]/F"); Ntup_->Branch("simTime", &crySimTime_ , "simTime[nSim]/F"); Ntup_->Branch("simEdep", &crySimEdep_ , "simEdep[nSim]/F"); Ntup_->Branch("simGenIdx", &crySimGenIdx_ ,"simGenIdx[nSim]/I"); @@ -325,9 +330,11 @@ namespace mu2e { cryT2_[nHits_] = cryT2; cryT1Err_[nHits_] = cryT1Err; cryT2Err_[nHits_] = cryT2Err; - cryPosX_[nHits_] = crystalPos.x(); - cryPosY_[nHits_] = crystalPos.y(); - cryPosZ_[nHits_] = crystalPos.z(); + GeomHandle det; + CLHEP::Hep3Vector Mu2ePos = det->toMu2e(crystalPos); // in mu2e coordinates for comparison + cryPosX_[nHits_] = Mu2ePos.x(); + cryPosY_[nHits_] = Mu2ePos.y(); + cryPosZ_[nHits_] = Mu2ePos.z(); cryConv_[nHits_] = isConversion ? 1 : 0; cryEtot_ += hit.energyDep(); @@ -349,11 +356,18 @@ namespace mu2e { crySimCrCode_[nSimHit_] = eDepMC.sim()->creationCode(); crySimTime_[nSimHit_] = eDepMC.time(); crySimEdep_[nSimHit_] = eDepMC.energyDep(); - crySimMom_[nSimHit_] = eDepMC.momentumIn(); + crySimMom_[nSimHit_] = eDepMC.momentumIn(); + crySimStartX_[nSimHit_] = parent->startPosition().x(); crySimStartY_[nSimHit_] = parent->startPosition().y(); crySimStartZ_[nSimHit_] = parent->startPosition().z(); crySimStartT_[nSimHit_] = parent->startGlobalTime(); + + crySimEndX_[nSimHit_] = parent->endPosition().x(); + crySimEndY_[nSimHit_] = parent->endPosition().y(); + crySimEndZ_[nSimHit_] = parent->endPosition().z(); + crySimEndT_[nSimHit_] = parent->endGlobalTime(); + crySimGenIdx_[nSimHit_] = genId; ++nSimHit_; @@ -376,6 +390,7 @@ namespace mu2e { //-------------------------- Do clusters -------------------------------- nCluster_ = nCluSim_ = 0; cluList_.clear(); + std::cout<<"calo cluster size "< Date: Mon, 14 Feb 2022 14:21:55 -0600 Subject: [PATCH 14/33] some of Robs comments addressed --- EventGenerator/src/CaloCalibGun_module.cc | 43 +++-------------------- 1 file changed, 5 insertions(+), 38 deletions(-) diff --git a/EventGenerator/src/CaloCalibGun_module.cc b/EventGenerator/src/CaloCalibGun_module.cc index 28ef4b9e37..b24651eb49 100644 --- a/EventGenerator/src/CaloCalibGun_module.cc +++ b/EventGenerator/src/CaloCalibGun_module.cc @@ -27,7 +27,7 @@ #include "Offline/MCDataProducts/inc/GenId.hh" #include "Offline/MCDataProducts/inc/GenParticle.hh" #include "Offline/MCDataProducts/inc/PrimaryParticle.hh" -#include "Offline/MCDataProducts/inc/MCTrajectoryCollection.hh" //TODO - is this needed? +#include "Offline/MCDataProducts/inc/MCTrajectoryCollection.hh" // Other external includes. #include "CLHEP/Random/RandFlat.h" @@ -43,8 +43,9 @@ //ROOT Includes #include -#include -const double piconst =CLHEP::pi; + +const double piconst = CLHEP::pi; +using CLHEP::degree; using namespace std; using namespace mu2e; @@ -95,14 +96,6 @@ namespace mu2e { std::vector _randomRad; CLHEP::Hep3Vector _zPipeCenter; - bool _doHistograms; - TTree* _Ntupe; - float _genErg; - float _genTime; - float _genCos; - float _genPosX; - float _genPosY; - float _genPosZ; }; CaloCalibGun::CaloCalibGun(const Parameters& conf) @@ -124,17 +117,6 @@ namespace mu2e { produces(); produces (); - if ( _doHistograms ) - { - art::ServiceHandle tfs; - _Ntupe = tfs->make("calibGun", "calibGun"); - _Ntupe -> Branch("genErg", &_genErg, "genErg/F"); - _Ntupe -> Branch("genTime", &_genTime, "genTime/F"); - _Ntupe -> Branch("genCos", &_genCos, "genCos/F"); - _Ntupe -> Branch("genPosX", &_genPosX, "genPosX/F"); - _Ntupe -> Branch("genPosY", &_genPosY, "genPosY/F"); - _Ntupe -> Branch("genPosZ", &_genPosZ, "genPosZ/F"); - } if (_mean < 0) throw cet::exception("RANGE") << "CaloCalibGun.mean must be non-negative "<< '\n'; } @@ -253,26 +235,11 @@ namespace mu2e { CLHEP::Hep3Vector p3 = _randomUnitSphere.fire(_energy); //Set Four-momentum - CLHEP::HepLorentzVector mom(0,0,0,0); - mom.setPx( p3.x() ); - mom.setPy( p3.y() ); - mom.setPz( p3.z() ); - mom.setE( energy ); + CLHEP::HepLorentzVector mom(p3.x(), p3.y(),p3.z(),energy ); // Add the particle to the list. output->emplace_back(PDGCode::gamma, GenId::CaloCalib, pos, mom, time); event.put(std::move(output)); - // Fill histograms. - if ( _doHistograms) - { - _genErg = energy; - _genTime = time; - _genCos = p3.cosTheta(); - _genPosX = pos.x(); - _genPosY = pos.y(); - _genPosZ = pos.z(); - } - if(_doHistograms) _Ntupe -> Fill(); } event.put(std::make_unique(primaryParticles)); event.put(std::make_unique(mctc)); From d3e643c72ae1912c17fbdf5040d9686041822dee Mon Sep 17 00:00:00 2001 From: sophieMu2e Date: Mon, 14 Feb 2022 14:52:05 -0600 Subject: [PATCH 15/33] some of Robs comments addressed --- EventGenerator/src/CaloCalibGun_module.cc | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/EventGenerator/src/CaloCalibGun_module.cc b/EventGenerator/src/CaloCalibGun_module.cc index b24651eb49..b5ebccc251 100644 --- a/EventGenerator/src/CaloCalibGun_module.cc +++ b/EventGenerator/src/CaloCalibGun_module.cc @@ -178,33 +178,33 @@ namespace mu2e { double radLgTor = _pipeTorRadius[idx]; // The phi range from 0 to half phi_lbd for the large torus - double phiLgTor = _randFlat.fire() * phi_lbd[idx] * piconst / 2. / 180.; + double phiLgTor = _randFlat.fire() * phi_lbd[idx] * CLHEP::degree / 2.; // x, y, z position of the large torus double xLgTor = sign[xsn]*(radLgTor + pipeR*cos(theta))*cos(phiLgTor); double yLgTor = sign[ysn]*(radLgTor + pipeR*cos(theta))*sin(phiLgTor); // circulus (center) of the large torus - double circLgTor = radLgTor * phi_lbd[idx] * piconst / 2. / 180.; + double circLgTor = radLgTor * phi_lbd[idx] * CLHEP::degree / 2.; // The phi range for the small torus - double phiSmTor = piconst * (_randFlat.fire() * phi_sbd[idx] + 180. + phi_lbd[idx]/2. - phi_sbd[idx])/180.; + double phiSmTor = CLHEP::degree * (_randFlat.fire() * phi_sbd[idx] + 180. + phi_lbd[idx]/2. - phi_sbd[idx]); // x, y, z position of the small torus double xSmTor = sign[xsn]*((radSmTor + pipeR*cos(theta))*cos(phiSmTor) + xsmall + xdistance * idx); double ySmTor = sign[ysn]*((radSmTor + pipeR*cos(theta))*sin(phiSmTor) + ysmall[idx]); // circulus (center) of the small torus - double circSmTor = radSmTor * piconst * phi_sbd[idx] / 180.; + double circSmTor = CLHEP::degree * radSmTor * phi_sbd[idx]; // strait pipe //double xmanifold = rInnerManifold * cos(piconst * (90 - phi_end[idx])/180.); - double ymanifold = rInnerManifold * sin(piconst * (90 - phi_end[idx])/180.); - double xstart = xsmall + xdistance * idx - radSmTor * cos(piconst * phi_end[idx]/180.); - double ystart = ysmall[idx] + radSmTor * sin(piconst * phi_end[idx]/180.); + double ymanifold = rInnerManifold * sin(CLHEP::degree * (90 - phi_end[idx])); + double xstart = xsmall + xdistance * idx - radSmTor * cos(CLHEP::degree * phi_end[idx]); + double ystart = ysmall[idx] + radSmTor * sin(CLHEP::degree * phi_end[idx]); // height of the strait pipe - double hPipe = (ymanifold - ystart) / sin(piconst * (90 - phi_end[idx]) / 180.); + double hPipe = (ymanifold - ystart) / sin(CLHEP::degree * (90 - phi_end[idx])); // a cylinder along y-axis double y_center = _randFlat.fire() * hPipe; double xPipe = pipeR * cos(theta); - double xStrait = sign[xsn] * (xPipe * cos(-piconst * phi_end[idx] / 180.) - y_center * sin(-piconst * phi_end[idx] / 180.) + xstart); - double yStrait = sign[ysn] * (xPipe * sin(-piconst * phi_end[idx] / 180.) + y_center * cos(-piconst * phi_end[idx] / 180.) + ystart); + double xStrait = sign[xsn] * (xPipe * cos(-CLHEP::degree * phi_end[idx]) - y_center * sin(-CLHEP::degree * phi_end[idx] ) + xstart); + double yStrait = sign[ysn] * (xPipe * sin(-CLHEP::degree * phi_end[idx]) + y_center * cos(-CLHEP::degree * phi_end[idx]) + ystart); double lenStrait = hPipe; double sample = _randFlat.fire(); From 69977b7f008f768a97a9d109616fadce56c3d99c Mon Sep 17 00:00:00 2001 From: sophieMu2e Date: Mon, 14 Feb 2022 15:35:52 -0600 Subject: [PATCH 16/33] some of Robs comments addressed --- EventGenerator/src/CaloCalibGun_module.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/EventGenerator/src/CaloCalibGun_module.cc b/EventGenerator/src/CaloCalibGun_module.cc index b5ebccc251..7320d9780c 100644 --- a/EventGenerator/src/CaloCalibGun_module.cc +++ b/EventGenerator/src/CaloCalibGun_module.cc @@ -166,8 +166,8 @@ namespace mu2e { double xpipe, ypipe, zpipe; //Pick position - int xsn = rint(_randFlat.fire()); - int ysn = rint(_randFlat.fire()); + int xsn = round(_randFlat.fire()); + int ysn = round(_randFlat.fire()); double theta = _randFlat.fire() * 2.0 * piconst; double pipeR = _pipeRadius * _randFlat.fire(); From b72dd19d412f80215c4482ab1face95be8e5f73e Mon Sep 17 00:00:00 2001 From: sophieMu2e Date: Wed, 16 Feb 2022 09:54:30 -0600 Subject: [PATCH 17/33] moved to geometry service --- Analyses/fcl/prolog.fcl | 9 + Analyses/src/CaloCalibAna_module.cc | 31 +- Analyses/src/CaloEventDisplays_module.cc | 318 ++++++++++++++++++++ EventGenerator/src/CaloCalibGun_module.cc | 16 +- GeometryService/src/DiskCalorimeterMaker.cc | 3 +- Mu2eG4/geom/calorimeter_CsI.txt | 11 +- 6 files changed, 368 insertions(+), 20 deletions(-) create mode 100644 Analyses/src/CaloEventDisplays_module.cc diff --git a/Analyses/fcl/prolog.fcl b/Analyses/fcl/prolog.fcl index c8088f4786..5cb46e287c 100644 --- a/Analyses/fcl/prolog.fcl +++ b/Analyses/fcl/prolog.fcl @@ -72,6 +72,15 @@ VirtualDetectorDefaults: { } +CaloEventDisplays: { + module_type : CaloEventDisplays + CaloCrystalHitCollection : "CaloCrystalHitFromHit" + CaloClusterCollection : "CaloClusterFromProtoCluster" + KalRepPtrCollection : "KFFDeM" + doDisplay : true + +} + # Many configurations use "readvd" readvd: @local::VirtualDetectorDefaults ClusterCompareNew : diff --git a/Analyses/src/CaloCalibAna_module.cc b/Analyses/src/CaloCalibAna_module.cc index 284e27fe7f..e2695d58e9 100644 --- a/Analyses/src/CaloCalibAna_module.cc +++ b/Analyses/src/CaloCalibAna_module.cc @@ -46,7 +46,10 @@ namespace constexpr int ntupLen = 16384; } - +int Contains(std::vector v, int x) +{ + return std::count(v.begin(), v.end(), x); +} namespace mu2e { class CaloCalibAna : public art::EDAnalyzer { @@ -88,8 +91,10 @@ namespace mu2e { TTree* Ntup_; int _evt,_run; - - int nHits_,cryId_[ntupLen],crySectionId_[ntupLen],crySimIdx_[ntupLen],crySimLen_[ntupLen]; + + int nHits_, nCrystals_; + float truetotalEnergyDep_; + int cryId_[ntupLen],crySectionId_[ntupLen],crySimIdx_[ntupLen],crySimLen_[ntupLen]; float cryEtot_,cryTime_[ntupLen],cryEdep_[ntupLen],cryEdepErr_[ntupLen],cryPosX_[ntupLen],cryPosY_[ntupLen],cryPosZ_[ntupLen],_cryLeak[ntupLen]; int nSimHit_,crySimId_[ntupLen],crySimPdgId_[ntupLen],crySimCrCode_[ntupLen],crySimGenIdx_[ntupLen],cryConv_[ntupLen]; @@ -132,8 +137,11 @@ namespace mu2e { Ntup_->Branch("evt", &_evt , "evt/I"); Ntup_->Branch("run", &_run , "run/I"); - Ntup_->Branch("cryEtot", &cryEtot_ , "cryEtot/F"); + Ntup_->Branch("cryEtot", &cryEtot_ , "cryEtot/F"); + Ntup_->Branch("nCrystals", &nCrystals_ , "nCrystals/I"); + Ntup_->Branch("trueEtot", &truetotalEnergyDep_ , "trueEtot/F"); + // Reconstructed carystal hit info (from CaloHitCollection): Ntup_->Branch("nCry", &nHits_ , "nCry/I"); Ntup_->Branch("cryId", &cryId_ , "cryId[nCry]/I"); @@ -290,12 +298,14 @@ namespace mu2e { if (diagLevel_ == 3){std::cout << "processing event in calo_example " << nProcess_ << " run and event = " << _run << " " << _evt << std::endl;} //-------------------------- Do calorimeter hits -------------------------------- - nHits_ = nSimHit_ = 0; cryEtot_ = 0.0; + truetotalEnergyDep_ = 0.0; + std::vector crystalsHit; for (unsigned int ic=0; icFill(hit.time(), edepTime); if (edepTime<1) hCryEEMC2_->Fill(hit.energyDep(), sumEdepMC); } - + nCrystals_ = crystalsHit.size(); + std::cout<<" Analyzer "<startPosition().x(); // in disk FF frame cluSimStartY_[nCluSim_] = sim->startPosition().y(); diff --git a/Analyses/src/CaloEventDisplays_module.cc b/Analyses/src/CaloEventDisplays_module.cc new file mode 100644 index 0000000000..4f431ea387 --- /dev/null +++ b/Analyses/src/CaloEventDisplays_module.cc @@ -0,0 +1,318 @@ +// C++ includes. +#include +#include +#include +#include +#include +//Mu2e Geom: +#include "Offline/CalorimeterGeom/inc/Calorimeter.hh" +#include "Offline/CalorimeterGeom/inc/DiskCalorimeter.hh" +#include "Offline/TrackerGeom/inc/Tracker.hh" + +#include "Offline/GeometryService/inc/GeomHandle.hh" +#include "Offline/GeometryService/inc/GeometryService.hh" +#include "Offline/GeometryService/inc/VirtualDetector.hh" +#include "Offline/GeometryService/inc/DetectorSystem.hh" + +//Mu2e Data Prods: +#include "Offline/MCDataProducts/inc/ProtonBunchIntensity.hh" +#include "Offline/MCDataProducts/inc/EventWeight.hh" +#include "Offline/RecoDataProducts/inc/CaloHit.hh" +#include "Offline/RecoDataProducts/inc/CaloCluster.hh" +#include "Offline/RecoDataProducts/inc/CaloCluster.hh" +// Mu2e Utilities +#include "Offline/GeometryService/inc/GeomHandle.hh" +#include "Offline/Mu2eUtilities/inc/SimParticleTimeOffset.hh" +#include "Offline/TrkDiag/inc/TrkMCTools.hh" + +// Mu2e diagnostics +#include "Offline/GeneralUtilities/inc/ParameterSetHelpers.hh" + +// Framework includes. +#include "art/Framework/Core/EDAnalyzer.h" +#include "art/Framework/Principal/Event.h" +#include "art/Framework/Principal/Handle.h" +#include "art_root_io/TFileService.h" +#include "art/Framework/Core/ModuleMacros.h" + +// BaBar Kalman filter includes +#include "BTrk/KalmanTrack/KalRep.hh" +#include "BTrk/TrkBase/HelixTraj.hh" +#include "BTrk/ProbTools/ChisqConsistency.hh" +#include "BTrk/BbrGeom/BbrVectorErr.hh" +#include "BTrk/BbrGeom/TrkLineTraj.hh" +#include "BTrk/TrkBase/TrkPoca.hh" +#include "BTrk/KalmanTrack/KalHit.hh" +#include "BTrk/TrkBase/HelixParams.hh" +#include "BTrk/BaBar/BaBar.hh" + +// ROOT incldues +#include "TLegend.h" +#include "TLatex.h" +#include "TTree.h" +#include "TH2D.h" +#include "TF1.h" +#include "TH3D.h" +#include "Rtypes.h" +#include "TApplication.h" +#include "TArc.h" +#include "TTUBE.h" +#include "TBox.h" +#include "TCanvas.h" +#include "TDirectory.h" +#include "TGraph.h" +#include "TH1F.h" +#include "TLine.h" +#include "TNtuple.h" +#include "TPolyMarker.h" +#include "TPolyMarker3D.h" +#include "TPolyLine3D.h" +#include "TStyle.h" +#include "TText.h" +#include "TRotMatrix.h" + + +using namespace std; + +namespace mu2e +{ + class CaloEventDisplays : public art::EDAnalyzer { + public: + struct Config{ + using Name=fhicl::Name; + using Comment=fhicl::Comment; + + fhicl::Atom calocrysTag{Name("CaloHitCollection"),Comment("cal reco crystal hit info")}; + + fhicl::Atom caloclusterTag{Name("CaloClusterCollection"),Comment("cal reco cluster info")}; + //fhicl::Atom kalrepTag{Name("KalRepPtrCollection"),Comment("outcome of Kalman filter (for tracker momentum info)")}; + fhicl::Atom doDisplay{Name("doDisplay"),Comment("use display"), false}; + fhicl::Atom clickToAdvance{Name("clickToAdvance"),Comment("next event"), false}; + }; + typedef art::EDAnalyzer::Table Parameters; + + explicit CaloEventDisplays(const Parameters& conf); + + virtual ~CaloEventDisplays(); + virtual void beginJob(); + virtual void analyze(const art::Event& e) override; + private: + Config _conf; + bool _mcdiag; + Int_t _evt; + + // The module label of this instance of this module. + std::string moduleLabel_; + + //For Event Displays: + TApplication* application_; + TDirectory* directory_ = nullptr; + TCanvas* canvas_ = nullptr; + TH2D* _display = nullptr; + TNtuple* _ntTrack = nullptr; + TNtuple* _ntHit = nullptr; + + + art::InputTag _calocrysTag; + art::InputTag _caloclusterTag; + //art::InputTag _kalrepTag; + const CaloHitCollection* _calcryhitcol; + const CaloClusterCollection* _calclustercol; + //const KalRepPtrCollection* _kalrepcol; + + bool doDisplay_; + bool clickToAdvance_; + void plot2d(const art::Event& evt); + + bool findData(const art::Event& evt); + }; + + CaloEventDisplays::CaloEventDisplays(const Parameters& conf) : + art::EDAnalyzer(conf), + _calocrysTag(conf().calocrysTag()), + _caloclusterTag(conf().caloclusterTag()), + //_kalrepTag(conf().kalrepTag()), + doDisplay_ (conf().doDisplay()), + clickToAdvance_ (conf().clickToAdvance()) + {} + + CaloEventDisplays::~CaloEventDisplays(){} + + void CaloEventDisplays::beginJob() { + // create diagnostics if requested... + if ( !doDisplay_ ) return; + art::ServiceHandle tfs; + directory_ = gDirectory; + // If needed, create the ROOT interactive environment. See note 1. + if ( !gApplication ){ + int tmp_argc(0); + char** tmp_argv(0); + application_ = new TApplication( "noapplication", &tmp_argc, tmp_argv ); + } + // Create a canvas with a guaranteed unique name; the module label is unique within a job. + TString name = "canvas_" + moduleLabel_; + TString title = "Canvas for " + moduleLabel_; + int window_size_x(1300); + int window_size_y(600); + canvas_ = tfs->make(name,title,window_size_x,window_size_y); + //canvas_->Divide(1,2); + + } + + void CaloEventDisplays::analyze(const art::Event& event) { + + plot2d(event); + } + + void CaloEventDisplays::plot2d(const art::Event& event){ + _evt = event.id().event(); + findData(event); + + std::vector clusterxs; + + //unsigned _ncluster = _calclustercol->size(); + unsigned _ncrystalhits = _calcryhitcol->size(); + + art::ServiceHandle geom; + if( ! geom->hasElement() ) return; + Calorimeter const & cal = *(GeomHandle()); + + if (doDisplay_) { + + std::cout << "Run: " << event.id().run() + << " Subrun: " << event.id().subRun() + << " Event: " << event.id().event()<SetTitle("foo title"); + auto pad = canvas_->cd(); + pad->Clear(); + canvas_->SetTitle("bar title"); + + auto xyplot = pad->DrawFrame(-1000,-1000, 1000,1000); + xyplot->GetYaxis()->SetTitleOffset(1.25); + xyplot->SetTitle( "View of Calo Disk 1 in YZ Plane; Z(mm);Y(mm)"); + + + + art::ServiceHandle geom; + + mu2e::GeomHandle ds; + mu2e::GeomHandle vdet; + + //float _clusterEdep = 0; + /*for (unsigned int tclu=0; tclu<_calclustercol->size();++tclu){ + CaloCluster const& cluster = (*_calclustercol)[tclu]; + _clusterEdep = cluster.energyDep(); + }*/ + + Disk const & disk = cal.disk(1); + double outerR = disk.outerRadius(); + double innerR= disk.innerRadius(); + + arcOut.SetFillColor(kGray); + arcIn.SetFillColor(kWhite); + arcIn.SetLineColor(kGray+1); + arcOut.SetLineColor(kGray+1); + arcOut.DrawArc(0.,0., outerR); + arcIn.DrawArc(0.,0., innerR); + + typedef std::list CaloCrystalList; + CaloCrystalList firstlist; + for(size_t i =0; i < _ncrystalhits; i++){ + CaloHit const& hit =(*_calcryhitcol)[i]; + firstlist.push_back(&hit); + } + + firstlist.sort([] (CaloHit const* lhs, CaloHit const* rhs) {return lhs->energyDep() > rhs->energyDep();} ); + + unsigned int i =0; + for(int i=0;i<674;i++){ + Crystal const &crystal = cal.crystal(i); + double crystalXLen = crystal.size().x(); + double crystalYLen = crystal.size().y(); + CLHEP::Hep3Vector crystalPos = cal.geomUtil().mu2eToDiskFF(1,crystal.position()); + box.SetLineColor(kGray+1); + box.DrawBox(crystalPos.x()-crystalXLen/2, crystalPos.y()-crystalYLen/2,crystalPos.x()+crystalXLen/2, crystalPos.y()+crystalYLen/2); + + } + float _crystalEdep = 0; + for(auto const& hit : firstlist){ + //CaloHit const& hit =(*_calcryhitcol).at(i);//_calcryhitcol + int diskId = cal.crystal(hit->crystalID()).diskID(); + + CLHEP::Hep3Vector crystalPos = cal.geomUtil().mu2eToDiskFF(diskId,cal.crystal(hit->crystalID()).position()); + int crystalID = hit->crystalID(); + Crystal const &crystal = cal.crystal(crystalID); + double crystalXLen = crystal.size().x(); + double crystalYLen = crystal.size().y(); + if(i==0) box.SetFillColor(kRed); + if(i==1 or i==2) box.SetFillColor(kOrange); + if(i==3 or i==4) box.SetFillColor(kYellow); + if(i>5 and i < 7) box.SetFillColor(kGreen); + if(i>7) box.SetFillColor(kCyan); + box.DrawBox(crystalPos.x()-crystalXLen/2, crystalPos.y()-crystalYLen/2,crystalPos.x()+crystalXLen/2, crystalPos.y()+crystalYLen/2); + _crystalEdep += hit->energyDep(); + if(hit->energyDep()>0){ + + TLatex latex; + stringstream crys; + crys<energyDep(); + const char* str_crys = crys.str().c_str(); + latex.SetTextSize(0.02); + latex.DrawLatex(crystalPos.x()-crystalXLen/2, crystalPos.y()-crystalYLen/2,str_crys); + cout<Modified(); + canvas_->Update(); + canvas_->SaveAs(title.str().c_str()); + if ( clickToAdvance_ ){ + cerr << "Double click in the Canvas " << moduleLabel_ << " to continue:" ; + gPad->WaitPrimitive(); + } else{ + char junk; + cerr << "Enter any character to continue: "; + cin >> junk; + } + cerr << endl; + + }//display +} + + + + bool CaloEventDisplays::findData(const art::Event& evt){ + + + _calcryhitcol =0; + _calclustercol=0; + + auto cryhit = evt.getValidHandle(_calocrysTag); + _calcryhitcol =cryhit.product(); + auto cluster= evt.getValidHandle(_caloclusterTag); + _calclustercol =cluster.product(); + + return _calcryhitcol!=0 && _calclustercol !=0; + } + + +} // end namespace mu2e + +using mu2e::CaloEventDisplays; +DEFINE_ART_MODULE(CaloEventDisplays); + diff --git a/EventGenerator/src/CaloCalibGun_module.cc b/EventGenerator/src/CaloCalibGun_module.cc index 7320d9780c..d19478f20b 100644 --- a/EventGenerator/src/CaloCalibGun_module.cc +++ b/EventGenerator/src/CaloCalibGun_module.cc @@ -141,21 +141,21 @@ namespace mu2e { //Define the parameters of the pipes: // angle of large torus in degrees - double phi_lbd[5] = {161.34, 149.50, 139.50, 132.07, 125.39}; + std::vector phi_lbd = _cal->caloInfo().getVDouble("LargeTorPhi");//{161.34, 149.50, 139.50, 132.07, 125.39}; // angle of small torus in degrees - double phi_sbd[5] = {84.63, 85.28, 85.79, 86.20, 86.53}; + std::vector phi_sbd = _cal->caloInfo().getVDouble("smallTorPhi");//{84.63, 85.28, 85.79, 86.20, 86.53}; // angle of the end point - double phi_end[5] = {3.96, 10.53, 15.80, 20.16, 23.84}; + std::vector phi_end = _cal->caloInfo().getVDouble("straitEndPhi");//{3.96, 10.53, 15.80, 20.16, 23.84}; // center position y of the small torus - double ysmall[5] = {432.2, 480.5, 524.3, 564.7, 602.5}; + std::vector ysmall = _cal->caloInfo().getVDouble("yposition");//{432.2, 480.5, 524.3, 564.7, 602.5}; // radius of small torus - double radSmTor = 41.0; + double radSmTor = _cal->caloInfo().getDouble("radSmTor");//41.0; // first center position x of the small torus - double xsmall = 71.0; + double xsmall = _cal->caloInfo().getDouble("radSmTor");//71.0; // distance of the small torus center - double xdistance = 60.0; + double xdistance = _cal->caloInfo().getDouble("xdistance");//60.0; // inner radius of the manifold - double rInnerManifold = 681.6; // 713.35 mm - 1.25 in (31.75 mm) + double rInnerManifold = _cal->caloInfo().getDouble("rInnerManifold");//681.6; // 713.35 mm - 1.25 in (31.75 mm) vector sign{-1.0, 1.0}; for (unsigned int ig = 0; ig < nGen; ++ig) diff --git a/GeometryService/src/DiskCalorimeterMaker.cc b/GeometryService/src/DiskCalorimeterMaker.cc index adce714e48..2a2294410e 100644 --- a/GeometryService/src/DiskCalorimeterMaker.cc +++ b/GeometryService/src/DiskCalorimeterMaker.cc @@ -127,7 +127,8 @@ namespace mu2e { config.getVectorDouble("calorimeter.pipeTorRadius", temp, calo_->caloInfo_.getInt("nPipes")); calo_->caloInfo_.set("pipeTorRadius",temp ); temp.clear(); - config.getVectorDouble("calorimeter.halfTorPhi", temp, calo_->caloInfo_.getInt("nPipes")); + //For source calibration system: + config.getVectorDouble("calorimeter.LargeTorPhi", temp, calo_->caloInfo_.getInt("nPipes")); calo_->caloInfo_.set("halfTorPhi", temp ); temp.clear(); config.getVectorDouble("calorimeter.smallTorPhi", temp, calo_->caloInfo_.getInt("nPipes")); diff --git a/Mu2eG4/geom/calorimeter_CsI.txt b/Mu2eG4/geom/calorimeter_CsI.txt index ee0ae2fcef..79161c8046 100644 --- a/Mu2eG4/geom/calorimeter_CsI.txt +++ b/Mu2eG4/geom/calorimeter_CsI.txt @@ -60,12 +60,17 @@ vector calorimeter.pipeTorRadius = {397,457,517,577,637}; double calorimeter.pipeRadius = 4.75; double calorimeter.pipeThickness = 0.5; double calorimeter.pipeInitSeparation = 25.4; -//double calorimeter.FPCoolPipeThickness = 1.4732; -vector calorimeter.halfTorPhi = {80.67, 74.75, 69.98, 66.04, 62.70}; // half angle of large torus + + +vector calorimeter.LargeTorPhi = {161.34, 149.50, 139.50, 132.07, 125.39}//{80.67, 74.75, 69.98, 66.04, 62.70}; // half angle of large torus vector calorimeter.smallTorPhi = {84.63, 85.28, 85.79, 86.20, 86.53}; // full angle of small torus vector calorimeter.straitEndPhi = {3.96, 10.53, 15.80, 20.16, 23.84}; // angle of the ending poing of the strait pipe vector calorimeter.yposition = {432.2, 480.5, 524.3, 564.7, 602.5}; // start y position of the strait pipe - +double calorimeter.radSmTor = 41.0; +double calorimeter.xsmall = 71.0; +double calorimeter.xdistance = 60.0; +double calorimeter.rInnerManifold = 681.6; + int calorimeter.crateVersion = 2; int calorimeter.numberOfCrates = 10; int calorimeter.numberOfBoards = 9; From 39c2e331726be7e6ab27a7dc8484b077e4286967 Mon Sep 17 00:00:00 2001 From: sophieMu2e Date: Wed, 16 Feb 2022 10:12:36 -0600 Subject: [PATCH 18/33] some more fixes --- GeometryService/src/DiskCalorimeterMaker.cc | 9 +++++++- Mu2eG4/geom/calorimeter_CsI.txt | 2 +- Mu2eG4/src/constructDiskCalorimeter.cc | 23 +++++++++++++-------- 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/GeometryService/src/DiskCalorimeterMaker.cc b/GeometryService/src/DiskCalorimeterMaker.cc index 2a2294410e..0aa687f027 100644 --- a/GeometryService/src/DiskCalorimeterMaker.cc +++ b/GeometryService/src/DiskCalorimeterMaker.cc @@ -129,7 +129,7 @@ namespace mu2e { temp.clear(); //For source calibration system: config.getVectorDouble("calorimeter.LargeTorPhi", temp, calo_->caloInfo_.getInt("nPipes")); - calo_->caloInfo_.set("halfTorPhi", temp ); + calo_->caloInfo_.set("LargeTorPhi", temp ); temp.clear(); config.getVectorDouble("calorimeter.smallTorPhi", temp, calo_->caloInfo_.getInt("nPipes")); calo_->caloInfo_.set("smallTorPhi", temp ); @@ -139,6 +139,13 @@ namespace mu2e { temp.clear(); config.getVectorDouble("calorimeter.straitEndPhi", temp, calo_->caloInfo_.getInt("nPipes")); calo_->caloInfo_.set("straitEndPhi", temp ); + temp.clear(); + calo_->caloInfo_.set("radSmTor", config.getDouble("calorimeter.radSmTor") ); + calo_->caloInfo_.set("xsmall", config.getDouble("calorimeter.xsmall") ); + calo_->caloInfo_.set("xdistance", config.getDouble("calorimeter.xdistance") ); + calo_->caloInfo_.set("rInnerManifold", config.getDouble("calorimeter.rInnerManifold") ); + temp.clear(); + calo_->caloInfo_.set("numberOfCrates", config.getInt("calorimeter.numberOfCrates") ); calo_->caloInfo_.set("nCrateBeforeSpace", config.getInt("calorimeter.nCrateBeforeSpace") ); diff --git a/Mu2eG4/geom/calorimeter_CsI.txt b/Mu2eG4/geom/calorimeter_CsI.txt index 79161c8046..801d732ce9 100644 --- a/Mu2eG4/geom/calorimeter_CsI.txt +++ b/Mu2eG4/geom/calorimeter_CsI.txt @@ -62,7 +62,7 @@ double calorimeter.pipeThickness = 0.5; double calorimeter.pipeInitSeparation = 25.4; -vector calorimeter.LargeTorPhi = {161.34, 149.50, 139.50, 132.07, 125.39}//{80.67, 74.75, 69.98, 66.04, 62.70}; // half angle of large torus +vector calorimeter.LargeTorPhi = {161.34, 149.50, 139.50, 132.07, 125.39};//full angle of large torus vector calorimeter.smallTorPhi = {84.63, 85.28, 85.79, 86.20, 86.53}; // full angle of small torus vector calorimeter.straitEndPhi = {3.96, 10.53, 15.80, 20.16, 23.84}; // angle of the ending poing of the strait pipe vector calorimeter.yposition = {432.2, 480.5, 524.3, 564.7, 602.5}; // start y position of the strait pipe diff --git a/Mu2eG4/src/constructDiskCalorimeter.cc b/Mu2eG4/src/constructDiskCalorimeter.cc index 4c42891dad..655eab5ac3 100644 --- a/Mu2eG4/src/constructDiskCalorimeter.cc +++ b/Mu2eG4/src/constructDiskCalorimeter.cc @@ -225,9 +225,14 @@ namespace mu2e { const bool isPipeVisible = geomOptions->isVisible("calorimeterPipe"); const bool isPipeSolid = geomOptions->isSolid("calorimeterPipe"); - const bool forceEdge = config.getBool("g4.forceEdge",false); - const bool doSurfaceCheck = config.getBool("g4.doSurfaceCheck",false) || config.getBool("calorimeter.doSurfaceCheck",false); + const bool forceEdge = geomOptions->forceAuxEdgeVisible("calorimeterPipe"); + const bool doSurfaceCheck = geomOptions->doSurfaceCheck("calorimeterPipe"); const int verbosityLevel = config.getInt("calorimeter.verbosityLevel",1); + + if ( verbosityLevel > 0) { + G4cout << __func__ << " Called. doSurfaceCheck: " << doSurfaceCheck << G4endl; + } + G4VPhysicalVolume* pv; G4Material* vacuumMaterial = materialFinder.get("calorimeter.vacuumMaterial"); @@ -248,7 +253,7 @@ namespace mu2e { G4double pipeThickness = cal.caloInfo().getDouble("pipeThickness"); G4double pipeInitSeparation = cal.caloInfo().getDouble("pipeInitSeparation"); std::vector pipeTorRadius = cal.caloInfo().getVDouble("pipeTorRadius"); - std::vector halfTorPhi = cal.caloInfo().getVDouble("halfTorPhi"); + std::vector LargeTorPhi = cal.caloInfo().getVDouble("LargeTorPhi"); std::vector smallTorPhi = cal.caloInfo().getVDouble("smallTorPhi"); std::vector yposition = cal.caloInfo().getVDouble("yposition"); std::vector straitEndPhi = cal.caloInfo().getVDouble("straitEndPhi"); @@ -317,8 +322,8 @@ namespace mu2e { { //double xpipe = pipeInitSeparation+pipeTorRadius[ipipe]-pipeTorRadius[0]; //double angle = std::asin(xpipe/pipeTorRadius[ipipe]); //angle taken w.r.t y axis! - double angle = halfTorPhi[ipipe] * CLHEP::pi / 180.; - double sAngle = smallTorPhi[ipipe] * CLHEP::pi / 180.; + double angle = LargeTorPhi[ipipe] * CLHEP::degree / 2; + double sAngle = smallTorPhi[ipipe] * CLHEP::degree; double sxPos = 71. + 60 * ipipe; double syPos = yposition[ipipe]; //double length = sqrt(FPOuterRadius*FPOuterRadius-xpipe*xpipe) - (pipeTorRadius[ipipe]+pipeRadius)*cos(angle) - 2.0*pipeRadius; @@ -337,10 +342,10 @@ namespace mu2e { // calculate the parameters of the strait pipes // minus 2.0 mm from the manifold pipe's most inner radius to avoid the overlap. - double xEnd = (FPCoolPipeTorRadius -FPCoolPipeRadius) * sin(straitEndPhi[ipipe] * CLHEP::pi / 180.); - double yEnd = (FPCoolPipeTorRadius -FPCoolPipeRadius) * cos(straitEndPhi[ipipe] * CLHEP::pi / 180.); - double xStart = sxPos - smallRadius * cos(straitEndPhi[ipipe] * CLHEP::pi / 180.); - double yStart = syPos + smallRadius * sin(straitEndPhi[ipipe] * CLHEP::pi / 180.); + double xEnd = (FPCoolPipeTorRadius -FPCoolPipeRadius) * sin(straitEndPhi[ipipe] * CLHEP::degree); + double yEnd = (FPCoolPipeTorRadius -FPCoolPipeRadius) * cos(straitEndPhi[ipipe] * CLHEP::degree); + double xStart = sxPos - smallRadius * cos(straitEndPhi[ipipe] * CLHEP::degree); + double yStart = syPos + smallRadius * sin(straitEndPhi[ipipe] * CLHEP::degree); double sLength = sqrt((xEnd - xStart)*(xEnd - xStart) + (yEnd - yStart)*(yEnd - yStart)); double zRotateAngle = std::atan((yEnd - yStart) / (xEnd - xStart)); From c038976a7efc1c8987d1459139945d926fc11b84 Mon Sep 17 00:00:00 2001 From: sophieMu2e Date: Wed, 16 Feb 2022 10:39:36 -0600 Subject: [PATCH 19/33] geometery construct file updated --- Mu2eG4/src/constructDiskCalorimeter.cc | 41 +++++++++++++------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/Mu2eG4/src/constructDiskCalorimeter.cc b/Mu2eG4/src/constructDiskCalorimeter.cc index 655eab5ac3..b87973af49 100644 --- a/Mu2eG4/src/constructDiskCalorimeter.cc +++ b/Mu2eG4/src/constructDiskCalorimeter.cc @@ -257,7 +257,11 @@ namespace mu2e { std::vector smallTorPhi = cal.caloInfo().getVDouble("smallTorPhi"); std::vector yposition = cal.caloInfo().getVDouble("yposition"); std::vector straitEndPhi = cal.caloInfo().getVDouble("straitEndPhi"); - + G4double radSmTor = cal.caloInfo().getDouble("radSmTor"); + G4double xsmall = cal.caloInfo().getDouble("xsmall"); + G4double xdistance = cal.caloInfo().getDouble("xdistance"); + G4double rInnerManifold = cal.caloInfo().getDouble("rInnerManifold"); + G4double frontPanelHalfThick = (2.0*FPCarbonDZ+2.0*FPFoamDZ-pipeRadius+FPCoolPipeRadius)/2.0; G4double ZposCarbon2 = frontPanelHalfThick-FPCarbonDZ; G4double ZposFoam = ZposCarbon2-FPCarbonDZ-FPFoamDZ; @@ -268,11 +272,11 @@ namespace mu2e { //this is the full front panel G4Tubs* frontPlate = new G4Tubs("caloFrontPlate",FPInnerRadius,FPCoolPipeTorRadius+FPCoolPipeRadius,frontPanelHalfThick,0,CLHEP::twopi); - G4LogicalVolume* frontPlateLog = caloBuildLogical(frontPlate, vacuumMaterial, "caloFrontPlateLog",0,G4Color::White(),0,0); + G4LogicalVolume* frontPlateLog = caloBuildLogical(frontPlate, vacuumMaterial, "caloFrontPlateLog_"+std::to_string(idisk),0,G4Color::White(),0,0); //carbon fiber panels G4Tubs* frontPanelCarb = new G4Tubs("caloFPCarb",FPInnerRadius,FPOuterRadius,FPCarbonDZ,0,CLHEP::twopi); - G4LogicalVolume* frontPanelCarbLog = caloBuildLogical(frontPanelCarb, FPCarbonMaterial, "caloFPCarbLog",isPipeVisible,G4Color::Grey(),0,forceEdge); + G4LogicalVolume* frontPanelCarbLog = caloBuildLogical(frontPanelCarb, FPCarbonMaterial, "caloFrontPlateLog_"+std::to_string(idisk),isPipeVisible,G4Color::Grey(),0,forceEdge); pv = new G4PVPlacement(0,G4ThreeVector(0.0,0.0,ZposCarbon1), frontPanelCarbLog, "caloFPCarbPV1", frontPlateLog, false, 0, false); doSurfaceCheck && checkForOverlaps( pv, config, verbosityLevel>0); @@ -281,7 +285,7 @@ namespace mu2e { //Foam panel G4Tubs* frontPanelFoam = new G4Tubs("caloFPFoam",FPInnerRadius,FPOuterRadius,FPFoamDZ,0,CLHEP::twopi); - G4LogicalVolume* frontPanelFoamLog = caloBuildLogical(frontPanelFoam, FPFoamMaterial, "caloFPFoamLog",isPipeVisible,G4Color::Brown(),0,forceEdge); + G4LogicalVolume* frontPanelFoamLog = caloBuildLogical(frontPanelFoam, FPFoamMaterial, "caloFPFoamLog"+std::to_string(idisk),isPipeVisible,G4Color::Brown(),0,forceEdge); pv = new G4PVPlacement(0,G4ThreeVector(0.0,0.0,ZposFoam), frontPanelFoamLog, "caloFPFoamPV", frontPlateLog, false, 0, false); doSurfaceCheck && checkForOverlaps( pv, config, verbosityLevel>0); @@ -293,30 +297,27 @@ namespace mu2e { reg.add(rotFPPipe); G4Torus* coolFP = new G4Torus("caloCoolFP",FPCoolPipeRadius-FPCoolPipeThickness, FPCoolPipeRadius, FPCoolPipeTorRadius, angMax, CLHEP::twopi-2.0*angMax); - G4LogicalVolume* coolFPLog = caloBuildLogical(coolFP, pipeMaterial, "caloCoolFPLog",isPipeVisible,G4Color::Red(),isPipeSolid,0); + G4LogicalVolume* coolFPLog = caloBuildLogical(coolFP, pipeMaterial, "caloCoolFPLog"+std::to_string(idisk),isPipeVisible,G4Color::Red(),isPipeSolid,0); pv = new G4PVPlacement(rotFPPipe,G4ThreeVector(0.0,0.0,ZposPipe), coolFPLog, "caloCoolFPPV", frontPlateLog, false, 0, false); doSurfaceCheck && checkForOverlaps( pv, config, verbosityLevel>0); //pipes nside foam - G4RotationMatrix* rotPipe1 = new G4RotationMatrix(CLHEP::HepRotation::IDENTITY); + G4RotationMatrix* rotPipe1 = new G4RotationMatrix(); //rotPipe1->rotateZ(CLHEP::pi/2.0); rotPipe1->rotateZ(0.0 * CLHEP::pi); - G4RotationMatrix* rotPipe2 = new G4RotationMatrix(CLHEP::HepRotation::IDENTITY); - rotPipe2->rotateZ(1.0 * CLHEP::pi); - G4RotationMatrix* rotPipe3 = new G4RotationMatrix(CLHEP::HepRotation::IDENTITY); - rotPipe3->rotateY(1.0 * CLHEP::pi); - G4RotationMatrix* rotPipe4 = new G4RotationMatrix(CLHEP::HepRotation::IDENTITY); - rotPipe4->rotateX(1.0 * CLHEP::pi); - //G4RotationMatrix* rotPipeFlat = new G4RotationMatrix(CLHEP::HepRotation::IDENTITY); - //rotPipeFlat->rotateX(CLHEP::pi/2.0); reg.add(rotPipe1); + G4RotationMatrix* rotPipe2 = new G4RotationMatrix(); + rotPipe2->rotateZ(1.0 * CLHEP::pi); reg.add(rotPipe2); + G4RotationMatrix* rotPipe3 = new G4RotationMatrix(); + rotPipe3->rotateY(1.0 * CLHEP::pi); reg.add(rotPipe3); + G4RotationMatrix* rotPipe4 = new G4RotationMatrix(); + rotPipe4->rotateX(1.0 * CLHEP::pi); reg.add(rotPipe4); - //reg.add(rotPipeFlat); - double smallRadius = 41.; + for (int ipipe=0; ipipe Date: Wed, 16 Feb 2022 11:01:53 -0600 Subject: [PATCH 20/33] analyses removed --- Analyses/fcl/prolog.fcl | 8 - Analyses/src/CaloEventDisplays_module.cc | 318 ----------------------- 2 files changed, 326 deletions(-) delete mode 100644 Analyses/src/CaloEventDisplays_module.cc diff --git a/Analyses/fcl/prolog.fcl b/Analyses/fcl/prolog.fcl index 5cb46e287c..6534e876c4 100644 --- a/Analyses/fcl/prolog.fcl +++ b/Analyses/fcl/prolog.fcl @@ -72,14 +72,6 @@ VirtualDetectorDefaults: { } -CaloEventDisplays: { - module_type : CaloEventDisplays - CaloCrystalHitCollection : "CaloCrystalHitFromHit" - CaloClusterCollection : "CaloClusterFromProtoCluster" - KalRepPtrCollection : "KFFDeM" - doDisplay : true - -} # Many configurations use "readvd" readvd: @local::VirtualDetectorDefaults diff --git a/Analyses/src/CaloEventDisplays_module.cc b/Analyses/src/CaloEventDisplays_module.cc deleted file mode 100644 index 4f431ea387..0000000000 --- a/Analyses/src/CaloEventDisplays_module.cc +++ /dev/null @@ -1,318 +0,0 @@ -// C++ includes. -#include -#include -#include -#include -#include -//Mu2e Geom: -#include "Offline/CalorimeterGeom/inc/Calorimeter.hh" -#include "Offline/CalorimeterGeom/inc/DiskCalorimeter.hh" -#include "Offline/TrackerGeom/inc/Tracker.hh" - -#include "Offline/GeometryService/inc/GeomHandle.hh" -#include "Offline/GeometryService/inc/GeometryService.hh" -#include "Offline/GeometryService/inc/VirtualDetector.hh" -#include "Offline/GeometryService/inc/DetectorSystem.hh" - -//Mu2e Data Prods: -#include "Offline/MCDataProducts/inc/ProtonBunchIntensity.hh" -#include "Offline/MCDataProducts/inc/EventWeight.hh" -#include "Offline/RecoDataProducts/inc/CaloHit.hh" -#include "Offline/RecoDataProducts/inc/CaloCluster.hh" -#include "Offline/RecoDataProducts/inc/CaloCluster.hh" -// Mu2e Utilities -#include "Offline/GeometryService/inc/GeomHandle.hh" -#include "Offline/Mu2eUtilities/inc/SimParticleTimeOffset.hh" -#include "Offline/TrkDiag/inc/TrkMCTools.hh" - -// Mu2e diagnostics -#include "Offline/GeneralUtilities/inc/ParameterSetHelpers.hh" - -// Framework includes. -#include "art/Framework/Core/EDAnalyzer.h" -#include "art/Framework/Principal/Event.h" -#include "art/Framework/Principal/Handle.h" -#include "art_root_io/TFileService.h" -#include "art/Framework/Core/ModuleMacros.h" - -// BaBar Kalman filter includes -#include "BTrk/KalmanTrack/KalRep.hh" -#include "BTrk/TrkBase/HelixTraj.hh" -#include "BTrk/ProbTools/ChisqConsistency.hh" -#include "BTrk/BbrGeom/BbrVectorErr.hh" -#include "BTrk/BbrGeom/TrkLineTraj.hh" -#include "BTrk/TrkBase/TrkPoca.hh" -#include "BTrk/KalmanTrack/KalHit.hh" -#include "BTrk/TrkBase/HelixParams.hh" -#include "BTrk/BaBar/BaBar.hh" - -// ROOT incldues -#include "TLegend.h" -#include "TLatex.h" -#include "TTree.h" -#include "TH2D.h" -#include "TF1.h" -#include "TH3D.h" -#include "Rtypes.h" -#include "TApplication.h" -#include "TArc.h" -#include "TTUBE.h" -#include "TBox.h" -#include "TCanvas.h" -#include "TDirectory.h" -#include "TGraph.h" -#include "TH1F.h" -#include "TLine.h" -#include "TNtuple.h" -#include "TPolyMarker.h" -#include "TPolyMarker3D.h" -#include "TPolyLine3D.h" -#include "TStyle.h" -#include "TText.h" -#include "TRotMatrix.h" - - -using namespace std; - -namespace mu2e -{ - class CaloEventDisplays : public art::EDAnalyzer { - public: - struct Config{ - using Name=fhicl::Name; - using Comment=fhicl::Comment; - - fhicl::Atom calocrysTag{Name("CaloHitCollection"),Comment("cal reco crystal hit info")}; - - fhicl::Atom caloclusterTag{Name("CaloClusterCollection"),Comment("cal reco cluster info")}; - //fhicl::Atom kalrepTag{Name("KalRepPtrCollection"),Comment("outcome of Kalman filter (for tracker momentum info)")}; - fhicl::Atom doDisplay{Name("doDisplay"),Comment("use display"), false}; - fhicl::Atom clickToAdvance{Name("clickToAdvance"),Comment("next event"), false}; - }; - typedef art::EDAnalyzer::Table Parameters; - - explicit CaloEventDisplays(const Parameters& conf); - - virtual ~CaloEventDisplays(); - virtual void beginJob(); - virtual void analyze(const art::Event& e) override; - private: - Config _conf; - bool _mcdiag; - Int_t _evt; - - // The module label of this instance of this module. - std::string moduleLabel_; - - //For Event Displays: - TApplication* application_; - TDirectory* directory_ = nullptr; - TCanvas* canvas_ = nullptr; - TH2D* _display = nullptr; - TNtuple* _ntTrack = nullptr; - TNtuple* _ntHit = nullptr; - - - art::InputTag _calocrysTag; - art::InputTag _caloclusterTag; - //art::InputTag _kalrepTag; - const CaloHitCollection* _calcryhitcol; - const CaloClusterCollection* _calclustercol; - //const KalRepPtrCollection* _kalrepcol; - - bool doDisplay_; - bool clickToAdvance_; - void plot2d(const art::Event& evt); - - bool findData(const art::Event& evt); - }; - - CaloEventDisplays::CaloEventDisplays(const Parameters& conf) : - art::EDAnalyzer(conf), - _calocrysTag(conf().calocrysTag()), - _caloclusterTag(conf().caloclusterTag()), - //_kalrepTag(conf().kalrepTag()), - doDisplay_ (conf().doDisplay()), - clickToAdvance_ (conf().clickToAdvance()) - {} - - CaloEventDisplays::~CaloEventDisplays(){} - - void CaloEventDisplays::beginJob() { - // create diagnostics if requested... - if ( !doDisplay_ ) return; - art::ServiceHandle tfs; - directory_ = gDirectory; - // If needed, create the ROOT interactive environment. See note 1. - if ( !gApplication ){ - int tmp_argc(0); - char** tmp_argv(0); - application_ = new TApplication( "noapplication", &tmp_argc, tmp_argv ); - } - // Create a canvas with a guaranteed unique name; the module label is unique within a job. - TString name = "canvas_" + moduleLabel_; - TString title = "Canvas for " + moduleLabel_; - int window_size_x(1300); - int window_size_y(600); - canvas_ = tfs->make(name,title,window_size_x,window_size_y); - //canvas_->Divide(1,2); - - } - - void CaloEventDisplays::analyze(const art::Event& event) { - - plot2d(event); - } - - void CaloEventDisplays::plot2d(const art::Event& event){ - _evt = event.id().event(); - findData(event); - - std::vector clusterxs; - - //unsigned _ncluster = _calclustercol->size(); - unsigned _ncrystalhits = _calcryhitcol->size(); - - art::ServiceHandle geom; - if( ! geom->hasElement() ) return; - Calorimeter const & cal = *(GeomHandle()); - - if (doDisplay_) { - - std::cout << "Run: " << event.id().run() - << " Subrun: " << event.id().subRun() - << " Event: " << event.id().event()<SetTitle("foo title"); - auto pad = canvas_->cd(); - pad->Clear(); - canvas_->SetTitle("bar title"); - - auto xyplot = pad->DrawFrame(-1000,-1000, 1000,1000); - xyplot->GetYaxis()->SetTitleOffset(1.25); - xyplot->SetTitle( "View of Calo Disk 1 in YZ Plane; Z(mm);Y(mm)"); - - - - art::ServiceHandle geom; - - mu2e::GeomHandle ds; - mu2e::GeomHandle vdet; - - //float _clusterEdep = 0; - /*for (unsigned int tclu=0; tclu<_calclustercol->size();++tclu){ - CaloCluster const& cluster = (*_calclustercol)[tclu]; - _clusterEdep = cluster.energyDep(); - }*/ - - Disk const & disk = cal.disk(1); - double outerR = disk.outerRadius(); - double innerR= disk.innerRadius(); - - arcOut.SetFillColor(kGray); - arcIn.SetFillColor(kWhite); - arcIn.SetLineColor(kGray+1); - arcOut.SetLineColor(kGray+1); - arcOut.DrawArc(0.,0., outerR); - arcIn.DrawArc(0.,0., innerR); - - typedef std::list CaloCrystalList; - CaloCrystalList firstlist; - for(size_t i =0; i < _ncrystalhits; i++){ - CaloHit const& hit =(*_calcryhitcol)[i]; - firstlist.push_back(&hit); - } - - firstlist.sort([] (CaloHit const* lhs, CaloHit const* rhs) {return lhs->energyDep() > rhs->energyDep();} ); - - unsigned int i =0; - for(int i=0;i<674;i++){ - Crystal const &crystal = cal.crystal(i); - double crystalXLen = crystal.size().x(); - double crystalYLen = crystal.size().y(); - CLHEP::Hep3Vector crystalPos = cal.geomUtil().mu2eToDiskFF(1,crystal.position()); - box.SetLineColor(kGray+1); - box.DrawBox(crystalPos.x()-crystalXLen/2, crystalPos.y()-crystalYLen/2,crystalPos.x()+crystalXLen/2, crystalPos.y()+crystalYLen/2); - - } - float _crystalEdep = 0; - for(auto const& hit : firstlist){ - //CaloHit const& hit =(*_calcryhitcol).at(i);//_calcryhitcol - int diskId = cal.crystal(hit->crystalID()).diskID(); - - CLHEP::Hep3Vector crystalPos = cal.geomUtil().mu2eToDiskFF(diskId,cal.crystal(hit->crystalID()).position()); - int crystalID = hit->crystalID(); - Crystal const &crystal = cal.crystal(crystalID); - double crystalXLen = crystal.size().x(); - double crystalYLen = crystal.size().y(); - if(i==0) box.SetFillColor(kRed); - if(i==1 or i==2) box.SetFillColor(kOrange); - if(i==3 or i==4) box.SetFillColor(kYellow); - if(i>5 and i < 7) box.SetFillColor(kGreen); - if(i>7) box.SetFillColor(kCyan); - box.DrawBox(crystalPos.x()-crystalXLen/2, crystalPos.y()-crystalYLen/2,crystalPos.x()+crystalXLen/2, crystalPos.y()+crystalYLen/2); - _crystalEdep += hit->energyDep(); - if(hit->energyDep()>0){ - - TLatex latex; - stringstream crys; - crys<energyDep(); - const char* str_crys = crys.str().c_str(); - latex.SetTextSize(0.02); - latex.DrawLatex(crystalPos.x()-crystalXLen/2, crystalPos.y()-crystalYLen/2,str_crys); - cout<Modified(); - canvas_->Update(); - canvas_->SaveAs(title.str().c_str()); - if ( clickToAdvance_ ){ - cerr << "Double click in the Canvas " << moduleLabel_ << " to continue:" ; - gPad->WaitPrimitive(); - } else{ - char junk; - cerr << "Enter any character to continue: "; - cin >> junk; - } - cerr << endl; - - }//display -} - - - - bool CaloEventDisplays::findData(const art::Event& evt){ - - - _calcryhitcol =0; - _calclustercol=0; - - auto cryhit = evt.getValidHandle(_calocrysTag); - _calcryhitcol =cryhit.product(); - auto cluster= evt.getValidHandle(_caloclusterTag); - _calclustercol =cluster.product(); - - return _calcryhitcol!=0 && _calclustercol !=0; - } - - -} // end namespace mu2e - -using mu2e::CaloEventDisplays; -DEFINE_ART_MODULE(CaloEventDisplays); - From 853f843fc3fe5852a4cb715939d6abd32b0fa7e0 Mon Sep 17 00:00:00 2001 From: sophieMu2e Date: Wed, 16 Feb 2022 11:07:08 -0600 Subject: [PATCH 21/33] G4 updates --- Mu2eG4/src/constructDiskCalorimeter.cc | 49 +++++++++++++------------- 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/Mu2eG4/src/constructDiskCalorimeter.cc b/Mu2eG4/src/constructDiskCalorimeter.cc index b87973af49..334515d211 100644 --- a/Mu2eG4/src/constructDiskCalorimeter.cc +++ b/Mu2eG4/src/constructDiskCalorimeter.cc @@ -260,8 +260,7 @@ namespace mu2e { G4double radSmTor = cal.caloInfo().getDouble("radSmTor"); G4double xsmall = cal.caloInfo().getDouble("xsmall"); G4double xdistance = cal.caloInfo().getDouble("xdistance"); - G4double rInnerManifold = cal.caloInfo().getDouble("rInnerManifold"); - + G4double frontPanelHalfThick = (2.0*FPCarbonDZ+2.0*FPFoamDZ-pipeRadius+FPCoolPipeRadius)/2.0; G4double ZposCarbon2 = frontPanelHalfThick-FPCarbonDZ; G4double ZposFoam = ZposCarbon2-FPCarbonDZ-FPFoamDZ; @@ -303,17 +302,17 @@ namespace mu2e { //pipes nside foam - G4RotationMatrix* rotPipe1 = new G4RotationMatrix(); + G4RotationMatrix* rotPipe1 = reg.add(new G4RotationMatrix()); //rotPipe1->rotateZ(CLHEP::pi/2.0); rotPipe1->rotateZ(0.0 * CLHEP::pi); - reg.add(rotPipe1); - G4RotationMatrix* rotPipe2 = new G4RotationMatrix(); + + G4RotationMatrix* rotPipe2 = reg.add(new G4RotationMatrix()); rotPipe2->rotateZ(1.0 * CLHEP::pi); reg.add(rotPipe2); - G4RotationMatrix* rotPipe3 = new G4RotationMatrix(); + G4RotationMatrix* rotPipe3 = reg.add(new G4RotationMatrix()); rotPipe3->rotateY(1.0 * CLHEP::pi); reg.add(rotPipe3); - G4RotationMatrix* rotPipe4 = new G4RotationMatrix(); + G4RotationMatrix* rotPipe4 = reg.add(new G4RotationMatrix()); rotPipe4->rotateX(1.0 * CLHEP::pi); reg.add(rotPipe4); @@ -352,18 +351,18 @@ namespace mu2e { // rotation coordinate //G4RotationMatrix* sPipeRotate = new G4RotationMatrix(CLHEP::HepRotation::IDENTITY); - G4RotationMatrix* sPipeRotate1 = new G4RotationMatrix(); + G4RotationMatrix* sPipeRotate1 = reg.add(new G4RotationMatrix()); sPipeRotate1 -> rotateX(0.5 * CLHEP::pi); - sPipeRotate1 -> rotateY((-0.5*CLHEP::pi + zRotateAngle) * CLHEP::rad); - G4RotationMatrix* sPipeRotate2 = new G4RotationMatrix(); + sPipeRotate1 -> rotateY((-0.5*CLHEP::pi + zRotateAngle)); + G4RotationMatrix* sPipeRotate2 = reg.add(new G4RotationMatrix()); sPipeRotate2 -> rotateX(0.5 * CLHEP::pi); - sPipeRotate2 -> rotateY((-0.5*CLHEP::pi - zRotateAngle) * CLHEP::rad); - G4RotationMatrix* sPipeRotate3 = new G4RotationMatrix(); + sPipeRotate2 -> rotateY((-0.5*CLHEP::pi - zRotateAngle)); + G4RotationMatrix* sPipeRotate3 = reg.add(new G4RotationMatrix()); sPipeRotate3 -> rotateX(0.5 * CLHEP::pi); - sPipeRotate3 -> rotateY((-1.5*CLHEP::pi + zRotateAngle) * CLHEP::rad); - G4RotationMatrix* sPipeRotate4 = new G4RotationMatrix(); + sPipeRotate3 -> rotateY((-1.5*CLHEP::pi + zRotateAngle)); + G4RotationMatrix* sPipeRotate4 = reg.add(new G4RotationMatrix()); sPipeRotate4 -> rotateX(0.5 * CLHEP::pi); - sPipeRotate4 -> rotateY((-1.5*CLHEP::pi - zRotateAngle) * CLHEP::rad); + sPipeRotate4 -> rotateY((-1.5*CLHEP::pi - zRotateAngle)); //reg.add(sPipeRotate); // transform movement double xCenter = 0.5 * (xEnd + xStart); @@ -374,28 +373,28 @@ namespace mu2e { G4LogicalVolume* pipe3Log = caloBuildLogical(pipe3, pipeMaterial, "caloPipe3Log",isPipeVisible,G4Color::Cyan(),isPipeSolid,forceEdge); // large bending torus - pv = new G4PVPlacement(rotPipe1, G4ThreeVector(0,0,z), pipe1Log, "caloPipePV", frontPanelFoamLog, false, ipipe, false); + pv = new G4PVPlacement(rotPipe1, G4ThreeVector(0,0,z), pipe1Log, "caloPipePV1", frontPanelFoamLog, false, ipipe, false); doSurfaceCheck && checkForOverlaps( pv, config, verbosityLevel>0); - pv = new G4PVPlacement(rotPipe2, G4ThreeVector(0,0,z), pipe1Log, "caloPipePV", frontPanelFoamLog, false, ipipe, false); + pv = new G4PVPlacement(rotPipe2, G4ThreeVector(0,0,z), pipe1Log, "caloPipePV2", frontPanelFoamLog, false, ipipe, false); doSurfaceCheck && checkForOverlaps( pv, config, verbosityLevel>0); // small bending torus - pv = new G4PVPlacement(rotPipe1, G4ThreeVector(sxPos, syPos, z), pipe2Log, "caloPipePV", frontPanelFoamLog, false, ipipe, false); + pv = new G4PVPlacement(rotPipe1, G4ThreeVector(sxPos, syPos, z), pipe2Log, "caloPipePV3", frontPanelFoamLog, false, ipipe, false); doSurfaceCheck && checkForOverlaps( pv, config, verbosityLevel>0); - pv = new G4PVPlacement(rotPipe3, G4ThreeVector(-sxPos, syPos, z), pipe2Log, "caloPipePV", frontPanelFoamLog, false, ipipe, false); + pv = new G4PVPlacement(rotPipe3, G4ThreeVector(-sxPos, syPos, z), pipe2Log, "caloPipePV4", frontPanelFoamLog, false, ipipe, false); doSurfaceCheck && checkForOverlaps( pv, config, verbosityLevel>0); - pv = new G4PVPlacement(rotPipe2, G4ThreeVector(-sxPos, -syPos, z), pipe2Log, "caloPipePV", frontPanelFoamLog, false, ipipe, false); + pv = new G4PVPlacement(rotPipe2, G4ThreeVector(-sxPos, -syPos, z), pipe2Log, "caloPipePV5", frontPanelFoamLog, false, ipipe, false); doSurfaceCheck && checkForOverlaps( pv, config, verbosityLevel>0); - pv = new G4PVPlacement(rotPipe4, G4ThreeVector(sxPos, -syPos, z), pipe2Log, "caloPipePV", frontPanelFoamLog, false, ipipe, false); + pv = new G4PVPlacement(rotPipe4, G4ThreeVector(sxPos, -syPos, z), pipe2Log, "caloPipePV6", frontPanelFoamLog, false, ipipe, false); doSurfaceCheck && checkForOverlaps( pv, config, verbosityLevel>0); // strait pipes - pv = new G4PVPlacement(sPipeRotate1, G4ThreeVector(xCenter, yCenter, z), pipe3Log, "caloPipePV", frontPanelFoamLog, false, ipipe, false); + pv = new G4PVPlacement(sPipeRotate1, G4ThreeVector(xCenter, yCenter, z), pipe3Log, "caloPipePV7", frontPanelFoamLog, false, ipipe, false); doSurfaceCheck && checkForOverlaps( pv, config, verbosityLevel>0); - pv = new G4PVPlacement(sPipeRotate2, G4ThreeVector(-xCenter, yCenter, z), pipe3Log, "caloPipePV", frontPanelFoamLog, false, ipipe, false); + pv = new G4PVPlacement(sPipeRotate2, G4ThreeVector(-xCenter, yCenter, z), pipe3Log, "caloPipePV8", frontPanelFoamLog, false, ipipe, false); doSurfaceCheck && checkForOverlaps( pv, config, verbosityLevel>0); - pv = new G4PVPlacement(sPipeRotate3, G4ThreeVector(-xCenter, -yCenter, z), pipe3Log, "caloPipePV", frontPanelFoamLog, false, ipipe, false); + pv = new G4PVPlacement(sPipeRotate3, G4ThreeVector(-xCenter, -yCenter, z), pipe3Log, "caloPipePV9", frontPanelFoamLog, false, ipipe, false); doSurfaceCheck && checkForOverlaps( pv, config, verbosityLevel>0); - pv = new G4PVPlacement(sPipeRotate4, G4ThreeVector(xCenter, -yCenter, z), pipe3Log, "caloPipePV", frontPanelFoamLog, false, ipipe, false); + pv = new G4PVPlacement(sPipeRotate4, G4ThreeVector(xCenter, -yCenter, z), pipe3Log, "caloPipePV10", frontPanelFoamLog, false, ipipe, false); doSurfaceCheck && checkForOverlaps( pv, config, verbosityLevel>0); ////pv = new G4PVPlacement(rotPipeFlat,G4ThreeVector(xpipe, y0,z), pipe2Log, "caloPipePV", frontPanelFoamLog, false, ipipe , false); //doSurfaceCheck && checkForOverlaps( pv, config, verbosityLevel>0); From f09ed56f144417db62c4434c08be4fab4236dae3 Mon Sep 17 00:00:00 2001 From: sophieMu2e Date: Wed, 16 Feb 2022 11:37:10 -0600 Subject: [PATCH 22/33] fixed memory leak: --- Analyses/src/CaloCalibAna_module.cc | 2 +- Mu2eG4/src/constructDiskCalorimeter.cc | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Analyses/src/CaloCalibAna_module.cc b/Analyses/src/CaloCalibAna_module.cc index e2695d58e9..0090e8baac 100644 --- a/Analyses/src/CaloCalibAna_module.cc +++ b/Analyses/src/CaloCalibAna_module.cc @@ -400,7 +400,7 @@ namespace mu2e { if (edepTime<1) hCryEEMC2_->Fill(hit.energyDep(), sumEdepMC); } nCrystals_ = crystalsHit.size(); - std::cout<<" Analyzer "<rotateZ(CLHEP::pi/2.0); rotPipe1->rotateZ(0.0 * CLHEP::pi); - - G4RotationMatrix* rotPipe2 = reg.add(new G4RotationMatrix()); + reg.add(rotPipe1); + G4RotationMatrix* rotPipe2 = new G4RotationMatrix(); rotPipe2->rotateZ(1.0 * CLHEP::pi); reg.add(rotPipe2); - G4RotationMatrix* rotPipe3 = reg.add(new G4RotationMatrix()); + G4RotationMatrix* rotPipe3 = new G4RotationMatrix(); rotPipe3->rotateY(1.0 * CLHEP::pi); reg.add(rotPipe3); - G4RotationMatrix* rotPipe4 = reg.add(new G4RotationMatrix()); + G4RotationMatrix* rotPipe4 = new G4RotationMatrix(); rotPipe4->rotateX(1.0 * CLHEP::pi); reg.add(rotPipe4); From 941c47f10e0c62c36e3d88e44369b9a1179d2dd7 Mon Sep 17 00:00:00 2001 From: sophieMu2e Date: Wed, 16 Feb 2022 11:48:50 -0600 Subject: [PATCH 23/33] fixed construction --- Mu2eG4/src/constructDiskCalorimeter.cc | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Mu2eG4/src/constructDiskCalorimeter.cc b/Mu2eG4/src/constructDiskCalorimeter.cc index fae578b8e3..6d6bd62674 100644 --- a/Mu2eG4/src/constructDiskCalorimeter.cc +++ b/Mu2eG4/src/constructDiskCalorimeter.cc @@ -302,19 +302,19 @@ namespace mu2e { //pipes nside foam - G4RotationMatrix* rotPipe1 = new G4RotationMatrix(); + G4RotationMatrix* rotPipe1 = nullptr; //rotPipe1->rotateZ(CLHEP::pi/2.0); - rotPipe1->rotateZ(0.0 * CLHEP::pi); + //rotPipe1->rotateZ(0.0 * CLHEP::pi); reg.add(rotPipe1); - G4RotationMatrix* rotPipe2 = new G4RotationMatrix(); + G4RotationMatrix* rotPipe2 = reg.add(new G4RotationMatrix()); rotPipe2->rotateZ(1.0 * CLHEP::pi); - reg.add(rotPipe2); - G4RotationMatrix* rotPipe3 = new G4RotationMatrix(); + //reg.add(rotPipe2); + G4RotationMatrix* rotPipe3 = reg.add(new G4RotationMatrix()); rotPipe3->rotateY(1.0 * CLHEP::pi); - reg.add(rotPipe3); - G4RotationMatrix* rotPipe4 = new G4RotationMatrix(); + //reg.add(rotPipe3); + G4RotationMatrix* rotPipe4 = reg.add(new G4RotationMatrix()); rotPipe4->rotateX(1.0 * CLHEP::pi); - reg.add(rotPipe4); + //reg.add(rotPipe4); for (int ipipe=0; ipipe Date: Wed, 16 Feb 2022 13:59:22 -0600 Subject: [PATCH 24/33] final fix --- Mu2eG4/src/constructDiskCalorimeter.cc | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/Mu2eG4/src/constructDiskCalorimeter.cc b/Mu2eG4/src/constructDiskCalorimeter.cc index 6d6bd62674..8989f38284 100644 --- a/Mu2eG4/src/constructDiskCalorimeter.cc +++ b/Mu2eG4/src/constructDiskCalorimeter.cc @@ -303,18 +303,14 @@ namespace mu2e { //pipes nside foam G4RotationMatrix* rotPipe1 = nullptr; - //rotPipe1->rotateZ(CLHEP::pi/2.0); - //rotPipe1->rotateZ(0.0 * CLHEP::pi); - reg.add(rotPipe1); G4RotationMatrix* rotPipe2 = reg.add(new G4RotationMatrix()); rotPipe2->rotateZ(1.0 * CLHEP::pi); - //reg.add(rotPipe2); + G4RotationMatrix* rotPipe3 = reg.add(new G4RotationMatrix()); rotPipe3->rotateY(1.0 * CLHEP::pi); - //reg.add(rotPipe3); + G4RotationMatrix* rotPipe4 = reg.add(new G4RotationMatrix()); rotPipe4->rotateX(1.0 * CLHEP::pi); - //reg.add(rotPipe4); for (int ipipe=0; ipipe Date: Wed, 16 Feb 2022 14:52:53 -0600 Subject: [PATCH 25/33] removed comments --- Mu2eG4/src/constructDiskCalorimeter.cc | 28 +++++--------------------- 1 file changed, 5 insertions(+), 23 deletions(-) diff --git a/Mu2eG4/src/constructDiskCalorimeter.cc b/Mu2eG4/src/constructDiskCalorimeter.cc index 8989f38284..97807d79e8 100644 --- a/Mu2eG4/src/constructDiskCalorimeter.cc +++ b/Mu2eG4/src/constructDiskCalorimeter.cc @@ -314,28 +314,20 @@ namespace mu2e { for (int ipipe=0; ipipe rotateX(0.5 * CLHEP::pi); sPipeRotate1 -> rotateY((-0.5*CLHEP::pi + zRotateAngle)); @@ -359,12 +350,11 @@ namespace mu2e { G4RotationMatrix* sPipeRotate4 = reg.add(new G4RotationMatrix()); sPipeRotate4 -> rotateX(0.5 * CLHEP::pi); sPipeRotate4 -> rotateY((-1.5*CLHEP::pi - zRotateAngle)); - //reg.add(sPipeRotate); + // transform movement double xCenter = 0.5 * (xEnd + xStart); double yCenter = 0.5 * (yEnd + yStart); - // the strait tubes at the origin coordinate system - //std::cout << "the length of the strait pipes: " << sLength << std::endl; + // the straight tubes at the origin coordinate system G4Tubs* pipe3 = new G4Tubs("caloPipe3", pipeRadius-pipeThickness, pipeRadius, 0.5 * (sLength - 4.), 0, CLHEP::twopi); G4LogicalVolume* pipe3Log = caloBuildLogical(pipe3, pipeMaterial, "caloPipe3Log",isPipeVisible,G4Color::Cyan(),isPipeSolid,forceEdge); @@ -391,15 +381,7 @@ namespace mu2e { pv = new G4PVPlacement(sPipeRotate3, G4ThreeVector(-xCenter, -yCenter, z), pipe3Log, "caloPipePV9", frontPanelFoamLog, false, ipipe, false); doSurfaceCheck && checkForOverlaps( pv, config, verbosityLevel>0); pv = new G4PVPlacement(sPipeRotate4, G4ThreeVector(xCenter, -yCenter, z), pipe3Log, "caloPipePV10", frontPanelFoamLog, false, ipipe, false); - doSurfaceCheck && checkForOverlaps( pv, config, verbosityLevel>0); - ////pv = new G4PVPlacement(rotPipeFlat,G4ThreeVector(xpipe, y0,z), pipe2Log, "caloPipePV", frontPanelFoamLog, false, ipipe , false); - //doSurfaceCheck && checkForOverlaps( pv, config, verbosityLevel>0); - //pv = new G4PVPlacement(rotPipeFlat,G4ThreeVector(xpipe,-y0,z), pipe2Log, "caloPipePV", frontPanelFoamLog, false, ipipe , false); - //doSurfaceCheck && checkForOverlaps( pv, config, verbosityLevel>0); - //pv = new G4PVPlacement(rotPipeFlat,G4ThreeVector(-xpipe,y1,z), pipe2Log, "caloPipePV", frontPanelFoamLog, false, ipipe , false); - //doSurfaceCheck && checkForOverlaps( pv, config, verbosityLevel>0); - //pv = new G4PVPlacement(rotPipeFlat,G4ThreeVector(-xpipe,-y1,z), pipe2Log, "caloPipePV", frontPanelFoamLog, false, ipipe , false); - //doSurfaceCheck && checkForOverlaps( pv, config, verbosityLevel>0); + doSurfaceCheck && checkForOverlaps( pv, config, verbosityLevel>0); } return frontPlateLog; From aefd0ebcec300dedfaf6a9641a9efac9f23a144c Mon Sep 17 00:00:00 2001 From: sophieMu2e Date: Thu, 17 Feb 2022 14:44:55 -0600 Subject: [PATCH 26/33] fixed typo --- EventGenerator/src/CaloCalibGun_module.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/EventGenerator/src/CaloCalibGun_module.cc b/EventGenerator/src/CaloCalibGun_module.cc index d19478f20b..9d382406c1 100644 --- a/EventGenerator/src/CaloCalibGun_module.cc +++ b/EventGenerator/src/CaloCalibGun_module.cc @@ -232,6 +232,7 @@ namespace mu2e { //Pick energy and momentum vector double energy =_energy; + CLHEP::Hep3Vector p3 = _randomUnitSphere.fire(_energy); //Set Four-momentum From 310f5673d4fd21282c4235a3319b0c013aab46ac Mon Sep 17 00:00:00 2001 From: sophieMu2e Date: Thu, 17 Feb 2022 16:56:52 -0600 Subject: [PATCH 27/33] this didnt push last time --- Mu2eG4/src/constructDiskCalorimeter.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Mu2eG4/src/constructDiskCalorimeter.cc b/Mu2eG4/src/constructDiskCalorimeter.cc index 97807d79e8..bb0ed18986 100644 --- a/Mu2eG4/src/constructDiskCalorimeter.cc +++ b/Mu2eG4/src/constructDiskCalorimeter.cc @@ -327,7 +327,7 @@ namespace mu2e { G4Torus* pipe2 = new G4Torus("caloPipe2", pipeRadius-pipeThickness, pipeRadius, radSmTor, angle-sAngle+CLHEP::pi, sAngle); G4LogicalVolume* pipe1Log = caloBuildLogical(pipe1, pipeMaterial, "caloPipe1Log",isPipeVisible,G4Color::Cyan(),isPipeSolid,forceEdge); G4LogicalVolume* pipe2Log = caloBuildLogical(pipe2, pipeMaterial, "caloPipe2Log",isPipeVisible,G4Color::Green(),isPipeSolid,forceEdge); - / + // calculate the parameters of the strait pipes // minus 2.0 mm from the manifold pipe's most inner radius to avoid the overlap. double xEnd = (FPCoolPipeTorRadius -FPCoolPipeRadius) * sin(straitEndPhi[ipipe] * CLHEP::degree); From ab9ebab17a5ed9c567f5e18813e568b3a5c180b7 Mon Sep 17 00:00:00 2001 From: sophieMu2e Date: Fri, 18 Feb 2022 11:37:17 -0600 Subject: [PATCH 28/33] bertrands comments --- Analyses/fcl/prolog.fcl | 1 - Analyses/src/CaloCalibAna_module.cc | 23 ++++----- EventGenerator/src/CaloCalibGun_module.cc | 52 ++++++++++----------- GeometryService/src/DiskCalorimeterMaker.cc | 8 ++-- Mu2eG4/geom/calorimeter_CsI.txt | 4 +- Mu2eG4/src/constructDiskCalorimeter.cc | 22 ++++----- 6 files changed, 53 insertions(+), 57 deletions(-) diff --git a/Analyses/fcl/prolog.fcl b/Analyses/fcl/prolog.fcl index 6534e876c4..c8088f4786 100644 --- a/Analyses/fcl/prolog.fcl +++ b/Analyses/fcl/prolog.fcl @@ -72,7 +72,6 @@ VirtualDetectorDefaults: { } - # Many configurations use "readvd" readvd: @local::VirtualDetectorDefaults ClusterCompareNew : diff --git a/Analyses/src/CaloCalibAna_module.cc b/Analyses/src/CaloCalibAna_module.cc index 0090e8baac..ddb969da02 100644 --- a/Analyses/src/CaloCalibAna_module.cc +++ b/Analyses/src/CaloCalibAna_module.cc @@ -180,7 +180,7 @@ namespace mu2e { Ntup_->Branch("simGenIdx", &crySimGenIdx_ ,"simGenIdx[nSim]/I"); // Reconstructed cluster info (from CaloClusterCollection): - Ntup_->Branch("nCluster", &nCluster_ , "nCluster/I"); + /*Ntup_->Branch("nCluster", &nCluster_ , "nCluster/I"); Ntup_->Branch("cluEnergy", &cluEnergy_ , "cluEnergy[nCluster]/F"); Ntup_->Branch("cluEnergyErr", &cluEnergyErr_ ,"cluEnergyErr[nCluster]/F"); Ntup_->Branch("cluTime", &cluTime_ , "cluTime[nCluster]/F"); @@ -197,10 +197,10 @@ namespace mu2e { Ntup_->Branch("cluConv", &cluConv_ , "cluConv[nCluster]/I"); Ntup_->Branch("cluSimIdx", &cluSimIdx_ , "cluSimIdx[nCluster]/I"); Ntup_->Branch("cluSimLen", &cluSimLen_ , "cluSimLen[nCluster]/I"); - Ntup_->Branch("cluList", &cluList_); + Ntup_->Branch("cluList", &cluList_);*/ // Truth CaloCluster info (from CaloClusterMCCollection) - Ntup_->Branch("nCluSim", &nCluSim_ , "nCluSim/I"); + /*Ntup_->Branch("nCluSim", &nCluSim_ , "nCluSim/I"); Ntup_->Branch("cluSimId", &cluSimId_ , "cluSimId[nCluSim]/I"); Ntup_->Branch("cluSimPdgId", &cluSimPdgId_ , "cluSimPdgId[nCluSim]/I"); Ntup_->Branch("cluSimGenId", &cluSimGenId_ , "cluSimGenId[nCluSim]/I"); @@ -215,11 +215,8 @@ namespace mu2e { Ntup_->Branch("cluSimStartY", &cluSimStartY_ ,"cluSimStartY[nCluSim]/F"); Ntup_->Branch("cluSimStartZ", &cluSimStartZ_ ,"cluSimStartZ[nCluSim]/F"); Ntup_->Branch("cluSimTime", &cluSimTime_ , "cluSimTime[nCluSim]/F"); - Ntup_->Branch("cluSimEdep", &cluSimEdep_ , "cluSimEdep[nCluSim]/F"); + Ntup_->Branch("cluSimEdep", &cluSimEdep_ , "cluSimEdep[nCluSim]/F");*/ - // Calibration Analysis - - // Virtual Detector info (from StepPointMCCollection) Ntup_->Branch("nVd", &nVd_ , "nVd/I"); Ntup_->Branch("vdId", &vdId_ , "vdId[nVd]/I"); @@ -273,9 +270,9 @@ namespace mu2e { const CaloHitCollection& CaloHits(*CaloHitsHandle); //Calorimeter clusters - art::Handle caloClustersHandle; + /*art::Handle caloClustersHandle; event.getByLabel(caloClusterTag_, caloClustersHandle); - const CaloClusterCollection& caloClusters(*caloClustersHandle); + const CaloClusterCollection& caloClusters(*caloClustersHandle);*/ //Virtual detector hits art::Handle vdhits; @@ -287,9 +284,9 @@ namespace mu2e { const CaloHitMCCollection& caloHitTruth(*caloHitMCHandle); //Calo cluster truth assignment - art::Handle caloClusterMCHandle; + /*art::Handle caloClusterMCHandle; event.getByLabel(caloClusterTruthTag_, caloClusterMCHandle); - const CaloClusterMCCollection& caloClusterTruth(*caloClusterMCHandle); + const CaloClusterMCCollection& caloClusterTruth(*caloClusterMCHandle);*/ _evt = event.id().event(); @@ -405,7 +402,7 @@ namespace mu2e { nCluster_ = nCluSim_ = 0; cluList_.clear(); - for (unsigned int ic=0; ic cryList; @@ -480,7 +477,7 @@ namespace mu2e { hcluZ_->Fill(cluster.cog3Vector().z()); hCluEEMC_->Fill(cluster.energyDep(), sumEdepMC); hCluTTMC_->Fill(cluster.time(), edepTime); - } + }*/ //-------------------------- Do virtual detectors -------------------------------- diff --git a/EventGenerator/src/CaloCalibGun_module.cc b/EventGenerator/src/CaloCalibGun_module.cc index 9d382406c1..4b90607f08 100644 --- a/EventGenerator/src/CaloCalibGun_module.cc +++ b/EventGenerator/src/CaloCalibGun_module.cc @@ -44,7 +44,6 @@ //ROOT Includes #include -const double piconst = CLHEP::pi; using CLHEP::degree; using namespace std; using namespace mu2e; @@ -64,6 +63,7 @@ namespace mu2e { fhicl::Atom phimax{Name("phimax"), CLHEP::twopi }; fhicl::Atom tmin{Name("tmin"),0.}; fhicl::Atom tmax{Name("tmax"),1694.}; + fhicl::Atom nDisk{Name("nDisk"),1}; fhicl::Atom doHistograms{Name("doHistograms"), true }; }; @@ -83,6 +83,7 @@ namespace mu2e { double _phimax; double _tmin; double _tmax; + int _nDisk; art::RandomNumberGenerator::base_engine_t& _engine; CLHEP::RandFlat _randFlat; @@ -108,6 +109,7 @@ namespace mu2e { , _phimax{conf().phimax()} , _tmin{conf().tmin()} , _tmax{conf().tmax()} + , _nDisk{conf().nDisk()} , _engine{createEngine(art::ServiceHandle()->getSeed())} , _randFlat{_engine} , _randPoissonQ{_engine, _mean*1.0} @@ -131,50 +133,50 @@ namespace mu2e { _pipeRadius = _cal->caloInfo().getDouble("pipeRadius"); _pipeTorRadius = _cal->caloInfo().getVDouble("pipeTorRadius"); _randomRad = _cal->caloInfo().getVDouble("pipeTorRadius"); - _zPipeCenter = _cal->disk(1).geomInfo().origin()-CLHEP::Hep3Vector(0,0,_cal->disk(1).geomInfo().size().z()/2.0-_pipeRadius);//disk =1 + _zPipeCenter = _cal->disk(_nDisk).geomInfo().origin()-CLHEP::Hep3Vector(0,0,_cal->disk(_nDisk).geomInfo().size().z()/2.0-_pipeRadius);//disk =1 // we normalize to the volume of the pipe (proportional to 2*pi*R if they have all the same radius) to draw a random number from which to generate the photons TODO - is this used? double sumR(0); std::for_each(_randomRad.begin(), _randomRad.end(), [&](double& d) {sumR+=d; d = sumR; }); std::for_each(_randomRad.begin(), _randomRad.end(), [&](double& d) {d /= sumR;}); - - unsigned int nGen = _mean; + //Define the parameters of the pipes: // angle of large torus in degrees - std::vector phi_lbd = _cal->caloInfo().getVDouble("LargeTorPhi");//{161.34, 149.50, 139.50, 132.07, 125.39}; + std::vector phi_lbd = _cal->caloInfo().getVDouble("largeTorPhi"); // angle of small torus in degrees - std::vector phi_sbd = _cal->caloInfo().getVDouble("smallTorPhi");//{84.63, 85.28, 85.79, 86.20, 86.53}; + std::vector phi_sbd = _cal->caloInfo().getVDouble("smallTorPhi"); // angle of the end point - std::vector phi_end = _cal->caloInfo().getVDouble("straitEndPhi");//{3.96, 10.53, 15.80, 20.16, 23.84}; + std::vector phi_end = _cal->caloInfo().getVDouble("straightEndPhi"); // center position y of the small torus - std::vector ysmall = _cal->caloInfo().getVDouble("yposition");//{432.2, 480.5, 524.3, 564.7, 602.5}; + std::vector ysmall = _cal->caloInfo().getVDouble("yposition"); // radius of small torus - double radSmTor = _cal->caloInfo().getDouble("radSmTor");//41.0; + double radSmTor = _cal->caloInfo().getDouble("radSmTor"); // first center position x of the small torus - double xsmall = _cal->caloInfo().getDouble("radSmTor");//71.0; + double xsmall = _cal->caloInfo().getDouble("radSmTor"); // distance of the small torus center - double xdistance = _cal->caloInfo().getDouble("xdistance");//60.0; + double xdistance = _cal->caloInfo().getDouble("xdistance"); // inner radius of the manifold - double rInnerManifold = _cal->caloInfo().getDouble("rInnerManifold");//681.6; // 713.35 mm - 1.25 in (31.75 mm) + double rInnerManifold = _cal->caloInfo().getDouble("rInnerManifold"); vector sign{-1.0, 1.0}; - for (unsigned int ig = 0; ig < nGen; ++ig) + for (unsigned int ig = 0; ig < _mean; ++ig) { - // only in the front of 2nd disk. - //int nDisk = 1; - //_zPipeCenter = _cal->disk(nDisk).geomInfo().origin()-CLHEP::Hep3Vector(0,0,_cal->disk(nDisk).geomInfo().size().z()/2.0-_pipeRadius); - double xpipe, ypipe, zpipe; - //Pick position - int xsn = round(_randFlat.fire()); + //Pick position - find either 0,1 - these are indices of the sign list (so 0=-1, 1=+1) + int xsn = round(_randFlat.fire()); int ysn = round(_randFlat.fire()); - double theta = _randFlat.fire() * 2.0 * piconst; - double pipeR = _pipeRadius * _randFlat.fire(); + // pick a random theta, between 0 and 2*pi: + double theta = _randFlat.fire() * 2.0 * CLHEP::pi; + // pick a random point on the radius + double pipeR = _pipeRadius * sqrt(_randFlat.fire()); + // find the z position based on above: zpipe = pipeR*sin(theta); double rtest = _randFlat.fire(); + // select an index from list of pipes: int idx = int( std::lower_bound(_randomRad.begin(), _randomRad.end(), rtest) - _randomRad.begin()); + // select the LgTor from list extracted from geom service above: double radLgTor = _pipeTorRadius[idx]; // The phi range from 0 to half phi_lbd for the large torus @@ -193,8 +195,8 @@ namespace mu2e { // circulus (center) of the small torus double circSmTor = CLHEP::degree * radSmTor * phi_sbd[idx]; - // strait pipe - //double xmanifold = rInnerManifold * cos(piconst * (90 - phi_end[idx])/180.); + // straight pipe + //double xmanifold = rInnerManifold * cos(CLHEP::pi * (90 - phi_end[idx])/180.); double ymanifold = rInnerManifold * sin(CLHEP::degree * (90 - phi_end[idx])); double xstart = xsmall + xdistance * idx - radSmTor * cos(CLHEP::degree * phi_end[idx]); double ystart = ysmall[idx] + radSmTor * sin(CLHEP::degree * phi_end[idx]); @@ -231,12 +233,10 @@ namespace mu2e { double time = _tmin + _randFlat.fire() * ( _tmax - _tmin ); //Pick energy and momentum vector - double energy =_energy; - CLHEP::Hep3Vector p3 = _randomUnitSphere.fire(_energy); //Set Four-momentum - CLHEP::HepLorentzVector mom(p3.x(), p3.y(),p3.z(),energy ); + CLHEP::HepLorentzVector mom(p3.x(), p3.y(),p3.z(),_energy ); // Add the particle to the list. output->emplace_back(PDGCode::gamma, GenId::CaloCalib, pos, mom, time); diff --git a/GeometryService/src/DiskCalorimeterMaker.cc b/GeometryService/src/DiskCalorimeterMaker.cc index 0aa687f027..5d82db7f4f 100644 --- a/GeometryService/src/DiskCalorimeterMaker.cc +++ b/GeometryService/src/DiskCalorimeterMaker.cc @@ -128,8 +128,8 @@ namespace mu2e { calo_->caloInfo_.set("pipeTorRadius",temp ); temp.clear(); //For source calibration system: - config.getVectorDouble("calorimeter.LargeTorPhi", temp, calo_->caloInfo_.getInt("nPipes")); - calo_->caloInfo_.set("LargeTorPhi", temp ); + config.getVectorDouble("calorimeter.largeTorPhi", temp, calo_->caloInfo_.getInt("nPipes")); + calo_->caloInfo_.set("largeTorPhi", temp ); temp.clear(); config.getVectorDouble("calorimeter.smallTorPhi", temp, calo_->caloInfo_.getInt("nPipes")); calo_->caloInfo_.set("smallTorPhi", temp ); @@ -137,8 +137,8 @@ namespace mu2e { config.getVectorDouble("calorimeter.yposition", temp, calo_->caloInfo_.getInt("nPipes")); calo_->caloInfo_.set("yposition", temp ); temp.clear(); - config.getVectorDouble("calorimeter.straitEndPhi", temp, calo_->caloInfo_.getInt("nPipes")); - calo_->caloInfo_.set("straitEndPhi", temp ); + config.getVectorDouble("calorimeter.straightEndPhi", temp, calo_->caloInfo_.getInt("nPipes")); + calo_->caloInfo_.set("straightEndPhi", temp ); temp.clear(); calo_->caloInfo_.set("radSmTor", config.getDouble("calorimeter.radSmTor") ); calo_->caloInfo_.set("xsmall", config.getDouble("calorimeter.xsmall") ); diff --git a/Mu2eG4/geom/calorimeter_CsI.txt b/Mu2eG4/geom/calorimeter_CsI.txt index 801d732ce9..6f384534b8 100644 --- a/Mu2eG4/geom/calorimeter_CsI.txt +++ b/Mu2eG4/geom/calorimeter_CsI.txt @@ -62,9 +62,9 @@ double calorimeter.pipeThickness = 0.5; double calorimeter.pipeInitSeparation = 25.4; -vector calorimeter.LargeTorPhi = {161.34, 149.50, 139.50, 132.07, 125.39};//full angle of large torus +vector calorimeter.largeTorPhi = {161.34, 149.50, 139.50, 132.07, 125.39};//full angle of large torus vector calorimeter.smallTorPhi = {84.63, 85.28, 85.79, 86.20, 86.53}; // full angle of small torus -vector calorimeter.straitEndPhi = {3.96, 10.53, 15.80, 20.16, 23.84}; // angle of the ending poing of the strait pipe +vector calorimeter.straightEndPhi = {3.96, 10.53, 15.80, 20.16, 23.84}; // angle of the ending poing of the straight pipe vector calorimeter.yposition = {432.2, 480.5, 524.3, 564.7, 602.5}; // start y position of the strait pipe double calorimeter.radSmTor = 41.0; double calorimeter.xsmall = 71.0; diff --git a/Mu2eG4/src/constructDiskCalorimeter.cc b/Mu2eG4/src/constructDiskCalorimeter.cc index bb0ed18986..50856837d7 100644 --- a/Mu2eG4/src/constructDiskCalorimeter.cc +++ b/Mu2eG4/src/constructDiskCalorimeter.cc @@ -253,10 +253,10 @@ namespace mu2e { G4double pipeThickness = cal.caloInfo().getDouble("pipeThickness"); G4double pipeInitSeparation = cal.caloInfo().getDouble("pipeInitSeparation"); std::vector pipeTorRadius = cal.caloInfo().getVDouble("pipeTorRadius"); - std::vector LargeTorPhi = cal.caloInfo().getVDouble("LargeTorPhi"); + std::vector largeTorPhi = cal.caloInfo().getVDouble("largeTorPhi"); std::vector smallTorPhi = cal.caloInfo().getVDouble("smallTorPhi"); std::vector yposition = cal.caloInfo().getVDouble("yposition"); - std::vector straitEndPhi = cal.caloInfo().getVDouble("straitEndPhi"); + std::vector straightEndPhi = cal.caloInfo().getVDouble("straightEndPhi"); G4double radSmTor = cal.caloInfo().getDouble("radSmTor"); G4double xsmall = cal.caloInfo().getDouble("xsmall"); G4double xdistance = cal.caloInfo().getDouble("xdistance"); @@ -284,7 +284,7 @@ namespace mu2e { //Foam panel G4Tubs* frontPanelFoam = new G4Tubs("caloFPFoam",FPInnerRadius,FPOuterRadius,FPFoamDZ,0,CLHEP::twopi); - G4LogicalVolume* frontPanelFoamLog = caloBuildLogical(frontPanelFoam, FPFoamMaterial, "caloFPFoamLog"+std::to_string(idisk),isPipeVisible,G4Color::Brown(),0,forceEdge); + G4LogicalVolume* frontPanelFoamLog = caloBuildLogical(frontPanelFoam, FPFoamMaterial, "caloFPFoamLog_"+std::to_string(idisk),isPipeVisible,G4Color::Brown(),0,forceEdge); pv = new G4PVPlacement(0,G4ThreeVector(0.0,0.0,ZposFoam), frontPanelFoamLog, "caloFPFoamPV", frontPlateLog, false, 0, false); doSurfaceCheck && checkForOverlaps( pv, config, verbosityLevel>0); @@ -302,7 +302,7 @@ namespace mu2e { //pipes nside foam - G4RotationMatrix* rotPipe1 = nullptr; + G4RotationMatrix* rotPipe1 = nullptr; //using the identity matrix G4RotationMatrix* rotPipe2 = reg.add(new G4RotationMatrix()); rotPipe2->rotateZ(1.0 * CLHEP::pi); @@ -315,7 +315,7 @@ namespace mu2e { for (int ipipe=0; ipipe0); - // strait pipes + // straight pipes pv = new G4PVPlacement(sPipeRotate1, G4ThreeVector(xCenter, yCenter, z), pipe3Log, "caloPipePV7", frontPanelFoamLog, false, ipipe, false); doSurfaceCheck && checkForOverlaps( pv, config, verbosityLevel>0); pv = new G4PVPlacement(sPipeRotate2, G4ThreeVector(-xCenter, yCenter, z), pipe3Log, "caloPipePV8", frontPanelFoamLog, false, ipipe, false); From 24f0cda8b6fa97ec1cd92365c371937ffc7d0683 Mon Sep 17 00:00:00 2001 From: sophieMu2e Date: Wed, 23 Feb 2022 13:40:48 -0600 Subject: [PATCH 29/33] Robs comments --- CaloMC/fcl/RunCaloCalibGun.fcl | 3 +-- EventGenerator/src/CaloCalibGun_module.cc | 19 ++++--------------- MCDataProducts/inc/ProcessCode.hh | 4 ++-- 3 files changed, 7 insertions(+), 19 deletions(-) diff --git a/CaloMC/fcl/RunCaloCalibGun.fcl b/CaloMC/fcl/RunCaloCalibGun.fcl index 112de117bd..219cccbb0f 100644 --- a/CaloMC/fcl/RunCaloCalibGun.fcl +++ b/CaloMC/fcl/RunCaloCalibGun.fcl @@ -33,7 +33,6 @@ physics: { phimax : 2.0 tmin : 500. tmax : 1694. - doHistograms: true } g4run : @local::g4run @@ -86,7 +85,7 @@ physics: { } physics.producers.CaloHitTruthMatch.primaryParticle : "generate" -physics.producers.FindMCPrimary.PrimaryProcess : "CaloCalib" +physics.producers.FindMCPrimary.PrimaryProcess : "mu2eCaloCalib" physics.producers.EWMProducer.SpillType : 0 physics.producers.muonTimeMap.applyToGenIds : [ "StoppedParticleReactionGun", "dioTail", "ExternalRMC", "InternalRMC", diff --git a/EventGenerator/src/CaloCalibGun_module.cc b/EventGenerator/src/CaloCalibGun_module.cc index 4b90607f08..af64239d8b 100644 --- a/EventGenerator/src/CaloCalibGun_module.cc +++ b/EventGenerator/src/CaloCalibGun_module.cc @@ -8,9 +8,6 @@ #include // Framework includes -#include "art/Framework/Principal/Run.h" -#include "art_root_io/TFileDirectory.h" -#include "art_root_io/TFileService.h" #include "messagefacility/MessageLogger/MessageLogger.h" #include "art/Framework/Core/EDProducer.h" #include "art/Framework/Core/ModuleMacros.h" @@ -37,16 +34,10 @@ #include "CLHEP/Random/RandExponential.h" #include "CLHEP/Random/RandPoissonQ.h" - #include "fhiclcpp/types/Atom.h" #include "messagefacility/MessageLogger/MessageLogger.h" -//ROOT Includes -#include - -using CLHEP::degree; using namespace std; -using namespace mu2e; namespace mu2e { @@ -64,7 +55,6 @@ namespace mu2e { fhicl::Atom tmin{Name("tmin"),0.}; fhicl::Atom tmax{Name("tmax"),1694.}; fhicl::Atom nDisk{Name("nDisk"),1}; - fhicl::Atom doHistograms{Name("doHistograms"), true }; }; using Parameters= art::EDProducer::Table; @@ -90,8 +80,7 @@ namespace mu2e { CLHEP::RandPoissonQ _randPoissonQ; RandomUnitSphere _randomUnitSphere; - const DiskCalorimeter *_cal; - //int _nPipes; + //int _nPipes; double _pipeRadius; std::vector _pipeTorRadius; std::vector _randomRad; @@ -128,7 +117,7 @@ namespace mu2e { PrimaryParticle primaryParticles; MCTrajectoryCollection mctc; - _cal = &*GeomHandle(); + const DiskCalorimeter *_cal = GeomHandle().get(); //_nPipes = _cal->caloInfo().getInt("nPipes"); _pipeRadius = _cal->caloInfo().getDouble("pipeRadius"); _pipeTorRadius = _cal->caloInfo().getVDouble("pipeTorRadius"); @@ -200,7 +189,7 @@ namespace mu2e { double ymanifold = rInnerManifold * sin(CLHEP::degree * (90 - phi_end[idx])); double xstart = xsmall + xdistance * idx - radSmTor * cos(CLHEP::degree * phi_end[idx]); double ystart = ysmall[idx] + radSmTor * sin(CLHEP::degree * phi_end[idx]); - // height of the strait pipe + // height of the straight pipe double hPipe = (ymanifold - ystart) / sin(CLHEP::degree * (90 - phi_end[idx])); // a cylinder along y-axis double y_center = _randFlat.fire() * hPipe; @@ -226,7 +215,7 @@ namespace mu2e { ypipe = yStrait; } CLHEP::Hep3Vector pos(xpipe, ypipe, zpipe); - // shift the pipe to the front of the calorimeter disk 0 + // shift the pipe to the front of the calorimeter disk pos +=_zPipeCenter; //pick time diff --git a/MCDataProducts/inc/ProcessCode.hh b/MCDataProducts/inc/ProcessCode.hh index 1f130b3800..48014fe083 100644 --- a/MCDataProducts/inc/ProcessCode.hh +++ b/MCDataProducts/inc/ProcessCode.hh @@ -86,7 +86,7 @@ namespace mu2e { mu2eCeMinusLeadingLog, mu2eCePlusEndpoint, mu2eDIOLeadingLog, mu2eInternalRMC, // 171 mu2eExternalRMC, mu2eFlateMinus, mu2eFlatePlus, mu2eFlatPhoton, // 175 mu2eCePlusLeadingLog, mu2ePionCaptureAtRest, mu2eExternalRPC, mu2eInternalRPC, - CaloCalib, mu2eunused6, mu2eunused7, mu2eunused8, + mu2eCaloCalib, mu2eunused6, mu2eunused7, mu2eunused8, uninitialized, NoProcess, lastEnum, // An alias for backward compatibility @@ -142,7 +142,7 @@ namespace mu2e { "mu2eCeMinusLeadingLog", "mu2eCePlusEndpoint", "mu2eDIOLeadingLog", "mu2eInternalRMC", \ "mu2eExternalRMC", "mu2eFlateMinus", "mu2eFlatePlus", "mu2eFlatPhoton", \ "mu2eCePlusLeadingLog", "mu2ePionCaptureAtRest", "mu2eExternalRPC", "mu2eInternalRPC", \ - "CaloCalib", "mu2eunused6", "mu2eunused7", "mu2eunused8", \ + "mu2eCaloCalib", "mu2eunused6", "mu2eunused7", "mu2eunused8", \ "uninitialized", "NoProcess" #endif From a4241a2228d50d9f7269cddc69cd7dcfd8f6ba55 Mon Sep 17 00:00:00 2001 From: sophieMu2e Date: Wed, 23 Feb 2022 16:06:28 -0600 Subject: [PATCH 30/33] swaped calorimeter geom files --- Mu2eG4/geom/calorimeter_CsI.txt | 10 -- Mu2eG4/geom/calorimeter_CsI_v02.txt | 145 +++++++++++++++++++++++++++ Mu2eG4/geom/geom_2021_PhaseI_v03.txt | 121 ++++++++++++++++++++++ Mu2eG4/geom/geom_common_current.txt | 2 +- 4 files changed, 267 insertions(+), 11 deletions(-) create mode 100644 Mu2eG4/geom/calorimeter_CsI_v02.txt create mode 100644 Mu2eG4/geom/geom_2021_PhaseI_v03.txt diff --git a/Mu2eG4/geom/calorimeter_CsI.txt b/Mu2eG4/geom/calorimeter_CsI.txt index 6f384534b8..12e609939f 100644 --- a/Mu2eG4/geom/calorimeter_CsI.txt +++ b/Mu2eG4/geom/calorimeter_CsI.txt @@ -61,16 +61,6 @@ double calorimeter.pipeRadius = 4.75; double calorimeter.pipeThickness = 0.5; double calorimeter.pipeInitSeparation = 25.4; - -vector calorimeter.largeTorPhi = {161.34, 149.50, 139.50, 132.07, 125.39};//full angle of large torus -vector calorimeter.smallTorPhi = {84.63, 85.28, 85.79, 86.20, 86.53}; // full angle of small torus -vector calorimeter.straightEndPhi = {3.96, 10.53, 15.80, 20.16, 23.84}; // angle of the ending poing of the straight pipe -vector calorimeter.yposition = {432.2, 480.5, 524.3, 564.7, 602.5}; // start y position of the strait pipe -double calorimeter.radSmTor = 41.0; -double calorimeter.xsmall = 71.0; -double calorimeter.xdistance = 60.0; -double calorimeter.rInnerManifold = 681.6; - int calorimeter.crateVersion = 2; int calorimeter.numberOfCrates = 10; int calorimeter.numberOfBoards = 9; diff --git a/Mu2eG4/geom/calorimeter_CsI_v02.txt b/Mu2eG4/geom/calorimeter_CsI_v02.txt new file mode 100644 index 0000000000..6f384534b8 --- /dev/null +++ b/Mu2eG4/geom/calorimeter_CsI_v02.txt @@ -0,0 +1,145 @@ +// Crystal calorimeter - all length in mm, angles in degres + +double calorimeter.caloMotherRadiusIn = 330; +double calorimeter.caloMotherRadiusOut = 719;//720; +double calorimeter.caloMotherZ0 = 11842; +double calorimeter.caloMotherZ1 = 13220; +double calorimeter.vdThickness = 0.02; + + + +int calorimeter.numberOfDisks = 2; +double calorimeter.diskCaseZLength = 206.; +double calorimeter.diskInnerRingIn = 356.; +double calorimeter.diskInnerRingOut = 361.; +double calorimeter.diskCrystalRadiusIn = 374.; +double calorimeter.diskCrystalRadiusOut = 660.; +double calorimeter.diskOuterRingIn = 662.; +double calorimeter.diskOuterRingOut = 672.; +double calorimeter.diskOutRingEdgeZLength = 30.; +double calorimeter.diskOutRingEdgeRLength = 47.; +double calorimeter.diskStepThickness = 3.; +vector calorimeter.diskZ0MotherShift = {0.0,700.0}; //separation w.r.t caloMotherZ0 + +bool calorimeter.crystalShift = true; +double calorimeter.crystalXYLength = 34.0; +double calorimeter.crystalZLength = 200.0; +double calorimeter.crystalFrameZLength = 2.0; +double calorimeter.crystalFrameThickness = 1.0; +double calorimeter.wrapperThickness = 0.150; +double calorimeter.refractiveIndex = 1.8; + + +int calorimeter.readoutPerCrystal = 2; +double calorimeter.readoutXLength = 12; +double calorimeter.readoutYLength = 18; +double calorimeter.readoutZLength = 2; +double calorimeter.FEEXLength = 3; +double calorimeter.FEEYLength = 30; +double calorimeter.FEEZLength = 58; +double calorimeter.FEEBoxThickness = 0.7; +double calorimeter.BPHoleXLength = 30.2; +double calorimeter.BPHoleYLength = 21.8; +double calorimeter.BPHoleZLength = 15; +double calorimeter.BPStripThickness = 5; +double calorimeter.BPOuterRadius = 714; //inner radius same as FP +double calorimeter.BPPipeRadiusHigh = 13.45; +double calorimeter.BPPipeRadiusLow = 8.60; +double calorimeter.BPPipeThickness = 1.5; +double calorimeter.BPPipeZOffset = 43.0; + +double calorimeter.FPInnerRadius = 336; +double calorimeter.FPOuterRadius = 680; +double calorimeter.FPFoamZLength = 21.75; +double calorimeter.FPCarbonZLength = 3; +double calorimeter.FPCoolPipeTorRadius = 698.5; +double calorimeter.FPCoolPipeRadius = 16.85; +double calorimeter.FPCoolPipeThickness = 0.9; +int calorimeter.nPipes = 5; +vector calorimeter.pipeTorRadius = {397,457,517,577,637}; +double calorimeter.pipeRadius = 4.75; +double calorimeter.pipeThickness = 0.5; +double calorimeter.pipeInitSeparation = 25.4; + + +vector calorimeter.largeTorPhi = {161.34, 149.50, 139.50, 132.07, 125.39};//full angle of large torus +vector calorimeter.smallTorPhi = {84.63, 85.28, 85.79, 86.20, 86.53}; // full angle of small torus +vector calorimeter.straightEndPhi = {3.96, 10.53, 15.80, 20.16, 23.84}; // angle of the ending poing of the straight pipe +vector calorimeter.yposition = {432.2, 480.5, 524.3, 564.7, 602.5}; // start y position of the strait pipe +double calorimeter.radSmTor = 41.0; +double calorimeter.xsmall = 71.0; +double calorimeter.xdistance = 60.0; +double calorimeter.rInnerManifold = 681.6; + +int calorimeter.crateVersion = 2; +int calorimeter.numberOfCrates = 10; +int calorimeter.numberOfBoards = 9; +int calorimeter.nCrateBeforeSpace = 3; +double calorimeter.crateXLength = 190.; +double calorimeter.crateZLength = 350.; +double calorimeter.crateYLength = 183; +double calorimeter.crateFShieldThickness = 8; // front shield thickness +double calorimeter.crateBShieldThickness = 8; // bottom shield thickness +double calorimeter.crateTThickness = 5; // top panel thickness +double calorimeter.crateSThickness = 8; // side panel thickness +double calorimeter.crateFShieldYLength = 160; +double calorimeter.crateFShieldDeltaZ = 60; +double calorimeter.cratephi0 = 30; +double calorimeter.crateDeltaPhi = 16; +double calorimeter.radiatorThickness = 3.0; +double calorimeter.radiatorZLength = 233.0; +double calorimeter.activeStripThickness = 1.0; +double calorimeter.passiveStripThickness = 1.6; + + +string calorimeter.vacuumMaterial = "DSVacuum"; +string calorimeter.crystalMaterial = "G4_CESIUM_IODIDE"; +string calorimeter.crystalFrameMaterial = "Polyethylene092"; +string calorimeter.wrapperMaterial = "Polyethylene092"; +string calorimeter.innerRingMaterial = "CarbonFiber"; +string calorimeter.innerStepMaterial = "AluminumHoneycomb";//"CarbonFiber"; +string calorimeter.outerRingMaterial = "G4_Al"; + +string calorimeter.readoutMaterial = "G4_Si"; +string calorimeter.FEEMaterial = "Electronics"; + +string calorimeter.coolPipeMaterial = "StainlessSteel"; +string calorimeter.pipeMaterial = "G4_Al"; +string calorimeter.FPFoamMaterial = "AluminumHoneycomb";//"PET_P100"; +string calorimeter.FPCarbonMaterial = "CarbonFiber"; + +string calorimeter.BackPlateMaterial = "Polyetheretherketone"; +string calorimeter.FEEBoxMaterial = "G4_Cu"; +string calorimeter.BPStripMaterial = "G4_Cu"; + +string calorimeter.crateMaterial = "G4_Al"; +string calorimeter.shieldMaterial = "CuW1090"; +string calorimeter.radiatorMaterial = "G4_Cu"; +string calorimeter.activeStripMaterial = "G4_Si"; // need to be changed with a mixed material (combination of Copper, Plexiglass and Silicon) +string calorimeter.passiveStripMaterial = "Electronics2"; + + + + +// Control display and debug printout. +int calorimeter.verbosityLevel = 0; +bool calorimeter.envelope.visible = false; +bool calorimeter.envelope.solid = false; +bool calorimeter.case.visible = true; +bool calorimeter.case.solid = false; +bool calorimeter.crystal.visible = true; +bool calorimeter.crystal.solid = false; +bool calorimeter.crate.visible = true; +bool calorimeter.crate.solid = false; +bool calorimeter.crateBoard.visible = true; +bool calorimeter.crateBoard.solid = false; +bool calorimeter.pipe.visible = true; +bool calorimeter.pipe.solid = false; +bool calorimeter.RO.visible = true; +bool calorimeter.RO.solid = false; + + +// This tells emacs to view this file in c++ mode. +// Local Variables: +// mode:c++ +// End: diff --git a/Mu2eG4/geom/geom_2021_PhaseI_v03.txt b/Mu2eG4/geom/geom_2021_PhaseI_v03.txt new file mode 100644 index 0000000000..f3257e06fd --- /dev/null +++ b/Mu2eG4/geom/geom_2021_PhaseI_v03.txt @@ -0,0 +1,121 @@ +// Updated to be used in the MDC2020 simulation campaign, based off Mu2eG4/geom/geom_2021_PhaseI.txt +// Updates made to improve the PS endcap implementation + +string detector.name = "g4geom_v00"; + +bool hasHall = true; +bool hasTarget = true; +bool hasProtonAbsorber = true; +bool hasTSdA = true; +bool hasExternalShielding = true; +bool hasDiskCalorimeter = true; +bool hasBFieldManager = true; +bool hasBeamline = true; +bool hasVirtualDetector = true; // some components, e.g. ProtonAbsorber assume vd presence now; +bool hasCosmicRayShield = true; +bool hasSTM = true; +bool hasMBS = true; // note the two subcomponents, see mbs section below; + // no MBS implies no downstream hole in Cosmic Ray Passive Shield + // Magnetic field may be affected as well +bool hasPTM = true; + + + + +#include "Offline/Mu2eG4/geom/g4_visOptions.txt" + +//------------------------------------------- +// Mu2e geometry includes +//------------------------------------------- + +// X-offset of the PS(+x) and DS(-x) from the Mu2e origin. +// The origin of the detector coordinate system is on the DS axis at the specified z. +double mu2e.solenoidOffset = 3904.; // mm +double mu2e.detectorSystemZ0 = 10171.; // mm G4BL: (17730-7292=9801 mm) + +#include "Offline/Mu2eG4/geom/mu2eWorld.txt" +// mu2eHall.txt should be used with protonBeamDump_v02.txt, below +//#include "Mu2eG4/geom/mu2eHall.txt" +// whereas mu2eHall_v*.txt should be used with protonBeamDump_v03.txt, below +#include "Offline/Mu2eG4/geom/mu2eHall_v04.txt" + +// Solenoids +#include "Offline/Mu2eG4/geom/DetectorSolenoid_v05.txt" +#include "Offline/Mu2eG4/geom/DSShielding_v03.txt" +#include "Offline/Mu2eG4/geom/ProductionSolenoid_v02.txt" +#include "Offline/Mu2eG4/geom/psEnclosure_v05.txt" +#include "Offline/Mu2eG4/geom/PSShield_v06.txt" +#include "Offline/Mu2eG4/geom/PSExternalShielding_v01.txt" +#include "Offline/Mu2eG4/geom/TransportSolenoid_v08.txt" + +// External Shielding +#include "Offline/Mu2eG4/geom/ExtShieldUpstream_v06.txt" +#include "Offline/Mu2eG4/geom/ExtShieldDownstream_v06.txt" +#include "Offline/Mu2eG4/geom/Saddle_v03.txt" +#include "Offline/Mu2eG4/geom/Pipe_v04.txt" +#include "Offline/Mu2eG4/geom/ElectronicRack_v01.txt" + +// #include "Mu2eG4/geom/stoppingTargetHoles_DOE_review_2017.txt" // 37 foil muon stopping target with holes +#include "Offline/Mu2eG4/geom/stoppingTargetHoles_v02.txt" // 37 foil muon stopping target with holes and thicker foils (0.1 mm -> 0.1056 mm) + +#include "Offline/Mu2eG4/geom/TSdA_v02.txt" +#include "Offline/Mu2eG4/geom/muonBeamStop_v08.txt" + +#include "Offline/Mu2eG4/geom/STM_v05.txt" // (muon) stopping target monitor + +// Proton Absorber +#include "Offline/Mu2eG4/geom/protonAbsorber_cylindrical_v04.txt" +#include "Offline/Mu2eG4/geom/degrader_v02.txt" // pion degrader. Off by default + +// #include "Mu2eG4/geom/ProductionTarget_Hayman_v2_0.txt" +#include "Offline/Mu2eG4/geom/ProductionTarget_Hayman_v2_1.txt" +#include "Offline/Mu2eG4/geom/protonBeamDump_v03.txt" +#include "Offline/Mu2eG4/geom/extmon_fnal_v02.txt" + +// as-built panel numbering +#include "Offline/Mu2eG4/geom/tracker_v6.txt" + +// Crystal calorimeter +#include "Offline/Mu2eG4/geom/calorimeter_CsI_v02.txt" + +//CRV counters +#include "Offline/Mu2eG4/geom/crv_counters_v08.txt" + +// Production target beam-scanning detectors +#include "Offline/Mu2eG4/geom/PTM.txt" + +// Magnetic field maps +#include "Offline/Mu2eG4/geom/bfgeom_v01.txt" + +//--------------------------------------- +// Virtual detectors +//--------------------------------------- +double vd.halfLength = 0.01; //mm +int vd.verbosityLevel = 0; +bool vd.visible = true; +bool vd.solid = false; + +// // VD right in front of a hall wall +// double vd.ExtMonCommonPlane.z = -11999.99; + + +//--------------------------------------- +// Region visualization +//--------------------------------------- +#include "Offline/Mu2eG4/geom/visualization_regions.txt" + + + + +// +// +// End notes: +// +// 1) Sources of information: +// +// +// +// This tells emacs to view this file in c++ mode. +// Local Variables: +// mode:c++ +// End: diff --git a/Mu2eG4/geom/geom_common_current.txt b/Mu2eG4/geom/geom_common_current.txt index 399a90fc73..32afe64c71 100644 --- a/Mu2eG4/geom/geom_common_current.txt +++ b/Mu2eG4/geom/geom_common_current.txt @@ -2,7 +2,7 @@ // and features that will eventually become default - // the latest for testing.. -#include "Offline/Mu2eG4/geom/geom_2021_PhaseI_v02.txt" +#include "Offline/Mu2eG4/geom/geom_2021_PhaseI_v03.txt" // This tells emacs to view this file in c++ mode. // Local Variables: From 7034334c801d1e36403ec0b438acf63baed4afca Mon Sep 17 00:00:00 2001 From: sophieMu2e Date: Thu, 24 Feb 2022 08:45:52 -0600 Subject: [PATCH 31/33] fixed prolog --- EventGenerator/fcl/prolog.fcl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/EventGenerator/fcl/prolog.fcl b/EventGenerator/fcl/prolog.fcl index 320632df1a..fcd650fd76 100644 --- a/EventGenerator/fcl/prolog.fcl +++ b/EventGenerator/fcl/prolog.fcl @@ -142,7 +142,6 @@ CaloCalibGun : { phimax : 2.0 tmin : 500. tmax : 1694. - doHistograms: true } # Save state of random numbers at the start of each event # the module is defined in art/Framework/Modules @@ -157,7 +156,7 @@ EventGenerator : { pionStops : { treeName : "stoppedPionDumper/stops" branchName : "stops" - inputFiles : ["mergedMuonStops/nts.mu2e.pion-DS-TGTstops.MDC2018a.001002_00000000.root" ] + inputFiles : ["mergedMuonStops/nts.mu2e.pion-DS-TGTstops.MDC2018a.001002_00000000.root" ] # does this need removing? averageNumRecordsToUse : 0 verbosityLevel : 0 } From 86c88110a0219a4900d5ef22755bc17628a34654 Mon Sep 17 00:00:00 2001 From: sophieMu2e Date: Thu, 24 Feb 2022 08:47:47 -0600 Subject: [PATCH 32/33] added bool --- Mu2eG4/geom/calorimeter_CsI.txt | 2 +- Mu2eG4/geom/calorimeter_CsI_v02.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Mu2eG4/geom/calorimeter_CsI.txt b/Mu2eG4/geom/calorimeter_CsI.txt index 12e609939f..3739a2c02e 100644 --- a/Mu2eG4/geom/calorimeter_CsI.txt +++ b/Mu2eG4/geom/calorimeter_CsI.txt @@ -60,7 +60,7 @@ vector calorimeter.pipeTorRadius = {397,457,517,577,637}; double calorimeter.pipeRadius = 4.75; double calorimeter.pipeThickness = 0.5; double calorimeter.pipeInitSeparation = 25.4; - +bool calorimeter.hasUpdatedSourceCalibrationSystem = false; int calorimeter.crateVersion = 2; int calorimeter.numberOfCrates = 10; int calorimeter.numberOfBoards = 9; diff --git a/Mu2eG4/geom/calorimeter_CsI_v02.txt b/Mu2eG4/geom/calorimeter_CsI_v02.txt index 6f384534b8..941cec2c65 100644 --- a/Mu2eG4/geom/calorimeter_CsI_v02.txt +++ b/Mu2eG4/geom/calorimeter_CsI_v02.txt @@ -61,7 +61,7 @@ double calorimeter.pipeRadius = 4.75; double calorimeter.pipeThickness = 0.5; double calorimeter.pipeInitSeparation = 25.4; - +bool calorimeter.hasUpdatedSourceCalibrationSystem = true; vector calorimeter.largeTorPhi = {161.34, 149.50, 139.50, 132.07, 125.39};//full angle of large torus vector calorimeter.smallTorPhi = {84.63, 85.28, 85.79, 86.20, 86.53}; // full angle of small torus vector calorimeter.straightEndPhi = {3.96, 10.53, 15.80, 20.16, 23.84}; // angle of the ending poing of the straight pipe From 01f6e85d36c3f842785b40b9b31238c5528175cf Mon Sep 17 00:00:00 2001 From: sophieMu2e Date: Fri, 25 Feb 2022 12:42:28 -0600 Subject: [PATCH 33/33] reverted --- Mu2eG4/geom/calorimeter_CsI.txt | 11 +- Mu2eG4/geom/calorimeter_CsI_v02.txt | 145 --------------------------- Mu2eG4/geom/geom_2021_PhaseI_v03.txt | 121 ---------------------- Mu2eG4/geom/geom_common_current.txt | 2 +- 4 files changed, 11 insertions(+), 268 deletions(-) delete mode 100644 Mu2eG4/geom/calorimeter_CsI_v02.txt delete mode 100644 Mu2eG4/geom/geom_2021_PhaseI_v03.txt diff --git a/Mu2eG4/geom/calorimeter_CsI.txt b/Mu2eG4/geom/calorimeter_CsI.txt index 3739a2c02e..14bc9f033a 100644 --- a/Mu2eG4/geom/calorimeter_CsI.txt +++ b/Mu2eG4/geom/calorimeter_CsI.txt @@ -60,7 +60,16 @@ vector calorimeter.pipeTorRadius = {397,457,517,577,637}; double calorimeter.pipeRadius = 4.75; double calorimeter.pipeThickness = 0.5; double calorimeter.pipeInitSeparation = 25.4; -bool calorimeter.hasUpdatedSourceCalibrationSystem = false; + +vector calorimeter.largeTorPhi = {161.34, 149.50, 139.50, 132.07, 125.39};//full angle of large torus +vector calorimeter.smallTorPhi = {84.63, 85.28, 85.79, 86.20, 86.53}; // full angle of small torus +vector calorimeter.straightEndPhi = {3.96, 10.53, 15.80, 20.16, 23.84}; // angle of the ending poing of the straight pipe +vector calorimeter.yposition = {432.2, 480.5, 524.3, 564.7, 602.5}; // start y position of the strait pipe +double calorimeter.radSmTor = 41.0; +double calorimeter.xsmall = 71.0; +double calorimeter.xdistance = 60.0; +double calorimeter.rInnerManifold = 681.6; + int calorimeter.crateVersion = 2; int calorimeter.numberOfCrates = 10; int calorimeter.numberOfBoards = 9; diff --git a/Mu2eG4/geom/calorimeter_CsI_v02.txt b/Mu2eG4/geom/calorimeter_CsI_v02.txt deleted file mode 100644 index 941cec2c65..0000000000 --- a/Mu2eG4/geom/calorimeter_CsI_v02.txt +++ /dev/null @@ -1,145 +0,0 @@ -// Crystal calorimeter - all length in mm, angles in degres - -double calorimeter.caloMotherRadiusIn = 330; -double calorimeter.caloMotherRadiusOut = 719;//720; -double calorimeter.caloMotherZ0 = 11842; -double calorimeter.caloMotherZ1 = 13220; -double calorimeter.vdThickness = 0.02; - - - -int calorimeter.numberOfDisks = 2; -double calorimeter.diskCaseZLength = 206.; -double calorimeter.diskInnerRingIn = 356.; -double calorimeter.diskInnerRingOut = 361.; -double calorimeter.diskCrystalRadiusIn = 374.; -double calorimeter.diskCrystalRadiusOut = 660.; -double calorimeter.diskOuterRingIn = 662.; -double calorimeter.diskOuterRingOut = 672.; -double calorimeter.diskOutRingEdgeZLength = 30.; -double calorimeter.diskOutRingEdgeRLength = 47.; -double calorimeter.diskStepThickness = 3.; -vector calorimeter.diskZ0MotherShift = {0.0,700.0}; //separation w.r.t caloMotherZ0 - -bool calorimeter.crystalShift = true; -double calorimeter.crystalXYLength = 34.0; -double calorimeter.crystalZLength = 200.0; -double calorimeter.crystalFrameZLength = 2.0; -double calorimeter.crystalFrameThickness = 1.0; -double calorimeter.wrapperThickness = 0.150; -double calorimeter.refractiveIndex = 1.8; - - -int calorimeter.readoutPerCrystal = 2; -double calorimeter.readoutXLength = 12; -double calorimeter.readoutYLength = 18; -double calorimeter.readoutZLength = 2; -double calorimeter.FEEXLength = 3; -double calorimeter.FEEYLength = 30; -double calorimeter.FEEZLength = 58; -double calorimeter.FEEBoxThickness = 0.7; -double calorimeter.BPHoleXLength = 30.2; -double calorimeter.BPHoleYLength = 21.8; -double calorimeter.BPHoleZLength = 15; -double calorimeter.BPStripThickness = 5; -double calorimeter.BPOuterRadius = 714; //inner radius same as FP -double calorimeter.BPPipeRadiusHigh = 13.45; -double calorimeter.BPPipeRadiusLow = 8.60; -double calorimeter.BPPipeThickness = 1.5; -double calorimeter.BPPipeZOffset = 43.0; - -double calorimeter.FPInnerRadius = 336; -double calorimeter.FPOuterRadius = 680; -double calorimeter.FPFoamZLength = 21.75; -double calorimeter.FPCarbonZLength = 3; -double calorimeter.FPCoolPipeTorRadius = 698.5; -double calorimeter.FPCoolPipeRadius = 16.85; -double calorimeter.FPCoolPipeThickness = 0.9; -int calorimeter.nPipes = 5; -vector calorimeter.pipeTorRadius = {397,457,517,577,637}; -double calorimeter.pipeRadius = 4.75; -double calorimeter.pipeThickness = 0.5; -double calorimeter.pipeInitSeparation = 25.4; - -bool calorimeter.hasUpdatedSourceCalibrationSystem = true; -vector calorimeter.largeTorPhi = {161.34, 149.50, 139.50, 132.07, 125.39};//full angle of large torus -vector calorimeter.smallTorPhi = {84.63, 85.28, 85.79, 86.20, 86.53}; // full angle of small torus -vector calorimeter.straightEndPhi = {3.96, 10.53, 15.80, 20.16, 23.84}; // angle of the ending poing of the straight pipe -vector calorimeter.yposition = {432.2, 480.5, 524.3, 564.7, 602.5}; // start y position of the strait pipe -double calorimeter.radSmTor = 41.0; -double calorimeter.xsmall = 71.0; -double calorimeter.xdistance = 60.0; -double calorimeter.rInnerManifold = 681.6; - -int calorimeter.crateVersion = 2; -int calorimeter.numberOfCrates = 10; -int calorimeter.numberOfBoards = 9; -int calorimeter.nCrateBeforeSpace = 3; -double calorimeter.crateXLength = 190.; -double calorimeter.crateZLength = 350.; -double calorimeter.crateYLength = 183; -double calorimeter.crateFShieldThickness = 8; // front shield thickness -double calorimeter.crateBShieldThickness = 8; // bottom shield thickness -double calorimeter.crateTThickness = 5; // top panel thickness -double calorimeter.crateSThickness = 8; // side panel thickness -double calorimeter.crateFShieldYLength = 160; -double calorimeter.crateFShieldDeltaZ = 60; -double calorimeter.cratephi0 = 30; -double calorimeter.crateDeltaPhi = 16; -double calorimeter.radiatorThickness = 3.0; -double calorimeter.radiatorZLength = 233.0; -double calorimeter.activeStripThickness = 1.0; -double calorimeter.passiveStripThickness = 1.6; - - -string calorimeter.vacuumMaterial = "DSVacuum"; -string calorimeter.crystalMaterial = "G4_CESIUM_IODIDE"; -string calorimeter.crystalFrameMaterial = "Polyethylene092"; -string calorimeter.wrapperMaterial = "Polyethylene092"; -string calorimeter.innerRingMaterial = "CarbonFiber"; -string calorimeter.innerStepMaterial = "AluminumHoneycomb";//"CarbonFiber"; -string calorimeter.outerRingMaterial = "G4_Al"; - -string calorimeter.readoutMaterial = "G4_Si"; -string calorimeter.FEEMaterial = "Electronics"; - -string calorimeter.coolPipeMaterial = "StainlessSteel"; -string calorimeter.pipeMaterial = "G4_Al"; -string calorimeter.FPFoamMaterial = "AluminumHoneycomb";//"PET_P100"; -string calorimeter.FPCarbonMaterial = "CarbonFiber"; - -string calorimeter.BackPlateMaterial = "Polyetheretherketone"; -string calorimeter.FEEBoxMaterial = "G4_Cu"; -string calorimeter.BPStripMaterial = "G4_Cu"; - -string calorimeter.crateMaterial = "G4_Al"; -string calorimeter.shieldMaterial = "CuW1090"; -string calorimeter.radiatorMaterial = "G4_Cu"; -string calorimeter.activeStripMaterial = "G4_Si"; // need to be changed with a mixed material (combination of Copper, Plexiglass and Silicon) -string calorimeter.passiveStripMaterial = "Electronics2"; - - - - -// Control display and debug printout. -int calorimeter.verbosityLevel = 0; -bool calorimeter.envelope.visible = false; -bool calorimeter.envelope.solid = false; -bool calorimeter.case.visible = true; -bool calorimeter.case.solid = false; -bool calorimeter.crystal.visible = true; -bool calorimeter.crystal.solid = false; -bool calorimeter.crate.visible = true; -bool calorimeter.crate.solid = false; -bool calorimeter.crateBoard.visible = true; -bool calorimeter.crateBoard.solid = false; -bool calorimeter.pipe.visible = true; -bool calorimeter.pipe.solid = false; -bool calorimeter.RO.visible = true; -bool calorimeter.RO.solid = false; - - -// This tells emacs to view this file in c++ mode. -// Local Variables: -// mode:c++ -// End: diff --git a/Mu2eG4/geom/geom_2021_PhaseI_v03.txt b/Mu2eG4/geom/geom_2021_PhaseI_v03.txt deleted file mode 100644 index f3257e06fd..0000000000 --- a/Mu2eG4/geom/geom_2021_PhaseI_v03.txt +++ /dev/null @@ -1,121 +0,0 @@ -// Updated to be used in the MDC2020 simulation campaign, based off Mu2eG4/geom/geom_2021_PhaseI.txt -// Updates made to improve the PS endcap implementation - -string detector.name = "g4geom_v00"; - -bool hasHall = true; -bool hasTarget = true; -bool hasProtonAbsorber = true; -bool hasTSdA = true; -bool hasExternalShielding = true; -bool hasDiskCalorimeter = true; -bool hasBFieldManager = true; -bool hasBeamline = true; -bool hasVirtualDetector = true; // some components, e.g. ProtonAbsorber assume vd presence now; -bool hasCosmicRayShield = true; -bool hasSTM = true; -bool hasMBS = true; // note the two subcomponents, see mbs section below; - // no MBS implies no downstream hole in Cosmic Ray Passive Shield - // Magnetic field may be affected as well -bool hasPTM = true; - - - - -#include "Offline/Mu2eG4/geom/g4_visOptions.txt" - -//------------------------------------------- -// Mu2e geometry includes -//------------------------------------------- - -// X-offset of the PS(+x) and DS(-x) from the Mu2e origin. -// The origin of the detector coordinate system is on the DS axis at the specified z. -double mu2e.solenoidOffset = 3904.; // mm -double mu2e.detectorSystemZ0 = 10171.; // mm G4BL: (17730-7292=9801 mm) - -#include "Offline/Mu2eG4/geom/mu2eWorld.txt" -// mu2eHall.txt should be used with protonBeamDump_v02.txt, below -//#include "Mu2eG4/geom/mu2eHall.txt" -// whereas mu2eHall_v*.txt should be used with protonBeamDump_v03.txt, below -#include "Offline/Mu2eG4/geom/mu2eHall_v04.txt" - -// Solenoids -#include "Offline/Mu2eG4/geom/DetectorSolenoid_v05.txt" -#include "Offline/Mu2eG4/geom/DSShielding_v03.txt" -#include "Offline/Mu2eG4/geom/ProductionSolenoid_v02.txt" -#include "Offline/Mu2eG4/geom/psEnclosure_v05.txt" -#include "Offline/Mu2eG4/geom/PSShield_v06.txt" -#include "Offline/Mu2eG4/geom/PSExternalShielding_v01.txt" -#include "Offline/Mu2eG4/geom/TransportSolenoid_v08.txt" - -// External Shielding -#include "Offline/Mu2eG4/geom/ExtShieldUpstream_v06.txt" -#include "Offline/Mu2eG4/geom/ExtShieldDownstream_v06.txt" -#include "Offline/Mu2eG4/geom/Saddle_v03.txt" -#include "Offline/Mu2eG4/geom/Pipe_v04.txt" -#include "Offline/Mu2eG4/geom/ElectronicRack_v01.txt" - -// #include "Mu2eG4/geom/stoppingTargetHoles_DOE_review_2017.txt" // 37 foil muon stopping target with holes -#include "Offline/Mu2eG4/geom/stoppingTargetHoles_v02.txt" // 37 foil muon stopping target with holes and thicker foils (0.1 mm -> 0.1056 mm) - -#include "Offline/Mu2eG4/geom/TSdA_v02.txt" -#include "Offline/Mu2eG4/geom/muonBeamStop_v08.txt" - -#include "Offline/Mu2eG4/geom/STM_v05.txt" // (muon) stopping target monitor - -// Proton Absorber -#include "Offline/Mu2eG4/geom/protonAbsorber_cylindrical_v04.txt" -#include "Offline/Mu2eG4/geom/degrader_v02.txt" // pion degrader. Off by default - -// #include "Mu2eG4/geom/ProductionTarget_Hayman_v2_0.txt" -#include "Offline/Mu2eG4/geom/ProductionTarget_Hayman_v2_1.txt" -#include "Offline/Mu2eG4/geom/protonBeamDump_v03.txt" -#include "Offline/Mu2eG4/geom/extmon_fnal_v02.txt" - -// as-built panel numbering -#include "Offline/Mu2eG4/geom/tracker_v6.txt" - -// Crystal calorimeter -#include "Offline/Mu2eG4/geom/calorimeter_CsI_v02.txt" - -//CRV counters -#include "Offline/Mu2eG4/geom/crv_counters_v08.txt" - -// Production target beam-scanning detectors -#include "Offline/Mu2eG4/geom/PTM.txt" - -// Magnetic field maps -#include "Offline/Mu2eG4/geom/bfgeom_v01.txt" - -//--------------------------------------- -// Virtual detectors -//--------------------------------------- -double vd.halfLength = 0.01; //mm -int vd.verbosityLevel = 0; -bool vd.visible = true; -bool vd.solid = false; - -// // VD right in front of a hall wall -// double vd.ExtMonCommonPlane.z = -11999.99; - - -//--------------------------------------- -// Region visualization -//--------------------------------------- -#include "Offline/Mu2eG4/geom/visualization_regions.txt" - - - - -// -// -// End notes: -// -// 1) Sources of information: -// -// -// -// This tells emacs to view this file in c++ mode. -// Local Variables: -// mode:c++ -// End: diff --git a/Mu2eG4/geom/geom_common_current.txt b/Mu2eG4/geom/geom_common_current.txt index 32afe64c71..399a90fc73 100644 --- a/Mu2eG4/geom/geom_common_current.txt +++ b/Mu2eG4/geom/geom_common_current.txt @@ -2,7 +2,7 @@ // and features that will eventually become default - // the latest for testing.. -#include "Offline/Mu2eG4/geom/geom_2021_PhaseI_v03.txt" +#include "Offline/Mu2eG4/geom/geom_2021_PhaseI_v02.txt" // This tells emacs to view this file in c++ mode. // Local Variables: