All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Public Types | Public Member Functions | Private Attributes | List of all members
sbnd::CRTDetSimAna Class Reference
Inheritance diagram for sbnd::CRTDetSimAna:

Classes

struct  Config
 

Public Types

using Parameters = art::EDAnalyzer::Table< Config >
 

Public Member Functions

 CRTDetSimAna (Parameters const &config)
 
virtual void beginJob () override
 
virtual void analyze (const art::Event &event) override
 
virtual void endJob () override
 

Private Attributes

art::InputTag fSimModuleLabel
 name of MCParticle producer in g4 More...
 
art::InputTag fSimChannelModuleLabel
 name of SimChannel producer in g4 More...
 
art::InputTag fCRTSimLabel
 name of CRT producer More...
 
bool fVerbose
 print information about what's going on More...
 
double fQPed
 
double fQSlope
 
double fClockSpeedCRT
 
std::map< std::string, TH1D * > hADC
 
std::map< std::string, TH1D * > hNpe
 
std::map< std::string, TH1D * > hNpeRatio
 
std::map< std::string, TH1D * > hTime
 
std::map< std::string, TH1D * > hStripDist
 
std::map< std::string, TH1D * > hSipmDist
 
std::map< std::string, TH1D * > hEffSipmDistTotal
 
std::map< std::string, TH1D * > hEffSipmDistReco
 
std::map< std::string, TH1D * > hEffStripDistTotal
 
std::map< std::string, TH1D * > hEffStripDistReco
 
std::map< std::string, TH1D * > hEffEDepTotal
 
std::map< std::string, TH1D * > hEffEDepReco
 
std::map< std::string, TH1D * > hEffLengthTotal
 
std::map< std::string, TH1D * > hEffLengthReco
 
std::map< std::string, TH2D * > hStripDistADC
 
std::map< std::string, TH2D * > hSipmDistADC
 
std::map< std::string, TH2D * > hStripDistNpe
 
std::map< std::string, TH2D * > hSipmDistNpe
 
std::map< std::string, TH2D * > hSipmDistNpeRatio
 
geo::GeometryCore const * fGeometryService
 
TPCGeoAlg fTpcGeo
 
CRTGeoAlg fCrtGeo
 
CRTBackTracker fCrtBackTrack
 

Detailed Description

Definition at line 63 of file CRTDetSimAna_module.cc.

Member Typedef Documentation

using sbnd::CRTDetSimAna::Parameters = art::EDAnalyzer::Table<Config>

Definition at line 111 of file CRTDetSimAna_module.cc.

Constructor & Destructor Documentation

sbnd::CRTDetSimAna::CRTDetSimAna ( Parameters const &  config)
explicit

Definition at line 172 of file CRTDetSimAna_module.cc.

173  : EDAnalyzer(config)
174  , fSimModuleLabel (config().SimModuleLabel())
175  , fSimChannelModuleLabel(config().SimChannelModuleLabel())
176  , fCRTSimLabel (config().CRTSimLabel())
177  , fVerbose (config().Verbose())
178  , fQPed (config().QPed())
179  , fQSlope (config().QSlope())
180  , fClockSpeedCRT (config().ClockSpeedCRT())
181  , fCrtBackTrack (config().CrtBackTrack())
182  {
183  // Get a pointer to the fGeometryServiceetry service provider
184  fGeometryService = lar::providerFrom<geo::Geometry>();
185  }
BEGIN_PROLOG Verbose
CRTBackTracker fCrtBackTrack
art::InputTag fCRTSimLabel
name of CRT producer
bool fVerbose
print information about what&#39;s going on
art::InputTag fSimModuleLabel
name of MCParticle producer in g4
art::InputTag fSimChannelModuleLabel
name of SimChannel producer in g4
geo::GeometryCore const * fGeometryService

Member Function Documentation

void sbnd::CRTDetSimAna::analyze ( const art::Event &  event)
overridevirtual

Definition at line 222 of file CRTDetSimAna_module.cc.

