CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DTPreCalibrationTask.cc
Go to the documentation of this file.
2 
3 
4 // Framework
13 
14 // Geometry
19 
20 // Digis
24 
25 
26 #include "TH2F.h"
27 #include "TFile.h"
28 
29 using namespace edm;
30 using namespace std;
31 
32 
33 
35 
36  LogTrace("DTPreCalibSummary") <<"[DTPrecalibrationTask]: Constructor"<<endl;
37 
38  dbe = Service<DQMStore>().operator->();
39 
40  // Label to retrieve DT digis from the event
41  digiLabel = consumes<DTDigiCollection>(ps.getUntrackedParameter<string>("digiLabel"));
42 
43  // parameter for Time Boxes booking
44  minTriggerWidth = ps.getUntrackedParameter<int>("minTriggerWidth",2000);
45  maxTriggerWidth = ps.getUntrackedParameter<int>("maxTriggerWidth",6000);
46 
47  // histo saving on file
48  saveFile = ps.getUntrackedParameter<bool>("SaveFile",false);
49  // output file name
50  outputFileName = ps.getUntrackedParameter<string>("outputFileName");
51  // get the histo folder name
52  folderName = ps.getUntrackedParameter<string>("folderName");
53 
54 }
55 
56 
58 
59 
61 
62  for(int wheel=-2; wheel<=2; wheel++){
63  for(int sector=1; sector<=14; sector++){
64  LogTrace("DTPreCalibSummary") <<"[DTPrecalibrationTask]: Book histos for wheel "<<wheel<<", sector "<<sector<<endl;
65  dbe->setCurrentFolder(folderName+"/TimeBoxes");
66  bookTimeBoxes(wheel, sector);
67  dbe->setCurrentFolder(folderName+"/OccupancyHistos");
68  if(sector<13) bookOccupancyPlot(wheel, sector);
69  }
70  }
71 
72 }
73 
74 
76 
77  // Get the digis from the event
79  event.getByToken(digiLabel, dtdigis);
80 
81  // LOOP OVER ALL THE DIGIS OF THE EVENT
83  for (dtLayerId_It=dtdigis->begin(); dtLayerId_It!=dtdigis->end(); ++dtLayerId_It){
84  for (DTDigiCollection::const_iterator digiIt = ((*dtLayerId_It).second).first;
85  digiIt!=((*dtLayerId_It).second).second; ++digiIt){
86 
87  //Fill the Time Boxes
88  int tdcTime = (*digiIt).countsTDC();
89  TimeBoxes[make_pair((*dtLayerId_It).first.superlayerId().chamberId().wheel(),
90  (*dtLayerId_It).first.superlayerId().chamberId().sector())]->Fill(tdcTime);
91 
92  //Fill the occupancy plot
93  const DTLayerId dtLId = (*dtLayerId_It).first;
94  int yBin = (dtLId.station()-1)*12+dtLId.layer()+4*(dtLId.superlayer()-1);
95  if(dtLId.station()==4 && dtLId.superlayer()==3)
96  yBin = (dtLId.station()-1)*12+dtLId.layer()+4*(dtLId.superlayer()-2);
97  if((*dtLayerId_It).first.superlayerId().chamberId().sector()<13)
98  OccupancyHistos[make_pair((*dtLayerId_It).first.superlayerId().chamberId().wheel(),
99  (*dtLayerId_It).first.superlayerId().chamberId().sector())]->Fill((*digiIt).wire(),yBin);
100  else{
101  if(dtLId.superlayer()!=3) yBin = 44 + dtLId.layer();
102  else yBin = 48 + dtLId.layer();
103  if((*dtLayerId_It).first.superlayerId().chamberId().sector()==13)
104  OccupancyHistos[make_pair((*dtLayerId_It).first.superlayerId().chamberId().wheel(),4)]->Fill((*digiIt).wire(),yBin);
105  if((*dtLayerId_It).first.superlayerId().chamberId().sector()==14)
106  OccupancyHistos[make_pair((*dtLayerId_It).first.superlayerId().chamberId().wheel(),10)]->Fill((*digiIt).wire(),yBin);
107  }
108 
109  }
110  }
111 
112 }
113 
114 
116 
117  // save file for offLine analysis
118  if(saveFile)
119  dbe->save(outputFileName);
120 
121 }
122 
123 
124 void DTPreCalibrationTask::bookTimeBoxes(int wheel, int sector) {
125 
126  stringstream wh; wh << wheel;
127  stringstream sec; sec << sector;
128 
129  // book the time boxes
130  TimeBoxes[make_pair(wheel, sector)]= dbe->book1D("TimeBox_W"+wh.str()+"_Sec"+sec.str(), "Time Box W"+wh.str()+"_Sec"+sec.str(),(maxTriggerWidth-minTriggerWidth)/50, minTriggerWidth, maxTriggerWidth);
131  TimeBoxes[make_pair(wheel, sector)]->setAxisTitle("TDC counts");
132 
133 }
134 
135 
136 
137 void DTPreCalibrationTask::bookOccupancyPlot(int wheel, int sector) {
138 
139  stringstream wh; wh << wheel;
140  stringstream sec; sec << sector;
141 
142  // book the occpancy plot
143  if(sector==4 || sector==10)
144  OccupancyHistos[make_pair(wheel, sector)]= dbe->book2D("Occupancy_W"+wh.str()+"_Sec"+sec.str(), "Occupancy W"+wh.str()+"_Sec"+sec.str(),100,1,100,52,1,53);
145  else
146  OccupancyHistos[make_pair(wheel, sector)]= dbe->book2D("Occupancy_W"+wh.str()+"_Sec"+sec.str(), "Occupancy W"+wh.str()+"_Sec"+sec.str(),100,1,100,44,1,45);
147  OccupancyHistos[make_pair(wheel, sector)]->setAxisTitle("wire number", 1);
148  OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(1,"M1L1",2);
149  OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(2,"M1L2",2);
150  OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(3,"M1L3",2);
151  OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(4,"M1L4",2);
152  OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(5,"M1L5",2);
153  OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(6,"M1L6",2);
154  OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(7,"M1L7",2);
155  OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(8,"M1L8",2);
156  OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(9,"M1L9",2);
157  OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(10,"M1L10",2);
158  OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(11,"M1L11",2);
159  OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(12,"M1L12",2);
160  OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(13,"M2L1",2);
161  OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(14,"M2L2",2);
162  OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(15,"M2L3",2);
163  OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(16,"M2L4",2);
164  OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(17,"M2L5",2);
165  OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(18,"M2L6",2);
166  OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(19,"M2L7",2);
167  OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(20,"M2L8",2);
168  OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(21,"M2L9",2);
169  OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(22,"M2L10",2);
170  OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(23,"M2L11",2);
171  OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(24,"M2L12",2);
172  OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(25,"M3L1",2);
173  OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(26,"M3L2",2);
174  OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(27,"M3L3",2);
175  OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(28,"M3L4",2);
176  OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(29,"M3L5",2);
177  OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(30,"M3L6",2);
178  OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(31,"M3L7",2);
179  OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(32,"M3L8",2);
180  OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(33,"M3L9",2);
181  OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(34,"M3L10",2);
182  OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(35,"M3L11",2);
183  OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(36,"M3L12",2);
184  OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(37,"M4L1",2);
185  OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(38,"M4L2",2);
186  OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(39,"M4L3",2);
187  OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(40,"M4L4",2);
188  OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(41,"M4L5",2);
189  OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(42,"M4L6",2);
190  OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(43,"M4L7",2);
191  OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(44,"M4L8",2);
192  if(sector==4){
193  OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(45,"M4Sec13L1",2);
194  OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(46,"M4Sec13L2",2);
195  OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(47,"M4Sec13L3",2);
196  OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(48,"M4Sec13L4",2);
197  OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(49,"M4Sec13L5",2);
198  OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(50,"M4Sec13L6",2);
199  OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(51,"M4Sec13L7",2);
200  OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(52,"M4Sec13L8",2);
201  }
202  if(sector==10){
203  OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(45,"M4Sec14L1",2);
204  OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(46,"M4Sec14L2",2);
205  OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(47,"M4Sec14L3",2);
206  OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(48,"M4Sec14L4",2);
207  OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(49,"M4Sec14L5",2);
208  OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(50,"M4Sec14L6",2);
209  OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(51,"M4Sec14L7",2);
210  OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(52,"M4Sec14L8",2);
211  }
212 
213 }
T getUntrackedParameter(std::string const &, T const &) const
DTPreCalibrationTask(const edm::ParameterSet &ps)
Constructor.
tuple yBin
Definition: cuy.py:891
int layer() const
Return the layer number.
Definition: DTLayerId.h:53
U second(std::pair< T, U > const &p)
virtual ~DTPreCalibrationTask()
Destructor.
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
void bookTimeBoxes(int wheel, int sector)
Book histos.
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
#define LogTrace(id)
int superlayer() const
Return the superlayer number (deprecated method name)
std::vector< DTDigi >::const_iterator const_iterator
int station() const
Return the station number.
Definition: DTChamberId.h:51
void bookOccupancyPlot(int wheel, int sector)
void analyze(const edm::Event &e, const edm::EventSetup &c)
Analyze.
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")