Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:17:08

0001 // Tell emacs that this is a C++ source
0002 //  -*- C++ -*-.
0003 
0004 /*!
0005  *  \file         MakeMilleFiles.h
0006  *  \brief      Class for moving corrected TPC clusters to the nearest TPC readout layer radius
0007  *  \author  Tony Frawley <afrawley@fsu.edu>
0008  */
0009 
0010 #ifndef MAKEMILLEFILES_H
0011 #define MAKEMILLEFILES_H
0012 
0013 #include "AlignmentDefs.h"
0014 
0015 #include <trackbase/ActsGeometry.h>
0016 #include <trackbase/ClusterErrorPara.h>
0017 #include <trackbase/TrkrDefs.h>
0018 #include <trackbase_historic/ActsTransformations.h>
0019 #include <trackbase_historic/SvtxAlignmentState.h>
0020 #include <trackbase_historic/SvtxAlignmentStateMap.h>
0021 
0022 #include <fun4all/SubsysReco.h>
0023 
0024 #include <ActsExamples/EventData/Trajectories.hpp>
0025 
0026 #include <string>
0027 #include <vector>
0028 
0029 class PHCompositeNode;
0030 class PHG4TpcCylinderGeomContainer;
0031 class SvtxTrack;
0032 class SvtxTrackMap;
0033 class TrkrCluster;
0034 class TrkrClusterContainer;
0035 class Mille;
0036 class ActsPropagator;
0037 
0038 class TFile;
0039 class TNtuple;
0040 
0041 using Trajectory = ActsExamples::Trajectories;
0042 
0043 class MakeMilleFiles : public SubsysReco
0044 {
0045  public:
0046   MakeMilleFiles(const std::string& name = "MakeMilleFiles");
0047 
0048   int InitRun(PHCompositeNode* topNode) override;
0049   int process_event(PHCompositeNode* topNode) override;
0050   int End(PHCompositeNode* topNode) override;
0051 
0052   void set_binary(bool bin) { _binary = bin; }
0053 
0054   void set_track_map_name(const std::string& name) {m_track_map_name = name;}
0055   void set_state_map_name(const std::string& name) {m_state_map_name = name;}
0056   void set_constraintfile_name(const std::string& file) { m_constraintFileName = file; }
0057   void set_datafile_name(const std::string& file) { data_outfilename = file; }
0058   void set_steeringfile_name(const std::string& file) { steering_outfilename = file; }
0059   void set_tfile_name(const std::string& file) { m_tfile_name = file; }
0060 
0061   void set_mvtx_grouping(int group) { mvtx_group = (AlignmentDefs::mvtxGrp) group; }
0062   void set_intt_grouping(int group) { intt_group = (AlignmentDefs::inttGrp) group; }
0063   void set_tpc_grouping(int group) { tpc_group = (AlignmentDefs::tpcGrp) group; }
0064   void set_mms_grouping(int group) { mms_group = (AlignmentDefs::mmsGrp) group; }
0065   void use_event_vertex(bool useit) { m_useEventVertex = useit; }
0066   void set_layer_fixed(unsigned int layer);
0067   void set_mvtx_layer_fixed(unsigned int layer, unsigned int clamshell);
0068   void set_layer_gparam_fixed(unsigned int layer, unsigned int param);
0069   void set_layer_lparam_fixed(unsigned int layer, unsigned int param);
0070 
0071   void set_layers_fixed(unsigned int minlayer, unsigned int maxlayer);
0072   void set_error_inflation_factor(unsigned int layer, float factor)
0073   {
0074     m_layerMisalignment.insert(std::make_pair(layer, factor));
0075   }
0076   void set_tpc_sector_fixed(unsigned int region, unsigned int sector,
0077                             unsigned int side)
0078   {
0079     // make a combined subsector index
0080     unsigned int subsector = region * 24 + side * 12 + sector;
0081     fixed_sectors.insert(subsector);
0082   }
0083   void set_vtx_sigma(float xysig, float zsig)
0084   {
0085     m_vtxSigma(0) = xysig;
0086     m_vtxSigma(1) = zsig;
0087   }
0088 
0089  private:
0090   Mille* _mille;
0091 
0092   int GetNodes(PHCompositeNode* topNode);
0093   Acts::Vector3 getEventVertex();
0094 
0095   bool is_layer_fixed(unsigned int layer);
0096 
0097   bool is_layer_param_fixed(unsigned int layer, unsigned int param, std::set<std::pair<unsigned int, unsigned int>>& param_fixed);
0098 
0099   bool is_tpc_sector_fixed(unsigned int layer, unsigned int sector, unsigned int side);
0100   bool is_mvtx_layer_fixed(unsigned int layer, unsigned int clamshell);
0101   void addTrackToMilleFile(SvtxAlignmentStateMap::StateVec& statevec);
0102   void getGlobalVtxDerivativesXY(SvtxTrack* track,
0103                                  const Acts::Vector3& vertex,
0104                                  float glblvtx_derivative[SvtxAlignmentState::NRES][3]);
0105   bool getLocalVtxDerivativesXY(SvtxTrack* track,
0106                                 ActsPropagator& propagator,
0107                                 const Acts::Vector3& vertex,
0108                                 float lclvtx_derivative[SvtxAlignmentState::NRES][SvtxAlignmentState::NLOC]);
0109   Acts::Vector3 localToGlobalVertex(SvtxTrack* track,
0110                                     const Acts::Vector3& vertex,
0111                                     const Acts::Vector3& localx) const;
0112   void getProjectionVtxXY(SvtxTrack* track, const Acts::Vector3& vertex,
0113                           Acts::Vector3& projx, Acts::Vector3& projy);
0114 
0115   std::string data_outfilename = ("mille_output_data_file.bin");
0116   std::string steering_outfilename = ("steer.txt");
0117 
0118   bool m_useEventVertex = false;
0119   bool _binary = true;
0120 
0121   Acts::Vector2 m_vtxSigma = {0.1, 0.1};
0122 
0123   std::map<unsigned int, float> m_layerMisalignment;
0124   std::set<unsigned int> fixed_sectors;
0125   // set default groups to lowest level
0126   AlignmentDefs::mvtxGrp mvtx_group = AlignmentDefs::mvtxGrp::snsr;
0127   AlignmentDefs::inttGrp intt_group = AlignmentDefs::inttGrp::chp;
0128   AlignmentDefs::tpcGrp tpc_group = AlignmentDefs::tpcGrp::htst;
0129   AlignmentDefs::mmsGrp mms_group = AlignmentDefs::mmsGrp::tl;
0130 
0131   std::set<unsigned int> fixed_layers;
0132   std::set<std::pair<unsigned int, unsigned int>> fixed_mvtx_layers;
0133   std::set<std::pair<unsigned int, unsigned int>> fixed_layer_gparams, fixed_layer_lparams;
0134 
0135   std::string m_constraintFileName = "mp2con.txt";
0136   std::ofstream m_constraintFile;
0137 
0138   std::string m_track_map_name{"SvtxTrackMap"};
0139   SvtxTrackMap* _track_map{nullptr};
0140 
0141   std::string m_state_map_name{"SvtxAlignmentStateMap"};
0142   SvtxAlignmentStateMap* _state_map{nullptr};
0143 
0144   ActsGeometry* _tGeometry{nullptr};
0145   TrkrClusterContainer* _cluster_map{nullptr};
0146   ClusterErrorPara _ClusErrPara;
0147 
0148   std::string m_tfile_name;
0149   TFile* m_file{nullptr};
0150   TNtuple* m_ntuple{nullptr};
0151 };
0152 
0153 #endif  // MAKEMILLEFILES_H