223  {
224 
225  // Fetch basic event info
226  if(fVerbose){
227  std::cout<<"============================================"<<std::endl
228  <<"Run = "<<event.run()<<", SubRun = "<<event.subRun()<<", Event = "<<event.id().event()<<std::endl
229  <<"============================================"<<std::endl;
230  }
231 
232 
233  //----------------------------------------------------------------------------------------------------------
234  // GETTING PRODUCTS
235  //----------------------------------------------------------------------------------------------------------
236 
237  // Get g4 particles
238  art::ServiceHandle<cheat::ParticleInventoryService> pi_serv;
239  auto particleHandle = event.getValidHandle<std::vector<simb::MCParticle>>(fSimModuleLabel);
240 
241  // Get CRT data from the event
242  art::Handle< std::vector<sbnd::crt::CRTData>> crtDataHandle;
243  std::vector<art::Ptr<sbnd::crt::CRTData> > crtDataList;
244  if (event.getByLabel(fCRTSimLabel, crtDataHandle))
245  art::fill_ptr_vector(crtDataList, crtDataHandle);
246 
247  art::FindManyP<sim::AuxDetIDE> findManyIdes(crtDataHandle, event, fCRTSimLabel);
248 
249  // Get all the auxdet IDEs from the event
250  art::Handle<std::vector<sim::AuxDetSimChannel> > channels;
251  event.getByLabel(fSimChannelModuleLabel, channels);
252 
253  //----------------------------------------------------------------------------------------------------------
254  // TRUTH MATCHING
255  //----------------------------------------------------------------------------------------------------------
256 
257  std::map<int, simb::MCParticle> particles;
258  // Loop over the true particles
259  for (auto const& particle: (*particleHandle)){
260 
261  // Make map with ID
262  int partID = particle.TrackId();
263  particles[partID] = particle;
264 
265  }
266 
267  //----------------------------------------------------------------------------------------------------------
268  // CRT DATA ANALYSIS
269  //----------------------------------------------------------------------------------------------------------
270 
271  std::map<int, std::vector<sbnd::crt::CRTData>> crtData;
272  for(size_t i = 0; i < crtDataList.size(); i++){
273 
274  // Truth matching
275  std::vector<int> trueIDs = fCrtBackTrack.AllTrueIds(event, *crtDataList[i]);
276  for(auto const& id : trueIDs){
277  crtData[id].push_back(*crtDataList[i]);
278  }
279 
280  int trueID = fCrtBackTrack.TrueIdFromTotalEnergy(event, *crtDataList[i]);
281  // Only consider primary muons
282  if(particles.find(trueID) == particles.end()) continue;
283  if(!(std::abs(particles[trueID].PdgCode()) == 13 && particles[trueID].Mother() == 0)) continue;
284 
285  // Get the IDEs associated with the crtData
286  std::vector<art::Ptr<sim::AuxDetIDE>> ides = findManyIdes.at(i);
287  // Calculate the average position
288  double x = 0, y = 0, z = 0;
289  for(auto const& ide : ides){
290  x += (ide->entryX + ide->exitX)/2.;
291  y += (ide->entryY + ide->exitY)/2.;
292  z += (ide->entryZ + ide->exitZ)/2.;
293  }
294  x = x/ides.size();
295  y = y/ides.size();
296  z = z/ides.size();
297  geo::Point_t cross {x, y, z};
298 
299  int channel = crtDataList[i]->Channel();
300  std::string stripName = fCrtGeo.ChannelToStripName(channel);
301  std::string tagger = fCrtGeo.GetTaggerName(stripName);
302 
303  double npe = ((double)crtDataList[i]->ADC() - fQPed)/fQSlope;
304 
305  // Calculate distance to the sipm
306  double sipmDist = fCrtGeo.DistanceBetweenSipms(cross, channel);
307  hSipmDist[tagger]->Fill(sipmDist);
308  hSipmDistADC[tagger]->Fill(sipmDist, crtDataList[i]->ADC());
309  hSipmDistNpe[tagger]->Fill(sipmDist, npe);
310 
311  if(channel % 2 == 0){
312  double npe1 = ((double)crtDataList[i+1]->ADC() - fQPed)/fQSlope;
313  hNpeRatio[tagger]->Fill(npe/npe1);
314  hSipmDistNpeRatio[tagger]->Fill(sipmDist, npe/npe1);
315  }
316 
317  // Calculate the distance to the end
318  double stripDist = std::abs(fCrtGeo.DistanceDownStrip(cross, stripName));
319  hStripDist[tagger]->Fill(stripDist);
320  hStripDistADC[tagger]->Fill(stripDist, crtDataList[i]->ADC());
321  hStripDistNpe[tagger]->Fill(stripDist, npe);
322 
323  hADC[tagger]->Fill(crtDataList[i]->ADC());
324  hNpe[tagger]->Fill(npe);
325 
326  //fTrigClock.SetTime(crtDataList[i]->T0());
327  //double time = fTrigClock.Time(); // [us]
328  double time = (double)(int)crtDataList[i]->T0()/fClockSpeedCRT; // [tick -> us]
329  hTime[tagger]->Fill(time);
330  }
331 
332  //----------------------------------------------------------------------------------------------------------
333  // EFFICIENCIES
334  //----------------------------------------------------------------------------------------------------------
335 
336  for (auto& adsc : *channels) {
337  // Get the IDEs from the Aux Det channels
338  if(adsc.AuxDetSensitiveID() == UINT_MAX) {
339  mf::LogWarning("CRTDetSimAna") << "AuxDetSimChannel with ID: UINT_MAX\n"
340  << "skipping channel...";
341  continue;
342  }
343 
344  std::string stripName = fCrtGeo.GetStrip(adsc.AuxDetSensitiveID()).name;
345  std::string tagger = fCrtGeo.GetTaggerName(stripName);
346  std::vector<sim::AuxDetIDE> ides = adsc.AuxDetIDEs();
347 
348  for(auto const& ide : ides){
349  geo::Point_t pos {(ide.entryX + ide.exitX)/2,
350  (ide.entryY + ide.exitY)/2,
351  (ide.entryZ + ide.exitZ)/2};
352  int trueID = ide.trackID;
353  // Calculate length in strip
354  double length = std::sqrt(std::pow(ide.entryX - ide.exitX, 2)
355  + std::pow(ide.entryY - ide.exitY, 2)
356  + std::pow(ide.entryZ - ide.exitZ, 2));
357  // Calculate distances of average point to sipms
358  double sipmDistIde = fCrtGeo.DistanceBetweenSipms(pos, stripName);
359  double stripDistIde = fCrtGeo.DistanceDownStrip(pos, stripName);
360 
361  // Only consider primary muons for efficiency
362  if(particles.find(trueID) == particles.end()) continue;
363  if(!(std::abs(particles[trueID].PdgCode()) == 13 && particles[trueID].Mother() == 0)) continue;
364 
365  // Fill total histograms
366  hEffSipmDistTotal[tagger]->Fill(sipmDistIde);
367  hEffStripDistTotal[tagger]->Fill(stripDistIde);
368  hEffEDepTotal[tagger]->Fill(ide.energyDeposited);
369  hEffLengthTotal[tagger]->Fill(length);
370 
371  // Get all the CRT data matched to the same true ID
372  if(crtData.find(trueID) == crtData.end()) continue;
373  bool match = false;
374  // If there is CRT data produced on the same channel then it is matched
375  for(auto const& data : crtData[trueID]){
376  std::string stripNameData = fCrtGeo.ChannelToStripName(data.Channel());
377  if(stripName == stripNameData) match = true;
378  }
379  if(!match) continue;
380 
381  // Fill reconstructed histograms
382  hEffSipmDistReco[tagger]->Fill(sipmDistIde);
383  hEffStripDistReco[tagger]->Fill(stripDistIde);
384  hEffEDepReco[tagger]->Fill(ide.energyDeposited);
385  hEffLengthReco[tagger]->Fill(length);
386 
387  }
388  }
389 
390 
391  } // CRTDetSimAna::analyze()
process_name opflash particleana ie ie ie z
std::vector< int > AllTrueIds(const art::Event &event, const sbnd::crt::CRTData &data)
process_name opflash particleana ie x
std::map< std::string, TH1D * > hEffStripDistReco
std::map< std::string, TH1D * > hSipmDist
CRTBackTracker fCrtBackTrack
std::map< std::string, TH1D * > hEffStripDistTotal
std::map< std::string, TH1D * > hEffLengthTotal
art::InputTag fCRTSimLabel
name of CRT producer
bool fVerbose
print information about what&#39;s going on
std::map< std::string, TH1D * > hNpe
int TrueIdFromTotalEnergy(const art::Event &event, const sbnd::crt::CRTData &data)
art::InputTag fSimModuleLabel
name of MCParticle producer in g4
T abs(T value)
process_name opflash particleana ie ie y
std::string ChannelToStripName(size_t channel) const
double DistanceDownStrip(geo::Point_t position, std::string stripName) const
CRTStripGeo GetStrip(std::string stripName) const
std::map< std::string, TH2D * > hSipmDistNpeRatio
std::string GetTaggerName(std::string name) const
std::map< std::string, TH1D * > hNpeRatio
std::map< std::string, TH2D * > hSipmDistNpe
std::map< std::string, TH1D * > hADC
std::map< std::string, TH1D * > hEffSipmDistReco
std::map< std::string, TH1D * > hEffEDepTotal
std::map< std::string, TH2D * > hSipmDistADC
then echo fcl name
std::map< std::string, TH1D * > hEffEDepReco
std::map< std::string, TH2D * > hStripDistADC
std::map< std::string, TH1D * > hStripDist
art::InputTag fSimChannelModuleLabel
name of SimChannel producer in g4
Vector cross(Vector const &a, Vector const &b)
Return cross product of two vectors.
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
Definition: geo_vectors.h:184
std::map< std::string, TH1D * > hTime
std::map< std::string, TH1D * > hEffLengthReco
std::map< std::string, TH1D * > hEffSipmDistTotal
std::map< std::string, TH2D * > hStripDistNpe
BEGIN_PROLOG could also be cout
double DistanceBetweenSipms(geo::Point_t position, size_t channel) const
void sbnd::CRTDetSimAna::beginJob ( )
overridevirtual

