Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:44:59

0001 #include <Alignment/HIPAlignmentAlgorithm/interface/HIPMonitorConfig.h>
0002 
0003 HIPMonitorConfig::HIPMonitorConfig(const edm::ParameterSet& cfg)
0004     : cfgMonitor(cfg.getParameter<edm::ParameterSet>("monitorConfig")),
0005       outfilecore(cfgMonitor.getParameter<std::string>("outfile")),
0006       maxEventsPerJob(cfgMonitor.getParameter<int>("maxEventsPerJob")),
0007       fillTrackMonitoring(cfgMonitor.getParameter<bool>("fillTrackMonitoring")),
0008       maxTracks(cfgMonitor.getParameter<int>("maxTracks")),
0009       trackmonitorvars(maxEventsPerJob, maxTracks),
0010       fillTrackHitMonitoring(cfgMonitor.getParameter<bool>("fillTrackHitMonitoring")),
0011       maxHits(cfgMonitor.getParameter<int>("maxHits")),
0012       hitmonitorvars(maxHits),
0013       eventCounter(0),
0014       hitCounter(0) {
0015   outfile = cfg.getParameter<std::string>("outpath") + outfilecore;
0016 }
0017 
0018 HIPMonitorConfig::HIPMonitorConfig(const HIPMonitorConfig& other)
0019     : cfgMonitor(other.cfgMonitor),
0020       outfilecore(other.outfilecore),
0021       maxEventsPerJob(other.maxEventsPerJob),
0022       fillTrackMonitoring(other.fillTrackMonitoring),
0023       maxTracks(other.maxTracks),
0024       fillTrackHitMonitoring(other.fillTrackHitMonitoring),
0025       maxHits(other.maxHits),
0026       outfile(other.outfile),
0027       eventCounter(other.eventCounter),
0028       hitCounter(other.hitCounter) {}
0029 
0030 bool HIPMonitorConfig::checkNevents() {
0031   bool res = (maxEventsPerJob < 0 || maxEventsPerJob > eventCounter);
0032   eventCounter++;
0033   return res;
0034 }
0035 bool HIPMonitorConfig::checkNhits() {
0036   bool res = (maxHits < 0 || maxHits > hitCounter);
0037   hitCounter++;
0038   return res;
0039 }
0040 
0041 void HIPTrackMonitorVariables::bookBranches() {
0042   if (tree != nullptr) {
0043     tree->Branch("Ntracks", &m_Ntracks);
0044     tree->Branch("Nhits", &m_Nhits);
0045     //tree->Branch("DataType", &m_datatype); This is done in HIPAlignmentAlgorithm
0046     tree->Branch("nhPXB", &m_nhPXB);
0047     tree->Branch("nhPXF", &m_nhPXF);
0048     tree->Branch("nhTIB", &m_nhTIB);
0049     tree->Branch("nhTOB", &m_nhTOB);
0050     tree->Branch("nhTID", &m_nhTID);
0051     tree->Branch("nhTEC", &m_nhTEC);
0052     tree->Branch("Pt", &m_Pt);
0053     tree->Branch("P", &m_P);
0054     tree->Branch("Eta", &m_Eta);
0055     tree->Branch("Phi", &m_Phi);
0056     tree->Branch("Chi2n", &m_Chi2n);
0057     tree->Branch("d0", &m_d0);
0058     tree->Branch("dz", &m_dz);
0059     tree->Branch("wt", &m_wt);
0060   }
0061 }
0062 void HIPHitMonitorVariables::bookBranches() {
0063   if (tree != nullptr) {
0064     tree->Branch("Id", &m_detId, "Id/i");
0065     tree->Branch("sinTheta", &m_sinTheta);
0066     tree->Branch("impactAngle", &m_angle);
0067     tree->Branch("wt", &m_hitwt);
0068     tree->Branch("probPresent", &m_hasHitProb);
0069     tree->Branch("probXY", &m_probXY);
0070     tree->Branch("probQ", &m_probQ);
0071     tree->Branch("qualityWord", &m_rawQualityWord);
0072   }
0073 }
0074 void HIPTrackMonitorVariables::fill() {
0075   if (tree == nullptr)
0076     return;
0077   if (maxNEvents >= 0 && nEvents >= maxNEvents)
0078     return;
0079 
0080   bool doFill = false;
0081   m_Ntracks = m_Pt.size();
0082   if (m_Ntracks == 0)
0083     return;
0084 
0085   if (maxTracksRcd < 0)
0086     doFill = true;
0087   else if (nTracks < maxTracksRcd) {
0088     if ((nTracks + m_Ntracks) < maxTracksRcd)
0089       doFill = true;
0090     else {
0091       int NewSize = maxTracksRcd - nTracks;
0092       if ((int)m_Pt.size() < NewSize)
0093         NewSize = m_Pt.size();
0094 
0095       // Do not touch m_Ntracks, just resize these vectors
0096       resizeVectors(NewSize);
0097 
0098       doFill = true;
0099     }
0100   } else {
0101     // Record only m_Ntracks
0102     int tmpNtracks = m_Ntracks;
0103     resetPerEvent();
0104     m_Ntracks = tmpNtracks;
0105 
0106     doFill = true;
0107   }
0108 
0109   if (doFill) {
0110     tree->Fill();
0111     nEvents++;
0112     nTracks += m_Ntracks;
0113   }
0114 
0115   resetPerEvent();
0116 }
0117 void HIPHitMonitorVariables::fill() {
0118   if (tree == nullptr)
0119     return;
0120 
0121   bool doFill = (maxHitsRcd < 0 || nHits < maxHitsRcd);
0122 
0123   if (doFill) {
0124     tree->Fill();
0125     nHits++;
0126   }
0127 
0128   resetPerHit();
0129 }