Changeset 226 in Idarraga


Ignore:
Timestamp:
Aug 2, 2011, 8:10:17 PM (13 years ago)
Author:
idarraga
Message:

trigger mechanism

Location:
allpix
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • allpix/include/AllPixDetectorConstruction.hh

    r192 r226  
    7070public:
    7171
    72   AllPixDetectorConstruction();
    73   ~AllPixDetectorConstruction();
    74   void DefineSensitiveDetector();
    75   void VolumesG4Properties();
    76   //void BuildMediPix(vector<G4ThreeVector>, vector<G4RotationMatrix *>);
    77   void BuildPixelDevices(map<int, AllPixGeoDsc *>);
    78 
    79   // check setup
    80   void CheckAllPixSetup();
    81 
    82   // test structures
    83   void SetBuildTestStructure(bool flg){m_buildTestStructureFlag = flg;}; 
    84   void SetBuildAppliances(bool flg){m_buildAppliancesFlag = flg;};
    85 
    86   void SetTestStructurePosition(G4ThreeVector);
    87   void SetTestStructureRotation(G4ThreeVector);
    88   void SetTestStructureDetectorLink(G4int);
    89   void SetAppliancePosition(G4ThreeVector);
    90   void SetWrapperEnhancement(G4ThreeVector);
    91 
    92   // mag field
    93   void SetPeakMagField(G4double fieldValue);
    94 
    95   // world volume from macro
    96   void SetWorldMaterial(G4String);
    97 
    98   // builders
    99   void BuildTestStructure(G4int); 
    100   void BuildAppliances(G4int);
    101 
    102   void SetDetectorPosition(G4ThreeVector);
    103   void SetDetectorRotation(G4ThreeVector);
    104   void SetDetectorID(G4int);
    105 
    106   void SetLowTHL(G4double);
    107   void UpdateGeometry();
     72        AllPixDetectorConstruction();
     73        ~AllPixDetectorConstruction();
     74        void DefineSensitiveDetector();
     75        void VolumesG4Properties();
     76        //void BuildMediPix(vector<G4ThreeVector>, vector<G4RotationMatrix *>);
     77        void BuildPixelDevices(map<int, AllPixGeoDsc *>);
     78
     79        // check setup
     80        void CheckAllPixSetup();
     81
     82        // test structures
     83        void SetBuildTestStructure(bool flg){m_buildTestStructureFlag = flg;};
     84        void SetBuildAppliances(bool flg){m_buildAppliancesFlag = flg;};
     85
     86        void SetTestStructurePosition(G4ThreeVector);
     87        void SetTestStructureRotation(G4ThreeVector);
     88        void SetTestStructureDetectorLink(G4int);
     89        void SetAppliancePosition(G4ThreeVector);
     90        void SetWrapperEnhancement(G4ThreeVector);
     91
     92        // mag field
     93        void SetPeakMagField(G4double fieldValue);
     94
     95        // world volume from macro
     96        void SetWorldMaterial(G4String);
     97
     98        // builders
     99        void BuildTestStructure(G4int);
     100        void BuildAppliances(G4int);
     101
     102        void SetDetectorPosition(G4ThreeVector);
     103        void SetDetectorRotation(G4ThreeVector);
     104        void SetDetectorID(G4int);
     105
     106        void SetLowTHL(G4double);
     107        void UpdateGeometry();
     108
     109        // Specific EUTelescope
     110#ifdef _EUTELESCOPE
     111        void SetScintPos(G4ThreeVector);
     112#endif
    108113
    109114public:
    110115
    111   G4VPhysicalVolume* Construct();
    112  
     116        G4VPhysicalVolume* Construct();
     117
    113118private:
    114   // flags
    115   bool m_clearanceToBuildGeometry;
    116 
    117   // pos rot detector
    118   vector<G4int>              m_detId;
    119   vector<G4int>::iterator    m_detIdItr;
    120 
    121   map<int, G4ThreeVector>      m_posVector; // position of medipix(es), key is detector Id
    122   map<int, G4RotationMatrix *> m_rotVector; // rotation
    123   G4int m_nPositions;
    124   G4int m_nRotations;
    125   G4int m_nIds;
    126 
    127   vector<G4double>           m_lowThlVector; // lowTHL
    128   // for user information.  Absolute position (center) of the Si wafers
    129   vector<G4ThreeVector>      m_absolutePosSiWafer;
    130 
    131 
    132   // pos,rot test structure
    133   map<int, G4ThreeVector> m_posVectorTestStructure; // position of test structure
    134   map<int, G4RotationMatrix *> m_rotVectorTestStructure; // rotation of test structure
    135   map<G4int, G4int> m_detectorLinkTestStructure;
    136   G4int m_nTestPositions;
    137   G4int m_nTestRotation;
    138 
    139   // pos appliance
    140   //vector<G4ThreeVector> m_posVectorAppliances;
    141   map<int, G4ThreeVector> m_posVectorAppliances;
    142   G4int m_nAppliancesPositions;
    143   //vector<G4ThreeVector> m_vectorWrapperEnhancement;
    144   map<int, G4ThreeVector> m_vectorWrapperEnhancement;
    145   G4int m_nWrapperEnhancement;
    146 
    147   // Geometry in G4
    148   AllPixGeoDsc * gD;   // geo bits for 1 detector
    149   ReadGeoDescription * m_geoDsc;
    150 
    151   // world
    152   G4LogicalVolume * expHall_log;
    153   G4VPhysicalVolume * expHall_phys;
    154 
    155  
    156   map<int, G4LogicalVolume *>    m_wrapper_log;
    157   map<int, G4VPhysicalVolume *>  m_wrapper_phys;
    158 
    159   map<int, G4LogicalVolume *>    m_PCB_log;
    160   map<int, G4VPhysicalVolume*>   m_PCB_phys;
    161 
    162   map<int, G4LogicalVolume *>    m_Box_log;
    163   map<int, G4VPhysicalVolume*>   m_Box_phys;
    164 
    165   map<int, G4LogicalVolume *>    m_GuardRings_log;
    166   map<int, G4VPhysicalVolume*>   m_GuardRings_phys;
    167 
    168   map<int, G4LogicalVolume *>    m_Slice_log;
    169   map<int, G4LogicalVolume *>    m_Pixel_log;
    170 
    171   /*
     119        // flags
     120        bool m_clearanceToBuildGeometry;
     121
     122        // pos rot detector
     123        vector<G4int>              m_detId;
     124        vector<G4int>::iterator    m_detIdItr;
     125
     126        map<int, G4ThreeVector>      m_posVector; // position of medipix(es), key is detector Id
     127        map<int, G4RotationMatrix *> m_rotVector; // rotation
     128        G4int m_nPositions;
     129        G4int m_nRotations;
     130        G4int m_nIds;
     131
     132        vector<G4double>           m_lowThlVector; // lowTHL
     133        // for user information.  Absolute position (center) of the Si wafers
     134        vector<G4ThreeVector>      m_absolutePosSiWafer;
     135
     136
     137        // pos,rot test structure
     138        map<int, G4ThreeVector> m_posVectorTestStructure; // position of test structure
     139        map<int, G4RotationMatrix *> m_rotVectorTestStructure; // rotation of test structure
     140        map<G4int, G4int> m_detectorLinkTestStructure;
     141        G4int m_nTestPositions;
     142        G4int m_nTestRotation;
     143
     144        // pos appliance
     145        //vector<G4ThreeVector> m_posVectorAppliances;
     146        map<int, G4ThreeVector> m_posVectorAppliances;
     147        G4int m_nAppliancesPositions;
     148        //vector<G4ThreeVector> m_vectorWrapperEnhancement;
     149        map<int, G4ThreeVector> m_vectorWrapperEnhancement;
     150        G4int m_nWrapperEnhancement;
     151
     152        // Geometry in G4
     153        AllPixGeoDsc * gD;   // geo bits for 1 detector
     154        ReadGeoDescription * m_geoDsc;
     155
     156        // world
     157        G4LogicalVolume * expHall_log;
     158        G4VPhysicalVolume * expHall_phys;
     159
     160
     161        map<int, G4LogicalVolume *>    m_wrapper_log;
     162        map<int, G4VPhysicalVolume *>  m_wrapper_phys;
     163
     164        map<int, G4LogicalVolume *>    m_PCB_log;
     165        map<int, G4VPhysicalVolume*>   m_PCB_phys;
     166
     167        map<int, G4LogicalVolume *>    m_Box_log;
     168        map<int, G4VPhysicalVolume*>   m_Box_phys;
     169
     170        map<int, G4LogicalVolume *>    m_GuardRings_log;
     171        map<int, G4VPhysicalVolume*>   m_GuardRings_phys;
     172
     173        map<int, G4LogicalVolume *>    m_Slice_log;
     174        map<int, G4LogicalVolume *>    m_Pixel_log;
     175
     176        /*
    172177  //////////////////////////////////
    173178  // wrapper
     
    188193  G4LogicalVolume ** m_Pixel_log;
    189194  //////////////////////////////////
    190 */
    191 
    192   // test Structure
    193   bool m_buildTestStructureFlag;
    194   G4LogicalVolume * m_TestStructure_log;
    195   G4VPhysicalVolume * m_TestStructure_phys;
    196 
    197   // appliances
    198   bool  m_buildAppliancesFlag;
    199 
    200   // messenger
    201   AllPixDetectorMessenger* m_detectorMessenger;
    202 
    203   // materials
    204   G4Material * m_Air;
    205   G4Material * m_Vacuum;
    206   G4Material * m_fillingWorldMaterial;
    207   bool m_userDefinedWorldMaterial;
    208 
    209   // mad field
    210   //G4UniformMagField * m_magField;      // pointer to the magnetic field
    211   MorourgoMagField * m_magField;
     195         */
     196
     197        // test Structure
     198        bool m_buildTestStructureFlag;
     199        G4LogicalVolume * m_TestStructure_log;
     200        G4VPhysicalVolume * m_TestStructure_phys;
     201
     202        // appliances
     203        bool  m_buildAppliancesFlag;
     204
     205        // messenger
     206        AllPixDetectorMessenger* m_detectorMessenger;
     207
     208        // materials
     209        G4Material * m_Air;
     210        G4Material * m_Vacuum;
     211        G4Material * m_fillingWorldMaterial;
     212        bool m_userDefinedWorldMaterial;
     213
     214        // mad field
     215        //G4UniformMagField * m_magField;      // pointer to the magnetic field
     216        MorourgoMagField * m_magField;
     217
     218        // Eutelescope specifig
     219#ifdef _EUTELESCOPE
     220        vector<G4ThreeVector> m_scintPos;
     221        vector<G4ThreeVector> m_scintRot;
     222#endif
    212223
    213224};
     
    216227
    217228#define _BUILD_MEDIPIX_MSG()                                            \
    218   G4cout << "  In order to place a detector you must include in your macro at least" << G4endl; \
    219   G4cout << "  the following lines: (setId must go first !)" << G4endl;                 \
    220   G4cout << "    /allpix/det/setId 5" << G4endl;        \
    221   G4cout << "    /allpix/det/setPosition 0.0 0.0 0.0 mm" << G4endl;     \
    222   G4cout << "    /allpix/det/setRotation 0.0 0.0 0.0 deg" << G4endl;    \
    223   G4cout << "    /allpix/det/setLowTHL 13. keV" << G4endl;              \
    224   G4cout << "  see an example in \"allpix_vis.in\"" << G4endl;
     229                G4cout << "  In order to place a detector you must include in your macro at least" << G4endl; \
     230                G4cout << "  the following lines: (setId must go first !)" << G4endl;                   \
     231                G4cout << "    /allpix/det/setId 5" << G4endl;  \
     232                G4cout << "    /allpix/det/setPosition 0.0 0.0 0.0 mm" << G4endl;       \
     233                G4cout << "    /allpix/det/setRotation 0.0 0.0 0.0 deg" << G4endl;      \
     234                G4cout << "    /allpix/det/setLowTHL 13. keV" << G4endl;                \
     235                G4cout << "  see an example in \"allpix_vis.in\"" << G4endl;
    225236
    226237#define _WRONG_CONFIG_ABORT_MSG()                                               \
    227   G4cout << "[ERROR] wrong configuration.  Aborting job." << G4endl;
     238                G4cout << "[ERROR] wrong configuration.  Aborting job." << G4endl;
    228239
    229240#endif /*AllPixDetectorConstruction_h*/
  • allpix/include/AllPixDetectorMessenger.hh

    r194 r226  
    8181#ifdef _EUTELESCOPE
    8282        // Specific EUTelescope
    83   G4UIcmdWith3VectorAndUnit * m_scint1Pos;
    84   G4UIcmdWith3VectorAndUnit * m_scint2Pos;
    85   G4UIcmdWith3VectorAndUnit * m_scint3Pos;
    86   G4UIcmdWith3VectorAndUnit * m_scint4Pos;
     83  G4UIcmdWith3VectorAndUnit * m_scint1PosCmd;
     84  G4UIcmdWith3VectorAndUnit * m_scint2PosCmd;
     85  G4UIcmdWith3VectorAndUnit * m_scint3PosCmd;
     86  G4UIcmdWith3VectorAndUnit * m_scint4PosCmd;
    8787#endif
    8888
  • allpix/include/AllPixRun.hh

    r193 r226  
    3232class SimpleHits;
    3333
     34#ifdef _EUTELESCOPE
    3435#define __magic_trigger_cntr_ack 4 // 4 scintillators with 4 primary particle hits
     36#endif
    3537
    3638class AllPixRun : public G4Run {
  • allpix/macros/telescope1_Inventor_vis.in

    r210 r226  
    127127/allpix/det/setRotation  0.0 0.0 180.0 deg
    128128/allpix/det/setLowTHL    13. keV
     129
     130####################################################################
     131# Scintillators
     132/allpix/eudet/scint1Pos 0.0  0.0  -24.0 mm # offset of 18mm +/- 6mm with of scinti
     133/allpix/eudet/scint2Pos 0.0  0.0  -18.0 mm
     134/allpix/eudet/scint3Pos 0.0  0.0 1011.8 mm
     135/allpix/eudet/scint4Pos 0.0  0.0 1017.8 mm
    129136
    130137####################################################################
  • allpix/src/AllPixDetectorConstruction.cc

    r210 r226  
    193193                ReadGeoDescription * m_geoDsc = new ReadGeoDescription("./models/pixeldetector.xml");
    194194
    195                 // don't keep in the database the detectors which are not used
    196                 // doing by searching the id's
     195                // Don't keep in the database the detectors which are not used.
     196                // Searching the id's
    197197                G4int nErased = m_geoDsc->UseTheseDetectorsOnly(m_detId);
    198198                if(nErased) G4cout << "[INFO] " << nErased << " detectors have been erased from the data base"
     
    361361
    362362}
     363
     364#ifdef _EUTELESCOPE
     365void AllPixDetectorConstruction::SetScintPos(G4ThreeVector pos){
     366        m_scintPos.push_back(pos);
     367}
     368
     369#endif
    363370
    364371//void AllPixDetectorConstruction::BuildMediPix(vector<G4ThreeVector> pos, vector<G4RotationMatrix *> rot) {
  • allpix/src/AllPixDetectorConstructionTestStructure.cc

    r191 r226  
    4040void AllPixDetectorConstruction::BuildTestStructure(G4int){
    4141
     42
     43
     44#ifdef _EUTELESCOPE
    4245        ////////////////////////////////////////////////////////////////////////
    4346        // Get GDML volume
     
    6871        }
    6972         */
    70 
    71 
    72 
    7373
    7474        // I will extract the wrapper from this volume
     
    109109
    110110        //////////////////////////////////////////////////////////
    111         // Case for Scintillators
     111        // Scintillators for EUDET
    112112        // Materials
    113113
    114 
     114        if( m_scintPos.empty() ) {
     115                G4cout << "[ERROR] no scintillators defined.  In the macro use the command"
     116                                << "       /allpix/eudet/scint1Pos 0.0  0.0  -24.0 mm"
     117                                << "       Can't recover ... giving up."
     118                                << G4endl;
     119                exit(1);
     120        }
     121
     122        /*
    115123        // first plane at 0. mm
    116124        G4double z1 = -24*mm;
     
    119127        G4double z3 = 523*mm;
    120128        G4double z4 = 529*mm;
     129*/
    121130
    122131        G4NistManager * nistman = G4NistManager::Instance();
     
    128137                        5.4*mm,
    129138                        3*mm); // scintillators 6mm thick
     139
    130140        G4VisAttributes * scintAtt = new G4VisAttributes(G4Color(1,0,1,1));
    131141        scintAtt->SetLineWidth(1);
    132142        scintAtt->SetForceSolid(true);
    133143
    134 
     144        // Place scintillators
     145        vector<G4ThreeVector>::iterator scintItr = m_scintPos.begin();
     146
     147        TString labelLog = "";
     148        TString labelPlacement = "";
     149        TString labelSD = "";
     150    Int_t cntr = 1;
     151        G4SDManager * SDman = G4SDManager::GetSDMpointer();
     152
     153        for( ; scintItr != m_scintPos.end() ; scintItr++) {
     154
     155                labelLog = "scint";
     156                labelLog += cntr;
     157                labelLog += "_log";
     158
     159                labelPlacement = "Scint";
     160                labelPlacement += cntr;
     161
     162                G4LogicalVolume * scint_log = new G4LogicalVolume(
     163                                scintb,
     164                                scplastic,
     165                                labelLog.Data());
     166                scint_log->SetVisAttributes(scintAtt);
     167                G4RotationMatrix* matrix_s = new G4RotationMatrix();
     168                matrix_s->rotateX(0.*deg);
     169
     170                new G4PVPlacement( matrix_s,
     171                                (*scintItr),
     172                                scint_log,
     173                                labelPlacement.Data(),
     174                                expHall_log,
     175                                false,
     176                                0,
     177                                true);
     178
     179                labelSD = "sdscint";
     180                labelSD += cntr;
     181                AllPixTrackerSD * scintTrack = new AllPixTrackerSD( labelSD.Data(), (*scintItr), 0);
     182                SDman->AddNewDetector( scintTrack );
     183                scint_log->SetSensitiveDetector( scintTrack );
     184
     185                cntr++;
     186        }
     187
     188        /*
    135189        //
    136190        G4LogicalVolume * scint1_log = new G4LogicalVolume(
     
    199253                        true);
    200254
     255
     256
    201257        // SD manager
    202258        G4SDManager * SDman = G4SDManager::GetSDMpointer();
     
    216272        SDman->AddNewDetector( scintTrack4 );
    217273        scint4_log->SetSensitiveDetector( scintTrack4 );
     274
     275*/
    218276
    219277        /*
     
    251309         */
    252310
     311#endif
     312
    253313}
    254314/*
  • allpix/src/AllPixDetectorMessenger.cc

    r194 r226  
    5757        m_detDir->SetGuidance("extras");
    5858
     59#ifdef _EUTELESCOPE
     60        m_detDir = new G4UIdirectory("/allpix/eudet/");
     61        m_detDir->SetGuidance("EUDET");
     62#endif
     63
    5964        m_detIdCmd = new G4UIcmdWithAnInteger("/allpix/det/setId", this);
    6065        m_detIdCmd->SetGuidance("Detector ID");
     
    169174#ifdef _EUTELESCOPE
    170175        // Specific EUTelescope
    171 
    172 
     176        m_scint1PosCmd = new G4UIcmdWith3VectorAndUnit("/allpix/eudet/scint1Pos", this);
     177        m_scint2PosCmd = new G4UIcmdWith3VectorAndUnit("/allpix/eudet/scint2Pos", this);
     178        m_scint3PosCmd = new G4UIcmdWith3VectorAndUnit("/allpix/eudet/scint3Pos", this);
     179        m_scint4PosCmd = new G4UIcmdWith3VectorAndUnit("/allpix/eudet/scint4Pos", this);
    173180#endif
    174181
     
    190197        delete m_detDir;
    191198        delete m_allpixDir;
     199
     200#ifdef _EUTELESCOPE
     201        delete m_scint1PosCmd;
     202        delete m_scint2PosCmd;
     203        delete m_scint3PosCmd;
     204        delete m_scint4PosCmd;
     205#endif
     206
    192207}
    193208
     
    282297        }
    283298
     299
     300
     301#ifdef _EUTELESCOPE
     302        if( command == m_scint1PosCmd )
     303        {
     304                m_AllPixDetector->SetScintPos(
     305                                m_scint1PosCmd->GetNew3VectorValue(newValue)
     306                );
     307        }
     308        if( command == m_scint2PosCmd )
     309        {
     310                m_AllPixDetector->SetScintPos(
     311                                m_scint2PosCmd->GetNew3VectorValue(newValue)
     312                );
     313        }
     314        if( command == m_scint3PosCmd )
     315        {
     316                m_AllPixDetector->SetScintPos(
     317                                m_scint3PosCmd->GetNew3VectorValue(newValue)
     318                );
     319        }
     320        if( command == m_scint4PosCmd )
     321        {
     322                m_AllPixDetector->SetScintPos(
     323                                m_scint4PosCmd->GetNew3VectorValue(newValue)
     324                );
     325        }
     326#endif
     327
    284328}
    285329
  • allpix/src/AllPixRun.cc

    r193 r226  
    321321void AllPixRun::RecordDigits(const G4Event* evt){
    322322
    323         // First check if this event triggered !
     323        // Check if this event triggered for EUTELESCOPE only
     324#ifdef _EUTELESCOPE
     325
    324326        G4HCofThisEvent* HCe = evt->GetHCofThisEvent();
     327
     328        G4int scintillatorsCntr = 0;
    325329        G4int triggerCntr = 0;
    326         G4int scintillatorsCntr = 0;
    327330
    328331        for(int i = 0 ; i < HCe->GetNumberOfCollections() ; i++){
     
    341344
    342345                                hit = (AllPixTrackerHit *) hc->GetHit(j);
    343                                 if(hit->GetTrackPdgId() == 211) // pion for now
     346                                // pdgId of primary particle.  Triggering on it.
     347                                G4int pdgPrim = evt->GetPrimaryVertex()->GetPrimary(0)->GetPDGcode();
     348                                if(hit->GetTrackPdgId() == pdgPrim) // pion for now
    344349                                        triggerCntr++;
    345350
     
    355360                G4cout << "Trigger ON --> " << scintillatorsCntr << " scintillators fired" << G4endl;
    356361        }
     362#endif
    357363
    358364        // get digits in this event
  • allpix/src/ReadGeoDescription.cc

    r220 r226  
    8282        map<int, AllPixGeoDsc *>::iterator detItr = m_detsGeo.begin();
    8383        bool found = false;
     84        vector<G4int> scheduledErase;
    8485
    8586        for( ; detItr != m_detsGeo.end() ; detItr++){
     
    8788                G4int aDet = (*detItr).first;
    8889                found = false;
     90
    8991                for( itr = useDetectors.begin() ; itr != useDetectors.end() ; itr++ ){
     92
     93
    9094                        if(aDet == *itr){
    9195                                found = true;
     
    9498                }
    9599
     100
    96101                if(!found){
    97                         m_detsGeo.erase(aDet);
     102                        G4cout << " ----> schedule for erasing " << aDet << G4endl;
     103                        // don't erase right away, schedule and delete later, otherwise the
     104                        // vector over which I am looping shrinks.
     105                        scheduledErase.push_back(aDet);
     106                        //m_detsGeo.erase(aDet);
    98107                        nErased++;
    99108                }
     109
     110        }
     111
     112        // and finally erase
     113        vector<G4int>::iterator eraseItr = scheduledErase.begin();
     114        for( ; eraseItr != scheduledErase.end() ; eraseItr++ ) {
     115                m_detsGeo.erase(*eraseItr);
    100116        }
    101117
     
    334350                                else if(m_currentNodeName == __sensor_Resistivity){
    335351
    336                                                                         float val = atof(tempContent.c_str());
    337                                                                         m_detsGeo[m_firstIndx]->SetResistivity(val);
    338 
    339                                                                 }
     352                                        float val = atof(tempContent.c_str());
     353                                        m_detsGeo[m_firstIndx]->SetResistivity(val);
     354
     355                                }
    340356
    341357
Note: See TracChangeset for help on using the changeset viewer.