Definition at line 187 of file CRTDetSimAna_module.cc.

188  {
189  // Access tfileservice to handle creating and writing histograms
190  art::ServiceHandle<art::TFileService> tfs;
191  for(size_t i = 0; i < fCrtGeo.NumTaggers(); i++){
192  std::string tagger = fCrtGeo.GetTagger(i).name;
193  hADC[tagger] = tfs->make<TH1D>(Form("ADC_%s", tagger.c_str()), "", 40, 0, 10000);
194  hNpe[tagger] = tfs->make<TH1D>(Form("Npe_%s", tagger.c_str()), "", 40, 0, 300);
195  hNpeRatio[tagger] = tfs->make<TH1D>(Form("NpeRatio_%s", tagger.c_str()), "", 40, 0, 10);
196  hTime[tagger] = tfs->make<TH1D>(Form("Time_%s", tagger.c_str()), "", 40, -5000, 5000);
197  hStripDist[tagger] = tfs->make<TH1D>(Form("StripDist_%s", tagger.c_str()), "", 40, 0, 450);
198  hSipmDist[tagger] = tfs->make<TH1D>(Form("SipmDist_%s", tagger.c_str()), "", 40, 0, 11.2);
199 
200  hEffSipmDistTotal[tagger] = tfs->make<TH1D>(Form("EffSipmDistTotal_%s", tagger.c_str()), "", 20, 0, 11.2);
201  hEffSipmDistReco[tagger] = tfs->make<TH1D>(Form("EffSipmDistReco_%s", tagger.c_str()), "", 20, 0, 11.2);
202  hEffStripDistTotal[tagger] = tfs->make<TH1D>(Form("EffStripDistTotal_%s", tagger.c_str()), "", 20, 0, 450);
203  hEffStripDistReco[tagger] = tfs->make<TH1D>(Form("EffStripDistReco_%s", tagger.c_str()), "", 20, 0, 450);
204  hEffEDepTotal[tagger] = tfs->make<TH1D>(Form("EffEdepTotal_%s", tagger.c_str()), "", 20, 0, 0.01);
205  hEffEDepReco[tagger] = tfs->make<TH1D>(Form("EffEdepReco_%s", tagger.c_str()), "", 20, 0, 0.01);
206  hEffLengthTotal[tagger] = tfs->make<TH1D>(Form("EffLengthTotal_%s", tagger.c_str()), "", 20, 0, 10);
207  hEffLengthReco[tagger] = tfs->make<TH1D>(Form("EffLengthReco_%s", tagger.c_str()), "", 20, 0, 10);
208 
209  hStripDistADC[tagger] = tfs->make<TH2D>(Form("StripDistADC_%s", tagger.c_str()), "", 20, 0, 450, 20, 0, 10000);
210  hSipmDistADC[tagger] = tfs->make<TH2D>(Form("SipmDistADC_%s", tagger.c_str()), "", 20, 0, 11.2, 20, 0, 10000);
211  hStripDistNpe[tagger] = tfs->make<TH2D>(Form("StripDistNpe_%s", tagger.c_str()), "", 20, 0, 450, 20, 0, 300);
212  hSipmDistNpe[tagger] = tfs->make<TH2D>(Form("SipmDistNpe_%s", tagger.c_str()), "", 20, 0, 11.2, 20, 0, 300);
213  hSipmDistNpeRatio[tagger] = tfs->make<TH2D>(Form("SipmDistNpeRatio_%s", tagger.c_str()), "", 20, 0, 11.2, 20, 0, 10);
214  }
215 
216 
217  // Initial output
218  std::cout<<"----------------- Full CRT Detector Simulation Analysis Module -------------------"<<std::endl;
219 
220  }// CRTDetSimAna::beginJob()
std::map< std::string, TH1D * > hEffStripDistReco
std::map< std::string, TH1D * > hSipmDist
CRTTaggerGeo GetTagger(std::string taggerName) const
std::map< std::string, TH1D * > hEffStripDistTotal
std::map< std::string, TH1D * > hEffLengthTotal
std::map< std::string, TH1D * > hNpe
std::map< std::string, TH2D * > hSipmDistNpeRatio
std::map< std::string, TH1D * > hNpeRatio
std::map< std::string, TH2D * > hSipmDistNpe
std::map< std::string, TH1D * > hADC
std::map< std::string, TH1D * > hEffSipmDistReco
std::map< std::string, TH1D * > hEffEDepTotal
std::map< std::string, TH2D * > hSipmDistADC
std::map< std::string, TH1D * > hEffEDepReco
art::ServiceHandle< art::TFileService > tfs
std::map< std::string, TH2D * > hStripDistADC
std::map< std::string, TH1D * > hStripDist
std::map< std::string, TH1D * > hTime
std::map< std::string, TH1D * > hEffLengthReco
std::map< std::string, TH1D * > hEffSipmDistTotal
std::map< std::string, TH2D * > hStripDistNpe
BEGIN_PROLOG could also be cout
void sbnd::CRTDetSimAna::endJob ( )
overridevirtual

