Changeset 260 in Idarraga


Ignore:
Timestamp:
Nov 18, 2011, 3:28:19 PM (13 years ago)
Author:
idarraga
Message:
 
Location:
allpix
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • allpix/allpix.cc

    r250 r260  
    140140        TString dataset = "AllPix";
    141141        TString tempdir = "";
    142         TString outputFilePrefix = detector->GetOutputFilePrefix();
    143         AllPixRunAction * run_action = new AllPixRunAction(outputFilePrefix, dataset, tempdir,
     142        AllPixRunAction * run_action = new AllPixRunAction(detector, dataset, tempdir,
    144143                        "lciobridge_allpix.txt",
    145144                        "lciobridge_allpix_dut.txt"); // dataset
     
    249248        G4int nHC = event_action->GetNumberOfHC();
    250249        for(G4int i = 0 ; i < nHC ; i++)
    251                 Hits_WriteToNtuple::GetInstance("", "", nHC, i)->closeNtuple();
     250                Hits_WriteToNtuple::GetInstance("", "", "", nHC, i)->closeNtuple();
    252251
    253252        G4cout << "[DONE]" << G4endl;
  • allpix/include/AllPixRun.hh

    r259 r260  
    99#include "AllPixTrackerHit.hh"
    1010#include "AllPixRunAction.hh"
    11 #include "AllPixMedipix2Digit.hh"
     11#include "AllPixMimosa26Digit.hh"
    1212#include "AllPixDigitInterface.hh"
    1313
  • allpix/include/AllPixRunAction.hh

    r258 r260  
    5555class G4Run;
    5656class AllPixRun;
     57class AllPixDetectorConstruction;
    5758//class FramesHandler;
    5859//class WriteToNtuple;
     
    7172
    7273public:
    73   AllPixRunAction(TString, TString, TString, TString, TString);
     74  AllPixRunAction(AllPixDetectorConstruction *, TString, TString, TString, TString);
    7475  ~AllPixRunAction();
    7576 
     
    8081 
    8182private:
    82   TString m_outputFilePrefix;
     83
     84  AllPixDetectorConstruction * m_detectorPtr;
    8385  TString m_dataset;
    8486  TString m_tempdir;
  • allpix/include/AllPix_Hits_WriteToEntuple.h

    r15 r260  
    7272public:
    7373
    74   Hits_WriteToNtuple(TString, TString, Int_t, TString om="RECREATE");
     74  Hits_WriteToNtuple(TString, TString, TString, Int_t, TString om="RECREATE");
    7575  ~Hits_WriteToNtuple(){};
    7676  void fillVars(SimpleHits *);
    7777  void closeNtuple();
    7878  TString GetNtupleFileName(){return m_ntupleFileName;};
    79   static Hits_WriteToNtuple * GetInstance(TString, TString, Int_t, Int_t, TString openmode = "RECREATE");
     79  static Hits_WriteToNtuple * GetInstance(TString, TString, TString, Int_t, Int_t, TString openmode = "RECREATE");
    8080  TTree * GetTree(){return t2;};
    8181  //void SetBranchAddress(FrameStruct * fs){b2->SetAddress(fs);};
  • allpix/macros/oneDetector_Inventor_vis.in

    r252 r260  
    2525# Build detectors
    2626/allpix/det/update
     27
     28####################################################################
     29# prefix for output filename (string) Don't use quotation marks \"
     30/allpix/config/setOutputPrefixWithPath dataprefix
    2731
    2832########################################################################
  • allpix/macros/telescope1_Inventor_vis.in

    r226 r260  
    127127/allpix/det/setRotation  0.0 0.0 180.0 deg
    128128/allpix/det/setLowTHL    13. keV
     129
     130####################################################################
     131# prefix for output filename (string) Don't use quotation marks \"
     132/allpix/config/setOutputPrefixWithPath dataprefix
    129133
    130134####################################################################
  • allpix/src/AllPixRun.cc

    r250 r260  
    309309                // fillVars rewinds values
    310310                m_datasetHits = SDman->GetHCtable()->GetHCname(itrCol);
    311                 Hits_WriteToNtuple::GetInstance(m_datasetHits,
     311                Hits_WriteToNtuple::GetInstance(m_outputFilePrefix, m_datasetHits,
    312312                                m_tempdir,
    313313                                nHC, // here is the number of Hit Collections (SD), not detectors.
  • allpix/src/AllPixRunAction.cc

    r250 r260  
    4141#include "AllPixRun.hh"
    4242
     43#include "AllPixDetectorConstruction.hh"
    4344#include "AllPix_Frames_WriteToEntuple.h"
    4445#include "allpix_dm.h"
     
    5152
    5253// this constructor is called only once in the whole program
    53 AllPixRunAction::AllPixRunAction(TString ofp, TString ds, TString td, TString lciofn, TString lciofn_dut)
     54AllPixRunAction::AllPixRunAction(AllPixDetectorConstruction * det, TString ds, TString td, TString lciofn, TString lciofn_dut)
    5455{
    5556
    56   m_outputFilePrefix = ofp;
     57        m_detectorPtr = det;
    5758        m_dataset = ds;
    5859        m_tempdir = td;
     
    8283G4Run * AllPixRunAction::GenerateRun(){
    8384
    84   m_AllPixRun = new AllPixRun(m_outputFilePrefix, m_dataset, m_tempdir); // keep this pointer
     85        m_AllPixRun = new AllPixRun(m_detectorPtr->GetOutputFilePrefix(), m_dataset, m_tempdir); // keep this pointer
    8586        m_AllPixRun->SetLCIOBridgeFileDsc(m_lciobridge_f, m_lciobridge_dut_f);
    8687
     
    108109        timer->Stop();
    109110        G4cout << "event Id = " << aRun->GetNumberOfEvent()
    110                         << " " << *timer << G4endl;
     111                                        << " " << *timer << G4endl;
    111112
    112113}
  • allpix/src/AllPix_Frames_WriteToEntuple.cc

    r250 r260  
    2626                m_ntupleFileName += "/";
    2727        }
     28
    2829
    2930        if(prefix.Length() > 0){
  • allpix/src/AllPix_Hits_WriteToEntuple.cc

    r15 r260  
    1212int g_instance_hit_Cntr = 0;
    1313
    14 Hits_WriteToNtuple::Hits_WriteToNtuple(TString dataSet, TString tempScratchDir,
    15                                        Int_t /*detID*/, TString openmode /* default "RECREATE" */){
     14Hits_WriteToNtuple::Hits_WriteToNtuple(TString prefix, TString dataSet, TString tempScratchDir,
     15                Int_t /*detID*/, TString openmode /* default "RECREATE" */){
    1616
    17   m_MPXDataSetNumber = dataSet;
    18   m_ntupleFileName = "";
     17        m_MPXDataSetNumber = dataSet;
     18        m_ntupleFileName = "";
    1919
    20   // change dir if requested
    21   if(tempScratchDir.Length() > 0){
    22     m_ntupleFileName += tempScratchDir;
    23     m_ntupleFileName += "/";
    24   }
     20        // change dir if requested
     21        if(tempScratchDir.Length() > 0){
     22                m_ntupleFileName += tempScratchDir;
     23                m_ntupleFileName += "/";
     24        }
    2525
    26   m_ntupleFileName += "Hits_"+m_MPXDataSetNumber;
    27   m_ntupleFileName += ".root";
     26        if(prefix.Length() > 0){
     27                m_ntupleFileName += prefix;
     28                m_ntupleFileName += "_";
     29                m_ntupleFileName += m_MPXDataSetNumber;
     30        } else {
     31                m_ntupleFileName += "Hits_"+m_MPXDataSetNumber;
     32        }
     33        m_ntupleFileName += ".root";
    2834
    29   nt = new TFile(m_ntupleFileName, openmode);
    30   t2 = new TTree("AllPixHits", dataSet);
     35        nt = new TFile(m_ntupleFileName, openmode);
     36        t2 = new TTree("AllPixHits", dataSet);
    3137
    32   m_storableHits = new SimpleHits;
    33   m_storableHits->Rewind();
    34   t2->Branch("SimpleHits", "SimpleHits", &m_storableHits);
     38        m_storableHits = new SimpleHits;
     39        m_storableHits->Rewind();
     40        t2->Branch("SimpleHits", "SimpleHits", &m_storableHits);
    3541
    3642}
     
    4046 *
    4147 */
    42 Hits_WriteToNtuple * Hits_WriteToNtuple::GetInstance(TString dataset, TString tempdir, Int_t nOfInstances, Int_t detID, TString openmode /* RECREATE */){
     48Hits_WriteToNtuple * Hits_WriteToNtuple::GetInstance(TString prefix, TString dataset, TString tempdir, Int_t nOfInstances, Int_t detID, TString openmode /* RECREATE */){
    4349
    44   if(detID >= nOfInstances){
    45     std::cout << "[ERROR] (in Hits_WriteToNtuple::GetInstance) you are asking for the " << detID << "th hits ntuple"
    46               << " out of " << nOfInstances << " aborting ..." << std::endl;
    47     std::cout << "        (note: Indexing starts at 0)" << std::endl;
    48     exit(1);
    49   }
    50  
    51   TString tempDataset = dataset;
    52   if (instance_hit == 0){
    53     // create pointers for all instances
    54     instance_hit = new Hits_WriteToNtuple * [nOfInstances];
    55   }
     50        if(detID >= nOfInstances){
     51                std::cout << "[ERROR] (in Hits_WriteToNtuple::GetInstance) you are asking for the " << detID << "th hits ntuple"
     52                                << " out of " << nOfInstances << " aborting ..." << std::endl;
     53                std::cout << "        (note: Indexing starts at 0)" << std::endl;
     54                exit(1);
     55        }
    5656
    57   // but instanciate only once at a time
    58   if(g_instance_hit_Cntr < nOfInstances)
    59     {
    60       std::cout << "Creating hits file : "
    61                 << "\"" << tempDataset
    62                 << "\"" << std::endl;
    63       instance_hit[detID] = new Hits_WriteToNtuple(tempDataset, tempdir, detID, openmode);
    64       g_instance_hit_Cntr++;
    65     }
     57        TString tempDataset = dataset;
     58        if (instance_hit == 0){
     59                // create pointers for all instances
     60                instance_hit = new Hits_WriteToNtuple * [nOfInstances];
     61        }
    6662
    67   return instance_hit[detID];
     63        // but instanciate only once at a time
     64        if(g_instance_hit_Cntr < nOfInstances)
     65        {
     66                std::cout << "Creating hits file : "
     67                                << "\"" << tempDataset
     68                                << "\"" << std::endl;
     69                instance_hit[detID] = new Hits_WriteToNtuple(prefix, tempDataset, tempdir, detID, openmode);
     70                g_instance_hit_Cntr++;
     71        }
     72
     73        return instance_hit[detID];
    6874}
    6975
    7076void Hits_WriteToNtuple::fillVars(SimpleHits * hits_i){
    7177
    72   // Variables(class) in the Tree
    73   m_storableHits = hits_i;
     78        // Variables(class) in the Tree
     79        m_storableHits = hits_i;
    7480
    75   // fill the Tree
    76   nt->cd();
    77   t2->Fill();
     81        // fill the Tree
     82        nt->cd();
     83        t2->Fill();
    7884
    79   // clean up
    80   m_storableHits->Rewind();
     85        // clean up
     86        m_storableHits->Rewind();
    8187
    8288}
     
    8591{
    8692
    87   nt->cd();
    88   t2->Write();
    89   nt->Close();
     93        nt->cd();
     94        t2->Write();
     95        nt->Close();
    9096
    9197}
     
    95101
    96102SimpleHits::SimpleHits(){
    97   Rewind();
     103        Rewind();
    98104}
    99105
    100106void SimpleHits::Rewind(){
    101107
    102   edepTotal = 0.;
     108        edepTotal = 0.;
    103109
    104   interactions.clear();
    105   pos.clear();
    106   pdgId.clear();
    107   edep.clear();
    108   trackId.clear();
    109   parentId.clear();
    110   trackVolumeName.clear();
    111   parentVolumeName.clear();
    112  
    113   event = 0;
    114   run = 0;
     110        interactions.clear();
     111        pos.clear();
     112        pdgId.clear();
     113        edep.clear();
     114        trackId.clear();
     115        parentId.clear();
     116        trackVolumeName.clear();
     117        parentVolumeName.clear();
     118
     119        event = 0;
     120        run = 0;
    115121}
Note: See TracChangeset for help on using the changeset viewer.