CMS 3D CMS Logo

DTDigiReader.cc
Go to the documentation of this file.
1 #ifndef SimMuon_DTDigiReader_h
2 #define SimMuon_DTDigiReader_h
3 
11 
15 
18 
21 
22 #include <iostream>
23 
24 #include "TFile.h"
25 #include "TH1F.h" //FIXME
26 
27 using namespace edm;
28 using namespace std;
29 
31 public:
32  explicit DTDigiReader(const ParameterSet &pset) {
33  file = new TFile("DTDigiPlots.root", "RECREATE");
34  file->cd();
35  DigiTimeBox = new TH1F("DigiTimeBox", "Digi Time Box", 2048, 0, 1600);
36  DigiTimeBoxW0 = new TH1F("DigiTimeBoxW0", "Digi Time Box W0", 2000, 0, 1600);
37  DigiTimeBoxW1 = new TH1F("DigiTimeBoxW1", "Digi Time Box W1", 2000, 0, 1600);
38  DigiTimeBoxW2 = new TH1F("DigiTimeBoxW2", "Digi Time Box W2", 2000, 0, 1600);
39  if (file->IsOpen())
40  cout << "file open!" << endl;
41  else
42  cout << "*** Error in opening file ***" << endl;
43  label = pset.getUntrackedParameter<string>("label");
44  psim_token = consumes<PSimHitContainer>(edm::InputTag("g4SimHits", "MuonDTHits"));
45  DTd_token = consumes<DTDigiCollection>(edm::InputTag(label));
46  }
47 
48  ~DTDigiReader() override {
49  file->cd();
50  DigiTimeBox->Write();
51  DigiTimeBoxW0->Write();
52  DigiTimeBoxW1->Write();
53  DigiTimeBoxW2->Write();
54  file->Close();
55  // delete file;
56  // delete DigiTimeBox;
57  }
58 
59  void analyze(const Event &event, const EventSetup &eventSetup) override {
60  cout << "--- Run: " << event.id().run() << " Event: " << event.id().event() << endl;
61 
63  event.getByToken(DTd_token, dtDigis);
64  // event.getByLabel("MuonDTDigis", dtDigis);
66  event.getByToken(psim_token, simHits);
67 
69  for (detUnitIt = dtDigis->begin(); detUnitIt != dtDigis->end(); ++detUnitIt) {
70  const DTLayerId &id = (*detUnitIt).first;
71  const DTDigiCollection::Range &range = (*detUnitIt).second;
72 
73  // DTLayerId print-out
74  cout << "--------------" << endl;
75  cout << "id: " << id;
76 
77  // Loop over the digis of this DetUnit
78  for (DTDigiCollection::const_iterator digiIt = range.first; digiIt != range.second; ++digiIt) {
79  // if((*digiIt).time()<703 &&(*digiIt).time()>699) {
80  cout << " Wire: " << (*digiIt).wire() << endl << " digi time (ns): " << (*digiIt).time() << endl;
81 
82  for (vector<PSimHit>::const_iterator simHit = simHits->begin(); simHit != simHits->end(); simHit++) {
83  DTWireId wireId((*simHit).detUnitId());
84  if (wireId.layerId() == id && abs((*simHit).particleType()) == 13) {
85  cout << "entry: " << (*simHit).entryPoint() << endl
86  << "exit: " << (*simHit).exitPoint() << endl
87  << "TOF: " << (*simHit).timeOfFlight() << endl;
88  }
89  }
90 
91  // }
92 
93  if (id.layer() == 3)
94  DigiTimeBoxW0->Fill((*digiIt).time());
95  else if (abs(id.superlayer()) == 1)
96  DigiTimeBoxW1->Fill((*digiIt).time());
97  else if (abs(id.superlayer()) == 2)
98  DigiTimeBoxW2->Fill((*digiIt).time());
99  else
100  cout << "Error" << endl;
101  DigiTimeBox->Fill((*digiIt).time());
102 
103  } // for digis in layer
104  } // for layers
105  cout << "--------------" << endl;
106  }
107 
108 private:
109  string label;
110  TH1F *DigiTimeBox;
114  TFile *file;
115 
118 };
119 
120 #endif
FastTimerService_cff.range
range
Definition: FastTimerService_cff.py:34
EDAnalyzer.h
DTDigiReader::DTd_token
edm::EDGetTokenT< DTDigiCollection > DTd_token
Definition: DTDigiReader.cc:117
DTDigiReader::DigiTimeBoxW2
TH1F * DigiTimeBoxW2
Definition: DTDigiReader.cc:113
edm::EDGetTokenT< PSimHitContainer >
edm
HLT enums.
Definition: AlignableModifier.h:19
gather_cfg.cout
cout
Definition: gather_cfg.py:144
PSimHitContainer.h
FastTrackerRecHitCombiner_cfi.simHits
simHits
Definition: FastTrackerRecHitCombiner_cfi.py:5
DTDigiReader::DTDigiReader
DTDigiReader(const ParameterSet &pset)
Definition: DTDigiReader.cc:32
edm::one::EDAnalyzer
Definition: EDAnalyzer.h:30
edm::Handle< DTDigiCollection >
MuonDigiCollection::const_iterator
std::vector< DigiType >::const_iterator const_iterator
Definition: MuonDigiCollection.h:94
DTDigiReader::DigiTimeBoxW0
TH1F * DigiTimeBoxW0
Definition: DTDigiReader.cc:111
PSimHit.h
DTDigiReader
Definition: DTDigiReader.cc:30
DTWireId
Definition: DTWireId.h:12
DTDigiReader::file
TFile * file
Definition: DTDigiReader.cc:114
rpcPointValidation_cfi.simHit
simHit
Definition: rpcPointValidation_cfi.py:24
DTDigiReader::psim_token
edm::EDGetTokenT< PSimHitContainer > psim_token
Definition: DTDigiReader.cc:116
DTLayerId
Definition: DTLayerId.h:12
DTDigiReader::DigiTimeBoxW1
TH1F * DigiTimeBoxW1
Definition: DTDigiReader.cc:112
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
DTDigiReader::analyze
void analyze(const Event &event, const EventSetup &eventSetup) override
Definition: DTDigiReader.cc:59
FrontierConditions_GlobalTag_cff.file
file
Definition: FrontierConditions_GlobalTag_cff.py:13
DTDigiReader::label
string label
Definition: DTDigiReader.cc:109
DTDigiReader::DigiTimeBox
TH1F * DigiTimeBox
Definition: DTDigiReader.cc:110
edm::EventSetup
Definition: EventSetup.h:57
DTDigiReader::~DTDigiReader
~DTDigiReader() override
Definition: DTDigiReader.cc:48
std
Definition: JetResolutionObject.h:76
DTWireId.h
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:31
MuonDigiCollection::Range
std::pair< const_iterator, const_iterator > Range
Definition: MuonDigiCollection.h:95
ConsumesCollector.h
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
DTDigiCollection.h
ParameterSet.h
event
Definition: event.py:1
DigiContainerIterator
Definition: MuonDigiCollection.h:30
edm::Event
Definition: Event.h:73
edm::InputTag
Definition: InputTag.h:15
label
const char * label
Definition: PFTauDecayModeTools.cc:11
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27