CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 "TH1F.h" //FIXME
25 #include "TFile.h"
26 
27 using namespace edm;
28 using namespace std;
29 
30 class DTDigiReader: public EDAnalyzer{
31 
32 public:
33  explicit DTDigiReader(const ParameterSet& pset){
34  file = new TFile("DTDigiPlots.root","RECREATE");
35  file->cd();
36  DigiTimeBox = new TH1F("DigiTimeBox","Digi Time Box",2048,0,1600);
37  DigiTimeBoxW0 = new TH1F("DigiTimeBoxW0","Digi Time Box W0",2000,0,1600);
38  DigiTimeBoxW1 = new TH1F("DigiTimeBoxW1","Digi Time Box W1",2000,0,1600);
39  DigiTimeBoxW2 = new TH1F("DigiTimeBoxW2","Digi Time Box W2",2000,0,1600);
40  if(file->IsOpen()) cout<<"file open!"<<endl;
41  else cout<<"*** Error in opening file ***"<<endl;
42  label = pset.getUntrackedParameter<string>("label");
43  psim_token = consumes<PSimHitContainer>( edm::InputTag("g4SimHits","MuonDTHits") );
44  DTd_token = consumes<DTDigiCollection>( edm::InputTag(label) );
45  }
46 
47  virtual ~DTDigiReader(){
48  file->cd();
49  DigiTimeBox->Write();
50  DigiTimeBoxW0->Write();
51  DigiTimeBoxW1->Write();
52  DigiTimeBoxW2->Write();
53  file->Close();
54  // delete file;
55  // delete DigiTimeBox;
56  }
57 
58  void analyze(const Event & event, const EventSetup& eventSetup) override{
59  cout << "--- Run: " << event.id().run()
60  << " Event: " << event.id().event() << endl;
61 
63  event.getByToken(DTd_token, dtDigis);
64  // event.getByLabel("MuonDTDigis", dtDigis);
66  event.getByToken(psim_token,simHits);
67 
68 
70  for (detUnitIt=dtDigis->begin();
71  detUnitIt!=dtDigis->end();
72  ++detUnitIt){
73 
74  const DTLayerId& id = (*detUnitIt).first;
75  const DTDigiCollection::Range& range = (*detUnitIt).second;
76 
77  // DTLayerId print-out
78  cout<<"--------------"<<endl;
79  cout<<"id: "<<id;
80 
81  // Loop over the digis of this DetUnit
82  for (DTDigiCollection::const_iterator digiIt = range.first;
83  digiIt!=range.second;
84  ++digiIt){
85  // if((*digiIt).time()<703 &&(*digiIt).time()>699) {
86  cout<<" Wire: "<<(*digiIt).wire()<<endl
87  <<" digi time (ns): "<<(*digiIt).time()<<endl;
88 
89  for(vector<PSimHit>::const_iterator simHit = simHits->begin();
90  simHit != simHits->end(); simHit++){
91  DTWireId wireId((*simHit).detUnitId());
92  if (wireId.layerId()==id && abs((*simHit).particleType())==13){
93  cout<<"entry: "<<(*simHit).entryPoint()<<endl
94  <<"exit: "<<(*simHit).exitPoint()<<endl
95  <<"TOF: "<<(*simHit).timeOfFlight()<<endl;
96  }
97  }
98 
99  // }
100 
101  if(id.layer()==3)
102  DigiTimeBoxW0->Fill((*digiIt).time());
103  else if(abs(id.superlayer())==1)
104  DigiTimeBoxW1->Fill((*digiIt).time());
105  else if(abs(id.superlayer())==2)
106  DigiTimeBoxW2->Fill((*digiIt).time());
107  else cout<<"Error"<<endl;
108  DigiTimeBox->Fill((*digiIt).time());
109 
110  }// for digis in layer
111  }// for layers
112  cout<<"--------------"<<endl;
113  }
114 
115 private:
116  string label;
117  TH1F *DigiTimeBox;
121  TFile *file;
122 
125 
126 };
127 
128 #endif
T getUntrackedParameter(std::string const &, T const &) const
DTDigiReader(const ParameterSet &pset)
Definition: DTDigiReader.cc:33
TH1F * DigiTimeBoxW1
TH1F * DigiTimeBox
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
std::vector< DTDigi >::const_iterator const_iterator
tuple simHits
Definition: trackerHits.py:16
edm::EDGetTokenT< PSimHitContainer > psim_token
void analyze(const Event &event, const EventSetup &eventSetup) override
Definition: DTDigiReader.cc:58
virtual ~DTDigiReader()
Definition: DTDigiReader.cc:47
std::pair< const_iterator, const_iterator > Range
tuple cout
Definition: gather_cfg.py:145
edm::EDGetTokenT< DTDigiCollection > DTd_token
TH1F * DigiTimeBoxW2
TH1F * DigiTimeBoxW0