Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:17:54

0001 #ifndef MICROMEGAS_MICROMEGASMAPPING_H
0002 #define MICROMEGAS_MICROMEGASMAPPING_H
0003 
0004 /*!
0005  * \file MicromegasMapping.h
0006  * \author Hugo Pereira Da Costa <hugo.pereira-da-costa@cea.fr>
0007  */
0008 
0009 #include "MicromegasDefs.h"
0010 
0011 #include <trackbase/TrkrDefs.h>
0012 
0013 #include <array>
0014 #include <map>
0015 #include <string>
0016 #include <vector>
0017 
0018 /// micromegas mapping
0019 class MicromegasMapping
0020 {
0021  public:
0022   /// constructor
0023   MicromegasMapping();
0024 
0025   /// get list of fee ids
0026   std::vector<int> get_fee_id_list() const;
0027 
0028   /// get list of fee ids for a given packet
0029   std::vector<int> get_fee_id_list(int /*packet_id*/) const;
0030 
0031   /// get hitsetkey from fiber_id (fee_id)
0032   TrkrDefs::hitsetkey get_hitsetkey(int /*fee_id*/) const;
0033 
0034   /// get detector name (saclay) from fiber_id (fee_id)
0035   /** saclay detector name are of type MxxP and MxxZ, with xx the module number */
0036   std::string get_detname_saclay(int /*fee_id*/) const;
0037 
0038   /// get detector name (sphenix) from fiber_id (fee_id)
0039   /** sphenix detector name are of type SWP, SWZ, etc. */
0040   std::string get_detname_sphenix(int /*fee_id*/) const;
0041 
0042   /// get physical strip number from channel_id
0043   /**
0044    * physical strip number correspond to a position in the
0045    * detector's geant implementation, with increasing number corresponding to strips further away from the detector's edge,
0046    * as defined in CylinderGeomMicromegas
0047    */
0048   int get_physical_strip(int /*fee_id*/, int /*channel_id*/) const;
0049 
0050   /// get detector name (sphenix) from hitset key
0051   std::string get_detname_saclay_from_hitsetkey(TrkrDefs::hitsetkey) const;
0052 
0053   /// get detector name (saclay) from hitset key
0054   std::string get_detname_sphenix_from_hitsetkey(TrkrDefs::hitsetkey) const;
0055 
0056   /// get fee id from hitset key
0057   int get_fee_id_from_hitsetkey(TrkrDefs::hitsetkey) const;
0058 
0059   /// convert fee_id from data stream into new fee_id after fiber swapping */
0060   /*
0061    * this is used  to keep being able to analyze older runs.
0062    * how it works is that every time a given fiber from the detector is connected to a new slot in the EBDC (a new FEE_ID),
0063    * one must convert the old fee_id to the new one, that match the same detector
0064    * in m_detectors.
0065    * This works as long as fibers from the detectors are assigned to previously unsused slots/fee_id.
0066    */
0067   int get_new_fee_id( int /*fee_id*/ ) const;
0068 
0069  private:
0070 
0071   /// construct fee channel id to physical strip mapping
0072   void construct_channel_mapping();
0073 
0074   /// contains all relevant detector information
0075   /** this effectively implements mapping between fee_id as defined in EDBC,
   * detector names (in both Saclay and sPHENIX convention),
0076    * and hitsetkey which is the detector unique identifier
0077    */
0078   class DetectorId
0079   {
0080    public:
0081     /// constructor
0082     DetectorId(
0083         int packet_id,
0084         int fee_id,
0085         TrkrDefs::hitsetkey hitsetkey,
0086         const std::string& fibername, const std::string& breakoutname,
0087         const std::string& detname_saclay, const std::string& detname_sphenix)
0088       :
0089       m_packet_id(packet_id)
0090       , m_fee_id(fee_id)
0091       , m_hitsetkey(hitsetkey)
0092       , m_fibername(fibername)
0093       , m_breakoutname(breakoutname)
0094       , m_detname_saclay(detname_saclay)
0095       , m_detname_sphenix(detname_sphenix)
0096     {
0097     }
0098 
0099     /// packet_id
0100     int m_packet_id = 0;
0101 
0102     /// fee_id
0103     int m_fee_id = 0;
0104 
0105     /// hitset key
0106     TrkrDefs::hitsetkey m_hitsetkey = 0;
0107 
0108     /// fiber name
0109     std::string m_fibername;
0110 
0111     /// breakout cable name
0112     std::string m_breakoutname;
0113 
0114     /// detector name
0115     std::string m_detname_saclay;
0116 
0117     /// detector name
0118     std::string m_detname_sphenix;
0119   };
0120 
0121   /// list of defined detectors
0122   std::vector<DetectorId> m_detectors;
0123 
0124   /// map detector_id to fee_id
0125   std::map<int, DetectorId> m_detector_map;
0126 
0127   /// map FEE channel id to physical strip id (z view)
0128   std::array<int, MicromegasDefs::m_nchannels_fee> m_fee_to_strip_mapping_z = {{0}};
0129 
0130   /// map FEE channel id to physical strip id (phi view)
0131   std::array<int, MicromegasDefs::m_nchannels_fee> m_fee_to_strip_mapping_phi = {{0}};
0132 
0133 };
0134 
0135 #endif