CMS 3D CMS Logo

SiStripGainFromCalibTree.cc
Go to the documentation of this file.
1 // Original Author: Loic QUERTENMONT
2 // Created: Mon Nov 16 08:55:18 CET 2009
3 
4 #include <memory>
5 #include <iostream>
6 
16 
18 
24 
32 
34 
37 
51 
54 
57 
61 
64 
67 
68 
69 #include "TFile.h"
70 #include "TObjString.h"
71 #include "TString.h"
72 #include "TH1F.h"
73 #include "TH2S.h"
74 #include "TProfile.h"
75 #include "TF1.h"
76 #include "TROOT.h"
77 #include "TTree.h"
78 #include "TChain.h"
79 
80 // user includes
83 
84 #include <unordered_map>
85 
86 
87 
88 using namespace edm;
89 using namespace reco;
90 using namespace std;
91 using namespace APVGain;
92 
93 class SiStripGainFromCalibTree : public ConditionDBWriter<SiStripApvGain> {
94 public:
97 
98 
99 private:
100 
101 
102  virtual void algoBeginRun(const edm::Run& run, const edm::EventSetup& iSetup) override;
103  virtual void algoEndRun (const edm::Run& run, const edm::EventSetup& iSetup) override;
104  virtual void algoBeginJob (const edm::EventSetup& iSetup) override;
105  virtual void algoEndJob () override;
106  virtual void algoAnalyze (const edm::Event &, const edm::EventSetup &) override;
107 
108  int statCollectionFromMode(const char* tag) const;
109  void bookDQMHistos(const char* dqm_dir, const char* tag);
110 
111  bool isBFieldConsistentWithMode( const edm::EventSetup& iSetup) const;
112  void swapBFieldMode(void);
113 
114  void merge(TH2* A, TH2* B); //needed to add histograms with different number of bins
115  void algoAnalyzeTheTree();
116  void algoComputeMPVandGain();
117  void processEvent(); //what really does the job
118 
119  void getPeakOfLandau(TH1* InputHisto, double* FitResults, double LowRange=50, double HighRange=5400);
120  bool IsGoodLandauFit(double* FitResults);
121  void storeOnTree(TFileService* tfs);
122  void qualityMonitor();
123  void MakeCalibrationMap();
124  bool produceTagFilter();
125 
126  template<typename T>
127  inline edm::Handle<T> connect(const T* &ptr, edm::EDGetTokenT<T> token, const edm::Event &evt) {
129  evt.getByToken(token, handle);
130  ptr = handle.product();
131  return handle; //return handle to keep alive pointer (safety first)
132  }
133 
134  SiStripApvGain* getNewObject() override;
135 
139  double MinNrEntries;
140  double MaxMPVError;
144  double MinTrackEta;
145  double MaxTrackEta;
146  unsigned int MaxNrStrips;
147  unsigned int MinTrackHits;
155 
164  std::vector<std::string> VChargeHisto;
168 
171  vector<string> VInputFiles;
172 
173  //enum statistic_type {None=-1, StdBunch, StdBunch0T, FaABunch, FaABunch0T, IsoBunch, IsoBunch0T, Harvest};
174 
175  std::vector<string> dqm_tag_;
177 
178  std::vector<MonitorElement*> Charge_Vs_Index;
179  std::array< std::vector<APVGain::APVmon>,7 > Charge_1;
180  std::array< std::vector<APVGain::APVmon>,7 > Charge_2;
181  std::array< std::vector<APVGain::APVmon>,7 > Charge_3;
182  std::array< std::vector<APVGain::APVmon>,7 > Charge_4;
184  std::vector<MonitorElement*> Charge_Vs_PathlengthTIB;
185  std::vector<MonitorElement*> Charge_Vs_PathlengthTOB;
186  std::vector<MonitorElement*> Charge_Vs_PathlengthTIDP;
187  std::vector<MonitorElement*> Charge_Vs_PathlengthTIDM;
188  std::vector<MonitorElement*> Charge_Vs_PathlengthTECP1;
189  std::vector<MonitorElement*> Charge_Vs_PathlengthTECP2;
190  std::vector<MonitorElement*> Charge_Vs_PathlengthTECM1;
191  std::vector<MonitorElement*> Charge_Vs_PathlengthTECM2;
194  //std::vector<MonitorElement*> Charge_Vs_Index_Absolute;
195 
196  //Validation histograms
248  std::vector<APVGain::APVmon> newCharge;
249 
250 
251  unsigned int NEvent;
252  unsigned int NTrack;
253  unsigned int NClusterStrip;
254  unsigned int NClusterPixel;
257  unsigned int SRun;
258  unsigned int ERun;
259  unsigned int GOOD;
260  unsigned int BAD;
261  unsigned int MASKED;
262 
263  //Data members for processing
264 
265  //Event data
266  unsigned int eventnumber =0;
267  unsigned int runnumber =0;
268  const std::vector<bool>* TrigTech =0; edm::EDGetTokenT<std::vector<bool> > TrigTech_token_;
269 
270  // Track data
271  const std::vector<double>* trackchi2ndof =0; edm::EDGetTokenT<std::vector<double> > trackchi2ndof_token_;
272  const std::vector<float>* trackp =0; edm::EDGetTokenT<std::vector<float> > trackp_token_;
273  const std::vector<float>* trackpt =0; edm::EDGetTokenT<std::vector<float> > trackpt_token_;
274  const std::vector<double>* tracketa =0; edm::EDGetTokenT<std::vector<double> > tracketa_token_;
275  const std::vector<double>* trackphi =0; edm::EDGetTokenT<std::vector<double> > trackphi_token_;
276  const std::vector<unsigned int>* trackhitsvalid =0; edm::EDGetTokenT<std::vector<unsigned int> > trackhitsvalid_token_;
277  const std::vector<int>* trackalgo =0; edm::EDGetTokenT<std::vector<int> > trackalgo_token_;
278 
279  // CalibTree data
280  const std::vector<int>* trackindex =0; edm::EDGetTokenT<std::vector<int> > trackindex_token_;
281  const std::vector<unsigned int>* rawid =0; edm::EDGetTokenT<std::vector<unsigned int> > rawid_token_;
282  const std::vector<double>* localdirx =0; edm::EDGetTokenT<std::vector<double> > localdirx_token_;
283  const std::vector<double>* localdiry =0; edm::EDGetTokenT<std::vector<double> > localdiry_token_;
284  const std::vector<double>* localdirz =0; edm::EDGetTokenT<std::vector<double> > localdirz_token_;
285  const std::vector<unsigned short>* firststrip =0; edm::EDGetTokenT<std::vector<unsigned short> > firststrip_token_;
286  const std::vector<unsigned short>* nstrips =0; edm::EDGetTokenT<std::vector<unsigned short> > nstrips_token_;
287  const std::vector<bool>* saturation =0; edm::EDGetTokenT<std::vector<bool> > saturation_token_;
288  const std::vector<bool>* overlapping =0; edm::EDGetTokenT<std::vector<bool> > overlapping_token_;
289  const std::vector<bool>* farfromedge =0; edm::EDGetTokenT<std::vector<bool> > farfromedge_token_;
290  const std::vector<unsigned int>* charge =0; edm::EDGetTokenT<std::vector<unsigned int> > charge_token_;
291  const std::vector<double>* path =0; edm::EDGetTokenT<std::vector<double> > path_token_;
292  const std::vector<double>* chargeoverpath =0; edm::EDGetTokenT<std::vector<double> > chargeoverpath_token_;
294  const std::vector<double>* gainused =0; edm::EDGetTokenT<std::vector<double> > gainused_token_;
295  const std::vector<double>* gainusedTick =0; edm::EDGetTokenT<std::vector<double> > gainusedTick_token_;
296 
297 
298  string EventPrefix_; //("");
299  string EventSuffix_; //("");
300  string TrackPrefix_; //("track");
301  string TrackSuffix_; //("");
302  string CalibPrefix_; //("GainCalibration");
303  string CalibSuffix_; //("");
304 
305 private :
306 
307  std::vector<stAPVGain*> APVsCollOrdered;
308  std::unordered_map<unsigned int, stAPVGain*> APVsColl;
310 };
311 
312 inline int
314 {
315  std::vector<string>::const_iterator it=dqm_tag_.begin();
316  while(it!=dqm_tag_.end()) {
317  if(*it==std::string(tag)) return it-dqm_tag_.begin();
318  it++;
319  }
320 
321  if (std::string(tag)=="") return 0; // return StdBunch calibration mode for backward compatibility
322 
323  return None;
324 }
325 
327  if(A->GetNbinsX() == B->GetNbinsX()){
328  A->Add(B);
329  }else{
330  for(int x=0;x<=B->GetNbinsX()+1; x++){
331  for(int y=0;y<=B->GetNbinsY()+1; y++){
332  A->SetBinContent(x,y,A->GetBinContent(x,y)+B->GetBinContent(x,y));
333  }}
334  }
335 }
336 
337 
338 
340 {
341  OutputGains = iConfig.getParameter<std::string>("OutputGains");
342 
343  AlgoMode = iConfig.getUntrackedParameter<std::string>("AlgoMode", "CalibTree");
344  MagFieldCurrentTh = iConfig.getUntrackedParameter<double> ("MagFieldCurrentTh" , 2000.);
345  MinNrEntries = iConfig.getUntrackedParameter<double> ("minNrEntries" , 20);
346  MaxMPVError = iConfig.getUntrackedParameter<double> ("maxMPVError" , 500.0);
347  MaxChi2OverNDF = iConfig.getUntrackedParameter<double> ("maxChi2OverNDF" , 5.0);
348  MinTrackMomentum = iConfig.getUntrackedParameter<double> ("minTrackMomentum" , 3.0);
349  MaxTrackMomentum = iConfig.getUntrackedParameter<double> ("maxTrackMomentum" , 99999.0);
350  MinTrackEta = iConfig.getUntrackedParameter<double> ("minTrackEta" , -5.0);
351  MaxTrackEta = iConfig.getUntrackedParameter<double> ("maxTrackEta" , 5.0);
352  MaxNrStrips = iConfig.getUntrackedParameter<unsigned>("maxNrStrips" , 2);
353  MinTrackHits = iConfig.getUntrackedParameter<unsigned>("MinTrackHits" , 8);
354  MaxTrackChiOverNdf = iConfig.getUntrackedParameter<double> ("MaxTrackChiOverNdf" , 3);
355  MaxTrackingIteration = iConfig.getUntrackedParameter<int> ("MaxTrackingIteration" , 7);
356  AllowSaturation = iConfig.getUntrackedParameter<bool> ("AllowSaturation" , false);
357  FirstSetOfConstants = iConfig.getUntrackedParameter<bool> ("FirstSetOfConstants" , true);
358  Validation = iConfig.getUntrackedParameter<bool> ("Validation" , false);
359  OldGainRemoving = iConfig.getUntrackedParameter<bool> ("OldGainRemoving" , false);
360 
361  CalibrationLevel = iConfig.getUntrackedParameter<int> ("CalibrationLevel" , 0);
362  VInputFiles = iConfig.getUntrackedParameter<vector<string> > ("InputFiles");
363  VChargeHisto = iConfig.getUntrackedParameter<vector<string> > ("ChargeHisto");
364 
365 
366  useCalibration = iConfig.getUntrackedParameter<bool> ("UseCalibration" , false);
367  m_harvestingMode = iConfig.getUntrackedParameter<bool> ("harvestingMode" , false);
368  m_splitDQMstat = iConfig.getUntrackedParameter<bool> ("splitDQMstat" , false);
369  m_calibrationMode = iConfig.getUntrackedParameter<string> ("calibrationMode" , "StdBunch");
370  m_calibrationPath = iConfig.getUntrackedParameter<string> ("calibrationPath");
371  m_DQMdir = iConfig.getUntrackedParameter<string> ("DQMdir" , "AlCaReco/SiStripGains");
372 
373  tagCondition_NClusters = iConfig.getUntrackedParameter<double> ("NClustersForTagProd" , 2E8);
374  tagCondition_GoodFrac = iConfig.getUntrackedParameter<double> ("GoodFracForTagProd" , 0.95);
375 
376  saveSummary = iConfig.getUntrackedParameter<bool> ("saveSummary" , false);
377 
378  doChargeMonitorPerPlane = iConfig.getUntrackedParameter<bool> ("doChargeMonitorPerPlane", false);
379 
380 
381  // Gather DQM Service
383  dbe->setVerbose(10);
384 
385  //Set the monitoring element tag and store
386  dqm_tag_.reserve(7);
387  dqm_tag_.clear();
388  dqm_tag_.push_back( "StdBunch" ); // statistic collection from Standard Collision Bunch @ 3.8 T
389  dqm_tag_.push_back( "StdBunch0T" ); // statistic collection from Standard Collision Bunch @ 0 T
390  dqm_tag_.push_back( "AagBunch" ); // statistic collection from First Collision After Abort Gap @ 3.8 T
391  dqm_tag_.push_back( "AagBunch0T" ); // statistic collection from First Collision After Abort Gap @ 0 T
392  dqm_tag_.push_back( "IsoMuon" ); // statistic collection from Isolated Muon @ 3.8 T
393  dqm_tag_.push_back( "IsoMuon0T" ); // statistic collection from Isolated Muon @ 0 T
394  dqm_tag_.push_back( "Harvest" ); // statistic collection: Harvest
395 
396  Charge_Vs_Index.insert( Charge_Vs_Index.begin(), dqm_tag_.size(), 0);
397  //Charge_Vs_Index_Absolute.insert( Charge_Vs_Index_Absolute.begin(), dqm_tag_.size(), 0);
398  Charge_Vs_PathlengthTIB.insert( Charge_Vs_PathlengthTIB.begin(), dqm_tag_.size(), 0);
399  Charge_Vs_PathlengthTOB.insert( Charge_Vs_PathlengthTOB.begin(), dqm_tag_.size(), 0);
400  Charge_Vs_PathlengthTIDP.insert( Charge_Vs_PathlengthTIDP.begin(), dqm_tag_.size(), 0);
401  Charge_Vs_PathlengthTIDM.insert( Charge_Vs_PathlengthTIDM.begin(), dqm_tag_.size(), 0);
406 
407 
408 
409 
410  // configure token for gathering the ntuple variables
411  edm::ParameterSet swhallowgain_pset = iConfig.getUntrackedParameter<edm::ParameterSet>("gain");
412 
413  string label = swhallowgain_pset.getUntrackedParameter<string>("label");
414  CalibPrefix_ = swhallowgain_pset.getUntrackedParameter<string>("prefix");
415  CalibSuffix_ = swhallowgain_pset.getUntrackedParameter<string>("suffix");
416 
417  trackindex_token_ = consumes<std::vector<int> >(edm::InputTag(label, CalibPrefix_ + "trackindex" + CalibSuffix_));
418  rawid_token_ = consumes<std::vector<unsigned int> >(edm::InputTag(label, CalibPrefix_ + "rawid" + CalibSuffix_));
419  localdirx_token_ = consumes<std::vector<double> >(edm::InputTag(label, CalibPrefix_ + "localdirx" + CalibSuffix_));
420  localdiry_token_ = consumes<std::vector<double> >(edm::InputTag(label, CalibPrefix_ + "localdiry" + CalibSuffix_));
421  localdirz_token_ = consumes<std::vector<double> >(edm::InputTag(label, CalibPrefix_ + "localdirz" + CalibSuffix_));
422  firststrip_token_ = consumes<std::vector<unsigned short> >(edm::InputTag(label, CalibPrefix_ + "firststrip" + CalibSuffix_));
423  nstrips_token_ = consumes<std::vector<unsigned short> >(edm::InputTag(label, CalibPrefix_ + "nstrips" + CalibSuffix_));
424  saturation_token_ = consumes<std::vector<bool> >(edm::InputTag(label, CalibPrefix_ + "saturation" + CalibSuffix_));
425  overlapping_token_ = consumes<std::vector<bool> >(edm::InputTag(label, CalibPrefix_ + "overlapping" + CalibSuffix_));
426  farfromedge_token_ = consumes<std::vector<bool> >(edm::InputTag(label, CalibPrefix_ + "farfromedge" + CalibSuffix_));
427  charge_token_ = consumes<std::vector<unsigned int> >(edm::InputTag(label, CalibPrefix_ + "charge" + CalibSuffix_));
428  path_token_ = consumes<std::vector<double> >(edm::InputTag(label, CalibPrefix_ + "path" + CalibSuffix_));
429  chargeoverpath_token_ = consumes<std::vector<double> >(edm::InputTag(label, CalibPrefix_ + "chargeoverpath"+ CalibSuffix_));
430  amplitude_token_ = consumes<std::vector<unsigned char> >(edm::InputTag(label, CalibPrefix_ + "amplitude" + CalibSuffix_));
431  gainused_token_ = consumes<std::vector<double> >(edm::InputTag(label, CalibPrefix_ + "gainused" + CalibSuffix_));
432  gainusedTick_token_ = consumes<std::vector<double> >(edm::InputTag(label, CalibPrefix_ + "gainusedTick" + CalibSuffix_));
433 
434  edm::ParameterSet evtinfo_pset = iConfig.getUntrackedParameter<edm::ParameterSet>("evtinfo");
435  label = evtinfo_pset.getUntrackedParameter<string>("label");
436  EventPrefix_ = evtinfo_pset.getUntrackedParameter<string>("prefix");
437  EventSuffix_ = evtinfo_pset.getUntrackedParameter<string>("suffix");
438  TrigTech_token_ = consumes<std::vector<bool> >(edm::InputTag(label, EventPrefix_ + "TrigTech" + EventSuffix_));
439 
440  edm::ParameterSet track_pset = iConfig.getUntrackedParameter<edm::ParameterSet>("tracks");
441  label = track_pset.getUntrackedParameter<string>("label");
442  TrackPrefix_ = track_pset.getUntrackedParameter<string>("prefix");
443  TrackSuffix_ = track_pset.getUntrackedParameter<string>("suffix");
444 
445  trackchi2ndof_token_ = consumes<std::vector<double> >(edm::InputTag(label, TrackPrefix_ + "chi2ndof" + TrackSuffix_));
446  trackp_token_ = consumes<std::vector<float> >(edm::InputTag(label, TrackPrefix_ + "momentum" + TrackSuffix_));
447  trackpt_token_ = consumes<std::vector<float> >(edm::InputTag(label, TrackPrefix_ + "pt" + TrackSuffix_));
448  tracketa_token_ = consumes<std::vector<double> >(edm::InputTag(label, TrackPrefix_ + "eta" + TrackSuffix_));
449  trackphi_token_ = consumes<std::vector<double> >(edm::InputTag(label, TrackPrefix_ + "phi" + TrackSuffix_));
450  trackhitsvalid_token_ = consumes<std::vector<unsigned int> >(edm::InputTag(label, TrackPrefix_ + "hitsvalid" + TrackSuffix_));
451  trackalgo_token_ = consumes<std::vector<int> >(edm::InputTag(label, TrackPrefix_ + "algo" + TrackSuffix_));
452 
453  tTopo_ = 0;
454 }
455 
456 void SiStripGainFromCalibTree::bookDQMHistos(const char* dqm_dir, const char* tag)
457 {
458  edm::LogInfo("SiStripGainFromCalibTree") << "Setting " << dqm_dir << "in DQM and booking histograms for tag "
459  << tag << std::endl;
460 
461  if ( strcmp(booked_dir_.c_str(),dqm_dir)!=0 ) {
462  booked_dir_ = dqm_dir;
463  dbe->setCurrentFolder(dqm_dir);
464  }
465 
466  std::string stag(tag);
467  if(stag.size()!=0 && stag[0]!='_') stag.insert(0,1,'_');
468 
469  std::string cvi = std::string("Charge_Vs_Index") + stag;
470  //std::string cviA = std::string("Charge_Vs_Index_Absolute") + stag;
471  std::string cvpTIB = std::string("Charge_Vs_PathlengthTIB") + stag;
472  std::string cvpTOB = std::string("Charge_Vs_PathlengthTOB") + stag;
473  std::string cvpTIDP = std::string("Charge_Vs_PathlengthTIDP") + stag;
474  std::string cvpTIDM = std::string("Charge_Vs_PathlengthTIDM") + stag;
475  std::string cvpTECP1 = std::string("Charge_Vs_PathlengthTECP1") + stag;
476  std::string cvpTECP2 = std::string("Charge_Vs_PathlengthTECP2") + stag;
477  std::string cvpTECM1 = std::string("Charge_Vs_PathlengthTECM1") + stag;
478  std::string cvpTECM2 = std::string("Charge_Vs_PathlengthTECM2") + stag;
479 
480  int elepos = (m_harvestingMode && AlgoMode=="PCL")? Harvest : statCollectionFromMode(tag);
481 
482  Charge_Vs_Index[elepos] = dbe->book2S(cvi.c_str() , cvi.c_str() , 88625, 0 , 88624,2000,0,4000);
483  //Charge_Vs_Index_Absolute[elepos] = dbe->book2S(cviA.c_str() , cviA.c_str() , 88625, 0 , 88624,1000,0,4000);
484  Charge_Vs_PathlengthTIB[elepos] = dbe->book2S(cvpTIB.c_str() , cvpTIB.c_str() , 20 , 0.3 , 1.3 , 250,0,2000);
485  Charge_Vs_PathlengthTOB[elepos] = dbe->book2S(cvpTOB.c_str() , cvpTOB.c_str() , 20 , 0.3 , 1.3 , 250,0,2000);
486  Charge_Vs_PathlengthTIDP[elepos] = dbe->book2S(cvpTIDP.c_str() , cvpTIDP.c_str() , 20 , 0.3 , 1.3 , 250,0,2000);
487  Charge_Vs_PathlengthTIDM[elepos] = dbe->book2S(cvpTIDM.c_str() , cvpTIDM.c_str() , 20 , 0.3 , 1.3 , 250,0,2000);
488  Charge_Vs_PathlengthTECP1[elepos] = dbe->book2S(cvpTECP1.c_str(), cvpTECP1.c_str(), 20 , 0.3 , 1.3 , 250,0,2000);
489  Charge_Vs_PathlengthTECP2[elepos] = dbe->book2S(cvpTECP2.c_str(), cvpTECP2.c_str(), 20 , 0.3 , 1.3 , 250,0,2000);
490  Charge_Vs_PathlengthTECM1[elepos] = dbe->book2S(cvpTECM1.c_str(), cvpTECM1.c_str(), 20 , 0.3 , 1.3 , 250,0,2000);
491  Charge_Vs_PathlengthTECM2[elepos] = dbe->book2S(cvpTECM2.c_str(), cvpTECM2.c_str(), 20 , 0.3 , 1.3 , 250,0,2000);
492 
493  //Book Charge monitoring histograms
494  std::vector<std::pair<std::string,std::string>> hnames = APVGain::monHnames(VChargeHisto,doChargeMonitorPerPlane,"");
495  for (unsigned int i=0;i<hnames.size();i++){
496  std::string htag = (hnames[i]).first + stag;
497  MonitorElement* monitor = dbe->book1DD( htag.c_str(), (hnames[i]).second.c_str(), 100 , 0. , 1000. );
498  int id = APVGain::subdetectorId((hnames[i]).first);
499  int side = APVGain::subdetectorSide((hnames[i]).first);
500  int plane = APVGain::subdetectorPlane((hnames[i]).first);
501  Charge_1[elepos].push_back( APVGain::APVmon(id,side,plane,monitor) );
502  }
503 
505  for (unsigned int i=0;i<hnames.size();i++){
506  std::string htag = (hnames[i]).first + stag;
507  MonitorElement* monitor = dbe->book1DD( htag.c_str(), (hnames[i]).second.c_str(), 100 , 0. , 1000. );
508  int id = APVGain::subdetectorId((hnames[i]).first);
509  int side = APVGain::subdetectorSide((hnames[i]).first);
510  int plane = APVGain::subdetectorPlane((hnames[i]).first);
511  Charge_2[elepos].push_back( APVGain::APVmon(id,side,plane,monitor) );
512  }
513 
515  for (unsigned int i=0;i<hnames.size();i++){
516  std::string htag = (hnames[i]).first + stag;
517  MonitorElement* monitor = dbe->book1DD( htag.c_str(), (hnames[i]).second.c_str(), 100 , 0. , 1000. );
518  int id = APVGain::subdetectorId((hnames[i]).first);
519  int side = APVGain::subdetectorSide((hnames[i]).first);
520  int plane = APVGain::subdetectorPlane((hnames[i]).first);
521  Charge_3[elepos].push_back( APVGain::APVmon(id,side,plane,monitor) );
522  }
523 
525  for (unsigned int i=0;i<hnames.size();i++){
526  std::string htag = (hnames[i]).first + stag;
527  MonitorElement* monitor = dbe->book1DD( htag.c_str(), (hnames[i]).second.c_str(), 100 , 0. , 1000. );
528  int id = APVGain::subdetectorId((hnames[i]).first);
529  int side = APVGain::subdetectorSide((hnames[i]).first);
530  int plane = APVGain::subdetectorPlane((hnames[i]).first);
531  Charge_4[elepos].push_back( APVGain::APVmon(id,side,plane,monitor) );
532  }
533 
534  //Book validation histograms
535  if (m_harvestingMode) {
536  int MPVbin = 300;
537  float MPVmin = 0.;
538  float MPVmax = 600.;
539 
540  MPV_Vs_EtaTIB = dbe->book2DD("MPV_vs_EtaTIB" ,"MPV vs Eta TIB" , 50, -3.0, 3.0, MPVbin, MPVmin, MPVmax);
541  MPV_Vs_EtaTID = dbe->book2DD("MPV_vs_EtaTID" ,"MPV vs Eta TID" , 50, -3.0, 3.0, MPVbin, MPVmin, MPVmax);
542  MPV_Vs_EtaTOB = dbe->book2DD("MPV_vs_EtaTOB" ,"MPV vs Eta TOB" , 50, -3.0, 3.0, MPVbin, MPVmin, MPVmax);
543  MPV_Vs_EtaTEC = dbe->book2DD("MPV_vs_EtaTEC" ,"MPV vs Eta TEC" , 50, -3.0, 3.0, MPVbin, MPVmin, MPVmax);
544  MPV_Vs_EtaTECthin = dbe->book2DD("MPV_vs_EtaTEC1","MPV vs Eta TEC-thin" , 50, -3.0, 3.0, MPVbin, MPVmin, MPVmax);
545  MPV_Vs_EtaTECthick = dbe->book2DD("MPV_vs_EtaTEC2","MPV vs Eta TEC-thick", 50, -3.0, 3.0, MPVbin, MPVmin, MPVmax);
546 
547  MPV_Vs_PhiTIB = dbe->book2DD("MPV_vs_PhiTIB" ,"MPV vs Phi TIB" , 50, -3.4, 3.4, MPVbin, MPVmin, MPVmax);
548  MPV_Vs_PhiTID = dbe->book2DD("MPV_vs_PhiTID" ,"MPV vs Phi TID" , 50, -3.4, 3.4, MPVbin, MPVmin, MPVmax);
549  MPV_Vs_PhiTOB = dbe->book2DD("MPV_vs_PhiTOB" ,"MPV vs Phi TOB" , 50, -3.4, 3.4, MPVbin, MPVmin, MPVmax);
550  MPV_Vs_PhiTEC = dbe->book2DD("MPV_vs_PhiTEC" ,"MPV vs Phi TEC" , 50, -3.4, 3.4, MPVbin, MPVmin, MPVmax);
551  MPV_Vs_PhiTECthin = dbe->book2DD("MPV_vs_PhiTEC1","MPV vs Phi TEC-thin" , 50, -3.4, 3.4, MPVbin, MPVmin, MPVmax);
552  MPV_Vs_PhiTECthick = dbe->book2DD("MPV_vs_PhiTEC2","MPV vs Phi TEC-thick", 50, -3.4, 3.4, MPVbin, MPVmin, MPVmax);
553 
554  NoMPV = dbe->book2DD("NoMPV" ,"NoMPV" ,350, -350, 350, 240, 0, 120);
555 
556  Gains = dbe->book1DD("Gains" ,"Gains" , 300, 0, 2);
557  MPVs = dbe->book1DD("MPVs" ,"MPVs" , MPVbin, MPVmin, MPVmax);
558  MPVs320 = dbe->book1DD("MPV_320" ,"MPV 320 thickness" , MPVbin, MPVmin, MPVmax);
559  MPVs500 = dbe->book1DD("MPV_500" ,"MPV 500 thickness" , MPVbin, MPVmin, MPVmax);
560  MPVsTIB = dbe->book1DD("MPV_TIB" ,"MPV TIB" , MPVbin, MPVmin, MPVmax);
561  MPVsTID = dbe->book1DD("MPV_TID" ,"MPV TID" , MPVbin, MPVmin, MPVmax);
562  MPVsTIDP = dbe->book1DD("MPV_TIDP" ,"MPV TIDP" , MPVbin, MPVmin, MPVmax);
563  MPVsTIDM = dbe->book1DD("MPV_TIDM" ,"MPV TIDM" , MPVbin, MPVmin, MPVmax);
564  MPVsTOB = dbe->book1DD("MPV_TOB" ,"MPV TOB" , MPVbin, MPVmin, MPVmax);
565  MPVsTEC = dbe->book1DD("MPV_TEC" ,"MPV TEC" , MPVbin, MPVmin, MPVmax);
566  MPVsTECP = dbe->book1DD("MPV_TECP" ,"MPV TECP" , MPVbin, MPVmin, MPVmax);
567  MPVsTECM = dbe->book1DD("MPV_TECM" ,"MPV TECM" , MPVbin, MPVmin, MPVmax);
568  MPVsTECthin = dbe->book1DD("MPV_TEC1" ,"MPV TEC1" , MPVbin, MPVmin, MPVmax);
569  MPVsTECthick = dbe->book1DD("MPV_TEC2" ,"MPV TEC2" , MPVbin, MPVmin, MPVmax);
570  MPVsTECP1 = dbe->book1DD("MPV_TECP1" ,"MPV TECP1" , MPVbin, MPVmin, MPVmax);
571  MPVsTECP2 = dbe->book1DD("MPV_TECP2" ,"MPV TECP2" , MPVbin, MPVmin, MPVmax);
572  MPVsTECM1 = dbe->book1DD("MPV_TECM1" ,"MPV TECM1" , MPVbin, MPVmin, MPVmax);
573  MPVsTECM2 = dbe->book1DD("MPV_TECM2" ,"MPV TECM2" , MPVbin, MPVmin, MPVmax);
574 
575  MPVError = dbe->book1DD("MPVError" ,"MPV Error" , 150, 0, 150);
576  MPVErrorVsMPV = dbe->book2DD("MPVErrorVsMPV" ,"MPV Error vs MPV" ,300, 0, 600, 150, 0, 150);
577  MPVErrorVsEta = dbe->book2DD("MPVErrorVsEta" ,"MPV Error vs Eta" , 50, -3.0, 3.0, 150, 0, 150);
578  MPVErrorVsPhi = dbe->book2DD("MPVErrorVsPhi" ,"MPV Error vs Phi" , 50, -3.4, 3.4, 150, 0, 150);
579  MPVErrorVsN = dbe->book2DD("MPVErrorVsN" ,"MPV Error vs N" ,500, 0,1000, 150, 0, 150);
580 
581  DiffWRTPrevGainTIB = dbe->book1DD("DiffWRTPrevGainTIB" ,"Diff w.r.t. PrevGain TIB" , 250, 0,2);
582  DiffWRTPrevGainTID = dbe->book1DD("DiffWRTPrevGainTID" ,"Diff w.r.t. PrevGain TID" , 250, 0,2);
583  DiffWRTPrevGainTOB = dbe->book1DD("DiffWRTPrevGainTOB" ,"Diff w.r.t. PrevGain TOB" , 250, 0,2);
584  DiffWRTPrevGainTEC = dbe->book1DD("DiffWRTPrevGainTEC" ,"Diff w.r.t. PrevGain TEC" , 250, 0,2);
585 
586  GainVsPrevGainTIB = dbe->book2DD("GainVsPrevGainTIB" ,"Gain vs PrevGain TIB" , 100, 0,2, 100, 0,2);
587  GainVsPrevGainTID = dbe->book2DD("GainVsPrevGainTID" ,"Gain vs PrevGain TID" , 100, 0,2, 100, 0,2);
588  GainVsPrevGainTOB = dbe->book2DD("GainVsPrevGainTOB" ,"Gain vs PrevGain TOB" , 100, 0,2, 100, 0,2);
589  GainVsPrevGainTEC = dbe->book2DD("GainVsPrevGainTEC" ,"Gain vs PrevGain TEC" , 100, 0,2, 100, 0,2);
590 
591  std::vector<std::pair<std::string,std::string>> hnames=APVGain::monHnames(VChargeHisto,doChargeMonitorPerPlane,"newG2");
592  for (unsigned int i=0;i<hnames.size();i++){
593  MonitorElement* monitor = dbe->book1DD( (hnames[i]).first.c_str(), (hnames[i]).second.c_str(), 100 , 0. , 1000. );
594  int id = APVGain::subdetectorId((hnames[i]).first);
595  int side = APVGain::subdetectorSide((hnames[i]).first);
596  int plane = APVGain::subdetectorPlane((hnames[i]).first);
597  newCharge.push_back( APVGain::APVmon(id,side,plane,monitor) );
598  }
599 
600  }
601 }
602 
604 {
605  edm::LogInfo("SiStripGainFromCalibTree") << "AlgoMode : " << AlgoMode << "\n"
606  << "CalibrationMode : " << m_calibrationMode << "\n"
607  << "HarvestingMode : " << m_harvestingMode << std::endl;
608  //Setup DQM histograms
609  if(AlgoMode != "PCL" or m_harvestingMode) {
610  const char * dqm_dir = "AlCaReco/SiStripGainsHarvesting/";
611  this->bookDQMHistos( dqm_dir, dqm_tag_[statCollectionFromMode(m_calibrationMode.c_str())].c_str() );
612  } else {
613  //Check consistency of calibration Mode and BField only for the ALCAPROMPT in the PCL workflow
614  if (!isBFieldConsistentWithMode(iSetup)) {
615  string prevMode = m_calibrationMode;
616  swapBFieldMode();
617  edm::LogInfo("SiStripGainFromCalibTree") << "Switching calibration mode for endorsing BField status: "
618  << prevMode << " ==> " << m_calibrationMode << std::endl;
619  }
620  std::string dqm_dir = m_DQMdir + ((m_splitDQMstat)? m_calibrationMode:"") + "/";
622  this->bookDQMHistos( dqm_dir.c_str(), dqm_tag_[elem].c_str() );
623  }
624 
626  iSetup.get<TrackerTopologyRcd>().get( TopoHandle );
627  tTopo_ = TopoHandle.product();
628 
630  iSetup.get<TrackerDigiGeometryRecord>().get( tkGeom );
631  auto const & Det = tkGeom->dets();
632 
633 
634  NPixelDets = 0;
635  NStripAPVs = 0;
636  unsigned int Index=0;
637  for(unsigned int i=0;i<Det.size();i++){
638  DetId Detid = Det[i]->geographicalId();
639  int SubDet = Detid.subdetId();
640 
641  if( SubDet == StripSubdetector::TIB || SubDet == StripSubdetector::TID ||
642  SubDet == StripSubdetector::TOB || SubDet == StripSubdetector::TEC ){
643 
644  auto DetUnit = dynamic_cast<const StripGeomDetUnit*> (Det[i]);
645  if(!DetUnit)continue;
646 
647  const StripTopology& Topo = DetUnit->specificTopology();
648  unsigned int NAPV = Topo.nstrips()/128;
649 
650  for(unsigned int j=0;j<NAPV;j++){
651  stAPVGain* APV = new stAPVGain;
652  APV->Index = Index;
653  APV->Bin = -1;
654  APV->DetId = Detid.rawId();
655  APV->APVId = j;
656  APV->SubDet = SubDet;
657  APV->FitMPV = -1;
658  APV->FitMPVErr = -1;
659  APV->FitWidth = -1;
660  APV->FitWidthErr = -1;
661  APV->FitChi2 = -1;
662  APV->FitNorm = -1;
663  APV->Gain = -1;
664  APV->PreviousGain = 1;
665  APV->PreviousGainTick = 1;
666  APV->x = DetUnit->position().basicVector().x();
667  APV->y = DetUnit->position().basicVector().y();
668  APV->z = DetUnit->position().basicVector().z();
669  APV->Eta = DetUnit->position().basicVector().eta();
670  APV->Phi = DetUnit->position().basicVector().phi();
671  APV->R = DetUnit->position().basicVector().transverse();
672  APV->Thickness = DetUnit->surface().bounds().thickness();
673  APV->NEntries = 0;
674  APV->isMasked = false;
675 
676  APVsCollOrdered.push_back(APV);
677  APVsColl[(APV->DetId<<4) | APV->APVId] = APV;
678  Index++;
679  NStripAPVs++;
680  }
681  }
682  }
683 
684  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
685  DetId Detid = Det[i]->geographicalId();
686  int SubDet = Detid.subdetId();
688  auto DetUnit = dynamic_cast<const PixelGeomDetUnit*> (Det[i]);
689  if(!DetUnit) continue;
690 
691  const PixelTopology& Topo = DetUnit->specificTopology();
692  unsigned int NROCRow = Topo.nrows()/(80.);
693  unsigned int NROCCol = Topo.ncolumns()/(52.);
694 
695  for(unsigned int j=0;j<NROCRow;j++){
696  for(unsigned int i=0;i<NROCCol;i++){
697 
698  stAPVGain* APV = new stAPVGain;
699  APV->Index = Index;
700  APV->Bin = -1;
701  APV->DetId = Detid.rawId();
702  APV->APVId = (j<<3 | i);
703  APV->SubDet = SubDet;
704  APV->FitMPV = -1;
705  APV->FitMPVErr = -1;
706  APV->FitWidth = -1;
707  APV->FitWidthErr = -1;
708  APV->FitChi2 = -1;
709  APV->Gain = -1;
710  APV->PreviousGain = 1;
711  APV->PreviousGainTick = 1;
712  APV->x = DetUnit->position().basicVector().x();
713  APV->y = DetUnit->position().basicVector().y();
714  APV->z = DetUnit->position().basicVector().z();
715  APV->Eta = DetUnit->position().basicVector().eta();
716  APV->Phi = DetUnit->position().basicVector().phi();
717  APV->R = DetUnit->position().basicVector().transverse();
718  APV->Thickness = DetUnit->surface().bounds().thickness();
719  APV->isMasked = false; //SiPixelQuality_->IsModuleBad(Detid.rawId());
720  APV->NEntries = 0;
721 
722  APVsCollOrdered.push_back(APV);
723  APVsColl[(APV->DetId<<4) | APV->APVId] = APV;
724  Index++;
725  NPixelDets++;
726  }}
727  }
728  }
729 
730 
732 
733  NEvent = 0;
734  NTrack = 0;
735  NClusterStrip = 0;
736  NClusterPixel = 0;
737  SRun = 1<<31;
738  ERun = 0;
739  GOOD = 0;
740  BAD = 0;
741  MASKED = 0;
742 }
743 
745  edm::ESHandle<RunInfo> runInfo;
746  iSetup.get<RunInfoRcd>().get(runInfo);
747 
748  double average_current = runInfo.product()->m_avg_current;
749  bool isOn = (average_current > MagFieldCurrentTh);
750  bool is0T = (m_calibrationMode.substr( m_calibrationMode.length()-2 )=="0T");
751 
752  return ( (isOn && !is0T) || (!isOn && is0T) );
753 }
754 
756  if ( m_calibrationMode.substr( m_calibrationMode.length()-2 )=="0T" ) {
757  m_calibrationMode.erase( m_calibrationMode.length()-2,2);
758  } else {
759  m_calibrationMode.append( "0T" );
760  }
761 }
762 
764 {
765  if( !m_harvestingMode && AlgoMode=="PCL") {
766  //Check consistency of calibration Mode and BField only for the ALCAPROMPT in the PCL workflow
767  if (!isBFieldConsistentWithMode(iSetup)) {
768  string prevMode = m_calibrationMode;
769  swapBFieldMode();
770  edm::LogInfo("SiStripGainFromCalibTree") << "Switching calibration mode for endorsing BField status: "
771  << prevMode << " ==> " << m_calibrationMode << std::endl;
772  }
773  }
774 
775  edm::ESHandle<SiStripGain> gainHandle;
776  iSetup.get<SiStripGainRcd>().get(gainHandle);
777  if(!gainHandle.isValid()){edm::LogError("SiStripGainFromCalibTree")<< "gainHandle is not valid\n"; exit(0);}
778 
779  edm::ESHandle<SiStripQuality> SiStripQuality_;
780  iSetup.get<SiStripQualityRcd>().get(SiStripQuality_);
781 
782  for(unsigned int a=0;a<APVsCollOrdered.size();a++){
783 
785 
786  // MM. 03/03/2017 all of this makes sense only for SiStrip (i.e. get me out of here if I am on a pixel ROC)
788 
789  APV->isMasked = SiStripQuality_->IsApvBad(APV->DetId,APV->APVId);
790  // if(!FirstSetOfConstants){
791 
792  if(gainHandle->getNumberOfTags()!=2){edm::LogError("SiStripGainFromCalibTree")<< "NUMBER OF GAIN TAG IS EXPECTED TO BE 2\n";fflush(stdout);exit(0);};
793  float newPreviousGain = gainHandle->getApvGain(APV->APVId,gainHandle->getRange(APV->DetId, 1),1);
794  if(APV->PreviousGain!=1 and newPreviousGain!=APV->PreviousGain)edm::LogWarning("SiStripGainFromCalibTree")<< "WARNING: ParticleGain in the global tag changed\n";
795  APV->PreviousGain = newPreviousGain;
796 
797  float newPreviousGainTick = gainHandle->getApvGain(APV->APVId,gainHandle->getRange(APV->DetId, 0),0);
798  if(APV->PreviousGainTick!=1 and newPreviousGainTick!=APV->PreviousGainTick){
799  edm::LogWarning("SiStripGainFromCalibTree")<< "WARNING: TickMarkGain in the global tag changed\n"<< std::endl
800  <<" APV->SubDet: "<< APV->SubDet << " APV->APVId:" << APV->APVId << std::endl
801  <<" APV->PreviousGainTick: "<<APV->PreviousGainTick<<" newPreviousGainTick: "<<newPreviousGainTick<<std::endl;
802  }
803  APV->PreviousGainTick = newPreviousGainTick;
804 
805  //printf("DETID = %7i APVID=%1i Previous Gain=%8.4f (G1) x %8.4f (G2)\n",APV->DetId,APV->APVId,APV->PreviousGainTick, APV->PreviousGain);
806  // }
807 
808  }
809 }
810 
812  if(AlgoMode == "PCL" && !m_harvestingMode) return;//nothing to do in that case
813 
814  if(AlgoMode == "PCL" and m_harvestingMode){
815  // Load the 2D histograms from the DQM objects
816  // When running in AlCaHarvesting mode the histos are already booked and should be just retrieved from
817  // DQMStore so that they can be used in the fit
818 
819  edm::LogInfo("SiStripGainFromCalibTree") << "Starting harvesting statistics" << std::endl;
820 
821  // check the required tag before adding histograms
822  int elepos = statCollectionFromMode(m_calibrationMode.c_str());
823  if (elepos!=Harvest) {
824 
825  //collect statistics from DQM into the related monitored elements
827  if(stag.size()!=0 && stag[0]!='_') stag.insert(0,1,'_');
828 
829 
830  if (elepos==-1) {
831  //implememt backward compatibility
832  elepos=0;
833  stag="";
834  }
835 
837 
838  std::string cvi = DQM_dir + std::string("/Charge_Vs_Index") + stag;
839  //std::string cviA = DQM_dir + std::string("/Charge_Vs_Index_Absolute") + stag;
840  std::string cvpTIB = DQM_dir + std::string("/Charge_Vs_PathlengthTIB") + stag;
841  std::string cvpTOB = DQM_dir + std::string("/Charge_Vs_PathlengthTOB") + stag;
842  std::string cvpTIDP = DQM_dir + std::string("/Charge_Vs_PathlengthTIDP") + stag;
843  std::string cvpTIDM = DQM_dir + std::string("/Charge_Vs_PathlengthTIDM") + stag;
844  std::string cvpTECP1 = DQM_dir + std::string("/Charge_Vs_PathlengthTECP1") + stag;
845  std::string cvpTECP2 = DQM_dir + std::string("/Charge_Vs_PathlengthTECP2") + stag;
846  std::string cvpTECM1 = DQM_dir + std::string("/Charge_Vs_PathlengthTECM1") + stag;
847  std::string cvpTECM2 = DQM_dir + std::string("/Charge_Vs_PathlengthTECM2") + stag;
848 
849  Charge_Vs_Index[elepos] = dbe->get(cvi.c_str());
850  //Charge_Vs_Index_Absolute[elepos] = dbe->get(cviA.c_str());
851  Charge_Vs_PathlengthTIB[elepos] = dbe->get(cvpTIB.c_str());
852  Charge_Vs_PathlengthTOB[elepos] = dbe->get(cvpTOB.c_str());
853  Charge_Vs_PathlengthTIDP[elepos] = dbe->get(cvpTIDP.c_str());
854  Charge_Vs_PathlengthTIDM[elepos] = dbe->get(cvpTIDM.c_str());
855  Charge_Vs_PathlengthTECP1[elepos] = dbe->get(cvpTECP1.c_str());
856  Charge_Vs_PathlengthTECP2[elepos] = dbe->get(cvpTECP2.c_str());
857  Charge_Vs_PathlengthTECM1[elepos] = dbe->get(cvpTECM1.c_str());
858  Charge_Vs_PathlengthTECM2[elepos] = dbe->get(cvpTECM2.c_str());
859 
860  if (Charge_Vs_Index[elepos]==0) {
861  edm::LogError("SiStripGainFromCalibTree") << "Harvesting: could not retrieve " << cvi.c_str()
862  << ", statistics will not be summed!" << std::endl;
863  } else {
864  merge( (Charge_Vs_Index[Harvest])->getTH2S(), (Charge_Vs_Index[elepos])->getTH2S() );
865  edm::LogInfo("SiStripGainFromCalibTree") << "Harvesting "
866  << (Charge_Vs_Index[elepos])->getTH2S()->GetEntries() << " more clusters" << std::endl;
867  }
868 
869  //if (Charge_Vs_Index_Absolute[elepos]==0) {
870  // edm::LogError("SiStripGainFromCalibTree") << "Harvesting: could not retrieve " << cviA.c_str()
871  // << ", statistics will not be summed!" << std::endl;
872  //} else merge( (Charge_Vs_Index_Absolute[Harvest])->getTH2S(), (Charge_Vs_Index_Absolute[elepos])->getTH2S() );
873 
874  if (Charge_Vs_PathlengthTIB[elepos]==0) {
875  edm::LogError("SiStripGainFromCalibTree") << "Harvesting: could not retrieve " << cvpTIB.c_str()
876  << ", statistics will not be summed!" << std::endl;
877  } else (Charge_Vs_PathlengthTIB[Harvest])->getTH2S()->Add((Charge_Vs_PathlengthTIB[elepos])->getTH2S());
878 
879  if (Charge_Vs_PathlengthTOB[elepos]==0) {
880  edm::LogError("SiStripGainFromCalibTree") << "Harvesting: could not retrieve " << cvpTOB.c_str()
881  << ", statistics will not be summed!" << std::endl;
882  } else (Charge_Vs_PathlengthTOB[Harvest])->getTH2S()->Add((Charge_Vs_PathlengthTOB[elepos])->getTH2S());
883 
884  if (Charge_Vs_PathlengthTIDP[elepos]==0) {
885  edm::LogError("SiStripGainFromCalibTree") << "Harvesting: could not retrieve " << cvpTIDP.c_str()
886  << ", statistics will not be summed!" << std::endl;
887  } else (Charge_Vs_PathlengthTIDP[Harvest])->getTH2S()->Add((Charge_Vs_PathlengthTIDP[elepos])->getTH2S());
888 
889  if (Charge_Vs_PathlengthTIDM[elepos]==0) {
890  edm::LogError("SiStripGainFromCalibTree") << "Harvesting: could not retrieve " << cvpTIDM.c_str()
891  << ", statistics will not be summed!" << std::endl;
892  } else (Charge_Vs_PathlengthTIDM[Harvest])->getTH2S()->Add((Charge_Vs_PathlengthTIDM[elepos])->getTH2S());
893 
894  if (Charge_Vs_PathlengthTECP1[elepos]==0) {
895  edm::LogError("SiStripGainFromCalibTree") << "Harvesting: could not retrieve " << cvpTECP1.c_str()
896  << ", statistics will not be summed!" << std::endl;
897  } else (Charge_Vs_PathlengthTECP1[Harvest])->getTH2S()->Add((Charge_Vs_PathlengthTECP1[elepos])->getTH2S());
898 
899  if (Charge_Vs_PathlengthTECP2[elepos]==0) {
900  edm::LogError("SiStripGainFromCalibTree") << "Harvesting: could not retrieve " << cvpTECP2.c_str()
901  << ", statistics will not be summed!" << std::endl;
902  } else (Charge_Vs_PathlengthTECP2[Harvest])->getTH2S()->Add((Charge_Vs_PathlengthTECP2[elepos])->getTH2S());
903 
904  if (Charge_Vs_PathlengthTECM1[elepos]==0) {
905  edm::LogError("SiStripGainFromCalibTree") << "Harvesting: could not retrieve " << cvpTECM1.c_str()
906  << ", statistics will not be summed!" << std::endl;
907  } else (Charge_Vs_PathlengthTECM1[Harvest])->getTH2S()->Add((Charge_Vs_PathlengthTECM1[elepos])->getTH2S());
908 
909  if (Charge_Vs_PathlengthTECM2[elepos]==0) {
910  edm::LogError("SiStripGainFromCalibTree") << "Harvesting: could not retrieve " << cvpTECM2.c_str()
911  << ", statistics will not be summed!" << std::endl;
912  } else (Charge_Vs_PathlengthTECM2[Harvest])->getTH2S()->Add((Charge_Vs_PathlengthTECM2[elepos])->getTH2S());
913 
914 
915  // Gather Charge monitoring histograms
916  std::vector<std::pair<std::string,std::string>> tags = APVGain::monHnames(VChargeHisto,doChargeMonitorPerPlane,"");
917  for (unsigned int i=0;i<tags.size();i++){
918  std::string tag = DQM_dir + "/" + (tags[i]).first + stag;
919  Charge_1[elepos].push_back( APVGain::APVmon(0,0,0,dbe->get( tag.c_str()) ) );
920  if ( (Charge_1[elepos][i]).monitor==0 ) {
921  edm::LogError("SiStripGainFromCalibTree") << "Harvesting: could not retrieve " << tag.c_str()
922  << ", statistics will not be summed!" << std::endl;
923  } else (Charge_1[Harvest][i]).monitor->getTH1D()->Add((Charge_1[elepos][i]).monitor->getTH1D());
924  }
925 
927  for (unsigned int i=0;i<tags.size();i++){
928  std::string tag = DQM_dir + "/" + (tags[i]).first + stag;
929  Charge_2[elepos].push_back( APVGain::APVmon(0,0,0,dbe->get( tag.c_str()) ) );
930  if ( (Charge_2[elepos][i]).monitor==0 ) {
931  edm::LogError("SiStripGainFromCalibTree") << "Harvesting: could not retrieve " << tag.c_str()
932  << ", statistics will not be summed!" << std::endl;
933  } else (Charge_2[Harvest][i]).monitor->getTH1D()->Add((Charge_2[elepos][i]).monitor->getTH1D());
934 
935  }
936 
938  for (unsigned int i=0;i<tags.size();i++){
939  std::string tag = DQM_dir + "/" + (tags[i]).first + stag;
940  Charge_3[elepos].push_back( APVGain::APVmon(0,0,0,dbe->get( tag.c_str()) ) );
941  if ( (Charge_3[elepos][i]).monitor==0 ) {
942  edm::LogError("SiStripGainFromCalibTree") << "Harvesting: could not retrieve " << tag.c_str()
943  << ", statistics will not be summed!" << std::endl;
944  } else (Charge_3[Harvest][i]).monitor->getTH1D()->Add((Charge_3[elepos][i]).monitor->getTH1D());
945 
946  }
947 
949  for (unsigned int i=0;i<tags.size();i++){
950  std::string tag = DQM_dir + "/" + (tags[i]).first + stag;
951  Charge_4[elepos].push_back( APVGain::APVmon(0,0,0,dbe->get( tag.c_str()) ) );
952  if ( (Charge_4[elepos][i]).monitor==0 ) {
953  edm::LogError("SiStripGainFromCalibTree") << "Harvesting: could not retrieve " << tag.c_str()
954  << ", statistics will not be summed!" << std::endl;
955  } else (Charge_4[Harvest][i]).monitor->getTH1D()->Add((Charge_4[elepos][i]).monitor->getTH1D());
956  }
957 
958  }
959  }
960 }
961 
962 void
964  if(AlgoMode == "PCL" && !m_harvestingMode) return;//nothing to do in that case
965 
966  if(AlgoMode == "CalibTree"){
967  edm::LogInfo("SiStripGainFromCalibTree") << "Analyzing calibration tree" << std::endl;
968  // Loop on calibTrees to fill the 2D histograms
970  }else if(m_harvestingMode){
971  NClusterStrip = (Charge_Vs_Index[Harvest])->getTH2S()->Integral(0,NStripAPVs+1, 0, 99999 );
972  NClusterPixel = (Charge_Vs_Index[Harvest])->getTH2S()->Integral(NStripAPVs+2, NStripAPVs+NPixelDets+2, 0, 99999 );
973  }
974 
975  // Now that we have the full statistics we can extract the information of the 2D histograms
977 
978  // Result monitoring
979  qualityMonitor();
980 
981  // Force the DB object writing,
982  // thus setting the IOV as the first processed run (if timeFromEndRun is set to false)
983  storeOnDbNow();
984 
985  if(AlgoMode != "PCL" or saveSummary){
986  edm::LogInfo("SiStripGainFromCalibTree") << "Saving summary into root file" << std::endl;
987 
988  //also save the 2D monitor elements to this file as TH2D tfs
990 
991  //save only the statistics for the calibrationTag
992  int elepos = statCollectionFromMode(m_calibrationMode.c_str());
993 
994  if( Charge_Vs_Index[elepos]!=0 ) tfs->make<TH2S> ( *(Charge_Vs_Index[elepos])->getTH2S() );
995  //if( Charge_Vs_Index_Absolute[elepos]!=0 ) tfs->make<TH2S> ( *(Charge_Vs_Index_Absolute[elepos])->getTH2S() );
996  if( Charge_Vs_PathlengthTIB[elepos]!=0 ) tfs->make<TH2S> ( *(Charge_Vs_PathlengthTIB[elepos])->getTH2S() );
997  if( Charge_Vs_PathlengthTOB[elepos]!=0 ) tfs->make<TH2S> ( *(Charge_Vs_PathlengthTOB[elepos])->getTH2S() );
998  if( Charge_Vs_PathlengthTIDP[elepos]!=0 ) tfs->make<TH2S> ( *(Charge_Vs_PathlengthTIDP[elepos])->getTH2S() );
999  if( Charge_Vs_PathlengthTIDM[elepos]!=0 ) tfs->make<TH2S> ( *(Charge_Vs_PathlengthTIDM[elepos])->getTH2S() );
1000  if( Charge_Vs_PathlengthTECP1[elepos]!=0 ) tfs->make<TH2S> ( *(Charge_Vs_PathlengthTECP1[elepos])->getTH2S() );
1001  if( Charge_Vs_PathlengthTECP2[elepos]!=0 ) tfs->make<TH2S> ( *(Charge_Vs_PathlengthTECP2[elepos])->getTH2S() );
1002  if( Charge_Vs_PathlengthTECM1[elepos]!=0 ) tfs->make<TH2S> ( *(Charge_Vs_PathlengthTECM1[elepos])->getTH2S() );
1003  if( Charge_Vs_PathlengthTECM2[elepos]!=0 ) tfs->make<TH2S> ( *(Charge_Vs_PathlengthTECM2[elepos])->getTH2S() );
1004 
1005  storeOnTree(tfs);
1006  }
1007 }
1008 
1009 
1010 void SiStripGainFromCalibTree::getPeakOfLandau(TH1* InputHisto, double* FitResults, double LowRange, double HighRange)
1011 {
1012  FitResults[0] = -0.5; //MPV
1013  FitResults[1] = 0; //MPV error
1014  FitResults[2] = -0.5; //Width
1015  FitResults[3] = 0; //Width error
1016  FitResults[4] = -0.5; //Fit Chi2/NDF
1017  FitResults[5] = 0; //Normalization
1018 
1019  if( InputHisto->GetEntries() < MinNrEntries)return;
1020 
1021  // perform fit with standard landau
1022  TF1* MyLandau = new TF1("MyLandau","landau",LowRange, HighRange);
1023  MyLandau->SetParameter(1,300);
1024  InputHisto->Fit(MyLandau,"0QR WW");
1025 
1026  // MPV is parameter 1 (0=constant, 1=MPV, 2=Sigma)
1027  FitResults[0] = MyLandau->GetParameter(1); //MPV
1028  FitResults[1] = MyLandau->GetParError(1); //MPV error
1029  FitResults[2] = MyLandau->GetParameter(2); //Width
1030  FitResults[3] = MyLandau->GetParError(2); //Width error
1031  FitResults[4] = MyLandau->GetChisquare() / MyLandau->GetNDF(); //Fit Chi2/NDF
1032  FitResults[5] = MyLandau->GetParameter(0);
1033 
1034  delete MyLandau;
1035 }
1036 
1038  if(FitResults[0] <= 0 )return false;
1039 // if(FitResults[1] > MaxMPVError )return false;
1040 // if(FitResults[4] > MaxChi2OverNDF)return false;
1041  return true;
1042 }
1043 
1045 
1046  edm::LogInfo("SiStripGainFromCalibTree") << "Processing run " << runnumber
1047  << " and event " << eventnumber
1048  << " for " << m_calibrationMode << " calibration." << std::endl;
1049 
1052 
1053  NEvent++;
1054  NTrack+=(*trackp).size();
1055 
1056  int elepos = statCollectionFromMode(m_calibrationMode.c_str());
1057 
1058  unsigned int FirstAmplitude=0;
1059  for(unsigned int i=0;i<(*chargeoverpath).size();i++){
1060  FirstAmplitude+=(*nstrips)[i];
1061  int TI = (*trackindex)[i];
1062 
1063  //printf("%i - %i - %i %i %i\n", (int)(*rawid)[i], (int)(*firststrip)[i]/128, (int)(*farfromedge)[i], (int)(*overlapping)[i], (int)(*saturation )[i] );
1064  if((*tracketa )[TI] < MinTrackEta )continue;
1065  if((*tracketa )[TI] > MaxTrackEta )continue;
1066  if((*trackp )[TI] < MinTrackMomentum )continue;
1067  if((*trackp )[TI] > MaxTrackMomentum )continue;
1068  if((*trackhitsvalid)[TI] < MinTrackHits )continue;
1069  if((*trackchi2ndof )[TI] > MaxTrackChiOverNdf )continue;
1070  if((*trackalgo )[TI] > MaxTrackingIteration )continue;
1071 
1072  stAPVGain* APV = APVsColl[((*rawid)[i]<<4) | ((*firststrip)[i]/128)]; //works for both strip and pixel thanks to firstStrip encoding for pixel in the calibTree
1073 
1074  if(APV->SubDet>2 && (*farfromedge)[i] == false )continue;
1075  if(APV->SubDet>2 && (*overlapping)[i] == true )continue;
1076  if(APV->SubDet>2 && (*saturation )[i] && !AllowSaturation)continue;
1077  if(APV->SubDet>2 && (*nstrips )[i] > MaxNrStrips )continue;
1078 
1079 
1080  //printf("detId=%7i run=%7i event=%9i charge=%5i cs=%3i\n",(*rawid)[i],runnumber,eventnumber,(*charge)[i],(*nstrips)[i]);
1081 
1082  //double trans = atan2((*localdiry)[i],(*localdirx)[i])*(180/3.14159265);
1083  //double alpha = acos ((*localdirx)[i] / sqrt( pow((*localdirx)[i],2) + pow((*localdirz)[i],2) ) ) * (180/3.14159265);
1084  //double beta = acos ((*localdiry)[i] / sqrt( pow((*localdirx)[i],2) + pow((*localdirz)[i],2) ) ) * (180/3.14159265);
1085 
1086  //printf("NStrip = %i : Charge = %i --> Path = %f --> ChargeOverPath=%f\n",(*nstrips)[i],(*charge)[i],(*path)[i],(*chargeoverpath)[i]);
1087  //printf("Amplitudes: ");
1088  //for(unsigned int a=0;a<(*nstrips)[i];a++){printf("%i ",(*amplitude)[FirstAmplitude+a]);}
1089  //printf("\n");
1090 
1091  if(APV->SubDet>2){NClusterStrip++;}else{NClusterPixel++;}
1092 
1093  int Charge = 0;
1094  if(APV->SubDet>2 && (useCalibration || !FirstSetOfConstants)){
1095  bool Saturation = false;
1096  for(unsigned int s=0;s<(*nstrips)[i];s++){
1097  int StripCharge = (*amplitude)[FirstAmplitude-(*nstrips)[i]+s];
1098  if(useCalibration && !FirstSetOfConstants){ StripCharge=(int)(StripCharge*(APV->PreviousGain/APV->CalibGain));
1099  }else if(useCalibration){ StripCharge=(int)(StripCharge/APV->CalibGain);
1100  }else if(!FirstSetOfConstants){ StripCharge=(int)(StripCharge*APV->PreviousGain);}
1101  if(StripCharge>1024){
1102  StripCharge = 255;
1103  Saturation = true;
1104  }else if(StripCharge>254){
1105  StripCharge = 254;
1106  Saturation = true;
1107  }
1108  Charge += StripCharge;
1109  }
1110  if(Saturation && !AllowSaturation)continue;
1111  }else if(APV->SubDet>2){
1112  Charge = (*charge)[i];
1113  }else{
1114  Charge = (*charge)[i]/265.0; //expected scale factor between pixel and strip charge
1115  }
1116 
1117  //printf("ChargeDifference = %i Vs %i with Gain = %f\n",(*charge)[i],Charge,APV->CalibGain);
1118 
1119  double ClusterChargeOverPath = ( (double) Charge )/(*path)[i] ;
1120  if(APV->SubDet>2){
1121  if(Validation) {ClusterChargeOverPath/=(*gainused)[i];}
1122  if(OldGainRemoving){ClusterChargeOverPath*=(*gainused)[i];}
1123  }
1124  //(Charge_Vs_Index_Absolute[elepos])->Fill(APV->Index,Charge);
1125  (Charge_Vs_Index[elepos]) ->Fill(APV->Index,ClusterChargeOverPath);
1126 
1127 
1128  // Compute the charge for monitoring and fill the relative histograms
1129  int mCharge1 = 0;
1130  int mCharge2 = 0;
1131  int mCharge3 = 0;
1132  int mCharge4 = 0;
1133  if(APV->SubDet>2) {
1134  for(unsigned int s=0;s<(*nstrips)[i];s++){
1135  int StripCharge = (*amplitude)[FirstAmplitude-(*nstrips)[i]+s];
1136  if(StripCharge>1024) StripCharge = 255;
1137  else if(StripCharge>254) StripCharge = 254;
1138  mCharge1 += StripCharge;
1139  mCharge2 += StripCharge;
1140  mCharge3 += StripCharge;
1141  mCharge4 += StripCharge;
1142  }
1143  // Revome gains for monitoring
1144  mCharge2 *= (*gainused)[i]; // remove G2
1145  mCharge3 *= (*gainusedTick)[i]; // remove G1
1146  mCharge4 *= ( (*gainused)[i] * (*gainusedTick)[i]); // remove G1 and G2
1147  }
1148  std::vector<APVGain::APVmon>& v1 = Charge_1[elepos];
1149  std::vector<MonitorElement*> cmon1 = APVGain::FetchMonitor(v1, (*rawid)[i], tTopo_);
1150  for(unsigned int m=0; m<cmon1.size(); m++) cmon1[m]->Fill(( (double) mCharge1 )/(*path)[i]);
1151 
1152  std::vector<APVGain::APVmon>& v2 = Charge_2[elepos];
1153  std::vector<MonitorElement*> cmon2 = APVGain::FetchMonitor(v2, (*rawid)[i], tTopo_);
1154  for(unsigned int m=0; m<cmon2.size(); m++) cmon2[m]->Fill(( (double) mCharge2 )/(*path)[i]);
1155 
1156  std::vector<APVGain::APVmon>& v3 = Charge_3[elepos];
1157  std::vector<MonitorElement*> cmon3 = APVGain::FetchMonitor(v3, (*rawid)[i], tTopo_);
1158  for(unsigned int m=0; m<cmon3.size(); m++) cmon3[m]->Fill(( (double) mCharge3 )/(*path)[i]);
1159 
1160  std::vector<APVGain::APVmon>& v4 = Charge_4[elepos];
1161  std::vector<MonitorElement*> cmon4 = APVGain::FetchMonitor(v4, (*rawid)[i], tTopo_);
1162  for(unsigned int m=0; m<cmon4.size(); m++) cmon4[m]->Fill(( (double) mCharge4 )/(*path)[i]);
1163 
1164 
1165 
1166  // Fill Charge Vs pathLenght histograms
1167  if(APV->SubDet==StripSubdetector::TIB){
1168  (Charge_Vs_PathlengthTIB[elepos])->Fill((*path)[i],Charge); // TIB
1169 
1170  }else if(APV->SubDet==StripSubdetector::TOB){
1171  (Charge_Vs_PathlengthTOB[elepos])->Fill((*path)[i],Charge); // TOB
1172 
1173  }else if(APV->SubDet==StripSubdetector::TID){
1174  if(APV->Eta<0) { (Charge_Vs_PathlengthTIDM[elepos])->Fill((*path)[i],Charge); } // TID minus
1175  else if(APV->Eta>0){ (Charge_Vs_PathlengthTIDP[elepos])->Fill((*path)[i],Charge); } // TID plus
1176 
1177  }else if(APV->SubDet==StripSubdetector::TEC){
1178  if(APV->Eta<0){
1179  if(APV->Thickness<0.04) { (Charge_Vs_PathlengthTECM1[elepos])->Fill((*path)[i],Charge); } // TEC minus, type 1
1180  else if(APV->Thickness>0.04){ (Charge_Vs_PathlengthTECM2[elepos])->Fill((*path)[i],Charge); } // TEC minus, type 2
1181  } else if(APV->Eta>0){
1182  if(APV->Thickness<0.04) { (Charge_Vs_PathlengthTECP1[elepos])->Fill((*path)[i],Charge); } // TEC plus, type 1
1183  else if(APV->Thickness>0.04){ (Charge_Vs_PathlengthTECP2[elepos])->Fill((*path)[i],Charge); } // TEC plus, type 2
1184  }
1185  }
1186 
1187  }// END OF ON-CLUSTER LOOP
1188 }//END OF processEvent()
1189 
1191 {
1192  for(unsigned int i=0;i<VInputFiles.size();i++){
1193  printf("Openning file %3i/%3i --> %s\n",i+1, (int)VInputFiles.size(), (char*)(VInputFiles[i].c_str())); fflush(stdout);
1194  TFile *tfile = TFile::Open(VInputFiles[i].c_str());
1195  TString tree_path = TString::Format("gainCalibrationTree%s/tree",m_calibrationMode.c_str());
1196  TTree* tree = dynamic_cast<TTree*> (tfile->Get(tree_path.Data()));
1197 
1198  tree->SetBranchAddress((EventPrefix_ + "event" + EventSuffix_).c_str(), &eventnumber , NULL);
1199  tree->SetBranchAddress((EventPrefix_ + "run" + EventSuffix_).c_str(), &runnumber , NULL);
1200  tree->SetBranchAddress((EventPrefix_ + "TrigTech" + EventSuffix_).c_str(), &TrigTech , NULL);
1201 
1202  tree->SetBranchAddress((TrackPrefix_ + "chi2ndof" + TrackSuffix_).c_str(), &trackchi2ndof , NULL);
1203  tree->SetBranchAddress((TrackPrefix_ + "momentum" + TrackSuffix_).c_str(), &trackp , NULL);
1204  tree->SetBranchAddress((TrackPrefix_ + "pt" + TrackSuffix_).c_str(), &trackpt , NULL);
1205  tree->SetBranchAddress((TrackPrefix_ + "eta" + TrackSuffix_).c_str(), &tracketa , NULL);
1206  tree->SetBranchAddress((TrackPrefix_ + "phi" + TrackSuffix_).c_str(), &trackphi , NULL);
1207  tree->SetBranchAddress((TrackPrefix_ + "hitsvalid" + TrackSuffix_).c_str(), &trackhitsvalid, NULL);
1208  tree->SetBranchAddress((TrackPrefix_ + "algo" + TrackSuffix_).c_str(), &trackalgo , NULL);
1209 
1210  tree->SetBranchAddress((CalibPrefix_ + "trackindex" + CalibSuffix_).c_str(), &trackindex , NULL);
1211  tree->SetBranchAddress((CalibPrefix_ + "rawid" + CalibSuffix_).c_str(), &rawid , NULL);
1212  tree->SetBranchAddress((CalibPrefix_ + "localdirx" + CalibSuffix_).c_str(), &localdirx , NULL);
1213  tree->SetBranchAddress((CalibPrefix_ + "localdiry" + CalibSuffix_).c_str(), &localdiry , NULL);
1214  tree->SetBranchAddress((CalibPrefix_ + "localdirz" + CalibSuffix_).c_str(), &localdirz , NULL);
1215  tree->SetBranchAddress((CalibPrefix_ + "firststrip" + CalibSuffix_).c_str(), &firststrip , NULL);
1216  tree->SetBranchAddress((CalibPrefix_ + "nstrips" + CalibSuffix_).c_str(), &nstrips , NULL);
1217  tree->SetBranchAddress((CalibPrefix_ + "saturation" + CalibSuffix_).c_str(), &saturation , NULL);
1218  tree->SetBranchAddress((CalibPrefix_ + "overlapping" + CalibSuffix_).c_str(), &overlapping , NULL);
1219  tree->SetBranchAddress((CalibPrefix_ + "farfromedge" + CalibSuffix_).c_str(), &farfromedge , NULL);
1220  tree->SetBranchAddress((CalibPrefix_ + "charge" + CalibSuffix_).c_str(), &charge , NULL);
1221  tree->SetBranchAddress((CalibPrefix_ + "path" + CalibSuffix_).c_str(), &path , NULL);
1222  tree->SetBranchAddress((CalibPrefix_ + "chargeoverpath" + CalibSuffix_).c_str(), &chargeoverpath, NULL);
1223  tree->SetBranchAddress((CalibPrefix_ + "amplitude" + CalibSuffix_).c_str(), &amplitude , NULL);
1224  tree->SetBranchAddress((CalibPrefix_ + "gainused" + CalibSuffix_).c_str(), &gainused , NULL);
1225 
1226 
1227  unsigned int nentries = tree->GetEntries();
1228  printf("Number of Events = %i + %i = %i\n",NEvent,nentries,(NEvent+nentries));
1229  printf("Progressing Bar :0%% 20%% 40%% 60%% 80%% 100%%\n");
1230  printf("Looping on the Tree :");
1231  int TreeStep = nentries/50;if(TreeStep<=1)TreeStep=1;
1232  for (unsigned int ientry = 0; ientry < tree->GetEntries(); ientry++) {
1233  if(ientry%TreeStep==0){printf(".");fflush(stdout);}
1234  tree->GetEntry(ientry);
1235  processEvent();
1236  }printf("\n");// END OF EVENT LOOP
1237  }
1238 }
1239 
1240 
1241 
1243  unsigned int I=0;
1244  TH1F* Proj = NULL;
1245  double FitResults[6];
1246  double MPVmean = 300;
1247 
1248  int elepos = (AlgoMode == "PCL")? Harvest : statCollectionFromMode(m_calibrationMode.c_str());
1249 
1250  if ( Charge_Vs_Index[elepos]==0 ) {
1251  edm::LogError("SiStripGainFromCalibTree") << "Harvesting: could not execute algoComputeMPVandGain method because "
1252  << m_calibrationMode.c_str() << " statistics cannot be retrieved.\n"
1253  << "Please check if input contains "
1254  << m_calibrationMode.c_str() << " data." << std::endl;
1255  return;
1256  }
1257 
1258  TH2S *chvsidx = (Charge_Vs_Index[elepos])->getTH2S();
1259 
1260 
1261  printf("Progressing Bar :0%% 20%% 40%% 60%% 80%% 100%%\n");
1262  printf("Fitting Charge Distribution :");
1263  int TreeStep = APVsColl.size()/50;
1264  for(auto it = APVsColl.begin();it!=APVsColl.end();it++,I++){
1265  if(I%TreeStep==0){printf(".");fflush(stdout);}
1266  stAPVGain* APV = it->second;
1267  if(APV->Bin<0) APV->Bin = chvsidx->GetXaxis()->FindBin(APV->Index);
1268 
1269  if(APV->isMasked){APV->Gain=APV->PreviousGain; MASKED++; continue;}
1270 
1271  Proj = (TH1F*)(chvsidx->ProjectionY("",chvsidx->GetXaxis()->FindBin(APV->Index),chvsidx->GetXaxis()->FindBin(APV->Index),"e"));
1272  if(!Proj)continue;
1273 
1274  if(CalibrationLevel==0){
1275  }else if(CalibrationLevel==1){
1276  int SecondAPVId = APV->APVId;
1277  if(SecondAPVId%2==0){ SecondAPVId = SecondAPVId+1; }else{ SecondAPVId = SecondAPVId-1; }
1278  stAPVGain* APV2 = APVsColl[(APV->DetId<<4) | SecondAPVId];
1279  if(APV2->Bin<0) APV2->Bin = chvsidx->GetXaxis()->FindBin(APV2->Index);
1280  TH1F* Proj2 = (TH1F*)(chvsidx->ProjectionY("",APV2->Bin,APV2->Bin,"e"));
1281  if(Proj2){Proj->Add(Proj2,1);delete Proj2;}
1282  }else if(CalibrationLevel==2){
1283  for(unsigned int i=0;i<16;i++){ //loop up to 6APV for Strip and up to 16 for Pixels
1284  auto tmpit = APVsColl.find((APV->DetId<<4) | i);
1285  if(tmpit==APVsColl.end())continue;
1286  stAPVGain* APV2 = tmpit->second;
1287  if(APV2->DetId != APV->DetId || APV2->APVId == APV->APVId)continue;
1288  if(APV2->Bin<0) APV2->Bin = chvsidx->GetXaxis()->FindBin(APV2->Index);
1289  TH1F* Proj2 = (TH1F*)(chvsidx->ProjectionY("",APV2->Bin,APV2->Bin,"e"));
1290  if(Proj2){Proj->Add(Proj2,1);delete Proj2;}
1291  }
1292  }else{
1293  CalibrationLevel = 0;
1294  printf("Unknown Calibration Level, will assume %i\n",CalibrationLevel);
1295  }
1296 
1297  getPeakOfLandau(Proj,FitResults);
1298  APV->FitMPV = FitResults[0];
1299  APV->FitMPVErr = FitResults[1];
1300  APV->FitWidth = FitResults[2];
1301  APV->FitWidthErr = FitResults[3];
1302  APV->FitChi2 = FitResults[4];
1303  APV->FitNorm = FitResults[5];
1304  APV->NEntries = Proj->GetEntries();
1305 
1306  if(IsGoodLandauFit(FitResults)){
1307  APV->Gain = APV->FitMPV / MPVmean;
1308  if(APV->SubDet>2)GOOD++;
1309  }else{
1310  APV->Gain = APV->PreviousGain;
1311  if(APV->SubDet>2)BAD++;
1312  }
1313  if(APV->Gain<=0) APV->Gain = 1;
1314 
1315  //printf("%5i/%5i: %6i - %1i %5E Entries --> MPV = %f +- %f\n",I,APVsColl.size(),APV->DetId, APV->APVId, Proj->GetEntries(), FitResults[0], FitResults[1]);fflush(stdout);
1316  delete Proj;
1317  }printf("\n");
1318 }
1319 
1321 
1322  int elepos = (AlgoMode == "PCL")? Harvest : statCollectionFromMode(m_calibrationMode.c_str());
1323 
1324  for(unsigned int a=0;a<APVsCollOrdered.size();a++) {
1326  if(APV==NULL)continue;
1327 
1328  unsigned int Index = APV->Index;
1329  unsigned int SubDet = APV->SubDet;
1330  unsigned int DetId = APV->DetId;
1331  float z = APV->z;
1332  float Eta = APV->Eta;
1333  float R = APV->R;
1334  float Phi = APV->Phi;
1335  float Thickness = APV->Thickness;
1336  double FitMPV = APV->FitMPV;
1337  double FitMPVErr = APV->FitMPVErr;
1338  double Gain = APV->Gain;
1339  double NEntries = APV->NEntries;
1340  double PreviousGain = APV->PreviousGain;
1341 
1342  if (SubDet<3) continue; // avoid to loop over Pixel det id
1343 
1344  if (Gain!=1.) {
1345  std::vector<MonitorElement*> charge_histos = APVGain::FetchMonitor(newCharge, DetId, tTopo_);
1346  TH2S *chvsidx = (Charge_Vs_Index[elepos])->getTH2S();
1347  int bin = chvsidx->GetXaxis()->FindBin(Index);
1348  TH1D* Proj = chvsidx->ProjectionY("proj",bin,bin);
1349  for (int binId=0; binId<Proj->GetXaxis()->GetNbins();binId++) {
1350  double new_charge = Proj->GetXaxis()->GetBinCenter(binId) / Gain;
1351  if (Proj->GetBinContent(binId)!=0.) {
1352  for (unsigned int h=0;h<charge_histos.size();h++) {
1353  TH1D* chisto = (charge_histos[h])->getTH1D();
1354  for (int e=0;e<Proj->GetBinContent(binId);e++) chisto->Fill(new_charge);
1355  }
1356  }
1357  }
1358  }
1359 
1360 
1361  if (FitMPV<0.) { // No fit of MPV
1362  NoMPV->Fill(z,R);
1363 
1364  } else { // Fit of MPV
1365  if(FitMPV>0.) Gains->Fill(Gain);
1366 
1367  MPVs->Fill(FitMPV);
1368  if(Thickness<0.04) MPVs320->Fill(Phi,FitMPV);
1369  if(Thickness>0.04) MPVs500->Fill(Phi,FitMPV);
1370 
1371  MPVError->Fill(FitMPVErr);
1372  MPVErrorVsMPV->Fill(FitMPV,FitMPVErr);
1373  MPVErrorVsEta->Fill(Eta,FitMPVErr);
1374  MPVErrorVsPhi->Fill(Phi,FitMPVErr);
1375  MPVErrorVsN->Fill(NEntries,FitMPVErr);
1376 
1377  if(SubDet==3) {
1378  MPV_Vs_EtaTIB->Fill(Eta,FitMPV);
1379  MPV_Vs_PhiTIB->Fill(Phi,FitMPV);
1380  MPVsTIB->Fill(FitMPV);
1381 
1382  } else if(SubDet==4) {
1383  MPV_Vs_EtaTID->Fill(Eta,FitMPV);
1384  MPV_Vs_PhiTID->Fill(Phi,FitMPV);
1385  MPVsTID->Fill(FitMPV);
1386  if(Eta<0.) MPVsTIDM->Fill(FitMPV);
1387  if(Eta>0.) MPVsTIDP->Fill(FitMPV);
1388 
1389  } else if (SubDet==5) {
1390  MPV_Vs_EtaTOB->Fill(Eta,FitMPV);
1391  MPV_Vs_PhiTOB->Fill(Phi,FitMPV);
1392  MPVsTOB->Fill(FitMPV);
1393 
1394  } else if (SubDet==6) {
1395  MPV_Vs_EtaTEC->Fill(Eta,FitMPV);
1396  MPV_Vs_PhiTEC->Fill(Phi,FitMPV);
1397  MPVsTEC->Fill(FitMPV);
1398  if(Eta<0.) MPVsTECM->Fill(FitMPV);
1399  if(Eta>0.) MPVsTECP->Fill(FitMPV);
1400  if(Thickness<0.04) {
1401  MPV_Vs_EtaTECthin->Fill(Eta,FitMPV);
1402  MPV_Vs_PhiTECthin->Fill(Phi,FitMPV);
1403  MPVsTECthin->Fill(FitMPV);
1404  if(Eta>0.) MPVsTECP1->Fill(FitMPV);
1405  if(Eta<0.) MPVsTECM1->Fill(FitMPV);
1406  }
1407  if(Thickness>0.04) {
1408  MPV_Vs_EtaTECthick->Fill(Eta,FitMPV);
1409  MPV_Vs_PhiTECthick->Fill(Phi,FitMPV);
1410  MPVsTECthick->Fill(FitMPV);
1411  if(Eta>0.) MPVsTECP2->Fill(FitMPV);
1412  if(Eta<0.) MPVsTECM2->Fill(FitMPV);
1413  }
1414  }
1415  }
1416 
1417  if(SubDet==3 && PreviousGain!=0. ) DiffWRTPrevGainTIB->Fill(Gain/PreviousGain);
1418  else if(SubDet==4 && PreviousGain!=0. ) DiffWRTPrevGainTID->Fill(Gain/PreviousGain);
1419  else if(SubDet==5 && PreviousGain!=0. ) DiffWRTPrevGainTOB->Fill(Gain/PreviousGain);
1420  else if(SubDet==6 && PreviousGain!=0. ) DiffWRTPrevGainTEC->Fill(Gain/PreviousGain);
1421 
1422  if(SubDet==3 ) GainVsPrevGainTIB->Fill(PreviousGain,Gain);
1423  else if(SubDet==4 ) GainVsPrevGainTID->Fill(PreviousGain,Gain);
1424  else if(SubDet==5 ) GainVsPrevGainTOB->Fill(PreviousGain,Gain);
1425  else if(SubDet==6 ) GainVsPrevGainTEC->Fill(PreviousGain,Gain);
1426  }
1427 }
1428 
1430 {
1431  unsigned int tree_Index;
1432  unsigned int tree_Bin;
1433  unsigned int tree_DetId;
1434  unsigned char tree_APVId;
1435  unsigned char tree_SubDet;
1436  float tree_x;
1437  float tree_y;
1438  float tree_z;
1439  float tree_Eta;
1440  float tree_R;
1441  float tree_Phi;
1442  float tree_Thickness;
1443  float tree_FitMPV;
1444  float tree_FitMPVErr;
1445  float tree_FitWidth;
1446  float tree_FitWidthErr;
1447  float tree_FitChi2NDF;
1448  float tree_FitNorm;
1449  double tree_Gain;
1450  double tree_PrevGain;
1451  double tree_PrevGainTick;
1452  double tree_NEntries;
1453  bool tree_isMasked;
1454 
1455  TTree* MyTree;
1456  MyTree = tfs->make<TTree> ("APVGain","APVGain");
1457  MyTree->Branch("Index" ,&tree_Index ,"Index/i");
1458  MyTree->Branch("Bin" ,&tree_Bin ,"Bin/i");
1459  MyTree->Branch("DetId" ,&tree_DetId ,"DetId/i");
1460  MyTree->Branch("APVId" ,&tree_APVId ,"APVId/b");
1461  MyTree->Branch("SubDet" ,&tree_SubDet ,"SubDet/b");
1462  MyTree->Branch("x" ,&tree_x ,"x/F");
1463  MyTree->Branch("y" ,&tree_y ,"y/F");
1464  MyTree->Branch("z" ,&tree_z ,"z/F");
1465  MyTree->Branch("Eta" ,&tree_Eta ,"Eta/F");
1466  MyTree->Branch("R" ,&tree_R ,"R/F");
1467  MyTree->Branch("Phi" ,&tree_Phi ,"Phi/F");
1468  MyTree->Branch("Thickness" ,&tree_Thickness ,"Thickness/F");
1469  MyTree->Branch("FitMPV" ,&tree_FitMPV ,"FitMPV/F");
1470  MyTree->Branch("FitMPVErr" ,&tree_FitMPVErr ,"FitMPVErr/F");
1471  MyTree->Branch("FitWidth" ,&tree_FitWidth ,"FitWidth/F");
1472  MyTree->Branch("FitWidthErr" ,&tree_FitWidthErr,"FitWidthErr/F");
1473  MyTree->Branch("FitChi2NDF" ,&tree_FitChi2NDF ,"FitChi2NDF/F");
1474  MyTree->Branch("FitNorm" ,&tree_FitNorm ,"FitNorm/F");
1475  MyTree->Branch("Gain" ,&tree_Gain ,"Gain/D");
1476  MyTree->Branch("PrevGain" ,&tree_PrevGain ,"PrevGain/D");
1477  MyTree->Branch("PrevGainTick" ,&tree_PrevGainTick,"PrevGainTick/D");
1478  MyTree->Branch("NEntries" ,&tree_NEntries ,"NEntries/D");
1479  MyTree->Branch("isMasked" ,&tree_isMasked ,"isMasked/O");
1480 
1481 
1482  FILE* Gains = stdout;
1483  fprintf(Gains,"NEvents = %i\n",NEvent);
1484  fprintf(Gains,"NTracks = %i\n",NTrack);
1485  fprintf(Gains,"NClustersPixel = %i\n",NClusterPixel);
1486  fprintf(Gains,"NClustersStrip = %i\n",NClusterStrip);
1487  fprintf(Gains,"Number of Pixel Dets = %lu\n",static_cast<unsigned long>(NPixelDets));
1488  fprintf(Gains,"Number of Strip APVs = %lu\n",static_cast<unsigned long>(NStripAPVs));
1489  fprintf(Gains,"GoodFits = %i BadFits = %i ratio = %f%% (MASKED=%i)\n",GOOD,BAD,(100.0*GOOD)/(GOOD+BAD), MASKED);
1490 
1491  Gains=fopen(OutputGains.c_str(),"w");
1492  fprintf(Gains,"NEvents = %i\n",NEvent);
1493  fprintf(Gains,"NTracks = %i\n",NTrack);
1494  fprintf(Gains,"NClustersPixel = %i\n",NClusterPixel);
1495  fprintf(Gains,"NClustersStrip = %i\n",NClusterStrip);
1496  fprintf(Gains,"Number of Strip APVs = %lu\n",static_cast<unsigned long>(NStripAPVs));
1497  fprintf(Gains,"Number of Pixel Dets = %lu\n",static_cast<unsigned long>(NPixelDets));
1498  fprintf(Gains,"GoodFits = %i BadFits = %i ratio = %f%% (MASKED=%i)\n",GOOD,BAD,(100.0*GOOD)/(GOOD+BAD), MASKED);
1499 
1500  int elepos = statCollectionFromMode(m_calibrationMode.c_str());
1501 
1502  for(unsigned int a=0;a<APVsCollOrdered.size();a++){
1504  if(APV==NULL)continue;
1505 // printf( "%i | %i | PreviousGain = %7.5f NewGain = %7.5f (#clusters=%8.0f)\n", APV->DetId,APV->APVId,APV->PreviousGain,APV->Gain, APV->NEntries);
1506  fprintf(Gains,"%i | %i | PreviousGain = %7.5f(tick) x %7.5f(particle) NewGain (particle) = %7.5f (#clusters=%8.0f)\n", APV->DetId,APV->APVId,APV->PreviousGainTick, APV->PreviousGain,APV->Gain, APV->NEntries);
1507 
1508  tree_Index = APV->Index;
1509  tree_Bin = (Charge_Vs_Index[elepos])->getTH2S()->GetXaxis()->FindBin(APV->Index);
1510  tree_DetId = APV->DetId;
1511  tree_APVId = APV->APVId;
1512  tree_SubDet = APV->SubDet;
1513  tree_x = APV->x;
1514  tree_y = APV->y;
1515  tree_z = APV->z;
1516  tree_Eta = APV->Eta;
1517  tree_R = APV->R;
1518  tree_Phi = APV->Phi;
1519  tree_Thickness = APV->Thickness;
1520  tree_FitMPV = APV->FitMPV;
1521  tree_FitMPVErr = APV->FitMPVErr;
1522  tree_FitWidth = APV->FitWidth;
1523  tree_FitWidthErr= APV->FitWidthErr;
1524  tree_FitChi2NDF = APV->FitChi2;
1525  tree_FitNorm = APV->FitNorm;
1526  tree_Gain = APV->Gain;
1527  tree_PrevGain = APV->PreviousGain;
1528  tree_PrevGainTick = APV->PreviousGainTick;
1529  tree_NEntries = APV->NEntries;
1530  tree_isMasked = APV->isMasked;
1531 
1532 
1533  if(tree_DetId==402673324){
1534  printf("%i | %i : %f --> %f (%f)\n", tree_DetId, tree_APVId, tree_PrevGain, tree_Gain, tree_NEntries);
1535  }
1536 
1537 
1538  MyTree->Fill();
1539  }
1540  if(Gains)fclose(Gains);
1541 
1542 
1543 }
1544 
1546 
1547  // The goal of this function is to check wether or not there is enough statistics
1548  // to produce a meaningful tag for the DB
1549  int elepos = (AlgoMode == "PCL")? Harvest : statCollectionFromMode(m_calibrationMode.c_str());
1550  if( Charge_Vs_Index[elepos]==0 ) {
1551  edm::LogError("SiStripGainFromCalibTree") << "produceTagFilter -> Return false: could not retrieve the "
1552  << m_calibrationMode.c_str() << " statistics.\n"
1553  << "Please check if input contains "
1554  << m_calibrationMode.c_str() << " data." << std::endl;
1555  return false;
1556  }
1557 
1558 
1559  float integral = (Charge_Vs_Index[elepos])->getTH2S()->Integral();
1560  if( (Charge_Vs_Index[elepos])->getTH2S()->Integral(0,NStripAPVs+1, 0, 99999 ) < tagCondition_NClusters) {
1561  edm::LogWarning("SiStripGainFromCalibTree")
1562  << "calibrationMode -> " << m_calibrationMode << "\n"
1563  << "produceTagFilter -> Return false: Statistics is too low : " << integral << endl;
1564  return false;
1565  }
1566  if((1.0 * GOOD) / (GOOD+BAD) < tagCondition_GoodFrac) {
1567  edm::LogWarning("SiStripGainFromCalibTree")
1568  << "calibrationMode -> " << m_calibrationMode << "\n"
1569  << "produceTagFilter -> Return false: ratio of GOOD/TOTAL is too low: " << (1.0 * GOOD) / (GOOD+BAD) << endl;
1570  return false;
1571  }
1572  return true;
1573 }
1574 
1576 {
1578  if(!m_harvestingMode) return obj;
1579 
1580  if(!produceTagFilter()){
1581  edm::LogWarning("SiStripGainFromCalibTree")<< "getNewObject -> will not produce a paylaod because produceTagFilter returned false " << endl;
1582  setDoStore(false);
1583  return obj;
1584  }
1585 
1586 
1587  std::vector<float>* theSiStripVector = NULL;
1588  unsigned int PreviousDetId = 0;
1589  for(unsigned int a=0;a<APVsCollOrdered.size();a++){
1591  if(APV==NULL){ printf("Bug\n"); continue; }
1592  if(APV->SubDet<=2)continue;
1593  if(APV->DetId != PreviousDetId){
1594  if(theSiStripVector!=NULL){
1595  SiStripApvGain::Range range(theSiStripVector->begin(),theSiStripVector->end());
1596  if ( !obj->put(PreviousDetId,range) ) printf("Bug to put detId = %i\n",PreviousDetId);
1597  }
1598  theSiStripVector = new std::vector<float>;
1599  PreviousDetId = APV->DetId;
1600  }
1601  theSiStripVector->push_back(APV->Gain);
1602  }
1603  if(theSiStripVector!=NULL){
1604  SiStripApvGain::Range range(theSiStripVector->begin(),theSiStripVector->end());
1605  if ( !obj->put(PreviousDetId,range) ) printf("Bug to put detId = %i\n",PreviousDetId);
1606  }
1607 
1608  if (theSiStripVector!=NULL) delete theSiStripVector;
1609 
1610  return obj;
1611 }
1612 
1613 
1615 {
1616  APVsColl.clear();
1617  for(unsigned int a=0;a<APVsCollOrdered.size();a++) {
1619  if(APV!=NULL) delete APV;
1620  }
1621  APVsCollOrdered.clear();
1622 }
1623 
1624 
1626  if(!useCalibration)return;
1627 
1628  TChain* t1 = new TChain("SiStripCalib/APVGain");
1629  t1->Add(m_calibrationPath.c_str());
1630 
1631  unsigned int tree_DetId;
1632  unsigned char tree_APVId;
1633  double tree_Gain;
1634 
1635  t1->SetBranchAddress("DetId" ,&tree_DetId );
1636  t1->SetBranchAddress("APVId" ,&tree_APVId );
1637  t1->SetBranchAddress("Gain" ,&tree_Gain );
1638 
1639  for (unsigned int ientry = 0; ientry < t1->GetEntries(); ientry++) {
1640  t1->GetEntry(ientry);
1641  stAPVGain* APV = APVsColl[(tree_DetId<<4) | (unsigned int)tree_APVId];
1642  APV->CalibGain = tree_Gain;
1643  }
1644 
1645  delete t1;
1646 }
1647 
1648 void
1650 {
1651  // in AlCaHarvesting mode we just need to run the logic in the endJob step
1652  if(m_harvestingMode) return;
1653 
1654  if(AlgoMode=="CalibTree")return;
1655 
1656  eventnumber = iEvent.id().event();
1657  runnumber = iEvent.id().run();
1658  auto handle01 = connect(TrigTech , TrigTech_token_ , iEvent);
1659  auto handle02 = connect(trackchi2ndof , trackchi2ndof_token_ , iEvent);
1660  auto handle03 = connect(trackp , trackp_token_ , iEvent);
1661  auto handle04 = connect(trackpt , trackpt_token_ , iEvent);
1662  auto handle05 = connect(tracketa , tracketa_token_ , iEvent);
1663  auto handle06 = connect(trackphi , trackphi_token_ , iEvent);
1664  auto handle07 = connect(trackhitsvalid, trackhitsvalid_token_, iEvent);
1665  auto handle08 = connect(trackindex , trackindex_token_ , iEvent);
1666  auto handle09 = connect(rawid , rawid_token_ , iEvent);
1667  auto handle11 = connect(localdirx , localdirx_token_ , iEvent);
1668  auto handle12 = connect(localdiry , localdiry_token_ , iEvent);
1669  auto handle13 = connect(localdirz , localdirz_token_ , iEvent);
1670  auto handle14 = connect(firststrip , firststrip_token_ , iEvent);
1671  auto handle15 = connect(nstrips , nstrips_token_ , iEvent);
1672  auto handle16 = connect(saturation , saturation_token_ , iEvent);
1673  auto handle17 = connect(overlapping , overlapping_token_ , iEvent);
1674  auto handle18 = connect(farfromedge , farfromedge_token_ , iEvent);
1675  auto handle19 = connect(charge , charge_token_ , iEvent);
1676  auto handle21 = connect(path , path_token_ , iEvent);
1677  auto handle22 = connect(chargeoverpath, chargeoverpath_token_, iEvent);
1678  auto handle23 = connect(amplitude , amplitude_token_ , iEvent);
1679  auto handle24 = connect(gainused , gainused_token_ , iEvent);
1680  auto handle25 = connect(gainusedTick , gainusedTick_token_ , iEvent);
1681  auto handle26 = connect(trackalgo , trackalgo_token_ , iEvent);
1682 
1683  processEvent();
1684 }
1685 
RunNumber_t run() const
Definition: EventID.h:39
bool IsApvBad(const uint32_t &detid, const short &apvNb) const
edm::EDGetTokenT< std::vector< int > > trackindex_token_
std::vector< MonitorElement * > Charge_Vs_Index
T getParameter(std::string const &) const
EventNumber_t event() const
Definition: EventID.h:41
T getUntrackedParameter(std::string const &, T const &) const
virtual int nrows() const =0
const std::vector< float > * trackp
edm::EDGetTokenT< std::vector< double > > tracketa_token_
edm::EDGetTokenT< std::vector< unsigned char > > amplitude_token_
std::vector< APVGain::APVmon > newCharge
const std::vector< double > * chargeoverpath
double FitMPV
Definition: APVGainStruct.h:19
edm::EDGetTokenT< std::vector< unsigned int > > rawid_token_
const std::vector< unsigned char > * amplitude
bool isBFieldConsistentWithMode(const edm::EventSetup &iSetup) const
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
double PreviousGainTick
Definition: APVGainStruct.h:28
SiStripApvGain * getNewObject() override
const std::vector< double > * localdirz
size_t getNumberOfTags() const
Definition: SiStripGain.h:87
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:460
const std::vector< double > * trackchi2ndof
virtual void algoBeginRun(const edm::Run &run, const edm::EventSetup &iSetup) override
const std::vector< double > * localdirx
const std::vector< double > * gainusedTick
dispatcher processEvent(e, inputTag, standby)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
unsigned int APVId
Definition: APVGainStruct.h:10
float Thickness
Definition: APVGainStruct.h:18
virtual void algoEndRun(const edm::Run &run, const edm::EventSetup &iSetup) override
const std::vector< unsigned int > * rawid
edm::EDGetTokenT< std::vector< bool > > overlapping_token_
SiStripGainFromCalibTree(const edm::ParameterSet &)
const TrackerTopology * tTopo_
edm::Handle< T > connect(const T *&ptr, edm::EDGetTokenT< T > token, const edm::Event &evt)
int subdetectorPlane(uint32_t, const TrackerTopology *)
const std::vector< int > * trackalgo
std::vector< MonitorElement * > Charge_Vs_PathlengthTOB
#define NULL
Definition: scimark2.h:8
void storeOnTree(TFileService *tfs)
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
const std::vector< float > * trackpt
std::vector< MonitorElement * > Charge_Vs_PathlengthTECM1
unsigned int DetId
Definition: APVGainStruct.h:9
const std::vector< unsigned int > * trackhitsvalid
std::vector< MonitorElement * > Charge_Vs_PathlengthTECM2
bool isMasked
Definition: APVGainStruct.h:32
void Fill(long long x)
static float getApvGain(const uint16_t &apv, const SiStripApvGain::Range &range)
Definition: SiStripGain.h:69
edm::EDGetTokenT< std::vector< bool > > farfromedge_token_
bool put(const uint32_t &detID, Range input)
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 int > > trackhitsvalid_token_
T x() const
Cartesian x coordinate.
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)
std::vector< stAPVGain * > APVsCollOrdered
edm::EDGetTokenT< std::vector< double > > path_token_
double FitWidth
Definition: APVGainStruct.h:21
int iEvent
Definition: GenABIO.cc:230
double Gain
Definition: APVGainStruct.h:25
edm::EDGetTokenT< std::vector< int > > trackalgo_token_
double PreviousGain
Definition: APVGainStruct.h:27
edm::EDGetTokenT< std::vector< float > > trackp_token_
bool IsGoodLandauFit(double *FitResults)
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
std::unordered_map< unsigned int, stAPVGain * > APVsColl
unsigned int Index
Definition: APVGainStruct.h:7
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
Definition: tfile.py:1
double FitNorm
Definition: APVGainStruct.h:24
double CalibGain
Definition: APVGainStruct.h:26
std::array< std::vector< APVGain::APVmon >, 7 > Charge_3
virtual void algoBeginJob(const edm::EventSetup &iSetup) override
std::pair< ContainerIterator, ContainerIterator > Range
edm::EDGetTokenT< std::vector< bool > > TrigTech_token_
edm::EDGetTokenT< std::vector< double > > chargeoverpath_token_
const std::complex< double > I
Definition: I.h:8
edm::EDGetTokenT< std::vector< double > > gainusedTick_token_
const std::vector< double > * gainused
double FitMPVErr
Definition: APVGainStruct.h:20
std::vector< MonitorElement * > Charge_Vs_PathlengthTECP1
edm::EDGetTokenT< std::vector< double > > localdirz_token_
static const std::string B
const std::vector< unsigned short > * firststrip
std::vector< MonitorElement * > Charge_Vs_PathlengthTIDM
const std::vector< double > * localdiry
std::array< std::vector< APVGain::APVmon >, 7 > Charge_2
edm::EDGetTokenT< std::vector< unsigned int > > charge_token_
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
Integral< F, X >::type integral(const F &f)
Definition: Integral.h:69
def elem(elemtype, innerHTML='', html_class='', kwargs)
Definition: HTMLExport.py:18
double FitChi2
Definition: APVGainStruct.h:23
bin
set the eta bin as selection string.
virtual void algoEndJob() override
edm::EDGetTokenT< std::vector< unsigned short > > nstrips_token_
std::vector< MonitorElement * > Charge_Vs_PathlengthTECP2
const std::vector< int > * trackindex
Definition: DetId.h:18
int statCollectionFromMode(const char *tag) const
std::vector< MonitorElement * > Charge_Vs_PathlengthTIB
edm::EDGetTokenT< std::vector< unsigned short > > firststrip_token_
virtual void algoAnalyze(const edm::Event &, const edm::EventSetup &) override
edm::EDGetTokenT< std::vector< float > > trackpt_token_
T const * product() const
Definition: Handle.h:81
const std::vector< bool > * overlapping
const std::vector< bool > * saturation
virtual int nstrips() const =0
bool merge(LuminosityBlockRange &lh, LuminosityBlockRange &rh)
void getPeakOfLandau(TH1 *InputHisto, double *FitResults, double LowRange=50, double HighRange=5400)
const T & get() const
Definition: EventSetup.h:55
int subdetectorSide(uint32_t, const TrackerTopology *)
double NEntries
Definition: APVGainStruct.h:29
const std::vector< bool > * farfromedge
float m_avg_current
Definition: RunInfo.h:29
const std::vector< bool > * TrigTech
void setDoStore(const bool doStore)
When set to false the payload will not be written to the db.
edm::EventID id() const
Definition: EventBase.h:60
fixed size matrix
HLT enums.
virtual int ncolumns() const =0
double a
Definition: hdecay.h:121
std::vector< std::string > VChargeHisto
edm::EDGetTokenT< std::vector< double > > localdirx_token_
edm::EDGetTokenT< std::vector< bool > > saturation_token_
edm::EDGetTokenT< std::vector< double > > trackchi2ndof_token_
std::vector< MonitorElement * > Charge_Vs_PathlengthTIDP
edm::EDGetTokenT< std::vector< double > > localdiry_token_
Definition: tree.py:1
const std::vector< unsigned int > * charge
std::vector< std::pair< std::string, std::string > > monHnames(std::vector< std::string >, bool, const char *tag)
bool isValid() const
Definition: ESHandle.h:47
const std::vector< double > * path
long double T
const std::vector< double > * trackphi
std::array< std::vector< APVGain::APVmon >, 7 > Charge_4
unsigned int SubDet
Definition: APVGainStruct.h:11
const std::vector< unsigned short > * nstrips
T const * product() const
Definition: ESHandle.h:86
edm::EDGetTokenT< std::vector< double > > gainused_token_
int subdetectorId(uint32_t)
void bookDQMHistos(const char *dqm_dir, const char *tag)
edm::EDGetTokenT< std::vector< double > > trackphi_token_
const std::vector< double > * tracketa
Definition: Run.h:42
double FitWidthErr
Definition: APVGainStruct.h:22
const SiStripApvGain::Range getRange(uint32_t detID) const
Definition: SiStripGain.h:66
std::array< std::vector< APVGain::APVmon >, 7 > Charge_1