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 
13 
16 
19 
20 #include <iostream>
21 
22 #include "TH1F.h" //FIXME
23 #include "TFile.h"
24 
25 using namespace edm;
26 using namespace std;
27 
28 class DTDigiReader: public EDAnalyzer{
29 
30 public:
31  explicit DTDigiReader(const ParameterSet& pset){
32  file = new TFile("DTDigiPlots.root","RECREATE");
33  file->cd();
34  DigiTimeBox = new TH1F("DigiTimeBox","Digi Time Box",2048,0,1600);
35  DigiTimeBoxW0 = new TH1F("DigiTimeBoxW0","Digi Time Box W0",2000,0,1600);
36  DigiTimeBoxW1 = new TH1F("DigiTimeBoxW1","Digi Time Box W1",2000,0,1600);
37  DigiTimeBoxW2 = new TH1F("DigiTimeBoxW2","Digi Time Box W2",2000,0,1600);
38  if(file->IsOpen()) cout<<"file open!"<<endl;
39  else cout<<"*** Error in opening file ***"<<endl;
40  label = pset.getUntrackedParameter<string>("label");
41  }
42 
43  virtual ~DTDigiReader(){
44  file->cd();
45  DigiTimeBox->Write();
46  DigiTimeBoxW0->Write();
47  DigiTimeBoxW1->Write();
48  DigiTimeBoxW2->Write();
49  file->Close();
50  // delete file;
51  // delete DigiTimeBox;
52  }
53 
54  void analyze(const Event & event, const EventSetup& eventSetup) override{
55  cout << "--- Run: " << event.id().run()
56  << " Event: " << event.id().event() << endl;
57 
59  event.getByLabel(label, dtDigis);
60  // event.getByLabel("MuonDTDigis", dtDigis);
62  event.getByLabel("g4SimHits","MuonDTHits",simHits);
63 
64 
66  for (detUnitIt=dtDigis->begin();
67  detUnitIt!=dtDigis->end();
68  ++detUnitIt){
69 
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;
79  digiIt!=range.second;
80  ++digiIt){
81  // if((*digiIt).time()<703 &&(*digiIt).time()>699) {
82  cout<<" Wire: "<<(*digiIt).wire()<<endl
83  <<" digi time (ns): "<<(*digiIt).time()<<endl;
84 
85  for(vector<PSimHit>::const_iterator simHit = simHits->begin();
86  simHit != simHits->end(); simHit++){
87  DTWireId wireId((*simHit).detUnitId());
88  if (wireId.layerId()==id && abs((*simHit).particleType())==13){
89  cout<<"entry: "<<(*simHit).entryPoint()<<endl
90  <<"exit: "<<(*simHit).exitPoint()<<endl
91  <<"TOF: "<<(*simHit).timeOfFlight()<<endl;
92  }
93  }
94 
95  // }
96 
97  if(id.layer()==3)
98  DigiTimeBoxW0->Fill((*digiIt).time());
99  else if(abs(id.superlayer())==1)
100  DigiTimeBoxW1->Fill((*digiIt).time());
101  else if(abs(id.superlayer())==2)
102  DigiTimeBoxW2->Fill((*digiIt).time());
103  else cout<<"Error"<<endl;
104  DigiTimeBox->Fill((*digiIt).time());
105 
106  }// for digis in layer
107  }// for layers
108  cout<<"--------------"<<endl;
109  }
110 
111 private:
112  string label;
113  TH1F *DigiTimeBox;
117  TFile *file;
118 
119 };
120 
121 #endif
T getUntrackedParameter(std::string const &, T const &) const
DTDigiReader(const ParameterSet &pset)
Definition: DTDigiReader.cc:31
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
void analyze(const Event &event, const EventSetup &eventSetup) override
Definition: DTDigiReader.cc:54
virtual ~DTDigiReader()
Definition: DTDigiReader.cc:43
std::pair< const_iterator, const_iterator > Range
tuple cout
Definition: gather_cfg.py:121
TH1F * DigiTimeBoxW2
TH1F * DigiTimeBoxW0