CMS 3D CMS Logo

SiStripGainsPCLWorker.cc
Go to the documentation of this file.
4 
5 #include <iostream>
6 #include <sstream>
7 
8 //********************************************************************************//
10  NEvent(0),
11  NTrack(0),
12  NClusterStrip(0),
13  NClusterPixel(0),
14  NStripAPVs(0),
15  NPixelDets(0),
16  SRun(1<<31),
17  ERun(0),
18  bareTkGeomPtr_(nullptr)
19 {
20 
21  MinTrackMomentum = iConfig.getUntrackedParameter<double> ("minTrackMomentum" , 3.0);
22  MaxTrackMomentum = iConfig.getUntrackedParameter<double> ("maxTrackMomentum" , 99999.0);
23  MinTrackEta = iConfig.getUntrackedParameter<double> ("minTrackEta" , -5.0);
24  MaxTrackEta = iConfig.getUntrackedParameter<double> ("maxTrackEta" , 5.0);
25  MaxNrStrips = iConfig.getUntrackedParameter<unsigned>("maxNrStrips" , 2);
26  MinTrackHits = iConfig.getUntrackedParameter<unsigned>("MinTrackHits" , 8);
27  MaxTrackChiOverNdf = iConfig.getUntrackedParameter<double> ("MaxTrackChiOverNdf" , 3);
28  MaxTrackingIteration = iConfig.getUntrackedParameter<int> ("MaxTrackingIteration" , 7);
29  AllowSaturation = iConfig.getUntrackedParameter<bool> ("AllowSaturation" , false);
30  FirstSetOfConstants = iConfig.getUntrackedParameter<bool> ("FirstSetOfConstants" , true);
31  Validation = iConfig.getUntrackedParameter<bool> ("Validation" , false);
32  OldGainRemoving = iConfig.getUntrackedParameter<bool> ("OldGainRemoving" , false);
33  useCalibration = iConfig.getUntrackedParameter<bool> ("UseCalibration" , false);
34  doChargeMonitorPerPlane = iConfig.getUntrackedParameter<bool> ("doChargeMonitorPerPlane" , false);
35  m_DQMdir = iConfig.getUntrackedParameter<std::string> ("DQMdir" , "AlCaReco/SiStripGains");
36  m_calibrationMode = iConfig.getUntrackedParameter<std::string> ("calibrationMode" , "StdBunch");
37  VChargeHisto = iConfig.getUntrackedParameter<std::vector<std::string> > ("ChargeHisto");
38 
39  //Set the monitoring element tag and store
40  dqm_tag_.reserve(7);
41  dqm_tag_.clear();
42  dqm_tag_.push_back( "StdBunch" ); // statistic collection from Standard Collision Bunch @ 3.8 T
43  dqm_tag_.push_back( "StdBunch0T" ); // statistic collection from Standard Collision Bunch @ 0 T
44  dqm_tag_.push_back( "AagBunch" ); // statistic collection from First Collision After Abort Gap @ 3.8 T
45  dqm_tag_.push_back( "AagBunch0T" ); // statistic collection from First Collision After Abort Gap @ 0 T
46  dqm_tag_.push_back( "IsoMuon" ); // statistic collection from Isolated Muon @ 3.8 T
47  dqm_tag_.push_back( "IsoMuon0T" ); // statistic collection from Isolated Muon @ 0 T
48  dqm_tag_.push_back( "Harvest" ); // statistic collection: Harvest
49 
50  Charge_Vs_Index.insert( Charge_Vs_Index.begin(), dqm_tag_.size(), 0);
51  Charge_Vs_PathlengthTIB.insert( Charge_Vs_PathlengthTIB.begin(), dqm_tag_.size(), 0);
52  Charge_Vs_PathlengthTOB.insert( Charge_Vs_PathlengthTOB.begin(), dqm_tag_.size(), 0);
59 
60  // configure token for gathering the ntuple variables
61  edm::ParameterSet swhallowgain_pset = iConfig.getUntrackedParameter<edm::ParameterSet>("gain");
62 
63  std::string label = swhallowgain_pset.getUntrackedParameter<std::string>("label");
64  CalibPrefix_ = swhallowgain_pset.getUntrackedParameter<std::string>("prefix");
65  CalibSuffix_ = swhallowgain_pset.getUntrackedParameter<std::string>("suffix");
66 
67  trackindex_token_ = consumes<std::vector<int> >(edm::InputTag(label, CalibPrefix_ + "trackindex" + CalibSuffix_));
68  rawid_token_ = consumes<std::vector<unsigned int> >(edm::InputTag(label, CalibPrefix_ + "rawid" + CalibSuffix_));
69  localdirx_token_ = consumes<std::vector<double> >(edm::InputTag(label, CalibPrefix_ + "localdirx" + CalibSuffix_));
70  localdiry_token_ = consumes<std::vector<double> >(edm::InputTag(label, CalibPrefix_ + "localdiry" + CalibSuffix_));
71  localdirz_token_ = consumes<std::vector<double> >(edm::InputTag(label, CalibPrefix_ + "localdirz" + CalibSuffix_));
72  firststrip_token_ = consumes<std::vector<unsigned short> >(edm::InputTag(label, CalibPrefix_ + "firststrip" + CalibSuffix_));
73  nstrips_token_ = consumes<std::vector<unsigned short> >(edm::InputTag(label, CalibPrefix_ + "nstrips" + CalibSuffix_));
74  saturation_token_ = consumes<std::vector<bool> >(edm::InputTag(label, CalibPrefix_ + "saturation" + CalibSuffix_));
75  overlapping_token_ = consumes<std::vector<bool> >(edm::InputTag(label, CalibPrefix_ + "overlapping" + CalibSuffix_));
76  farfromedge_token_ = consumes<std::vector<bool> >(edm::InputTag(label, CalibPrefix_ + "farfromedge" + CalibSuffix_));
77  charge_token_ = consumes<std::vector<unsigned int> >(edm::InputTag(label, CalibPrefix_ + "charge" + CalibSuffix_));
78  path_token_ = consumes<std::vector<double> >(edm::InputTag(label, CalibPrefix_ + "path" + CalibSuffix_));
79  chargeoverpath_token_ = consumes<std::vector<double> >(edm::InputTag(label, CalibPrefix_ + "chargeoverpath"+ CalibSuffix_));
80  amplitude_token_ = consumes<std::vector<unsigned char> >(edm::InputTag(label, CalibPrefix_ + "amplitude" + CalibSuffix_));
81  gainused_token_ = consumes<std::vector<double> >(edm::InputTag(label, CalibPrefix_ + "gainused" + CalibSuffix_));
82  gainusedTick_token_ = consumes<std::vector<double> >(edm::InputTag(label, CalibPrefix_ + "gainusedTick" + CalibSuffix_));
83 
84  edm::ParameterSet evtinfo_pset = iConfig.getUntrackedParameter<edm::ParameterSet>("evtinfo");
85  label = evtinfo_pset.getUntrackedParameter<std::string>("label");
86  EventPrefix_ = evtinfo_pset.getUntrackedParameter<std::string>("prefix");
87  EventSuffix_ = evtinfo_pset.getUntrackedParameter<std::string>("suffix");
88  TrigTech_token_ = consumes<std::vector<bool> >(edm::InputTag(label, EventPrefix_ + "TrigTech" + EventSuffix_));
89 
90  edm::ParameterSet track_pset = iConfig.getUntrackedParameter<edm::ParameterSet>("tracks");
91  label = track_pset.getUntrackedParameter<std::string>("label");
92  TrackPrefix_ = track_pset.getUntrackedParameter<std::string>("prefix");
93  TrackSuffix_ = track_pset.getUntrackedParameter<std::string>("suffix");
94 
95  trackchi2ndof_token_ = consumes<std::vector<double> >(edm::InputTag(label, TrackPrefix_ + "chi2ndof" + TrackSuffix_));
96  trackp_token_ = consumes<std::vector<float> >(edm::InputTag(label, TrackPrefix_ + "momentum" + TrackSuffix_));
97  trackpt_token_ = consumes<std::vector<float> >(edm::InputTag(label, TrackPrefix_ + "pt" + TrackSuffix_));
98  tracketa_token_ = consumes<std::vector<double> >(edm::InputTag(label, TrackPrefix_ + "eta" + TrackSuffix_));
99  trackphi_token_ = consumes<std::vector<double> >(edm::InputTag(label, TrackPrefix_ + "phi" + TrackSuffix_));
100  trackhitsvalid_token_ = consumes<std::vector<unsigned int> >(edm::InputTag(label, TrackPrefix_ + "hitsvalid" + TrackSuffix_));
101  trackalgo_token_ = consumes<std::vector<int> >(edm::InputTag(label, TrackPrefix_ + "algo" + TrackSuffix_));
102 
103 }
104 
105 //********************************************************************************//
106 void
108 
109  using namespace edm;
110 
111  this->checkBookAPVColls(iSetup); // check whether APV colls are booked and do so if not yet done
112 
113  edm::ESHandle<SiStripGain> gainHandle;
114  iSetup.get<SiStripGainRcd>().get(gainHandle);
115  if(!gainHandle.isValid()){edm::LogError("SiStripGainPCLWorker")<< "gainHandle is not valid\n"; exit(0);}
116 
117  edm::ESHandle<SiStripQuality> SiStripQuality_;
118  iSetup.get<SiStripQualityRcd>().get(SiStripQuality_);
119 
120  for(unsigned int a=0;a<APVsCollOrdered.size();a++){
121 
122  std::shared_ptr<stAPVGain> APV = APVsCollOrdered[a];
123 
124  if(APV->SubDet==PixelSubdetector::PixelBarrel || APV->SubDet==PixelSubdetector::PixelEndcap) continue;
125 
126  APV->isMasked = SiStripQuality_->IsApvBad(APV->DetId,APV->APVId);
127 
128  if(gainHandle->getNumberOfTags()!=2){edm::LogError("SiStripGainPCLWorker")<< "NUMBER OF GAIN TAG IS EXPECTED TO BE 2\n";fflush(stdout);exit(0);};
129  float newPreviousGain = gainHandle->getApvGain(APV->APVId,gainHandle->getRange(APV->DetId, 1),1);
130  if(APV->PreviousGain!=1 and newPreviousGain!=APV->PreviousGain)edm::LogWarning("SiStripGainPCLWorker")<< "WARNING: ParticleGain in the global tag changed\n";
131  APV->PreviousGain = newPreviousGain;
132 
133  float newPreviousGainTick = gainHandle->getApvGain(APV->APVId,gainHandle->getRange(APV->DetId, 0),0);
134  if(APV->PreviousGainTick!=1 and newPreviousGainTick!=APV->PreviousGainTick){
135  edm::LogWarning("SiStripGainPCLWorker")<< "WARNING: TickMarkGain in the global tag changed\n"<< std::endl
136  <<" APV->SubDet: "<< APV->SubDet << " APV->APVId:" << APV->APVId << std::endl
137  <<" APV->PreviousGainTick: "<<APV->PreviousGainTick<<" newPreviousGainTick: "<<newPreviousGainTick<<std::endl;
138  }
139  APV->PreviousGainTick = newPreviousGainTick;
140  }
141 
142 }
143 
144 //********************************************************************************//
145 // ------------ method called for each event ------------
146 void
148 {
149  using namespace edm;
150 
151  // this->checkBookAPVColls(iSetup); // check whether APV colls are booked and do so if not yet done
152 
153  eventnumber = iEvent.id().event();
154  runnumber = iEvent.id().run();
155 
156  auto handle01 = connect(TrigTech , TrigTech_token_ , iEvent);
157  auto handle02 = connect(trackchi2ndof , trackchi2ndof_token_ , iEvent);
158  auto handle03 = connect(trackp , trackp_token_ , iEvent);
159  auto handle04 = connect(trackpt , trackpt_token_ , iEvent);
160  auto handle05 = connect(tracketa , tracketa_token_ , iEvent);
161  auto handle06 = connect(trackphi , trackphi_token_ , iEvent);
162  auto handle07 = connect(trackhitsvalid, trackhitsvalid_token_, iEvent);
163  auto handle08 = connect(trackindex , trackindex_token_ , iEvent);
164  auto handle09 = connect(rawid , rawid_token_ , iEvent);
165  auto handle11 = connect(localdirx , localdirx_token_ , iEvent);
166  auto handle12 = connect(localdiry , localdiry_token_ , iEvent);
167  auto handle13 = connect(localdirz , localdirz_token_ , iEvent);
168  auto handle14 = connect(firststrip , firststrip_token_ , iEvent);
169  auto handle15 = connect(nstrips , nstrips_token_ , iEvent);
170  auto handle16 = connect(saturation , saturation_token_ , iEvent);
171  auto handle17 = connect(overlapping , overlapping_token_ , iEvent);
172  auto handle18 = connect(farfromedge , farfromedge_token_ , iEvent);
173  auto handle19 = connect(charge , charge_token_ , iEvent);
174  auto handle21 = connect(path , path_token_ , iEvent);
175  auto handle22 = connect(chargeoverpath, chargeoverpath_token_, iEvent);
176  auto handle23 = connect(amplitude , amplitude_token_ , iEvent);
177  auto handle24 = connect(gainused , gainused_token_ , iEvent);
178  auto handle25 = connect(gainusedTick , gainusedTick_token_ , iEvent);
179  auto handle26 = connect(trackalgo , trackalgo_token_ , iEvent);
180 
182  iSetup.get<TrackerTopologyRcd>().get( TopoHandle );
183  const TrackerTopology* topo = TopoHandle.product();
184 
185  processEvent(topo);
186 
187 }
188 
189 //********************************************************************************//
191 
192  edm::LogInfo("SiStripGainsPCLWorker") << "Processing run " << runnumber
193  << " and event " << eventnumber
194  << std::endl;
195 
198 
199  NEvent++;
200  NTrack+=(*trackp).size();
201 
202  edm::LogInfo("SiStripGainsPCLWorker")
203  <<"for mode"<< m_calibrationMode
204  <<" Nevent:"<<NEvent
205  <<" NTrack:"<<NTrack
206  <<" NClusterStrip:"<<NClusterStrip
207  <<" NClusterPixel:"<<NClusterPixel
208  <<" NStripAPVs:"<<NStripAPVs
209  <<" NPixelDets:"<<NPixelDets
210  <<std::endl;
211 
212  int elepos = statCollectionFromMode(m_calibrationMode.c_str());
213 
214  unsigned int FirstAmplitude=0;
215  for(unsigned int i=0;i<(*chargeoverpath).size();i++){
216 
217  FirstAmplitude+=(*nstrips)[i];
218  int TI = (*trackindex)[i];
219 
220  if((*tracketa )[TI] < MinTrackEta )continue;
221  if((*tracketa )[TI] > MaxTrackEta )continue;
222  if((*trackp )[TI] < MinTrackMomentum )continue;
223  if((*trackp )[TI] > MaxTrackMomentum )continue;
224  if((*trackhitsvalid)[TI] < MinTrackHits )continue;
225  if((*trackchi2ndof )[TI] > MaxTrackChiOverNdf )continue;
226  if((*trackalgo )[TI] > MaxTrackingIteration )continue;
227 
228  std::shared_ptr<stAPVGain> APV = APVsColl[((*rawid)[i]<<4) | ((*firststrip)[i]/128)]; //works for both strip and pixel thanks to firstStrip encoding for pixel in the calibTree
229 
230  if(APV->SubDet>2 && (*farfromedge)[i] == false )continue;
231  if(APV->SubDet>2 && (*overlapping)[i] == true )continue;
232  if(APV->SubDet>2 && (*saturation )[i] && !AllowSaturation)continue;
233  if(APV->SubDet>2 && (*nstrips )[i] > MaxNrStrips )continue;
234 
235  if(APV->SubDet>2){
236  NClusterStrip++;
237  } else {
238  NClusterPixel++;
239  }
240 
241  int Charge = 0;
242  if(APV->SubDet>2 && (useCalibration || !FirstSetOfConstants)){
243  bool Saturation = false;
244  for(unsigned int s=0;s<(*nstrips)[i];s++){
245  int StripCharge = (*amplitude)[FirstAmplitude-(*nstrips)[i]+s];
246  if(useCalibration && !FirstSetOfConstants){ StripCharge=(int)(StripCharge*(APV->PreviousGain/APV->CalibGain));
247  }else if(useCalibration){ StripCharge=(int)(StripCharge/APV->CalibGain);
248  }else if(!FirstSetOfConstants){ StripCharge=(int)(StripCharge*APV->PreviousGain);}
249  if(StripCharge>1024){
250  StripCharge = 255;
251  Saturation = true;
252  }else if(StripCharge>254){
253  StripCharge = 254;
254  Saturation = true;
255  }
256  Charge += StripCharge;
257  }
258  if(Saturation && !AllowSaturation)continue;
259  }else if(APV->SubDet>2){
260  Charge = (*charge)[i];
261  }else{
262  Charge = (*charge)[i]/265.0; //expected scale factor between pixel and strip charge
263  }
264 
265  double ClusterChargeOverPath = ( (double) Charge )/(*path)[i] ;
266  if(APV->SubDet>2){
267  if(Validation) {ClusterChargeOverPath/=(*gainused)[i];}
268  if(OldGainRemoving){ClusterChargeOverPath*=(*gainused)[i];}
269  }
270 
271  // real histogram for calibration
272  (Charge_Vs_Index[elepos])->Fill(APV->Index,ClusterChargeOverPath);
273 
274  LogDebug("SiStripGainsPCLWorker") <<" for mode "<< m_calibrationMode << "\n"
275  <<" i "<< i
276  <<" NClusterStrip "<< NClusterStrip
277  <<" useCalibration "<< useCalibration
278  <<" FirstSetOfConstants "<< FirstSetOfConstants
279  <<" APV->DetId "<< APV->DetId
280  <<" APV->Index "<< APV->Index
281  <<" Charge "<< Charge
282  <<" ClusterChargeOverPath "<< ClusterChargeOverPath
283  <<std::endl;
284 
285  // Fill monitoring histograms
286  int mCharge1 = 0;
287  int mCharge2 = 0;
288  int mCharge3 = 0;
289  int mCharge4 = 0;
290  if(APV->SubDet>2) {
291  for(unsigned int s=0;s<(*nstrips)[i];s++){
292  int StripCharge = (*amplitude)[FirstAmplitude-(*nstrips)[i]+s];
293  if(StripCharge>1024) StripCharge = 255;
294  else if(StripCharge>254) StripCharge = 254;
295  mCharge1 += StripCharge;
296  mCharge2 += StripCharge;
297  mCharge3 += StripCharge;
298  mCharge4 += StripCharge;
299  }
300  // Revome gains for monitoring
301  mCharge2 *= (*gainused)[i]; // remove G2
302  mCharge3 *= (*gainusedTick)[i]; // remove G1
303  mCharge4 *= ( (*gainused)[i] * (*gainusedTick)[i]); // remove G1 and G2
304  }
305  std::vector<APVGain::APVmon>& v1 = Charge_1[elepos];
306  std::vector<MonitorElement*> cmon1 = APVGain::FetchMonitor(v1, (*rawid)[i], topo);
307  for(unsigned int m=0; m<cmon1.size(); m++) cmon1[m]->Fill(( (double) mCharge1 )/(*path)[i]);
308 
309  std::vector<APVGain::APVmon>& v2 = Charge_2[elepos];
310  std::vector<MonitorElement*> cmon2 = APVGain::FetchMonitor(v2, (*rawid)[i], topo);
311  for(unsigned int m=0; m<cmon2.size(); m++) cmon2[m]->Fill(( (double) mCharge2 )/(*path)[i]);
312 
313  std::vector<APVGain::APVmon>& v3 = Charge_3[elepos];
314  std::vector<MonitorElement*> cmon3 = APVGain::FetchMonitor(v3, (*rawid)[i], topo);
315  for(unsigned int m=0; m<cmon3.size(); m++) cmon3[m]->Fill(( (double) mCharge3 )/(*path)[i]);
316 
317  std::vector<APVGain::APVmon>& v4 = Charge_4[elepos];
318  std::vector<MonitorElement*> cmon4 = APVGain::FetchMonitor(v4, (*rawid)[i], topo);
319  for(unsigned int m=0; m<cmon4.size(); m++) cmon4[m]->Fill(( (double) mCharge4 )/(*path)[i]);
320 
321 
322  if(APV->SubDet==StripSubdetector::TIB){
323  (Charge_Vs_PathlengthTIB[elepos])->Fill((*path)[i],Charge); // TIB
324 
325  }else if(APV->SubDet==StripSubdetector::TOB){
326  (Charge_Vs_PathlengthTOB[elepos])->Fill((*path)[i],Charge); // TOB
327 
328  }else if(APV->SubDet==StripSubdetector::TID){
329  if(APV->Eta<0) { (Charge_Vs_PathlengthTIDM[elepos])->Fill((*path)[i],Charge); } // TID minus
330  else if(APV->Eta>0){ (Charge_Vs_PathlengthTIDP[elepos])->Fill((*path)[i],Charge); } // TID plus
331 
332  }else if(APV->SubDet==StripSubdetector::TEC){
333  if(APV->Eta<0){
334  if(APV->Thickness<0.04) { (Charge_Vs_PathlengthTECM1[elepos])->Fill((*path)[i],Charge); } // TEC minus, type 1
335  else if(APV->Thickness>0.04){ (Charge_Vs_PathlengthTECM2[elepos])->Fill((*path)[i],Charge); } // TEC minus, type 2
336  } else if(APV->Eta>0){
337  if(APV->Thickness<0.04) { (Charge_Vs_PathlengthTECP1[elepos])->Fill((*path)[i],Charge); } // TEC plus, type 1
338  else if(APV->Thickness>0.04){ (Charge_Vs_PathlengthTECP2[elepos])->Fill((*path)[i],Charge); } // TEC plus, type 2
339  }
340  }
341 
342  }// END OF ON-CLUSTER LOOP
343 
344  LogDebug("SiStripGainsPCLWorker")<<" for mode"<< m_calibrationMode
345  <<" entries in histogram:"<< (Charge_Vs_Index[elepos])->getTH2S()->GetEntries()
346  <<std::endl;
347 
348 }//END OF processEvent()
349 
350 
351 //********************************************************************************//
352 void
354 {
355 }
356 
357 //********************************************************************************//
358 // ------------ method called once each job just before starting event loop ------------
359 void
361 
363  const TrackerGeometry *newBareTkGeomPtr = &(*tkGeom_);
364  if (newBareTkGeomPtr == bareTkGeomPtr_) return; // already filled APVColls, nothing changed
365 
366  if (!bareTkGeomPtr_) { // pointer not yet set: called the first time => fill the APVColls
367  auto const & Det = newBareTkGeomPtr->dets();
368 
369  edm::LogInfo("SiStripGainsPCLWorker")
370  <<" Resetting APV struct"<<std::endl;
371 
372  unsigned int Index=0;
373 
374  for(unsigned int i=0;i<Det.size();i++){
375 
376  DetId Detid = Det[i]->geographicalId();
377  int SubDet = Detid.subdetId();
378 
379  if( SubDet == StripSubdetector::TIB || SubDet == StripSubdetector::TID ||
380  SubDet == StripSubdetector::TOB || SubDet == StripSubdetector::TEC ){
381 
382  auto DetUnit = dynamic_cast<const StripGeomDetUnit*> (Det[i]);
383  if(!DetUnit)continue;
384 
385  const StripTopology& Topo = DetUnit->specificTopology();
386  unsigned int NAPV = Topo.nstrips()/128;
387 
388  for(unsigned int j=0;j<NAPV;j++){
389  auto APV = std::make_shared<stAPVGain>();
390  APV->Index = Index;
391  APV->Bin = -1;
392  APV->DetId = Detid.rawId();
393  APV->APVId = j;
394  APV->SubDet = SubDet;
395  APV->FitMPV = -1;
396  APV->FitMPVErr = -1;
397  APV->FitWidth = -1;
398  APV->FitWidthErr = -1;
399  APV->FitChi2 = -1;
400  APV->FitNorm = -1;
401  APV->Gain = -1;
402  APV->PreviousGain = 1;
403  APV->PreviousGainTick = 1;
404  APV->x = DetUnit->position().basicVector().x();
405  APV->y = DetUnit->position().basicVector().y();
406  APV->z = DetUnit->position().basicVector().z();
407  APV->Eta = DetUnit->position().basicVector().eta();
408  APV->Phi = DetUnit->position().basicVector().phi();
409  APV->R = DetUnit->position().basicVector().transverse();
410  APV->Thickness = DetUnit->surface().bounds().thickness();
411  APV->NEntries = 0;
412  APV->isMasked = false;
413 
414  APVsCollOrdered.push_back(APV);
415  APVsColl[(APV->DetId<<4) | APV->APVId] = APV;
416  Index++;
417  NStripAPVs++;
418  } // loop on APVs
419  } // if is Strips
420  } // loop on dets
421 
422  for(unsigned int i=0;i<Det.size();i++){ //Make two loop such that the Pixel information is added at the end --> make transition simpler
423  DetId Detid = Det[i]->geographicalId();
424  int SubDet = Detid.subdetId();
426  auto DetUnit = dynamic_cast<const PixelGeomDetUnit*> (Det[i]);
427  if(!DetUnit) continue;
428 
429  const PixelTopology& Topo = DetUnit->specificTopology();
430  unsigned int NROCRow = Topo.nrows()/(80.);
431  unsigned int NROCCol = Topo.ncolumns()/(52.);
432 
433  for(unsigned int j=0;j<NROCRow;j++){
434  for(unsigned int i=0;i<NROCCol;i++){
435 
436  auto APV = std::make_shared<stAPVGain>();
437  APV->Index = Index;
438  APV->Bin = -1;
439  APV->DetId = Detid.rawId();
440  APV->APVId = (j<<3 | i);
441  APV->SubDet = SubDet;
442  APV->FitMPV = -1;
443  APV->FitMPVErr = -1;
444  APV->FitWidth = -1;
445  APV->FitWidthErr = -1;
446  APV->FitChi2 = -1;
447  APV->Gain = -1;
448  APV->PreviousGain = 1;
449  APV->PreviousGainTick = 1;
450  APV->x = DetUnit->position().basicVector().x();
451  APV->y = DetUnit->position().basicVector().y();
452  APV->z = DetUnit->position().basicVector().z();
453  APV->Eta = DetUnit->position().basicVector().eta();
454  APV->Phi = DetUnit->position().basicVector().phi();
455  APV->R = DetUnit->position().basicVector().transverse();
456  APV->Thickness = DetUnit->surface().bounds().thickness();
457  APV->isMasked = false; //SiPixelQuality_->IsModuleBad(Detid.rawId());
458  APV->NEntries = 0;
459 
460  APVsCollOrdered.push_back(APV);
461  APVsColl[(APV->DetId<<4) | APV->APVId] = APV;
462  Index++;
463  NPixelDets++;
464 
465  } // loop on ROC cols
466  } // loop on ROC rows
467  } // if Pixel
468  } // loop on Dets
469  } //if (!bareTkGeomPtr_) ...
470  bareTkGeomPtr_ = newBareTkGeomPtr;
471 }
472 
473 
474 //********************************************************************************//
475 void
477 {
478 }
479 
480 //********************************************************************************//
481 void
484  desc.setUnknown();
485  descriptions.addDefault(desc);
486 }
487 
488 //********************************************************************************//
489 void
491 
492  ibooker.cd();
493  std::string dqm_dir = m_DQMdir;
494  const char* tag = dqm_tag_[statCollectionFromMode(m_calibrationMode.c_str())].c_str();
495 
496  edm::LogInfo("SiStripGainsPCLWorker") << "Setting " << dqm_dir << "in DQM and booking histograms for tag "
497  << tag << std::endl;
498 
499  ibooker.setCurrentFolder(dqm_dir);
500 
501  std::string stag(tag);
502  if(stag.size()!=0 && stag[0]!='_') stag.insert(0,1,'_');
503 
504  std::string cvi = std::string("Charge_Vs_Index") + stag;
505  std::string cvpTIB = std::string("Charge_Vs_PathlengthTIB") + stag;
506  std::string cvpTOB = std::string("Charge_Vs_PathlengthTOB") + stag;
507  std::string cvpTIDP = std::string("Charge_Vs_PathlengthTIDP") + stag;
508  std::string cvpTIDM = std::string("Charge_Vs_PathlengthTIDM") + stag;
509  std::string cvpTECP1 = std::string("Charge_Vs_PathlengthTECP1") + stag;
510  std::string cvpTECP2 = std::string("Charge_Vs_PathlengthTECP2") + stag;
511  std::string cvpTECM1 = std::string("Charge_Vs_PathlengthTECM1") + stag;
512  std::string cvpTECM2 = std::string("Charge_Vs_PathlengthTECM2") + stag;
513 
514  int elepos = statCollectionFromMode(tag);
515 
516  Charge_Vs_Index[elepos] = ibooker.book2S(cvi.c_str() , cvi.c_str() , 88625, 0 , 88624,2000,0,4000);
517  Charge_Vs_PathlengthTIB[elepos] = ibooker.book2S(cvpTIB.c_str() , cvpTIB.c_str() , 20 , 0.3 , 1.3 , 250,0,2000);
518  Charge_Vs_PathlengthTOB[elepos] = ibooker.book2S(cvpTOB.c_str() , cvpTOB.c_str() , 20 , 0.3 , 1.3 , 250,0,2000);
519  Charge_Vs_PathlengthTIDP[elepos] = ibooker.book2S(cvpTIDP.c_str() , cvpTIDP.c_str() , 20 , 0.3 , 1.3 , 250,0,2000);
520  Charge_Vs_PathlengthTIDM[elepos] = ibooker.book2S(cvpTIDM.c_str() , cvpTIDM.c_str() , 20 , 0.3 , 1.3 , 250,0,2000);
521  Charge_Vs_PathlengthTECP1[elepos] = ibooker.book2S(cvpTECP1.c_str(), cvpTECP1.c_str(), 20 , 0.3 , 1.3 , 250,0,2000);
522  Charge_Vs_PathlengthTECP2[elepos] = ibooker.book2S(cvpTECP2.c_str(), cvpTECP2.c_str(), 20 , 0.3 , 1.3 , 250,0,2000);
523  Charge_Vs_PathlengthTECM1[elepos] = ibooker.book2S(cvpTECM1.c_str(), cvpTECM1.c_str(), 20 , 0.3 , 1.3 , 250,0,2000);
524  Charge_Vs_PathlengthTECM2[elepos] = ibooker.book2S(cvpTECM2.c_str(), cvpTECM2.c_str(), 20 , 0.3 , 1.3 , 250,0,2000);
525 
526  std::vector<std::pair<std::string,std::string>> hnames = APVGain::monHnames(VChargeHisto,doChargeMonitorPerPlane,"");
527  for (unsigned int i=0;i<hnames.size();i++){
528  std::string htag = (hnames[i]).first + stag;
529  MonitorElement* monitor = ibooker.book1DD( htag.c_str(), (hnames[i]).second.c_str(), 100 , 0. , 1000. );
530  int id = APVGain::subdetectorId((hnames[i]).first);
531  int side = APVGain::subdetectorSide((hnames[i]).first);
532  int plane = APVGain::subdetectorPlane((hnames[i]).first);
533  Charge_1[elepos].push_back( APVGain::APVmon(id,side,plane,monitor) );
534  }
535 
537  for (unsigned int i=0;i<hnames.size();i++){
538  std::string htag = (hnames[i]).first + stag;
539  MonitorElement* monitor = ibooker.book1DD( htag.c_str(), (hnames[i]).second.c_str(), 100 , 0. , 1000. );
540  int id = APVGain::subdetectorId((hnames[i]).first);
541  int side = APVGain::subdetectorSide((hnames[i]).first);
542  int plane = APVGain::subdetectorPlane((hnames[i]).first);
543  Charge_2[elepos].push_back( APVGain::APVmon(id,side,plane,monitor) );
544  }
545 
547  for (unsigned int i=0;i<hnames.size();i++){
548  std::string htag = (hnames[i]).first + stag;
549  MonitorElement* monitor = ibooker.book1DD( htag.c_str(), (hnames[i]).second.c_str(), 100 , 0. , 1000. );
550  int id = APVGain::subdetectorId((hnames[i]).first);
551  int side = APVGain::subdetectorSide((hnames[i]).first);
552  int plane = APVGain::subdetectorPlane((hnames[i]).first);
553  Charge_3[elepos].push_back( APVGain::APVmon(id,side,plane,monitor) );
554  }
555 
557  for (unsigned int i=0;i<hnames.size();i++){
558  std::string htag = (hnames[i]).first + stag;
559  MonitorElement* monitor = ibooker.book1DD( htag.c_str(), (hnames[i]).second.c_str(), 100 , 0. , 1000. );
560  int id = APVGain::subdetectorId((hnames[i]).first);
561  int side = APVGain::subdetectorSide((hnames[i]).first);
562  int plane = APVGain::subdetectorPlane((hnames[i]).first);
563  Charge_4[elepos].push_back( APVGain::APVmon(id,side,plane,monitor) );
564  }
565 
566 }
#define LogDebug(id)
RunNumber_t run() const
Definition: EventID.h:39
std::vector< MonitorElement * > Charge_Vs_PathlengthTOB
const std::vector< double > * chargeoverpath
bool IsApvBad(const uint32_t &detid, const short &apvNb) const
edm::EDGetTokenT< std::vector< double > > gainused_token_
EventNumber_t event() const
Definition: EventID.h:41
T getUntrackedParameter(std::string const &, T const &) const
const std::vector< int > * trackalgo
virtual int nrows() const =0
edm::EDGetTokenT< std::vector< double > > localdirz_token_
edm::EDGetTokenT< std::vector< bool > > saturation_token_
std::array< std::vector< APVGain::APVmon >, 7 > Charge_1
edm::EDGetTokenT< std::vector< double > > trackchi2ndof_token_
edm::EDGetTokenT< std::vector< double > > gainusedTick_token_
virtual void checkBookAPVColls(const edm::EventSetup &setup)
size_t getNumberOfTags() const
Definition: SiStripGain.h:87
void cd(void)
Definition: DQMStore.cc:269
edm::EDGetTokenT< std::vector< float > > trackp_token_
SiStripGainsPCLWorker(const edm::ParameterSet &)
const TrackerGeometry * bareTkGeomPtr_
virtual void analyze(const edm::Event &, const edm::EventSetup &)
const std::vector< bool > * TrigTech
int subdetectorPlane(uint32_t, const TrackerTopology *)
virtual void dqmBeginRun(edm::Run const &, edm::EventSetup const &)
const std::vector< int > * trackindex
const std::vector< float > * trackpt
const std::vector< unsigned int > * rawid
std::vector< std::shared_ptr< stAPVGain > > APVsCollOrdered
#define nullptr
const std::vector< unsigned int > * charge
const std::vector< double > * path
const std::vector< bool > * farfromedge
edm::EDGetTokenT< std::vector< unsigned int > > trackhitsvalid_token_
edm::EDGetTokenT< std::vector< unsigned short > > firststrip_token_
edm::EDGetTokenT< std::vector< bool > > farfromedge_token_
edm::EDGetTokenT< std::vector< bool > > overlapping_token_
static float getApvGain(const uint16_t &apv, const SiStripApvGain::Range &range)
Definition: SiStripGain.h:69
const std::vector< double > * gainusedTick
std::vector< std::string > dqm_tag_
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
U second(std::pair< T, U > const &p)
edm::EDGetTokenT< std::vector< unsigned short > > nstrips_token_
const std::vector< double > * tracketa
edm::EDGetTokenT< std::vector< double > > tracketa_token_
std::vector< MonitorElement * > FetchMonitor(std::vector< APVmon >, uint32_t, const TrackerTopology *topo=0)
const DetContainer & dets() const override
Returm a vector of all GeomDet (including all GeomDetUnits)
int iEvent
Definition: GenABIO.cc:230
const std::vector< double > * localdiry
void addDefault(ParameterSetDescription const &psetDescription)
const std::vector< float > * trackp
const std::vector< bool > * saturation
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
edm::ESHandle< TrackerGeometry > tkGeom_
std::unordered_map< unsigned int, std::shared_ptr< stAPVGain > > APVsColl
MonitorElement * book2S(Args &&...args)
Definition: DQMStore.h:139
const std::vector< double > * localdirz
const std::vector< double > * trackphi
std::vector< MonitorElement * > Charge_Vs_PathlengthTIB
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
std::array< std::vector< APVGain::APVmon >, 7 > Charge_4
const std::vector< bool > * overlapping
edm::EDGetTokenT< std::vector< int > > trackindex_token_
const std::vector< double > * localdirx
edm::EDGetTokenT< std::vector< double > > localdirx_token_
edm::EDGetTokenT< std::vector< unsigned int > > charge_token_
std::vector< MonitorElement * > Charge_Vs_PathlengthTECP1
edm::EDGetTokenT< std::vector< double > > trackphi_token_
const std::vector< unsigned short > * firststrip
const std::vector< unsigned int > * trackhitsvalid
Definition: DetId.h:18
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:277
std::vector< MonitorElement * > Charge_Vs_PathlengthTECM2
edm::EDGetTokenT< std::vector< float > > trackpt_token_
virtual int nstrips() const =0
const T & get() const
Definition: EventSetup.h:55
std::array< std::vector< APVGain::APVmon >, 7 > Charge_2
int subdetectorSide(uint32_t, const TrackerTopology *)
edm::Handle< T > connect(const T *&ptr, edm::EDGetTokenT< T > token, const edm::Event &evt)
std::vector< std::string > VChargeHisto
edm::EDGetTokenT< std::vector< double > > path_token_
edm::EventID id() const
Definition: EventBase.h:60
HLT enums.
virtual int ncolumns() const =0
std::vector< MonitorElement * > Charge_Vs_PathlengthTECM1
double a
Definition: hdecay.h:121
const std::vector< unsigned char > * amplitude
std::array< std::vector< APVGain::APVmon >, 7 > Charge_3
void processEvent(const TrackerTopology *topo)
int statCollectionFromMode(const char *tag) const
edm::EDGetTokenT< std::vector< double > > chargeoverpath_token_
const std::vector< double > * trackchi2ndof
edm::EDGetTokenT< std::vector< int > > trackalgo_token_
std::vector< MonitorElement * > Charge_Vs_PathlengthTECP2
edm::EDGetTokenT< std::vector< double > > localdiry_token_
std::vector< std::pair< std::string, std::string > > monHnames(std::vector< std::string >, bool, const char *tag)
bool isValid() const
Definition: ESHandle.h:47
std::vector< MonitorElement * > Charge_Vs_PathlengthTIDP
edm::EDGetTokenT< std::vector< unsigned char > > amplitude_token_
const std::vector< unsigned short > * nstrips
MonitorElement * book1DD(Args &&...args)
Definition: DQMStore.h:127
T const * product() const
Definition: ESHandle.h:86
virtual void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &)
std::vector< MonitorElement * > Charge_Vs_PathlengthTIDM
int subdetectorId(uint32_t)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: Run.h:42
const std::vector< double > * gainused
edm::EDGetTokenT< std::vector< unsigned int > > rawid_token_
std::vector< MonitorElement * > Charge_Vs_Index
const SiStripApvGain::Range getRange(uint32_t detID) const
Definition: SiStripGain.h:66
edm::EDGetTokenT< std::vector< bool > > TrigTech_token_