Definition at line 393 of file CRTDetSimAna_module.cc.

393  {
394 
395  } // CRTDetSimAna::endJob()

Member Data Documentation

double sbnd::CRTDetSimAna::fClockSpeedCRT
private

Definition at line 134 of file CRTDetSimAna_module.cc.

CRTBackTracker sbnd::CRTDetSimAna::fCrtBackTrack
private

Definition at line 167 of file CRTDetSimAna_module.cc.

CRTGeoAlg sbnd::CRTDetSimAna::fCrtGeo
private

Definition at line 166 of file CRTDetSimAna_module.cc.

art::InputTag sbnd::CRTDetSimAna::fCRTSimLabel
private

name of CRT producer

Definition at line 130 of file CRTDetSimAna_module.cc.

geo::GeometryCore const* sbnd::CRTDetSimAna::fGeometryService
private

Definition at line 164 of file CRTDetSimAna_module.cc.

double sbnd::CRTDetSimAna::fQPed
private

Definition at line 132 of file CRTDetSimAna_module.cc.

double sbnd::CRTDetSimAna::fQSlope
private

Definition at line 133 of file CRTDetSimAna_module.cc.

art::InputTag sbnd::CRTDetSimAna::fSimChannelModuleLabel
private

name of SimChannel producer in g4

