Record thresholds from the ODB. More...
Functions | |
INT | MDQ_Thresholds_init (void) |
INT | MDQ_Thresholds (EVENT_HEADER *, void *) |
INT | MDQ_Thresholds_eor (INT) |
Variables | |
HNDLE | hDB |
TGlobalData * | gData |
Object to hold data used and produced by modules throughout alcapana stage of analysis. | |
TSetupData * | gSetup |
Hardware information about digitizers and detectors to be used during alcapana stage of analysis. | |
map< std::string, TH1F * > | DQ_Thresholds_histograms_map |
Map of bank name to histogram. FADC histograms have 2 entries, one each for an upper and lower trigger threshold. CAENs have single entry. | |
ANA_MODULE | MDQ_Thresholds_module |
Record thresholds from the ODB.
Record thresholds from ODB as entries in a histogram per bank.
INT MDQ_Thresholds | ( | EVENT_HEADER * | pheader, | |
void * | pevent | |||
) |
This method fills the histograms
Definition at line 238 of file MDQ_Thresholds.cpp.
00239 { 00240 // Get the event number 00241 int midas_event_number = pheader->serial_number; 00242 00243 // Some typedefs 00244 typedef map<string, vector<TPulseIsland*> > TStringPulseIslandMap; 00245 typedef pair<string, vector<TPulseIsland*> > TStringPulseIslandPair; 00246 typedef map<string, vector<TPulseIsland*> >::iterator map_iterator; 00247 00248 // Don't need anything here 00249 00250 return SUCCESS; 00251 }
INT MDQ_Thresholds_eor | ( | INT | run_number | ) |
This method does any last minute things to the histograms at the end of the run
Definition at line 115 of file MDQ_Thresholds.cpp.
References DQ_Thresholds_histograms_map, TSetupData::fBankToDetectorMap, hDB, TSetupData::Instance(), and TSetupData::IsFADC().
00115 { 00116 00117 // Get the run duration to scale the histogram 00118 HNDLE hDB, hKey; 00119 char keyName[200]; 00120 00121 if(cm_get_experiment_database(&hDB, NULL) != CM_SUCCESS){ 00122 printf("Warning: Could not connect to ODB database!\n"); 00123 return false; 00124 } 00125 00126 // Loop through the channels and get the thresholds 00127 std::map<std::string, std::string> bank_to_detector_map = gSetup->fBankToDetectorMap; 00128 for(std::map<std::string, std::string>::iterator mapIter = bank_to_detector_map.begin(); 00129 mapIter != bank_to_detector_map.end(); mapIter++) { 00130 00131 std::string bankname = mapIter->first; 00132 00133 if (TSetupData::Instance()->IsFADC(bankname)) { 00134 // get the FADC thresholds (both upper and lower) 00135 00136 // first get the channel and address from the bankname 00137 int iChn = (int)(bankname[1] - 97); 00138 std::string iAddr = bankname.substr(2, 2); 00139 00140 // Get the lower threshold 00141 sprintf(keyName, "/Equipment/Crate 9/Settings/NFADC %s/Channel %d/Lower threshold", iAddr.c_str(), iChn); 00142 if(db_find_key(hDB,0,keyName, &hKey) != SUCCESS){ 00143 printf("Warning: Could not find key %s\n", keyName); 00144 return false; 00145 } 00146 KEY lower_threshold_key; 00147 if(db_get_key(hDB, hKey, &lower_threshold_key) != DB_SUCCESS){ 00148 printf("Warning: Could not find key %s\n", keyName); 00149 return false; 00150 } 00151 INT LowerThresholds[lower_threshold_key.num_values]; 00152 int size = sizeof(LowerThresholds); 00153 if(db_get_value(hDB, 0, keyName, LowerThresholds, &size, TID_INT, 0) != DB_SUCCESS){ 00154 printf("Warning: Could not retrieve values for key %s\n", keyName); 00155 return false; 00156 } 00157 00158 00159 // Upper threshold 00160 sprintf(keyName, "/Equipment/Crate 9/Settings/NFADC %s/Channel %d/Upper threshold", iAddr.c_str(), iChn); 00161 if(db_find_key(hDB,0,keyName, &hKey) != SUCCESS){ 00162 printf("Warning: Could not find key %s\n", keyName); 00163 return false; 00164 } 00165 KEY upper_threshold_key; 00166 if(db_get_key(hDB, hKey, &upper_threshold_key) != DB_SUCCESS){ 00167 printf("Warning: Could not find key %s\n", keyName); 00168 return false; 00169 } 00170 INT UpperThresholds[upper_threshold_key.num_values]; 00171 size = sizeof(UpperThresholds); 00172 if(db_get_value(hDB, 0, keyName, UpperThresholds, &size, TID_INT, 0) != DB_SUCCESS){ 00173 printf("Warning: Could not retrieve values for key %s\n", keyName); 00174 return false; 00175 } 00176 00177 // Print the results 00178 DQ_Thresholds_histograms_map[bankname]->Fill("lower threshold", LowerThresholds[0]); 00179 DQ_Thresholds_histograms_map[bankname]->Fill("upper threshold", UpperThresholds[0]); 00180 } 00181 else if (TSetupData::Instance()->IsHoustonCAEN(bankname)) { 00182 // get the UH CAEN thresholds 00183 00184 // first get the channel and address from the bankname 00185 int iChn = (int)(bankname[1] - 97); 00186 00187 // Get the threshold 00188 sprintf(keyName, "/Equipment/Crate 4/Settings/CAEN0/Ch%d/trigger threshhold", iChn); 00189 if(db_find_key(hDB,0,keyName, &hKey) != SUCCESS){ 00190 printf("Warning: Could not find key %s\n", keyName); 00191 return false; 00192 } 00193 KEY threshold_key; 00194 if(db_get_key(hDB, hKey, &threshold_key) != DB_SUCCESS){ 00195 printf("Warning: Could not find key %s\n", keyName); 00196 return false; 00197 } 00198 DWORD Thresholds[threshold_key.num_values]; 00199 int size = sizeof(Thresholds); 00200 if(db_get_value(hDB, 0, keyName, Thresholds, &size, TID_DWORD, 0) != DB_SUCCESS){ 00201 printf("Warning: Could not retrieve values for key %s\n", keyName); 00202 return false; 00203 } 00204 DQ_Thresholds_histograms_map[bankname]->Fill("trigger threshold", Thresholds[0]); 00205 } 00206 else if (TSetupData::Instance()->IsBostonCAEN(bankname)) { 00207 // get the BU CAEN thresholds 00208 00209 // first get the channel and address from the bankname 00210 int iChn = (int)(bankname[1] - 97); 00211 00212 // Get the threshold 00213 sprintf(keyName, "/Equipment/Crate 5/Settings/CAEN/Ch0%d/self_trigger_threshhold", iChn); 00214 if(db_find_key(hDB,0,keyName, &hKey) != SUCCESS){ 00215 printf("Warning: Could not find key %s\n", keyName); 00216 return false; 00217 } 00218 KEY threshold_key; 00219 if(db_get_key(hDB, hKey, &threshold_key) != DB_SUCCESS){ 00220 printf("Warning: Could not find key %s\n", keyName); 00221 return false; 00222 } 00223 float Thresholds[threshold_key.num_values]; 00224 int size = sizeof(Thresholds); 00225 if(db_get_value(hDB, 0, keyName, Thresholds, &size, TID_FLOAT, 0) != DB_SUCCESS){ 00226 printf("Warning: Could not retrieve values for key %s\n", keyName); 00227 return false; 00228 } 00229 DQ_Thresholds_histograms_map[bankname]->Fill("self_trigger_threshold", Thresholds[0]); 00230 } 00231 } 00232 00233 return SUCCESS; 00234 }
INT MDQ_Thresholds_init | ( | ) |
This method initializes histograms.
Definition at line 81 of file MDQ_Thresholds.cpp.
References DQ_Thresholds_histograms_map, TSetupData::fBankToDetectorMap, and TSetupData::GetDetectorName().
00082 { 00083 // See if the DataQuality_LowLevel/ directory already exists 00084 if (!gDirectory->Cd("DataQuality_LowLevel")) { 00085 00086 std::string dir_name("DataQuality_LowLevel/"); 00087 gDirectory->mkdir(dir_name.c_str()); 00088 gDirectory->Cd(dir_name.c_str()); 00089 } 00090 00091 // Create a histogram for each channel 00092 std::map<std::string, std::string> bank_to_detector_map = gSetup->fBankToDetectorMap; 00093 for(std::map<std::string, std::string>::iterator mapIter = bank_to_detector_map.begin(); 00094 mapIter != bank_to_detector_map.end(); mapIter++) { 00095 00096 std::string bankname = mapIter->first; 00097 std::string detname = gSetup->GetDetectorName(bankname); 00098 00099 // hDQ_Thresholds_[DetName]_[BankName] 00100 std::string histname = "hDQ_Thresholds_" + detname + "_" + bankname; 00101 std::string histtitle = "ODB Thresholds in " + bankname; 00102 TH1F* hDQ_Histogram = new TH1F(histname.c_str(), histtitle.c_str(), 00103 2,0,2); // will want an upper and lower threshold for FADC channels 00104 hDQ_Histogram->GetXaxis()->SetTitle(""); 00105 hDQ_Histogram->GetYaxis()->SetTitle("Threshold"); 00106 DQ_Thresholds_histograms_map[bankname] = hDQ_Histogram; 00107 } 00108 00109 gDirectory->Cd("/MidasHists/"); 00110 return SUCCESS; 00111 }
Map of bank name to histogram. FADC histograms have 2 entries, one each for an upper and lower trigger threshold. CAENs have single entry.
Definition at line 63 of file MDQ_Thresholds.cpp.
Referenced by MDQ_Thresholds_eor(), and MDQ_Thresholds_init().
Object to hold data used and produced by modules throughout alcapana stage of analysis.
Definition at line 76 of file analyzer.cpp.
Hardware information about digitizers and detectors to be used during alcapana stage of analysis.
Definition at line 80 of file analyzer.cpp.
HNDLE hDB |
ANA_MODULE MDQ_Thresholds_module |
{ "MDQ_Thresholds", "Andrew Edmonds", MDQ_Thresholds, NULL, MDQ_Thresholds_eor, MDQ_Thresholds_init, NULL, NULL, 0, NULL, }
Definition at line 65 of file MDQ_Thresholds.cpp.