CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
31 
33 
36 
49 
52 
55 
60 
63 
66 
67 
68 #include "TFile.h"
69 #include "TObjString.h"
70 #include "TString.h"
71 #include "TH1F.h"
72 #include "TH2S.h"
73 #include "TProfile.h"
74 #include "TF1.h"
75 #include "TROOT.h"
76 #include "TTree.h"
77 #include "TChain.h"
78 
79 #include <unordered_map>
80 
81 
82 
83 using namespace edm;
84 using namespace reco;
85 using namespace std;
86 
87 struct stAPVGain{
88  unsigned int Index;
89  int Bin;
90  unsigned int DetId;
91  unsigned int APVId;
92  unsigned int SubDet;
93  float x;
94  float y;
95  float z;
96  float Eta;
97  float R;
98  float Phi;
99  float Thickness;
100  double FitMPV;
101  double FitMPVErr;
102  double FitWidth;
103  double FitWidthErr;
104  double FitChi2;
105  double FitNorm;
106  double Gain;
107  double CalibGain;
108  double PreviousGain;
109  double PreviousGainTick;
110  double NEntries;
111  TH1F* HCharge;
112  TH1F* HChargeN;
113  bool isMasked;
114 };
115 
116 class SiStripGainFromCalibTree : public ConditionDBWriter<SiStripApvGain> {
117 public:
120 
121 
122 private:
123 
124 
125  virtual void algoBeginRun(const edm::Run& run, const edm::EventSetup& iSetup) override;
126  virtual void algoEndRun (const edm::Run& run, const edm::EventSetup& iSetup) override;
127  virtual void algoBeginJob (const edm::EventSetup& iSetup) override;
128  virtual void algoEndJob () override;
129  virtual void algoAnalyze (const edm::Event &, const edm::EventSetup &) override;
130 
131  int statCollectionFromMode(const char* tag) const;
132  void bookDQMHistos(const char* dqm_dir, const char* tag);
133 
134  bool isBFieldConsistentWithMode( const edm::EventSetup& iSetup) const;
135  void swapBFieldMode(void);
136 
137  void merge(TH2* A, TH2* B); //needed to add histograms with different number of bins
138  void algoAnalyzeTheTree();
139  void algoComputeMPVandGain();
140  void processEvent(); //what really does the job
141 
142  void getPeakOfLandau(TH1* InputHisto, double* FitResults, double LowRange=50, double HighRange=5400);
143  bool IsGoodLandauFit(double* FitResults);
144  void storeOnTree(TFileService* tfs);
145  void MakeCalibrationMap();
146  bool produceTagFilter();
147 
148  template<typename T>
149  inline edm::Handle<T> connect(const T* &ptr, edm::EDGetTokenT<T> token, const edm::Event &evt) {
151  evt.getByToken(token, handle);
152  ptr = handle.product();
153  return handle; //return handle to keep alive pointer (safety first)
154  }
155 
156  SiStripApvGain* getNewObject() override;
157 
161  double MinNrEntries;
162  double MaxMPVError;
166  double MinTrackEta;
167  double MaxTrackEta;
168  unsigned int MaxNrStrips;
169  unsigned int MinTrackHits;
177 
184  string m_DQMdir;
185 
188 
191  vector<string> VInputFiles;
192 
194 
195  std::vector<string> dqm_tag_;
197 
198  std::vector<MonitorElement*> Charge_Vs_Index;
199  //std::vector<MonitorElement*> Charge_Vs_Index_Absolute;
200  std::vector<MonitorElement*> Charge_Vs_PathlengthTIB;
201  std::vector<MonitorElement*> Charge_Vs_PathlengthTOB;
202  std::vector<MonitorElement*> Charge_Vs_PathlengthTIDP;
203  std::vector<MonitorElement*> Charge_Vs_PathlengthTIDM;
204  std::vector<MonitorElement*> Charge_Vs_PathlengthTECP1;
205  std::vector<MonitorElement*> Charge_Vs_PathlengthTECP2;
206  std::vector<MonitorElement*> Charge_Vs_PathlengthTECM1;
207  std::vector<MonitorElement*> Charge_Vs_PathlengthTECM2;
208 
209  unsigned int NEvent;
210  unsigned int NTrack;
211  unsigned int NClusterStrip;
212  unsigned int NClusterPixel;
215  unsigned int SRun;
216  unsigned int ERun;
217  unsigned int GOOD;
218  unsigned int BAD;
219  unsigned int MASKED;
220 
221  //Data members for processing
222 
223  //Event data
224  unsigned int eventnumber =0;
225  unsigned int runnumber =0;
226  const std::vector<bool>* TrigTech =0; edm::EDGetTokenT<std::vector<bool> > TrigTech_token_;
227 
228  // Track data
229  const std::vector<double>* trackchi2ndof =0; edm::EDGetTokenT<std::vector<double> > trackchi2ndof_token_;
230  const std::vector<float>* trackp =0; edm::EDGetTokenT<std::vector<float> > trackp_token_;
231  const std::vector<float>* trackpt =0; edm::EDGetTokenT<std::vector<float> > trackpt_token_;
232  const std::vector<double>* tracketa =0; edm::EDGetTokenT<std::vector<double> > tracketa_token_;
233  const std::vector<double>* trackphi =0; edm::EDGetTokenT<std::vector<double> > trackphi_token_;
234  const std::vector<unsigned int>* trackhitsvalid =0; edm::EDGetTokenT<std::vector<unsigned int> > trackhitsvalid_token_;
235  const std::vector<int>* trackalgo =0; edm::EDGetTokenT<std::vector<int> > trackalgo_token_;
236 
237  // CalibTree data
238  const std::vector<int>* trackindex =0; edm::EDGetTokenT<std::vector<int> > trackindex_token_;
239  const std::vector<unsigned int>* rawid =0; edm::EDGetTokenT<std::vector<unsigned int> > rawid_token_;
240  const std::vector<double>* localdirx =0; edm::EDGetTokenT<std::vector<double> > localdirx_token_;
241  const std::vector<double>* localdiry =0; edm::EDGetTokenT<std::vector<double> > localdiry_token_;
242  const std::vector<double>* localdirz =0; edm::EDGetTokenT<std::vector<double> > localdirz_token_;
243  const std::vector<unsigned short>* firststrip =0; edm::EDGetTokenT<std::vector<unsigned short> > firststrip_token_;
244  const std::vector<unsigned short>* nstrips =0; edm::EDGetTokenT<std::vector<unsigned short> > nstrips_token_;
245  const std::vector<bool>* saturation =0; edm::EDGetTokenT<std::vector<bool> > saturation_token_;
246  const std::vector<bool>* overlapping =0; edm::EDGetTokenT<std::vector<bool> > overlapping_token_;
247  const std::vector<bool>* farfromedge =0; edm::EDGetTokenT<std::vector<bool> > farfromedge_token_;
248  const std::vector<unsigned int>* charge =0; edm::EDGetTokenT<std::vector<unsigned int> > charge_token_;
249  const std::vector<double>* path =0; edm::EDGetTokenT<std::vector<double> > path_token_;
250  const std::vector<double>* chargeoverpath =0; edm::EDGetTokenT<std::vector<double> > chargeoverpath_token_;
252  const std::vector<double>* gainused =0; edm::EDGetTokenT<std::vector<double> > gainused_token_;
253 
254  string EventPrefix_; //("");
255  string EventSuffix_; //("");
256  string TrackPrefix_; //("track");
257  string TrackSuffix_; //("");
258  string CalibPrefix_; //("GainCalibration");
259  string CalibSuffix_; //("");
260 
261 private :
262 
263  std::vector<stAPVGain*> APVsCollOrdered;
264  std::unordered_map<unsigned int, stAPVGain*> APVsColl;
265 };
266 
267 inline int
269 {
270  std::vector<string>::const_iterator it=dqm_tag_.begin();
271  while(it!=dqm_tag_.end()) {
272  if(*it==std::string(tag)) return it-dqm_tag_.begin();
273  it++;
274  }
275 
276  if (std::string(tag)=="") return 0; // return StdBunch calibration mode for backward compatibility
277 
278  return None;
279 }
280 
282  if(A->GetNbinsX() == B->GetNbinsX()){
283  A->Add(B);
284  }else{
285  for(int x=0;x<=B->GetNbinsX()+1; x++){
286  for(int y=0;y<=B->GetNbinsY()+1; y++){
287  A->SetBinContent(x,y,A->GetBinContent(x,y)+B->GetBinContent(x,y));
288  }}
289  }
290 }
291 
292 
293 
295 {
296  OutputGains = iConfig.getParameter<std::string>("OutputGains");
297 
298  AlgoMode = iConfig.getUntrackedParameter<std::string>("AlgoMode", "CalibTree");
299  MagFieldCurrentTh = iConfig.getUntrackedParameter<double> ("MagFieldCurrentTh" , 2000.);
300  MinNrEntries = iConfig.getUntrackedParameter<double> ("minNrEntries" , 20);
301  MaxMPVError = iConfig.getUntrackedParameter<double> ("maxMPVError" , 500.0);
302  MaxChi2OverNDF = iConfig.getUntrackedParameter<double> ("maxChi2OverNDF" , 5.0);
303  MinTrackMomentum = iConfig.getUntrackedParameter<double> ("minTrackMomentum" , 3.0);
304  MaxTrackMomentum = iConfig.getUntrackedParameter<double> ("maxTrackMomentum" , 99999.0);
305  MinTrackEta = iConfig.getUntrackedParameter<double> ("minTrackEta" , -5.0);
306  MaxTrackEta = iConfig.getUntrackedParameter<double> ("maxTrackEta" , 5.0);
307  MaxNrStrips = iConfig.getUntrackedParameter<unsigned>("maxNrStrips" , 2);
308  MinTrackHits = iConfig.getUntrackedParameter<unsigned>("MinTrackHits" , 8);
309  MaxTrackChiOverNdf = iConfig.getUntrackedParameter<double> ("MaxTrackChiOverNdf" , 3);
310  MaxTrackingIteration = iConfig.getUntrackedParameter<int> ("MaxTrackingIteration" , 7);
311  AllowSaturation = iConfig.getUntrackedParameter<bool> ("AllowSaturation" , false);
312  FirstSetOfConstants = iConfig.getUntrackedParameter<bool> ("FirstSetOfConstants" , true);
313  Validation = iConfig.getUntrackedParameter<bool> ("Validation" , false);
314  OldGainRemoving = iConfig.getUntrackedParameter<bool> ("OldGainRemoving" , false);
315 
316  CalibrationLevel = iConfig.getUntrackedParameter<int> ("CalibrationLevel" , 0);
317  VInputFiles = iConfig.getUntrackedParameter<vector<string> > ("InputFiles");
318 
319 
320  useCalibration = iConfig.getUntrackedParameter<bool> ("UseCalibration" , false);
321  m_harvestingMode = iConfig.getUntrackedParameter<bool> ("harvestingMode" , false);
322  m_splitDQMstat = iConfig.getUntrackedParameter<bool> ("splitDQMstat" , false);
323  m_calibrationMode = iConfig.getUntrackedParameter<string> ("calibrationMode" , "StdBunch");
324  m_calibrationPath = iConfig.getUntrackedParameter<string> ("calibrationPath");
325  m_DQMdir = iConfig.getUntrackedParameter<string> ("DQMdir" , "AlCaReco/SiStripGains");
326 
327  tagCondition_NClusters = iConfig.getUntrackedParameter<double> ("NClustersForTagProd" , 2E8);
328  tagCondition_GoodFrac = iConfig.getUntrackedParameter<double> ("GoodFracForTagProd" , 0.95);
329 
330  saveSummary = iConfig.getUntrackedParameter<bool> ("saveSummary" , false);
331 
332 
333  // Gather DQM Service
335  dbe->setVerbose(10);
336 
337  //Set the monitoring element tag and store
338  dqm_tag_.reserve(7);
339  dqm_tag_.clear();
340  dqm_tag_.push_back( "StdBunch" ); // statistic collection from Standard Collision Bunch @ 3.8 T
341  dqm_tag_.push_back( "StdBunch0T" ); // statistic collection from Standard Collision Bunch @ 0 T
342  dqm_tag_.push_back( "AagBunch" ); // statistic collection from First Collision After Abort Gap @ 3.8 T
343  dqm_tag_.push_back( "AagBunch0T" ); // statistic collection from First Collision After Abort Gap @ 0 T
344  dqm_tag_.push_back( "IsoMuon" ); // statistic collection from Isolated Muon @ 3.8 T
345  dqm_tag_.push_back( "IsoMuon0T" ); // statistic collection from Isolated Muon @ 0 T
346  dqm_tag_.push_back( "Harvest" ); // statistic collection: Harvest
347 
348  Charge_Vs_Index.insert( Charge_Vs_Index.begin(), dqm_tag_.size(), 0);
349  //Charge_Vs_Index_Absolute.insert( Charge_Vs_Index_Absolute.begin(), dqm_tag_.size(), 0);
350  Charge_Vs_PathlengthTIB.insert( Charge_Vs_PathlengthTIB.begin(), dqm_tag_.size(), 0);
351  Charge_Vs_PathlengthTOB.insert( Charge_Vs_PathlengthTOB.begin(), dqm_tag_.size(), 0);
352  Charge_Vs_PathlengthTIDP.insert( Charge_Vs_PathlengthTIDP.begin(), dqm_tag_.size(), 0);
353  Charge_Vs_PathlengthTIDM.insert( Charge_Vs_PathlengthTIDM.begin(), dqm_tag_.size(), 0);
358 
359 
360 
361 
362  // configure token for gathering the ntuple variables
363  edm::ParameterSet swhallowgain_pset = iConfig.getUntrackedParameter<edm::ParameterSet>("gain");
364 
365  string label = swhallowgain_pset.getUntrackedParameter<string>("label");
366  CalibPrefix_ = swhallowgain_pset.getUntrackedParameter<string>("prefix");
367  CalibSuffix_ = swhallowgain_pset.getUntrackedParameter<string>("suffix");
368 
369  trackindex_token_ = consumes<std::vector<int> >(edm::InputTag(label, CalibPrefix_ + "trackindex" + CalibSuffix_));
370  rawid_token_ = consumes<std::vector<unsigned int> >(edm::InputTag(label, CalibPrefix_ + "rawid" + CalibSuffix_));
371  localdirx_token_ = consumes<std::vector<double> >(edm::InputTag(label, CalibPrefix_ + "localdirx" + CalibSuffix_));
372  localdiry_token_ = consumes<std::vector<double> >(edm::InputTag(label, CalibPrefix_ + "localdiry" + CalibSuffix_));
373  localdirz_token_ = consumes<std::vector<double> >(edm::InputTag(label, CalibPrefix_ + "localdirz" + CalibSuffix_));
374  firststrip_token_ = consumes<std::vector<unsigned short> >(edm::InputTag(label, CalibPrefix_ + "firststrip" + CalibSuffix_));
375  nstrips_token_ = consumes<std::vector<unsigned short> >(edm::InputTag(label, CalibPrefix_ + "nstrips" + CalibSuffix_));
376  saturation_token_ = consumes<std::vector<bool> >(edm::InputTag(label, CalibPrefix_ + "saturation" + CalibSuffix_));
377  overlapping_token_ = consumes<std::vector<bool> >(edm::InputTag(label, CalibPrefix_ + "overlapping" + CalibSuffix_));
378  farfromedge_token_ = consumes<std::vector<bool> >(edm::InputTag(label, CalibPrefix_ + "farfromedge" + CalibSuffix_));
379  charge_token_ = consumes<std::vector<unsigned int> >(edm::InputTag(label, CalibPrefix_ + "charge" + CalibSuffix_));
380  path_token_ = consumes<std::vector<double> >(edm::InputTag(label, CalibPrefix_ + "path" + CalibSuffix_));
381  chargeoverpath_token_ = consumes<std::vector<double> >(edm::InputTag(label, CalibPrefix_ + "chargeoverpath"+ CalibSuffix_));
382  amplitude_token_ = consumes<std::vector<unsigned char> >(edm::InputTag(label, CalibPrefix_ + "amplitude" + CalibSuffix_));
383  gainused_token_ = consumes<std::vector<double> >(edm::InputTag(label, CalibPrefix_ + "gainused" + CalibSuffix_));
384 
385  edm::ParameterSet evtinfo_pset = iConfig.getUntrackedParameter<edm::ParameterSet>("evtinfo");
386  label = evtinfo_pset.getUntrackedParameter<string>("label");
387  EventPrefix_ = evtinfo_pset.getUntrackedParameter<string>("prefix");
388  EventSuffix_ = evtinfo_pset.getUntrackedParameter<string>("suffix");
389  TrigTech_token_ = consumes<std::vector<bool> >(edm::InputTag(label, EventPrefix_ + "TrigTech" + EventSuffix_));
390 
391  edm::ParameterSet track_pset = iConfig.getUntrackedParameter<edm::ParameterSet>("tracks");
392  label = track_pset.getUntrackedParameter<string>("label");
393  TrackPrefix_ = track_pset.getUntrackedParameter<string>("prefix");
394  TrackSuffix_ = track_pset.getUntrackedParameter<string>("suffix");
395 
396  trackchi2ndof_token_ = consumes<std::vector<double> >(edm::InputTag(label, TrackPrefix_ + "chi2ndof" + TrackSuffix_));
397  trackp_token_ = consumes<std::vector<float> >(edm::InputTag(label, TrackPrefix_ + "momentum" + TrackSuffix_));
398  trackpt_token_ = consumes<std::vector<float> >(edm::InputTag(label, TrackPrefix_ + "pt" + TrackSuffix_));
399  tracketa_token_ = consumes<std::vector<double> >(edm::InputTag(label, TrackPrefix_ + "eta" + TrackSuffix_));
400  trackphi_token_ = consumes<std::vector<double> >(edm::InputTag(label, TrackPrefix_ + "phi" + TrackSuffix_));
401  trackhitsvalid_token_ = consumes<std::vector<unsigned int> >(edm::InputTag(label, TrackPrefix_ + "hitsvalid" + TrackSuffix_));
402  trackalgo_token_ = consumes<std::vector<int> >(edm::InputTag(label, TrackPrefix_ + "algo" + TrackSuffix_));
403 }
404 
405 void SiStripGainFromCalibTree::bookDQMHistos(const char* dqm_dir, const char* tag)
406 {
407  edm::LogInfo("SiStripGainFromCalibTree") << "Setting " << dqm_dir << "in DQM and booking histograms for tag "
408  << tag << std::endl;
409 
410  if ( strcmp(booked_dir_.c_str(),dqm_dir)!=0 ) {
411  booked_dir_ = dqm_dir;
412  dbe->setCurrentFolder(dqm_dir);
413  }
414 
415  std::string stag(tag);
416  if(stag.size()!=0 && stag[0]!='_') stag.insert(0,1,'_');
417 
418  std::string cvi = std::string("Charge_Vs_Index") + stag;
419  //std::string cviA = std::string("Charge_Vs_Index_Absolute") + stag;
420  std::string cvpTIB = std::string("Charge_Vs_PathlengthTIB") + stag;
421  std::string cvpTOB = std::string("Charge_Vs_PathlengthTOB") + stag;
422  std::string cvpTIDP = std::string("Charge_Vs_PathlengthTIDP") + stag;
423  std::string cvpTIDM = std::string("Charge_Vs_PathlengthTIDM") + stag;
424  std::string cvpTECP1 = std::string("Charge_Vs_PathlengthTECP1") + stag;
425  std::string cvpTECP2 = std::string("Charge_Vs_PathlengthTECP2") + stag;
426  std::string cvpTECM1 = std::string("Charge_Vs_PathlengthTECM1") + stag;
427  std::string cvpTECM2 = std::string("Charge_Vs_PathlengthTECM2") + stag;
428 
429  int elepos = (m_harvestingMode && AlgoMode=="PCL")? Harvest : statCollectionFromMode(tag);
430 
431  Charge_Vs_Index[elepos] = dbe->book2S(cvi.c_str() , cvi.c_str() , 88625, 0 , 88624,2000,0,4000);
432  //Charge_Vs_Index_Absolute[elepos] = dbe->book2S(cviA.c_str() , cviA.c_str() , 88625, 0 , 88624,1000,0,4000);
433  Charge_Vs_PathlengthTIB[elepos] = dbe->book2S(cvpTIB.c_str() , cvpTIB.c_str() , 20 , 0.3 , 1.3 , 250,0,2000);
434  Charge_Vs_PathlengthTOB[elepos] = dbe->book2S(cvpTOB.c_str() , cvpTOB.c_str() , 20 , 0.3 , 1.3 , 250,0,2000);
435  Charge_Vs_PathlengthTIDP[elepos] = dbe->book2S(cvpTIDP.c_str() , cvpTIDP.c_str() , 20 , 0.3 , 1.3 , 250,0,2000);
436  Charge_Vs_PathlengthTIDM[elepos] = dbe->book2S(cvpTIDM.c_str() , cvpTIDM.c_str() , 20 , 0.3 , 1.3 , 250,0,2000);
437  Charge_Vs_PathlengthTECP1[elepos] = dbe->book2S(cvpTECP1.c_str(), cvpTECP1.c_str(), 20 , 0.3 , 1.3 , 250,0,2000);
438  Charge_Vs_PathlengthTECP2[elepos] = dbe->book2S(cvpTECP2.c_str(), cvpTECP2.c_str(), 20 , 0.3 , 1.3 , 250,0,2000);
439  Charge_Vs_PathlengthTECM1[elepos] = dbe->book2S(cvpTECM1.c_str(), cvpTECM1.c_str(), 20 , 0.3 , 1.3 , 250,0,2000);
440  Charge_Vs_PathlengthTECM2[elepos] = dbe->book2S(cvpTECM2.c_str(), cvpTECM2.c_str(), 20 , 0.3 , 1.3 , 250,0,2000);
441 }
442 
444 {
445  edm::LogInfo("SiStripGainFromCalibTree") << "AlgoMode : " << AlgoMode << "\n"
446  << "CalibrationMode : " << m_calibrationMode << "\n"
447  << "HarvestingMode : " << m_harvestingMode << std::endl;
448  //Setup DQM histograms
449  if(AlgoMode != "PCL" or m_harvestingMode) {
450  const char * dqm_dir = "AlCaReco/SiStripGainsHarvesting/";
451  this->bookDQMHistos( dqm_dir, dqm_tag_[statCollectionFromMode(m_calibrationMode.c_str())].c_str() );
452  } else {
453  //Check consistency of calibration Mode and BField only for the ALCAPROMPT in the PCL workflow
454  if (!isBFieldConsistentWithMode(iSetup)) {
455  string prevMode = m_calibrationMode;
456  swapBFieldMode();
457  edm::LogInfo("SiStripGainFromCalibTree") << "Switching calibration mode for endorsing BField status: "
458  << prevMode << " ==> " << m_calibrationMode << std::endl;
459  }
460  std::string dqm_dir = m_DQMdir + ((m_splitDQMstat)? m_calibrationMode:"") + "/";
462  this->bookDQMHistos( dqm_dir.c_str(), dqm_tag_[elem].c_str() );
463  }
464 
465 
467  iSetup.get<TrackerDigiGeometryRecord>().get( tkGeom );
468  auto const & Det = tkGeom->dets();
469 
470  NPixelDets = 0;
471  NStripAPVs = 0;
472  unsigned int Index=0;
473  for(unsigned int i=0;i<Det.size();i++){
474  DetId Detid = Det[i]->geographicalId();
475  int SubDet = Detid.subdetId();
476 
477  if( SubDet == StripSubdetector::TIB || SubDet == StripSubdetector::TID ||
478  SubDet == StripSubdetector::TOB || SubDet == StripSubdetector::TEC ){
479 
480  auto DetUnit = dynamic_cast<const StripGeomDetUnit*> (Det[i]);
481  if(!DetUnit)continue;
482 
483  const StripTopology& Topo = DetUnit->specificTopology();
484  unsigned int NAPV = Topo.nstrips()/128;
485 
486  for(unsigned int j=0;j<NAPV;j++){
487  stAPVGain* APV = new stAPVGain;
488  APV->Index = Index;
489  APV->Bin = -1;
490  APV->DetId = Detid.rawId();
491  APV->APVId = j;
492  APV->SubDet = SubDet;
493  APV->FitMPV = -1;
494  APV->FitMPVErr = -1;
495  APV->FitWidth = -1;
496  APV->FitWidthErr = -1;
497  APV->FitChi2 = -1;
498  APV->FitNorm = -1;
499  APV->Gain = -1;
500  APV->PreviousGain = 1;
501  APV->PreviousGainTick = 1;
502  APV->x = DetUnit->position().basicVector().x();
503  APV->y = DetUnit->position().basicVector().y();
504  APV->z = DetUnit->position().basicVector().z();
505  APV->Eta = DetUnit->position().basicVector().eta();
506  APV->Phi = DetUnit->position().basicVector().phi();
507  APV->R = DetUnit->position().basicVector().transverse();
508  APV->Thickness = DetUnit->surface().bounds().thickness();
509  APV->NEntries = 0;
510  APV->isMasked = false;
511 
512  APVsCollOrdered.push_back(APV);
513  APVsColl[(APV->DetId<<4) | APV->APVId] = APV;
514  Index++;
515  NStripAPVs++;
516  }
517  }
518  }
519 
520  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
521  DetId Detid = Det[i]->geographicalId();
522  int SubDet = Detid.subdetId();
524  auto DetUnit = dynamic_cast<const PixelGeomDetUnit*> (Det[i]);
525  if(!DetUnit) continue;
526 
527  const PixelTopology& Topo = DetUnit->specificTopology();
528  unsigned int NROCRow = Topo.nrows()/(80.);
529  unsigned int NROCCol = Topo.ncolumns()/(52.);
530 
531  for(unsigned int j=0;j<NROCRow;j++){
532  for(unsigned int i=0;i<NROCCol;i++){
533 
534  stAPVGain* APV = new stAPVGain;
535  APV->Index = Index;
536  APV->Bin = -1;
537  APV->DetId = Detid.rawId();
538  APV->APVId = (j<<3 | i);
539  APV->SubDet = SubDet;
540  APV->FitMPV = -1;
541  APV->FitMPVErr = -1;
542  APV->FitWidth = -1;
543  APV->FitWidthErr = -1;
544  APV->FitChi2 = -1;
545  APV->Gain = -1;
546  APV->PreviousGain = 1;
547  APV->PreviousGainTick = 1;
548  APV->x = DetUnit->position().basicVector().x();
549  APV->y = DetUnit->position().basicVector().y();
550  APV->z = DetUnit->position().basicVector().z();
551  APV->Eta = DetUnit->position().basicVector().eta();
552  APV->Phi = DetUnit->position().basicVector().phi();
553  APV->R = DetUnit->position().basicVector().transverse();
554  APV->Thickness = DetUnit->surface().bounds().thickness();
555  APV->isMasked = false; //SiPixelQuality_->IsModuleBad(Detid.rawId());
556  APV->NEntries = 0;
557 
558  APVsCollOrdered.push_back(APV);
559  APVsColl[(APV->DetId<<4) | APV->APVId] = APV;
560  Index++;
561  NPixelDets++;
562  }}
563  }
564  }
565 
566 
568 
569  NEvent = 0;
570  NTrack = 0;
571  NClusterStrip = 0;
572  NClusterPixel = 0;
573  SRun = 1<<31;
574  ERun = 0;
575  GOOD = 0;
576  BAD = 0;
577  MASKED = 0;
578 }
579 
581  edm::ESHandle<RunInfo> runInfo;
582  iSetup.get<RunInfoRcd>().get(runInfo);
583 
584  double average_current = runInfo.product()->m_avg_current;
585  bool isOn = (average_current > MagFieldCurrentTh);
586  bool is0T = (m_calibrationMode.substr( m_calibrationMode.length()-2 )=="0T");
587 
588  return ( (isOn && !is0T) || (!isOn && is0T) );
589 }
590 
592  if ( m_calibrationMode.substr( m_calibrationMode.length()-2 )=="0T" ) {
593  m_calibrationMode.erase( m_calibrationMode.length()-2,2);
594  } else {
595  m_calibrationMode.append( "0T" );
596  }
597 }
598 
600 {
601  if( !m_harvestingMode && AlgoMode=="PCL") {
602  //Check consistency of calibration Mode and BField only for the ALCAPROMPT in the PCL workflow
603  if (!isBFieldConsistentWithMode(iSetup)) {
604  string prevMode = m_calibrationMode;
605  swapBFieldMode();
606  edm::LogInfo("SiStripGainFromCalibTree") << "Switching calibration mode for endorsing BField status: "
607  << prevMode << " ==> " << m_calibrationMode << std::endl;
608  }
609  }
610 
611  edm::ESHandle<SiStripGain> gainHandle;
612  iSetup.get<SiStripGainRcd>().get(gainHandle);
613  if(!gainHandle.isValid()){edm::LogError("SiStripGainFromCalibTree")<< "gainHandle is not valid\n"; exit(0);}
614 
615  edm::ESHandle<SiStripQuality> SiStripQuality_;
616  iSetup.get<SiStripQualityRcd>().get(SiStripQuality_);
617 
618  for(unsigned int a=0;a<APVsCollOrdered.size();a++){
619 
621 
622  // 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)
624 
625  APV->isMasked = SiStripQuality_->IsApvBad(APV->DetId,APV->APVId);
626  // if(!FirstSetOfConstants){
627 
628  if(gainHandle->getNumberOfTags()!=2){edm::LogError("SiStripGainFromCalibTree")<< "NUMBER OF GAIN TAG IS EXPECTED TO BE 2\n";fflush(stdout);exit(0);};
629  float newPreviousGain = gainHandle->getApvGain(APV->APVId,gainHandle->getRange(APV->DetId, 1),1);
630  if(APV->PreviousGain!=1 and newPreviousGain!=APV->PreviousGain)edm::LogWarning("SiStripGainFromCalibTree")<< "WARNING: ParticleGain in the global tag changed\n";
631  APV->PreviousGain = newPreviousGain;
632 
633  float newPreviousGainTick = gainHandle->getApvGain(APV->APVId,gainHandle->getRange(APV->DetId, 0),0);
634  if(APV->PreviousGainTick!=1 and newPreviousGainTick!=APV->PreviousGainTick){
635  edm::LogWarning("SiStripGainFromCalibTree")<< "WARNING: TickMarkGain in the global tag changed\n"<< std::endl
636  <<" APV->SubDet: "<< APV->SubDet << " APV->APVId:" << APV->APVId << std::endl
637  <<" APV->PreviousGainTick: "<<APV->PreviousGainTick<<" newPreviousGainTick: "<<newPreviousGainTick<<std::endl;
638  }
639  APV->PreviousGainTick = newPreviousGainTick;
640 
641  //printf("DETID = %7i APVID=%1i Previous Gain=%8.4f (G1) x %8.4f (G2)\n",APV->DetId,APV->APVId,APV->PreviousGainTick, APV->PreviousGain);
642  // }
643 
644  }
645 }
646 
648  if(AlgoMode == "PCL" && !m_harvestingMode) return;//nothing to do in that case
649 
650  if(AlgoMode == "PCL" and m_harvestingMode){
651  // Load the 2D histograms from the DQM objects
652  // When running in AlCaHarvesting mode the histos are already booked and should be just retrieved from
653  // DQMStore so that they can be used in the fit
654 
655  edm::LogInfo("SiStripGainFromCalibTree") << "Starting harvesting statistics" << std::endl;
656 
657  // check the required tag before adding histograms
658  int elepos = statCollectionFromMode(m_calibrationMode.c_str());
659  if (elepos!=Harvest) {
660 
661  //collect statistics from DQM into the related monitored elements
663  if(stag.size()!=0 && stag[0]!='_') stag.insert(0,1,'_');
664 
665 
666  if (elepos==-1) {
667  //implememt backward compatibility
668  elepos=0;
669  stag="";
670  }
671 
673 
674  std::string cvi = DQM_dir + std::string("/Charge_Vs_Index") + stag;
675  //std::string cviA = DQM_dir + std::string("/Charge_Vs_Index_Absolute") + stag;
676  std::string cvpTIB = DQM_dir + std::string("/Charge_Vs_PathlengthTIB") + stag;
677  std::string cvpTOB = DQM_dir + std::string("/Charge_Vs_PathlengthTOB") + stag;
678  std::string cvpTIDP = DQM_dir + std::string("/Charge_Vs_PathlengthTIDP") + stag;
679  std::string cvpTIDM = DQM_dir + std::string("/Charge_Vs_PathlengthTIDM") + stag;
680  std::string cvpTECP1 = DQM_dir + std::string("/Charge_Vs_PathlengthTECP1") + stag;
681  std::string cvpTECP2 = DQM_dir + std::string("/Charge_Vs_PathlengthTECP2") + stag;
682  std::string cvpTECM1 = DQM_dir + std::string("/Charge_Vs_PathlengthTECM1") + stag;
683  std::string cvpTECM2 = DQM_dir + std::string("/Charge_Vs_PathlengthTECM2") + stag;
684 
685  Charge_Vs_Index[elepos] = dbe->get(cvi.c_str());
686  //Charge_Vs_Index_Absolute[elepos] = dbe->get(cviA.c_str());
687  Charge_Vs_PathlengthTIB[elepos] = dbe->get(cvpTIB.c_str());
688  Charge_Vs_PathlengthTOB[elepos] = dbe->get(cvpTOB.c_str());
689  Charge_Vs_PathlengthTIDP[elepos] = dbe->get(cvpTIDP.c_str());
690  Charge_Vs_PathlengthTIDM[elepos] = dbe->get(cvpTIDM.c_str());
691  Charge_Vs_PathlengthTECP1[elepos] = dbe->get(cvpTECP1.c_str());
692  Charge_Vs_PathlengthTECP2[elepos] = dbe->get(cvpTECP2.c_str());
693  Charge_Vs_PathlengthTECM1[elepos] = dbe->get(cvpTECM1.c_str());
694  Charge_Vs_PathlengthTECM2[elepos] = dbe->get(cvpTECM2.c_str());
695 
696  if (Charge_Vs_Index[elepos]==0) {
697  edm::LogError("SiStripGainFromCalibTree") << "Harvesting: could not retrieve " << cvi.c_str()
698  << ", statistics will not be summed!" << std::endl;
699  } else {
700  merge( (Charge_Vs_Index[Harvest])->getTH2S(), (Charge_Vs_Index[elepos])->getTH2S() );
701  edm::LogInfo("SiStripGainFromCalibTree") << "Harvesting "
702  << (Charge_Vs_Index[elepos])->getTH2S()->GetEntries() << " more clusters" << std::endl;
703  }
704 
705  //if (Charge_Vs_Index_Absolute[elepos]==0) {
706  // edm::LogError("SiStripGainFromCalibTree") << "Harvesting: could not retrieve " << cviA.c_str()
707  // << ", statistics will not be summed!" << std::endl;
708  //} else merge( (Charge_Vs_Index_Absolute[Harvest])->getTH2S(), (Charge_Vs_Index_Absolute[elepos])->getTH2S() );
709 
710  if (Charge_Vs_PathlengthTIB[elepos]==0) {
711  edm::LogError("SiStripGainFromCalibTree") << "Harvesting: could not retrieve " << cvpTIB.c_str()
712  << ", statistics will not be summed!" << std::endl;
713  } else (Charge_Vs_PathlengthTIB[Harvest])->getTH2S()->Add((Charge_Vs_PathlengthTIB[elepos])->getTH2S());
714 
715  if (Charge_Vs_PathlengthTOB[elepos]==0) {
716  edm::LogError("SiStripGainFromCalibTree") << "Harvesting: could not retrieve " << cvpTOB.c_str()
717  << ", statistics will not be summed!" << std::endl;
718  } else (Charge_Vs_PathlengthTOB[Harvest])->getTH2S()->Add((Charge_Vs_PathlengthTOB[elepos])->getTH2S());
719 
720  if (Charge_Vs_PathlengthTIDP[elepos]==0) {
721  edm::LogError("SiStripGainFromCalibTree") << "Harvesting: could not retrieve " << cvpTIDP.c_str()
722  << ", statistics will not be summed!" << std::endl;
723  } else (Charge_Vs_PathlengthTIDP[Harvest])->getTH2S()->Add((Charge_Vs_PathlengthTIDP[elepos])->getTH2S());
724 
725  if (Charge_Vs_PathlengthTIDM[elepos]==0) {
726  edm::LogError("SiStripGainFromCalibTree") << "Harvesting: could not retrieve " << cvpTIDM.c_str()
727  << ", statistics will not be summed!" << std::endl;
728  } else (Charge_Vs_PathlengthTIDM[Harvest])->getTH2S()->Add((Charge_Vs_PathlengthTIDM[elepos])->getTH2S());
729 
730  if (Charge_Vs_PathlengthTECP1[elepos]==0) {
731  edm::LogError("SiStripGainFromCalibTree") << "Harvesting: could not retrieve " << cvpTECP1.c_str()
732  << ", statistics will not be summed!" << std::endl;
733  } else (Charge_Vs_PathlengthTECP1[Harvest])->getTH2S()->Add((Charge_Vs_PathlengthTECP1[elepos])->getTH2S());
734 
735  if (Charge_Vs_PathlengthTECP2[elepos]==0) {
736  edm::LogError("SiStripGainFromCalibTree") << "Harvesting: could not retrieve " << cvpTECP2.c_str()
737  << ", statistics will not be summed!" << std::endl;
738  } else (Charge_Vs_PathlengthTECP2[Harvest])->getTH2S()->Add((Charge_Vs_PathlengthTECP2[elepos])->getTH2S());
739 
740  if (Charge_Vs_PathlengthTECM1[elepos]==0) {
741  edm::LogError("SiStripGainFromCalibTree") << "Harvesting: could not retrieve " << cvpTECM1.c_str()
742  << ", statistics will not be summed!" << std::endl;
743  } else (Charge_Vs_PathlengthTECM1[Harvest])->getTH2S()->Add((Charge_Vs_PathlengthTECM1[elepos])->getTH2S());
744 
745  if (Charge_Vs_PathlengthTECM2[elepos]==0) {
746  edm::LogError("SiStripGainFromCalibTree") << "Harvesting: could not retrieve " << cvpTECM2.c_str()
747  << ", statistics will not be summed!" << std::endl;
748  } else (Charge_Vs_PathlengthTECM2[Harvest])->getTH2S()->Add((Charge_Vs_PathlengthTECM2[elepos])->getTH2S());
749  }
750  }
751 }
752 
753 void
755  if(AlgoMode == "PCL" && !m_harvestingMode) return;//nothing to do in that case
756 
757  if(AlgoMode == "CalibTree"){
758  edm::LogInfo("SiStripGainFromCalibTree") << "Analyzing calibration tree" << std::endl;
759  // Loop on calibTrees to fill the 2D histograms
761  }else if(m_harvestingMode){
762  NClusterStrip = (Charge_Vs_Index[Harvest])->getTH2S()->Integral(0,NStripAPVs+1, 0, 99999 );
763  NClusterPixel = (Charge_Vs_Index[Harvest])->getTH2S()->Integral(NStripAPVs+2, NStripAPVs+NPixelDets+2, 0, 99999 );
764  }
765 
766  // Now that we have the full statistics we can extract the information of the 2D histograms
768 
769  // Force the DB object writing,
770  // thus setting the IOV as the first processed run (if timeFromEndRun is set to false)
771  storeOnDbNow();
772 
773  if(AlgoMode != "PCL" or saveSummary){
774  edm::LogInfo("SiStripGainFromCalibTree") << "Saving summary into root file" << std::endl;
775 
776  //also save the 2D monitor elements to this file as TH2D tfs
778 
779  //save only the statistics for the calibrationTag
780  int elepos = statCollectionFromMode(m_calibrationMode.c_str());
781 
782  if( Charge_Vs_Index[elepos]!=0 ) tfs->make<TH2S> ( *(Charge_Vs_Index[elepos])->getTH2S() );
783  //if( Charge_Vs_Index_Absolute[elepos]!=0 ) tfs->make<TH2S> ( *(Charge_Vs_Index_Absolute[elepos])->getTH2S() );
784  if( Charge_Vs_PathlengthTIB[elepos]!=0 ) tfs->make<TH2S> ( *(Charge_Vs_PathlengthTIB[elepos])->getTH2S() );
785  if( Charge_Vs_PathlengthTOB[elepos]!=0 ) tfs->make<TH2S> ( *(Charge_Vs_PathlengthTOB[elepos])->getTH2S() );
786  if( Charge_Vs_PathlengthTIDP[elepos]!=0 ) tfs->make<TH2S> ( *(Charge_Vs_PathlengthTIDP[elepos])->getTH2S() );
787  if( Charge_Vs_PathlengthTIDM[elepos]!=0 ) tfs->make<TH2S> ( *(Charge_Vs_PathlengthTIDM[elepos])->getTH2S() );
788  if( Charge_Vs_PathlengthTECP1[elepos]!=0 ) tfs->make<TH2S> ( *(Charge_Vs_PathlengthTECP1[elepos])->getTH2S() );
789  if( Charge_Vs_PathlengthTECP2[elepos]!=0 ) tfs->make<TH2S> ( *(Charge_Vs_PathlengthTECP2[elepos])->getTH2S() );
790  if( Charge_Vs_PathlengthTECM1[elepos]!=0 ) tfs->make<TH2S> ( *(Charge_Vs_PathlengthTECM1[elepos])->getTH2S() );
791  if( Charge_Vs_PathlengthTECM2[elepos]!=0 ) tfs->make<TH2S> ( *(Charge_Vs_PathlengthTECM2[elepos])->getTH2S() );
792 
793  storeOnTree(tfs);
794  }
795 }
796 
797 
798 void SiStripGainFromCalibTree::getPeakOfLandau(TH1* InputHisto, double* FitResults, double LowRange, double HighRange)
799 {
800  FitResults[0] = -0.5; //MPV
801  FitResults[1] = 0; //MPV error
802  FitResults[2] = -0.5; //Width
803  FitResults[3] = 0; //Width error
804  FitResults[4] = -0.5; //Fit Chi2/NDF
805  FitResults[5] = 0; //Normalization
806 
807  if( InputHisto->GetEntries() < MinNrEntries)return;
808 
809  // perform fit with standard landau
810  TF1* MyLandau = new TF1("MyLandau","landau",LowRange, HighRange);
811  MyLandau->SetParameter(1,300);
812  InputHisto->Fit(MyLandau,"0QR WW");
813 
814  // MPV is parameter 1 (0=constant, 1=MPV, 2=Sigma)
815  FitResults[0] = MyLandau->GetParameter(1); //MPV
816  FitResults[1] = MyLandau->GetParError(1); //MPV error
817  FitResults[2] = MyLandau->GetParameter(2); //Width
818  FitResults[3] = MyLandau->GetParError(2); //Width error
819  FitResults[4] = MyLandau->GetChisquare() / MyLandau->GetNDF(); //Fit Chi2/NDF
820  FitResults[5] = MyLandau->GetParameter(0);
821 
822  delete MyLandau;
823 }
824 
826  if(FitResults[0] <= 0 )return false;
827 // if(FitResults[1] > MaxMPVError )return false;
828 // if(FitResults[4] > MaxChi2OverNDF)return false;
829  return true;
830 }
831 
833 
834  edm::LogInfo("SiStripGainFromCalibTree") << "Processing run " << runnumber
835  << " and event " << eventnumber
836  << " for " << m_calibrationMode << " calibration." << std::endl;
837 
840 
841  NEvent++;
842  NTrack+=(*trackp).size();
843 
844  int elepos = statCollectionFromMode(m_calibrationMode.c_str());
845 
846  unsigned int FirstAmplitude=0;
847  for(unsigned int i=0;i<(*chargeoverpath).size();i++){
848  FirstAmplitude+=(*nstrips)[i];
849  int TI = (*trackindex)[i];
850 
851  //printf("%i - %i - %i %i %i\n", (int)(*rawid)[i], (int)(*firststrip)[i]/128, (int)(*farfromedge)[i], (int)(*overlapping)[i], (int)(*saturation )[i] );
852  if((*tracketa )[TI] < MinTrackEta )continue;
853  if((*tracketa )[TI] > MaxTrackEta )continue;
854  if((*trackp )[TI] < MinTrackMomentum )continue;
855  if((*trackp )[TI] > MaxTrackMomentum )continue;
856  if((*trackhitsvalid)[TI] < MinTrackHits )continue;
857  if((*trackchi2ndof )[TI] > MaxTrackChiOverNdf )continue;
858  if((*trackalgo )[TI] > MaxTrackingIteration )continue;
859 
860  stAPVGain* APV = APVsColl[((*rawid)[i]<<4) | ((*firststrip)[i]/128)]; //works for both strip and pixel thanks to firstStrip encoding for pixel in the calibTree
861 
862  if(APV->SubDet>2 && (*farfromedge)[i] == false )continue;
863  if(APV->SubDet>2 && (*overlapping)[i] == true )continue;
864  if(APV->SubDet>2 && (*saturation )[i] && !AllowSaturation)continue;
865  if(APV->SubDet>2 && (*nstrips )[i] > MaxNrStrips )continue;
866 
867 
868  //printf("detId=%7i run=%7i event=%9i charge=%5i cs=%3i\n",(*rawid)[i],runnumber,eventnumber,(*charge)[i],(*nstrips)[i]);
869 
870  //double trans = atan2((*localdiry)[i],(*localdirx)[i])*(180/3.14159265);
871  //double alpha = acos ((*localdirx)[i] / sqrt( pow((*localdirx)[i],2) + pow((*localdirz)[i],2) ) ) * (180/3.14159265);
872  //double beta = acos ((*localdiry)[i] / sqrt( pow((*localdirx)[i],2) + pow((*localdirz)[i],2) ) ) * (180/3.14159265);
873 
874  //printf("NStrip = %i : Charge = %i --> Path = %f --> ChargeOverPath=%f\n",(*nstrips)[i],(*charge)[i],(*path)[i],(*chargeoverpath)[i]);
875  //printf("Amplitudes: ");
876  //for(unsigned int a=0;a<(*nstrips)[i];a++){printf("%i ",(*amplitude)[FirstAmplitude+a]);}
877  //printf("\n");
878 
879  if(APV->SubDet>2){NClusterStrip++;}else{NClusterPixel++;}
880 
881  int Charge = 0;
882  if(APV->SubDet>2 && (useCalibration || !FirstSetOfConstants)){
883  bool Saturation = false;
884  for(unsigned int s=0;s<(*nstrips)[i];s++){
885  int StripCharge = (*amplitude)[FirstAmplitude-(*nstrips)[i]+s];
886  if(useCalibration && !FirstSetOfConstants){ StripCharge=(int)(StripCharge*(APV->PreviousGain/APV->CalibGain));
887  }else if(useCalibration){ StripCharge=(int)(StripCharge/APV->CalibGain);
888  }else if(!FirstSetOfConstants){ StripCharge=(int)(StripCharge*APV->PreviousGain);}
889  if(StripCharge>1024){
890  StripCharge = 255;
891  Saturation = true;
892  }else if(StripCharge>254){
893  StripCharge = 254;
894  Saturation = true;
895  }
896  Charge += StripCharge;
897  }
898  if(Saturation && !AllowSaturation)continue;
899  }else if(APV->SubDet>2){
900  Charge = (*charge)[i];
901  }else{
902  Charge = (*charge)[i]/265.0; //expected scale factor between pixel and strip charge
903  }
904 
905  //printf("ChargeDifference = %i Vs %i with Gain = %f\n",(*charge)[i],Charge,APV->CalibGain);
906 
907  double ClusterChargeOverPath = ( (double) Charge )/(*path)[i] ;
908  if(APV->SubDet>2){
909  if(Validation) {ClusterChargeOverPath/=(*gainused)[i];}
910  if(OldGainRemoving){ClusterChargeOverPath*=(*gainused)[i];}
911  }
912  //(Charge_Vs_Index_Absolute[elepos])->Fill(APV->Index,Charge);
913  (Charge_Vs_Index[elepos]) ->Fill(APV->Index,ClusterChargeOverPath);
914 
915  if(APV->SubDet==StripSubdetector::TIB){ (Charge_Vs_PathlengthTIB[elepos]) ->Fill((*path)[i],Charge);
916  }else if(APV->SubDet==StripSubdetector::TOB){ (Charge_Vs_PathlengthTOB[elepos]) ->Fill((*path)[i],Charge);
917  }else if(APV->SubDet==StripSubdetector::TID){
918  if(APV->Eta<0){ (Charge_Vs_PathlengthTIDM[elepos]) ->Fill((*path)[i],Charge);
919  }else if(APV->Eta>0){ (Charge_Vs_PathlengthTIDP[elepos]) ->Fill((*path)[i],Charge);
920  }
921  }else if(APV->SubDet==StripSubdetector::TEC){
922  if(APV->Eta<0){
923  if(APV->Thickness<0.04){ (Charge_Vs_PathlengthTECM1[elepos])->Fill((*path)[i],Charge);
924  }else if(APV->Thickness>0.04){ (Charge_Vs_PathlengthTECM2[elepos])->Fill((*path)[i],Charge);
925  }
926  }else if(APV->Eta>0){
927  if(APV->Thickness<0.04){ (Charge_Vs_PathlengthTECP1[elepos])->Fill((*path)[i],Charge);
928  }else if(APV->Thickness>0.04){ (Charge_Vs_PathlengthTECP2[elepos])->Fill((*path)[i],Charge);
929  }
930  }
931  }
932 
933  }// END OF ON-CLUSTER LOOP
934 }//END OF processEvent()
935 
937 {
938  for(unsigned int i=0;i<VInputFiles.size();i++){
939  printf("Openning file %3i/%3i --> %s\n",i+1, (int)VInputFiles.size(), (char*)(VInputFiles[i].c_str())); fflush(stdout);
940  TFile *tfile = TFile::Open(VInputFiles[i].c_str());
941  TString tree_path = TString::Format("gainCalibrationTree%s/tree",m_calibrationMode.c_str());
942  TTree* tree = dynamic_cast<TTree*> (tfile->Get(tree_path.Data()));
943 
944  tree->SetBranchAddress((EventPrefix_ + "event" + EventSuffix_).c_str(), &eventnumber , NULL);
945  tree->SetBranchAddress((EventPrefix_ + "run" + EventSuffix_).c_str(), &runnumber , NULL);
946  tree->SetBranchAddress((EventPrefix_ + "TrigTech" + EventSuffix_).c_str(), &TrigTech , NULL);
947 
948  tree->SetBranchAddress((TrackPrefix_ + "chi2ndof" + TrackSuffix_).c_str(), &trackchi2ndof , NULL);
949  tree->SetBranchAddress((TrackPrefix_ + "momentum" + TrackSuffix_).c_str(), &trackp , NULL);
950  tree->SetBranchAddress((TrackPrefix_ + "pt" + TrackSuffix_).c_str(), &trackpt , NULL);
951  tree->SetBranchAddress((TrackPrefix_ + "eta" + TrackSuffix_).c_str(), &tracketa , NULL);
952  tree->SetBranchAddress((TrackPrefix_ + "phi" + TrackSuffix_).c_str(), &trackphi , NULL);
953  tree->SetBranchAddress((TrackPrefix_ + "hitsvalid" + TrackSuffix_).c_str(), &trackhitsvalid, NULL);
954  tree->SetBranchAddress((TrackPrefix_ + "algo" + TrackSuffix_).c_str(), &trackalgo , NULL);
955 
956  tree->SetBranchAddress((CalibPrefix_ + "trackindex" + CalibSuffix_).c_str(), &trackindex , NULL);
957  tree->SetBranchAddress((CalibPrefix_ + "rawid" + CalibSuffix_).c_str(), &rawid , NULL);
958  tree->SetBranchAddress((CalibPrefix_ + "localdirx" + CalibSuffix_).c_str(), &localdirx , NULL);
959  tree->SetBranchAddress((CalibPrefix_ + "localdiry" + CalibSuffix_).c_str(), &localdiry , NULL);
960  tree->SetBranchAddress((CalibPrefix_ + "localdirz" + CalibSuffix_).c_str(), &localdirz , NULL);
961  tree->SetBranchAddress((CalibPrefix_ + "firststrip" + CalibSuffix_).c_str(), &firststrip , NULL);
962  tree->SetBranchAddress((CalibPrefix_ + "nstrips" + CalibSuffix_).c_str(), &nstrips , NULL);
963  tree->SetBranchAddress((CalibPrefix_ + "saturation" + CalibSuffix_).c_str(), &saturation , NULL);
964  tree->SetBranchAddress((CalibPrefix_ + "overlapping" + CalibSuffix_).c_str(), &overlapping , NULL);
965  tree->SetBranchAddress((CalibPrefix_ + "farfromedge" + CalibSuffix_).c_str(), &farfromedge , NULL);
966  tree->SetBranchAddress((CalibPrefix_ + "charge" + CalibSuffix_).c_str(), &charge , NULL);
967  tree->SetBranchAddress((CalibPrefix_ + "path" + CalibSuffix_).c_str(), &path , NULL);
968  tree->SetBranchAddress((CalibPrefix_ + "chargeoverpath" + CalibSuffix_).c_str(), &chargeoverpath, NULL);
969  tree->SetBranchAddress((CalibPrefix_ + "amplitude" + CalibSuffix_).c_str(), &amplitude , NULL);
970  tree->SetBranchAddress((CalibPrefix_ + "gainused" + CalibSuffix_).c_str(), &gainused , NULL);
971 
972 
973  unsigned int nentries = tree->GetEntries();
974  printf("Number of Events = %i + %i = %i\n",NEvent,nentries,(NEvent+nentries));
975  printf("Progressing Bar :0%% 20%% 40%% 60%% 80%% 100%%\n");
976  printf("Looping on the Tree :");
977  int TreeStep = nentries/50;if(TreeStep<=1)TreeStep=1;
978  for (unsigned int ientry = 0; ientry < tree->GetEntries(); ientry++) {
979  if(ientry%TreeStep==0){printf(".");fflush(stdout);}
980  tree->GetEntry(ientry);
981  processEvent();
982  }printf("\n");// END OF EVENT LOOP
983  }
984 }
985 
986 
987 
989  unsigned int I=0;
990  TH1F* Proj = NULL;
991  double FitResults[6];
992  double MPVmean = 300;
993 
994  int elepos = (AlgoMode == "PCL")? Harvest : statCollectionFromMode(m_calibrationMode.c_str());
995 
996  if ( Charge_Vs_Index[elepos]==0 ) {
997  edm::LogError("SiStripGainFromCalibTree") << "Harvesting: could not execute algoComputeMPVandGain method because "
998  << m_calibrationMode.c_str() << " statistics cannot be retrieved.\n"
999  << "Please check if input contains "
1000  << m_calibrationMode.c_str() << " data." << std::endl;
1001  return;
1002  }
1003 
1004  TH2S *chvsidx = (Charge_Vs_Index[elepos])->getTH2S();
1005 
1006 
1007  printf("Progressing Bar :0%% 20%% 40%% 60%% 80%% 100%%\n");
1008  printf("Fitting Charge Distribution :");
1009  int TreeStep = APVsColl.size()/50;
1010  for(auto it = APVsColl.begin();it!=APVsColl.end();it++,I++){
1011  if(I%TreeStep==0){printf(".");fflush(stdout);}
1012  stAPVGain* APV = it->second;
1013  if(APV->Bin<0) APV->Bin = chvsidx->GetXaxis()->FindBin(APV->Index);
1014 
1015  if(APV->isMasked){APV->Gain=APV->PreviousGain; MASKED++; continue;}
1016 
1017  Proj = (TH1F*)(chvsidx->ProjectionY("",chvsidx->GetXaxis()->FindBin(APV->Index),chvsidx->GetXaxis()->FindBin(APV->Index),"e"));
1018  if(!Proj)continue;
1019 
1020  if(CalibrationLevel==0){
1021  }else if(CalibrationLevel==1){
1022  int SecondAPVId = APV->APVId;
1023  if(SecondAPVId%2==0){ SecondAPVId = SecondAPVId+1; }else{ SecondAPVId = SecondAPVId-1; }
1024  stAPVGain* APV2 = APVsColl[(APV->DetId<<4) | SecondAPVId];
1025  if(APV2->Bin<0) APV2->Bin = chvsidx->GetXaxis()->FindBin(APV2->Index);
1026  TH1F* Proj2 = (TH1F*)(chvsidx->ProjectionY("",APV2->Bin,APV2->Bin,"e"));
1027  if(Proj2){Proj->Add(Proj2,1);delete Proj2;}
1028  }else if(CalibrationLevel==2){
1029  for(unsigned int i=0;i<16;i++){ //loop up to 6APV for Strip and up to 16 for Pixels
1030  auto tmpit = APVsColl.find((APV->DetId<<4) | i);
1031  if(tmpit==APVsColl.end())continue;
1032  stAPVGain* APV2 = tmpit->second;
1033  if(APV2->DetId != APV->DetId || APV2->APVId == APV->APVId)continue;
1034  if(APV2->Bin<0) APV2->Bin = chvsidx->GetXaxis()->FindBin(APV2->Index);
1035  TH1F* Proj2 = (TH1F*)(chvsidx->ProjectionY("",APV2->Bin,APV2->Bin,"e"));
1036  if(Proj2){Proj->Add(Proj2,1);delete Proj2;}
1037  }
1038  }else{
1039  CalibrationLevel = 0;
1040  printf("Unknown Calibration Level, will assume %i\n",CalibrationLevel);
1041  }
1042 
1043  getPeakOfLandau(Proj,FitResults);
1044  APV->FitMPV = FitResults[0];
1045  APV->FitMPVErr = FitResults[1];
1046  APV->FitWidth = FitResults[2];
1047  APV->FitWidthErr = FitResults[3];
1048  APV->FitChi2 = FitResults[4];
1049  APV->FitNorm = FitResults[5];
1050  APV->NEntries = Proj->GetEntries();
1051 
1052  if(IsGoodLandauFit(FitResults)){
1053  APV->Gain = APV->FitMPV / MPVmean;
1054  if(APV->SubDet>2)GOOD++;
1055  }else{
1056  APV->Gain = APV->PreviousGain;
1057  if(APV->SubDet>2)BAD++;
1058  }
1059  if(APV->Gain<=0) APV->Gain = 1;
1060 
1061  //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);
1062  delete Proj;
1063  }printf("\n");
1064 }
1065 
1066 
1068 {
1069  unsigned int tree_Index;
1070  unsigned int tree_Bin;
1071  unsigned int tree_DetId;
1072  unsigned char tree_APVId;
1073  unsigned char tree_SubDet;
1074  float tree_x;
1075  float tree_y;
1076  float tree_z;
1077  float tree_Eta;
1078  float tree_R;
1079  float tree_Phi;
1080  float tree_Thickness;
1081  float tree_FitMPV;
1082  float tree_FitMPVErr;
1083  float tree_FitWidth;
1084  float tree_FitWidthErr;
1085  float tree_FitChi2NDF;
1086  float tree_FitNorm;
1087  double tree_Gain;
1088  double tree_PrevGain;
1089  double tree_PrevGainTick;
1090  double tree_NEntries;
1091  bool tree_isMasked;
1092 
1093  TTree* MyTree;
1094  MyTree = tfs->make<TTree> ("APVGain","APVGain");
1095  MyTree->Branch("Index" ,&tree_Index ,"Index/i");
1096  MyTree->Branch("Bin" ,&tree_Bin ,"Bin/i");
1097  MyTree->Branch("DetId" ,&tree_DetId ,"DetId/i");
1098  MyTree->Branch("APVId" ,&tree_APVId ,"APVId/b");
1099  MyTree->Branch("SubDet" ,&tree_SubDet ,"SubDet/b");
1100  MyTree->Branch("x" ,&tree_x ,"x/F");
1101  MyTree->Branch("y" ,&tree_y ,"y/F");
1102  MyTree->Branch("z" ,&tree_z ,"z/F");
1103  MyTree->Branch("Eta" ,&tree_Eta ,"Eta/F");
1104  MyTree->Branch("R" ,&tree_R ,"R/F");
1105  MyTree->Branch("Phi" ,&tree_Phi ,"Phi/F");
1106  MyTree->Branch("Thickness" ,&tree_Thickness ,"Thickness/F");
1107  MyTree->Branch("FitMPV" ,&tree_FitMPV ,"FitMPV/F");
1108  MyTree->Branch("FitMPVErr" ,&tree_FitMPVErr ,"FitMPVErr/F");
1109  MyTree->Branch("FitWidth" ,&tree_FitWidth ,"FitWidth/F");
1110  MyTree->Branch("FitWidthErr" ,&tree_FitWidthErr,"FitWidthErr/F");
1111  MyTree->Branch("FitChi2NDF" ,&tree_FitChi2NDF ,"FitChi2NDF/F");
1112  MyTree->Branch("FitNorm" ,&tree_FitNorm ,"FitNorm/F");
1113  MyTree->Branch("Gain" ,&tree_Gain ,"Gain/D");
1114  MyTree->Branch("PrevGain" ,&tree_PrevGain ,"PrevGain/D");
1115  MyTree->Branch("PrevGainTick" ,&tree_PrevGainTick,"PrevGainTick/D");
1116  MyTree->Branch("NEntries" ,&tree_NEntries ,"NEntries/D");
1117  MyTree->Branch("isMasked" ,&tree_isMasked ,"isMasked/O");
1118 
1119 
1120  FILE* Gains = stdout;
1121  fprintf(Gains,"NEvents = %i\n",NEvent);
1122  fprintf(Gains,"NTracks = %i\n",NTrack);
1123  fprintf(Gains,"NClustersPixel = %i\n",NClusterPixel);
1124  fprintf(Gains,"NClustersStrip = %i\n",NClusterStrip);
1125  fprintf(Gains,"Number of Pixel Dets = %lu\n",static_cast<unsigned long>(NPixelDets));
1126  fprintf(Gains,"Number of Strip APVs = %lu\n",static_cast<unsigned long>(NStripAPVs));
1127  fprintf(Gains,"GoodFits = %i BadFits = %i ratio = %f%% (MASKED=%i)\n",GOOD,BAD,(100.0*GOOD)/(GOOD+BAD), MASKED);
1128 
1129  Gains=fopen(OutputGains.c_str(),"w");
1130  fprintf(Gains,"NEvents = %i\n",NEvent);
1131  fprintf(Gains,"NTracks = %i\n",NTrack);
1132  fprintf(Gains,"NClustersPixel = %i\n",NClusterPixel);
1133  fprintf(Gains,"NClustersStrip = %i\n",NClusterStrip);
1134  fprintf(Gains,"Number of Strip APVs = %lu\n",static_cast<unsigned long>(NStripAPVs));
1135  fprintf(Gains,"Number of Pixel Dets = %lu\n",static_cast<unsigned long>(NPixelDets));
1136  fprintf(Gains,"GoodFits = %i BadFits = %i ratio = %f%% (MASKED=%i)\n",GOOD,BAD,(100.0*GOOD)/(GOOD+BAD), MASKED);
1137 
1138  int elepos = statCollectionFromMode(m_calibrationMode.c_str());
1139 
1140  for(unsigned int a=0;a<APVsCollOrdered.size();a++){
1142  if(APV==NULL)continue;
1143 // printf( "%i | %i | PreviousGain = %7.5f NewGain = %7.5f (#clusters=%8.0f)\n", APV->DetId,APV->APVId,APV->PreviousGain,APV->Gain, APV->NEntries);
1144  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);
1145 
1146  tree_Index = APV->Index;
1147  tree_Bin = (Charge_Vs_Index[elepos])->getTH2S()->GetXaxis()->FindBin(APV->Index);
1148  tree_DetId = APV->DetId;
1149  tree_APVId = APV->APVId;
1150  tree_SubDet = APV->SubDet;
1151  tree_x = APV->x;
1152  tree_y = APV->y;
1153  tree_z = APV->z;
1154  tree_Eta = APV->Eta;
1155  tree_R = APV->R;
1156  tree_Phi = APV->Phi;
1157  tree_Thickness = APV->Thickness;
1158  tree_FitMPV = APV->FitMPV;
1159  tree_FitMPVErr = APV->FitMPVErr;
1160  tree_FitWidth = APV->FitWidth;
1161  tree_FitWidthErr= APV->FitWidthErr;
1162  tree_FitChi2NDF = APV->FitChi2;
1163  tree_FitNorm = APV->FitNorm;
1164  tree_Gain = APV->Gain;
1165  tree_PrevGain = APV->PreviousGain;
1166  tree_PrevGainTick = APV->PreviousGainTick;
1167  tree_NEntries = APV->NEntries;
1168  tree_isMasked = APV->isMasked;
1169 
1170 
1171  if(tree_DetId==402673324){
1172  printf("%i | %i : %f --> %f (%f)\n", tree_DetId, tree_APVId, tree_PrevGain, tree_Gain, tree_NEntries);
1173  }
1174 
1175 
1176  MyTree->Fill();
1177  }
1178  if(Gains)fclose(Gains);
1179 
1180 
1181 }
1182 
1184 
1185  // The goal of this function is to check wether or not there is enough statistics
1186  // to produce a meaningful tag for the DB
1187  int elepos = (AlgoMode == "PCL")? Harvest : statCollectionFromMode(m_calibrationMode.c_str());
1188  if( Charge_Vs_Index[elepos]==0 ) {
1189  edm::LogError("SiStripGainFromCalibTree") << "produceTagFilter -> Return false: could not retrieve the "
1190  << m_calibrationMode.c_str() << " statistics.\n"
1191  << "Please check if input contains "
1192  << m_calibrationMode.c_str() << " data." << std::endl;
1193  return false;
1194  }
1195 
1196 
1197  float integral = (Charge_Vs_Index[elepos])->getTH2S()->Integral();
1198  if( (Charge_Vs_Index[elepos])->getTH2S()->Integral(0,NStripAPVs+1, 0, 99999 ) < tagCondition_NClusters) {
1199  edm::LogWarning("SiStripGainFromCalibTree")
1200  << "calibrationMode -> " << m_calibrationMode << "\n"
1201  << "produceTagFilter -> Return false: Statistics is too low : " << integral << endl;
1202  return false;
1203  }
1204  if((1.0 * GOOD) / (GOOD+BAD) < tagCondition_GoodFrac) {
1205  edm::LogWarning("SiStripGainFromCalibTree")
1206  << "calibrationMode -> " << m_calibrationMode << "\n"
1207  << "produceTagFilter -> Return false: ratio of GOOD/TOTAL is too low: " << (1.0 * GOOD) / (GOOD+BAD) << endl;
1208  return false;
1209  }
1210  return true;
1211 }
1212 
1214 {
1216  if(!m_harvestingMode) return obj;
1217 
1218  if(!produceTagFilter()){
1219  edm::LogWarning("SiStripGainFromCalibTree")<< "getNewObject -> will not produce a paylaod because produceTagFilter returned false " << endl;
1220  setDoStore(false);
1221  return obj;
1222  }
1223 
1224 
1225  std::vector<float>* theSiStripVector = NULL;
1226  unsigned int PreviousDetId = 0;
1227  for(unsigned int a=0;a<APVsCollOrdered.size();a++){
1229  if(APV==NULL){ printf("Bug\n"); continue; }
1230  if(APV->SubDet<=2)continue;
1231  if(APV->DetId != PreviousDetId){
1232  if(theSiStripVector!=NULL){
1233  SiStripApvGain::Range range(theSiStripVector->begin(),theSiStripVector->end());
1234  if ( !obj->put(PreviousDetId,range) ) printf("Bug to put detId = %i\n",PreviousDetId);
1235  }
1236  theSiStripVector = new std::vector<float>;
1237  PreviousDetId = APV->DetId;
1238  }
1239  theSiStripVector->push_back(APV->Gain);
1240  }
1241  if(theSiStripVector!=NULL){
1242  SiStripApvGain::Range range(theSiStripVector->begin(),theSiStripVector->end());
1243  if ( !obj->put(PreviousDetId,range) ) printf("Bug to put detId = %i\n",PreviousDetId);
1244  }
1245 
1246  return obj;
1247 }
1248 
1249 
1251 {
1252 }
1253 
1255  if(!useCalibration)return;
1256 
1257  TChain* t1 = new TChain("SiStripCalib/APVGain");
1258  t1->Add(m_calibrationPath.c_str());
1259 
1260  unsigned int tree_DetId;
1261  unsigned char tree_APVId;
1262  double tree_Gain;
1263 
1264  t1->SetBranchAddress("DetId" ,&tree_DetId );
1265  t1->SetBranchAddress("APVId" ,&tree_APVId );
1266  t1->SetBranchAddress("Gain" ,&tree_Gain );
1267 
1268  for (unsigned int ientry = 0; ientry < t1->GetEntries(); ientry++) {
1269  t1->GetEntry(ientry);
1270  stAPVGain* APV = APVsColl[(tree_DetId<<4) | (unsigned int)tree_APVId];
1271  APV->CalibGain = tree_Gain;
1272  }
1273 }
1274 
1275 void
1277 {
1278  // in AlCaHarvesting mode we just need to run the logic in the endJob step
1279  if(m_harvestingMode) return;
1280 
1281  if(AlgoMode=="CalibTree")return;
1282 
1283  eventnumber = iEvent.id().event();
1284  runnumber = iEvent.id().run();
1285  auto handle01 = connect(TrigTech , TrigTech_token_ , iEvent);
1286  auto handle02 = connect(trackchi2ndof , trackchi2ndof_token_ , iEvent);
1287  auto handle03 = connect(trackp , trackp_token_ , iEvent);
1288  auto handle04 = connect(trackpt , trackpt_token_ , iEvent);
1289  auto handle05 = connect(tracketa , tracketa_token_ , iEvent);
1290  auto handle06 = connect(trackphi , trackphi_token_ , iEvent);
1291  auto handle07 = connect(trackhitsvalid, trackhitsvalid_token_, iEvent);
1292  auto handle08 = connect(trackindex , trackindex_token_ , iEvent);
1293  auto handle09 = connect(rawid , rawid_token_ , iEvent);
1294  auto handle11 = connect(localdirx , localdirx_token_ , iEvent);
1295  auto handle12 = connect(localdiry , localdiry_token_ , iEvent);
1296  auto handle13 = connect(localdirz , localdirz_token_ , iEvent);
1297  auto handle14 = connect(firststrip , firststrip_token_ , iEvent);
1298  auto handle15 = connect(nstrips , nstrips_token_ , iEvent);
1299  auto handle16 = connect(saturation , saturation_token_ , iEvent);
1300  auto handle17 = connect(overlapping , overlapping_token_ , iEvent);
1301  auto handle18 = connect(farfromedge , farfromedge_token_ , iEvent);
1302  auto handle19 = connect(charge , charge_token_ , iEvent);
1303  auto handle21 = connect(path , path_token_ , iEvent);
1304  auto handle22 = connect(chargeoverpath, chargeoverpath_token_, iEvent);
1305  auto handle23 = connect(amplitude , amplitude_token_ , iEvent);
1306  auto handle24 = connect(gainused , gainused_token_ , iEvent);
1307 
1308  auto handle25 = connect(trackalgo , trackalgo_token_ , iEvent);
1309 
1310  processEvent();
1311 }
1312 
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_
const std::vector< double > * chargeoverpath
double FitMPV
Definition: APVGainStruct.h:17
edm::EDGetTokenT< std::vector< unsigned int > > rawid_token_
const std::vector< unsigned char > * amplitude
bool isBFieldConsistentWithMode(const edm::EventSetup &iSetup) const
double PreviousGainTick
Definition: APVGainStruct.h:26
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:457
const std::vector< double > * trackchi2ndof
virtual void algoBeginRun(const edm::Run &run, const edm::EventSetup &iSetup) override
const std::vector< double > * localdirx
dispatcher processEvent(e, inputTag, standby)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
unsigned int APVId
Definition: APVGainStruct.h:8
float Thickness
Definition: APVGainStruct.h:16
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 &)
edm::Handle< T > connect(const T *&ptr, edm::EDGetTokenT< T > token, const edm::Event &evt)
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:7
const std::vector< unsigned int > * trackhitsvalid
float float float z
std::vector< MonitorElement * > Charge_Vs_PathlengthTECM2
bool isMasked
Definition: APVGainStruct.h:30
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
edm::EDGetTokenT< std::vector< unsigned int > > trackhitsvalid_token_
T x() const
Cartesian x coordinate.
std::vector< stAPVGain * > APVsCollOrdered
edm::EDGetTokenT< std::vector< double > > path_token_
double FitWidth
Definition: APVGainStruct.h:19
int iEvent
Definition: GenABIO.cc:230
double Gain
Definition: APVGainStruct.h:23
edm::EDGetTokenT< std::vector< int > > trackalgo_token_
double PreviousGain
Definition: APVGainStruct.h:25
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:5
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:22
double CalibGain
Definition: APVGainStruct.h:24
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
const std::vector< double > * gainused
double FitMPVErr
Definition: APVGainStruct.h:18
std::vector< MonitorElement * > Charge_Vs_PathlengthTECP1
edm::EDGetTokenT< std::vector< double > > localdirz_token_
const std::vector< unsigned short > * firststrip
std::vector< MonitorElement * > Charge_Vs_PathlengthTIDM
const std::vector< double > * localdiry
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:21
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:56
double NEntries
Definition: APVGainStruct.h:27
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:58
fixed size matrix
HLT enums.
virtual int ncolumns() const =0
double a
Definition: hdecay.h:121
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
bool isValid() const
Definition: ESHandle.h:47
const std::vector< double > * path
long double T
const std::vector< double > * trackphi
unsigned int SubDet
Definition: APVGainStruct.h:9
const std::vector< unsigned short > * nstrips
T const * product() const
Definition: ESHandle.h:86
edm::EDGetTokenT< std::vector< double > > gainused_token_
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:20
const SiStripApvGain::Range getRange(uint32_t detID) const
Definition: SiStripGain.h:66