Definition at line 129 of file CRTDetSimAna_module.cc.

art::InputTag sbnd::CRTDetSimAna::fSimModuleLabel
private

name of MCParticle producer in g4

Definition at line 128 of file CRTDetSimAna_module.cc.

TPCGeoAlg sbnd::CRTDetSimAna::fTpcGeo
private

Definition at line 165 of file CRTDetSimAna_module.cc.

bool sbnd::CRTDetSimAna::fVerbose
private

print information about what's going on

Definition at line 131 of file CRTDetSimAna_module.cc.

std::map<std::string, TH1D*> sbnd::CRTDetSimAna::hADC
private

Definition at line 138 of file CRTDetSimAna_module.cc.

std::map<std::string, TH1D*> sbnd::CRTDetSimAna::hEffEDepReco
private

Definition at line 152 of file CRTDetSimAna_module.cc.

std::map<std::string, TH1D*> sbnd::CRTDetSimAna::hEffEDepTotal
private

Definition at line 151 of file CRTDetSimAna_module.cc.

std::map<std::string, TH1D*> sbnd::CRTDetSimAna::hEffLengthReco
private

Definition at line 154 of file CRTDetSimAna_module.cc.

std::map<std::string, TH1D*> sbnd::CRTDetSimAna::hEffLengthTotal
private

