CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ApvTimingHistograms.cc
Go to the documentation of this file.
8 #include "TProfile.h"
9 #include <iostream>
10 #include <sstream>
11 #include <iomanip>
12 
13 using namespace std;
14 using namespace sistrip;
15 
16 // -----------------------------------------------------------------------------
19  DQMStore* bei )
20  : CommissioningHistograms( pset.getParameter<edm::ParameterSet>("ApvTimingParameters"),
21  bei,
22  sistrip::APV_TIMING )
23 {
24  factory_ = auto_ptr<ApvTimingSummaryFactory>( new ApvTimingSummaryFactory );
26  << "[ApvTimingHistograms::" << __func__ << "]"
27  << " Constructing object...";
28 }
29 
30 // -----------------------------------------------------------------------------
34  << "[ApvTimingHistograms::" << __func__ << "]"
35  << " Destructing object...";
36 }
37 
38 // -----------------------------------------------------------------------------
42  << "[ApvTimingHistograms::" << __func__ << "]";
43 
44  // Some initialisation
45  uint16_t valid = 0;
46  HistosMap::const_iterator iter;
47  Analyses::iterator ianal;
48  std::map<std::string,uint16_t> errors;
49 
50  // Clear map holding analysis objects
51  for ( ianal = data().begin(); ianal != data().end(); ianal++ ) {
52  if ( ianal->second ) { delete ianal->second; }
53  }
54  data().clear();
55 
56  // Reset minimum / maximum delays
57  float time_min = 1. * sistrip::invalid_;
58  float time_max = -1. * sistrip::invalid_;
59  uint32_t device_min = sistrip::invalid_;
60  uint32_t device_max = sistrip::invalid_;
61 
62  // Iterate through map containing histograms
63  for ( iter = histos().begin();
64  iter != histos().end(); iter++ ) {
65 
66  // Check vector of histos is not empty
67  if ( iter->second.empty() ) {
69  << "[ApvTimingHistograms::" << __func__ << "]"
70  << " Zero histograms found!";
71  continue;
72  }
73 
74  // Retrieve pointers to histos
75  std::vector<TH1*> profs;
76  Histos::const_iterator ihis = iter->second.begin();
77  for ( ; ihis != iter->second.end(); ihis++ ) {
78  TProfile* prof = ExtractTObject<TProfile>().extract( (*ihis)->me_ );
79  if ( prof ) { profs.push_back(prof); }
80  }
81 
82  // Perform histo analysis
83  ApvTimingAnalysis* anal = new ApvTimingAnalysis( iter->first );
84  ApvTimingAlgorithm algo( this->pset(), anal );
85  algo.analysis( profs );
86  data()[iter->first] = anal;
87 
88  // Check if tick mark found
89  if ( !anal->foundTickMark() ) { continue; }
90 
91  // Find maximum time
92  if ( anal->time() > time_max ) {
93  time_max = anal->time();
94  device_max = iter->first;
95  }
96 
97  // Find minimum time
98  if ( anal->time() < time_min ) {
99  time_min = anal->time();
100  device_min = iter->first;
101  }
102 
103  }
104 
105  // Adjust maximum (and minimum) delay(s) to find optimum sampling point(s)
106  if ( time_max > sistrip::valid_ ||
107  time_max < -1.*sistrip::valid_ ) {
108 
110  << "[ApvTimingHistograms::" << __func__ << "]"
111  << " Unable to set maximum time! Found unexpected value: "
112  << time_max;
113 
114  } else {
115 
116  SiStripFecKey min( device_min );
118  << "[ApvTimingHistograms::" << __func__ << "]"
119  << " Crate/FEC/Ring/CCU/module/channel: "
120  << min.fecCrate() << "/"
121  << min.fecSlot() << "/"
122  << min.fecRing() << "/"
123  << min.ccuAddr() << "/"
124  << min.ccuChan() << "/"
125  << min.lldChan()
126  << " has minimum time for tick mark rising edge [ns]: " << time_min;
127 
128  SiStripFecKey max( device_max );
130  << "[ApvTimingHistograms::" << __func__ << "]"
131  << " Crate/FEC/Ring/CCU/module/channel: "
132  << max.fecCrate() << "/"
133  << max.fecSlot() << "/"
134  << max.fecRing() << "/"
135  << max.ccuAddr() << "/"
136  << max.ccuChan() << "/"
137  << max.lldChan()
138  << " has maximum time for tick mark rising edge [ns]: " << time_max;
139 
141  << "[ApvTimingHistograms::" << __func__ << "]"
142  << " Difference b/w minimum and maximum times"
143  << " for tick mark rising edges [ns] is: " << ( time_max - time_min );
144 
145  }
146 
147  // Set reference time for all analysis objects
148  for ( ianal = data().begin(); ianal != data().end(); ianal++ ) {
149  ApvTimingAnalysis* anal = dynamic_cast<ApvTimingAnalysis*>(ianal->second);
150  if ( !anal ) { continue; }
151  anal->refTime( time_max, this->pset().getParameter<int>("TargetDelay") );
152  if ( anal->isValid() ) { valid++; }
153  if ( !anal->getErrorCodes().empty() ) {
154  errors[anal->getErrorCodes()[0]]++;
155  }
156  }
157 
158  if ( !histos().empty() ) {
160  << "[ApvTimingHistograms::" << __func__ << "]"
161  << " Analyzed histograms for " << histos().size()
162  << " FED channels, of which " << valid
163  << " (" << 100 * valid / histos().size()
164  << "%) are valid.";
165  } else {
167  << "[ApvTimingHistograms::" << __func__ << "]"
168  << " No histograms to analyze!";
169  }
170 
171  if ( !histos().empty() ) {
173  << "[ApvTimingHistograms::" << __func__ << "]"
174  << " Analyzed histograms for " << histos().size()
175  << " FED channels, of which " << valid
176  << " (" << 100 * valid / histos().size()
177  << "%) are valid.";
178  if ( !errors.empty() ) {
179  uint16_t count = 0;
180  std::stringstream ss;
181  ss << std::endl;
182  std::map<std::string,uint16_t>::const_iterator ii;
183  for ( ii = errors.begin(); ii != errors.end(); ++ii ) {
184  ss << " " << ii->first << ": " << ii->second << std::endl;
185  count += ii->second;
186  }
188  << "[ApvTimingHistograms::" << __func__ << "]"
189  << " Found " << count << " errors ("
190  << 100 * count / histos().size() << "%): "
191  << ss.str();
192  }
193  } else {
195  << "[ApvTimingHistograms::" << __func__ << "]"
196  << " No histograms to analyze!";
197  }
198 
199 }
void analysis(const std::vector< TH1 * > &)
const uint16_t & fecRing() const
const edm::ParameterSet & pset() const
const float & refTime() const
Analysis for timing run using APV tick marks.
static const char mlDqmClient_[]
const uint16_t & lldChan() const
#define min(a, b)
Definition: mlp_lapack.h:161
const uint16_t & fecSlot() const
static const uint16_t valid_
Definition: Constants.h:18
Utility class that identifies a position within the strip tracker control structure, down to the level of an APV25.
Definition: SiStripFecKey.h:46
const T & max(const T &a, const T &b)
void histoAnalysis(bool debug)
const float & time() const
#define LogTrace(id)
const uint16_t & fecCrate() const
int extract(std::vector< int > *output, const std::string &dati)
const uint16_t & ccuAddr() const
static const uint16_t invalid_
Definition: Constants.h:17
std::auto_ptr< Factory > factory_
#define begin
Definition: vmac.h:31
const uint16_t & ccuChan() const
LimitAlgo * algo
Definition: Combine.cc:60
#define debug
Definition: MEtoEDMFormat.h:34
Analysis for timing run using APV tick marks.
const VString & getErrorCodes() const
bool foundTickMark() const
ApvTimingHistograms(const edm::ParameterSet &pset, DQMStore *)
const HistosMap & histos() const