CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_0/src/Validation/GlobalDigis/src/GlobalDigisAnalyzer.cc

Go to the documentation of this file.
00001 
00010 #include "Validation/GlobalDigis/interface/GlobalDigisAnalyzer.h"
00011 #include "DQMServices/Core/interface/DQMStore.h"
00012 
00013 GlobalDigisAnalyzer::GlobalDigisAnalyzer(const edm::ParameterSet& iPSet) :
00014   fName(""), verbosity(0), frequency(0), label(""), getAllProvenances(false),
00015   printProvenanceInfo(false), hitsProducer(""), theCSCStripPedestalSum(0),
00016   theCSCStripPedestalCount(0), count(0)
00017 {
00018   std::string MsgLoggerCat = "GlobalDigisAnalyzer_GlobalDigisAnalyzer";
00019 
00020   // get information from parameter set
00021   fName = iPSet.getUntrackedParameter<std::string>("Name");
00022   verbosity = iPSet.getUntrackedParameter<int>("Verbosity");
00023   frequency = iPSet.getUntrackedParameter<int>("Frequency");
00024   edm::ParameterSet m_Prov =
00025     iPSet.getParameter<edm::ParameterSet>("ProvenanceLookup");
00026   getAllProvenances = 
00027     m_Prov.getUntrackedParameter<bool>("GetAllProvenances");
00028   printProvenanceInfo = 
00029     m_Prov.getUntrackedParameter<bool>("PrintProvenanceInfo");
00030   hitsProducer = iPSet.getParameter<std::string>("hitsProducer");
00031   
00032   //get Labels to use to extract information
00033   ECalEBSrc_ = iPSet.getParameter<edm::InputTag>("ECalEBSrc");
00034   ECalEESrc_ = iPSet.getParameter<edm::InputTag>("ECalEESrc");
00035   ECalESSrc_ = iPSet.getParameter<edm::InputTag>("ECalESSrc");
00036   HCalSrc_ = iPSet.getParameter<edm::InputTag>("HCalSrc");
00037   HCalDigi_ = iPSet.getParameter<edm::InputTag>("HCalDigi");
00038   SiStripSrc_ = iPSet.getParameter<edm::InputTag>("SiStripSrc"); 
00039   SiPxlSrc_ = iPSet.getParameter<edm::InputTag>("SiPxlSrc");
00040   MuDTSrc_ = iPSet.getParameter<edm::InputTag>("MuDTSrc");
00041   MuCSCStripSrc_ = iPSet.getParameter<edm::InputTag>("MuCSCStripSrc");
00042   MuCSCWireSrc_ = iPSet.getParameter<edm::InputTag>("MuCSCWireSrc");
00043   MuRPCSrc_ = iPSet.getParameter<edm::InputTag>("MuRPCSrc");
00044   
00045   // use value of first digit to determine default output level (inclusive)
00046   // 0 is none, 1 is basic, 2 is fill output, 3 is gather output
00047   verbosity %= 10;
00048   
00049   // print out Parameter Set information being used
00050   if (verbosity >= 0) {
00051     edm::LogInfo(MsgLoggerCat) 
00052       << "\n===============================\n"
00053       << "Initialized as EDAnalyzer with parameter values:\n"
00054       << "    Name          = " << fName << "\n"
00055       << "    Verbosity     = " << verbosity << "\n"
00056       << "    Frequency     = " << frequency << "\n"
00057       << "    GetProv       = " << getAllProvenances << "\n"
00058       << "    PrintProv     = " << printProvenanceInfo << "\n"
00059       << "    ECalEBSrc     = " << ECalEBSrc_.label() 
00060       << ":" << ECalEBSrc_.instance() << "\n"
00061       << "    ECalEESrc     = " << ECalEESrc_.label() 
00062       << ":" << ECalEESrc_.instance() << "\n"
00063       << "    ECalESSrc     = " << ECalESSrc_.label() 
00064       << ":" << ECalESSrc_.instance() << "\n"
00065       << "    HCalSrc       = " << HCalSrc_.label() 
00066       << ":" << HCalSrc_.instance() << "\n"
00067       << "    HCalDigi       = " << HCalDigi_.label() 
00068       << ":" << HCalDigi_.instance() << "\n"
00069       << "    SiStripSrc    = " << SiStripSrc_.label() 
00070       << ":" << SiStripSrc_.instance() << "\n" 
00071       << "    SiPixelSrc    = " << SiPxlSrc_.label()
00072       << ":" << SiPxlSrc_.instance() << "\n"
00073       << "    MuDTSrc       = " << MuDTSrc_.label()
00074       << ":" << MuDTSrc_.instance() << "\n"
00075       << "    MuCSCStripSrc = " << MuCSCStripSrc_.label()
00076       << ":" << MuCSCStripSrc_.instance() << "\n"
00077       << "    MuCSCWireSrc  = " << MuCSCWireSrc_.label()
00078       << ":" << MuCSCWireSrc_.instance() << "\n"
00079       << "    MuRPCSrc      = " << MuRPCSrc_.label()
00080       << ":" << MuRPCSrc_.instance() << "\n"
00081       << "===============================\n";
00082   }
00083   
00084   //Put in analyzer stuff here.... Pasted from Rec Hits... 
00085   
00086   dbe = 0;
00087   dbe = edm::Service<DQMStore>().operator->();
00088   if (dbe) {
00089     if (verbosity > 0 ) {
00090       dbe->setVerbose(1);
00091     } else {
00092       dbe->setVerbose(0);
00093     }
00094   }
00095   if (dbe) {
00096     if (verbosity > 0 ) dbe->showDirStructure();
00097   }
00098   
00099   //monitor elements 
00100   
00101   //Si Strip
00102   if (dbe) {
00103     std::string SiStripString[19] = {"TECW1", "TECW2", "TECW3", "TECW4", 
00104                                      "TECW5", "TECW6", "TECW7", "TECW8", 
00105                                      "TIBL1", "TIBL2", "TIBL3", "TIBL4", 
00106                                      "TIDW1", "TIDW2", "TIDW3", "TOBL1", 
00107                                      "TOBL2", "TOBL3", "TOBL4"};
00108     for(int i = 0; i<19; ++i) {
00109       mehSiStripn[i]=0;
00110       mehSiStripADC[i]=0;
00111       mehSiStripStrip[i]=0;
00112     }
00113     std::string hcharname, hchartitle;
00114     dbe->setCurrentFolder("GlobalDigisV/SiStrips");
00115     for(int amend = 0; amend < 19; ++amend) { 
00116       hcharname = "hSiStripn_"+SiStripString[amend];
00117       hchartitle= SiStripString[amend]+"  Digis";
00118       mehSiStripn[amend] = dbe->book1D(hcharname,hchartitle,5000,0.,10000.);
00119       mehSiStripn[amend]->setAxisTitle("Number of Digis",1);
00120       mehSiStripn[amend]->setAxisTitle("Count",2);
00121       
00122       hcharname = "hSiStripADC_"+SiStripString[amend];
00123       hchartitle= SiStripString[amend]+" ADC";
00124       mehSiStripADC[amend] = dbe->book1D(hcharname,hchartitle,150,0.0,300.);
00125       mehSiStripADC[amend]->setAxisTitle("ADC",1);
00126       mehSiStripADC[amend]->setAxisTitle("Count",2);
00127       
00128       hcharname = "hSiStripStripADC_"+SiStripString[amend];
00129       hchartitle= SiStripString[amend]+" Strip";
00130       mehSiStripStrip[amend] = dbe->book1D(hcharname,hchartitle,200,0.0,800.);
00131       mehSiStripStrip[amend]->setAxisTitle("Strip Number",1);
00132       mehSiStripStrip[amend]->setAxisTitle("Count",2);
00133     }
00134     
00135     //HCal
00136     std::string HCalString[4] = {"HB", "HE", "HO","HF"}; 
00137     float calnUpper[4] = {30000.,30000.,30000.,20000.}; 
00138     float calnLower[4]={0.,0.,0.,0.}; 
00139     float SHEUpper[4]={1.,1.,1.,1.};
00140     float SHEvAEEUpper[4] = {5000, 5000, 5000, 5000}; 
00141     float SHEvAEELower[4] = {-5000, -5000, -5000, -5000}; 
00142     int SHEvAEEnBins[4] = {200,200,200,200};
00143     double ProfileUpper[4] = {1.,1.,1.,1.};  
00144     
00145     for(int i =0; i<4; ++i) {
00146       mehHcaln[i]=0;
00147       mehHcalAEE[i]=0;
00148       mehHcalSHE[i]=0;
00149       mehHcalAEESHE[i]=0;
00150       mehHcalSHEvAEE[i]=0;
00151     }
00152     dbe->setCurrentFolder("GlobalDigisV/HCals");
00153     
00154     for(int amend = 0; amend < 4; ++amend) {
00155       hcharname = "hHcaln_"+HCalString[amend];
00156       hchartitle= HCalString[amend]+"  digis";
00157       mehHcaln[amend] = dbe->book1D(hcharname,hchartitle, 10000, calnLower[amend], 
00158                                     calnUpper[amend]);
00159       mehHcaln[amend]->setAxisTitle("Number of Digis",1);
00160       mehHcaln[amend]->setAxisTitle("Count",2);
00161 
00162       hcharname = "hHcalAEE_"+HCalString[amend];
00163       hchartitle= HCalString[amend]+"Cal AEE";
00164       mehHcalAEE[amend] = dbe->book1D(hcharname,hchartitle, 60, -10., 50.);
00165       mehHcalAEE[amend]->setAxisTitle("Analog Equivalent Energy",1);
00166       mehHcalAEE[amend]->setAxisTitle("Count",2);
00167 
00168       hcharname = "hHcalSHE_"+HCalString[amend];
00169       hchartitle= HCalString[amend]+"Cal SHE";
00170       mehHcalSHE[amend] = dbe->book1D(hcharname,hchartitle, 1000, 0.0, 
00171                                       SHEUpper[amend]);
00172       mehHcalSHE[amend]->setAxisTitle("Simulated Hit Energy",1);
00173       mehHcalSHE[amend]->setAxisTitle("Count",2);
00174 
00175       hcharname = "hHcalAEESHE_"+HCalString[amend];
00176       hchartitle= HCalString[amend]+"Cal AEE/SHE";
00177       mehHcalAEESHE[amend] = dbe->book1D(hcharname, hchartitle, SHEvAEEnBins[amend], 
00178                                          SHEvAEELower[amend], 
00179                                          SHEvAEEUpper[amend]);
00180       mehHcalAEESHE[amend]->setAxisTitle("ADC / SHE",1);
00181       mehHcalAEESHE[amend]->setAxisTitle("Count",2);
00182       
00183       hcharname = "hHcalSHEvAEE_"+HCalString[amend];
00184       hchartitle= HCalString[amend]+"Cal SHE vs. AEE";
00185       mehHcalSHEvAEE[amend] = dbe->bookProfile(hcharname,hchartitle, 60, -10., 
00186                                                50., 100, 0., 
00187                                                (float)ProfileUpper[amend],"");
00188       mehHcalSHEvAEE[amend]->setAxisTitle("AEE / SHE",1);
00189       mehHcalSHEvAEE[amend]->setAxisTitle("SHE",2);
00190 
00191     }
00192     
00193     //Ecal
00194     std::string ECalString[2] = {"EB","EE"}; 
00195     
00196     for(int i =0; i<2; ++i) {
00197       mehEcaln[i]=0;
00198       mehEcalAEE[i]=0;
00199       mehEcalSHE[i]=0;
00200       mehEcalMaxPos[i]=0;
00201       mehEcalMultvAEE[i]=0;
00202       mehEcalSHEvAEESHE[i]=0;
00203     }
00204     dbe->setCurrentFolder("GlobalDigisV/ECals");
00205     
00206     for(int amend = 0; amend < 2; ++amend) {
00207       hcharname = "hEcaln_"+ECalString[amend];
00208       hchartitle= ECalString[amend]+"  digis";
00209       mehEcaln[amend] = dbe->book1D(hcharname,hchartitle, 3000, 0., 40000.);
00210       mehEcaln[amend]->setAxisTitle("Number of Digis",1);
00211       mehEcaln[amend]->setAxisTitle("Count",2);
00212 
00213       hcharname = "hEcalAEE_"+ECalString[amend];
00214       hchartitle= ECalString[amend]+"Cal AEE";
00215       mehEcalAEE[amend] = dbe->book1D(hcharname,hchartitle, 1000, 0., 100.);
00216       mehEcalAEE[amend]->setAxisTitle("Analog Equivalent Energy",1);
00217       mehEcalAEE[amend]->setAxisTitle("Count",2);
00218 
00219       hcharname = "hEcalSHE_"+ECalString[amend];
00220       hchartitle= ECalString[amend]+"Cal SHE";
00221       mehEcalSHE[amend] = dbe->book1D(hcharname,hchartitle, 500, 0., 50.);
00222       mehEcalSHE[amend]->setAxisTitle("Simulated Hit Energy",1);
00223       mehEcalSHE[amend]->setAxisTitle("Count",2);
00224 
00225       hcharname = "hEcalMaxPos_"+ECalString[amend];
00226       hchartitle= ECalString[amend]+"Cal MaxPos";
00227       mehEcalMaxPos[amend] = dbe->book1D(hcharname,hchartitle,10, 0., 10.);
00228       mehEcalMaxPos[amend]->setAxisTitle("Maximum Position",1);
00229       mehEcalMaxPos[amend]->setAxisTitle("Count",2);
00230       
00231       hcharname = "hEcalSHEvAEESHE_"+ECalString[amend];
00232       hchartitle= ECalString[amend]+"Cal SHE vs. AEE/SHE";
00233       mehEcalSHEvAEESHE[amend] = dbe->bookProfile(hcharname,hchartitle,1000, 0., 100., 
00234                                                   500, 0., 50.,"");
00235       mehEcalSHEvAEESHE[amend]->setAxisTitle("AEE / SHE",1);
00236       mehEcalSHEvAEESHE[amend]->setAxisTitle("SHE",2);
00237 
00238       hcharname = "hEcalMultvAEE_"+ECalString[amend];
00239       hchartitle= ECalString[amend]+"Cal Multi vs. AEE";
00240       mehEcalMultvAEE[amend] = dbe->bookProfile(hcharname,hchartitle, 1000, 0., 100., 
00241                                                 4000, 0., 40000.,"");
00242       mehEcalMultvAEE[amend]->setAxisTitle("Analog Equivalent Energy",1);
00243       mehEcalMultvAEE[amend]->setAxisTitle("Number of Digis",2);      
00244     }
00245     mehEScaln = 0;
00246 
00247     hcharname = "hEcaln_ES";
00248     hchartitle= "ESCAL  digis";
00249     mehEScaln = dbe->book1D(hcharname,hchartitle, 1000, 0., 5000.);
00250     mehEScaln->setAxisTitle("Number of Digis",1);
00251     mehEScaln->setAxisTitle("Count",2);
00252 
00253     std::string ADCNumber[3] = {"0", "1", "2"};
00254     for(int i =0; i<3; ++i) {
00255       mehEScalADC[i] = 0;
00256       hcharname = "hEcalADC"+ADCNumber[i]+"_ES";
00257       hchartitle= "ESCAL  ADC"+ADCNumber[i];
00258       mehEScalADC[i] = dbe->book1D(hcharname,hchartitle, 1500, 0., 1500.);
00259       mehEScalADC[i]->setAxisTitle("ADC"+ADCNumber[i],1);
00260       mehEScalADC[i]->setAxisTitle("Count",2);
00261     }
00262     
00263     //Si Pixels ***DONE***  
00264     std::string SiPixelString[7] = {"BRL1", "BRL2", "BRL3", "FWD1n", "FWD1p", 
00265                                     "FWD2n", "FWD2p"};
00266     for(int j =0; j<7; ++j) {
00267       mehSiPixeln[j]=0;
00268       mehSiPixelADC[j]=0;
00269       mehSiPixelRow[j]=0;
00270       mehSiPixelCol[j]=0;
00271     }
00272     
00273     dbe->setCurrentFolder("GlobalDigisV/SiPixels");
00274     for(int amend = 0; amend < 7; ++amend) {
00275       hcharname = "hSiPixeln_"+SiPixelString[amend];
00276       hchartitle= SiPixelString[amend]+" Digis";
00277       if(amend<3) mehSiPixeln[amend] = dbe->book1D(hcharname,hchartitle,500,0.,1000.);
00278       else mehSiPixeln[amend] = dbe->book1D(hcharname,hchartitle,500,0.,1000.);
00279       mehSiPixeln[amend]->setAxisTitle("Number of Digis",1);
00280       mehSiPixeln[amend]->setAxisTitle("Count",2);
00281       
00282       hcharname = "hSiPixelADC_"+SiPixelString[amend];
00283       hchartitle= SiPixelString[amend]+" ADC";
00284       mehSiPixelADC[amend] = dbe->book1D(hcharname,hchartitle,150,0.0,300.);
00285       mehSiPixelADC[amend]->setAxisTitle("ADC",1);
00286       mehSiPixelADC[amend]->setAxisTitle("Count",2);
00287 
00288       hcharname = "hSiPixelRow_"+SiPixelString[amend];
00289       hchartitle= SiPixelString[amend]+" Row";
00290       mehSiPixelRow[amend] = dbe->book1D(hcharname,hchartitle,100,0.0,100.);
00291       mehSiPixelRow[amend]->setAxisTitle("Row Number",1);
00292       mehSiPixelRow[amend]->setAxisTitle("Count",2);
00293 
00294       hcharname = "hSiPixelColumn_"+SiPixelString[amend];
00295       hchartitle= SiPixelString[amend]+" Column";
00296       mehSiPixelCol[amend] = dbe->book1D(hcharname,hchartitle,200,0.0,500.);
00297       mehSiPixelCol[amend]->setAxisTitle("Column Number",1);
00298       mehSiPixelCol[amend]->setAxisTitle("Count",2);
00299     }
00300 
00301     //Muons
00302     dbe->setCurrentFolder("GlobalDigisV/Muons");
00303 
00304     //DT
00305     std::string MuonString[4] = {"MB1", "MB2", "MB3", "MB4"};
00306     
00307     for(int i =0; i < 4; ++i) {
00308       mehDtMuonn[i] = 0;
00309       mehDtMuonLayer[i] = 0;
00310       mehDtMuonTime[i] = 0;
00311       mehDtMuonTimevLayer[i] = 0;
00312     }
00313     
00314     for(int j = 0; j < 4; ++j) {
00315       hcharname = "hDtMuonn_"+MuonString[j];
00316       hchartitle= MuonString[j]+"  digis";
00317       mehDtMuonn[j] = dbe->book1D(hcharname,hchartitle,250, 0., 500.);
00318       mehDtMuonn[j]->setAxisTitle("Number of Digis",1);
00319       mehDtMuonn[j]->setAxisTitle("Count",2);
00320 
00321       hcharname = "hDtLayer_"+MuonString[j];
00322       hchartitle= MuonString[j]+"  Layer";
00323       mehDtMuonLayer[j] = dbe->book1D(hcharname,hchartitle,12, 1., 13.);
00324       mehDtMuonLayer[j]->setAxisTitle("4 * (SuperLayer - 1) + Layer",1);
00325       mehDtMuonLayer[j]->setAxisTitle("Count",2);
00326 
00327       hcharname = "hDtMuonTime_"+MuonString[j];
00328       hchartitle= MuonString[j]+"  Time";
00329       mehDtMuonTime[j] = dbe->book1D(hcharname,hchartitle,300, 400., 1000.);
00330       mehDtMuonTime[j]->setAxisTitle("Time",1);
00331       mehDtMuonTime[j]->setAxisTitle("Count",2);
00332 
00333       hcharname = "hDtMuonTimevLayer_"+MuonString[j];
00334       hchartitle= MuonString[j]+"  Time vs. Layer";
00335       mehDtMuonTimevLayer[j] = dbe->bookProfile(hcharname,hchartitle,12, 1., 13., 300, 
00336                                                 400., 1000.,"");
00337       mehDtMuonTimevLayer[j]->setAxisTitle("4 * (SuperLayer - 1) + Layer",1);
00338       mehDtMuonTimevLayer[j]->setAxisTitle("Time",2);
00339     }
00340 
00341     //CSC 
00342     mehCSCStripn = 0;
00343     hcharname = "hCSCStripn";
00344     hchartitle = "CSC Strip digis";
00345     mehCSCStripn = dbe->book1D(hcharname,hchartitle,250, 0., 500.);
00346     mehCSCStripn->setAxisTitle("Number of Digis",1);
00347     mehCSCStripn->setAxisTitle("Count",2);
00348     
00349     mehCSCStripADC = 0;
00350     hcharname = "hCSCStripADC";
00351     hchartitle = "CSC Strip ADC";
00352     mehCSCStripADC = dbe->book1D(hcharname,hchartitle, 110, 0., 1100.);
00353     mehCSCStripADC->setAxisTitle("ADC",1);
00354     mehCSCStripADC->setAxisTitle("Count",2);
00355     
00356     mehCSCWiren = 0;
00357     hcharname = "hCSCWiren";
00358     hchartitle = "CSC Wire digis";
00359     mehCSCWiren = dbe->book1D(hcharname,hchartitle,250, 0., 500.);
00360     mehCSCWiren->setAxisTitle("Number of Digis",1);
00361     mehCSCWiren->setAxisTitle("Count",2);
00362     
00363     mehCSCWireTime = 0;
00364     hcharname = "hCSCWireTime";
00365     hchartitle = "CSC Wire Time";
00366     mehCSCWireTime = dbe->book1D(hcharname,hchartitle,10, 0., 10.);
00367     mehCSCWireTime->setAxisTitle("Time",1);
00368     mehCSCWireTime->setAxisTitle("Count",2);
00369     
00370     // RPC 
00371     mehRPCMuonn = 0;
00372     hcharname = "hRPCMuonn";
00373     hchartitle = "RPC digis";
00374     mehCSCStripn = dbe->book1D(hcharname,hchartitle,250, 0., 500.);
00375     mehCSCStripn->setAxisTitle("Number of Digis",1);
00376     mehCSCStripn->setAxisTitle("Count",2);
00377 
00378     std::string MuonRPCString[5] = {"Wmin2", "Wmin1", "W0", "Wpu1", "Wpu2"};
00379     for(int i =0; i < 5; ++i) {
00380       mehRPCRes[i] = 0;
00381     }
00382 
00383     for(int j = 0; j < 5; ++j) {    
00384       hcharname = "hRPCRes_"+MuonRPCString[j];
00385       hchartitle= MuonRPCString[j]+"  Digi - Sim";   
00386       mehRPCRes[j] = dbe->book1D(hcharname,hchartitle,200, -8., 8.);
00387       mehRPCRes[j]->setAxisTitle("Digi - Sim center of strip x",1);
00388       mehRPCRes[j]->setAxisTitle("Count",2);
00389     }
00390   }
00391 
00392   // set default constants
00393   // ECal
00394   
00395   ECalgainConv_[0] = 0.;
00396   ECalgainConv_[1] = 1.;
00397   ECalgainConv_[2] = 2.;
00398   ECalgainConv_[3] = 12.;  
00399   ECalbarrelADCtoGeV_ = 0.035;
00400   ECalendcapADCtoGeV_ = 0.06;
00401 }
00402  
00403 GlobalDigisAnalyzer::~GlobalDigisAnalyzer() {}
00404 
00405 void GlobalDigisAnalyzer::beginJob( void )
00406 {
00407   std::string MsgLoggerCat = "GlobalDigisAnalyzer_beginJob";
00408   
00409   EcalMGPAGainRatio * defaultRatios = new EcalMGPAGainRatio();
00410   
00411   ECalgainConv_[0] = 0.;
00412   ECalgainConv_[1] = 1.;
00413   ECalgainConv_[2] = defaultRatios->gain12Over6() ;
00414   ECalgainConv_[3] = ECalgainConv_[2]*(defaultRatios->gain6Over1()) ;
00415   
00416   delete defaultRatios;
00417   
00418   if (verbosity >= 0) {
00419     edm::LogInfo(MsgLoggerCat) 
00420       << "Modified Calorimeter gain constants: g0 = " << ECalgainConv_[0]
00421       << ", g1 = " << ECalgainConv_[1] << ", g2 = " << ECalgainConv_[2]
00422       << ", g3 = " << ECalgainConv_[3];
00423   }
00424   
00425   return;
00426 }
00427 
00428 
00429 void GlobalDigisAnalyzer::endJob()
00430 {
00431   std::string MsgLoggerCat = "GlobalDigisAnalyzer_endJob";
00432   if (verbosity >= 0)
00433     edm::LogInfo(MsgLoggerCat) 
00434       << "Terminating having processed " << count << " events.";
00435   return;
00436 }
00437 
00438 void GlobalDigisAnalyzer::analyze(const edm::Event& iEvent, 
00439                                   const edm::EventSetup& iSetup)
00440 {
00441   std::string MsgLoggerCat = "GlobalDigisAnalyzer_analyze";
00442   
00443   // keep track of number of events processed
00444   ++count;
00445 
00446 
00447   
00448   // THIS BLOCK MIGRATED HERE FROM beginJob:
00449   // setup calorimeter constants from service
00450   edm::ESHandle<EcalADCToGeVConstant> pAgc;
00451   iSetup.get<EcalADCToGeVConstantRcd>().get(pAgc);
00452   const EcalADCToGeVConstant* agc = pAgc.product();
00453   ECalbarrelADCtoGeV_ = agc->getEBValue();
00454   ECalendcapADCtoGeV_ = agc->getEEValue();
00455   if (verbosity >= 0) {
00456     edm::LogInfo(MsgLoggerCat)
00457       << "Modified Calorimeter ADCtoGeV constants: barrel = " 
00458       << ECalbarrelADCtoGeV_ << ", endcap = " << ECalendcapADCtoGeV_;
00459   }
00460   
00461 
00462 
00463   // get event id information
00464   int nrun = iEvent.id().run();
00465   int nevt = iEvent.id().event();
00466   
00467   if (verbosity > 0) {
00468     edm::LogInfo(MsgLoggerCat)
00469       << "Processing run " << nrun << ", event " << nevt
00470       << " (" << count << " events total)";
00471   } else if (verbosity == 0) {
00472     if (nevt%frequency == 0 || nevt == 1) {
00473       edm::LogInfo(MsgLoggerCat)
00474         << "Processing run " << nrun << ", event " << nevt
00475         << " (" << count << " events total)";
00476     }
00477   }
00478     
00479   // look at information available in the event
00480   if (getAllProvenances) {
00481     
00482     std::vector<const edm::Provenance*> AllProv;
00483     iEvent.getAllProvenance(AllProv);
00484     
00485     if (verbosity >= 0)
00486       edm::LogInfo(MsgLoggerCat)
00487         << "Number of Provenances = " << AllProv.size();
00488     
00489     if (printProvenanceInfo && (verbosity >= 0)) {
00490       TString eventout("\nProvenance info:\n");      
00491       
00492       for (unsigned int i = 0; i < AllProv.size(); ++i) {
00493         eventout += "\n       ******************************";
00494         eventout += "\n       Module       : ";
00495         eventout += AllProv[i]->moduleLabel();
00496         eventout += "\n       ProductID    : ";
00497         eventout += AllProv[i]->productID().id();
00498         eventout += "\n       ClassName    : ";
00499         eventout += AllProv[i]->className();
00500         eventout += "\n       InstanceName : ";
00501         eventout += AllProv[i]->productInstanceName();
00502         eventout += "\n       BranchName   : ";
00503         eventout += AllProv[i]->branchName();
00504       }
00505       eventout += "\n       ******************************\n";
00506       edm::LogInfo(MsgLoggerCat) << eventout << "\n";
00507       printProvenanceInfo = false;
00508     }
00509     getAllProvenances = false;
00510   }
00511   
00512   // call fill functions
00513   // gather Ecal information from event
00514   fillECal(iEvent,  iSetup);
00515   // gather Hcal information from event
00516   fillHCal(iEvent, iSetup);
00517   // gather Track information from event
00518   fillTrk(iEvent,  iSetup);
00519   // gather Muon information from event
00520   fillMuon(iEvent,  iSetup);
00521   
00522   if (verbosity > 0)
00523     edm::LogInfo (MsgLoggerCat)
00524       << "Done gathering data from event.";
00525   
00526   if (verbosity > 2)
00527     edm::LogInfo (MsgLoggerCat)
00528       << "Saving event contents:";
00529     
00530   return;
00531 }
00532 
00533 void GlobalDigisAnalyzer::fillECal(const edm::Event& iEvent, 
00534                                    const edm::EventSetup& iSetup)
00535 {
00536   std::string MsgLoggerCat = "GlobalDigisAnalyzer_fillECal";
00537   
00538   TString eventout;
00539   if (verbosity > 0)
00540     eventout = "\nGathering info:";  
00541   
00542   // extract crossing frame from event
00543   edm::Handle<CrossingFrame<PCaloHit> > crossingFrame;
00544   
00546   //extract EB information
00548   bool isBarrel = true;
00549   edm::Handle<EBDigiCollection> EcalDigiEB;  
00550   iEvent.getByLabel(ECalEBSrc_, EcalDigiEB);
00551   bool validDigiEB = true;
00552   if (!EcalDigiEB.isValid()) {
00553     LogDebug(MsgLoggerCat)
00554       << "Unable to find EcalDigiEB in event!";
00555     validDigiEB = false;
00556   }  
00557   if (validDigiEB) {
00558     if ( EcalDigiEB->size() == 0) isBarrel = false;
00559     
00560     if (isBarrel) {
00561       
00562       // loop over simhits
00563       MapType ebSimMap;
00564       const std::string barrelHitsName(hitsProducer+"EcalHitsEB");
00565       iEvent.getByLabel("mix",barrelHitsName,crossingFrame);
00566       bool validXFrame = true;
00567       if (!crossingFrame.isValid()) {
00568         LogDebug(MsgLoggerCat)
00569           << "Unable to find cal barrel crossingFrame in event!";
00570         validXFrame = false;
00571       }
00572       if (validXFrame) {
00573         std::auto_ptr<MixCollection<PCaloHit> >
00574           barrelHits(new MixCollection<PCaloHit>(crossingFrame.product()));
00575         
00576         // keep track of sum of simhit energy in each crystal
00577         for (MixCollection<PCaloHit>::MixItr hitItr 
00578                = barrelHits->begin();
00579              hitItr != barrelHits->end();
00580              ++hitItr) {
00581           
00582           EBDetId ebid = EBDetId(hitItr->id());
00583           
00584           uint32_t crystid = ebid.rawId();
00585           ebSimMap[crystid] += hitItr->energy();
00586         }
00587       }
00588 
00589       // loop over digis
00590       const EBDigiCollection *barrelDigi = EcalDigiEB.product();
00591       
00592       std::vector<double> ebAnalogSignal;
00593       std::vector<double> ebADCCounts;
00594       std::vector<double> ebADCGains;
00595       ebAnalogSignal.reserve(EBDataFrame::MAXSAMPLES);
00596       ebADCCounts.reserve(EBDataFrame::MAXSAMPLES);
00597       ebADCGains.reserve(EBDataFrame::MAXSAMPLES);
00598       
00599       int i = 0;
00600       for (unsigned int digis=0; digis<EcalDigiEB->size(); ++digis) {
00601         
00602         ++i;
00603         
00604         EBDataFrame ebdf = (*barrelDigi)[digis];
00605         int nrSamples = ebdf.size();
00606         
00607         EBDetId ebid = ebdf.id () ;
00608         
00609         double Emax = 0;
00610         int Pmax = 0;
00611         double pedestalPreSample = 0.;
00612         double pedestalPreSampleAnalog = 0.;
00613         
00614         for (int sample = 0 ; sample < nrSamples; ++sample) {
00615           ebAnalogSignal[sample] = 0.;
00616           ebADCCounts[sample] = 0.;
00617           ebADCGains[sample] = -1.;
00618         }
00619         
00620         // calculate maximum energy and pedestal
00621         for (int sample = 0 ; sample < nrSamples; ++sample) {
00622           
00623           EcalMGPASample thisSample = ebdf[sample];
00624           ebADCCounts[sample] = (thisSample.adc());
00625           ebADCGains[sample]  = (thisSample.gainId());
00626           ebAnalogSignal[sample] = 
00627             (ebADCCounts[sample] * ECalgainConv_[(int)ebADCGains[sample]]
00628              * ECalbarrelADCtoGeV_);
00629           if (Emax < ebAnalogSignal[sample]) {
00630             Emax = ebAnalogSignal[sample];
00631             Pmax = sample;
00632           }
00633           if ( sample < 3 ) {
00634             pedestalPreSample += ebADCCounts[sample] ;
00635             pedestalPreSampleAnalog += 
00636               ebADCCounts[sample] * ECalgainConv_[(int)ebADCGains[sample]]
00637               * ECalbarrelADCtoGeV_ ;
00638           }
00639           
00640         }
00641         pedestalPreSample /= 3. ; 
00642         pedestalPreSampleAnalog /= 3. ; 
00643         
00644         // calculate pedestal subtracted digi energy in the crystal
00645         double Erec = Emax - pedestalPreSampleAnalog
00646           * ECalgainConv_[(int)ebADCGains[Pmax]];
00647         
00648         // gather necessary information
00649         mehEcalMaxPos[0]->Fill(Pmax);
00650         mehEcalSHE[0]->Fill(ebSimMap[ebid.rawId()]);
00651         mehEcalAEE[0]->Fill(Erec);
00652         //Adding protection against FPE
00653         if (ebSimMap[ebid.rawId()]!=0) {
00654           mehEcalSHEvAEESHE[0]->Fill(Erec/ebSimMap[ebid.rawId()],
00655                                      ebSimMap[ebid.rawId()]);
00656         }
00657         //else {
00658         //  std::cout<<"Would have been an FPE! with ebSimMap[ebid.rawId()]==0\n";
00659         //}
00660 
00661         mehEcalMultvAEE[0]->Fill(Pmax,(float)i);
00662       }
00663       
00664       if (verbosity > 1) {
00665         eventout += "\n          Number of EBDigis collected:.............. ";
00666         eventout += i;
00667       }
00668       mehEcaln[0]->Fill((float)i);
00669     }
00670   }
00671   
00673   //extract EE information
00675   bool isEndCap = true;
00676   edm::Handle<EEDigiCollection> EcalDigiEE;  
00677   iEvent.getByLabel(ECalEESrc_, EcalDigiEE);
00678   bool validDigiEE = true;
00679   if (!EcalDigiEE.isValid()) {
00680     LogDebug(MsgLoggerCat)
00681       << "Unable to find EcalDigiEE in event!";
00682     validDigiEE = false;
00683   }  
00684   if (validDigiEE) {
00685     if (EcalDigiEE->size() == 0) isEndCap = false;
00686     
00687     if (isEndCap) {
00688       
00689       // loop over simhits
00690       MapType eeSimMap;
00691       const std::string endcapHitsName(hitsProducer+"EcalHitsEE");
00692       iEvent.getByLabel("mix",endcapHitsName,crossingFrame);
00693       bool validXFrame = true;
00694       if (!crossingFrame.isValid()) {
00695         LogDebug(MsgLoggerCat)
00696           << "Unable to find cal endcap crossingFrame in event!";
00697         validXFrame = false;
00698       }
00699       if (validXFrame) {
00700         std::auto_ptr<MixCollection<PCaloHit> >
00701           endcapHits(new MixCollection<PCaloHit>(crossingFrame.product()));
00702         
00703         // keep track of sum of simhit energy in each crystal
00704         for (MixCollection<PCaloHit>::MixItr hitItr 
00705                = endcapHits->begin();
00706              hitItr != endcapHits->end();
00707              ++hitItr) {
00708           
00709           EEDetId eeid = EEDetId(hitItr->id());
00710           
00711           uint32_t crystid = eeid.rawId();
00712           eeSimMap[crystid] += hitItr->energy();
00713         }
00714       }
00715 
00716       // loop over digis
00717       const EEDigiCollection *endcapDigi = EcalDigiEE.product();
00718       
00719       std::vector<double> eeAnalogSignal;
00720       std::vector<double> eeADCCounts;
00721       std::vector<double> eeADCGains;
00722       eeAnalogSignal.reserve(EEDataFrame::MAXSAMPLES);
00723       eeADCCounts.reserve(EEDataFrame::MAXSAMPLES);
00724       eeADCGains.reserve(EEDataFrame::MAXSAMPLES);
00725       
00726       int inc = 0;
00727       for (unsigned int digis=0; digis<EcalDigiEE->size(); ++digis){ 
00728         
00729         ++inc;
00730         
00731         EEDataFrame eedf = (*endcapDigi)[digis];
00732         int nrSamples = eedf.size();
00733         
00734         EEDetId eeid = eedf.id () ;
00735         
00736         double Emax = 0;
00737         int Pmax = 0;
00738         double pedestalPreSample = 0.;
00739         double pedestalPreSampleAnalog = 0.;
00740         
00741         for (int sample = 0 ; sample < nrSamples; ++sample) {
00742           eeAnalogSignal[sample] = 0.;
00743           eeADCCounts[sample] = 0.;
00744           eeADCGains[sample] = -1.;
00745         }
00746         
00747         // calculate maximum enery and pedestal
00748         for (int sample = 0 ; sample < nrSamples; ++sample) {
00749           
00750           EcalMGPASample thisSample = eedf[sample];
00751           
00752           eeADCCounts[sample] = (thisSample.adc());
00753           eeADCGains[sample]  = (thisSample.gainId());
00754           eeAnalogSignal[sample] = 
00755             (eeADCCounts[sample] * ECalgainConv_[(int)eeADCGains[sample]]
00756              * ECalbarrelADCtoGeV_);
00757           if (Emax < eeAnalogSignal[sample]) {
00758             Emax = eeAnalogSignal[sample];
00759             Pmax = sample;
00760           }
00761           if ( sample < 3 ) {
00762             pedestalPreSample += eeADCCounts[sample] ;
00763             pedestalPreSampleAnalog += 
00764               eeADCCounts[sample] * ECalgainConv_[(int)eeADCGains[sample]]
00765               * ECalbarrelADCtoGeV_ ;
00766           }
00767           
00768         }
00769         pedestalPreSample /= 3. ; 
00770         pedestalPreSampleAnalog /= 3. ; 
00771         
00772         // calculate pedestal subtracted digi energy in the crystal
00773         double Erec = Emax - pedestalPreSampleAnalog
00774           * ECalgainConv_[(int)eeADCGains[Pmax]];
00775         
00776         // gather necessary information
00777         mehEcalMaxPos[1]->Fill(Pmax);
00778         mehEcalSHE[1]->Fill(eeSimMap[eeid.rawId()]);
00779         mehEcalAEE[1]->Fill(Erec);
00780         //Adding protection against FPE
00781         if (eeSimMap[eeid.rawId()]!=0){
00782           mehEcalSHEvAEESHE[1]->Fill(Erec/eeSimMap[eeid.rawId()],
00783                                      eeSimMap[eeid.rawId()]);
00784         }
00785         //else{
00786         //  std::cout<<"Would have been an FPE! with eeSimMap[eeid.rawId()]==0\n"; 
00787         //}
00788         mehEcalMultvAEE[1]->Fill(Pmax,(float)inc);
00789         
00790       }
00791       
00792       if (verbosity > 1) {
00793         eventout += "\n          Number of EEDigis collected:.............. ";
00794         eventout += inc;
00795       }
00796       
00797       mehEcaln[1]->Fill((float)inc);
00798     }
00799   }
00800 
00802   //extract ES information
00804   bool isPreshower = true;
00805   edm::Handle<ESDigiCollection> EcalDigiES;  
00806   iEvent.getByLabel(ECalESSrc_, EcalDigiES);
00807   bool validDigiES = true;
00808   if (!EcalDigiES.isValid()) {
00809     LogDebug(MsgLoggerCat)
00810       << "Unable to find EcalDigiES in event!";
00811     validDigiES = false;
00812   } 
00813   
00814   // ONLY WHILE GEOMETRY IS REMOVED
00815   validDigiES = false;
00816  
00817   if (validDigiES) {
00818     if (EcalDigiES->size() == 0) isPreshower = false;
00819     
00820     if (isPreshower) {
00821       
00822       // loop over simhits
00823       const std::string preshowerHitsName(hitsProducer+"EcalHitsES");
00824       iEvent.getByLabel("mix",preshowerHitsName,crossingFrame);
00825       bool validXFrame = true;
00826       if (!crossingFrame.isValid()) {
00827         LogDebug(MsgLoggerCat)
00828           << "Unable to find cal preshower crossingFrame in event!";
00829         validXFrame = false;
00830       }
00831       if (validXFrame) {
00832         std::auto_ptr<MixCollection<PCaloHit> >
00833           preshowerHits(new MixCollection<PCaloHit>(crossingFrame.product()));
00834         
00835         // keep track of sum of simhit energy in each crystal
00836         MapType esSimMap;
00837         for (MixCollection<PCaloHit>::MixItr hitItr 
00838                = preshowerHits->begin();
00839              hitItr != preshowerHits->end();
00840              ++hitItr) {
00841           
00842           ESDetId esid = ESDetId(hitItr->id());
00843           
00844           uint32_t crystid = esid.rawId();
00845           esSimMap[crystid] += hitItr->energy();
00846         }
00847       }
00848 
00849       // loop over digis
00850       const ESDigiCollection *preshowerDigi = EcalDigiES.product();
00851       
00852       std::vector<double> esADCCounts;
00853       esADCCounts.reserve(ESDataFrame::MAXSAMPLES);
00854       
00855       int i = 0;
00856       for (unsigned int digis=0; digis<EcalDigiES->size(); ++digis) {
00857         
00858         ++i;
00859         
00860         
00861         ESDataFrame esdf = (*preshowerDigi)[digis];
00862         int nrSamples = esdf.size();
00863         
00864         for (int sample = 0 ; sample < nrSamples; ++sample) {
00865           esADCCounts[sample] = 0.;
00866         }
00867         
00868         // gether ADC counts
00869         for (int sample = 0 ; sample < nrSamples; ++sample) {
00870           
00871           ESSample thisSample = esdf[sample];
00872           esADCCounts[sample] = (thisSample.adc());
00873         }
00874         
00875         mehEScalADC[0]->Fill(esADCCounts[0]);
00876         mehEScalADC[1]->Fill(esADCCounts[1]);
00877         mehEScalADC[2]->Fill(esADCCounts[2]);
00878         
00879       }
00880       
00881       if (verbosity > 1) {
00882         eventout += "\n          Number of ESDigis collected:.............. ";
00883         eventout += i;
00884       }
00885       
00886       mehEScaln->Fill((float)i);
00887     }
00888   }
00889   if (verbosity > 0)
00890     edm::LogInfo(MsgLoggerCat) << eventout << "\n";
00891   
00892   return;
00893 }
00894 
00895 
00896 void GlobalDigisAnalyzer::fillHCal(const edm::Event& iEvent, 
00897                                    const edm::EventSetup& iSetup)
00898 {
00899   std::string MsgLoggerCat = "GlobalDigisAnalyzer_fillHCal";
00900   
00901   TString eventout;
00902   if (verbosity > 0)
00903     eventout = "\nGathering info:";  
00904   
00905   // get calibration info
00906   edm::ESHandle<HcalDbService> HCalconditions;
00907   iSetup.get<HcalDbRecord>().get(HCalconditions);
00908   if (!HCalconditions.isValid()) {
00909     edm::LogWarning(MsgLoggerCat)
00910       << "Unable to find HCalconditions in event!";
00911     return;
00912   } 
00913   const HcalQIEShape *shape = HCalconditions->getHcalShape();
00914   //HcalCalibrations calibrations;
00915   CaloSamples tool;
00916   
00918   // extract simhit info
00920   edm::Handle<edm::PCaloHitContainer> hcalHits;
00921   iEvent.getByLabel(HCalSrc_,hcalHits);
00922   bool validhcalHits = true;
00923   if (!hcalHits.isValid()) {
00924     LogDebug(MsgLoggerCat)
00925       << "Unable to find hcalHits in event!";
00926     validhcalHits = false;
00927   }  
00928   MapType fHBEnergySimHits;
00929   MapType fHEEnergySimHits;
00930   MapType fHOEnergySimHits;
00931   MapType fHFEnergySimHits;
00932   if (validhcalHits) {
00933     const edm::PCaloHitContainer *simhitResult = hcalHits.product();
00934     
00935     for (std::vector<PCaloHit>::const_iterator simhits = simhitResult->begin();
00936          simhits != simhitResult->end();
00937          ++simhits) {
00938       
00939       HcalDetId detId(simhits->id());
00940       uint32_t cellid = detId.rawId();
00941       
00942       if (detId.subdet() == sdHcalBrl){  
00943         fHBEnergySimHits[cellid] += simhits->energy(); 
00944       }
00945       if (detId.subdet() == sdHcalEC){  
00946         fHEEnergySimHits[cellid] += simhits->energy(); 
00947       }    
00948       if (detId.subdet() == sdHcalOut){  
00949         fHOEnergySimHits[cellid] += simhits->energy(); 
00950       }    
00951       if (detId.subdet() == sdHcalFwd){  
00952         fHFEnergySimHits[cellid] += simhits->energy(); 
00953       }    
00954     } 
00955   }
00956 
00958   // get HBHE information
00960   edm::Handle<edm::SortedCollection<HBHEDataFrame> > hbhe;
00961   iEvent.getByLabel(HCalDigi_,hbhe);
00962   bool validHBHE = true;
00963   if (!hbhe.isValid()) {
00964     LogDebug(MsgLoggerCat)
00965       << "Unable to find HBHEDataFrame in event!";
00966     validHBHE = false;
00967   }    
00968 
00969   if (validHBHE) {
00970     edm::SortedCollection<HBHEDataFrame>::const_iterator ihbhe;
00971     
00972     int iHB = 0;
00973     int iHE = 0; 
00974     for (ihbhe = hbhe->begin(); ihbhe != hbhe->end(); ++ihbhe) {
00975       HcalDetId cell(ihbhe->id()); 
00976       
00977       if ((cell.subdet() == sdHcalBrl) || (cell.subdet() == sdHcalEC)) {
00978         
00979         //HCalconditions->makeHcalCalibration(cell, &calibrations);
00980         const HcalCalibrations& calibrations = 
00981           HCalconditions->getHcalCalibrations(cell);
00982         const HcalQIECoder *channelCoder = HCalconditions->getHcalCoder(cell);
00983         HcalCoderDb coder(*channelCoder, *shape);
00984         coder.adc2fC(*ihbhe, tool);
00985         
00986         // get HB info
00987         if (cell.subdet() == sdHcalBrl) {
00988           
00989           ++iHB;
00990           float fDigiSum = 0.0;
00991           for  (int ii = 0; ii < tool.size(); ++ii) {
00992             // default ped is 4.5
00993             int capid = (*ihbhe)[ii].capid();
00994             fDigiSum += (tool[ii] - calibrations.pedestal(capid));
00995           }
00996           
00997           mehHcalSHE[0]->Fill(fHFEnergySimHits[cell.rawId()]);
00998           mehHcalAEE[0]->Fill(fDigiSum);
00999           //Adding protection against FPE
01000           if (fHFEnergySimHits[cell.rawId()]!=0){
01001             mehHcalAEESHE[0]->Fill(fDigiSum/fHFEnergySimHits[cell.rawId()]);
01002           }
01003           //else {
01004           //  std::cout<<"It would have been an FPE! with fHFEnergySimHits[cell.rawId()]==0!\n";
01005           //}
01006           mehHcalSHEvAEE[0]->Fill(fDigiSum, fHFEnergySimHits[cell.rawId()]);
01007         }
01008         
01009         // get HE info
01010         if (cell.subdet() == sdHcalEC) {
01011           
01012           ++iHE;
01013           float fDigiSum = 0.0;
01014           for  (int ii = 0; ii < tool.size(); ++ii) {
01015             int capid = (*ihbhe)[ii].capid();
01016             fDigiSum += (tool[ii]-calibrations.pedestal(capid));
01017           }
01018           
01019           mehHcalSHE[1]->Fill(fHFEnergySimHits[cell.rawId()]);
01020           mehHcalAEE[1]->Fill(fDigiSum);
01021           //Adding protection against FPE
01022           if (fHFEnergySimHits[cell.rawId()]!=0){
01023             mehHcalAEESHE[1]->Fill(fDigiSum/fHFEnergySimHits[cell.rawId()]);
01024           }
01025           //else{
01026           //  std::cout<<"It would have been an FPE! with fHFEnergySimHits[cell.rawId()]==0!\n";
01027           //}
01028           mehHcalSHEvAEE[1]->Fill(fDigiSum, fHFEnergySimHits[cell.rawId()]);
01029         }
01030       }
01031     }
01032   
01033     if (verbosity > 1) {
01034       eventout += "\n          Number of HBDigis collected:.............. ";
01035       eventout += iHB;
01036     }
01037     mehHcaln[0]->Fill((float)iHB);
01038     
01039     if (verbosity > 1) {
01040       eventout += "\n          Number of HEDigis collected:.............. ";
01041       eventout += iHE;
01042     }
01043     mehHcaln[1]->Fill((float)iHE);
01044   }
01045 
01047   // get HO information
01049   edm::Handle<edm::SortedCollection<HODataFrame> > ho;
01050   iEvent.getByLabel(HCalDigi_,ho);
01051   bool validHO = true;
01052   if (!ho.isValid()) {
01053     LogDebug(MsgLoggerCat)
01054       << "Unable to find HODataFrame in event!";
01055     validHO = false;
01056   }    
01057   if (validHO) {
01058     edm::SortedCollection<HODataFrame>::const_iterator iho;
01059     
01060     int iHO = 0; 
01061     for (iho = ho->begin(); iho != ho->end(); ++iho) {
01062       HcalDetId cell(iho->id()); 
01063       
01064       if (cell.subdet() == sdHcalOut) {
01065         
01066         //HCalconditions->makeHcalCalibration(cell, &calibrations);
01067         const HcalCalibrations& calibrations = 
01068           HCalconditions->getHcalCalibrations(cell);
01069         const HcalQIECoder *channelCoder = HCalconditions->getHcalCoder(cell);
01070         HcalCoderDb coder (*channelCoder, *shape);
01071         coder.adc2fC(*iho, tool);
01072         
01073         ++iHO;
01074         float fDigiSum = 0.0;
01075         for  (int ii = 0; ii < tool.size(); ++ii) {
01076           // default ped is 4.5
01077           int capid = (*iho)[ii].capid();
01078           fDigiSum += (tool[ii] - calibrations.pedestal(capid));
01079         }
01080         
01081         mehHcalSHE[2]->Fill(fHFEnergySimHits[cell.rawId()]);
01082         mehHcalAEE[2]->Fill(fDigiSum);
01083         //Adding protection against FPE
01084         if (fHFEnergySimHits[cell.rawId()]!=0){
01085           mehHcalAEESHE[2]->Fill(fDigiSum/fHFEnergySimHits[cell.rawId()]);
01086         }
01087         //else{
01088         //  std::cout<<"It would have been an FPE! with fHFEnergySimHits[cell.rawId()]==0!\n";
01089         //}
01090         mehHcalSHEvAEE[2]->Fill(fDigiSum, fHFEnergySimHits[cell.rawId()]);
01091       }
01092     }
01093     
01094     if (verbosity > 1) {
01095       eventout += "\n          Number of HODigis collected:.............. ";
01096       eventout += iHO;
01097     }
01098     mehHcaln[2]->Fill((float)iHO);
01099   }  
01100 
01102   // get HF information
01104   edm::Handle<edm::SortedCollection<HFDataFrame> > hf;
01105   iEvent.getByLabel(HCalDigi_,hf);
01106   bool validHF = true;
01107   if (!hf.isValid()) {
01108     LogDebug(MsgLoggerCat)
01109       << "Unable to find HFDataFrame in event!";
01110     validHF = false;
01111   }    
01112   if (validHF) {
01113     edm::SortedCollection<HFDataFrame>::const_iterator ihf;
01114     
01115     int iHF = 0; 
01116     for (ihf = hf->begin(); ihf != hf->end(); ++ihf) {
01117       HcalDetId cell(ihf->id()); 
01118       
01119       if (cell.subdet() == sdHcalFwd) {
01120         
01121         //HCalconditions->makeHcalCalibration(cell, &calibrations);
01122         const HcalCalibrations& calibrations = 
01123           HCalconditions->getHcalCalibrations(cell);
01124         const HcalQIECoder *channelCoder = HCalconditions->getHcalCoder(cell);
01125         HcalCoderDb coder (*channelCoder, *shape);
01126         coder.adc2fC(*ihf, tool);
01127         
01128         ++iHF;
01129         float fDigiSum = 0.0;
01130         for  (int ii = 0; ii < tool.size(); ++ii) {
01131           // default ped is 1.73077
01132           int capid = (*ihf)[ii].capid();
01133           fDigiSum += (tool[ii] - calibrations.pedestal(capid));
01134         }
01135         
01136         mehHcalSHE[3]->Fill(fHFEnergySimHits[cell.rawId()]);
01137         mehHcalAEE[3]->Fill(fDigiSum);
01138         //Adding protection against FPE
01139         if (fHFEnergySimHits[cell.rawId()]!=0){
01140           mehHcalAEESHE[3]->Fill(fDigiSum/fHFEnergySimHits[cell.rawId()]);
01141         }
01142         //else{
01143         //  std::cout<<"It would have been an FPE! with fHFEnergySimHits[cell.rawId()]==0!\n";
01144         //}
01145         mehHcalSHEvAEE[3]->Fill(fDigiSum, fHFEnergySimHits[cell.rawId()]);
01146       }
01147     }
01148   
01149     if (verbosity > 1) {
01150       eventout += "\n          Number of HFDigis collected:.............. ";
01151       eventout += iHF;
01152     }
01153     mehHcaln[3]->Fill((float)iHF);
01154   }
01155 
01156   if (verbosity > 0)
01157     edm::LogInfo(MsgLoggerCat) << eventout << "\n";
01158   
01159   return;
01160 }
01161 
01162 void GlobalDigisAnalyzer::fillTrk(const edm::Event& iEvent, 
01163                                   const edm::EventSetup& iSetup)
01164 {
01165   std::string MsgLoggerCat = "GlobalDigisAnalyzer_fillTrk";
01166   
01167   TString eventout;
01168   if (verbosity > 0)
01169     eventout = "\nGathering info:";  
01170   
01171   // get strip information
01172   edm::Handle<edm::DetSetVector<SiStripDigi> > stripDigis;  
01173   iEvent.getByLabel(SiStripSrc_, stripDigis);
01174   bool validstripDigis = true;
01175   if (!stripDigis.isValid()) {
01176     LogDebug(MsgLoggerCat)
01177       << "Unable to find stripDigis in event!";
01178     validstripDigis = false;
01179   }  
01180   
01181   if (validstripDigis) {
01182     int nStripBrl = 0, nStripFwd = 0;
01183     edm::DetSetVector<SiStripDigi>::const_iterator DSViter;
01184     for (DSViter = stripDigis->begin(); DSViter != stripDigis->end(); 
01185          ++DSViter) {
01186       unsigned int id = DSViter->id;
01187       DetId detId(id);
01188       edm::DetSet<SiStripDigi>::const_iterator begin = DSViter->data.begin();
01189       edm::DetSet<SiStripDigi>::const_iterator end = DSViter->data.end();
01190       edm::DetSet<SiStripDigi>::const_iterator iter;
01191       
01192       // get TIB
01193       if (detId.subdetId() == sdSiTIB) {
01194         TIBDetId tibid(id);
01195         for (iter = begin; iter != end; ++iter) {
01196           ++nStripBrl;
01197           if (tibid.layer() == 1) {
01198             mehSiStripADC[0]->Fill((*iter).adc());
01199             mehSiStripStrip[0]->Fill((*iter).strip());
01200           }
01201           if (tibid.layer() == 2) {
01202             mehSiStripADC[1]->Fill((*iter).adc());
01203             mehSiStripStrip[1]->Fill((*iter).strip());
01204           }     
01205           if (tibid.layer() == 3) {
01206             mehSiStripADC[2]->Fill((*iter).adc());
01207             mehSiStripStrip[2]->Fill((*iter).strip());
01208           }
01209           if (tibid.layer() == 4) {
01210             mehSiStripADC[3]->Fill((*iter).adc());
01211             mehSiStripStrip[3]->Fill((*iter).strip());
01212           }
01213         }
01214       }
01215       
01216       // get TOB
01217       if (detId.subdetId() == sdSiTOB) {
01218         TOBDetId tobid(id);
01219         for (iter = begin; iter != end; ++iter) {
01220           ++nStripBrl;
01221           if (tobid.layer() == 1) {
01222             mehSiStripADC[4]->Fill((*iter).adc());
01223             mehSiStripStrip[4]->Fill((*iter).strip());
01224           }
01225           if (tobid.layer() == 2) {
01226             mehSiStripADC[5]->Fill((*iter).adc());
01227             mehSiStripStrip[5]->Fill((*iter).strip());
01228           }     
01229           if (tobid.layer() == 3) {
01230             mehSiStripADC[6]->Fill((*iter).adc());
01231             mehSiStripStrip[6]->Fill((*iter).strip());
01232           }
01233           if (tobid.layer() == 4) {
01234             mehSiStripADC[7]->Fill((*iter).adc());
01235             mehSiStripStrip[7]->Fill((*iter).strip());
01236           }
01237         }
01238       }    
01239       
01240       // get TID
01241       if (detId.subdetId() == sdSiTID) {
01242         TIDDetId tidid(id);
01243         for (iter = begin; iter != end; ++iter) {
01244           ++nStripFwd;
01245           if (tidid.wheel() == 1) {
01246             mehSiStripADC[8]->Fill((*iter).adc());
01247             mehSiStripStrip[8]->Fill((*iter).strip());
01248           }
01249           if (tidid.wheel() == 2) {
01250             mehSiStripADC[9]->Fill((*iter).adc());
01251             mehSiStripStrip[9]->Fill((*iter).strip());
01252           }
01253           if (tidid.wheel() == 3) {
01254             mehSiStripADC[10]->Fill((*iter).adc());
01255             mehSiStripStrip[10]->Fill((*iter).strip());
01256           }
01257         }
01258       }   
01259       
01260       // get TEC
01261       if (detId.subdetId() == sdSiTEC) {
01262         TECDetId tecid(id);
01263         for (iter = begin; iter != end; ++iter) {
01264           ++nStripFwd;
01265           if (tecid.wheel() == 1) {
01266             mehSiStripADC[11]->Fill((*iter).adc());
01267             mehSiStripStrip[11]->Fill((*iter).strip());
01268           }
01269           if (tecid.wheel() == 2) {
01270             mehSiStripADC[12]->Fill((*iter).adc());
01271             mehSiStripStrip[12]->Fill((*iter).strip());
01272           }
01273           if (tecid.wheel() == 3) {
01274             mehSiStripADC[13]->Fill((*iter).adc());
01275             mehSiStripStrip[13]->Fill((*iter).strip());
01276           }
01277           if (tecid.wheel() == 4) {
01278             mehSiStripADC[14]->Fill((*iter).adc());
01279             mehSiStripStrip[14]->Fill((*iter).strip());
01280           }
01281           if (tecid.wheel() == 5) {
01282             mehSiStripADC[15]->Fill((*iter).adc());
01283             mehSiStripStrip[15]->Fill((*iter).strip());
01284           }
01285           if (tecid.wheel() == 6) {
01286             mehSiStripADC[16]->Fill((*iter).adc());
01287             mehSiStripStrip[16]->Fill((*iter).strip());
01288           }
01289           if (tecid.wheel() == 7) {
01290             mehSiStripADC[17]->Fill((*iter).adc());
01291             mehSiStripStrip[17]->Fill((*iter).strip());
01292           }
01293           if (tecid.wheel() == 8) {
01294             mehSiStripADC[18]->Fill((*iter).adc());
01295             mehSiStripStrip[18]->Fill((*iter).strip());
01296           }
01297         }
01298       }     
01299     } // end loop over DataSetVector
01300     
01301     if (verbosity > 1) {
01302       eventout += "\n          Number of BrlStripDigis collected:........ ";
01303       eventout += nStripBrl;
01304     }
01305     for(int i = 0; i < 8; ++i) {
01306       mehSiStripn[i]->Fill((float)nStripBrl);
01307     }
01308     
01309     if (verbosity > 1) {
01310       eventout += "\n          Number of FrwdStripDigis collected:....... ";
01311       eventout += nStripFwd;
01312     }
01313     for(int i = 8; i < 19; ++i) {
01314       mehSiStripn[i]->Fill((float)nStripFwd);
01315     }
01316   }
01317 
01318   // get pixel information
01319   edm::Handle<edm::DetSetVector<PixelDigi> > pixelDigis;  
01320   iEvent.getByLabel(SiPxlSrc_, pixelDigis);
01321   bool validpixelDigis = true;
01322   if (!pixelDigis.isValid()) {
01323     LogDebug(MsgLoggerCat)
01324       << "Unable to find pixelDigis in event!";
01325     validpixelDigis = false;
01326   }  
01327   if (validpixelDigis) {
01328     int nPxlBrl = 0, nPxlFwd = 0;
01329     edm::DetSetVector<PixelDigi>::const_iterator DPViter;
01330     for (DPViter = pixelDigis->begin(); DPViter != pixelDigis->end(); 
01331          ++DPViter) {
01332       unsigned int id = DPViter->id;
01333       DetId detId(id);
01334       edm::DetSet<PixelDigi>::const_iterator begin = DPViter->data.begin();
01335       edm::DetSet<PixelDigi>::const_iterator end = DPViter->data.end();
01336       edm::DetSet<PixelDigi>::const_iterator iter;
01337       
01338       // get Barrel pixels
01339       if (detId.subdetId() == sdPxlBrl) {
01340         PXBDetId bdetid(id);
01341         for (iter = begin; iter != end; ++iter) {
01342           ++nPxlBrl;
01343           if (bdetid.layer() == 1) {
01344             mehSiPixelADC[0]->Fill((*iter).adc());
01345             mehSiPixelRow[0]->Fill((*iter).row());
01346             mehSiPixelCol[0]->Fill((*iter).column());
01347           }
01348           if (bdetid.layer() == 2) {
01349             mehSiPixelADC[1]->Fill((*iter).adc());
01350             mehSiPixelRow[1]->Fill((*iter).row());
01351             mehSiPixelCol[1]->Fill((*iter).column());
01352           }
01353           if (bdetid.layer() == 3) {
01354             mehSiPixelADC[2]->Fill((*iter).adc());
01355             mehSiPixelRow[2]->Fill((*iter).row());
01356             mehSiPixelCol[2]->Fill((*iter).column());
01357           }
01358         }
01359       }
01360       
01361       // get Forward pixels
01362       if (detId.subdetId() == sdPxlFwd) {
01363         PXFDetId fdetid(id);
01364         for (iter = begin; iter != end; ++iter) {
01365           ++nPxlFwd;
01366           if (fdetid.disk() == 1) {
01367             if (fdetid.side() == 1) {
01368               mehSiPixelADC[4]->Fill((*iter).adc());
01369               mehSiPixelRow[4]->Fill((*iter).row());
01370               mehSiPixelCol[4]->Fill((*iter).column());
01371             }
01372             if (fdetid.side() == 2) {
01373               mehSiPixelADC[3]->Fill((*iter).adc());
01374               mehSiPixelRow[3]->Fill((*iter).row());
01375               mehSiPixelCol[3]->Fill((*iter).column());
01376             }
01377           }
01378           if (fdetid.disk() == 2) {
01379             if (fdetid.side() == 1) {
01380               
01381               mehSiPixelADC[6]->Fill((*iter).adc());
01382               mehSiPixelRow[6]->Fill((*iter).row());
01383               mehSiPixelCol[6]->Fill((*iter).column());
01384             }
01385             if (fdetid.side() == 2) {
01386               mehSiPixelADC[5]->Fill((*iter).adc());
01387               mehSiPixelRow[5]->Fill((*iter).row());
01388               mehSiPixelCol[5]->Fill((*iter).column());
01389             }
01390           }
01391         }
01392       }
01393     }
01394     
01395     if (verbosity > 1) {
01396       eventout += "\n          Number of BrlPixelDigis collected:........ ";
01397       eventout += nPxlBrl;
01398     }
01399     for(int i = 0; i < 3; ++i) {
01400       mehSiPixeln[i]->Fill((float)nPxlBrl);
01401     }
01402     
01403     if (verbosity > 1) {
01404       eventout += "\n          Number of FrwdPixelDigis collected:....... ";
01405       eventout += nPxlFwd;
01406     }
01407     
01408     for(int i = 3; i < 7; ++i) {
01409       mehSiPixeln[i]->Fill((float)nPxlFwd);
01410     }
01411   }
01412 
01413   if (verbosity > 0)
01414     edm::LogInfo(MsgLoggerCat) << eventout << "\n";
01415   
01416   return;
01417 }
01418 
01419 void GlobalDigisAnalyzer::fillMuon(const edm::Event& iEvent, 
01420                                    const edm::EventSetup& iSetup)
01421 {
01422   std::string MsgLoggerCat = "GlobalDigisAnalyzer_fillMuon";
01423   
01424   TString eventout;
01425   if (verbosity > 0)
01426     eventout = "\nGathering info:";  
01427   
01428   // get DT information
01429   edm::Handle<DTDigiCollection> dtDigis;  
01430   iEvent.getByLabel(MuDTSrc_, dtDigis);
01431   bool validdtDigis = true;
01432   if (!dtDigis.isValid()) {
01433     LogDebug(MsgLoggerCat)
01434       << "Unable to find dtDigis in event!";
01435     validdtDigis = false;
01436   }  
01437   if (validdtDigis) {
01438     int nDt0 = 0; int nDt1 = 0; int nDt2 = 0; int nDt3 = 0;
01439     int nDt = 0;
01440     DTDigiCollection::DigiRangeIterator detUnitIt;
01441     for (detUnitIt = dtDigis->begin(); detUnitIt != dtDigis->end(); 
01442          ++detUnitIt) {
01443       
01444       const DTLayerId& id = (*detUnitIt).first;
01445       const DTDigiCollection::Range& range = (*detUnitIt).second;
01446       for (DTDigiCollection::const_iterator digiIt = range.first;
01447            digiIt != range.second;
01448            ++digiIt) {
01449         
01450         ++nDt;
01451         
01452         DTWireId wireId(id,(*digiIt).wire());
01453         if (wireId.station() == 1) {
01454           mehDtMuonLayer[0]->Fill(id.layer());
01455           mehDtMuonTime[0]->Fill((*digiIt).time());
01456           mehDtMuonTimevLayer[0]->Fill(id.layer(),(*digiIt).time());
01457           ++nDt0;
01458         }
01459         if (wireId.station() == 2) {
01460           mehDtMuonLayer[1]->Fill(id.layer());
01461           mehDtMuonTime[1]->Fill((*digiIt).time());
01462           mehDtMuonTimevLayer[1]->Fill(id.layer(),(*digiIt).time());
01463           ++nDt1;
01464         }
01465         if (wireId.station() == 3) {
01466           mehDtMuonLayer[2]->Fill(id.layer());
01467           mehDtMuonTime[2]->Fill((*digiIt).time());
01468           mehDtMuonTimevLayer[2]->Fill(id.layer(),(*digiIt).time());
01469           ++nDt2;
01470         }
01471         if (wireId.station() == 4) {
01472           mehDtMuonLayer[3]->Fill(id.layer());
01473           mehDtMuonTime[3]->Fill((*digiIt).time());
01474           mehDtMuonTimevLayer[3]->Fill(id.layer(),(*digiIt).time());
01475           ++nDt3;
01476         }
01477       }
01478     }
01479     mehDtMuonn[0]->Fill((float)nDt0);
01480     mehDtMuonn[1]->Fill((float)nDt1);
01481     mehDtMuonn[2]->Fill((float)nDt2);
01482     mehDtMuonn[3]->Fill((float)nDt3);
01483     
01484     
01485     if (verbosity > 1) {
01486       eventout += "\n          Number of DtMuonDigis collected:.......... ";
01487       eventout += nDt;
01488     }
01489   }
01490 
01491   // get CSC Strip information
01492   edm::Handle<CSCStripDigiCollection> strips;  
01493   iEvent.getByLabel(MuCSCStripSrc_, strips);
01494   bool validstrips = true;
01495   if (!strips.isValid()) {
01496     LogDebug(MsgLoggerCat)
01497       << "Unable to find muon strips in event!";
01498     validstrips = false;
01499   }
01500   
01501   if (validstrips) {
01502     int nStrips = 0;
01503     for (CSCStripDigiCollection::DigiRangeIterator j = strips->begin();
01504          j != strips->end();
01505          ++j) {
01506       
01507       std::vector<CSCStripDigi>::const_iterator digiItr = (*j).second.first;
01508       std::vector<CSCStripDigi>::const_iterator last = (*j).second.second;
01509       
01510       for ( ; digiItr != last; ++digiItr) {
01511         ++nStrips;
01512         
01513         // average pedestals
01514         std::vector<int> adcCounts = digiItr->getADCCounts();
01515         theCSCStripPedestalSum += adcCounts[0];
01516         theCSCStripPedestalSum += adcCounts[1];
01517         theCSCStripPedestalCount += 2;
01518         
01519         // if there are enough pedestal statistics
01520         if (theCSCStripPedestalCount > 100) {
01521           float pedestal = theCSCStripPedestalSum / theCSCStripPedestalCount;
01522           if (adcCounts[5] > (pedestal + 100)) 
01523             mehCSCStripADC->Fill(adcCounts[4] - pedestal);
01524         }
01525       }
01526     }
01527     
01528     if (verbosity > 1) {
01529       eventout += "\n          Number of CSCStripDigis collected:........ ";
01530       eventout += nStrips;
01531     }
01532     mehCSCStripn->Fill((float)nStrips);
01533   }
01534 
01535   // get CSC Wire information
01536   edm::Handle<CSCWireDigiCollection> wires;  
01537   iEvent.getByLabel(MuCSCWireSrc_, wires);
01538   bool validwires = true;
01539   if (!wires.isValid()) {
01540     LogDebug(MsgLoggerCat)
01541       << "Unable to find muon wires in event!";
01542     validwires = false;
01543   }  
01544   
01545   if (validwires) {
01546     int nWires = 0;
01547     for (CSCWireDigiCollection::DigiRangeIterator j = wires->begin();
01548          j != wires->end();
01549          ++j) {
01550       
01551       std::vector<CSCWireDigi>::const_iterator digiItr = (*j).second.first;
01552       std::vector<CSCWireDigi>::const_iterator endDigi = (*j).second.second;
01553       
01554       for ( ; digiItr != endDigi; ++digiItr) {
01555         ++nWires;
01556         mehCSCWireTime->Fill(digiItr->getTimeBin());
01557       }
01558     }
01559     
01560     if (verbosity > 1) {
01561       eventout += "\n          Number of CSCWireDigis collected:......... ";
01562       eventout += nWires;
01563     }
01564     mehCSCWiren->Fill((float)nWires); 
01565   }
01566 
01567   // get RPC information
01568   // Get the RPC Geometry
01569   edm::ESHandle<RPCGeometry> rpcGeom;
01570   iSetup.get<MuonGeometryRecord>().get(rpcGeom);
01571   if (!rpcGeom.isValid()) {
01572     edm::LogWarning(MsgLoggerCat)
01573       << "Unable to find RPCGeometryRecord in event!";
01574     return;
01575   }
01576   
01577   edm::Handle<edm::PSimHitContainer> rpcsimHit;
01578   iEvent.getByLabel("g4SimHits", "MuonRPCHits", rpcsimHit);
01579   bool validrpcsim = true;
01580   if (!rpcsimHit.isValid()) {
01581     LogDebug(MsgLoggerCat)
01582       << "Unable to find rpcsimHit in event!";
01583     validrpcsim = false;
01584   }   
01585   
01586   edm::Handle<RPCDigiCollection> rpcDigis;  
01587   iEvent.getByLabel(MuRPCSrc_, rpcDigis);
01588   bool validrpcdigi = true;
01589   if (!rpcDigis.isValid()) {
01590     LogDebug(MsgLoggerCat)
01591       << "Unable to find rpcDigis in event!";
01592     validrpcdigi = false;
01593   } 
01594 
01595   // ONLY UNTIL PROBLEM WITH RPC DIGIS IS FIGURED OUT
01596   validrpcdigi = false;
01597 
01598   // Loop on simhits
01599   edm::PSimHitContainer::const_iterator rpcsimIt;
01600   std::map<RPCDetId, std::vector<double> > allsims;
01601 
01602   if (validrpcsim) {
01603     for (rpcsimIt = rpcsimHit->begin(); rpcsimIt != rpcsimHit->end(); 
01604          rpcsimIt++) {
01605       RPCDetId Rsid = (RPCDetId)(*rpcsimIt).detUnitId();
01606       int ptype = rpcsimIt->particleType();
01607       
01608       if (ptype == 13 || ptype == -13) {
01609         std::vector<double> buff;
01610         if (allsims.find(Rsid) != allsims.end() ){
01611           buff= allsims[Rsid];
01612         }
01613         buff.push_back(rpcsimIt->localPosition().x());
01614         allsims[Rsid]=buff;
01615       }
01616     }
01617   }
01618 
01619   // CRASH HAPPENS SOMEWHERE HERE IN FOR DECLARATION
01620   // WHAT IS WRONG WITH rpcDigis?????
01621   if (validrpcdigi) {
01622     int nRPC = 0;
01623     RPCDigiCollection::DigiRangeIterator rpcdetUnitIt;
01624     for (rpcdetUnitIt = rpcDigis->begin(); rpcdetUnitIt != rpcDigis->end(); 
01625          ++rpcdetUnitIt) {
01626       
01627       const RPCDetId Rsid = (*rpcdetUnitIt).first;      
01628       const RPCRoll* roll = 
01629         dynamic_cast<const RPCRoll* >( rpcGeom->roll(Rsid));   
01630       const RPCDigiCollection::Range& range = (*rpcdetUnitIt).second;
01631       
01632       std::vector<double> sims;
01633       if (allsims.find(Rsid) != allsims.end() ){
01634         sims = allsims[Rsid];
01635       }
01636       
01637       int ndigi = 0;
01638       for (RPCDigiCollection::const_iterator rpcdigiIt = range.first;
01639            rpcdigiIt != range.second;
01640            ++rpcdigiIt) {
01641         
01642         ++ndigi;
01643         ++nRPC;
01644       }
01645       
01646       if (sims.size() == 1 && ndigi == 1){
01647         double dis = roll->centreOfStrip(range.first->strip()).x()-sims[0];
01648         
01649         if (Rsid.region() == 0 ){
01650           if (Rsid.ring() == -2)
01651             mehRPCRes[0]->Fill((float)dis);
01652           else if (Rsid.ring() == -1)
01653             mehRPCRes[1]->Fill((float)dis);
01654           else if (Rsid.ring() == 0)
01655             mehRPCRes[2]->Fill((float)dis);
01656           else if (Rsid.ring() == 1)
01657             mehRPCRes[3]->Fill((float)dis);
01658           else if (Rsid.ring() == 2)
01659             mehRPCRes[4]->Fill((float)dis);
01660         }  
01661       }
01662     }
01663     
01664     if (verbosity > 1) {
01665       eventout += "\n          Number of RPCDigis collected:.............. ";
01666       eventout += nRPC;
01667     }
01668     mehRPCMuonn->Fill(float(nRPC));
01669   }
01670   
01671   if (verbosity > 0)
01672     edm::LogInfo(MsgLoggerCat) << eventout << "\n";
01673   
01674   return;
01675 }