Definition at line 153 of file CRTDetSimAna_module.cc.

std::map<std::string, TH1D*> sbnd::CRTDetSimAna::hEffSipmDistReco
private

Definition at line 148 of file CRTDetSimAna_module.cc.

std::map<std::string, TH1D*> sbnd::CRTDetSimAna::hEffSipmDistTotal
private

Definition at line 147 of file CRTDetSimAna_module.cc.

std::map<std::string, TH1D*> sbnd::CRTDetSimAna::hEffStripDistReco
private

Definition at line 150 of file CRTDetSimAna_module.cc.

std::map<std::string, TH1D*> sbnd::CRTDetSimAna::hEffStripDistTotal
private

Definition at line 149 of file CRTDetSimAna_module.cc.

std::map<std::string, TH1D*> sbnd::CRTDetSimAna::hNpe
private

Definition at line 139 of file CRTDetSimAna_module.cc.

std::map<std::string, TH1D*> sbnd::CRTDetSimAna::hNpeRatio
private

Definition at line 140 of file CRTDetSimAna_module.cc.

std::map<std::string, TH1D*> sbnd::CRTDetSimAna::hSipmDist
private

Definition at line 144 of file CRTDetSimAna_module.cc.

std::map<std::string, TH2D*> sbnd::CRTDetSimAna::hSipmDistADC
private

Definition at line 158 of file CRTDetSimAna_module.cc.

std::map<std::string, TH2D*> sbnd::CRTDetSimAna::hSipmDistNpe
private

Definition at line 160 of file CRTDetSimAna_module.cc.

std::map<std::string, TH2D*> sbnd::CRTDetSimAna::hSipmDistNpeRatio
private

Definition at line 161 of file CRTDetSimAna_module.cc.

std::map<std::string, TH1D*> sbnd::CRTDetSimAna::hStripDist
private

Definition at line 143 of file CRTDetSimAna_module.cc.

std::map<std::string, TH2D*> sbnd::CRTDetSimAna::hStripDistADC
private

Definition at line 157 of file CRTDetSimAna_module.cc.

std::map<std::string, TH2D*> sbnd::CRTDetSimAna::hStripDistNpe
private

Definition at line 159 of file CRTDetSimAna_module.cc.

std::map<std::string, TH1D*> sbnd::CRTDetSimAna::hTime
private

Definition at line 142 of file CRTDetSimAna_module.cc.


The documentation for this class was generated from the following file: